:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f8fbfd;
  --text: #08162d;
  --muted: #64748b;
  --border: #dbe4ee;
  --navy: #071b3d;
  --teal: #0ea5a4;
  --blue: #2563eb;
  --violet: #7c3aed;
  --amber: #f59e0b;
  --green: #10b981;
  --red: #ef4444;
  --shadow: 0 18px 45px rgba(15, 27, 51, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 246px;
  padding: 22px 10px;
  background: linear-gradient(180deg, #071b3d, #041124);
  color: #e7eefb;
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; padding: 0 10px 12px; }
.brand-mark { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.34); border-radius: var(--radius); background: rgba(14,165,164,.18); color: #6ee7df; }
.brand strong, .profile-button strong { display: block; font-size: 15px; line-height: 1.2; }
.brand small, .profile-button small { display: block; color: #94a3b8; font-size: 12px; margin-top: 2px; }

.nav-list { display: grid; gap: 4px; }
.nav-list a { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 10px 14px; border-radius: var(--radius); color: #d8e2f1; text-decoration: none; font-size: 14px; font-weight: 750; }
.nav-list a svg { width: 18px; height: 18px; }
.nav-list a.active, .nav-list a:hover { background: linear-gradient(90deg, #0ea5a4, #0b8f9b); color: #fff; }

.institute-card { margin-top: auto; padding: 14px; border: 1px solid rgba(255,255,255,.16); border-radius: var(--radius); background: rgba(255,255,255,.06); }
.institute-card span, .institute-card small { display: block; color: #a9b8cf; font-size: 12px; }
.institute-card strong { display: block; margin: 5px 0 2px; color: #fff; font-size: 14px; }

.main-shell { margin-left: 246px; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 8; height: 68px; padding: 12px 24px; display: flex; align-items: center; gap: 16px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--border); backdrop-filter: blur(14px); }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: #344054; display: grid; place-items: center; }
.icon-button.has-dot { position: relative; color: var(--amber); font-weight: 900; }
.icon-button.has-dot::after { content: ""; position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 999px; background: var(--teal); }
.menu-button { display: none; }
.menu-button span { width: 16px; height: 2px; background: currentColor; display: block; }

.search-box { min-width: 260px; max-width: 520px; flex: 1; height: 42px; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); display: flex; align-items: center; gap: 10px; padding: 0 12px; }
.search-box svg { color: #8a94a6; width: 18px; }
.search-box input { flex: 1; border: 0; outline: 0; min-width: 0; color: var(--text); background: transparent; }
.search-box kbd { border: 1px solid var(--border); border-radius: 5px; padding: 3px 7px; color: #8792a5; background: #f8fafc; font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.profile-button { height: 42px; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; color: var(--text); }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 999px; background: #dff7f4; color: #087a7a; font-size: 12px; font-weight: 900; }
.avatar.large { width: 46px; height: 46px; }

.content { padding: 24px 24px 38px; }
.page-header { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.page-header h1 { margin: 0; font-size: 28px; line-height: 1.15; letter-spacing: 0; }
.page-header p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.header-actions { display: flex; gap: 10px; }

.primary-button, .secondary-button, .text-button, .join-button { border-radius: var(--radius); min-height: 38px; padding: 0 14px; border: 1px solid transparent; font-weight: 800; font-size: 13px; }
.primary-button { background: var(--teal); color: #fff; }
.secondary-button { background: var(--surface); color: var(--text); border-color: var(--border); }
.text-button { background: transparent; color: var(--blue); padding: 0; min-height: auto; }
.join-button { background: #e6fffb; color: #087a7a; border-color: #99f6e4; }

.panel, .kpi-card, .student-card, .course-card, .teacher-card, .phone-preview, .now-card, .scan-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-ops { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); gap: 14px; margin-bottom: 14px; }
.now-card { padding: 20px; background: linear-gradient(135deg, #071b3d, #0f766e); color: #fff; }
.now-card span, .scan-card span { color: #b7d9e4; font-size: 13px; font-weight: 800; }
.now-card h2 { margin: 8px 0; font-size: 30px; }
.now-card p { margin: 0; color: #d8eef4; }
.now-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.scan-card { padding: 18px; }
.scan-card span { display: flex; align-items: center; gap: 8px; color: var(--text); }
.scan-card form { display: flex; gap: 10px; margin: 12px 0 8px; }
.scan-card input, .scan-form input, .action-form input, .settings-form input { height: 42px; border: 1px solid var(--border); border-radius: var(--radius); padding: 0 12px; outline: 0; color: var(--text); background: #fff; }
.scan-card input { flex: 1; min-width: 0; }
.scan-card small { color: var(--muted); }

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi-card { display: flex; align-items: center; gap: 14px; padding: 18px; min-width: 0; }
.kpi-card span { color: var(--muted); font-size: 13px; }
.kpi-card strong { display: block; margin-top: 6px; font-size: 24px; line-height: 1.15; }
.kpi-card small { display: block; margin-top: 6px; color: #0f9f6e; font-size: 12px; }
.kpi-icon { width: 48px; height: 48px; flex: 0 0 48px; display: grid; place-items: center; border-radius: var(--radius); color: #fff !important; }
.kpi-icon.teal { background: var(--teal); }
.kpi-icon.blue { background: var(--blue); }
.kpi-icon.violet { background: var(--violet); }
.kpi-icon.amber { background: var(--amber); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, .85fr) 294px; gap: 16px; align-items: start; }
.right-rail { display: grid; gap: 16px; }
.panel { padding: 0; overflow: hidden; }
.panel-header { min-height: 52px; padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-header h2 { margin: 0; font-size: 16px; line-height: 1.2; }
.muted { color: var(--muted); font-size: 13px; }

.status { display: inline-grid; place-items: center; min-width: 68px; height: 26px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 900; background: #e8f7ef; color: #087a4d; white-space: nowrap; }
.status.warning, .status.upcoming { background: #fff7e6; color: #b45309; }
.status.blocked, .status.overdue, .status.offline { background: #feeceb; color: #c01f1f; }
.status.paid, .status.live, .status.online, .status.active { background: #def7ec; color: #087a4d; }
.status.neutral { background: #edf2ff; color: #3151b7; }

.class-list { display: grid; }
.class-row { width: 100%; border: 0; border-bottom: 1px solid var(--border); background: #fff; display: grid; grid-template-columns: 76px 1fr auto; align-items: center; gap: 12px; padding: 14px 16px; text-align: left; }
.class-row.selected, .class-row:hover { background: #f2fbfb; }
.class-row time { font-weight: 900; }
.class-row time small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.class-row strong, .student-card strong, .course-card strong { display: block; font-size: 14px; }
.class-row span, .student-card span, .course-card span, td span { color: var(--muted); font-size: 12px; }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; }
.quick-grid button { min-height: 58px; display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid #bdebe8; border-radius: var(--radius); background: #f5fffe; color: #087a7a; font-weight: 900; font-size: 12px; }

.fee-list { display: grid; }
.fee-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.fee-row strong { display: block; margin-bottom: 3px; }
.fee-row span { display: block; color: var(--muted); font-size: 12px; }
.fee-row:last-child { border-bottom: 0; }
.fee-panel { margin-top: 14px; }

.phone-preview { position: relative; min-height: 282px; padding: 28px 16px 16px; background: #101828; color: #fff; }
.phone-speaker { position: absolute; top: 10px; left: 50%; width: 68px; height: 6px; border-radius: 999px; transform: translateX(-50%); background: #344054; }
.phone-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,.12); }
.phone-preview p, .phone-preview small { color: #b6c2d4; }
.phone-preview p { margin: 16px 0 6px; }
.phone-preview strong { display: block; }

.qr-grid { width: 92px; height: 92px; padding: 6px; display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.qr-grid i { border-radius: 2px; background: #e8eef6; }
.qr-grid i.on { background: #071b3d; }
.qr-code { width: 96px; height: 96px; display: block; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; padding: 5px; }
.qr-code svg { width: 100%; height: 100%; display: block; fill: #071b3d; stroke: none; }
.barcode { height: 42px; display: flex; align-items: stretch; gap: 2px; margin: 8px 0; padding: 6px; border-radius: var(--radius); background: #fff; border: 1px solid var(--border); }
.barcode i { display: block; background: #071b3d; }

.student-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.student-card { padding: 16px; display: grid; gap: 12px; }
.student-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.id-zone { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; padding: 12px; border-radius: var(--radius); background: var(--surface-2); }
.id-zone b { display: block; font-size: 18px; }
.student-card p { margin: 0; color: var(--muted); font-size: 13px; }
.student-actions { display: flex; justify-content: space-between; gap: 10px; align-items: center; }

.attendance-layout { display: grid; grid-template-columns: minmax(320px, .75fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.scanner-panel { overflow: visible; }
.class-picker { max-height: 280px; overflow: auto; border-bottom: 1px solid var(--border); }
.scan-form { display: grid; gap: 12px; padding: 16px; }
.scan-form label, .settings-form label, .action-form label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 800; }
.scan-result { margin: 0 16px 16px; padding: 12px; border-radius: var(--radius); background: #f2fbfb; color: #0f766e; font-size: 13px; }

.timetable-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.timetable-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.timetable-card.selected { border-color: rgba(14, 165, 164, .55); }
.timetable-main { width: 100%; border: 0; background: #fff; display: grid; grid-template-columns: 78px 1fr auto; align-items: center; gap: 12px; padding: 16px; text-align: left; }
.timetable-main:hover { background: #f2fbfb; }
.timetable-main time { font-weight: 900; }
.timetable-main time small { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.timetable-main strong { display: block; }
.timetable-main span { color: var(--muted); font-size: 12px; }
.assigned-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 16px; }
.assigned-list span { padding: 7px 9px; border-radius: 999px; background: #eef6ff; color: #3151b7; font-size: 12px; font-weight: 800; }

.course-board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.course-card { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 14px; padding: 16px; }
.course-symbol { width: 50px; height: 50px; display: grid; place-items: center; border-radius: var(--radius); background: var(--course-color); color: #fff !important; font-weight: 900; }
.progress-bar { height: 7px; margin-top: 10px; border-radius: 999px; background: #edf1f7; overflow: hidden; }
.progress-bar span { display: block; height: 100%; border-radius: inherit; background: var(--teal); }

.teacher-grid, .report-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.teacher-card, .report-card { padding: 18px; display: grid; gap: 12px; }
.teacher-card h2 { margin: 0; font-size: 16px; }
.teacher-card p, .report-card p { margin: 0; color: var(--muted); font-size: 13px; }
.teacher-stats { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.report-card strong { font-size: 28px; }
.report-card span { color: var(--muted); font-size: 13px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; vertical-align: middle; }
th { color: #516075; background: var(--surface-2); font-size: 12px; font-weight: 900; }
.empty-cell { padding: 24px; color: var(--muted); text-align: center; }

.settings-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 18px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 18px; background: rgba(7,27,61,.45); }
.modal { width: min(540px, 100%); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: 0 24px 70px rgba(0,0,0,.22); }
.action-form { display: grid; gap: 14px; padding: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 30; padding: 12px 14px; border-radius: var(--radius); background: #071b3d; color: #fff; box-shadow: var(--shadow); font-size: 13px; }
.toast.error { background: #b91c1c; }
.toast.success { background: #047857; }

@media (max-width: 1180px) {
  .kpi-grid, .teacher-grid, .report-grid, .student-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .hero-ops, .attendance-layout { grid-template-columns: 1fr; }
  .right-rail { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform 180ms ease; }
  .nav-open .sidebar { transform: translateX(0); }
  .main-shell { margin-left: 0; }
  .menu-button { display: grid; }
  .profile-button span:last-child, .search-box kbd { display: none; }
  .content { padding: 18px 14px 28px; }
  .topbar { padding: 12px 14px; }
  .page-header, .header-actions, .scan-card form { flex-direction: column; align-items: stretch; }
  .kpi-grid, .right-rail, .course-board, .teacher-grid, .report-grid, .settings-form, .student-grid { grid-template-columns: 1fr; }
  .timetable-grid { grid-template-columns: 1fr; }
  .student-card { padding: 14px; }
  .id-zone { grid-template-columns: 86px 1fr; }
  .qr-grid { width: 82px; height: 82px; }
  .qr-code { width: 84px; height: 84px; }
  table { min-width: 640px; }
}

@media (max-width: 520px) {
  .topbar-actions .icon-button { display: none; }
  .search-box { min-width: 0; }
  .quick-grid { grid-template-columns: 1fr; }
  .class-row { grid-template-columns: 64px 1fr; }
  .class-row .status { grid-column: 2; justify-self: start; }
  .timetable-main { grid-template-columns: 64px 1fr; }
  .timetable-main .status { grid-column: 2; justify-self: start; }
  table { min-width: 520px; }
  th, td { padding: 12px 10px; }
}
