:root {
  --paper: oklch(26.5% 0.006 210);
  --paper-2: oklch(29.5% 0.007 210);
  --paper-3: oklch(32.5% 0.008 210);
  --ink: oklch(95% 0.006 210);
  --ink-2: oklch(84% 0.007 210);
  --muted: oklch(72% 0.007 210);
  --rule: oklch(40% 0.009 210);
  --rule-2: oklch(53% 0.01 210);
  --accent: oklch(73.76% 0.1257 209.5);
  --accent-hover: oklch(82% 0.132 209.5);
  --positive: oklch(77% 0.16 160);
  --warning: oklch(81% 0.15 75);
  --error: oklch(74% 0.16 15);
  --font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Arial Narrow", Inter, ui-sans-serif, sans-serif;
  --mono: "SFMono-Regular", Consolas, monospace;
  --radius: .625rem;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-width: 20rem; min-height: 100%; background: var(--paper); color: var(--ink); }
body { font-family: var(--font); font-size: 1rem; line-height: 1.55; -webkit-font-smoothing: antialiased; }
body:has(dialog[open]) { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.03em; }
button { color: inherit; }
[hidden] { display: none !important; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: clip; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; z-index: 1000; inset: .75rem auto auto .75rem; padding: .7rem 1rem; transform: translateY(-150%); background: var(--accent); color: #04282c; border-radius: .35rem; }
.skip-link:focus { transform: none; }
:focus-visible { outline: 2px solid oklch(90% .08 210); outline-offset: 3px; }

.topbar { position: sticky; top: 0; z-index: 20; min-height: 4.5rem; padding: 0 clamp(1rem, 4vw, 3rem); display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--paper); border-bottom: 1px solid var(--rule); }
.brand { min-width: 0; display: inline-flex; align-items: center; gap: .8rem; }
.brand img { width: 8.2rem; height: 2rem; }
.brand span { padding-left: .8rem; border-left: 1px solid var(--rule); color: var(--muted); font-size: .85rem; white-space: nowrap; }
.topbar__actions { display: flex; gap: .5rem; }

.button, .icon-button { min-height: 2.75rem; border: 1px solid var(--rule-2); background: transparent; border-radius: var(--radius); cursor: pointer; transition: border-color .15s ease, background .15s ease, color .15s ease; }
.button { padding: .7rem 1rem; font-size: .84rem; font-weight: 700; }
.button:hover, .icon-button:hover { border-color: var(--ink-2); }
.button--primary { background: var(--accent); border-color: var(--accent); color: #06272b; }
.button--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button--quiet { color: var(--ink-2); }
.button:disabled { opacity: .45; cursor: wait; }
.icon-button { min-width: 3rem; padding: .65rem .8rem; color: var(--muted); font-size: .78rem; font-weight: 700; }

.auth-screen { min-height: calc(100vh - 4.5rem); padding: clamp(3rem, 8vw, 7rem) 1rem; }
.auth-panel { width: min(100%, 31rem); margin: 0 auto; }
.plain-label { color: var(--accent); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
.auth-panel h1 { margin-top: .8rem; font-size: clamp(2.35rem, 6vw, 4.5rem); line-height: 1; }
.auth-panel > p:not(.plain-label) { margin-top: 1.4rem; color: var(--muted); font-size: 1.08rem; }
.stack-form { margin-top: 2.5rem; display: grid; gap: 1rem; }
label { display: grid; gap: .45rem; color: var(--ink-2); font-size: .8rem; font-weight: 650; }
input, select, textarea { width: 100%; min-height: 2.9rem; padding: .72rem .82rem; border: 1px solid var(--rule-2); border-radius: .4rem; background: var(--paper-2); color: var(--ink); }
textarea { resize: vertical; }
input::placeholder { color: oklch(61% .007 210); }
label small { color: var(--muted); font-size: .72rem; font-weight: 400; }
.form-message { min-height: 1.5rem; color: var(--error); font-size: .82rem; }
.form-message[data-state="success"] { color: var(--positive); }

.dashboard { width: min(100%, 92rem); margin: 0 auto; padding: clamp(2.5rem, 6vw, 5rem) clamp(1rem, 4vw, 3rem) 6rem; }
.dashboard-head { display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
.dashboard-head h1 { font-size: clamp(2.25rem, 4.5vw, 4.5rem); line-height: 1; }
.dashboard-head p { margin-top: .75rem; color: var(--muted); font-size: 1.05rem; }

.metrics { margin-top: 3.5rem; display: grid; grid-template-columns: repeat(4, 1fr); border-block: 1px solid var(--rule); }
.metrics div { min-height: 8rem; padding: 1.35rem 1.5rem; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--rule); }
.metrics div:first-child { padding-left: 0; }
.metrics div:last-child { border-right: 0; }
.metrics strong { font-family: var(--display); font-size: clamp(2rem, 4vw, 3.4rem); line-height: 1; }
.metrics span { color: var(--muted); font-size: .78rem; }

.policy-strip { margin-top: 2rem; padding: 1.5rem 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2rem; border-bottom: 1px solid var(--rule); }
.policy-strip h2 { font-size: 1rem; }
.policy-strip p { margin-top: .35rem; max-width: 65rem; color: var(--muted); font-size: .83rem; }
.policy-strip__legend { display: flex; align-items: center; gap: 1rem; color: var(--muted); font-size: .72rem; white-space: nowrap; }
.policy-strip__legend span, .health-label { display: inline-flex; align-items: center; gap: .42rem; }
.signal { width: .5rem; height: .5rem; display: inline-block; border-radius: 50%; background: var(--rule-2); }
.signal--healthy { background: var(--positive); }
.signal--degraded { background: var(--warning); }
.signal--down { background: var(--error); }
.signal--unknown { background: var(--rule-2); }

.directory-admin { margin-top: 4rem; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
.section-head h2 { font-size: clamp(1.8rem, 3vw, 2.7rem); }
.section-head p { margin-top: .35rem; color: var(--muted); font-size: .8rem; }
.filters { display: flex; gap: .6rem; }
.search-field { width: min(18rem, 38vw); }
.select-field { width: 8rem; }
.filters input, .filters select { min-height: 2.65rem; background: transparent; font-size: .8rem; }

.table-shell { margin-top: 1.25rem; overflow: clip; border-top: 1px solid var(--rule-2); }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { padding: .8rem .65rem; color: var(--muted); font-size: .68rem; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
td { padding: 1.25rem .65rem; border-top: 1px solid var(--rule); vertical-align: middle; }
th:first-child, td:first-child { width: 27%; padding-left: 0; }
th:nth-child(2), td:nth-child(2) { width: 10%; }
th:nth-child(3), td:nth-child(3) { width: 14%; }
th:nth-child(4), td:nth-child(4) { width: 17%; }
th:nth-child(5), td:nth-child(5) { width: 17%; }
th:last-child, td:last-child { width: 15%; padding-right: 0; text-align: right; }
.route-name strong { display: block; font-size: .92rem; }
.route-name code { display: block; margin-top: .3rem; overflow: hidden; color: var(--muted); font-family: var(--mono); font-size: .72rem; text-overflow: ellipsis; white-space: nowrap; }
.role-label, .publish-label, .health-label, .check-time { color: var(--ink-2); font-size: .76rem; }
.publish-label small, .health-label small, .check-time small { display: block; margin-top: .25rem; color: var(--muted); font-size: .68rem; }
.row-actions { display: flex; justify-content: flex-end; gap: .35rem; }
.row-action { min-height: 2.15rem; padding: .4rem .6rem; border: 1px solid var(--rule); border-radius: .3rem; background: transparent; color: var(--ink-2); cursor: pointer; font-size: .7rem; }
.row-action:hover { border-color: var(--rule-2); color: var(--ink); }
.row-action--danger { color: var(--error); }
.empty-state { padding: 3rem 0; border-bottom: 1px solid var(--rule); color: var(--muted); text-align: center; }

.dialog { width: min(calc(100% - 2rem), 52rem); max-height: calc(100vh - 2rem); padding: 0; border: 1px solid var(--rule-2); border-radius: .8rem; background: var(--paper-2); color: var(--ink); box-shadow: 0 1.5rem 5rem rgb(0 0 0 / .35); }
.dialog--wide { width: min(calc(100% - 2rem), 66rem); }
.dialog::backdrop { background: rgb(4 10 11 / .8); backdrop-filter: blur(4px); }
.dialog-panel { padding: clamp(1.2rem, 4vw, 2.25rem); }
.dialog-head { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.dialog-head h2 { margin-top: .35rem; font-size: 2rem; }
.form-grid { margin-top: 2rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.span-2 { grid-column: 1 / -1; }
.check-group { display: grid; align-content: end; gap: .65rem; }
.check-field { display: flex; align-items: center; gap: .6rem; }
.check-field input { width: 1rem; min-height: 1rem; accent-color: var(--accent); }
.dialog-actions { margin-top: 1.5rem; display: flex; justify-content: flex-end; gap: .6rem; }
.history-list { margin-top: 1.5rem; }
.history-item { display: grid; grid-template-columns: 8rem 7rem 6rem 1fr; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--rule); font-size: .75rem; }
.history-item strong { font-weight: 650; }
.history-item span { color: var(--muted); }
.history-item code { overflow-wrap: anywhere; color: var(--muted); font-family: var(--mono); font-size: .68rem; }

.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; max-width: min(28rem, calc(100% - 2rem)); padding: .85rem 1rem; border: 1px solid var(--rule-2); border-radius: .5rem; background: var(--paper-3); box-shadow: 0 .75rem 2.5rem rgb(0 0 0 / .3); color: var(--ink-2); font-size: .82rem; }

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics div:nth-child(2) { border-right: 0; }
  .metrics div:nth-child(n+3) { border-top: 1px solid var(--rule); }
  .metrics div:nth-child(3) { padding-left: 0; }
  .policy-strip { grid-template-columns: 1fr; }
  .section-head { align-items: stretch; flex-direction: column; }
  .filters { width: 100%; }
  .search-field { width: 100%; }
}

@media (max-width: 720px) {
  .topbar { padding-inline: 1rem; }
  .brand span, .topbar__actions .button:first-child { display: none; }
  .dashboard { padding-inline: 1rem; }
  .dashboard-head { align-items: stretch; flex-direction: column; }
  .dashboard-head .button { align-self: start; }
  .metrics div { min-height: 6.8rem; padding: 1rem; }
  .policy-strip__legend { align-items: flex-start; flex-wrap: wrap; white-space: normal; }
  .filters { flex-direction: column; }
  .select-field { width: 100%; }
  .table-shell { overflow: visible; }
  table, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tr { padding: 1.25rem 0; border-top: 1px solid var(--rule-2); }
  td, td:first-child, td:last-child, td:nth-child(n) { width: 100%; padding: .45rem 0; border: 0; text-align: left; }
  td:not(:first-child)::before { content: attr(data-label); width: 6.5rem; display: inline-block; color: var(--muted); font-size: .68rem; text-transform: uppercase; vertical-align: top; }
  td:not(:first-child) > * { max-width: calc(100% - 7rem); display: inline-flex; vertical-align: top; }
  .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .history-item { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
