:root {
  --cream: #f4f2ee;
  --card: #ffffff;
  --ink: #2b2620;
  --muted: #6f665b;
  --brown: #6b3f1d;
  --brown-2: #8a5a2b;
  --gold: #b8860b;
  --line: #e6e0d6;
  --pass: #1f9d55;
  --fail: #d64545;
  --blocked: #d9902b;
  --shadow: 0 2px 10px rgba(60, 40, 20, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
}
a { color: var(--brown); }
.loading, .error { padding: 40px; text-align: center; color: var(--muted); }
.error { color: var(--fail); }

/* ---------- Sign in ---------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 36px 32px; max-width: 440px; text-align: center;
}
.signin-card .logo {
  display: block; width: 76px; height: 76px; margin: 0 auto 16px;
  border-radius: 50%; background: #fff; padding: 6px; object-fit: contain;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.signin-card .brand { font-size: 26px; font-weight: 700; color: var(--brown); margin-bottom: 10px; }
.signin-card .lede { color: var(--muted); margin: 0 0 22px; }
.signin-card #gbtn { display: flex; justify-content: center; min-height: 44px; }
.signin-card .fine { color: var(--muted); font-size: 13px; margin-top: 18px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  background: var(--brown); color: #fff; padding: 10px 16px;
}
.topbar .logo {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%;
  background: #fff; padding: 3px; object-fit: contain; box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.topbar .brand { font-weight: 700; font-size: 17px; }
.topbar .spacer { flex: 1; }
.topbar .overall { background: rgba(255,255,255,.15); padding: 4px 10px; border-radius: 999px; font-size: 13px; }
.topbar .user { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.topbar .user img { width: 28px; height: 28px; border-radius: 50%; }
.role { text-transform: capitalize; font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.role-admin { background: var(--gold); color: #3a2a00; }
.role-tester { background: rgba(255,255,255,.2); color: #fff; }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; }
.btn-ghost:hover { background: rgba(255,255,255,.12); }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 288px 1fr; align-items: start; }
.sidebar {
  position: sticky; top: 49px; align-self: start; height: calc(100vh - 49px); overflow-y: auto;
  background: var(--card); border-right: 1px solid var(--line); padding: 12px;
}
.navsep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 8px 6px; }
.navitem {
  display: grid; grid-template-columns: 26px 1fr auto; grid-template-rows: auto auto; gap: 2px 8px;
  width: 100%; text-align: left; background: transparent; border: 0; border-radius: 10px;
  padding: 9px 10px; cursor: pointer; align-items: center; color: var(--ink);
}
.navitem:hover { background: #f6f1ea; }
.navitem.active { background: #f0e6d8; }
.navitem .ic { font-size: 18px; grid-row: 1 / span 2; }
.navitem .lbl { font-weight: 600; font-size: 14px; }
.navitem .cnt { font-size: 12px; color: var(--muted); }
.navitem .bar { grid-column: 2 / span 2; height: 5px; background: var(--line); border-radius: 999px; overflow: hidden; }
.navitem .bar i { display: block; height: 100%; background: var(--pass); }

/* ---------- Content ---------- */
.content { padding: 24px clamp(16px, 4vw, 40px); max-width: 900px; }
.modhead h1 { margin: 0 0 6px; font-size: 26px; color: var(--brown); }
.modhead .intro { color: var(--muted); margin: 0 0 20px; }
.modhead .btn { display: inline-block; background: var(--brown); color: #fff; text-decoration: none; padding: 7px 14px; border-radius: 8px; font-size: 14px; }
.legend { font-size: 13px; color: var(--muted); background: #f7f3ec; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; margin: 6px 0 18px; line-height: 1.7; }
.legend b { color: var(--ink); font-weight: 600; white-space: nowrap; }

.case { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.case-top { display: flex; align-items: center; gap: 10px; }
.case-top h2 { margin: 0; font-size: 17px; flex: 1; }
.cid { font-size: 11px; color: var(--muted); font-family: ui-monospace, monospace; }
.pri { font-size: 10px; text-transform: uppercase; font-weight: 700; padding: 2px 7px; border-radius: 999px; }
.pri-high { background: #fbe4e4; color: #a11; }
.pri-medium { background: #fdf1dd; color: #8a5a00; }
.pri-low { background: #e9edf2; color: #556; }
.steps { margin: 12px 0; padding-left: 20px; color: var(--ink); }
.steps li { margin: 3px 0; }
.expected { background: #f7f3ec; border-left: 3px solid var(--gold); padding: 8px 12px; border-radius: 6px; font-size: 14px; margin-bottom: 12px; }
.steps a, .expected a, .intro a { color: var(--brown); font-weight: 600; text-decoration: underline; word-break: break-word; }
.steps a:hover, .expected a:hover, .intro a:hover { color: var(--brown-2); text-decoration: none; }

.verdict { display: flex; gap: 8px; flex-wrap: wrap; }
.v { border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.v:hover { border-color: var(--brown-2); }
.v-pass.sel { background: var(--pass); color: #fff; border-color: var(--pass); }
.v-fail.sel { background: var(--fail); color: #fff; border-color: var(--fail); }
.v-blocked.sel { background: var(--blocked); color: #fff; border-color: var(--blocked); }
.notes-cta { display: block; font-size: 13px; color: var(--brown); margin: 14px 0 5px; }
.notes-cta b { font-weight: 700; }
.notes-cta em { font-style: italic; }
.legend-cta { display: inline-block; margin-top: 6px; color: var(--brown); font-weight: 500; }
.notes { width: 100%; margin-top: 0; min-height: 60px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
.saved { font-size: 12px; color: var(--pass); height: 16px; margin-top: 4px; opacity: 0; transition: opacity .2s; }
.saved.show { opacity: 1; }
.saved.err { color: var(--fail); opacity: 1; }

/* ---------- Admin ---------- */
.summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.scard { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; min-width: 120px; box-shadow: var(--shadow); }
.scard b { font-size: 22px; color: var(--brown); }
.scard span { display: block; font-size: 12px; color: var(--muted); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.tbl { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 13px; }
.tbl th, .tbl td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { background: #f6f1ea; font-size: 12px; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; text-transform: capitalize; }
.pill.pass { background: #e2f5ea; color: #167a43; }
.pill.fail { background: #fbe4e4; color: #a11; }
.pill.blocked { background: #fdf1dd; color: #8a5a00; }

/* ---------- Access management ---------- */
.muted { color: var(--muted); font-size: 13px; }
.access { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 18px; box-shadow: var(--shadow); }
.access h2 { margin: 0 0 4px; font-size: 18px; color: var(--brown); }
.access .muted { margin: 0 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: #f2ece2; border: 1px solid var(--line); border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 13px; }
.chip .x { border: 0; background: #e0d6c8; color: #7a5230; border-radius: 50%; width: 19px; height: 19px; cursor: pointer; line-height: 1; font-weight: 700; font-size: 13px; }
.chip .x:hover { background: var(--fail); color: #fff; }
.chip .lock { font-size: 12px; padding-right: 4px; }
.addrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.addrow input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; min-width: 240px; }
.access .btn { background: var(--brown); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; font: inherit; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 6px; }
  .navitem { width: auto; grid-template-rows: auto; }
  .navitem .bar { display: none; }
  .content { padding: 16px; }
  .topbar { flex-wrap: wrap; }
  .topbar .overall { display: none; }
}
