/* ═══════════════════════════════════════════════════════════════
   MARROW QBANK TRACKER v2.0
   Palette: Mediterranean Warm  (Terracotta · Sage · Sand · Plum)
   Fonts : Outfit (display) + DM Sans (body)
   ═══════════════════════════════════════════════════════════════ */

/* ── Tokens ────────────────────────────────────────────────── */
:root {
  /* Surfaces — warm charcoal */
  --bg-body:     #161219;
  --bg-surface:  #1e1a22;
  --bg-card:     #252029;
  --bg-hover:    #2e2834;
  --border:      rgba(255,255,255,0.06);
  --border-loud: rgba(255,255,255,0.10);

  /* Text — warm off-whites */
  --t1: #f4f1de;
  --t2: #c5bfae;
  --t3: #8a8279;

  /* Accent — terracotta */
  --accent:      #d67d54;
  --accent-lit:  #e8a07c;
  --accent-bg:   rgba(214,125,84,0.12);

  /* Secondary — sage */
  --sage:        #81b29a;
  --sage-bg:     rgba(129,178,154,0.12);

  /* Tertiary — sand / warm gold */
  --sand:        #f2cc8f;
  --sand-bg:     rgba(242,204,143,0.12);

  /* Utility */
  --rose:        #e07a5f;
  --rose-bg:     rgba(224,122,95,0.10);
  --plum:        #a682a6;

  /* Gradient helpers */
  --grad-hero:   linear-gradient(135deg, #201a28 0%, #1a1520 50%, #1e181f 100%);
  --grad-accent: linear-gradient(135deg, #d67d54, #e8a07c);
  --grad-bar:    linear-gradient(90deg, #d67d54, #e8a07c, #f2cc8f);
  --grad-sage:   linear-gradient(135deg, #6a9e82, #81b29a);

  /* Shadows */
  --sh-sm:  0 2px 6px  rgba(0,0,0,0.20);
  --sh-md:  0 6px 18px rgba(0,0,0,0.25);
  --sh-lg:  0 12px 36px rgba(0,0,0,0.35);
  --sh-glow:0 0 28px rgba(214,125,84,0.20);

  /* Radii */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 26px;

  /* Layout */
  --sidebar-w: 250px;

  /* Timing */
  --ease: cubic-bezier(0.16,1,0.3,1);
}

/* ── Light override ───────────────────────────────────────── */
[data-theme="light"] {
  --bg-body:    #f5f0eb;
  --bg-surface: #fffbf5;
  --bg-card:    #ffffff;
  --bg-hover:   #f0e9e1;
  --border:     rgba(0,0,0,0.07);
  --border-loud:rgba(0,0,0,0.12);

  --t1: #2c2420;
  --t2: #5c544c;
  --t3: #9a918a;

  --accent-bg: rgba(214,125,84,0.08);
  --sage-bg:   rgba(129,178,154,0.10);
  --sand-bg:   rgba(242,204,143,0.10);
  --rose-bg:   rgba(224,122,95,0.08);

  --grad-hero: linear-gradient(135deg, #f5f0eb 0%, #ede6dc 50%, #f9f4ee 100%);

  --sh-sm:  0 2px 6px  rgba(0,0,0,0.06);
  --sh-md:  0 6px 18px rgba(0,0,0,0.08);
  --sh-lg:  0 12px 36px rgba(0,0,0,0.10);
  --sh-glow:0 0 20px rgba(214,125,84,0.10);
}

/* ── Reset ─────────────────────────────────────────────────── */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0;}
html{scroll-behavior:smooth;-webkit-font-smoothing:antialiased;}

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  color: var(--t1);
  background: var(--bg-body);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.55;
}

body.menu-open {
  overflow: hidden;
}

body.auth-locked .sidebar,
body.auth-locked .mobile-header,
body.auth-locked .main-content {
  display: none;
}

.auth-gate {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

body.auth-locked .auth-gate {
  display: flex;
}

.auth-gate-card {
  width: min(440px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border-loud);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  padding: 28px 24px;
  text-align: center;
}

.auth-gate-card h1 {
  font-size: 1.5rem;
  margin-bottom: 8px;
}

.auth-gate-card p {
  color: var(--t2);
  font-size: 0.92rem;
  margin-bottom: 18px;
}

.auth-gate-btn {
  width: 100%;
}

h1,h2,h3,.brand-name,.kpi-value,.ring-pct,.donut-pct {
  font-family: 'Outfit', 'DM Sans', system-ui, sans-serif;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform .4s var(--ease);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 26px 22px 22px;
}

.brand-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.brand-name {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.brand-tag {
  display: block;
  font-size: 0.68rem;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: var(--r-md);
  color: var(--t2);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all .2s var(--ease);
}

.nav-emoji { font-size: 1.05rem; flex-shrink: 0; }

.nav-link:hover {
  color: var(--t1);
  background: var(--accent-bg);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-bg);
  font-weight: 600;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px; bottom: 8px;
  width: 3px;
  background: var(--grad-accent);
  border-radius: 0 3px 3px 0;
}

/* ── Auth UI ───────────────────────────────────────────────── */
.sidebar-auth {
  padding: 0 22px 14px;
  min-height: 54px;
  display: flex;
  align-items: flex-end;
}

.btn-signin {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--t1);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s var(--ease);
}

.btn-signin:hover {
  background: var(--bg-hover);
  border-color: var(--border-loud);
}

.auth-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.auth-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.auth-avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.8rem;
  border: 1px solid var(--border);
}

.auth-info {
  display: flex;
  flex-direction: column;
}

.auth-name {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--t1);
  line-height: 1.2;
}

.auth-sync {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--t3);
}

.auth-sync.syncing { color: var(--sand); }
.auth-sync.synced  { color: var(--sage); }
.auth-sync.error   { color: var(--rose); }

.auth-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-switch-account {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--t2);
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 6px;
  transition: all .2s;
}

.btn-switch-account:hover {
  background: var(--bg-hover);
  color: var(--t1);
}

.btn-signout {
  background: none;
  border: none;
  color: var(--t3);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all .2s;
}

.btn-signout:hover {
  background: var(--bg-hover);
  color: var(--t1);
}

.sidebar-footer {
  padding: 14px 22px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
}

.sidebar-version {
  font-size: 0.7rem;
  color: var(--t3);
  font-weight: 500;
}

.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all .25s;
  font-size: 1rem;
}

.theme-toggle:hover {
  background: var(--accent-bg);
  border-color: var(--accent);
  box-shadow: var(--sh-glow);
}

.icon-moon { display: inline; }
.icon-sun  { display: none; }
[data-theme="light"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: inline; }

/* Sidebar Collapse Toggle Button */
.sidebar-collapse-btn {
  background: none;
  border: 1px solid var(--border);
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--t3);
  margin-left: auto;
  flex-shrink: 0;
  transition: all .3s var(--ease);
  padding: 0;
}
.sidebar-collapse-btn svg { width: 14px; height: 14px; transition: transform .3s var(--ease); }
.sidebar-collapse-btn:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }

/* Collapsed Sidebar State */
.sidebar.collapsed { width: 68px; }
.sidebar.collapsed .brand-text { display: none; }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }
.sidebar.collapsed .nav-link span:not(.nav-emoji) { display: none; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 11px 0; }
.sidebar.collapsed .nav-emoji { font-size: 1.2rem; }
.sidebar.collapsed .sidebar-footer { flex-direction: column; gap: 8px; padding: 14px 8px 18px; }
.sidebar.collapsed .sidebar-version { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding: 22px 8px 18px; }
.sidebar.collapsed .brand-icon { font-size: 1.3rem; }
.sidebar.collapsed .sidebar-nav { padding: 14px 6px; align-items: center; }
.sidebar.collapsed .sidebar-auth { display: none; }

body.sidebar-collapsed .main-content { margin-left: 68px; }

/* ── Mobile Header ─────────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 18px;
  gap: 14px;
  z-index: 200;
}

.hamburger {
  background: none; border: none;
  width: 26px; height: 18px;
  display: flex; flex-direction: column; justify-content: space-between;
  cursor: pointer; padding: 0;
}
.hamburger span {
  display: block; width: 100%; height: 2px;
  background: var(--t1); border-radius: 2px;
  transition: all .3s var(--ease);
}
.hamburger.open span:nth-child(1){transform:rotate(45deg) translateY(8px);}
.hamburger.open span:nth-child(2){opacity:0;}
.hamburger.open span:nth-child(3){transform:rotate(-45deg) translateY(-8px);}

.mobile-brand {
  display: flex; align-items: baseline; gap: 5px;
}
.mobile-brand .brand-name { font-size: .95rem; }
.mobile-brand .brand-tag  { font-size: .62rem; }

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  padding: 30px 34px 56px;
  position: relative;
  z-index: 1;
  min-height: 100vh;
  max-width: 1200px;
}

/* ── Hero ───────────────────────────────────────────────────── */
.hero-banner {
  background: var(--grad-hero);
  border-radius: var(--r-xl);
  padding: 36px 40px;
  border: 1px solid var(--border-loud);
  box-shadow: var(--sh-lg);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.hero-banner::after {
  content: '';
  position: absolute;
  top: -60%; right: -15%;
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(214,125,84,0.12) 0%, transparent 65%);
  border-radius: 50%;
  pointer-events: none;
}

.hero-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  position: relative;
}

.hero-greeting {
  font-size: 0.82rem;
  color: var(--t3);
  font-weight: 500;
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hero-title {
  font-size: clamp(1.5rem, 2.8vw, 2.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 10px;
  color: var(--t1);
}

.hero-subtitle {
  color: var(--t2);
  font-size: 0.88rem;
  max-width: 500px;
}

.hero-subtitle code {
  background: var(--accent-bg);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 0.8rem;
  color: var(--accent-lit);
  border: 1px solid rgba(214,125,84,0.15);
}

/* Hero ring */
.hero-ring {
  width: 130px; height: 130px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, rgba(255,255,255,0.04) 0deg);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: background .8s var(--ease);
  box-shadow: var(--sh-glow);
}

.ring-inner {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border: 2px solid var(--border);
}

.ring-pct {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.ring-label {
  font-size: 0.6rem;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* ── KPI Cards ─────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 26px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--sh-sm);
  transition: transform .3s var(--ease), box-shadow .3s;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
}

.kpi-card:nth-child(1)::before { background: var(--grad-accent); }
.kpi-card:nth-child(2)::before { background: var(--grad-sage); }
.kpi-card:nth-child(3)::before { background: linear-gradient(90deg, var(--sand), var(--accent)); }
.kpi-card:nth-child(4)::before { background: linear-gradient(90deg, var(--plum), var(--rose)); }

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-md);
}

.kpi-emoji {
  font-size: 1.3rem;
  margin-bottom: 10px;
  display: block;
}

.kpi-title {
  font-size: 0.74rem;
  color: var(--t3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}

.kpi-value {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--t1);
}

/* ── Card (generic) ────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 26px;
  box-shadow: var(--sh-sm);
}

/* ── Section ───────────────────────────────────────────────── */
.content-section { margin-bottom: 30px; }

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 14px;
  flex-wrap: wrap;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.section-desc {
  font-size: 0.8rem;
  color: var(--t3);
}

.section-desc code {
  background: var(--accent-bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.76rem;
  color: var(--accent-lit);
}

/* ── Analytics Grid ────────────────────────────────────────── */
.analytics-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
}

.card-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--t2);
}

.subject-analytics {
  display: grid;
  gap: 13px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 6px;
}

.subject-analytics::-webkit-scrollbar { width: 4px; }
.subject-analytics::-webkit-scrollbar-track { background: transparent; }
.subject-analytics::-webkit-scrollbar-thumb { background: var(--border-loud); border-radius: 4px; }

.subject-row { display: grid; gap: 7px; }

.subject-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.82rem;
}

.subject-top strong { color: var(--t1); font-weight: 600; }
.subject-top span   { color: var(--t3); font-variant-numeric: tabular-nums; white-space: nowrap; }

.progress-track {
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

[data-theme="light"] .progress-track { background: rgba(0,0,0,0.05); }

.progress-fill {
  height: 100%;
  background: var(--grad-bar);
  border-radius: 999px;
  transition: width .5s var(--ease);
}

/* ── Donut ──────────────────────────────────────────────────── */
.donut-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.donut {
  width: clamp(110px, 16vw, 150px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, rgba(255,255,255,0.03) 0deg);
  position: relative;
  box-shadow: var(--sh-glow);
  transition: background .8s var(--ease);
}

.donut::after {
  content: '';
  position: absolute;
  inset: 18%;
  background: var(--bg-card);
  border-radius: 50%;
  border: 1px solid var(--border);
}

.donut-info { text-align: center; }

.donut-pct {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--accent);
  margin: 0;
}

.donut-desc {
  font-size: 0.76rem;
  color: var(--t3);
  margin: 3px 0 0;
  max-width: 190px;
}

/* ── Filter Bar ────────────────────────────────────────────── */
.filter-bar {
  display: grid;
  grid-template-columns: 1.2fr 2fr auto auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 26px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group > label {
  font-size: 0.76rem;
  color: var(--t3);
  font-weight: 600;
}

select,
input[type="text"],
input[type="date"],
input[type="number"] {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  min-height: 42px;
  padding: 0 12px;
  font-size: 0.86rem;
  color: var(--t1);
  font-family: inherit;
  transition: all .2s var(--ease);
  width: 100%;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%238a8279' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}

input::placeholder { color: var(--t3); }

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.86rem;
  color: var(--t2);
  min-height: 42px;
  user-select: none;
}

.checkbox-label input[type="checkbox"] { display: none; }

.custom-check {
  width: 18px; height: 18px;
  border: 2px solid var(--border-loud);
  border-radius: 5px;
  background: var(--bg-surface);
  display: grid;
  place-items: center;
  transition: all .2s;
  flex-shrink: 0;
}

.checkbox-label input:checked + .custom-check {
  background: var(--grad-accent);
  border-color: var(--accent);
}

.checkbox-label input:checked + .custom-check::after {
  content: '✓';
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--r-sm);
  min-height: 42px;
  padding: 0 18px;
  font-size: 0.86rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .25s var(--ease);
  white-space: nowrap;
}

.btn-primary {
  background: var(--grad-accent);
  color: #fff;
  box-shadow: var(--sh-sm);
}

.btn-primary:hover {
  box-shadow: var(--sh-glow);
  transform: translateY(-2px);
}

.btn-danger {
  background: var(--rose-bg);
  color: var(--rose);
  border: 1px solid rgba(224,122,95,0.2);
}

.btn-danger:hover {
  background: rgba(224,122,95,0.18);
}

.btn-full { width: 100%; }

.btn-sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
  border-radius: 7px;
}

/* ── GT Layout ─────────────────────────────────────────────── */
.gt-layout {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 16px;
  margin-bottom: 16px;
}

.gt-form-card { padding: 22px; }

.gt-form { display: flex; flex-direction: column; gap: 12px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  font-size: 0.76rem;
  color: var(--t3);
  font-weight: 500;
}

.gt-summary-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.gt-summary-cards .kpi-card { padding: 16px 18px; }

/* ── Tables ────────────────────────────────────────────────── */
.table-card { padding: 0; overflow: hidden; }

.gt-history-dropdown {
  margin: 0;
}

.gt-history-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.015);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--t2);
}

.gt-history-summary::-webkit-details-marker { display: none; }

.gt-history-hint {
  color: var(--t3);
  font-size: 0.72rem;
  font-weight: 500;
}

.gt-history-summary::after {
  content: "▾";
  color: var(--t3);
  font-size: 0.9rem;
  transition: transform .2s var(--ease);
}

.gt-history-dropdown:not([open]) .gt-history-summary::after {
  transform: rotate(-90deg);
}

.gt-history-dropdown:not([open]) .gt-history-summary {
  border-bottom: 0;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; min-width: 640px; }

th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(255,255,255,0.015);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
}

[data-theme="light"] th { background: rgba(0,0,0,0.015); }

td {
  padding: 10px 16px;
  font-size: 0.86rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--t2);
}

tr:hover td { background: var(--accent-bg); }
tr:last-child td { border-bottom: none; }

td input[type="number"] {
  max-width: 72px;
  min-height: 34px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.progress-cell { min-width: 140px; }

.delta-pos  { color: var(--sage);  font-weight: 600; }
.delta-neg  { color: var(--rose);  font-weight: 600; }
.delta-zero { color: var(--t3); }

/* ── Module Accordion ──────────────────────────────────────── */
.module-accordion {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.accordion-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-sm);
  transition: box-shadow .3s;
}

.accordion-item:hover {
  box-shadow: var(--sh-md);
}

.accordion-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  user-select: none;
  transition: background .2s;
}

.accordion-header:hover {
  background: var(--bg-hover);
}

.accordion-chevron {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform .3s var(--ease);
  color: var(--t3);
}

.accordion-item.open .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-subject-name {
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--t1);
  flex: 1;
}

.accordion-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--t3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.accordion-meta .pill {
  background: var(--accent-bg);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.72rem;
}

.accordion-progress {
  width: 100px;
  height: 6px;
  background: rgba(255,255,255,0.04);
  border-radius: 999px;
  overflow: hidden;
}

[data-theme="light"] .accordion-progress { background: rgba(0,0,0,0.05); }

.accordion-progress-fill {
  height: 100%;
  background: var(--grad-bar);
  border-radius: 999px;
  transition: width .5s var(--ease);
}

.accordion-body {
  display: none;
  border-top: 1px solid var(--border);
}

.accordion-item.open .accordion-body {
  display: block;
}

/* ── Module Checklist ───────────────────────────────────────── */
.module-body-inner {
  padding: 8px 16px 12px;
}

.module-checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.module-row-wrap {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  transition: border-color .2s;
}

.module-row-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}

.module-check-row {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background .15s, opacity .3s;
  user-select: none;
}

input.module-score-input {
  width: 70px;
  border: none;
  border-left: 1px solid var(--border);
  background: transparent;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 0 8px;
  color: var(--accent-lit);
  font-weight: 600;
  border-radius: 0;
}

input.module-score-input:focus {
  outline: none;
  box-shadow: none;
  background: var(--accent-bg);
}

.module-check-row:hover {
  background: var(--bg-hover);
}

.module-check-row input[type="checkbox"] {
  display: none;
}

.module-check-row .check-box {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-loud);
  border-radius: 6px;
  background: var(--bg-surface);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all .25s var(--ease);
}

.module-check-row.checked .check-box {
  background: var(--grad-accent);
  border-color: var(--accent);
}

.module-check-row.checked .check-box::after {
  content: '✓';
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
}

.module-check-name {
  flex: 1;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--t1);
  transition: all .25s;
}

.module-check-row.checked .module-check-name {
  text-decoration: line-through;
  color: var(--t3);
  opacity: 0.65;
}

.module-mcq-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--t3);
  background: var(--accent-bg);
  padding: 3px 9px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all .25s;
}

.module-check-row.checked .module-mcq-badge {
  opacity: 0.45;
}

/* ── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

[data-theme="light"] ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.08); }
[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.16); }

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-banner          { animation: fadeUp .5s var(--ease) both; }
.kpi-grid             { animation: fadeUp .5s var(--ease) .08s both; }
.content-section:nth-of-type(1) { animation: fadeUp .5s var(--ease) .14s both; }
.filter-bar           { animation: fadeUp .5s var(--ease) .18s both; }
.content-section:nth-of-type(2) { animation: fadeUp .5s var(--ease) .22s both; }
.content-section:nth-of-type(3) { animation: fadeUp .5s var(--ease) .26s both; }

/* ── Responsive ────────────────────────────────────────────── */

/* Tablet */
@media (max-width: 1100px) {
  .kpi-grid   { grid-template-columns: repeat(2, 1fr); }
  .analytics-grid { grid-template-columns: 1fr; }
  .gt-layout  { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr 1fr; }
}

/* Mobile */
@media (max-width: 860px) {
  /* Sidebar off-screen, slides in */
  .sidebar {
    width: min(86vw, 320px);
    transform: translateX(-100%);
    box-shadow: var(--sh-lg);
    z-index: 240;
  }
  .sidebar.open { transform: translateX(0); }\r
  .sidebar-collapse-btn { display: none; }\r
  body.sidebar-collapsed .main-content { margin-left: 0; }
  .sidebar {
    height: 100dvh;
  }
  .sidebar-nav {
    overflow-y: auto;
    padding-bottom: 20px;
  }
  .nav-link {
    min-height: 44px;
    font-size: 0.92rem;
  }

  /* Mobile top bar */
  .mobile-header { display: flex; }

  /* Main area takes full width */
  .main-content {
    margin-left: 0;
    padding: 68px 14px 40px;
    max-width: 100%;
  }

  /* Hero */
  .hero-banner {
    padding: 20px 18px;
    border-radius: var(--r-lg);
    margin-bottom: 16px;
  }
  .hero-content {
    flex-direction: column;
    text-align: center;
    gap: 18px;
  }
  .hero-ring { width: 95px; height: 95px; }
  .ring-inner { width: 70px; height: 70px; }
  .ring-pct   { font-size: 1.1rem; }
  .hero-title { font-size: 1.2rem; }
  .hero-subtitle { font-size: 0.82rem; }

  /* KPI */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
  }
  .kpi-card { padding: 14px 16px; }
  .kpi-emoji { font-size: 1.1rem; margin-bottom: 6px; }
  .kpi-value { font-size: 1.25rem; }

  /* Sections */
  .content-section { margin-bottom: 20px; }
  .section-header { margin-bottom: 12px; }
  .section-title { font-size: 1.05rem; }

  /* Cards */
  .card { padding: 18px 14px; border-radius: var(--r-md); }

  /* Analytics */
  .analytics-grid { gap: 12px; }
  .subject-analytics { max-height: 280px; }
  .donut { width: 110px; }

  /* Filter Bar */
  .filter-bar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 16px 14px;
  }
  .filter-action .btn { width: 100%; }
  .checkbox-label { min-height: 44px; }
  .filter-search { order: -1; }

  /* GT */
  .gt-layout { gap: 12px; }
  .gt-form-card { padding: 16px; }
  .gt-summary-cards {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .gt-summary-cards .kpi-card { padding: 12px 14px; }
  .form-row { grid-template-columns: 1fr; gap: 8px; }
  #gtScore, #gtTotal { min-height: 44px; }

  /* Tables — horizontally scrollable */
  .table-card { border-radius: var(--r-md); }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 520px; }
  th { padding: 10px 12px; font-size: 0.68rem; }
  td { padding: 9px 12px; font-size: 0.82rem; }

  /* Accordion */
  .module-accordion { gap: 8px; }
  .accordion-item { border-radius: var(--r-md); }
  .accordion-header { padding: 14px 14px; gap: 10px; flex-wrap: wrap; }
  .accordion-subject-name {
    font-size: 0.88rem;
    min-width: 0;
    flex: 1 1 180px;
  }
  .accordion-meta {
    gap: 8px;
    font-size: 0.72rem;
    margin-left: 30px;
    width: calc(100% - 30px);
    justify-content: space-between;
  }
  .accordion-progress { width: 50px; height: 5px; }

  /* Checklist — touch-friendly */
  .module-body-inner { padding: 4px 8px 8px; }
  .module-check-row {
    padding: 12px 10px;
    gap: 10px;
    flex-wrap: wrap;
    min-height: 44px; /* touch target */
  }
  .module-check-row .check-box { width: 24px; height: 24px; }
  .module-check-name {
    font-size: 0.82rem;
    min-width: 0;
    flex: 1 1 180px;
    overflow-wrap: anywhere;
  }
  .module-mcq-badge {
    font-size: 0.66rem;
    padding: 2px 7px;
    margin-left: auto;
  }

  /* Auth in sidebar */
  .sidebar-auth { padding: 0 16px 12px; }
}

/* Small phones */
@media (max-width: 480px) {
  .main-content { padding: 64px 10px 32px; }

  .hero-banner { padding: 18px 14px; }
  .hero-title { font-size: 1.05rem; }
  .hero-greeting { font-size: 0.72rem; }
  .hero-ring { width: 80px; height: 80px; }
  .ring-inner { width: 60px; height: 60px; }
  .ring-pct { font-size: 0.95rem; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 1.1rem; }
  .kpi-title { font-size: 0.68rem; }

  .gt-summary-cards { grid-template-columns: 1fr; }

  .accordion-header { padding: 12px 10px; }
  .accordion-subject-name { font-size: 0.82rem; }
  .accordion-meta .pill { font-size: 0.65rem; padding: 2px 7px; }
  .accordion-progress { width: 40px; }

  .module-check-row { padding: 11px 8px; }
  .module-check-name { font-size: 0.78rem; }

  .section-header { flex-direction: column; gap: 4px; }
  .filter-bar { padding: 14px 10px; }

  .donut { width: 90px; }
  .donut-pct { font-size: 1.5rem; }
  .donut-desc { font-size: 0.68rem; }
}

/* Very small phones */
@media (max-width: 640px) {
  .table-wrap { overflow-x: visible; }
  table { min-width: 100%; }

  #section-gt table,
  #section-gt thead,
  #section-gt tbody,
  #section-gt tr,
  #section-gt td {
    display: block;
    width: 100%;
  }

  #section-gt thead { display: none; }

  #section-gt tr {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--bg-card);
    margin: 0 0 10px;
    overflow: hidden;
  }

  #section-gt td {
    border: 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    text-align: right;
  }

  #section-gt td:last-child { border-bottom: 0; }

  #section-gt td::before {
    color: var(--t3);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }

  #section-gt td:nth-child(1)::before { content: "GT"; }
  #section-gt td:nth-child(2)::before { content: "Date"; }
  #section-gt td:nth-child(3)::before { content: "Score"; }
  #section-gt td:nth-child(4)::before { content: "Accuracy"; }
  #section-gt td:nth-child(5)::before { content: "Delta"; }
  #section-gt td:nth-child(6)::before { content: ""; }
  #section-gt td:nth-child(6) { justify-content: flex-end; padding-top: 8px; }
}

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ── Overlay ───────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 99;
}

.sidebar-overlay.active { display: block; }

/* ── Safe area for notched phones ──────────────────────────── */
@supports (padding-top: env(safe-area-inset-top)) {
  .mobile-header {
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
  }
  .main-content {
    padding-bottom: calc(32px + env(safe-area-inset-bottom));
  }
}

