/* 369 Tesla Learning Portal — design system
   Navy / white base, blue primary, teal accent, small purple highlights. No external assets. */

:root {
  --navy-950: #060d22;
  --navy-900: #0a1633;
  --navy-800: #102149;
  --navy-700: #1a2f63;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-50: #eff6ff;
  --teal-500: #14b8a6;
  --teal-400: #2dd4bf;
  --teal-50: #f0fdfa;
  --violet-600: #7c3aed;
  --violet-50: #f5f3ff;
  --amber-600: #d97706;
  --amber-50: #fffbeb;
  --red-600: #dc2626;
  --red-50: #fef2f2;
  --green-600: #059669;
  --green-50: #ecfdf5;

  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8f2;
  --border-strong: #cfd7e6;
  --text: #0f1b3d;
  --text-2: #475572;
  --text-3: #7a88a6;
  --primary: var(--blue-600);
  --primary-ink: #ffffff;
  --focus: 0 0 0 3px rgba(37, 99, 235, 0.28);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 61, 0.06);
  --shadow: 0 1px 2px rgba(15, 27, 61, 0.05), 0 4px 16px rgba(15, 27, 61, 0.06);
  --shadow-lg: 0 20px 50px rgba(6, 13, 34, 0.22);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --sidebar-w: 256px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14.5px; line-height: 1.55; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { vertical-align: middle; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 0.75rem; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.icon { flex-shrink: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); font-size: 0.86em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; min-width: 0; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 600 13.5px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:hover { background: var(--surface-2); border-color: #b9c4da; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.btn-teal { background: var(--teal-500); border-color: var(--teal-500); color: #042f2e; }
.btn-teal:hover { background: #0d9488; border-color: #0d9488; color: #fff; }
.btn-danger { background: var(--surface); border-color: #f3c4c4; color: var(--red-600); }
.btn-danger:hover { background: var(--red-50); }
.btn-danger-solid { background: var(--red-600); border-color: var(--red-600); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(15, 27, 61, 0.05); border-color: transparent; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-loading { opacity: 0.6; pointer-events: none; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: inherit; cursor: pointer; }
.icon-btn:hover { background: rgba(127, 140, 170, 0.14); }

/* ---------------- Forms ---------------- */
label, .label { display: block; font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.field .hint { font-size: 12.5px; color: var(--text-3); margin-top: 5px; }
.field .error { font-size: 12.5px; color: var(--red-600); margin-top: 5px; font-weight: 500; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--red-600); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=search], input[type=tel], input[type=url], select, textarea {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text); font: 400 14px/1.4 var(--font); transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #7a88a6 50%), linear-gradient(135deg, #7a88a6 50%, transparent 50%); background-position: calc(100% - 17px) 17px, calc(100% - 12px) 17px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue-500); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; margin-bottom: 10px; }
.check input { margin-top: 3px; }
.check small { display: block; color: var(--text-3); font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; padding-top: 8px; }
.input-group { display: flex; gap: 8px; }
.input-group > input { flex: 1; }

/* ---------------- Cards / surfaces ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2 { font-size: 1rem; }
.card-body { padding: 18px 22px; }
.card-foot { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 30px 0 14px; }
.section-title h2 { font-size: 1.08rem; }
.section-title a { font-size: 13px; font-weight: 600; }

/* ---------------- Stat tiles ---------------- */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .k { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.stat .v { font-size: 1.65rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { font-size: 12px; color: var(--text-3); }
.stat.accent { border-top: 3px solid var(--primary); }
.stat.teal { border-top: 3px solid var(--teal-500); }
.stat.violet { border-top: 3px solid var(--violet-600); }
.stat.amber { border-top: 3px solid var(--amber-600); }

/* ---------------- Badges ---------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap; border: 1px solid transparent; }
.badge-green { background: var(--green-50); color: #047857; border-color: #b7ebd6; }
.badge-amber { background: var(--amber-50); color: #b45309; border-color: #f7d9a8; }
.badge-red { background: var(--red-50); color: #b91c1c; border-color: #f5c2c2; }
.badge-blue { background: var(--blue-50); color: #1d4ed8; border-color: #c7d9fb; }
.badge-violet { background: var(--violet-50); color: #6d28d9; border-color: #ddd0fb; }
.badge-teal { background: var(--teal-50); color: #0f766e; border-color: #b4ece3; }
.badge-slate { background: #f1f4f9; color: #334155; border-color: #dfe5ef; }
.badge-gray { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }

/* ---------------- Tables ---------------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-3); font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfe; }
.table .actions { text-align: right; white-space: nowrap; }
.who { display: flex; align-items: center; gap: 10px; min-width: 180px; }
.who b { display: block; font-weight: 600; }
.who small { color: var(--text-3); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12.5px; color: #fff; background: linear-gradient(135deg, var(--blue-600), var(--violet-600)); flex-shrink: 0; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }

/* ---------------- Toolbar / filters ---------------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 22px; border-bottom: 1px solid var(--border); }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; min-width: 140px; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px; font-size: 13px; }
.pagination a, .pagination span.disabled { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.pagination span.disabled { color: var(--text-3); }
.pagination .page-info { color: var(--text-2); }

/* ---------------- Empty / skeleton ---------------- */
.empty { text-align: center; padding: 42px 24px; color: var(--text-2); }
.empty .empty-icon { width: 54px; height: 54px; border-radius: 16px; display: inline-grid; place-items: center; background: var(--blue-50); color: var(--primary); margin-bottom: 12px; }
.empty h3 { margin-bottom: 6px; }
.skeleton { background: linear-gradient(90deg, #eef1f7 25%, #f6f8fc 50%, #eef1f7 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------- Alerts ---------------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius); border: 1px solid; font-size: 13.5px; }
.alert-info { background: var(--blue-50); border-color: #c7d9fb; color: #1e3a8a; }
.alert-warn { background: var(--amber-50); border-color: #f7d9a8; color: #92400e; }
.alert-danger { background: var(--red-50); border-color: #f5c2c2; color: #991b1b; }
.alert-success { background: var(--green-50); border-color: #b7ebd6; color: #065f46; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------------- Admin shell ---------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--navy-900); color: #c3cde6; display: flex; flex-direction: column; padding: 18px 14px; z-index: 40; }
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; color: #fff; text-decoration: none !important; }
.brand-mark { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; font-weight: 800; font-size: 13px; color: #fff; background: linear-gradient(135deg, var(--blue-600) 0%, var(--violet-600) 100%); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15); letter-spacing: -0.02em; }
.brand-text b { display: block; font-size: 15px; letter-spacing: -0.01em; color: #fff; }
.brand-text small { display: block; font-size: 11px; color: #8b9bc4; letter-spacing: 0.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: #6b7ba6; padding: 16px 12px 6px; font-weight: 700; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: #c3cde6; font-weight: 550; font-size: 13.5px; text-decoration: none; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav a.active { background: linear-gradient(90deg, rgba(37, 99, 235, 0.35), rgba(37, 99, 235, 0.12)); color: #fff; box-shadow: inset 3px 0 0 var(--teal-400); }
.nav a .icon { opacity: 0.85; }
.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; color: #fff; }
.sidebar-user small { display: block; color: #8b9bc4; font-size: 11.5px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; height: 64px; padding: 0 28px; background: rgba(244, 246, 251, 0.86); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.topbar .search { flex: 1; max-width: 460px; position: relative; }
.topbar .search input { padding-left: 38px; background: var(--surface); }
.topbar .search .icon { position: absolute; left: 12px; top: 11px; color: var(--text-3); }
.content { padding: 26px 28px 60px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.crumbs { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.crumbs a { color: var(--text-2); }
.menu-toggle { display: none; }
.scrim { display: none; }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; border: 0; background: none; font: 600 13.5px var(--font); color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.tabs a.active, .tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------------- Lists ---------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .meta { font-size: 12.5px; color: var(--text-3); }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 10px 16px; font-size: 13.5px; }
.kv dt { color: var(--text-3); font-weight: 600; }
.kv dd { margin: 0; word-break: break-word; }

/* ---------------- Charts (server-rendered SVG) ---------------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 8px 4px 0; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .bar span { width: 100%; max-width: 30px; border-radius: 6px 6px 3px 3px; background: linear-gradient(180deg, var(--blue-500), var(--blue-600)); min-height: 2px; }
.bars .bar small { font-size: 10.5px; color: var(--text-3); margin-top: 6px; white-space: nowrap; }
.bars .bar:hover span { background: var(--teal-500); }
.meter { height: 8px; border-radius: 999px; background: #e8edf6; overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue-600), var(--teal-500)); }

/* ---------------- Modal / toast ---------------- */
dialog.modal { border: 0; padding: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); color: var(--text); }
dialog.modal::backdrop { background: rgba(6, 13, 34, 0.55); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px 22px; overflow-y: auto; max-height: calc(100vh - 200px); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 40px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; background: var(--navy-900); color: #fff; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: toast-in 0.2s ease-out; border-left: 4px solid var(--teal-400); }
.toast.error { border-left-color: #f87171; }
.toast.warn { border-left-color: #fbbf24; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
.cred-box { background: var(--navy-900); color: #e2e8ff; border-radius: 12px; padding: 16px 18px; font-family: var(--mono); font-size: 13.5px; line-height: 1.9; white-space: pre-wrap; word-break: break-all; }

/* ---------------- Auth pages ---------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr); background: var(--surface); }
.auth-hero { position: relative; overflow: hidden; background: radial-gradient(1000px 500px at 85% 10%, rgba(20, 184, 166, 0.25), transparent 60%), radial-gradient(700px 500px at 0% 100%, rgba(124, 58, 237, 0.28), transparent 60%), linear-gradient(160deg, var(--navy-950), var(--navy-800)); color: #dbe4ff; padding: 48px 56px; display: flex; flex-direction: column; }
.auth-hero .grid-lines { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(circle at 60% 40%, #000 20%, transparent 75%); }
.auth-hero > * { position: relative; }
.auth-hero h1 { color: #fff; font-size: 2.5rem; letter-spacing: -0.03em; margin: auto 0 14px; max-width: 520px; line-height: 1.12; }
.auth-hero h1 span { background: linear-gradient(90deg, var(--teal-400), #a78bfa); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-hero p { color: #a9b6d8; max-width: 470px; font-size: 15px; }
.auth-points { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 26px; font-size: 13px; color: #c3cde6; }
.auth-points div { display: flex; align-items: center; gap: 8px; }
.auth-points .icon { color: var(--teal-400); }
.auth-foot { margin-top: 42px; font-size: 12px; color: #6f7fa8; letter-spacing: 0.04em; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 28px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-card .lead { color: var(--text-2); margin-bottom: 26px; }
.pw-wrap { position: relative; }
.pw-wrap button { position: absolute; right: 6px; top: 5px; height: 30px; border: 0; background: none; color: var(--text-3); font: 600 12px var(--font); cursor: pointer; padding: 0 8px; }
.minimal-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(900px 400px at 50% -10%, rgba(37, 99, 235, 0.12), transparent), var(--bg); }
.error-card { max-width: 520px; width: 100%; text-align: center; padding: 40px 32px; }
.error-code { display: inline-block; font: 700 12px/1 var(--font); letter-spacing: 0.14em; color: var(--teal-500); background: var(--navy-900); padding: 8px 12px; border-radius: 999px; margin-bottom: 16px; }

/* ---------------- Student shell ---------------- */
.s-header { position: sticky; top: 0; z-index: 30; background: var(--navy-900); color: #dbe4ff; box-shadow: 0 1px 0 rgba(255,255,255,0.04); }
.s-header-inner { max-width: 1320px; margin: 0 auto; height: 66px; display: flex; align-items: center; gap: 18px; padding: 0 24px; }
.s-nav { display: flex; gap: 4px; margin-left: 12px; }
.s-nav a { color: #b7c3e3; padding: 8px 12px; border-radius: 9px; font-weight: 600; font-size: 13.5px; text-decoration: none; }
.s-nav a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.s-nav a.active { background: rgba(37, 99, 235, 0.3); color: #fff; }
.s-search { margin-left: auto; position: relative; width: 260px; }
.s-search input { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.12); color: #fff; padding-left: 36px; height: 38px; }
.s-search input::placeholder { color: #8b9bc4; }
.s-search .icon { position: absolute; left: 11px; top: 10px; color: #8b9bc4; }
.s-user { display: flex; align-items: center; gap: 10px; color: #fff; }
.s-user .menu { position: relative; }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); min-width: 220px; padding: 6px; display: none; }
.dropdown.open { display: block; }
.dropdown a, .dropdown button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px; color: var(--text); font: 550 13.5px var(--font); background: none; border: 0; cursor: pointer; text-decoration: none; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); }
.dropdown .who { padding: 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.s-main { max-width: 1320px; margin: 0 auto; padding: 28px 24px 70px; }
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 30px 32px; color: #dbe4ff; background: radial-gradient(700px 300px at 90% 0%, rgba(20, 184, 166, 0.28), transparent 60%), radial-gradient(600px 300px at 0% 120%, rgba(124, 58, 237, 0.3), transparent 60%), linear-gradient(135deg, var(--navy-900), var(--navy-700)); }
.hero h1 { color: #fff; font-size: 1.75rem; }
.hero p { color: #a9b6d8; margin: 6px 0 0; }
.hero-stats { display: flex; gap: 28px; margin-top: 22px; flex-wrap: wrap; }
.hero-stats div b { display: block; font-size: 1.4rem; color: #fff; font-variant-numeric: tabular-nums; }
.hero-stats div small { color: #93a3cc; font-size: 12px; }
.hero .btn { margin-top: 18px; }

/* course + content cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }
.course-card, .app-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); transition: box-shadow 0.18s, transform 0.18s, border-color 0.18s; color: var(--text); text-decoration: none !important; }
.course-card:hover, .app-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--border-strong); }
.thumb { position: relative; aspect-ratio: 16 / 9; background: var(--navy-800); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .badges { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; gap: 6px; }
.thumb .lock { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(6, 13, 34, 0.55); color: #fff; font-weight: 650; font-size: 13px; backdrop-filter: blur(1px); }
.thumb .lock span { display: inline-flex; align-items: center; gap: 8px; background: rgba(6, 13, 34, 0.75); padding: 8px 14px; border-radius: 999px; }
.card-content { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-content h3 { font-size: 15.5px; }
.card-content .desc { color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.card-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); }
.card-meta span { display: inline-flex; align-items: center; gap: 5px; }
.card-actions { margin-top: auto; padding-top: 8px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.unit { margin-bottom: 28px; }
.unit-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.unit-num { font: 700 11.5px var(--font); letter-spacing: 0.1em; color: var(--violet-600); background: var(--violet-50); border: 1px solid #ddd0fb; padding: 5px 10px; border-radius: 999px; text-transform: uppercase; white-space: nowrap; }
.unit-head h2 { font-size: 1.1rem; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.announcement { border-left: 4px solid var(--blue-500); padding: 14px 18px; }
.announcement.HIGH { border-left-color: var(--red-600); }
.announcement.LOW { border-left-color: var(--border-strong); }
.announcement h3 { font-size: 14.5px; margin-bottom: 4px; }
.announcement p { margin: 0; color: var(--text-2); font-size: 13.5px; white-space: pre-line; }

/* ---------------- Viewer (full-screen lab) ---------------- */
body.viewer-body { background: var(--navy-950); height: 100vh; overflow: hidden; }
.viewer { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.viewer-bar { display: flex; align-items: center; gap: 12px; height: 52px; padding: 0 12px; background: var(--navy-900); color: #dbe4ff; border-bottom: 1px solid rgba(255, 255, 255, 0.06); flex-shrink: 0; }
.viewer-bar .title { min-width: 0; flex: 1; }
.viewer-bar .title b { display: block; color: #fff; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .title small { display: block; color: #8b9bc4; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-bar .btn { height: 34px; background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.1); color: #e2e8ff; }
.viewer-bar .btn:hover { background: rgba(255, 255, 255, 0.14); }
.viewer-bar .btn-primary { background: var(--blue-600); border-color: var(--blue-600); color: #fff; }
.viewer-bar .btn-teal { background: var(--teal-500); border-color: var(--teal-500); color: #042f2e; }
.viewer-bar .status { font-size: 12px; color: #93a3cc; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.viewer-bar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal-400); box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.2); }
.viewer-bar .dot.off { background: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2); }
.preview-flag { background: var(--amber-600); color: #fff; font: 700 11px/1 var(--font); letter-spacing: 0.1em; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.stage { position: relative; flex: 1; min-height: 0; background: #fff; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.stage-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: var(--navy-950); color: #dbe4ff; z-index: 5; text-align: center; padding: 24px; }
.stage-overlay h2 { color: #fff; margin: 10px 0 6px; }
.stage-overlay p { color: #a9b6d8; max-width: 440px; margin: 0 auto 16px; }
.loader { width: 44px; height: 44px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.12); border-top-color: var(--teal-400); animation: spin 0.9s linear infinite; margin: 0 auto; }
.watermark { position: absolute; z-index: 4; pointer-events: none; user-select: none; font: 600 13px var(--font); color: rgba(128, 138, 160, 0.3); transform: rotate(-18deg); white-space: nowrap; transition: top 1.2s ease, left 1.2s ease; }
.viewer:fullscreen .viewer-bar { height: 44px; }
.viewer-foot { display: none; }

/* ---------------- Upload ---------------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 42px 24px; text-align: center; background: var(--surface-2); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--blue-500); background: var(--blue-50); }
.dropzone .big { width: 58px; height: 58px; border-radius: 16px; display: inline-grid; place-items: center; background: linear-gradient(135deg, var(--blue-600), var(--violet-600)); color: #fff; margin-bottom: 12px; }
.progress { height: 10px; border-radius: 999px; background: #e8edf6; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--blue-600), var(--teal-500)); transition: width 0.2s; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #eef2f9; color: var(--text-2); border: 1px solid var(--border); }

/* ---------------- Builder ---------------- */
.module { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; }
.module-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; }
.module-head .grip, .item .grip { cursor: grab; color: var(--text-3); }
.items { list-style: none; margin: 0; padding: 8px; min-height: 48px; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 6px; }
.item:last-child { margin-bottom: 0; }
.dragging { opacity: 0.45; }
.drop-hint { border: 2px dashed var(--blue-500); border-radius: 10px; height: 44px; background: var(--blue-50); }

/* ---------------- Access matrix ---------------- */
.matrix th.course { writing-mode: horizontal-tb; min-width: 150px; }
.matrix select { height: 32px; font-size: 12.5px; min-width: 116px; }
.matrix select.lvl-FREE { background-color: #f1f4f9; }
.matrix select.lvl-PREMIUM { background-color: var(--violet-50); border-color: #ddd0fb; color: #6d28d9; font-weight: 600; }
.matrix select.lvl-CUSTOM { background-color: var(--teal-50); border-color: #b4ece3; color: #0f766e; font-weight: 600; }
.matrix select.lvl-EXPIRED { background-color: var(--red-50); color: #b91c1c; }
.trace { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin: 0; list-style: decimal inside; line-height: 1.8; }
.verdict { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-radius: 12px; font-weight: 700; font-size: 15px; }
.verdict.ok { background: var(--green-50); color: #065f46; border: 1px solid #b7ebd6; }
.verdict.no { background: var(--red-50); color: #991b1b; border: 1px solid #f5c2c2; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 272px; transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(6, 13, 34, 0.5); z-index: 35; }
  .menu-toggle { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 60px; }
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-hero { padding: 32px 24px; min-height: 0; }
  .auth-hero h1 { font-size: 1.8rem; margin-top: 28px; }
  .auth-points, .auth-foot { display: none; }
  .s-nav { display: none; position: absolute; top: 66px; left: 0; right: 0; flex-direction: column; background: var(--navy-900); padding: 10px 16px 16px; border-top: 1px solid rgba(255,255,255,0.06); }
  .s-header.nav-open .s-nav { display: flex; }
  .s-search { display: none; }
  .s-header .menu-toggle { display: inline-grid; color: #fff; }
  .s-main { padding: 20px 16px 60px; }
  .viewer-bar .hide-sm { display: none; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  h1 { font-size: 1.35rem; }
  .card-head, .card-body, .card-pad, .toolbar { padding-left: 16px; padding-right: 16px; }
  .list li { padding: 12px 16px; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
  .toolbar input[type=search], .toolbar select { max-width: none; width: 100%; }
  /* stacked table rows */
  table.table.responsive thead { display: none; }
  table.table.responsive, table.table.responsive tbody, table.table.responsive tr, table.table.responsive td { display: block; width: 100%; }
  table.table.responsive tr { border-bottom: 1px solid var(--border); padding: 10px 4px; }
  table.table.responsive td { border: 0; padding: 5px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.table.responsive td::before { content: attr(data-label); font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; text-align: left; }
  table.table.responsive td.actions { justify-content: flex-end; }
  table.table.responsive td.actions::before { content: none; }
  .hero { padding: 24px 20px; }
  .hero h1 { font-size: 1.4rem; }
  .viewer-bar { gap: 6px; padding: 0 8px; }
  .viewer-bar .btn span.lbl { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media print { .sidebar, .topbar, .s-header { display: none; } }

/* ---------------- Brand logos (369 Tesla + Kalviyogi) ---------------- */
.brand-logo { height: 40px; width: auto; flex-shrink: 0; display: block; filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.35)); }
.s-header .brand-logo { height: 36px; }
.auth-foot { display: flex; align-items: center; gap: 14px; }
.auth-foot .kv-logo { height: 56px; width: auto; opacity: 0.9; }
.auth-card-logo { height: 96px; width: auto; display: block; margin-bottom: 18px; }
.hero::after { content: ""; position: absolute; right: -40px; top: 50%; width: 360px; height: 340px; transform: translateY(-50%) rotate(-8deg); background: url("../img/brand/369-tesla-mark-white.png") center / contain no-repeat; opacity: 0.08; pointer-events: none; }
.hero > * { position: relative; z-index: 1; }
@media (max-width: 640px) { .hero::after { width: 200px; height: 190px; right: -50px; } }
