/* ExamSetu — mobile-first design system. No frameworks, no web fonts. */
:root {
  --brand-900: #0b1f3a;
  --brand-800: #12305a;
  --brand-700: #1a4380;
  --brand-600: #1f56a8;
  --brand-500: #2667cc;
  --brand-100: #e4edfb;
  --brand-50:  #f2f6fd;
  --accent:    #f29d1b;   /* saffron */
  --accent-50: #fff6e8;
  --ink:       #0f172a;
  --ink-2:     #334155;
  --muted:     #64748b;
  --line:      #e2e8f0;
  --line-2:    #cbd5e1;
  --bg:        #f5f7fb;
  --card:      #ffffff;
  --ok:        #15803d;
  --ok-50:     #e8f6ee;
  --warn:      #b45309;
  --warn-50:   #fdf3e2;
  --bad:       #c62828;
  --bad-50:    #fdecec;
  --radius:    10px;
  --radius-sm: 7px;
  --shadow:    0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .16);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --header-h: 56px;
  --sidebar-w: 248px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; color: var(--ink); }
h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .small { font-size: .85rem; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand-500) 45%, transparent); outline-offset: 2px; }

/* ---------- Layout ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  display: flex; align-items: center; gap: .75rem; padding: 0 1rem;
  background: var(--brand-900); color: #fff;
}
.app-header .brand { display: flex; align-items: center; gap: .55rem; color: #fff; font-weight: 700; font-size: 1.08rem; letter-spacing: .01em; }
.app-header .brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; flex: none; }
.app-header .spacer { flex: 1; }
.icon-btn { background: none; border: 0; color: inherit; width: 40px; height: 40px; border-radius: 8px; display: inline-grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: rgba(255,255,255,.1); }
.icon-btn svg { width: 22px; height: 22px; }
.user-chip { display: flex; align-items: center; gap: .5rem; background: rgba(255,255,255,.08); color: #fff; border: 0; border-radius: 999px; padding: .25rem .65rem .25rem .25rem; cursor: pointer; font: inherit; }
.user-chip:hover { background: rgba(255,255,255,.16); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--brand-900); display: grid; place-items: center; font-weight: 700; font-size: .85rem; flex: none; }
.user-chip .meta { display: none; text-align: left; line-height: 1.15; }
.user-chip .meta small { color: #b9c7de; font-size: .72rem; text-transform: capitalize; }

.layout { display: flex; min-height: calc(100vh - var(--header-h)); }
.sidebar {
  position: fixed; inset: var(--header-h) auto 0 0; width: var(--sidebar-w); z-index: 35;
  background: #fff; border-right: 1px solid var(--line); padding: .75rem .6rem 1.5rem; overflow-y: auto;
  transform: translateX(-100%); transition: transform .2s ease;
}
.sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
.scrim { position: fixed; inset: var(--header-h) 0 0 0; background: rgba(15,23,42,.35); z-index: 34; }
.nav-section { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .9rem .75rem .35rem; }
.nav-link { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 8px; color: var(--ink-2); font-weight: 520; }
.nav-link svg { width: 19px; height: 19px; flex: none; opacity: .8; }
.nav-link:hover { background: var(--brand-50); text-decoration: none; }
.nav-link.active { background: var(--brand-100); color: var(--brand-700); font-weight: 650; }
.nav-link .count { margin-left: auto; background: var(--bad); color: #fff; font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 0 .45rem; min-width: 1.3rem; text-align: center; }
.main { flex: 1; min-width: 0; padding: 1rem 1rem 5rem; max-width: 1200px; margin: 0 auto; width: 100%; }

@media (min-width: 960px) {
  .menu-btn { display: none; }
  .sidebar { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); transform: none; box-shadow: none; flex: none; }
  .scrim { display: none; }
  .main { padding: 1.5rem 2rem 4rem; }
  .user-chip .meta { display: block; }
}

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; justify-content: space-between; margin-bottom: 1.1rem; }
.page-head p { margin: .15rem 0 0; color: var(--muted); }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.breadcrumb a { color: var(--muted); }

/* ---------- Cards / grid ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .85rem 1rem; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; }
@media (min-width: 720px) { .card-body { padding: 1.25rem; } .card-head { padding: 1rem 1.25rem; } }
.stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.stats { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.stat { padding: .9rem 1rem; }
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.6rem; font-weight: 700; margin-top: .15rem; color: var(--brand-800); }
.stat .hint { font-size: .8rem; color: var(--muted); }
.stat.alert .value { color: var(--bad); }

/* ---------- Buttons ---------- */
.btn {
  --b: var(--brand-600);
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 40px; padding: .5rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--b); background: var(--b); color: #fff;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn svg { width: 18px; height: 18px; }
.btn-secondary { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn-secondary:hover { background: var(--brand-50); filter: none; }
.btn-ghost { background: transparent; color: var(--brand-600); border-color: transparent; }
.btn-ghost:hover { background: var(--brand-50); filter: none; }
.btn-danger { --b: var(--bad); }
.btn-success { --b: var(--ok); }
.btn-accent { --b: var(--accent); color: var(--brand-900); }
.btn-sm { min-height: 32px; padding: .25rem .65rem; font-size: .87rem; }
.btn-lg { min-height: 48px; padding: .7rem 1.4rem; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.form { display: grid; gap: .9rem; }
.form-row { display: grid; gap: .9rem; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 640px) { .form-row.cols-2 { grid-template-columns: 1fr 1fr; } .form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; } }
.field { display: grid; gap: .3rem; }
.field > label, .label { font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.field .req { color: var(--bad); }
.field .help { font-size: .8rem; color: var(--muted); }
input:not([type]), input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=search],
input[type=datetime-local], input[type=date], select, textarea {
  width: 100%; min-height: 42px; padding: .55rem .7rem; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink); font: inherit; font-size: 16px; /* 16px prevents iOS zoom */
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-100); }
.check { display: flex; gap: .6rem; align-items: flex-start; cursor: pointer; font-size: .93rem; }
.check input { width: 18px; height: 18px; margin-top: .15rem; flex: none; accent-color: var(--brand-600); }
.seg { justify-self: start; display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; background: #fff; flex-wrap: wrap; }
.seg label { display: flex; align-items: center; gap: .4rem; padding: .5rem .85rem; cursor: pointer; font-weight: 550; font-size: .92rem; border-right: 1px solid var(--line); }
.seg label:last-child { border-right: 0; }
.seg input { accent-color: var(--brand-600); }
.seg label:has(input:checked) { background: var(--brand-100); color: var(--brand-700); }
.input-group { display: flex; gap: .5rem; }
.input-group > *:first-child { flex: 1; }
.form-error { background: var(--bad-50); color: var(--bad); border: 1px solid #f5c2c2; border-radius: var(--radius-sm); padding: .6rem .8rem; font-size: .92rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem 1rem; margin: 0; }
legend { font-weight: 650; padding: 0 .35rem; color: var(--brand-800); }

/* ---------- Tables (become cards on mobile) ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: .65rem .9rem; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
.table td { padding: .7rem .9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbff; }
.table .actions { text-align: right; white-space: nowrap; }
@media (max-width: 719px) {
  table.table.responsive thead { display: none; }
  table.table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: .75rem 1rem; border-bottom: 1px solid var(--line); }
  .table.responsive td { border: 0; padding: .2rem 0; display: flex; gap: .75rem; justify-content: space-between; }
  .table.responsive td::before { content: attr(data-label); font-weight: 600; color: var(--muted); font-size: .8rem; flex: none; }
  .table.responsive td.primary { display: block; font-weight: 600; }
  .table.responsive td.primary::before { display: none; }
  .table.responsive .actions { text-align: left; justify-content: flex-start; padding-top: .5rem; }
  .table.responsive .actions::before { display: none; }
}

/* ---------- Badges, alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 650; background: #eef2f7; color: var(--ink-2); white-space: nowrap; text-transform: capitalize; }
.badge.blue { background: var(--brand-100); color: var(--brand-700); }
.badge.green { background: var(--ok-50); color: var(--ok); }
.badge.amber { background: var(--warn-50); color: var(--warn); }
.badge.red { background: var(--bad-50); color: var(--bad); }
.badge.dark { background: var(--brand-800); color: #fff; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.live .dot { animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.alert { display: flex; gap: .75rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--radius); border: 1px solid; font-size: .93rem; }
.alert svg { width: 20px; height: 20px; flex: none; margin-top: .1rem; }
.alert.info { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-800); }
.alert.warn { background: var(--warn-50); border-color: #f4d9ae; color: #7c3d06; }
.alert.bad { background: var(--bad-50); border-color: #f5c2c2; color: #8f1c1c; }
.alert.ok { background: var(--ok-50); border-color: #bfe5cd; color: #14532d; }
.alert .grow { flex: 1; }

/* ---------- Ad ticker & banner ---------- */
.ad-ticker { display: flex; align-items: center; background: var(--accent-50); border-bottom: 1px solid #f6dcae; height: 36px; overflow: hidden; font-size: .88rem; }
.ad-ticker .tag { flex: none; height: 100%; display: flex; align-items: center; padding: 0 .75rem; background: var(--accent); color: var(--brand-900); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.ad-ticker .track { flex: 1; overflow: hidden; position: relative; height: 100%; }
.ad-ticker .rail { position: absolute; display: flex; gap: 3rem; white-space: nowrap; height: 100%; align-items: center; padding-left: 100%; animation: ticker var(--dur, 30s) linear infinite; }
.ad-ticker:hover .rail { animation-play-state: paused; }
.ad-ticker .item { color: #6b3a02; font-weight: 550; }
.ad-ticker .item b { color: var(--brand-900); }
.ad-ticker .item .loc { font-size: .7rem; background: #fff; color: var(--warn); border-radius: 4px; padding: 0 .3rem; margin-right: .35rem; font-weight: 700; }
@keyframes ticker { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .ad-ticker .rail { animation-duration: 120s; } }
.ad-cards { display: flex; gap: .75rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: .25rem; }
.ad-card { flex: 0 0 min(280px, 85%); scroll-snap-align: start; display: flex; gap: .75rem; align-items: center; padding: .75rem; color: inherit; }
.ad-card:hover { text-decoration: none; border-color: var(--accent); }
.ad-card img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; flex: none; background: var(--bg); }
.ad-card .t { font-weight: 650; }
.ad-card .s { font-size: .82rem; color: var(--muted); }
.sponsored { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: .4rem; }

/* ---------- Exam list items ---------- */
.exam-card { display: flex; flex-direction: column; gap: .6rem; padding: 1rem; }
.exam-card .top { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.exam-card h3 { margin: 0; }
.exam-card .facts { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .85rem; color: var(--muted); }
.exam-card .facts span { display: inline-flex; align-items: center; gap: .3rem; }
.exam-card .facts svg { width: 15px; height: 15px; }

/* ---------- Exam taking ---------- */
.exam-shell { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.exam-top { position: sticky; top: 0; z-index: 30; background: var(--brand-900); color: #fff; padding: .55rem 1rem; display: flex; align-items: center; gap: .75rem; }
.exam-top .title { flex: 1; min-width: 0; }
.exam-top .title b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.exam-top .title small { color: #b9c7de; }
.timer { font-family: var(--mono); font-size: 1.25rem; font-weight: 700; background: rgba(255,255,255,.1); padding: .3rem .7rem; border-radius: 8px; display: flex; align-items: center; gap: .4rem; }
.timer svg { width: 18px; height: 18px; }
.timer.warn { background: var(--accent); color: var(--brand-900); }
.timer.danger { background: var(--bad); color: #fff; animation: pulse 1s infinite; }
.progress { height: 4px; background: var(--brand-800); }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.exam-body { flex: 1; display: grid; gap: 1rem; padding: 1rem; max-width: 1100px; width: 100%; margin: 0 auto; grid-template-columns: 1fr; }
@media (min-width: 960px) { .exam-body { grid-template-columns: 1fr 300px; padding: 1.5rem; } }
.q-card { padding: 1.1rem; }
@media (min-width: 720px) { .q-card { padding: 1.5rem; } }
.q-meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.q-text { font-size: 1.08rem; font-weight: 560; white-space: pre-wrap; margin-bottom: 1rem; }
.options { display: grid; gap: .6rem; }
.option { display: flex; gap: .8rem; align-items: center; padding: .85rem 1rem; border: 1.5px solid var(--line-2); border-radius: var(--radius); background: #fff; cursor: pointer; transition: border-color .12s, background .12s; min-height: 54px; }
.option:hover { border-color: var(--brand-500); }
.option input { width: 20px; height: 20px; flex: none; accent-color: var(--brand-600); margin: 0; }
.option .key { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-50); color: var(--brand-700); font-weight: 700; font-size: .85rem; flex: none; }
.option:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); }
.option:has(input:checked) .key { background: var(--brand-600); color: #fff; }
.option.correct { border-color: var(--ok); background: var(--ok-50); }
.option.wrong { border-color: var(--bad); background: var(--bad-50); }
.q-nav { display: flex; gap: .5rem; justify-content: space-between; margin-top: 1.25rem; flex-wrap: wrap; }
.palette { padding: 1rem; align-self: start; position: sticky; top: 76px; }
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: .4rem; margin: .75rem 0; }
.pal { height: 40px; border-radius: 8px; border: 1.5px solid var(--line-2); background: #fff; font-weight: 650; cursor: pointer; font: inherit; color: var(--ink-2); position: relative; }
.pal.answered { background: var(--ok); border-color: var(--ok); color: #fff; }
.pal.review { border-color: var(--accent); box-shadow: inset 0 -4px 0 var(--accent); }
.pal.current { outline: 3px solid var(--brand-500); outline-offset: 1px; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: .3rem .75rem; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1.5px solid var(--line-2); margin-right: .35rem; vertical-align: -1px; }
.legend i.a { background: var(--ok); border-color: var(--ok); }
.legend i.r { box-shadow: inset 0 -3px 0 var(--accent); border-color: var(--accent); }
.save-state { font-size: .8rem; color: #b9c7de; white-space: nowrap; }
.save-state.err { color: #ffb4b4; }
@media (max-width: 959px) {
  .palette { position: fixed; inset: auto 0 0 0; top: auto; z-index: 45; border-radius: 16px 16px 0 0; max-height: 70vh; overflow-y: auto; transform: translateY(105%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .palette.open { transform: none; }
}
@media (max-width: 959px) { .q-nav #prev, .q-nav #next { display: none; } }
.exam-bottom { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: .6rem 1rem; display: flex; gap: .5rem; justify-content: space-between; align-items: center; z-index: 30; }
@media (min-width: 960px) { .exam-bottom { display: none; } }

/* ---------- Result ---------- */
.score-ring { --p: 0; width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto;
  background: conic-gradient(var(--brand-600) calc(var(--p) * 1%), var(--brand-100) 0); }
.score-ring > div { width: 104px; height: 104px; border-radius: 50%; background: #fff; display: grid; place-items: center; text-align: center; }
.score-ring b { font-size: 1.6rem; color: var(--brand-800); display: block; line-height: 1; }
.score-ring small { color: var(--muted); }

/* ---------- Modal, toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 640px) { .modal-backdrop { align-items: center; padding: 1.5rem; } }
.modal { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; display: flex; flex-direction: column; border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 860px; }
@media (min-width: 640px) { .modal { border-radius: 14px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-head .icon-btn { color: var(--muted); }
.modal-head .icon-btn:hover { background: var(--bg); }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .9rem 1.25rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: 1rem; display: grid; gap: .5rem; width: min(440px, calc(100% - 2rem)); }
.toast { background: var(--ink); color: #fff; padding: .75rem 1rem; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .93rem; animation: up .2s ease; display: flex; gap: .6rem; align-items: center; }
.toast.ok { background: #14532d; }
.toast.bad { background: #8f1c1c; }
.toast.warn { background: #7c3d06; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }

/* ---------- Public pages ---------- */
.public-header { background: var(--brand-900); }
.public-header .inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; height: 60px; padding: 0 1rem; }
.public-header .brand { color: #fff; font-weight: 700; display: flex; gap: .55rem; align-items: center; font-size: 1.1rem; }
.public-header .brand:hover { text-decoration: none; }
.public-header nav { margin-left: auto; display: flex; gap: .5rem; }
.hero { background: linear-gradient(160deg, var(--brand-900), var(--brand-700)); color: #fff; padding: 3rem 1rem 3.5rem; }
.hero .inner { max-width: 1100px; margin: 0 auto; display: grid; gap: 2rem; align-items: center; }
@media (min-width: 900px) { .hero .inner { grid-template-columns: 1.15fr 1fr; } .hero { padding: 4.5rem 1rem 5rem; } }
.hero h1 { color: #fff; font-size: clamp(1.8rem, 4.5vw, 2.7rem); letter-spacing: -.02em; }
.hero p.lead { color: #d3def0; font-size: 1.08rem; max-width: 36rem; }
.hero .eyebrow { color: var(--accent); font-weight: 700; text-transform: uppercase; font-size: .78rem; letter-spacing: .1em; margin-bottom: .6rem; }
.hero-panel { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.14); border-radius: 16px; padding: 1.25rem; }
.hero-panel .row { display: flex; justify-content: space-between; padding: .55rem 0; border-bottom: 1px dashed rgba(255,255,255,.15); font-size: .93rem; color: #d3def0; }
.hero-panel .row:last-child { border: 0; }
.hero-panel .row b { color: #fff; }
.section { max-width: 1100px; margin: 0 auto; padding: 2.5rem 1rem; }
.feature { padding: 1.1rem; }
.feature .ic { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; margin-bottom: .6rem; }
.feature .ic svg { width: 22px; height: 22px; }
.feature p { color: var(--muted); font-size: .93rem; margin: 0; }
.auth-wrap { min-height: calc(100vh - 60px); display: grid; place-items: start center; padding: 1.5rem 1rem 3rem; }
@media (min-width: 640px) { .auth-wrap { place-items: center; } }
.auth-card { width: 100%; max-width: 460px; }
.auth-card.wide { max-width: 720px; }
.auth-card .card-body { padding: 1.5rem; }
.role-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; }
@media (min-width: 640px) { .role-pick { grid-template-columns: repeat(4, 1fr); } }
.role-pick label { border: 1.5px solid var(--line-2); border-radius: var(--radius); padding: .7rem .5rem; text-align: center; cursor: pointer; font-weight: 600; font-size: .88rem; display: grid; gap: .2rem; justify-items: center; }
.role-pick label svg { width: 22px; height: 22px; color: var(--brand-600); }
.role-pick input { position: absolute; opacity: 0; pointer-events: none; }
.role-pick label:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); color: var(--brand-700); }
.role-pick label:has(input:focus-visible) { outline: 3px solid var(--brand-100); }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 2rem 1rem; border-top: 1px solid var(--line); background: #fff; }
.footer a { color: var(--muted); margin: 0 .5rem; }
.disclaimer-box { background: var(--accent-50); border: 1px solid #f4d9ae; border-radius: var(--radius); padding: 1rem 1.1rem; font-size: .92rem; color: #5b3006; }
.disclaimer-box h3 { color: #5b3006; display: flex; align-items: center; gap: .4rem; }
h1 svg, h2 svg, h3 svg { width: 1.1em; height: 1.1em; flex: none; vertical-align: -.15em; }
.disclaimer-box p:last-child { margin: 0; }

/* ---------- Misc ---------- */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty svg { width: 44px; height: 44px; opacity: .45; margin-bottom: .5rem; }
.empty h3 { color: var(--ink-2); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--brand-100); border-top-color: var(--brand-600); border-radius: 50%; animation: spin .8s linear infinite; margin: 2.5rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .9rem; }
.toolbar > input[type=search], .toolbar > select { width: auto; flex: 1 1 160px; min-height: 38px; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a, .tabs button { padding: .6rem .9rem; color: var(--muted); font-weight: 600; border: 0; background: none; border-bottom: 2px solid transparent; cursor: pointer; font: inherit; white-space: nowrap; }
.tabs .active { color: var(--brand-700); border-bottom-color: var(--brand-600); }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 550; word-break: break-word; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border: 0; }
.bar { height: 8px; background: var(--brand-100); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand-600); }
.qpick { max-height: 380px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.qpick label { display: flex; gap: .6rem; padding: .6rem .8rem; border-bottom: 1px solid var(--line); cursor: pointer; font-size: .92rem; align-items: flex-start; }
.qpick label:last-child { border: 0; }
.qpick label:hover { background: var(--brand-50); }
.qpick input { margin-top: .2rem; accent-color: var(--brand-600); width: 17px; height: 17px; flex: none; }
.chip-list { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; gap: .35rem; align-items: center; padding: .2rem .35rem .2rem .65rem; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0 .2rem; }
.divider { height: 1px; background: var(--line); margin: 1rem 0; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
@media print {
  .app-header, .sidebar, .ad-ticker, .btn, .scrim { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; }
}

/* ---------- Combobox (pick existing or create) ---------- */
.combo { position: relative; }
.combo .combo-input { padding-right: 2.4rem; }
.combo-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); width: 34px; height: 34px; border-radius: 6px; cursor: pointer; display: none; place-items: center; }
.combo-clear svg { width: 16px; height: 16px; }
.combo.has-value .combo-clear { display: grid; }
.combo-list { position: absolute; z-index: 120; left: 0; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line-2); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; }
.combo-opt { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; cursor: pointer; border-bottom: 1px solid var(--line); }
.combo-opt:last-child { border-bottom: 0; }
.combo-opt:hover, .combo-opt.active { background: var(--brand-50); }
.combo-opt.selected .t { color: var(--brand-700); font-weight: 650; }
.combo-opt .grow { flex: 1; min-width: 0; }
.combo-opt .t { font-weight: 550; }
.combo-opt .s { font-size: .8rem; color: var(--muted); }
.combo-opt .s.warn { color: var(--warn); }
.combo-opt.create { color: var(--brand-700); font-weight: 600; background: #fafbff; }
.combo-opt.create svg { width: 18px; height: 18px; flex: none; }
.combo-empty { padding: .8rem; color: var(--muted); font-size: .9rem; }
.dup-list { list-style: none; padding: 0; margin: .5rem 0; }
.dup-list li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .4rem 0; border-top: 1px dashed rgba(0,0,0,.1); }
.chapter-tag { display: inline-flex; align-items: center; gap: .25rem; font-size: .78rem; color: var(--brand-700); background: var(--brand-50); border-radius: 4px; padding: 0 .4rem; margin-top: .2rem; }
.chapter-tag svg { width: 12px; height: 12px; flex: none; }
.org-brand { display: none; align-items: center; gap: .45rem; color: #d3def0; font-size: .9rem; padding-left: .75rem; margin-left: .25rem; border-left: 1px solid rgba(255,255,255,.18); max-width: 320px; }
.org-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.org-brand img { width: 26px; height: 26px; border-radius: 6px; object-fit: contain; background: #fff; }
.org-brand svg { width: 18px; height: 18px; flex: none; }
@media (min-width: 720px) { .org-brand { display: inline-flex; } }
.list-plain li svg { width: 16px; height: 16px; vertical-align: -3px; color: var(--brand-600); margin-right: .35rem; }
.card.stat.alert { display: block; border: 1px solid var(--line); padding: .9rem 1rem; background: var(--card); color: inherit; }

/* ---------- Charts ---------- */
.chart-tip { position: fixed; z-index: 300; display: none; pointer-events: none; background: var(--ink); color: #fff; font-size: .82rem; line-height: 1.35; padding: .45rem .6rem; border-radius: 6px; box-shadow: var(--shadow-lg); max-width: 260px; }
.chart { width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart [tabindex]:focus { outline: none; }
.chart [tabindex]:focus-visible path, .chart [tabindex]:focus-visible circle { stroke: var(--ink); stroke-width: 2; }
.table-toggle { margin-top: .5rem; }
.table-toggle summary { cursor: pointer; color: var(--brand-600); font-size: .85rem; font-weight: 600; }
.table-toggle .table { margin-top: .5rem; font-size: .85rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters select { width: auto; min-height: 38px; flex: 0 1 auto; }
.kpis { display: grid; gap: .75rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.trend-up { color: var(--ok); } .trend-down { color: var(--bad); } .trend-flat { color: var(--muted); }
.strength-list li { display: flex; justify-content: space-between; gap: .5rem; }
.trend-up svg, .trend-down svg { width: 14px; height: 14px; vertical-align: -2px; }

/* ---------- Notifications ---------- */
.bell { position: relative; }
.bell-count { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--accent); color: var(--brand-900); font-size: .7rem; font-weight: 800; display: grid; place-items: center; line-height: 1; }
.notif-panel { position: fixed; z-index: 150; top: calc(var(--header-h) + 6px); right: 8px; width: min(380px, calc(100vw - 16px)); max-height: 70vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.notif-list { display: block; }
.notif { display: flex; gap: .7rem; padding: .75rem 1rem; border-bottom: 1px solid var(--line); color: inherit; }
.notif:hover { background: var(--brand-50); text-decoration: none; }
.notif.unread { background: #f7faff; }
.notif.unread b::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-600); margin-right: .4rem; vertical-align: 1px; }
.notif-ic { width: 32px; height: 32px; border-radius: 8px; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; flex: none; }
.notif-ic svg { width: 17px; height: 17px; }
.notif .grow { flex: 1; min-width: 0; }
.d-block { display: block; }
.tg-login { display: flex; justify-content: center; min-height: 44px; margin-bottom: .25rem; }
.or { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: .75rem 0 1rem; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.table td svg { width: 16px; height: 16px; vertical-align: -3px; }
