/* ═══════════════════════════════════════════════
   ExamVerse — App Design System (tokens + base)
   Shared by every portal page. Extracted from the
   landing page theme: light paper · India palette.
   ═══════════════════════════════════════════════ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --paper:  #FAF5EC;
  --paper2: #F2EADA;
  --card:   #FFFDF7;
  --line:   rgba(43, 33, 24, 0.13);
  --ink:    #2B2118;
  --ink2:   #6B5B48;
  --ink3:   #776749;

  --saffron:  #F08C00;
  --marigold: #FFB300;
  --chili:    #C94F3D;
  --green:    #0E8A4A;
  --leaf:     #17A45C;
  --chakra:   #1D3F9E;
  --sky:      #3E63C4;

  --amb1: 240, 140, 0;
  --amb2: 255, 179, 0;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.2, 0.9, 0.3, 1.18);
  --shadow: 0 14px 44px rgba(75, 56, 34, 0.10);
  --shadow-sm: 0 4px 18px rgba(75, 56, 34, 0.08);
  --navbg: rgba(250, 245, 236, 0.92);
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 22px;
}

body[data-theme="dark"] {
  --paper:  #161310;
  --paper2: #1E1A16;
  --card:   #252019;
  --line:   rgba(235, 220, 195, 0.14);
  --ink:    #F3EADA;
  --ink2:   #C9BA9F;
  --ink3:   #93836B;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 6px 22px rgba(0, 0, 0, 0.4);
  --navbg:  rgba(22, 19, 16, 0.92);
}

html { font-size: 16px; overflow-x: clip; scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: clip;
}
body::after {
  content: ''; position: fixed; inset: 0; z-index: 40; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.06; mix-blend-mode: overlay;
}
body::before {
  content: ''; position: fixed; inset: 0 0 auto 0; height: 5px; z-index: 41;
  background: linear-gradient(90deg, var(--saffron) 0 33%, #fff 33% 33.5%, #fff 33% 34%, var(--chili) 34% 66%, #fff 66% 66.5%, var(--green) 66.5% 100%);
}

/* paper-grain / tricolour off on the exam screen (focus mode) */
body.exam-mode::after, body.exam-mode::before { display: none; }

a { color: var(--sky); }
img { max-width: 100%; }
button { font-family: inherit; }
:focus-visible { outline: 2.5px solid var(--saffron); outline-offset: 3px; border-radius: 8px; }

.container { max-width: 1160px; margin: 0 auto; padding: 0 24px; position: relative; z-index: 2; min-width: 0; }
@media (max-width: 640px) { .container { padding: 0 16px; } }

/* ── ambient blobs (subtle, reused from landing) ── */
.ambient { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.amb-blob { position: absolute; border-radius: 50%; filter: blur(90px); }
.amb-a { background: rgba(var(--amb1), 0.08); width: 52vmax; height: 52vmax; top: -22%; left: -14%; }
.amb-b { background: rgba(var(--amb2), 0.07); width: 46vmax; height: 46vmax; bottom: -24%; right: -16%; }
body[data-theme="dark"] .amb-a { background: rgba(var(--amb1), 0.11); }
body[data-theme="dark"] .amb-b { background: rgba(var(--amb2), 0.09); }
main, .page-main { position: relative; z-index: 2; }

/* ── headings ── */
.page-title { font-family: 'Poppins'; font-size: clamp(1.5rem, 3.4vw, 2.2rem); font-weight: 800; letter-spacing: -1px; line-height: 1.18; }
.page-sub { font-size: 0.95rem; color: var(--ink2); margin-top: 6px; line-height: 1.6; }
.sec-label {
  display: inline-flex; align-items: center; gap: 8px; font-size: 0.68rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 2.4px; margin-bottom: 12px; color: var(--chakra);
}
.sec-label::before { content: ''; width: 26px; height: 3px; border-radius: 2px; background: linear-gradient(90deg, var(--saffron), var(--green)); }

/* ── buttons ── */
.btn, .btn-p, .btn-g, .btn-s, .btn-d {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 0;
  padding: 12px 26px; border: none; border-radius: 12px; cursor: pointer; text-decoration: none;
  font-family: inherit; font-size: 0.95rem; font-weight: 700; transition: all 0.22s; position: relative;
}
.btn-p { background: linear-gradient(135deg, var(--saffron), #e2711d); color: #fff; box-shadow: 0 6px 22px rgba(240, 140, 0, 0.32); }
.btn-p:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(240, 140, 0, 0.42); }
.btn-g { background: linear-gradient(135deg, var(--green), var(--leaf)); color: #fff; box-shadow: 0 6px 22px rgba(14, 138, 74, 0.3); }
.btn-g:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(14, 138, 74, 0.4); }
.btn-d { background: linear-gradient(135deg, var(--chakra), var(--sky)); color: #fff; box-shadow: 0 6px 22px rgba(29, 63, 158, 0.28); }
.btn-d:hover { transform: translateY(-2px); }
.btn-s {
  background: var(--card); color: var(--ink2); border: 1.5px solid var(--line);
}
.btn-s:hover { border-color: var(--ink3); color: var(--ink); transform: translateY(-2px); }
.btn-sm { padding: 8px 16px; font-size: 0.84rem; border-radius: 10px; }
.btn-xs { padding: 5px 12px; font-size: 0.76rem; border-radius: 8px; }
.btn:disabled, .btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none !important; box-shadow: none; }
.btn-danger { background: rgba(201, 79, 61, 0.1); color: var(--chili); border: 1.5px solid rgba(201, 79, 61, 0.35); box-shadow: none; }
.btn-danger:hover { background: rgba(201, 79, 61, 0.16); }

/* ── forms ── */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 0.78rem; font-weight: 700; color: var(--ink2); text-transform: uppercase; letter-spacing: 0.8px; }
.input, select.input, textarea.input {
  padding: 12px 15px; border-radius: var(--r-md); background: var(--card); border: 1.5px solid var(--line);
  color: var(--ink); font-size: 0.95rem; font-family: inherit; transition: border-color 0.25s, box-shadow 0.25s; width: 100%;
}
.input::placeholder { color: var(--ink3); }
.input:focus { outline: none; border-color: var(--saffron); box-shadow: 0 0 0 3px rgba(240, 140, 0, 0.18); }
.input.err { border-color: var(--chili); box-shadow: 0 0 0 3px rgba(201, 79, 61, 0.15); }
select.input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239C8B73' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.check-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 0.88rem; color: var(--ink2); line-height: 1.5; }
.check-row input[type="checkbox"] { width: 19px; height: 19px; margin-top: 1px; accent-color: var(--saffron); cursor: pointer; flex-shrink: 0; }
.check-row input:focus-visible { outline: 2.5px solid var(--saffron); outline-offset: 2px; }
.switch { position: relative; width: 44px; height: 25px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .knob { position: absolute; inset: 0; border-radius: 100px; background: rgba(43, 33, 24, 0.18); transition: background 0.25s; cursor: pointer; }
.switch .knob::after { content: ''; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: transform 0.25s var(--spring); box-shadow: 0 2px 6px rgba(0,0,0,0.25); }
.switch input:checked + .knob { background: var(--green); }
.switch input:checked + .knob::after { transform: translateX(19px); }
.switch input:focus-visible + .knob { outline: 2.5px solid var(--saffron); outline-offset: 2px; }

/* ── cards ── */
.card { background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-sm); padding: 24px; position: relative; min-width: 0; }
.card.lift { transition: transform 0.3s var(--ease-out), box-shadow 0.3s, border-color 0.3s; }
.card.lift:hover { transform: translateY(-5px); border-color: rgba(240, 140, 0, 0.4); }
.card-title { font-family: 'Poppins'; font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }

/* ── badges & pills ── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 11px; border-radius: 100px; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.3px; white-space: nowrap; }
.badge.green  { background: rgba(14, 138, 74, 0.1);  color: var(--green);  border: 1px solid rgba(14, 138, 74, 0.28); }
.badge.saffron{ background: rgba(240, 140, 0, 0.12); color: #b76400;      border: 1px solid rgba(240, 140, 0, 0.32); }
.badge.chili  { background: rgba(201, 79, 61, 0.1);  color: var(--chili);  border: 1px solid rgba(201, 79, 61, 0.3); }
.badge.chakra { background: rgba(29, 63, 158, 0.1);  color: var(--chakra); border: 1px solid rgba(29, 63, 158, 0.28); }
.badge.grey   { background: var(--paper2); color: var(--ink2); border: 1px solid var(--line); }
.badge .ld { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: blink 1.2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.25} }
.pill { padding: 5px 12px; border-radius: 100px; font-size: 0.72rem; font-weight: 800; background: var(--paper2); color: var(--ink2); border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 6px; }
.pill.green { background: rgba(14,138,74,.1); color: var(--green); border-color: rgba(14,138,74,.25); }
.pill.saffron { background: rgba(240,140,0,.12); color: #b76400; border-color: rgba(240,140,0,.3); }
.pill.chili { background: rgba(201,79,61,.1); color: var(--chili); border-color: rgba(201,79,61,.28); }

/* ── tables ── */
.tbl-wrap { overflow-x: auto; border: 1.5px solid var(--line); border-radius: var(--r-lg); background: var(--card); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 560px; }
.tbl th { text-align: left; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1.2px; color: var(--ink3); padding: 13px 16px; border-bottom: 1.5px solid var(--line); background: var(--paper2); white-space: nowrap; }
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--line); color: var(--ink2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background 0.15s; }
.tbl tbody tr:hover { background: rgba(240, 140, 0, 0.04); }
.tbl tbody tr.rowlink { cursor: pointer; }
.tbl tbody tr.rowlink:focus-visible { outline: 2.5px solid var(--saffron); outline-offset: -2.5px; background: rgba(240, 140, 0, 0.06); }
.tbl td strong, .tbl td .strong { color: var(--ink); font-weight: 700; }

/* ── stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.stat-card { text-align: center; padding: 22px 12px; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); transition: transform 0.3s var(--ease-out); }
.stat-card:hover { transform: translateY(-4px); }
.stat-num { font-family: 'Poppins'; font-size: 2rem; font-weight: 800; line-height: 1.1; margin-bottom: 5px; background: linear-gradient(120deg, var(--saffron), var(--chili), var(--green)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.74rem; color: var(--ink2); font-weight: 600; }

/* ── progress bars ── */
.pbar { height: 9px; background: rgba(43, 33, 24, 0.1); border-radius: 6px; overflow: hidden; }
body[data-theme="dark"] .pbar { background: rgba(235, 220, 195, 0.12); }
.pbar i { display: block; height: 100%; width: 0; border-radius: 6px; background: linear-gradient(90deg, var(--saffron), var(--marigold)); transition: width 0.9s var(--ease-out); }
.pbar.green i { background: linear-gradient(90deg, var(--green), var(--leaf)); }
.pbar.chili i { background: linear-gradient(90deg, var(--chili), #e2711d); }

/* ── reveal on scroll ── */
.rv { opacity: 0; transform: translateY(34px); transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out); }
.rv.vis { opacity: 1; transform: none; }

/* ── utility ── */
.muted { color: var(--ink3); }
.small { font-size: 0.8rem; }
.mono { font-variant-numeric: tabular-nums; font-family: 'Poppins', sans-serif; letter-spacing: 0.5px; }
.flex { display: flex; align-items: center; gap: 12px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 36px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.tc { text-align: center; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 500; background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 10px; font-weight: 700; font-size: 0.86rem; text-decoration: none; transition: top 0.2s; }
.skip-link:focus { top: 12px; color: var(--paper); }
.hide { display: none !important; }
@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-num { font-size: 1.6rem; }
}

/* ── touch targets (WCAG 2.5.8 minimum) ── */
.tb-item select, .pill-btn { min-height: 44px; }
.gk-opt { min-height: 44px; }
.slot-card .btn, .exam-card .btn, .qa-card { min-height: 44px; }
.sectab, .tab-btn { min-height: 44px; }
.pal-cell { min-height: 38px; min-width: 38px; }
@media (max-width: 640px) {
  .btn-sm { min-height: 44px; }
  .week-sel button { width: 44px; height: 44px; }
}
/* ── reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
  .rv { opacity: 1 !important; transform: none !important; }
}

/* ═══════════════════════════════════════════════
   Device friendliness — fill the screen on every
   size: fluid wide containers on desktop, denser
   spacing on phones, full-height app shell.
   ═══════════════════════════════════════════════ */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }

/* full-height shell: nav · main stretches · footer pinned down.
   ui.js adds .ev-shell on pages that render the app nav. */
body.ev-shell { display: flex; flex-direction: column; min-height: 100vh; min-height: 100svh; }
body.ev-shell > main { flex: 1 0 auto; width: 100%; }
body.ev-shell > footer { margin-top: auto; }

/* wider containers on big monitors — no dead margins */
@media (min-width: 1280px) { .container { max-width: 1240px; } }
@media (min-width: 1440px) { .container { max-width: 1380px; } }
@media (min-width: 1800px) { .container { max-width: 1580px; } }

/* phones: tighter spacing so content uses the screen */
@media (max-width: 640px) {
  .card { padding: 16px; border-radius: 16px; }
  .page-head { margin: 20px 0 14px; }
  .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 26px; }
  .page-title { font-size: clamp(1.3rem, 6vw, 1.7rem); }
  .tbl th, .tbl td { padding: 10px 11px; }
  table.tbl { min-width: 520px; font-size: 0.82rem; }
  .modal { padding: 18px 16px; max-height: 92svh; }
  .modal.wide { max-width: 100%; }
  .stat-card { padding: 16px 10px; }
  .toast-zone { bottom: calc(18px + env(safe-area-inset-bottom)); }
  .empty { padding: 36px 16px; }
}

/* short laptops: trim vertical rhythm slightly */
@media (max-height: 800px) and (min-width: 901px) {
  .page-head { margin: 22px 0 16px; }
}

/* ── v0.13: icon system + emoji fallback ── */
body { font-family: 'Inter', 'Segoe UI Emoji', 'Apple Color Emoji', 'Noto Color Emoji', sans-serif; }
.ic { display: inline-block; vertical-align: -0.16em; flex-shrink: 0; width: 1em; height: 1em; }
.btn .ic, .badge .ic, .pill .ic, .sec-label .ic, .nl .ic { margin-right: 0.38em; }
.btn .ic:last-child, .badge .ic:last-child { margin-right: 0; }
.theme-btn .ic, .mob-toggle .ic, .ev-fb-btn .ic, .pal-toggle .ic, .sound-btn .ic { margin-right: 0; width: 1.15em; height: 1.15em; vertical-align: -0.2em; }
.ev-fb-btn .ic { margin-right: 0.4em; }
.empty .e-ic .ic, .qa-ic .ic, .nb-ic .ic { width: 1em; height: 1em; vertical-align: middle; stroke-width: 1.7; }
.empty .e-ic { color: var(--saffron); line-height: 1; }
.qa-ic { color: var(--ink); }
.nb-ic .ic { color: var(--chili); }
.stat-label .ic { color: var(--saffron); vertical-align: -0.18em; }
.ptab .ic, .admin-nav .ic, .anav .ic { margin-right: 0.45em; opacity: 0.85; }
