/* Scorecard — admin theme.
   Brand: slate #2E3A46, coral #D9634A, off-white #F7F5F1. */

:root{
  --slate:#2E3A46;
  --coral:#D9634A;
  --coral-dark:#C24F38;
  --paper:#F7F5F1;
  --surface:#FFFFFF;
  --surface-2:#FBFAF7;
  --ink:#222C36;
  --ink-soft:#4E5A66;
  --muted:#828D99;
  --line:#E5E1D9;
  --line-strong:#D2CCC0;
  --coral-tint:#FBEDE9;
  --green:#2F8F6B;
  --green-tint:#E6F3ED;
  --amber:#B57A1F;
  --amber-tint:#FBF0DC;
  --red:#C0392B;
  --red-tint:#FBEAE7;
  --radius:14px;
  --radius-sm:9px;
  --radius-lg:20px;
  --shadow-sm:0 1px 2px rgba(34,44,54,.05);
  --shadow:0 1px 2px rgba(34,44,54,.04), 0 10px 28px -16px rgba(34,44,54,.22);
  --sidebar-w:236px;
  --display:"Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --body:"Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root:not([data-theme="light"]){ color-scheme: light; }

@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --slate:#1A2028; --paper:#151A20; --surface:#1D242C; --surface-2:#222A33;
    --ink:#EDE9E1; --ink-soft:#BFC6CE; --muted:#8C959E;
    --line:#2C353F; --line-strong:#3D4854;
    --coral:#E4795F; --coral-dark:#EE8C74; --coral-tint:#33231E;
    --green:#5FBF97; --green-tint:#1B2D26;
    --amber:#D9A752; --amber-tint:#2E2617;
    --red:#E4796B; --red-tint:#31201E;
    --shadow-sm:0 1px 2px rgba(0,0,0,.3);
    --shadow:0 1px 2px rgba(0,0,0,.25), 0 14px 32px -18px rgba(0,0,0,.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"]{
  --slate:#1A2028; --paper:#151A20; --surface:#1D242C; --surface-2:#222A33;
  --ink:#EDE9E1; --ink-soft:#BFC6CE; --muted:#8C959E;
  --line:#2C353F; --line-strong:#3D4854;
  --coral:#E4795F; --coral-dark:#EE8C74; --coral-tint:#33231E;
  --green:#5FBF97; --green-tint:#1B2D26;
  --amber:#D9A752; --amber-tint:#2E2617;
  --red:#E4796B; --red-tint:#31201E;
  --shadow-sm:0 1px 2px rgba(0,0,0,.3);
  --shadow:0 1px 2px rgba(0,0,0,.25), 0 14px 32px -18px rgba(0,0,0,.7);
  color-scheme: dark;
}

*{ box-sizing:border-box; }
html,body{ margin:0; padding:0; }
body{
  background:var(--paper); color:var(--ink);
  font-family:var(--body); font-size:14.5px; line-height:1.55;
  -webkit-font-smoothing:antialiased;
}
h1,h2,h3,h4{ font-family:var(--display); margin:0; color:var(--ink); font-weight:600; letter-spacing:-.01em; }
h1{ font-size:24px; }
h2{ font-size:18px; }
h3{ font-size:15.5px; }
a{ color:var(--coral); text-decoration:none; }
a:hover{ text-decoration:underline; }
p{ margin:0 0 10px; }

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

.sidebar{
  width:var(--sidebar-w); flex:0 0 var(--sidebar-w);
  background:var(--slate); color:#DCE3EA;
  display:flex; flex-direction:column; padding:20px 14px;
  position:sticky; top:0; height:100vh;
}
.logo{ display:flex; align-items:center; gap:10px; padding:2px 8px 22px; color:#fff; text-decoration:none; }
.logo:hover{ text-decoration:none; }
.logo-mark{
  width:30px; height:30px; border-radius:9px; background:var(--coral); color:#fff;
  display:grid; place-items:center; font-family:var(--display); font-weight:700; font-size:15px;
  position:relative; overflow:hidden; flex:0 0 auto;
}
.logo-mark::after{
  content:""; position:absolute; top:0; right:0; border-width:0 10px 10px 0;
  border-style:solid; border-color:transparent rgba(255,255,255,.35) transparent transparent;
}
.logo-text{ font-family:var(--display); font-weight:700; font-size:16px; letter-spacing:-.02em; }
.logo-center{ justify-content:center; padding-bottom:24px; }
.auth-body .logo-text{ color:var(--ink); }
.auth-body .logo{ color:var(--ink); }

.nav{ display:flex; flex-direction:column; gap:2px; }
.nav-link{
  display:flex; align-items:center; gap:11px; padding:9px 11px; border-radius:var(--radius-sm);
  color:#AFBBC7; font-size:14px; font-weight:500; text-decoration:none;
  transition:background .12s ease, color .12s ease;
}
.nav-link svg{ width:17px; height:17px; flex:0 0 auto; opacity:.9; }
.nav-link:hover{ background:rgba(255,255,255,.07); color:#fff; text-decoration:none; }
.nav-link.active{ background:var(--coral); color:#fff; }
.nav-sep{ height:1px; background:rgba(255,255,255,.1); margin:10px 11px; }

.sidebar-foot{ margin-top:auto; padding:14px 11px 2px; border-top:1px solid rgba(255,255,255,.1); }
.org-name{ font-family:var(--display); font-weight:600; font-size:13.5px; color:#fff; }
.org-plan{ font-size:11.5px; color:#8C99A6; text-transform:capitalize; letter-spacing:.02em; }
.logout-form{ margin-top:8px; }
.linkish{
  background:none; border:none; padding:0; cursor:pointer; font:inherit;
  font-size:12.5px; color:#8C99A6; text-decoration:underline; text-underline-offset:2px;
}
.linkish:hover{ color:#fff; }

.main{ flex:1; min-width:0; padding:30px 34px 70px; max-width:1120px; }
.main-wide{ max-width:none; }

@media (max-width:900px){
  .shell{ flex-direction:column; }
  .sidebar{ width:auto; flex:none; height:auto; position:static; flex-direction:row; align-items:center;
    gap:8px; padding:10px 14px; overflow-x:auto; }
  .logo{ padding:0 10px 0 0; }
  .logo-text{ display:none; }
  .nav{ flex-direction:row; gap:4px; }
  .nav-link span{ display:none; }
  .nav-link{ padding:9px; }
  .nav-sep{ display:none; }
  .sidebar-foot{ margin:0 0 0 auto; padding:0; border:none; }
  .org-chip{ display:none; }
  .main{ padding:20px 16px 60px; }
}

/* ---------- page head ---------- */
.page-head{
  display:flex; align-items:flex-start; justify-content:space-between; gap:18px;
  flex-wrap:wrap; margin-bottom:22px;
}
.page-head .sub{ color:var(--muted); font-size:14px; margin:5px 0 0; max-width:62ch; }
.page-actions{ display:flex; gap:9px; flex-wrap:wrap; }

/* ---------- cards & tables ---------- */
.card{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  box-shadow:var(--shadow-sm); padding:22px;
}
.card + .card{ margin-top:16px; }
.card-head{ display:flex; align-items:center; justify-content:space-between; gap:14px; margin-bottom:14px; flex-wrap:wrap; }
.card-head h2{ font-size:16px; }
.card-note{ color:var(--muted); font-size:13px; margin:-4px 0 16px; max-width:66ch; }

.grid{ display:grid; gap:16px; }
.grid-2{ grid-template-columns:repeat(2,minmax(0,1fr)); }
.grid-3{ grid-template-columns:repeat(3,minmax(0,1fr)); }
.grid-4{ grid-template-columns:repeat(4,minmax(0,1fr)); }
@media (max-width:900px){ .grid-2,.grid-3,.grid-4{ grid-template-columns:1fr; } }

.stat{
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius);
  padding:18px 20px; box-shadow:var(--shadow-sm);
}
.stat-label{ font-size:12px; font-weight:600; letter-spacing:.05em; text-transform:uppercase; color:var(--muted); }
.stat-value{ font-family:var(--display); font-size:30px; font-weight:600; line-height:1.15; margin-top:6px;
  font-variant-numeric:tabular-nums; }
.stat-hint{ font-size:12.5px; color:var(--muted); margin-top:3px; }

.table-wrap{ overflow-x:auto; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); }
table{ width:100%; border-collapse:collapse; font-size:14px; }
thead th{
  text-align:left; font-size:11.5px; font-weight:600; letter-spacing:.05em; text-transform:uppercase;
  color:var(--muted); padding:11px 16px; background:var(--surface-2); border-bottom:1px solid var(--line);
  white-space:nowrap;
}
tbody td{ padding:13px 16px; border-bottom:1px solid var(--line); vertical-align:middle; }
tbody tr:last-child td{ border-bottom:none; }
tbody tr:hover{ background:var(--surface-2); }
td.num, th.num{ text-align:right; font-variant-numeric:tabular-nums; }
.t-title{ font-weight:600; color:var(--ink); }
.t-sub{ color:var(--muted); font-size:12.5px; }

.empty{
  text-align:center; padding:52px 22px; color:var(--muted);
  border:1px dashed var(--line-strong); border-radius:var(--radius); background:var(--surface-2);
}
.empty h3{ color:var(--ink); margin-bottom:6px; }
.empty p{ max-width:46ch; margin:0 auto 16px; }

/* ---------- buttons ---------- */
.btn{
  display:inline-flex; align-items:center; gap:7px; justify-content:center;
  border-radius:999px; border:1px solid transparent; cursor:pointer;
  font-family:var(--body); font-weight:600; font-size:13.5px; padding:9px 18px;
  text-decoration:none; transition:background .12s ease, border-color .12s ease, opacity .12s ease;
  white-space:nowrap;
}
.btn:hover{ text-decoration:none; }
.btn svg{ width:15px; height:15px; }
.btn-primary{ background:var(--coral); color:#fff; }
.btn-primary:hover{ background:var(--coral-dark); }
.btn-secondary{ background:var(--surface); color:var(--ink); border-color:var(--line-strong); }
.btn-secondary:hover{ border-color:var(--muted); }
.btn-ghost{ background:transparent; color:var(--ink-soft); border-color:var(--line); }
.btn-ghost:hover{ border-color:var(--line-strong); color:var(--ink); }
.btn-danger{ background:var(--red-tint); color:var(--red); border-color:transparent; }
.btn-danger:hover{ background:var(--red); color:#fff; }
.btn-sm{ padding:6px 13px; font-size:12.5px; }
.btn:disabled{ opacity:.45; cursor:not-allowed; }
.btn-block{ width:100%; }

/* ---------- forms ---------- */
.field{ margin-bottom:16px; }
.field:last-child{ margin-bottom:0; }
label, .label{
  display:block; font-size:12.5px; font-weight:600; color:var(--ink-soft); margin-bottom:6px;
}
.hint{ font-size:12.5px; color:var(--muted); margin-top:5px; }
input[type=text],input[type=email],input[type=password],input[type=url],input[type=number],select,textarea{
  width:100%; font-family:inherit; font-size:14px; color:var(--ink);
  background:var(--surface); border:1px solid var(--line-strong); border-radius:var(--radius-sm);
  padding:9px 12px; transition:border-color .12s ease, box-shadow .12s ease;
}
textarea{ resize:vertical; min-height:82px; line-height:1.5; }
input:focus,select:focus,textarea:focus{
  outline:none; border-color:var(--coral); box-shadow:0 0 0 3px var(--coral-tint);
}
input[type=color]{
  width:44px; height:36px; padding:2px; border:1px solid var(--line-strong);
  border-radius:var(--radius-sm); background:var(--surface); cursor:pointer;
}
.inline{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.inline > *{ margin:0; }
.checkline{ display:flex; align-items:center; gap:8px; }
.checkline input{ width:auto; margin:0; accent-color:var(--coral); }
.checkline label{ margin:0; font-weight:500; color:var(--ink); font-size:14px; }
fieldset{ border:none; margin:0; padding:0; }

/* ---------- badges & flash ---------- */
.badge{
  display:inline-flex; align-items:center; gap:5px; border-radius:999px;
  padding:3px 10px; font-size:11.5px; font-weight:600; letter-spacing:.02em;
}
.badge-live{ background:var(--green-tint); color:var(--green); }
.badge-draft{ background:var(--amber-tint); color:var(--amber); }
.badge-archived{ background:var(--surface-2); color:var(--muted); }
.badge-dot{ width:6px; height:6px; border-radius:50%; background:currentColor; }

.flash{
  border-radius:var(--radius-sm); padding:11px 16px; font-size:13.5px; font-weight:500;
  margin-bottom:18px; border:1px solid transparent;
}
.flash-ok{ background:var(--green-tint); color:var(--green); }
.flash-warn{ background:var(--amber-tint); color:var(--amber); }
.flash-error{ background:var(--red-tint); color:var(--red); }

/* ---------- tabs ---------- */
.tabs{
  display:flex; gap:3px; border-bottom:1px solid var(--line); margin-bottom:22px;
  /* Scroll sideways on a narrow screen, but never show a scrollbar: the tabs'
     -1px bottom margin would otherwise make the browser add a vertical one. */
  overflow-x:auto; overflow-y:hidden; scrollbar-width:none;
}
.tabs::-webkit-scrollbar{ display:none; }
.tab{
  padding:9px 15px; font-size:13.5px; font-weight:600; color:var(--muted);
  border-bottom:2px solid transparent; margin-bottom:-1px; text-decoration:none; white-space:nowrap;
}
.tab:hover{ color:var(--ink); text-decoration:none; }
.tab.active{ color:var(--coral); border-bottom-color:var(--coral); }

/* ---------- auth ---------- */
.auth-body{ display:grid; place-items:center; min-height:100vh; padding:24px; background:var(--paper); }
.auth-card{
  width:100%; max-width:380px; background:var(--surface); border:1px solid var(--line);
  border-radius:var(--radius-lg); box-shadow:var(--shadow); padding:32px 30px;
}
.auth-card h1{ font-size:20px; margin-bottom:4px; text-align:center; }
.auth-card .sub{ color:var(--muted); font-size:13.5px; text-align:center; margin-bottom:22px; }
.auth-foot{ text-align:center; margin-top:18px; font-size:13px; color:var(--muted); }

/* ---------- builder ---------- */
.cat-block{
  border:1px solid var(--line); border-radius:var(--radius); background:var(--surface);
  margin-bottom:16px; overflow:hidden;
}
.cat-head{
  display:flex; align-items:center; gap:12px; padding:14px 18px;
  background:var(--surface-2); border-bottom:1px solid var(--line); flex-wrap:wrap;
}
.cat-head h3{ margin:0; flex:1; min-width:120px; }
.cat-count{ font-size:12px; color:var(--muted); font-variant-numeric:tabular-nums; }
.q-row{
  display:flex; align-items:flex-start; gap:14px; padding:14px 18px; border-bottom:1px solid var(--line);
}
.q-row:last-child{ border-bottom:none; }
.q-num{
  flex:0 0 auto; width:24px; height:24px; border-radius:50%; background:var(--surface-2);
  border:1px solid var(--line); display:grid; place-items:center;
  font-size:11.5px; font-weight:600; color:var(--muted); font-variant-numeric:tabular-nums; margin-top:1px;
}
.q-main{ flex:1; min-width:0; }
.q-text{ font-weight:500; color:var(--ink); }
.q-opts{ font-size:12.5px; color:var(--muted); margin-top:4px; }
.q-opts b{ color:var(--ink-soft); font-weight:600; }
.q-actions{ display:flex; gap:5px; flex:0 0 auto; }
.icon-btn{
  width:29px; height:29px; border-radius:8px; border:1px solid var(--line);
  background:var(--surface); color:var(--muted); cursor:pointer;
  display:grid; place-items:center; padding:0;
}
.icon-btn:hover{ border-color:var(--line-strong); color:var(--ink); }
.icon-btn svg{ width:14px; height:14px; }
.icon-btn.danger:hover{ background:var(--red); border-color:var(--red); color:#fff; }

.opt-row{ display:grid; grid-template-columns:1fr 92px 34px; gap:8px; align-items:center; margin-bottom:8px; }
@media (max-width:560px){ .opt-row{ grid-template-columns:1fr 80px 34px; } }

/* ---------- score bars ---------- */
.bar{ height:8px; border-radius:999px; background:var(--line); overflow:hidden; min-width:70px; }
.bar-fill{ height:100%; border-radius:999px; background:var(--coral); }
.bar-fill.good{ background:var(--green); }
.bar-fill.mid{ background:var(--amber); }

/* ---------- misc ---------- */
.copy-row{ display:flex; gap:8px; align-items:center; }
.copy-row input{ font-family:ui-monospace, SFMono-Regular, Menlo, monospace; font-size:12.5px; }
code, .mono{ font-family:ui-monospace, SFMono-Regular, Menlo, monospace; font-size:12.5px; }
pre{
  background:var(--surface-2); border:1px solid var(--line); border-radius:var(--radius-sm);
  padding:13px 15px; overflow-x:auto; font-size:12.5px; line-height:1.5; margin:0;
}
.divider{ height:1px; background:var(--line); margin:20px 0; }
.muted{ color:var(--muted); }
.right{ text-align:right; }
details.disclose summary{
  cursor:pointer; font-size:13.5px; font-weight:600; color:var(--ink-soft); padding:6px 0;
}
details.disclose summary::-webkit-details-marker{ color:var(--muted); }
dialog{
  border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); color:var(--ink);
  padding:24px; max-width:560px; width:calc(100% - 32px); box-shadow:var(--shadow);
}
dialog::backdrop{ background:rgba(20,26,32,.45); }

/* ---------- advice, scale editor, grades ---------- */
.q-advice{ display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }
.chip{
  display:inline-flex; align-items:center; gap:4px; font-size:11px; font-weight:600;
  border-radius:999px; padding:2px 9px; background:var(--surface-2);
  color:var(--muted); border:1px solid var(--line); white-space:nowrap;
}
.chip-ok{ background:var(--green-tint); color:var(--green); border-color:transparent; }
.chip-todo{ background:var(--amber-tint); color:var(--amber); border-color:transparent; }
.chip-scale{ background:var(--coral-tint); color:var(--coral); border-color:transparent; }

.opt-row-3{ grid-template-columns:1fr 1.3fr 92px 34px; }
@media (max-width:760px){ .opt-row-3{ grid-template-columns:1fr 80px 34px; } .opt-row-3 input[name="scale_hint[]"]{ grid-column:1 / -1; } }

.scale-preview{ display:grid; gap:8px; }
.sp-item{
  display:grid; grid-template-columns:190px 1fr 62px; gap:12px; align-items:baseline;
  padding:10px 14px; border:1px solid var(--line); border-radius:var(--radius-sm); background:var(--surface-2);
}
@media (max-width:620px){ .sp-item{ grid-template-columns:1fr 56px; } .sp-item span{ grid-column:1 / -1; } }
.sp-item b{ font-size:13.5px; }
.sp-item span{ font-size:12.5px; color:var(--muted); }
.sp-item em{ font-style:normal; font-size:12px; font-weight:600; color:var(--muted); text-align:right;
  font-variant-numeric:tabular-nums; }

.grade-scale{ display:flex; gap:8px; flex-wrap:wrap; }
.gs-item{
  display:flex; flex-direction:column; align-items:center; gap:1px; min-width:66px;
  padding:9px 11px; border:1px solid var(--line); border-radius:var(--radius-sm); background:var(--surface-2);
}
.gs-item b{ font-family:var(--display); font-size:16px; }
.gs-item span{ font-size:11.5px; color:var(--muted); font-variant-numeric:tabular-nums; }
.gs-item em{ font-style:normal; font-size:10.5px; color:var(--muted); opacity:.8; }
