:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-soft: #eff6ff;
    --success: #10b981;
    --success-soft: #ecfdf5;
    --warning: #f59e0b;
    --danger: #ef4444;
    --pink: #ec4899;
    --boy: #3b82f6;
    --girl: #ec4899;
    --gray: #6b7280;
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2937;
    --text-2: #4b5563;
    --muted: #9ca3af;
    --border: #e8ebf2;
    --shadow: 0 1px 3px rgba(17, 24, 39, .06), 0 1px 2px rgba(17, 24, 39, .04);
    --radius: 14px;
    --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
.boot { padding: 60px; text-align: center; color: var(--muted); }
button { font-family: inherit; cursor: pointer; }
a { color: var(--primary); text-decoration: none; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: #ffffff;
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: fixed; top: 0; bottom: 0; left: 0;
    z-index: 40;
    transition: transform .25s ease;
}
.brand {
    padding: 18px 20px;
    display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid var(--border);
}
.brand .logo {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #60a5fa);
    color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.brand .title { font-weight: 700; font-size: 15px; }
.brand .sub { font-size: 11px; color: var(--muted); }

.nav { flex: 1; overflow-y: auto; padding: 10px 10px 20px; }
.nav-group-title {
    font-size: 11px; color: var(--muted); padding: 14px 14px 6px; font-weight: 600; letter-spacing: .04em;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; border-radius: 10px; color: var(--text-2);
    cursor: pointer; margin: 2px 0; font-size: 14px; transition: all .15s;
    user-select: none;
}
.nav-item .ico { width: 20px; text-align: center; font-size: 16px; }
.nav-item:hover { background: var(--primary-soft); color: var(--primary-dark); }
.nav-item.active { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(59,130,246,.3); }
.nav-item.active .ico { filter: brightness(1.2); }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar {
    height: 60px; background: #fff; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px; padding: 0 20px;
    position: sticky; top: 0; z-index: 30;
}
.topbar .hamburger { display: none; font-size: 22px; background: none; border: none; color: var(--text-2); }
.topbar .class-info { display: flex; flex-direction: column; }
.topbar .class-info .cn { font-weight: 700; font-size: 15px; }
.topbar .class-info .meta { font-size: 12px; color: var(--muted); }
.topbar .spacer { flex: 1; }
.topbar .pill {
    background: var(--primary-soft); color: var(--primary-dark);
    padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.topbar .teacher { font-size: 13px; color: var(--text-2); }
.topbar .avatar-sm {
    width: 32px; height: 32px; border-radius: 50%; color: #fff; font-weight: 600;
    display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.content { padding: 20px; flex: 1; }

/* ---------- Cards & grids ---------- */
.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.card h3 { margin: 0 0 14px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.card .card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 8px; }
.card .card-head h3 { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card {
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat-card .label { font-size: 13px; color: var(--muted); }
.stat-card .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-card .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); }
.stat-card.green .bar { background: var(--success); }
.stat-card.pink .bar { background: var(--pink); }
.stat-card.amber .bar { background: var(--warning); }

/* ---------- Buttons ---------- */
.btn {
    border: 1px solid var(--border); background: #fff; color: var(--text-2);
    padding: 8px 14px; border-radius: 10px; font-size: 13px; transition: all .15s;
    display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { filter: brightness(.95); color: #fff; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl th { background: #f9fafb; color: var(--text-2); font-weight: 600; position: sticky; top: 0; }
table.tbl tbody tr:hover { background: #fafbff; }
table.tbl td.wrap { white-space: normal; }

/* ---------- Badges & tags ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge.blue { background: var(--primary-soft); color: var(--primary-dark); }
.badge.green { background: var(--success-soft); color: #047857; }
.badge.pink { background: #fdf2f8; color: #be185d; }
.badge.gray { background: #f3f4f6; color: var(--gray); }
.badge.amber { background: #fffbeb; color: #b45309; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; background: #eef2ff; color: #4338ca; font-size: 12px; margin: 2px; }

/* ---------- Avatar ---------- */
.avatar {
    width: 38px; height: 38px; border-radius: 50%; color: #fff; font-weight: 600;
    display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex: none;
}
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.boy { background: linear-gradient(135deg, #60a5fa, #3b82f6); }
.avatar.girl { background: linear-gradient(135deg, #f472b6, #ec4899); }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.field input, .field select, .field textarea {
    border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; font-size: 14px; font-family: inherit;
    background: #fff; color: var(--text); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field textarea { resize: vertical; min-height: 70px; }
.field.full { grid-column: 1 / -1; }

/* ---------- Modal ---------- */
.modal-mask {
    position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 100;
    display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal {
    background: #fff; border-radius: 16px; width: 100%; max-width: 720px; box-shadow: 0 20px 50px rgba(0,0,0,.25);
    animation: pop .18s ease;
}
@keyframes pop { from { transform: translateY(8px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.x { background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }

/* ---------- Misc ---------- */
.alert { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.alert.info { background: var(--primary-soft); color: var(--primary-dark); }
.alert.warn { background: #fffbeb; color: #b45309; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.privacy-note { color: var(--danger); font-size: 12px; }
.timeline { border-left: 2px solid var(--border); padding-left: 16px; margin-left: 6px; }
.timeline .item { position: relative; padding: 0 0 16px; }
.timeline .item::before { content: ''; position: absolute; left: -23px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.timeline .item .date { font-size: 12px; color: var(--muted); }
.timeline .item .ttl { font-weight: 600; }
.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 240px; }
.flex { display: flex; }
.between { justify-content: space-between; }
.items-center { align-items: center; }
.gap8 { gap: 8px; }
.gap12 { gap: 12px; }
.wrap { flex-wrap: wrap; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.section-title { font-size: 13px; color: var(--muted); font-weight: 700; margin: 16px 0 8px; }

/* ---------- Seat grid ---------- */
.seat-grid { display: inline-grid; gap: 8px; padding: 10px; background: #f8fafc; border-radius: 12px; border: 1px dashed var(--border); }
.seat-grid .dais {
    grid-column: 1 / -1; text-align: center; background: var(--primary-soft); color: var(--primary-dark);
    border-radius: 8px; padding: 6px; font-weight: 600; font-size: 13px; margin-bottom: 4px;
}
.seat {
    width: 84px; height: 64px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer;
    transition: all .12s; position: relative; user-select: none;
}
.seat:hover { border-color: var(--primary); transform: translateY(-1px); }
.seat.filled.boy { background: #eef5ff; border-color: #bfdbfe; }
.seat.filled.girl { background: #fdf2f8; border-color: #fbcfe8; }
.seat.empty { background: #f9fafb; color: var(--muted); border-style: dashed; }
.seat .sn { font-weight: 700; font-size: 14px; }
.seat .sno { font-size: 11px; color: var(--muted); }
.seat.selected { outline: 3px solid var(--primary); }
.seat.dragging { opacity: .5; }

/* ---------- Login ---------- */
.login-wrap { position: fixed; inset: 0; background: linear-gradient(135deg, #3b82f6, #6366f1); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.login-card { background: #fff; border-radius: 18px; padding: 32px; width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card .logo { width: 52px; height: 52px; border-radius: 14px; background: linear-gradient(135deg, var(--primary), #60a5fa); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 26px; margin: 0 auto 14px; }
.login-card h2 { text-align: center; margin: 0 0 4px; }
.login-card p { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 13px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 860px) {
    :root { --sidebar-w: 0px; }
    .sidebar { transform: translateX(-100%); width: 240px; box-shadow: 0 0 40px rgba(0,0,0,.2); }
    .sidebar.open { transform: none; }
    .main { margin-left: 0; }
    .topbar .hamburger { display: block; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 14px; }
}
@media (max-width: 520px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .card { padding: 14px; }
    .topbar .class-info .meta { display: none; }
    .seat { width: 72px; height: 58px; }
}
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 35; }
