:root {
  color-scheme: dark;
  font-family: Inter, system-ui, sans-serif;
  background: #11161d;
  color: #eff4f8;
  --page: #11161d;
  --panel: #1b222c;
  --surface: #242d39;
  --border: #3a4758;
  --text: #eff4f8;
  --muted: #b0bfcd;
  --accent: #83dcff;
  --ok: #9ee6ba;
  --warning: #ffdb8c;
  --danger: #ff9c9b;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.5; }
h1, h2, h3, h4, p, dl { margin: 0; }
h1, h2, h3 { line-height: 1.16; }
h1 { font-size: clamp(1.8rem, 5vw, 2.65rem); letter-spacing: -.035em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
a { color: var(--accent); }
button, input, textarea, select { font: inherit; }
button, input, textarea, select { border: 1px solid var(--border); border-radius: .45rem; }
input, textarea, select {
  width: 100%;
  min-width: 0;
  background: var(--page);
  color: var(--text);
  padding: .65rem .75rem;
}
textarea { resize: vertical; }
input::placeholder { color: var(--muted); }
button {
  padding: .56rem .85rem;
  min-height: 2.65rem;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { cursor: not-allowed; opacity: .65; }
button.primary { background: var(--accent); border-color: var(--accent); color: #10232b; }
button.danger { border-color: #98686c; color: var(--danger); }
button.quiet { background: transparent; }
button.small { font-size: .85rem; padding: .35rem .6rem; min-height: 2.2rem; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
label { display: block; font-size: .875rem; font-weight: 650; margin-bottom: .32rem; }
main { margin: 0 auto; padding: 1.6rem clamp(.85rem, 4vw, 2rem) 3rem; max-width: 1440px; }
.skip-link {
  position: fixed;
  inset: .5rem auto auto .5rem;
  transform: translateY(-200%);
  padding: .5rem 1rem;
  z-index: 2;
  background: var(--panel);
}
.skip-link:focus { transform: translateY(0); }
.site-header { background: #181e27; border-bottom: 1px solid var(--border); }
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: .75rem clamp(.85rem, 4vw, 2rem);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 750; white-space: nowrap; }
.brand-mark {
  display: inline-block;
  width: .95rem;
  height: .95rem;
  background: var(--accent);
  border-radius: .18rem;
  transform: rotate(45deg) scale(.75);
}
nav { display: flex; flex-wrap: wrap; gap: .15rem .7rem; }
nav a { padding: .4rem .24rem; color: var(--muted); font-size: .88rem; text-decoration: none; }
nav a:hover { color: var(--text); text-decoration: underline; }
#logout-button { margin-left: auto; }
.login-view { display: grid; place-items: center; min-height: 64vh; }
.login-panel { width: min(100%, 27rem); }
.login-panel h1 { margin-bottom: 1.25rem; }
.login-panel input { margin-bottom: .9rem; }
.login-panel button { width: 100%; }
.login-panel .notice { margin-bottom: 0; }
section + section { margin-top: 2.3rem; }
.overview-top, .panel-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .55rem 1rem; }
.overview-top { margin-bottom: 1rem; }
.overview-top p { margin-top: .35rem; }
.section-title { margin-bottom: .75rem; }
.mode-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: .85rem 1.5rem;
  padding: 1rem 1.2rem;
  border-radius: .55rem;
  border: 1px solid currentColor;
  background: #172936;
}
.mode-banner[data-tone="danger"] { background: #362227; }
.mode-banner[data-tone="warning"] { background: #352d1d; }
.mode-account { max-width: 100%; }
.mode-account p:last-child { font-family: "IBM Plex Mono", ui-monospace, monospace; overflow-wrap: anywhere; }
.eyebrow { font-size: .72rem; font-weight: 750; letter-spacing: .07em; text-transform: uppercase; }
.mode-value { font-size: clamp(1.6rem, 4.6vw, 2.4rem); font-weight: 800; letter-spacing: -.03em; }
[data-tone="info"] { color: var(--accent); }
[data-tone="ok"] { color: var(--ok); }
[data-tone="warning"] { color: var(--warning); }
[data-tone="danger"] { color: var(--danger); }
.notice { margin: .75rem 0; overflow-wrap: anywhere; }
.notice:empty { display: none; }
.muted, .empty { color: var(--muted); }
.empty { margin-top: .7rem; }
.metric-grid, .panel-grid, .action-grid, .filter-grid { display: grid; gap: .75rem; }
.metric-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr)); }
.overview .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric {
  padding: .82rem .95rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: .55rem;
  min-width: 0;
}
.metric dt { font-size: .8rem; color: var(--muted); }
.metric dd { margin: .15rem 0 0; font-size: 1.15rem; font-weight: 670; overflow-wrap: anywhere; }
.metric small { display: block; color: var(--muted); font-size: .75rem; font-weight: 400; }
.panel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel {
  border: 1px solid var(--border);
  border-radius: .6rem;
  background: var(--panel);
  padding: 1rem;
  min-width: 0;
}
.panel-grid + .panel, .panel + .panel-grid, .operations { margin-top: .75rem; }
.panel h3 { margin-bottom: .15rem; }
.panel-heading { margin-bottom: .6rem; }
.action-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); margin: .85rem 0; }
.control { display: flex; flex-direction: column; align-items: flex-start; gap: .4rem; }
.control p { color: var(--muted); font-size: .83rem; }
.badge {
  display: inline-block;
  padding: .17rem .5rem;
  border: 1px solid var(--border);
  border-radius: .35rem;
  font-weight: 650;
  font-size: .76rem;
}
.filter-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); align-items: end; margin: .65rem 0; }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .65rem; margin: .6rem 0; }
.inline-form div { flex: 0 1 21rem; }
#performance-metrics { margin-top: .75rem; }
#performance-metrics .metric { background: var(--page); }
.facts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); font-size: .88rem; margin: .45rem 0; }
.facts dt, .facts dd { padding: .34rem 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.facts dt { color: var(--muted); padding-right: .65rem; }
.facts dd { margin: 0; }
.table-scroll { overflow: auto; margin-top: .55rem; }
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
th { color: var(--muted); font-weight: 650; font-size: .76rem; }
th:first-child, td:first-child { padding-left: .1rem; }
th:last-child, td:last-child { padding-right: .1rem; }
td.amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
details { margin-top: .5rem; }
summary { cursor: pointer; color: var(--accent); }
pre, #policy-document {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: .82rem;
  line-height: 1.55;
  tab-size: 2;
}
pre {
  max-height: 22rem;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: .4rem;
  background: var(--page);
}
#policy-editor, #revision-detail:not(:empty) { margin: .85rem 0; }
#policy-guided {
  min-width: 0;
  margin: 0;
  padding: .55rem .75rem .75rem;
  border: 1px solid var(--border);
  border-radius: .45rem;
}
#policy-guided legend { padding: 0 .35rem; font-weight: 650; }
#policy-guided .filter-grid { align-items: start; }
#policy-advanced { margin-bottom: .55rem; }
#policy-advanced label { margin-top: .55rem; }
.check-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-height: 2.75rem;
  margin-bottom: 0;
  overflow-wrap: anywhere;
}
.check-row input { flex: 0 0 auto; width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--accent); }
#revision-detail:not(:empty) { border-top: 1px solid var(--border); padding-top: .85rem; }
.button-group { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: .75rem; }
dialog {
  width: min(calc(100% - 1.5rem), 43rem);
  max-height: calc(100dvh - 1.5rem);
  overflow: auto;
  padding: clamp(1rem, 4vw, 1.5rem);
  border: 1px solid var(--border);
  border-radius: .65rem;
  background: var(--panel);
  color: var(--text);
}
dialog::backdrop { background: #0a0e14d9; }
dialog h2 { margin-bottom: .55rem; }
dialog label { margin-top: .65rem; }
dialog input, dialog textarea { margin-top: .12rem; }
dialog .button-group { justify-content: end; }
@media (max-width: 760px) {
  .panel-grid { grid-template-columns: minmax(0, 1fr); }
  .header-inner nav { order: 3; flex-basis: 100%; }
  .overview .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 400px) {
  .mode-banner, .panel { padding: .78rem; }
  th, td { padding-inline: .35rem; }
}
@media (max-width: 350px) {
  .overview .metric-grid { grid-template-columns: minmax(0, 1fr); }
}
