:root {
  color-scheme: dark;
  --bg: #0d0d0d;
  --panel: #131313;
  --line: #262626;
  --fg: #e5e5e5;
  --muted: #888;
  --accent: #3fa96d;
  --side: 15rem;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
}

h1 { margin: 0; font-size: 1.25rem; letter-spacing: 0.05em; }
.subtitle { color: var(--muted); font-size: 0.8rem; margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }

/* sign in */
#login { padding: 2rem; }
#login .subtitle { margin: 0.25rem 0 2rem; }
.card { display: flex; flex-direction: column; gap: 0.75rem; max-width: 20rem; }
.card input, .card button {
  padding: 0.6rem; background: #161616; color: var(--fg);
  border: 1px solid #333; font: inherit;
}
.card button { background: var(--accent); color: #000; border: 0; }
.err { color: #e53935; min-height: 1em; margin: 0; font-size: 0.8rem; }

/* shell */
#app { min-height: 100vh; }
#sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side);
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; overflow-y: auto; z-index: 20;
  transition: transform 0.2s;
}
#content { margin-left: var(--side); padding: 1.5rem 2rem; transition: margin 0.2s; }
.nav-collapsed #sidebar { transform: translateX(-100%); }
.nav-collapsed #content { margin-left: 0; }

.brand { padding: 1.1rem 1rem; border-bottom: 1px solid var(--line); letter-spacing: 0.08em; }
#nav { flex: 1; padding: 0.5rem 0; }

.group-head {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  background: none; border: 0; padding: 0.6rem 1rem; text-align: left;
  color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em;
}
.group-head:hover { color: var(--fg); }
.chev { transition: transform 0.15s; }
.group.closed .chev { transform: rotate(-90deg); }
.group.closed .group-items { display: none; }
.group-items a {
  display: block; padding: 0.45rem 1rem 0.45rem 1.5rem; color: var(--fg);
  text-decoration: none; font-size: 0.85rem; border-left: 2px solid transparent;
}
.group-items a:hover { background: #1b1b1b; }
.group-items a.active { border-left-color: var(--accent); color: var(--accent); background: #181d1a; }
.link { background: none; border: 0; border-top: 1px solid var(--line); padding: 0.9rem 1rem; text-align: left; color: var(--muted); }

#scrim { display: none; }
.top { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.5rem; }
.top .subtitle { margin-left: auto; }
#menuToggle { background: none; border: 1px solid var(--line); padding: 0.35rem 0.6rem; font-size: 1rem; }

/* views */
.metrics { display: flex; gap: 2rem; flex-wrap: wrap; }
.metric { display: flex; flex-direction: column; min-width: 8rem; }
.metric .value { font-size: 2.5rem; font-weight: 600; color: var(--accent); }
.metric .label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.empty { color: var(--muted); }
.checklist { list-style: none; padding: 0; margin: 0; line-height: 2; }
.checklist .done { color: var(--accent); }
.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.8rem; }
th, td { text-align: left; padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 400; text-transform: uppercase; font-size: 0.7rem; letter-spacing: 0.06em; }

@media (max-width: 800px) {
  #content { margin-left: 0; padding: 1rem; }
  body:not(.nav-collapsed) #scrim { display: block; position: fixed; inset: 0; background: #0009; z-index: 10; }
  .top .subtitle { display: none; }
}

/* forms and actions */
.toolbar { margin-bottom: 1rem; }
button.sm, button.ghost { padding: 0.3rem 0.65rem; font-size: 0.75rem; background: none; border: 1px solid var(--line); }
.toolbar button.sm { border-color: var(--accent); color: var(--accent); }
button.ghost:hover { border-color: var(--accent); }
.rowbtns { display: flex; gap: 0.35rem; }
dialog { background: var(--panel); color: var(--fg); border: 1px solid var(--line); padding: 0; max-width: min(42rem, 94vw); width: 100%; max-height: 90vh; overflow: auto; }
dialog::backdrop { background: #000a; }
.modal { display: flex; flex-direction: column; gap: 0.75rem; padding: 1.25rem; }
.modal h2 { margin: 0; font-size: 1rem; }
.field { display: flex; flex-direction: column; gap: 0.25rem; }
.flabel { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.modal input, .modal select, .modal textarea { padding: 0.5rem; background: #161616; color: var(--fg); border: 1px solid #333; font: inherit; }
.modal input[type=checkbox] { align-self: flex-start; }
.rows { display: flex; flex-direction: column; gap: 0.5rem; }
.rowline { display: grid; grid-template-columns: repeat(auto-fit, minmax(7rem, 1fr)) auto; gap: 0.5rem; align-items: end; padding: 0.5rem; border: 1px solid var(--line); }
.x { background: none; border: 0; color: var(--muted); }
.btns { display: flex; gap: 0.5rem; }
.btns button:first-child { background: var(--accent); color: #000; border: 0; padding: 0.5rem 1rem; }
.result { margin: 0; white-space: pre-wrap; word-break: break-all; font-size: 0.75rem; }
