/* ============================================================================
   CATalyst — shared premium design system
   Used by dashboard.html, library.html, history.html (NOT the exam screen).
   Same design language as the landing page.
   ============================================================================ */

:root {
  --ink: #0f1720; --ink2: #33414f; --muted: #6b7885;
  --line: #e8e6e0; --paper: #faf9f6; --white: #fff;
  --accent: #2f6df6; --accent-dk: #1c56d6; --accent-soft: #eaf0fd;
  --dark: #0c1826; --dark2: #13253a; --dark-line: #22344a;
  --green: #1e7a3d; --red: #c0392b; --amber: #b8791b;
  --disp: "Space Grotesk", -apple-system, "Segoe UI", sans-serif;
  --body: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body { font-family: var(--body); color: var(--ink); background: var(--paper);
  line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
.shell { max-width: 1120px; margin: 0 auto; padding: 0 28px; }
.disp { font-family: var(--disp); font-weight: 700; letter-spacing: -.02em; color: var(--ink); }
.kicker { font-family: var(--disp); font-size: 12.5px; font-weight: 600; letter-spacing: .22em;
  text-transform: uppercase; color: var(--accent); }
.svgico { flex: 0 0 auto; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--body); font-weight: 600; font-size: 14.5px; padding: 11px 20px;
  border-radius: 999px; border: 1px solid transparent; cursor: pointer; transition: .16s;
  color: #fff; background: var(--ink); }
.btn:hover { background: #000; transform: translateY(-1px); }
.btn.accent { background: var(--accent); } .btn.accent:hover { background: var(--accent-dk); }
.btn.green { background: var(--green); } .btn.green:hover { background: #17692f; }
.btn.line { background: transparent; border-color: #cfccc2; color: var(--ink); }
.btn.line:hover { border-color: var(--ink); background: transparent; }
.btn.ghost { background: var(--white); border: 1px solid var(--line); color: var(--ink2); }
.btn.ghost:hover { background: #f2f1ec; color: var(--ink); }
.btn.sm { padding: 8px 14px; font-size: 13px; gap: 6px; }
.btn svg { width: 17px; height: 17px; }
.btn.sm svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.arrow { transition: transform .16s; }
.btn:hover .arrow { transform: translateX(3px); }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 9px; border: 1px solid var(--line); background: var(--white); color: var(--muted);
  transition: .15s; cursor: pointer; }
.iconbtn:hover { background: var(--accent-soft); color: var(--accent); border-color: #cddcf7; }
.iconbtn.danger:hover { background: #fdecec; color: var(--red); border-color: #f0c4c0; }
.linkbtn { background: none; border: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }

/* ---------- top nav ---------- */
.cnav { position: sticky; top: 0; z-index: 50; background: rgba(250,249,246,.85);
  backdrop-filter: saturate(180%) blur(12px); border-bottom: 1px solid var(--line); }
.cnav-inner { display: flex; align-items: center; gap: 18px; height: 64px; }
.cbrand { display: flex; align-items: center; gap: 10px; font-family: var(--disp); font-weight: 700; font-size: 18px; letter-spacing: -.02em; }
.cbrand img { width: 30px; height: 30px; border-radius: 8px; }
.cnav-links { display: flex; gap: 6px; margin-left: 14px; }
.cnav-links a { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: var(--ink2);
  padding: 8px 14px; border-radius: 9px; transition: .14s; }
.cnav-links a:hover { background: #f0efea; color: var(--ink); }
.cnav-links a.active { background: var(--ink); color: #fff; }
.cnav-links a svg { width: 16px; height: 16px; }
.cnav-spacer { flex: 1; }
.cnav-auth { display: flex; align-items: center; gap: 8px; }
.authchip { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink);
  background: var(--accent-soft); border: 1px solid #d7e4f7; border-radius: 999px; padding: 6px 13px; }
.authchip .svgico { color: var(--accent); }
@media (max-width: 720px) { .cnav-links a span { display: none; } .cnav-links { margin-left: 4px; } }

/* ---------- page header ---------- */
.pagehead { padding: 46px 0 26px; }
.pagehead h1 { font-family: var(--disp); font-weight: 700; font-size: clamp(30px, 4vw, 46px); letter-spacing: -.03em; margin: 12px 0 8px; }
.pagehead p { color: var(--ink2); font-size: 16px; max-width: 620px; }
.pageblock { padding-bottom: 90px; }

/* ---------- cards / panels ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; }

/* ---------- dropzone (dashboard) ---------- */
.drop { border: 2px dashed #c9d3df; border-radius: var(--radius); padding: 40px 24px; text-align: center;
  background: var(--white); transition: .18s; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.drop:hover { border-color: #9db8e0; background: #fbfcff; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.drop .dropicon { color: #9db8e0; transition: .18s; }
.drop:hover .dropicon, .drop.over .dropicon { color: var(--accent); }
.drop .dropmain { font-family: var(--disp); font-weight: 600; font-size: 19px; }
.drop .dropsub { font-size: 14px; color: var(--muted); }
.drop .dropsub b { color: var(--accent); }
.drop code { background: #eef0f4; padding: 1px 7px; border-radius: 5px; font-size: 13px; }
#fileErr, .formerr { color: var(--red); font-size: 13px; margin-top: 10px; white-space: pre-wrap; }

/* ---------- quick action tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.tile { display: flex; align-items: center; gap: 14px; padding: 18px; background: var(--white);
  border: 1px solid var(--line); border-radius: var(--radius); transition: .16s; cursor: pointer; text-align: left; width: 100%; font: inherit; }
.tile:hover { border-color: #c7d6ef; box-shadow: 0 12px 30px -18px rgba(15,23,32,.4); transform: translateY(-2px); }
.tile .tic { width: 44px; height: 44px; border-radius: 11px; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.tile .tic svg { width: 22px; height: 22px; }
.tile h3 { font-family: var(--disp); font-weight: 600; font-size: 16px; margin-bottom: 2px; }
.tile p { font-size: 13px; color: var(--muted); line-height: 1.35; }

/* ---------- stat cards ---------- */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.statcard { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.statcard .k { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.statcard .v { font-family: var(--disp); font-weight: 700; font-size: 30px; letter-spacing: -.02em; margin-top: 4px; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); }
table.ctable { border-collapse: collapse; width: 100%; font-size: 14px; }
.ctable th { text-align: center; font-family: var(--disp); font-weight: 600; font-size: 12.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; padding: 14px 12px; border-bottom: 1px solid var(--line); background: #fbfaf7; }
.ctable td { text-align: center; padding: 14px 12px; border-bottom: 1px solid #f0eee8; vertical-align: top; }
.ctable tr:last-child td { border-bottom: none; }
.ctable tr:hover td { background: #fbfcff; }
.ctable .lead { text-align: left; }
.ctable .t-title { font-family: var(--disp); font-weight: 600; font-size: 15px; }
.ctable .t-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.ctable .t-topics { font-size: 11.5px; color: #9aa6b2; margin-top: 2px; }
.actions { white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.pos { color: var(--green); } .neg { color: var(--red); }

/* ---------- trend + mastery (history) ---------- */
.trend { display: flex; align-items: flex-end; gap: 10px; height: 150px; padding: 12px 8px;
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
.tbar { flex: 0 0 34px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.tbarfill { width: 26px; background: linear-gradient(#5b8def, var(--accent)); border-radius: 5px 5px 0 0; min-height: 3px; }
.tbarval { font-family: var(--disp); font-size: 11px; color: var(--ink2); margin-top: 5px; }
.mastery { display: flex; flex-direction: column; gap: 9px; }
.mrow { display: grid; grid-template-columns: 210px 1fr 200px; gap: 12px; align-items: center; font-size: 13.5px; }
.mtopic { color: var(--ink); }
.mbar { background: #eceae4; border-radius: 999px; height: 12px; overflow: hidden; }
.mfill { height: 100%; border-radius: 999px; }
.mval { color: var(--ink2); } .msub { color: #9aa6b2; font-size: 11.5px; }
@media (max-width: 680px) { .mrow { grid-template-columns: 1fr; gap: 3px; } }

/* ---------- forms ---------- */
.flabel { display: block; font-size: 12.5px; color: var(--ink2); margin: 14px 0 6px; font-weight: 600; }
.finput { width: 100%; padding: 11px 13px; font-size: 14px; border: 1px solid #cfd6de; border-radius: 10px;
  background: var(--white); font-family: var(--body); transition: .15s; }
.finput:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,109,246,.15); }
.inwrap { position: relative; }
.inwrap .inico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #90a4b8; }
.inwrap .finput { padding-left: 42px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(12,24,38,.55); z-index: 200; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.show { display: flex; }
.modal .box { background: var(--white); border-radius: 16px; width: 460px; max-width: 100%; max-height: 88vh; overflow: auto; box-shadow: 0 40px 90px -30px rgba(0,0,0,.5); }
.modal .mhead { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 4px; }
.modal .mhead span { font-family: var(--disp); font-weight: 700; font-size: 18px; }
.modal .mhead button { background: none; border: none; color: var(--muted); cursor: pointer; display: flex; padding: 4px; border-radius: 8px; }
.modal .mhead button:hover { background: #f0eee8; color: var(--ink); }
.modal .mbody { padding: 8px 22px 22px; }
.modal .mfoot { padding: 0 22px 20px; text-align: right; }
.authbrand { display: flex; align-items: center; gap: 13px; padding: 4px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.authbrand img { width: 46px; height: 46px; border-radius: 12px; }
.authbrand .abname { font-family: var(--disp); font-size: 19px; font-weight: 700; }
.authbrand .abtag { font-size: 12.5px; color: var(--muted); }
.authmsg { font-size: 12.5px; margin: 12px 0 2px; min-height: 16px; color: var(--red); }
.authswitch { text-align: center; font-size: 13px; color: var(--ink2); margin-top: 14px; }
.authswitch a { color: var(--accent); font-weight: 600; }
.upmeta { margin: 10px 0; }
.upok { font-size: 13px; color: var(--green); background: #eaf6ee; border: 1px solid #bfe6cd; border-radius: 10px; padding: 10px 12px; }
.uperr { font-size: 13px; color: var(--red); background: #fdeaea; border: 1px solid #f3c6c2; border-radius: 10px; padding: 10px 12px; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--dark); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  box-shadow: 0 14px 40px rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: .25s; z-index: 300; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty svg { width: 40px; height: 40px; color: #c3ccd6; margin-bottom: 14px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }
.toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.count { font-size: 13px; color: var(--muted); }
footer.cfoot { background: var(--dark); color: #8ea3bd; padding: 34px 0; margin-top: 40px; font-size: 13px; }
footer.cfoot a { color: #bcd3e8; }
