* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #333;
    line-height: 1.6;
}
nav {
    background: #1a1a2e;
    color: #fff;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    height: 56px;
}
.nav-brand {
    color: #e94560;
    font-weight: 700;
    font-size: 1.2rem;
    text-decoration: none;
    margin-right: 2rem;
}
.nav-links { display: flex; gap: 0.25rem; }
.nav-links a {
    color: #ccc;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: all 0.2s;
}
.nav-links a:hover { color: #fff; background: rgba(255,255,255,0.1); }
.container { max-width: 1200px; margin: 2rem auto; padding: 0 1rem; }

h1 { font-size: 1.5rem; margin-bottom: 1rem; color: #1a1a2e; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; color: #1a1a2e; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: #e94560;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}
.btn:hover { background: #d63851; }
.btn-primary { background: #0f3460; }
.btn-primary:hover { background: #1a4a7a; }
.btn-secondary { background: #533483; }
.btn-secondary:hover { background: #6a44a0; }
.btn-danger { background: #dc3545; }
.btn-danger:hover { background: #c82333; }
.btn-sm {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    border-radius: 4px;
    background: #e94560;
    color: #fff;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-sm:hover { background: #d63851; }
.btn-sm.btn-danger { background: #dc3545; }
.btn-sm.btn-danger:hover { background: #c82333; }

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 1rem;
}
th, td { padding: 0.6rem 0.75rem; text-align: left; font-size: 0.9rem; }
th { background: #f0f2f5; font-weight: 600; color: #555; }
tr:not(:last-child) td { border-bottom: 1px solid #eee; }
tr:hover td { background: #f8f9fa; }
.actions { display: flex; gap: 0.35rem; align-items: center; flex-wrap: wrap; }

.form { max-width: 500px; background: #fff; padding: 1.5rem; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,0.08); margin-bottom: 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; color: #444; }
.form-group input, .form-group select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: #e94560; }
.form-group small { display: block; margin-top: 0.25rem; }
.form-actions { margin-top: 1.25rem; display: flex; gap: 0.5rem; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: #fff;
    padding: 1.25rem;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    text-align: center;
}
.stat-number { display: block; font-size: 2rem; font-weight: 700; color: #e94560; }
.stat-label { font-size: 0.85rem; color: #888; }

.quick-actions { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }

.section { margin-top: 1.5rem; }

.info-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; margin-bottom: 1.5rem; }
.info-card {
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.info-label { display: block; font-size: 0.75rem; color: #888; text-transform: uppercase; letter-spacing: 0.5px; }
.info-value { font-size: 1rem; font-weight: 600; color: #1a1a2e; }

.scan-area { margin-bottom: 1.5rem; }
.scan-area .form { max-width: 500px; }

.student-list { max-height: 400px; overflow-y: auto; }
.student-row {
    display: flex;
    gap: 6px;
    margin-bottom: 0.4rem;
    align-items: center;
}
.student-id-input {
    flex: 0 0 140px;
    padding: 0.45rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}
.student-name-input {
    flex: 1;
    padding: 0.45rem 0.6rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}
.student-id-input:focus, .student-name-input:focus { outline: none; border-color: #e94560; }
.form-students { max-width: 600px; }

.text-muted { color: #888; font-size: 0.85rem; }
.unused-code { font-family: monospace; font-size: 1.1rem; font-weight: 600; color: #dc3545; }

.barcode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 4px;
    margin: 0.75rem 0 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}
.bc-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3px 2px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: monospace;
    border: 1px solid #ddd;
    transition: all 0.2s;
    min-height: 38px;
    justify-content: center;
}
.bc-code {
    font-weight: 700;
    font-size: 0.8rem;
}
.bc-student {
    font-weight: 400;
    font-size: 0.65rem;
    color: inherit;
    opacity: 0.85;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bc-delivered {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}
.bc-scanned {
    background: #d6ecff;
    border-color: #b8daff;
    color: #004085;
    box-shadow: 0 0 0 2px #004085;
}
.bc-pending {
    background: #fff;
    color: #999;
}
.bc-pending:hover {
    background: #f0f0f0;
}
.barcode-progress {
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.25rem;
}
#barcode-grid-container {
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}
#barcode-grid-container h3 {
    margin-bottom: 0.25rem;
    font-size: 1rem;
    color: #1a1a2e;
}
.student-input {
    width: 120px;
    padding: 0.25rem 0.4rem;
    border: 1px solid #e94560;
    border-radius: 4px;
    font-size: 0.85rem;
}
.student-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(233,69,96,0.3);
}
.edit-error {
    font-size: 0.75rem;
    margin-top: 2px;
}
.filter-row td {
    padding: 4px 6px;
    background: #fafbfc;
}
.filter-input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.8rem;
    box-sizing: border-box;
}
.filter-input:focus {
    outline: none;
    border-color: #e94560;
}

.barcode-page {
    max-width: 560px;
    margin: 0 auto;
}
.bc-hero {
    background: #1a1a2e;
    color: #fff;
    text-align: center;
    padding: 2rem 1rem;
    border-radius: 10px;
    margin-bottom: 1.25rem;
}
.bc-hero-code {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    font-family: monospace;
    letter-spacing: 2px;
    color: #e94560;
}
.bc-hero-task {
    display: block;
    font-size: 0.9rem;
    color: #ccc;
    margin-top: 0.35rem;
}
