/* ============================================================
   SCHOLARA — dark-premium academic design system
   Reused across every feature app. Use the CSS variables and
   component classes below; avoid hardcoding colours.
   ============================================================ */

:root {
  /* Surfaces */
  --bg: #0a0e1a;
  --bg-2: #0e1426;
  --surface: #141c33;
  --surface-2: #1a2440;
  --surface-3: #212d4f;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  /* Text */
  --text: #e9edf7;
  --text-muted: #97a2c0;
  --text-faint: #5f6b8c;

  /* Brand */
  --gold: #e6b450;
  --gold-soft: #f3d089;
  --indigo: #6e8bff;
  --indigo-soft: #9db0ff;
  --teal: #45d6c4;
  --rose: #ff7a90;
  --green: #4ad991;
  --amber: #f5b945;
  --red: #ff6b6b;

  /* Accent gradients */
  --grad-gold: linear-gradient(135deg, #e6b450, #f3d089);
  --grad-indigo: linear-gradient(135deg, #6e8bff, #8e6bff);
  --grad-hero: radial-gradient(1200px 600px at 12% -10%, rgba(110, 139, 255, 0.18), transparent 60%),
               radial-gradient(900px 500px at 100% 0%, rgba(230, 180, 80, 0.12), transparent 55%);

  /* IB subject-group accents (groups 1..6 + core) */
  --g1: #ff7a90; --g2: #f5b945; --g3: #4ad991;
  --g4: #6e8bff; --g5: #c98bff; --g6: #45d6c4; --g0: #45d6c4;

  /* Eisenhower quadrants (tasks prioritizer) */
  --q-do: #ff6b6b;        /* urgent + important   */
  --q-schedule: #6e8bff;  /* important, not urgent */
  --q-delegate: #f5b945;  /* urgent, not important */
  --q-eliminate: #97a2c0; /* neither               */

  /* Geometry */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 7px;
  --shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.7);
  --shadow-sm: 0 8px 20px -12px rgba(0, 0, 0, 0.6);
  --sidebar-w: 264px;
  --topbar-h: 64px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Fraunces", "Newsreader", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--indigo-soft); text-decoration: none; }
a:hover { color: var(--text); }
h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
::selection { background: rgba(230, 180, 80, 0.3); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #2c3a64; background-clip: padding-box; }

/* ===================== App layout ===================== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 10px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center;
  background: var(--grad-gold); color: #1a1407; font-weight: 800; font-family: var(--font-serif);
  box-shadow: 0 8px 22px -8px rgba(230, 180, 80, 0.7);
}
.brand-name { font-family: var(--font-serif); font-size: 19px; font-weight: 700; letter-spacing: 0.02em; }
.brand-tag { font-size: 11px; color: var(--text-faint); }

.nav-section { margin-top: 14px; }
.nav-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-faint); padding: 0 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-weight: 500; font-size: 14px; transition: all 0.15s;
}
.nav-item svg { width: 18px; height: 18px; opacity: 0.85; flex: none; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--gold); }
.nav-item.active svg { color: var(--gold); opacity: 1; }
.nav-item.disabled { opacity: 0.4; pointer-events: none; }
.sidebar-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); font-size: 12px; }

/* ===================== Topbar ===================== */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 16px;
  padding: 0 28px; border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 26, 0.7); backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 30;
}
.page-title { font-family: var(--font-serif); font-size: 20px; font-weight: 600; margin: 0; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.content { padding: 28px; max-width: 1320px; width: 100%; }

.chip-account {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-muted);
}
.chip-account .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); }
.chip-account .dot.off { background: var(--text-faint); box-shadow: none; }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--grad-indigo); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; }

/* ===================== Buttons ===================== */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 13.5px; cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.btn:hover { background: var(--surface-3); transform: translateY(-1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--grad-gold); color: #1a1407; border: none; box-shadow: 0 10px 24px -12px rgba(230, 180, 80, 0.8); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-indigo { background: var(--grad-indigo); color: #fff; border: none; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger { background: transparent; border-color: rgba(255,107,107,0.4); color: var(--red); }
.btn-danger:hover { background: rgba(255,107,107,0.12); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.icon-btn { width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: var(--radius-sm); }

/* ===================== Cards & panels ===================== */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow-sm);
}
.card-pad-lg { padding: 26px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.card-title { font-family: var(--font-serif); font-size: 16.5px; font-weight: 600; margin: 0; }
.card-sub { color: var(--text-muted); font-size: 13px; margin: 2px 0 0; }
.panel { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.hero { background: var(--grad-hero), var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Stat tiles */
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-value { font-family: var(--font-serif); font-size: 30px; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-accent-gold .stat-value { color: var(--gold); }
.stat-accent-indigo .stat-value { color: var(--indigo-soft); }
.stat-accent-green .stat-value { color: var(--green); }

/* ===================== Forms ===================== */
label { font-size: 13px; color: var(--text-muted); font-weight: 500; display: block; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=datetime-local], input[type=date], input[type=time], input[type=search],
input[type=url], textarea, select {
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm); background: var(--bg-2);
  border: 1px solid var(--border-strong); color: var(--text); font-family: inherit; font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(110, 139, 255, 0.18); }
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 160px; }
.help { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--red); font-size: 12.5px; }
.checkbox-row { display: flex; align-items: center; gap: 9px; }
.checkbox-row input { width: auto; }
.checkbox-row label { margin: 0; }

/* ===================== Badges / chips / tags ===================== */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge-gold { background: rgba(230,180,80,0.16); color: var(--gold-soft); }
.badge-indigo { background: rgba(110,139,255,0.16); color: var(--indigo-soft); }
.badge-green { background: rgba(74,217,145,0.16); color: var(--green); }
.badge-amber { background: rgba(245,185,69,0.16); color: var(--amber); }
.badge-red { background: rgba(255,107,107,0.16); color: var(--red); }
.badge-muted { background: var(--surface-2); color: var(--text-muted); }
.tag-hl { background: rgba(230,180,80,0.16); color: var(--gold-soft); }
.tag-sl { background: rgba(110,139,255,0.16); color: var(--indigo-soft); }

.subject-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.pill { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; color: var(--text-muted); cursor: pointer; }
.pill.active { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }

/* ===================== Tables / lists ===================== */
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.tbl tr:hover td { background: var(--surface-2); }

.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 10px; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .muted { color: var(--text-muted); font-size: 12.5px; }

.empty { text-align: center; padding: 36px 20px; color: var(--text-faint); }
.empty svg { width: 40px; height: 40px; opacity: 0.5; margin-bottom: 10px; }

/* ===================== Notification dropdown ===================== */
.notif-wrap { position: relative; }
.notif-badge { position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.notif-panel {
  position: absolute; right: 0; top: 48px; width: 360px; max-height: 460px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 8px; display: none; z-index: 50;
}
.notif-panel.open { display: block; }
.notif-item { padding: 11px 12px; border-radius: var(--radius-sm); display: flex; gap: 10px; }
.notif-item:hover { background: var(--surface-2); }
.notif-item .nt { font-weight: 600; font-size: 13.5px; }
.notif-item .nb { color: var(--text-muted); font-size: 12.5px; }
.notif-item .na { color: var(--text-faint); font-size: 11px; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--indigo); }

/* ===================== Toast ===================== */
#toast-host { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { background: var(--surface-2); border: 1px solid var(--border-strong); border-left: 3px solid var(--indigo); border-radius: var(--radius-sm); padding: 12px 16px; box-shadow: var(--shadow); min-width: 240px; animation: toast-in 0.2s ease; }
.toast.success { border-left-color: var(--green); }
.toast.warning { border-left-color: var(--amber); }
.toast.danger { border-left-color: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ===================== Modal ===================== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(4, 7, 15, 0.7); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 100; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 24px; width: 520px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); overflow-y: auto; box-shadow: var(--shadow); }

/* ===================== Messages ===================== */
.messages { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 11px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 13.5px; }
.msg.success { background: rgba(74,217,145,0.1); border-color: rgba(74,217,145,0.3); }
.msg.error, .msg.danger { background: rgba(255,107,107,0.1); border-color: rgba(255,107,107,0.3); }
.msg.warning { background: rgba(245,185,69,0.1); border-color: rgba(245,185,69,0.3); }
.msg.info { background: rgba(110,139,255,0.1); border-color: rgba(110,139,255,0.3); }

/* ===================== Auth pages ===================== */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--grad-hero), var(--bg); padding: 24px; }
.auth-card { width: 420px; max-width: 100%; }

/* ===================== Utilities ===================== */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-sm { gap: 8px; } .gap { gap: 14px; } .gap-lg { gap: 22px; } .wrap { flex-wrap: wrap; }
.mt-0{margin-top:0}.mt{margin-top:14px}.mt-lg{margin-top:26px}.mb-0{margin-bottom:0}.mb{margin-bottom:14px}
.muted { color: var(--text-muted); } .faint { color: var(--text-faint); }
.text-sm { font-size: 13px; } .text-xs { font-size: 11.5px; } .text-lg { font-size: 18px; }
.bold { font-weight: 700; } .center { text-align: center; } .right { text-align: right; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: none; }
.scroll-x { overflow-x: auto; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabular { font-variant-numeric: tabular-nums; }
code.kbd { background: var(--bg-2); border: 1px solid var(--border-strong); border-radius: 6px; padding: 2px 7px; font-family: ui-monospace, monospace; font-size: 12px; color: var(--gold-soft); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -100%; z-index: 60; transition: left 0.2s; width: 84%; max-width: 300px; }
  .sidebar.open { left: 0; }
  .content { padding: 18px; }
}
