/* ==========================================================================
   EvalHub design system
   ==========================================================================
   Ported from the approved EvalHub visual design (dark navy nav, indigo
   accents, soft cards) so the real app matches the approved mockups exactly.
   Plain CSS on purpose - no build step, no Tailwind CDN - so the whole app
   stays "clone it and run it" simple. Organized in the order a page uses it:
   reset/base -> layout shell (nav, page header) -> primitives (card, btn,
   badge, table, form) -> feature-specific blocks (paper annotations, review
   workspace, skills graph, etc). */

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: #f8fafc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color: #0f172a;
}

a { color: #4f46e5; text-decoration: none; }
a:hover { color: #4338ca; }

/* ---- App shell: left sidebar nav + navy top header ---- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0;
  background: #0f172a;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.navbrand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding: 22px 20px 18px; }
.navlogo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #818cf8, #4f46e5);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.navtitle { color: #fff; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; white-space: nowrap; }
.navbrand-text { display: flex; flex-direction: column; line-height: 1.3; }
.navsubtitle { color: #94a3b8; font-size: 11px; font-weight: 500; white-space: nowrap; }
.sidenav { display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; flex: 1; overflow-y: auto; }
.navlink {
  display: flex; align-items: center; color: #94a3b8; font-size: 14px; font-weight: 500;
  padding: 10px 14px; border-radius: 8px; border-left: 3px solid transparent; white-space: nowrap;
}
.navlink:hover { color: #e2e8f0; background: rgba(255, 255, 255, 0.04); }
.navlink.active { color: #ffffff; font-weight: 600; background: rgba(99, 102, 241, 0.16); border-left-color: #6366f1; }
.sidefoot { padding: 16px; border-top: 1px solid #1e293b; display: flex; flex-direction: column; gap: 12px; }
.sidefoot-user { display: flex; align-items: center; gap: 10px; }
.navuser { display: flex; flex-direction: column; line-height: 1.3; overflow: hidden; }
.navuser .name { color: #fff; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navuser .role { color: #94a3b8; font-size: 12px; text-transform: capitalize; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700; background: #6366f1;
}
.logout-btn {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: #cbd5e1; background: #1e293b;
  border: 1px solid #334155; border-radius: 7px; padding: 8px 14px; cursor: pointer;
}
.logout-btn:hover { background: #334155; color: #fff; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; flex-shrink: 0; background: #0f172a;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 32px;
}

/* ---- Page shell ---- */
.page { padding: 28px 40px 60px 40px; max-width: 1280px; margin: 0 auto; }
.page.narrow { max-width: 820px; }
.crumb { font-size: 13px; color: #94a3b8; margin-bottom: 14px; }
.crumb b { color: #0f172a; font-weight: 600; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; }
h1.title { font-size: 28px; font-weight: 700; margin: 0 0 6px 0; color: #0f172a; letter-spacing: -0.01em; }
p.subtitle { font-size: 14px; color: #64748b; margin: 0 0 20px 0; }

/* ---- Flash / alert banners ---- */
.flash, .banner {
  display: flex; align-items: center; gap: 10px;
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  font-size: 14px; padding: 14px 18px; border-radius: 10px; margin-bottom: 22px; line-height: 1.6;
}
.flash.error, .banner.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash.success, .banner.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.flash a, .banner a { color: inherit; font-weight: 600; text-decoration: underline; }

/* ---- Card ---- */
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.card + .card { margin-top: 20px; }
.cardpad { padding: 20px 24px; }
.sectiontitle { font-size: 15px; font-weight: 700; margin: 0 0 14px 0; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 600; border-radius: 8px; padding: 10px 18px;
  cursor: pointer; border: 1px solid transparent; white-space: nowrap;
  font-family: inherit; line-height: 1.2;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #4338ca; color: #fff; }
.btn-outline { background: #fff; color: #334155; border-color: #e2e8f0; }
.btn-outline:hover:not(:disabled) { background: #f8fafc; color: #334155; }
.btn-ghost { background: transparent; color: #64748b; }
.btn-ghost:hover:not(:disabled) { color: #334155; }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover:not(:disabled) { background: #047857; color: #fff; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-link {
  background: none; border: none; padding: 0; font: inherit; font-weight: 600;
  color: #4f46e5; cursor: pointer;
}

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-green { background: #dcfce7; color: #166534; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #e0e7ff; color: #4338ca; }
.badge-gray { background: #f1f5f9; color: #475569; }

/* ---- Stat cards ---- */
.stat-row { display: flex; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 140px; padding: 18px 22px; }
.stat-label { font-size: 13px; color: #94a3b8; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 700; color: #0f172a; }
.stat-value .of { font-size: 14px; color: #94a3b8; font-weight: 500; }

/* ---- Tables ---- */
.table-card { overflow: hidden; }
table.evh { width: 100%; border-collapse: collapse; }
table.evh th {
  text-align: left; font-size: 12px; color: #64748b; font-weight: 600;
  padding: 12px 20px; background: #f8fafc; border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}
table.evh td { font-size: 14px; color: #334155; padding: 13px 20px; border-bottom: 1px solid #f1f5f9; }
table.evh tbody tr:last-child td { border-bottom: none; }
table.evh .empty-row td { text-align: center; color: #94a3b8; padding: 32px 20px; }
.rankcell { font-weight: 700; }
.muted { color: #94a3b8; }

/* ---- Forms ---- */
.form-card { padding: 24px; max-width: 640px; }
.form-card.wide { max-width: 880px; }
.form-row { margin-bottom: 14px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #475569; margin-bottom: 5px; }
.form-hint { font-size: 12px; color: #94a3b8; margin-top: 4px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="file"], input:not([type]), select, textarea {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  color: #0f172a;
  font-family: inherit;
  background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.select-inline {
  display: inline-flex; align-items: center; gap: 10px; border: 1px solid #e2e8f0;
  border-radius: 8px; padding: 9px 14px; font-size: 14px; color: #0f172a; background: #fff;
}
.select-inline select {
  border: none; padding: 0; font-size: 14px; color: #0f172a; background: transparent;
}
hr.divider { border: none; border-top: 1px solid #f1f5f9; margin: 18px 0; }

/* Grade-boundary / dynamic add-remove rows (release checklist) */
.boundrow { display: grid; grid-template-columns: 100px 1fr 32px; gap: 12px; align-items: center; margin-bottom: 10px; }
.addrow {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  color: #4f46e5; margin-top: 4px; cursor: pointer; background: none; border: none; padding: 0; font-family: inherit;
}
.rm-row { color: #94a3b8; font-size: 16px; text-align: center; cursor: pointer; background: none; border: none; }
.rm-row:hover { color: #dc2626; }

/* Pre-release checklist */
.checkrow { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #334155; padding: 8px 0; }
.checkicon {
  width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.checkicon.done { background: #dcfce7; }
.checkicon.pending { background: #fee2e2; }

/* ---- Login page ---- */
.login-wrap { max-width: 400px; margin: 80px auto 0; padding: 0 16px; }
.login-card { padding: 32px; }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; justify-content: center; }
.login-brand { font-weight: 700; font-size: 20px; color: #0f172a; }
.login-hint { font-size: 12.5px; color: #94a3b8; margin-top: 18px; line-height: 1.6; text-align: center; }

/* ---- Two/three column result & review layouts ---- */
.body-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 20px; align-items: start; }
.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; align-items: start; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) {
  .body-grid, .grid2, .three-col { grid-template-columns: 1fr; }
}

/* ---- Annotated paper / annotation boxes ---- */
.paper-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid #e2e8f0; }
.paper-frame {
  position: relative;
  background: repeating-linear-gradient(#ffffff 0px, #ffffff 27px, #eef2ff 28px);
  overflow: hidden;
}
.paper-frame img { display: block; width: 100%; }
.ann-box { position: absolute; border-radius: 3px 14px 4px 12px / 12px 4px 14px 3px; border-width: 2px; border-style: solid; pointer-events: none; }
.ann-qmark {
  position: absolute; top: -10px; left: 6px; font-family: 'Caveat', cursive;
  font-weight: 700; font-size: 22px; color: #1d4ed8; transform: rotate(-5deg);
}
.ann-tag {
  position: absolute; top: -11px; left: -2px; font-size: 11px; font-weight: 700;
  color: #fff; border-radius: 4px; padding: 1px 6px;
}
.pagechip {
  position: absolute; top: 8px; left: 8px; background: rgba(15, 23, 42, 0.65); color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 5px; font-weight: 600;
}
.thumbstrip { display: flex; gap: 10px; padding: 14px 18px; flex-wrap: wrap; }
.thumb { width: 64px; height: 84px; border-radius: 6px; background: repeating-linear-gradient(#fff 0, #fff 6px, #eef2ff 7px); border: 2px solid #e2e8f0; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.active { border-color: #6366f1; }

/* "Hand-graded" red-pen marks - simulates a teacher's own pen on the
   scanned paper, layered on top of the AI-detected highlight boxes.
   Caveat is a handwriting-style Google Font; everything here uses the
   same "red ink" color (#b91c1c) and small rotations so marks read as
   drawn by a person rather than machine-perfect shapes. */
.pen-mark { position: absolute; display: flex; flex-direction: column; align-items: center; gap: 3px; transform: translateY(-50%); }
.pen-circle {
  width: 44px; height: 44px; border: 2.5px solid #b91c1c;
  border-radius: 52% 48% 47% 53% / 48% 55% 45% 52%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Caveat', cursive; font-size: 21px; font-weight: 700; color: #b91c1c;
  transform: rotate(-6deg); position: relative; flex-shrink: 0; background: #fff;
}
.pen-icon { position: absolute; top: -9px; right: -11px; }
.pen-comment { font-family: 'Caveat', cursive; font-size: 17px; font-weight: 700; color: #b91c1c; transform: rotate(-3deg); white-space: nowrap; line-height: 1; }
.pen-underline { position: absolute; stroke: #b91c1c; fill: none; stroke-linecap: round; }
.scribble { stroke-linecap: round; fill: none; }

/* ---- Score / question cards (student result detail) ---- */
.qcard { padding: 16px 18px; border-bottom: 1px solid #f1f5f9; }
.qcard:last-child { border-bottom: none; }
.qhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 12px; }
.qtag-left { display: flex; align-items: center; gap: 8px; }
.qlabel { font-size: 13px; color: #475569; }
.qscore { font-weight: 700; font-size: 15px; color: #0f172a; white-space: nowrap; }
.qbar-track { height: 5px; background: #f1f5f9; border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.qbar-fill { height: 100%; border-radius: 3px; }
.qremark { font-size: 13px; color: #64748b; font-style: italic; margin: 0 0 10px 0; line-height: 1.5; }
.verified { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.verified span { font-size: 12px; color: #166534; font-weight: 600; }
.dispute-link { font-size: 12px; font-weight: 600; cursor: pointer; }
.dispute-box { margin-top: 10px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; }
.dispute-box textarea { margin-bottom: 8px; }

/* ---- Review workspace (3-pane grading) ---- */
.paneh { padding: 14px 18px; border-bottom: 1px solid #e2e8f0; font-weight: 600; font-size: 14px; }
.paneh .hint { font-weight: 400; color: #94a3b8; font-size: 12px; }
.panebody { padding: 16px 18px; max-height: 640px; overflow-y: auto; }
.aiblock { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid #f1f5f9; }
.aiblock:last-child { border: none; margin: 0; padding: 0; }
.aihead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.qtitle { font-size: 13px; font-weight: 700; color: #0f172a; }
.transcript { background: #f8fafc; border: 1px solid #f1f5f9; border-radius: 6px; padding: 10px 12px; font-size: 13px; color: #334155; margin-bottom: 10px; line-height: 1.5; white-space: pre-wrap; }
.airow { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 6px; }
.airemark { font-size: 12.5px; color: #64748b; font-style: italic; margin: 6px 0 0 0; }
.field-label { font-size: 12px; font-weight: 600; color: #475569; margin: 0 0 5px 0; }
input.markinput { width: 90px; font-size: 14px; font-weight: 600; }
textarea.remarkinput { font-size: 13px; }
.reason-field { border: 1.5px solid #f59e0b; background: #fffbeb; border-radius: 6px; padding: 8px 10px; }
.reason-field input { border: none; background: transparent; padding: 0; box-shadow: none; }
.reason-field input:focus { box-shadow: none; }
.reason-label { font-size: 11px; font-weight: 700; color: #92400e; margin-bottom: 4px; display: block; }
.footer-bar { position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; margin-top: 18px; flex-wrap: wrap; gap: 10px; }

/* ---- Skills graph ---- */
.skillrow { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid #f1f5f9; }
.skillrow:last-child { border-bottom: none; }
.skillname { width: 170px; flex-shrink: 0; font-size: 14px; font-weight: 600; color: #0f172a; }
.skilltrack { flex: 1; height: 10px; background: #f1f5f9; border-radius: 5px; overflow: hidden; }
.skillfill { height: 100%; border-radius: 5px; }
.skillpct { width: 90px; text-align: right; font-size: 13.5px; font-weight: 700; color: #334155; flex-shrink: 0; }
.skillrow.compact { padding: 8px 0; gap: 12px; }
.skillrow.compact .skillname { width: 110px; font-size: 13px; }
.skillrow.compact .skilltrack { height: 8px; }
.skillrow.compact .skillpct { width: 60px; font-size: 12.5px; }

/* ---- Parent dashboard: child switcher ---- */
.switcher { display: flex; gap: 8px; margin-bottom: 22px; flex-wrap: wrap; }
.chip {
  padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
  display: inline-block;
}
.chip.active { background: #0f172a; color: #fff; }
.chip.inactive { background: #fff; border: 1px solid #e2e8f0; color: #334155; }
.chip.inactive:hover { border-color: #c7d2fe; color: #0f172a; }
.childhead { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.childavatar { width: 52px; height: 52px; border-radius: 50%; background: #6366f1; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; flex-shrink: 0; }
.childname { font-size: 18px; font-weight: 700; color: #0f172a; }
.childmeta { font-size: 13px; color: #64748b; }
.planitem { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: #334155; padding: 8px 0; border-bottom: 1px solid #f1f5f9; }
.planitem:last-child { border: none; }
.plandot { width: 6px; height: 6px; border-radius: 50%; background: #4f46e5; margin-top: 7px; flex-shrink: 0; }

/* ---- Utility ---- */
.mb-0 { margin-bottom: 0 !important; }
.mt-16 { margin-top: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.flex-gap { display: flex; gap: 10px; flex-wrap: wrap; }
.text-right { text-align: right; }

@media print {
  .no-print { display: none !important; }
  .app-shell { display: block; }
  .main-area { display: block; }
  body { background: #fff; }
}
