/* Layout idea: a fixed left rail of sections, one working surface to the right; summary first, tables below. */
:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --ink: #16211f;
  --muted: #5a6966;
  --line: #d9e1df;
  --accent: #0e6a6a;
  --accent-ink: #ffffff;
  --accent-soft: #dff0ee;
  --good: #2a7a4b;   --good-soft: #e1f2e7;
  --warn: #9a5b00;   --warn-soft: #fbeed3;
  --crit: #b0352a;   --crit-soft: #fbe3df;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1514; --surface: #171f1e; --ink: #e5ecea; --muted: #93a29f; --line: #2a3634;
    --accent: #52b9b3; --accent-ink: #06201f; --accent-soft: #173130;
    --good: #6fc594; --good-soft: #173023; --warn: #e2ab4e; --warn-soft: #33270f; --crit: #f08578; --crit-soft: #3a1b17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1514; --surface: #171f1e; --ink: #e5ecea; --muted: #93a29f; --line: #2a3634;
  --accent: #52b9b3; --accent-ink: #06201f; --accent-soft: #173130;
  --good: #6fc594; --good-soft: #173023; --warn: #e2ab4e; --warn-soft: #33270f; --crit: #f08578; --crit-soft: #3a1b17;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.45 var(--font-body); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; text-wrap: balance; }
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.shell { display: grid; grid-template-columns: 208px minmax(0, 1fr); min-height: 100%; }
.nav { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 12px; display: flex; flex-direction: column; gap: 20px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; font-family: var(--font-display); font-size: 17px; }
.brand b { font-weight: 600; }
.brand-mark { width: 22px; height: 22px; border-radius: 5px; background: linear-gradient(90deg, var(--accent) 0 60%, var(--warn) 60% 100%); }
#nav { display: flex; flex-direction: column; gap: 2px; }
#nav a { padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; font-weight: 500; }
#nav a:hover { background: var(--bg); }
#nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-foot { margin-top: auto; padding: 0 8px; font-size: 12px; color: var(--muted); }

main { padding: 28px 32px 56px; display: flex; flex-direction: column; gap: 20px; min-width: 0; outline: none; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; }
.head .sub { color: var(--muted); margin-top: 2px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; align-items: start; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; border-top: 3px solid var(--line); }
.tile.bench { border-top-color: var(--warn); }
.tile.util { border-top-color: var(--accent); }
.tile .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.tile .v { font-family: var(--font-display); font-size: 34px; font-weight: 600; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .n { font-size: 13px; color: var(--muted); margin-top: 2px; }

.banner { border: 1px solid var(--line); border-left: 4px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; }
.banner.crit { border-left-color: var(--crit); background: var(--crit-soft); }
.banner.info { border-left-color: var(--accent); background: var(--accent-soft); }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td .name { font-weight: 500; }

.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.pill.bench { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.partial { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.full, .pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.over, .pill.crit { background: var(--crit-soft); color: var(--crit); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; gap: 6px; align-items: baseline; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; font-size: 13px; }
.chip b { font-weight: 500; }
.chip .num { color: var(--muted); }

.rolebar { display: grid; grid-template-columns: minmax(110px, 180px) minmax(60px, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; }
.bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; background: var(--bg); }
.bar i { display: block; height: 100%; }
.bar .busy { background: var(--accent); }
.bar .partial { background: color-mix(in srgb, var(--accent) 45%, var(--surface)); }
.bar .bench { background: var(--warn); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; background: var(--c); }

.proj { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.proj:first-of-type { border-top: 0; padding-top: 0; }
.proj-head { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }

.btn { font: inherit; font-weight: 500; padding: 7px 13px; border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.link { border: 0; background: none; padding: 2px 6px; color: var(--accent); }
.btn.link.danger { color: var(--crit); }
.btn[disabled] { opacity: 0.55; cursor: default; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; min-width: 0; }
textarea { width: 100%; min-height: 150px; resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; padding: 0; accent-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); font-weight: 400; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px 12px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; max-height: 150px; overflow: auto; }
pre.out { margin: 0; padding: 12px 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; overflow-x: auto; font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; white-space: pre; }

dialog { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(8, 16, 15, 0.5); }
#dlgForm { padding: 20px 22px; display: flex; flex-direction: column; gap: 16px; }
#dlgBody { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
#dlgBody > .wide { grid-column: 1 / -1; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }
.form-error { color: var(--crit); font-size: 14px; }
.hint { font-size: 12px; font-weight: 400; color: var(--muted); }

.empty { text-align: center; padding: 34px 16px; color: var(--muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }
.empty h2 { color: var(--ink); }
.empty .row { justify-content: center; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 6px; font-size: 14px; max-width: calc(100vw - 32px); opacity: 0; pointer-events: none; transition: opacity 0.15s; }
#toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { position: static; height: auto; flex-direction: column; gap: 10px; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  #nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  #nav a { white-space: nowrap; }
  .nav-foot { margin-top: 0; }
  main { padding: 20px 16px 48px; }
  #dlgBody { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .rolebar { grid-template-columns: 1fr; gap: 4px; }
}

/* sign-in */
body.signed-out .shell { display: none; }
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.auth[hidden] { display: none; }
.auth-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 10px; padding: 26px 24px; display: flex; flex-direction: column; gap: 14px; }
.auth-card .brand { padding: 0; }
.auth-card .btn.primary { padding: 10px 13px; }
.auth-card .btn.link { align-self: center; }
.nav-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.nav-foot .who { display: flex; flex-direction: column; padding: 0 6px 6px; }
.nav-foot .who b { color: var(--ink); font-weight: 500; font-size: 14px; }
.nav-foot .btn.link { font-size: 13px; }
#nav a[hidden] { display: none; }
@media (max-width: 820px) { .nav-foot { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 10px; } .nav-foot .who { flex-direction: row; gap: 8px; padding: 0 6px; } }
