/* Quiz System Theme Upgrade v3.1.7 */
:root{
  --bg:#0b1220;
  --panel:#111827;
  --panel-2:#0f172a;
  --card:#111827;
  --muted:#9ca3af;
  --text:#e5e7eb;
  --text-soft:#cbd5e1;
  --border:rgba(148,163,184,.18);
  --border-strong:rgba(148,163,184,.28);
  --primary:#6366f1;
  --primary-2:#8b5cf6;
  --primary-soft:rgba(99,102,241,.14);
  --success:#10b981;
  --warning:#f59e0b;
  --danger:#ef4444;
  --shadow:0 10px 30px rgba(2,6,23,.28);
  --radius:16px;
  --radius-sm:12px;
}

:root.light{
  --bg:#f3f6fb;
  --panel:#ffffff;
  --panel-2:#ffffff;
  --card:#ffffff;
  --muted:#6b7280;
  --text:#0f172a;
  --text-soft:#334155;
  --border:rgba(15,23,42,.08);
  --border-strong:rgba(15,23,42,.14);
  --primary:#4f46e5;
  --primary-2:#7c3aed;
  --primary-soft:rgba(79,70,229,.08);
  --shadow:0 10px 28px rgba(15,23,42,.08);
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  background:
    radial-gradient(900px 500px at -10% -10%, rgba(99,102,241,.12), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(139,92,246,.10), transparent 60%),
    var(--bg);
  color:var(--text);
  font:14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

a{color:inherit;text-decoration:none}
img{max-width:100%;display:block}

.container{max-width:1200px;margin:0 auto;padding:16px}
.app-layout{
  display:grid;
  grid-template-columns:280px minmax(0,1fr);
  min-height:100vh;
}
.main{min-width:0;padding:18px 18px 26px}

.sidebar{
  position:sticky; top:0; height:100vh;
  background:linear-gradient(180deg, rgba(17,24,39,.94), rgba(15,23,42,.96));
  border-right:1px solid var(--border);
  padding:14px;
  backdrop-filter: blur(8px);
}
:root.light .sidebar{
  background:rgba(255,255,255,.85);
}
.brand{
  display:flex; align-items:center; gap:12px;
  padding:10px;
  border:1px solid var(--border);
  border-radius:16px;
  background:rgba(255,255,255,.02);
}
.brand-logo{
  width:40px;height:40px;border-radius:12px;
  display:grid;place-items:center;
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
  color:#fff;font-weight:800; box-shadow:0 8px 18px rgba(99,102,241,.35);
}
.brand-name{font-weight:800;letter-spacing:.2px}
.brand-sub{font-size:12px;color:var(--muted)}

.nav{display:flex;flex-direction:column;gap:6px;margin-top:14px}
.nav-link{
  display:flex;align-items:center;gap:10px;
  min-height:42px;padding:0 12px;border-radius:12px;
  color:var(--text-soft);
  border:1px solid transparent;
  transition:.15s ease;
}
.nav-link:hover{
  background:rgba(255,255,255,.03);
  border-color:var(--border);
  color:var(--text);
}
.nav-link.active{
  background:linear-gradient(180deg,var(--primary-soft),rgba(255,255,255,.01));
  border-color:rgba(99,102,241,.22);
  color:var(--text);
  font-weight:600;
}

/* Topbar */
.topbar{
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  margin-bottom:16px;
  padding:12px 14px;
  border:1px solid var(--border);
  border-radius:16px;
  background:rgba(255,255,255,.02);
  backdrop-filter: blur(8px);
}
.topbar h1,.topbar h2,.topbar h3{margin:0;font-size:18px}
.topbar .actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}

/* Cards */
.card{
  background:linear-gradient(180deg, rgba(255,255,255,.02), rgba(255,255,255,.01));
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
}
:root.light .card{
  background:var(--card);
}
.card + .card{margin-top:14px}
.card-head{
  display:flex;justify-content:space-between;align-items:center;gap:12px;
  padding:14px 16px 0;
}
.card-title{margin:0;font-size:16px;font-weight:700}
.card-sub{margin:4px 0 0;color:var(--muted);font-size:13px}
.card-body{padding:14px 16px 16px}

.label{font-size:12px;color:var(--muted);text-transform:uppercase;letter-spacing:.06em}
.value{font-size:26px;font-weight:800;line-height:1.1;margin-top:6px}

/* Grid */
.grid{display:grid;gap:14px}
.grid.cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.grid.cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.grid.cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}

/* Buttons */
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  gap:8px; min-height:40px; padding:0 12px;
  border-radius:12px; border:1px solid var(--border-strong);
  background:rgba(255,255,255,.02); color:var(--text);
  cursor:pointer; transition:.15s ease; font-weight:600;
}
.btn:hover{transform:translateY(-1px); border-color:rgba(148,163,184,.35)}
.btn:active{transform:translateY(0)}
.btn-primary{
  border-color:rgba(99,102,241,.32);
  background:linear-gradient(135deg,var(--primary),var(--primary-2));
  color:#fff;
  box-shadow:0 10px 22px rgba(99,102,241,.28);
}
.btn-primary:hover{filter:brightness(1.04)}
.btn-danger{
  border-color:rgba(239,68,68,.28);
  background:rgba(239,68,68,.1);
  color:#fecaca;
}

/* Forms */
.field{margin-bottom:12px}
.field label{
  display:block; margin-bottom:6px;
  color:var(--muted); font-size:13px; font-weight:600;
}
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"],
select, textarea{
  width:100%;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,.02);
  color:var(--text);
  padding:10px 12px;
  outline:none;
}
textarea{min-height:110px; resize:vertical}
input:focus, select:focus, textarea:focus{
  border-color:rgba(99,102,241,.45);
  box-shadow:0 0 0 4px rgba(99,102,241,.12);
}

/* Tables */
.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  min-width:700px;
}
.table th,.table td{
  text-align:left;
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  vertical-align:middle;
}
.table th{
  font-size:12px; letter-spacing:.04em; text-transform:uppercase;
  color:var(--muted); font-weight:700;
  background:rgba(255,255,255,.01);
  position:sticky; top:0;
}
.table tr:hover td{background:rgba(255,255,255,.015)}

code{
  background:rgba(255,255,255,.04);
  border:1px solid var(--border);
  border-radius:8px;
  padding:2px 6px;
  font-size:12px;
}

/* Small UI atoms */
.actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
.pill{
  display:inline-flex;align-items:center;gap:6px;
  border:1px solid var(--border);
  border-radius:999px;
  padding:4px 10px;
  font-size:12px;
  color:var(--text-soft);
  background:rgba(255,255,255,.02);
}
.pill.warning{
  border-color:rgba(245,158,11,.28);
  background:rgba(245,158,11,.08);
  color:#fde68a;
}
.notice{
  border-left:4px solid var(--primary);
  border:1px solid var(--border);
  background:rgba(255,255,255,.02);
  border-radius:12px;
  padding:10px 12px;
  color:var(--text-soft);
}

.kpi-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.kpi{
  border:1px solid var(--border);
  background:rgba(255,255,255,.015);
  border-radius:12px;
  padding:10px;
}
.kpi .t{font-size:12px;color:var(--muted)}
.kpi .v{margin-top:4px;font-weight:700}

/* Quiz pages */
.quiz-shell{display:flex;flex-direction:column;gap:14px}
.quiz-header{
  display:flex;justify-content:space-between;gap:12px;align-items:flex-start;
  border:1px solid var(--border);
  background:rgba(255,255,255,.02);
  border-radius:16px;
  padding:14px;
}
.meta-row{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
.timer{
  min-width:120px;
  text-align:center;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid rgba(99,102,241,.25);
  background:rgba(99,102,241,.1);
  font-weight:800;
  letter-spacing:.06em;
}
.question-card h2{
  margin:0 0 12px;
  font-size:20px;
  line-height:1.3;
}
.answer-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:10px;
}
.answer-option{
  display:flex; gap:10px; align-items:flex-start;
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
  cursor:pointer;
  background:rgba(255,255,255,.015);
  transition:.15s ease;
}
.answer-option:hover{border-color:rgba(99,102,241,.28); transform:translateY(-1px)}
.answer-option.selected{
  border-color:rgba(99,102,241,.4);
  background:rgba(99,102,241,.08);
}
.answer-option input{margin-top:2px}
.answer-letter{
  width:28px;height:28px; border-radius:10px;
  display:grid; place-items:center;
  background:rgba(255,255,255,.04);
  border:1px solid var(--border);
  font-weight:700; flex:0 0 auto;
}
.quiz-nav{
  display:flex;justify-content:space-between;gap:10px;align-items:center;
  margin-top:12px; flex-wrap:wrap;
}

/* Auth pages generic */
.auth-wrap{
  min-height:calc(100vh - 20px);
  display:grid; place-items:center;
  padding:20px 14px;
}
.auth-card{
  width:100%; max-width:520px;
}
.auth-brand{
  margin-bottom:12px;
}

/* Mobile menu helper */
.mobile-only{display:none}
body.sidebar-open .sidebar{transform:translateX(0)}

@media (max-width: 1024px){
  .grid.cols-4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .grid.cols-3{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media (max-width: 860px){
  .app-layout{grid-template-columns:1fr}
  .sidebar{
    position:fixed; z-index:40; left:0; top:0;
    width:280px; transform:translateX(-104%);
    transition:transform .2s ease;
    box-shadow:0 12px 40px rgba(0,0,0,.35);
  }
  .main{padding:14px}
  .mobile-only{display:inline-flex}
  .answer-grid{grid-template-columns:1fr}
  .quiz-header{flex-direction:column}
  .timer{align-self:flex-start}
}
@media (max-width: 640px){
  .grid.cols-2,.grid.cols-3,.grid.cols-4{grid-template-columns:1fr}
  .topbar{padding:10px 12px}
  .card-head,.card-body{padding-left:12px;padding-right:12px}
  .kpi-row{grid-template-columns:1fr}
  .table{min-width:560px}
}
