:root {
  color-scheme: light;
  --ink: #171a1f;
  --muted: #606874;
  --line: #d9dde2;
  --soft: #e8ebee;
  --paper: #ffffff;
  --shell: #15191f;
  --shell-2: #252b33;
  --orange: #ff5a00;
  --orange-dark: #c94700;
  --yellow: #ffc107;
  --green: #17854a;
  --red: #c9342f;
  --blue: #1d4e73;
  --radius: 5px;
  --tap: 48px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--shell); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--soft); color: var(--ink); padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.topbar { position: relative; min-height: calc(76px + env(safe-area-inset-top)); padding: calc(10px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 10px max(18px, env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--shell); color: white; }
.topbar::after { position: absolute; right: 0; bottom: 0; left: 0; height: 2px; content: ""; background: linear-gradient(90deg, var(--orange) 0 150px, #39414b 150px 100%); }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.brand-logo { width: 166px; height: auto; flex: 0 0 auto; object-fit: contain; }
.brand-module { display: grid; padding-left: 12px; border-left: 1px solid #454c56; }
.brand small, .command-band small, .content-band header small { color: #aab1ba; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.brand strong { font-family: Montserrat, "Arial Narrow", Arial, sans-serif; font-size: 17px; letter-spacing: .01em; }
.identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.identity > span { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cbd0d6; font-size: 12px; }
.icon-button { width: var(--tap); height: var(--tap); border: 1px solid #444b55; border-radius: var(--radius); display: grid; place-items: center; color: white; background: var(--shell-2); }
.icon-button.light { background: var(--paper); color: var(--ink); border-color: var(--line); }
.command-band { padding: 25px max(18px, calc((100vw - 1240px) / 2)); display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 16px 20px; background: linear-gradient(115deg, rgba(21,25,31,.98), rgba(31,37,45,.97)), repeating-linear-gradient(90deg, transparent 0 79px, rgba(255,255,255,.035) 80px); color: white; border-top: 1px solid #363c45; }
.command-band h1 { margin: 3px 0; font-family: Montserrat, "Arial Narrow", Arial, sans-serif; font-size: clamp(24px, 5vw, 38px); letter-spacing: -.02em; }
.command-band p { margin: 0; color: #aeb5be; font-size: 13px; }
.command-controls { display: flex; gap: 10px; align-items: center; }
.scope-controls { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.scope-controls label { color: #aeb5be; }
.scope-controls select { color: white; border-color: #454c56; background: var(--shell-2); }
.segmented { display: flex; padding: 3px; background: #15181d; border: 1px solid #3a414b; border-radius: var(--radius); }
.segmented button { min-height: 44px; padding: 0 14px; border: 0; border-radius: 5px; color: #b7bdc5; background: transparent; font-weight: 750; }
.segmented button.active { color: var(--ink); background: var(--paper); }
.section-nav { position: sticky; top: 0; z-index: 8; display: flex; overflow-x: auto; scrollbar-width: none; background: var(--paper); border-bottom: 1px solid var(--line); padding: 0 max(18px, calc((100vw - 1240px) / 2)); }
.section-nav button { flex: 0 0 auto; min-height: 58px; padding: 0 15px; border: 0; border-bottom: 3px solid transparent; display: flex; align-items: center; gap: 8px; background: transparent; color: var(--muted); font-weight: 750; }
.section-nav button.active { color: var(--ink); border-color: var(--orange); }
.section-nav b { min-width: 22px; height: 22px; padding: 0 5px; display: grid; place-items: center; border-radius: 11px; background: var(--soft); font-size: 11px; }
.view { max-width: 1240px; margin: 0 auto; padding: 22px 18px; }
.status-band { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: var(--radius); }
.status-band.degraded { border-left-color: var(--yellow); }
.status-band strong { font-size: 15px; }
.status-band span { color: var(--muted); font-size: 13px; }
.metric-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric { min-height: 120px; padding: 16px; background: var(--paper); border: 1px solid var(--line); border-top: 3px solid #b9bec4; border-radius: var(--radius); display: flex; flex-direction: column; justify-content: space-between; box-shadow: 0 5px 18px rgba(21,25,31,.055); }
.metric:nth-child(4n + 1) { border-top-color: var(--orange); }
.metric span { color: var(--muted); font-size: 13px; font-weight: 700; }
.metric strong { font-size: 28px; }
.metric small { color: #7a828d; line-height: 1.35; }
.metric.unavailable strong { color: #9aa1aa; font-size: 18px; }
.content-band { margin-top: 14px; padding: 18px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 5px 18px rgba(21,25,31,.045); }
.content-band > header { min-height: 48px; margin-bottom: 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.content-band h2 { margin: 3px 0 0; font-size: 19px; }
.content-band header small { color: var(--orange-dark); }
.content-band header > span { color: var(--muted); font-size: 12px; }
.flow { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.flow-step { min-width: 0; padding: 14px 10px; border-top: 3px solid var(--line); background: var(--soft); }
.flow-step.complete { border-color: var(--green); }
.flow-step.active { border-color: var(--orange); }
.flow-step span { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.flow-step strong { display: block; margin-top: 5px; font-size: 21px; }
.timeline { min-height: 180px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); align-items: end; gap: 8px; }
.timeline-day { min-width: 0; display: grid; gap: 6px; text-align: center; }
.timeline-bar { height: 120px; display: flex; align-items: flex-end; justify-content: center; background: var(--soft); border-radius: 4px 4px 0 0; overflow: hidden; }
.timeline-bar i { width: 100%; min-height: 3px; background: var(--orange); display: block; }
.timeline-day strong { font-size: 13px; }
.timeline-day small { color: var(--muted); font-size: 10px; }
.breakdown-grid, .health-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.breakdown, .health-card { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); }
.breakdown h3, .health-card h3 { margin: 0 0 10px; font-size: 14px; }
.breakdown-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--soft); font-size: 13px; }
.health-card strong { display: block; font-size: 25px; margin-top: 6px; }
.health-card p { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.record-list, .audit-list { display: grid; gap: 8px; }
.record { min-height: 72px; padding: 13px 14px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: var(--radius); }
.record.selectable { grid-template-columns: 34px minmax(0, 1fr) auto; }
.record h3 { margin: 0 0 5px; font-size: 15px; }
.record p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }
.record-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 7px; }
.chip { min-height: 25px; padding: 4px 8px; display: inline-flex; align-items: center; border-radius: 4px; background: var(--soft); color: var(--muted); font-size: 11px; font-weight: 800; }
.chip.success { background: #e7f5ed; color: var(--green); }
.chip.warning { background: #fff4ce; color: #765800; }
.chip.danger { background: #fdebea; color: var(--red); }
.record-actions { display: flex; gap: 7px; align-items: center; }
.text-command, .secondary-command, .primary-command { min-height: var(--tap); border-radius: var(--radius); display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 800; }
.text-command { padding: 0 10px; color: var(--orange-dark); }
.secondary-command { padding: 0 13px; border: 1px solid var(--line); color: var(--ink); background: var(--paper); }
.primary-command { padding: 0 18px; border: 1px solid var(--orange); color: white; background: var(--orange); }
.primary-command:disabled, .secondary-command:disabled { opacity: .4; cursor: not-allowed; }
.inline-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid #bfc5cc; border-radius: var(--radius); color: var(--ink); background: var(--paper); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(230, 92, 0, .28); outline-offset: 2px; }
.audit-entry { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 160px minmax(0, 1fr) auto; gap: 14px; font-size: 12px; }
.audit-entry strong { font-size: 13px; }
.audit-entry span { color: var(--muted); }
.empty { padding: 28px 14px; color: var(--muted); text-align: center; border: 1px dashed #c8cdd3; }
dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 30px); padding: 0; border: 0; border-radius: var(--radius); color: var(--ink); box-shadow: 0 20px 70px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(16, 18, 22, .72); }
dialog form { padding: 18px; display: grid; gap: 14px; }
dialog header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
dialog h2 { margin: 3px 0 0; font-size: 20px; }
dialog small { color: var(--orange-dark); font-size: 11px; font-weight: 800; text-transform: uppercase; }
#dialogBody { display: grid; gap: 12px; }
.temporary-password { padding: 14px; border: 2px solid var(--orange); background: #fff7f1; overflow-wrap: anywhere; font: 700 15px ui-monospace, SFMono-Regular, Menlo, monospace; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(460px, calc(100vw - 30px)); padding: 13px 15px; border-radius: var(--radius); background: #121519; color: white; text-align: center; font-size: 13px; box-shadow: 0 12px 32px rgba(0, 0, 0, .28); }

@media (max-width: 820px) {
  .identity > span { display: none; }
  .command-band { align-items: stretch; flex-direction: column; }
  .command-band { grid-template-columns: 1fr; }
  .scope-controls { grid-column: 1; grid-template-columns: 1fr; }
  .command-controls { justify-content: space-between; }
  .segmented { flex: 1; }
  .segmented button { flex: 1; }
  .section-nav { padding: 0; }
  .section-nav button { position: relative; min-width: 86px; justify-content: center; flex-direction: column; gap: 2px; font-size: 10px; }
  .section-nav button svg { width: 20px; height: 20px; }
  .section-nav button b { position: absolute; top: 4px; right: 8px; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .flow { grid-template-columns: repeat(3, 1fr); }
  .breakdown-grid, .health-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .audit-entry { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 520px) {
  .brand-logo { width: 112px; }
  .brand-module { display: none; }
  .view { padding: 14px 10px; }
  .command-band { padding-left: 14px; padding-right: 14px; }
  .content-band { padding: 14px 12px; }
  .metric { min-height: 110px; padding: 13px; }
  .metric strong { font-size: 24px; }
  .flow-step strong { font-size: 18px; }
  .record, .record.selectable { grid-template-columns: minmax(0, 1fr); }
  .record.selectable > input { width: 28px; height: 28px; }
  .record-actions { justify-content: stretch; }
  .record-actions > * { flex: 1; }
  .content-band > header { align-items: flex-start; }
  .timeline { gap: 4px; }
  .timeline-day small { font-size: 9px; }
}

@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 84px; }
}

@media (prefers-reduced-motion: no-preference) {
  button, a, .metric, .record { transition: transform 120ms ease, border-color 160ms ease, background-color 160ms ease; }
  button:active { transform: scale(.97); }
}
