/* =========================================================
   Grade 7 OMR Marking System — modern dashboard theme
   ========================================================= */
:root{
  --bg:#f4f6fb;
  --surface:#ffffff;
  --surface-2:#f8fafc;
  --border:#e6e9f0;
  --border-strong:#d3d9e6;
  --text:#101828;
  --text-muted:#667085;
  --text-faint:#98a2b3;

  --accent:#4f46e5;
  --accent-hover:#4338ca;
  --accent-soft:#eef2ff;
  --accent-ring:rgba(79,70,229,.28);

  --danger:#dc2626;
  --danger-hover:#b91c1c;
  --danger-soft:#fef2f2;

  --ok:#0f7a3d;
  --ok-soft:#e7f6ec;
  --warn:#b45309;
  --warn-soft:#fef6e7;

  --radius:14px;
  --radius-sm:10px;
  --shadow-sm:0 1px 2px rgba(16,24,40,.06),0 1px 3px rgba(16,24,40,.04);
  --shadow-md:0 8px 24px rgba(16,24,40,.08);

  --sidebar-w:280px;

  font-family:'Inter',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
  color:var(--text);
}

*{box-sizing:border-box}
html{background:var(--bg)}
body{margin:0;background:var(--bg);color:var(--text);line-height:1.5;-webkit-font-smoothing:antialiased}
h1,h2,h3{margin:0;letter-spacing:-.01em}
b{font-weight:700}
svg{width:100%;height:100%}

/* ---------- App shell ---------- */
.app{display:flex;min-height:100vh}

/* ---------- Sidebar ---------- */
.sidebar{
  width:var(--sidebar-w);
  flex-shrink:0;
  background:#0f172a;
  color:#e2e8f0;
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:22px 16px;
  position:sticky;
  top:0;
  height:100vh;
}
.brand{display:flex;align-items:center;gap:12px;padding:6px 8px 18px}
.brand-mark{
  width:40px;height:40px;flex-shrink:0;
  display:grid;place-items:center;
  border-radius:12px;
  background:linear-gradient(135deg,var(--accent),#7c73f5);
  color:#fff;box-shadow:0 4px 14px var(--accent-ring);
}
.brand-mark svg{width:22px;height:22px}
.brand-text{display:flex;flex-direction:column;line-height:1.2}
.brand-text strong{font-size:16px;font-weight:700;color:#fff}
.brand-text small{font-size:12px;color:#94a3b8}

.steps{display:flex;flex-direction:column;gap:6px;flex:1}
.step{
  display:flex;align-items:center;gap:12px;
  width:100%;text-align:left;
  background:transparent;border:0;
  padding:11px 12px;border-radius:var(--radius-sm);
  color:#cbd5e1;cursor:pointer;
  font:inherit;position:relative;
  transition:background .15s,color .15s;
}
.step:hover{background:rgba(255,255,255,.06);color:#fff}
.step[aria-current="true"]{background:rgba(79,70,229,.18);color:#fff}
.step[aria-current="true"] .step-ico{background:var(--accent);color:#fff;border-color:transparent}
.step-ico{
  width:34px;height:34px;flex-shrink:0;
  display:grid;place-items:center;
  border-radius:9px;background:rgba(255,255,255,.05);
  border:1px solid rgba(255,255,255,.08);color:#cbd5e1;
}
.step-ico svg{width:17px;height:17px}
.step-body{display:flex;flex-direction:column;min-width:0}
.step-n{font-size:11px;font-weight:600;color:#94a3b8;text-transform:uppercase;letter-spacing:.06em}
.step[aria-current="true"] .step-n{color:#a5b4fc}
.step-t{font-size:14px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.step-badge{
  margin-left:auto;min-width:22px;height:22px;padding:0 6px;
  display:grid;place-items:center;border-radius:999px;
  background:var(--warn);color:#fff;font-size:12px;font-weight:700;
}

.sidebar-foot{display:flex;align-items:center;gap:10px;padding:12px 10px 2px;border-top:1px solid rgba(255,255,255,.08)}
.sidebar-foot .pill{background:transparent;color:#cbd5e1;padding:0;font-size:13px;font-weight:600}
.dot{width:9px;height:9px;border-radius:999px;background:var(--danger);flex-shrink:0;box-shadow:0 0 0 3px rgba(220,38,38,.18)}
.dot.ok{background:#22c55e;box-shadow:0 0 0 3px rgba(34,197,94,.2)}

/* ---------- Content ---------- */
.content{flex:1;min-width:0;display:flex;flex-direction:column}

.topbar{
  position:sticky;top:0;z-index:10;
  display:flex;align-items:center;gap:16px;
  padding:16px 28px;
  background:rgba(244,246,251,.82);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--border);
}
.topbar-title{flex:1;min-width:0}
.topbar-title h1{font-size:20px;font-weight:700}
.topbar-title p{margin:2px 0 0;font-size:13px;color:var(--text-muted)}
.menu-btn{display:none;width:40px;height:40px;padding:9px;border:1px solid var(--border);border-radius:10px;background:var(--surface);color:var(--text);cursor:pointer}

.pill{
  padding:6px 12px;border-radius:999px;
  background:var(--danger-soft);color:var(--danger);
  font-size:13px;font-weight:600;white-space:nowrap;
  border:1px solid transparent;
}
.pill.ok{background:var(--ok-soft);color:var(--ok)}
#apiStatusTop{display:inline-block}

main{padding:28px;max-width:1120px;width:100%;margin:0 auto}

/* ---------- Panels ---------- */
.panel{display:none;animation:fade .25s ease}
.panel.active{display:block}
@keyframes fade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}

/* ---------- Card ---------- */
.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:24px;
  box-shadow:var(--shadow-sm);
}
.card-head{margin-bottom:20px}
.card-head h2{font-size:18px;font-weight:700}
.card-head .muted{margin:6px 0 0;font-size:13.5px}

/* ---------- Forms ---------- */
.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px}
label{display:flex;flex-direction:column;gap:7px;font-weight:600;font-size:13px;color:var(--text)}
input,select{font:inherit}
input,.select-wrap select{
  width:100%;padding:11px 12px;
  border:1px solid var(--border-strong);border-radius:var(--radius-sm);
  background:var(--surface);color:var(--text);
  transition:border-color .15s,box-shadow .15s;
}
input::placeholder{color:var(--text-faint)}
input:focus,select:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 4px var(--accent-ring)}

.select-wrap{position:relative}
.select-wrap select{appearance:none;padding-right:38px;cursor:pointer}
.select-wrap::after{
  content:"";position:absolute;right:14px;top:50%;
  width:9px;height:9px;margin-top:-6px;
  border-right:2px solid var(--text-muted);border-bottom:2px solid var(--text-muted);
  transform:rotate(45deg);pointer-events:none;
}

/* file drop */
.filedrop{position:relative;border:1.5px dashed var(--border-strong);border-radius:var(--radius-sm);background:var(--surface-2);transition:border-color .15s,background .15s}
.filedrop:hover,.filedrop.drag{border-color:var(--accent);background:var(--accent-soft)}
.filedrop input[type=file]{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}
.filedrop-inner{display:flex;align-items:center;gap:12px;padding:13px 14px;color:var(--text-muted);font-weight:500;font-size:13.5px}
.filedrop-inner svg{width:20px;height:20px;flex-shrink:0;color:var(--accent)}
.filedrop.has-file .filedrop-inner{color:var(--text)}

/* ---------- Buttons ---------- */
.row,.actions{display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-top:20px}
.btn{
  display:inline-flex;align-items:center;gap:8px;
  border:1px solid var(--border-strong);border-radius:var(--radius-sm);
  padding:10px 16px;cursor:pointer;font:inherit;font-weight:600;font-size:14px;
  background:var(--surface);color:var(--text);
  transition:background .15s,border-color .15s,transform .05s,box-shadow .15s;
}
.btn svg{width:16px;height:16px}
.btn:hover{background:var(--surface-2);border-color:var(--border-strong)}
.btn:active{transform:translateY(1px)}
.btn:focus-visible{outline:none;box-shadow:0 0 0 4px var(--accent-ring)}
.btn.primary{background:var(--accent);border-color:var(--accent);color:#fff;box-shadow:0 2px 8px var(--accent-ring)}
.btn.primary:hover{background:var(--accent-hover);border-color:var(--accent-hover)}
.btn.danger{background:var(--danger);border-color:var(--danger);color:#fff}
.btn.danger:hover{background:var(--danger-hover);border-color:var(--danger-hover)}
.btn.ghost{background:transparent}
.btn.ghost:hover{background:var(--surface-2)}

/* ---------- Session info ---------- */
.session-info{margin-top:20px;font-size:13.5px}
.session-info:not(:empty){
  padding:14px 16px;border-radius:var(--radius-sm);
  background:var(--surface-2);border:1px solid var(--border);
  color:var(--text);font-weight:500;
}

/* ---------- Progress + status ---------- */
.progress-wrap{margin-top:18px}
progress{
  width:100%;height:10px;border:0;border-radius:999px;overflow:hidden;
  background:var(--surface-2);appearance:none;display:block;
}
progress::-webkit-progress-bar{background:var(--surface-2);border-radius:999px}
progress::-webkit-progress-value{background:linear-gradient(90deg,var(--accent),#7c73f5);border-radius:999px;transition:width .3s}
progress::-moz-progress-bar{background:var(--accent);border-radius:999px}

.status{margin-top:14px;white-space:pre-wrap;font-size:13.5px;font-family:'JetBrains Mono',ui-monospace,monospace;color:var(--text-muted)}
.status:not(:empty){padding:12px 14px;border-radius:var(--radius-sm);background:var(--surface-2);border:1px solid var(--border)}
.status.oktxt,.oktxt{color:var(--ok)}
.status.warn,.warn{color:var(--warn)}
.status.err,.err{color:var(--danger)}
.status.err:not(:empty){background:var(--danger-soft);border-color:#fecaca}
.status.oktxt:not(:empty){background:var(--ok-soft);border-color:#bbf7d0}

/* ---------- Reviews ---------- */
.reviews{margin-top:18px;display:flex;flex-direction:column;gap:14px}
.review{
  border:1px solid #fcd9a6;border-left:4px solid var(--warn);
  border-radius:var(--radius-sm);padding:16px;background:var(--warn-soft);
}
.review>b{font-size:14.5px;color:var(--text)}
.review .muted{margin-top:2px;font-size:12.5px;font-family:'JetBrains Mono',monospace}
.review-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:10px;margin-top:14px}
.review-grid button{
  background:var(--ok);color:#fff;border:0;border-radius:var(--radius-sm);
  padding:10px 12px;font:inherit;font-weight:600;font-size:13.5px;cursor:pointer;
  transition:filter .15s;
}
.review-grid button:hover{filter:brightness(1.06)}
.review-grid select{
  padding:10px 12px;border:1px solid var(--border-strong);
  border-radius:var(--radius-sm);background:var(--surface);font:inherit;font-size:13.5px;
}
.oktxt{font-weight:600}

/* ---------- Results table ---------- */
.results{margin-top:18px}
.tablewrap{overflow:auto;border:1px solid var(--border);border-radius:var(--radius-sm);margin-top:12px}
table{border-collapse:collapse;width:100%;font-size:13px}
th,td{padding:10px 12px;text-align:left;white-space:nowrap;border-bottom:1px solid var(--border)}
th{background:var(--surface-2);font-weight:600;color:var(--text);position:sticky;top:0;font-size:12px;text-transform:uppercase;letter-spacing:.03em}
tbody tr:last-child td{border-bottom:0}
tbody tr:hover{background:var(--surface-2)}

/* ---------- Footer ---------- */
.foot{text-align:center;padding:28px 8px 8px;color:var(--text-faint);font-size:12.5px;max-width:640px;margin:0 auto;text-wrap:balance}

/* ---------- Scrim (mobile nav) ---------- */
.scrim{position:fixed;inset:0;background:rgba(15,23,42,.5);z-index:40;border:0}

/* ---------- Responsive ---------- */
@media (max-width:900px){
  .menu-btn{display:grid;place-items:center}
  .sidebar{
    position:fixed;left:0;top:0;z-index:50;
    transform:translateX(-100%);transition:transform .25s ease;
    box-shadow:var(--shadow-md);
  }
  .sidebar.open{transform:none}
  main{padding:20px}
  .topbar{padding:14px 18px}
}
@media (max-width:520px){
  .card{padding:18px}
  .actions .btn,.row .btn{flex:1 1 auto;justify-content:center}
  .topbar-title p{display:none}
}
