/* Valuable. One stylesheet, tokens for both themes. Light is the product's
   own look; dark follows the device. No inline styles anywhere: the content
   security policy forbids them. */

:root {
  --navy: #1B3A6B;
  --blue: #2E75B6;
  --bg: #F3F5F8;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --text: #18212F;
  --muted: #5A6677;
  --line: #DCE2EA;
  --accent: #2E75B6;
  --accent-text: #FFFFFF;
  --accent-soft: #E6F0FA;
  --good: #1E7B4C;
  --good-soft: #E3F4EA;
  --warn: #9A5B00;
  --warn-soft: #FFF2D9;
  --bad: #B3261E;
  --bad-soft: #FCE8E6;
  --bar: #1B3A6B;
  --bar-text: #FFFFFF;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .06);
  --radius: 12px;
  --tap: 44px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1726;
    --surface: #162235;
    --surface-2: #1B2A41;
    --text: #E8EDF5;
    --muted: #9AA8BC;
    --line: #2A3B55;
    --accent: #5BA3E0;
    --accent-text: #08121F;
    --accent-soft: #1D3350;
    --good: #5FCB94;
    --good-soft: #173527;
    --warn: #F0B45A;
    --warn-soft: #3A2C12;
    --bad: #F2867F;
    --bad-soft: #401B19;
    --bar: #111C2E;
    --bar-text: #E8EDF5;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
}

[hidden] { display: none !important; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.25; }
h2 { font-size: 1.125rem; line-height: 1.3; }
h3 { font-size: 1rem; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 20px; }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ----------------------------------------------------------------- boot */

.boot {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  background: var(--navy); color: #fff;
}
.boot-mark, .mark {
  width: 64px; height: 64px; border-radius: 16px;
  display: grid; place-items: center;
  background: #fff; color: var(--navy);
  font-weight: 800; font-size: 34px; letter-spacing: -1px;
}
.boot-text { font-weight: 600; letter-spacing: .5px; }

/* -------------------------------------------------------------- sign-in */

.signin {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--navy) 0, var(--navy) 38%, var(--bg) 38%);
}
.signin-brand { color: #fff; text-align: center; margin-bottom: 24px; }
.signin-brand .mark { margin: 0 auto 14px; }
.signin-brand h1 { font-size: 1.75rem; }
.signin-brand p { opacity: .85; }
.signin-card { width: 100%; max-width: 420px; }
.signin-foot { margin-top: 20px; text-align: center; }

/* ---------------------------------------------------------------- shell */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bar); color: var(--bar-text);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; gap: 12px;
}
.topbar .mark { width: 34px; height: 34px; border-radius: 9px; font-size: 19px; flex: none; }
.topbar .brand { font-weight: 700; font-size: 1.0625rem; }
.topbar .env {
  font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  background: #F0B45A; color: #2B1D00; padding: 2px 8px; border-radius: 999px;
}
.topbar .who { margin-left: auto; font-size: .875rem; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw; }

.layout { display: flex; min-height: calc(100dvh - 54px); }

.nav {
  flex: none; width: 216px; padding: 16px 12px;
  border-right: 1px solid var(--line); background: var(--surface);
}
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: var(--tap); padding: 8px 12px; margin-bottom: 4px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer;
}
.nav button:hover { background: var(--surface-2); }
.nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .glyph { width: 22px; text-align: center; flex: none; }

.main { flex: 1 1 auto; min-width: 0; padding: 24px; }
.page { max-width: 880px; margin: 0 auto; }
.page-head { margin-bottom: 20px; }
.page-head p { margin-top: 4px; }

@media (max-width: 760px) {
  .layout { display: block; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; width: auto;
    display: flex; gap: 4px; padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line);
  }
  .nav button {
    flex: 1 1 0; flex-direction: column; gap: 2px; justify-content: center;
    margin: 0; padding: 6px 4px; min-height: 52px; font-size: .75rem; text-align: center;
  }
  .nav .glyph { width: auto; font-size: 1.125rem; }
  .main { padding: 16px 16px calc(84px + env(safe-area-inset-bottom)); }
}

/* ---------------------------------------------------------------- parts */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card h2 { margin-bottom: 4px; }
.card + .card { margin-top: 16px; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

.tile {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 14px;
}
.tile .count { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.tile .label { font-weight: 600; }

.notice { border-radius: 10px; padding: 12px 14px; font-size: .9375rem; }
.notice.info { background: var(--accent-soft); color: var(--text); }
.notice.good { background: var(--good-soft); color: var(--good); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }

label.field { display: block; }
label.field > span { display: block; font-size: .875rem; font-weight: 600; margin-bottom: 6px; }
label.field > small { display: block; color: var(--muted); margin-top: 4px; }

input[type="text"], input[type="email"], input[type="search"], input[type="date"], input[type="month"],
input[type="url"], input[type="number"], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
input.code {
  font-size: 1.75rem; letter-spacing: .4em; text-align: center; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 18px;
  border: 1px solid transparent; border-radius: 10px;
  background: var(--accent); color: var(--accent-text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.06); }
.btn[disabled] { opacity: .55; cursor: default; filter: none; }
.btn.block { width: 100%; }
.btn.quiet { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.plain { background: transparent; color: var(--accent); padding: 10px 8px; }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .875rem; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }

.pill {
  display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.pill.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; max-width: min(92vw, 480px);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: .9375rem;
}
.toast.bad { background: var(--bad); color: #fff; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .nav button { transition: background-color .12s ease, filter .12s ease; }
}
