:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --ink: #18212b;
  --muted: #66727f;
  --line: #dce2e7;
  --line-strong: #c9d1d8;
  --nav: #18212b;
  --nav-muted: #9ca9b5;
  --primary: #19715f;
  --primary-hover: #145c4e;
  --blue: #2563a7;
  --amber: #a65d12;
  --red: #ad3535;
  --green-soft: #e7f4ef;
  --blue-soft: #e8f0f8;
  --amber-soft: #fff3df;
  --red-soft: #fae8e8;
  --row-line: #edf0f2;
  --row-hover: #fbfcfc;
  --auth-bg: #eef2f4;
  --green-status: #236b58;
  --blue-status: #2563a7;
  --amber-status: #a65d12;
  --red-status: #ad3535;
  --neutral-soft: #eef1f3;
  --neutral-status: #58636d;
  --notice-ink: #79501d;
  --primary-contrast: #ffffff;
  --command-border: #9bc9bd;
  --command-bg: #edf8f5;
  --command-code-bg: #142a25;
  --command-code-ink: #d8eee8;
  --shadow: rgba(24,33,43,.12);
  --radius: 6px;
  font-family: Inter, Aptos, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  letter-spacing: 0;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111513;
  --surface: #1a201e;
  --surface-muted: #202724;
  --ink: #e5ece8;
  --muted: #9ba8a2;
  --line: #303936;
  --line-strong: #414c48;
  --nav: #0d1211;
  --nav-muted: #99a7a2;
  --primary: #56bca3;
  --primary-hover: #72cdb6;
  --blue: #74abe0;
  --amber: #dfa45f;
  --red: #ed8585;
  --green-soft: #18362e;
  --blue-soft: #1c3044;
  --amber-soft: #3a2c1c;
  --red-soft: #402323;
  --row-line: #29312e;
  --row-hover: #202825;
  --auth-bg: #101412;
  --green-status: #77d2b8;
  --blue-status: #91bde8;
  --amber-status: #edb879;
  --red-status: #f2a0a0;
  --neutral-soft: #2b3330;
  --neutral-status: #aeb9b4;
  --notice-ink: #edbd82;
  --primary-contrast: #0e201b;
  --command-border: #356d60;
  --command-bg: #172923;
  --command-code-bg: #0d1714;
  --command-code-ink: #cfe9e1;
  --shadow: rgba(0,0,0,.34);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; stroke-width: 1.8; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--nav); color: white; display: flex; flex-direction: column; padding: 20px 14px 14px; z-index: 20; }
.sidebar-header { display: flex; align-items: flex-start; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: white; font-size: 16px; font-weight: 700; padding: 0 8px 24px; }
.brand:hover { color: white; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 5px; background: #37a88f; color: #10241f; font-size: 12px; font-weight: 800; }
.primary-nav { display: flex; flex-direction: column; gap: 3px; }
.nav-link { min-height: 40px; display: flex; align-items: center; gap: 11px; padding: 0 10px; border-radius: 5px; color: var(--nav-muted); font-size: 14px; font-weight: 500; }
.nav-link:hover { color: white; background: rgba(255,255,255,.06); }
.nav-link.is-active { color: white; background: rgba(55,168,143,.19); }
.nav-link.is-active svg { color: #5fc8b0; }
.nav-label { margin: 24px 10px 7px; color: #73818e; text-transform: uppercase; font-size: 10px; font-weight: 700; letter-spacing: .08em; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.09); padding: 14px 6px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.user-block { min-width: 0; display: flex; align-items: center; gap: 9px; }
.user-avatar { flex: 0 0 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #31404d; font-size: 11px; font-weight: 700; }
.user-meta { min-width: 0; display: flex; flex-direction: column; }
.user-meta strong { max-width: 125px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.user-meta small { color: var(--nav-muted); font-size: 10px; }
.sidebar-footer .icon-button { color: var(--nav-muted); border-color: transparent; background: transparent; }
.sidebar-actions { display: flex; align-items: center; gap: 2px; }
.sidebar-actions form { display: flex; }
.theme-icon--sun { display: none; }
.sidebar .sidebar-close, .sidebar-backdrop { display: none; }
[data-theme="dark"] .theme-icon--moon { display: none; }
[data-theme="dark"] .theme-icon--sun { display: block; }

.main-content { min-width: 0; padding: 34px clamp(22px, 3vw, 48px) 64px; }
.mobile-header { display: none; }
.page-heading { min-height: 78px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 27px; }
.page-heading--compact { min-height: auto; }
.page-heading h1 { margin: 2px 0 7px; font-size: 28px; line-height: 1.2; }
.page-heading p { margin: 0; color: var(--muted); font-size: 14px; }
.heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.heading-actions form { display: flex; }
.eyebrow { color: var(--primary) !important; text-transform: uppercase; font-size: 10px !important; font-weight: 700; letter-spacing: .08em !important; }
.breadcrumb { display: flex; align-items: center; gap: 6px; margin-bottom: 20px; color: var(--muted); font-size: 12px; }
.breadcrumb svg { width: 14px; height: 14px; }

.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: var(--radius); padding: 0 14px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.button--primary { background: var(--primary); color: var(--primary-contrast); }
.button--primary:hover { background: var(--primary-hover); color: var(--primary-contrast); }
.button--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.button--secondary:hover { background: var(--surface-muted); color: var(--ink); }
.button--wide { width: 100%; }
.icon-button { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--muted); padding: 0; }
.icon-button:hover { color: var(--ink); background: var(--surface-muted); }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(145px, 1fr)); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); margin-bottom: 28px; }
.metric { min-height: 114px; background: var(--surface); padding: 19px 20px; display: flex; flex-direction: column; }
.metric span { color: var(--muted); font-size: 12px; font-weight: 500; }
.metric strong { margin: 7px 0 3px; font-size: 27px; line-height: 1; }
.metric small { margin-top: auto; color: #89939c; font-size: 11px; }

.content-section { margin-top: 28px; }
.section-heading { min-height: 48px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 12px; }
.section-heading h2 { margin: 0 0 4px; font-size: 16px; }
.section-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.section-heading > a { font-size: 12px; font-weight: 600; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { height: 41px; padding: 0 15px; background: var(--surface-muted); color: var(--muted); border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
td { height: 58px; padding: 9px 15px; border-bottom: 1px solid var(--row-line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--row-hover); }
td strong { font-weight: 600; }
.table-subtext { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.table-action { width: 44px; text-align: right; }
.action-group { display: inline-flex; align-items: center; gap: 6px; }
.action-group form { display: inline-flex; }
.empty-state { height: 96px; color: var(--muted); text-align: center; }
.mono, code { font-family: "Source Code Pro", Consolas, monospace; font-size: 11px; }

.status { display: inline-flex; align-items: center; min-height: 22px; border-radius: 4px; padding: 2px 7px; background: var(--neutral-soft); color: var(--neutral-status); font-size: 10px; font-weight: 600; white-space: nowrap; }
.status--healthy, .status--active, .status--ready, .status--verified, .status--succeeded, .status--passed { background: var(--green-soft); color: var(--green-status); }
.status--watch, .status--pending, .status--dns_pending, .status--queued, .status--waiting, .status--warnings, .status--warning, .status--enrolling { background: var(--amber-soft); color: var(--amber-status); }
.status--provisioning, .status--verifying, .status--running, .status--deploying { background: var(--blue-soft); color: var(--blue-status); }
.status--degraded, .status--burned, .status--failed, .status--suspended, .status--offline, .status--mismatch, .status--error, .status--quarantined { background: var(--red-soft); color: var(--red-status); }
.status--draft, .status--retired, .status--inactive, .status--not_installed, .status--unknown, .status--canceled { background: var(--neutral-soft); color: var(--neutral-status); }
.status-text--error, .inline-error { color: var(--red) !important; }
.status-row { display: flex; flex-wrap: wrap; gap: 5px; min-width: 190px; }

.filter-bar { display: flex; margin-bottom: 14px; }
.search-field { position: relative; width: min(420px, 100%); }
.search-field svg { position: absolute; left: 11px; top: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-field input { width: 100%; height: 37px; padding: 0 12px 0 36px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); outline: none; }
.search-field input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(25,113,95,.11); }

.detail-strip { display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 30px; }
.detail-strip--three { grid-template-columns: repeat(3, 1fr); }
.detail-strip--six { grid-template-columns: repeat(6, 1fr); }
.detail-strip > div { min-width: 0; padding: 16px 17px; border-right: 1px solid var(--line); }
.detail-strip > div:last-child { border-right: 0; }
.detail-strip span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .05em; }
.detail-strip strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.split-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 32px; }
.dns-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.dns-row { min-height: 76px; display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.dns-row:last-child { border-bottom: 0; }
.dns-row strong { display: block; margin-bottom: 5px; font-size: 11px; }
.dns-row code { display: block; overflow-wrap: anywhere; color: var(--muted); }
.dns-error { display: block; margin-top: 5px; color: var(--red); font-size: 10px; overflow-wrap: anywhere; }
.record-type { width: 42px; min-height: 25px; display: grid; place-items: center; border-radius: 4px; background: var(--blue-soft); color: var(--blue); font-family: "Source Code Pro", Consolas, monospace; font-size: 10px; font-weight: 600; }
.notice { min-height: 50px; display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--amber-soft); color: var(--notice-ink); font-size: 11px; }
.notice--status { margin: -14px 0 28px; border: 1px solid color-mix(in srgb, var(--amber) 40%, var(--line)); border-radius: var(--radius); }
.notice svg { width: 16px; height: 16px; flex: 0 0 auto; }
.rollout-summary { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.rollout-summary .section-heading { margin-bottom: 10px; }
.rollout-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rollout-steps a { min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px 10px; padding: 12px; color: var(--ink); background: var(--surface-muted); }
.rollout-steps a + a { border-left: 1px solid var(--line); }
.rollout-steps a strong { overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.rollout-steps a small { grid-column: 2; color: var(--muted); font-size: 10px; }
.inline-error { margin-top: 10px; font-size: 11px; }
.check-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.check-list > div { min-height: 58px; display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--row-line); }
.check-list > div:last-child { border-bottom: 0; }
.check-list svg { width: 16px; height: 16px; color: var(--muted); }
.check-list strong, .check-list small { display: block; }
.check-list strong { font-size: 11px; }
.check-list small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.event-list { border-left: 1px solid var(--line-strong); margin-left: 7px; }
.event-list > div { position: relative; display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 3px 15px; padding: 0 0 20px 20px; }
.event-list time { color: var(--muted); font-family: Consolas, monospace; font-size: 10px; }
.event-list strong { font-size: 11px; }
.event-list p { grid-column: 2; margin: 0; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.event-marker { position: absolute; left: -5px; top: 3px; width: 9px; height: 9px; border: 2px solid var(--surface); border-radius: 50%; background: var(--blue); }
.event-marker--warning { background: var(--amber); }
.event-marker--error { background: var(--red); }
.result-panel { max-height: 440px; overflow: auto; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--command-code-bg); color: var(--command-code-ink); font: 11px/1.6 Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

.form-section { border-top: 1px solid var(--line); padding-top: 24px; }
.form-width { width: min(640px, 100%); }
.stacked-form { display: flex; flex-direction: column; gap: 17px; }
.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-group label { font-size: 12px; font-weight: 600; }
.field-group small { color: var(--muted); font-size: 10px; line-height: 1.5; }
.field-group--checkbox { display: grid; grid-template-columns: auto 1fr; align-items: center; justify-content: start; column-gap: 9px; }
.field-group--checkbox label { grid-column: 2; grid-row: 1; }
.field-group--checkbox input { grid-column: 1; grid-row: 1; width: 17px; min-height: 17px; margin: 0; accent-color: var(--primary); }
.field-group--checkbox small, .field-group--checkbox .field-error { grid-column: 2; }
.field-control, .auth-panel input { width: 100%; min-height: 39px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); padding: 8px 10px; color: var(--ink); outline: none; }
textarea.field-control { resize: vertical; line-height: 1.5; }
.field-control:focus, .auth-panel input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(25,113,95,.11); }
.field-error, .form-error { color: var(--red); font-size: 11px; }
.form-error ul { margin: 0; padding-left: 18px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 8px; }
.code-editor { min-height: 520px; font-family: "Source Code Pro", Consolas, monospace; font-size: 12px; tab-size: 2; white-space: pre; }
.mailbox-generator { margin-top: 28px; }
.command-panel { margin-bottom: 24px; border: 1px solid var(--command-border); border-radius: var(--radius); background: var(--command-bg); padding: 15px; }
.command-panel > div { display: flex; align-items: center; justify-content: space-between; margin-bottom: 9px; font-size: 11px; font-weight: 600; }
.command-panel code { display: block; padding: 12px; border-radius: 4px; background: var(--command-code-bg); color: var(--command-code-ink); overflow-x: auto; white-space: nowrap; }
.command-panel p { margin: 9px 0 0; color: var(--muted); font-size: 10px; }

.message-stack { position: fixed; top: 18px; right: 24px; z-index: 50; width: min(380px, calc(100vw - 48px)); }
.message { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 8px 24px var(--shadow); font-size: 12px; }
.message--success { border-color: #9bc9bd; }
.message--success svg { color: var(--primary); }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--auth-bg); }
.auth-panel { width: min(400px, 100%); padding: 30px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 16px 40px rgba(24,33,43,.08); }
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.auth-heading { margin: 34px 0 24px; }
.auth-heading h1 { margin: 0 0 7px; font-size: 23px; }
.auth-heading p { margin: 0; color: var(--muted); font-size: 12px; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(3, 1fr); }
  .detail-strip { grid-template-columns: repeat(3, 1fr); }
  .detail-strip > div:nth-child(3) { border-right: 0; }
  .detail-strip > div:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .split-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -260px; width: 244px; transition: left .2s ease; box-shadow: 10px 0 30px rgba(0,0,0,.18); }
  .sidebar.is-open { left: 0; }
  .sidebar-header .brand { min-width: 0; flex: 1; }
  .sidebar .sidebar-close { display: inline-grid; flex: 0 0 34px; color: var(--nav-muted); border-color: transparent; background: transparent; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 15; border: 0; border-radius: 0; background: rgba(5, 10, 8, .48); }
  .sidebar.is-open + .sidebar-backdrop { display: block; }
  .main-content { padding: 0 16px 48px; }
  .mobile-header { height: 58px; display: flex; align-items: center; gap: 12px; margin: 0 -16px 24px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .mobile-theme-toggle { margin-left: auto; }
  .page-heading { min-height: auto; align-items: flex-start; flex-direction: column; }
  .heading-actions { width: 100%; justify-content: space-between; }
  .heading-actions form { width: 100%; }
  .page-heading .button { width: 100%; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-strip { grid-template-columns: repeat(2, 1fr); }
  .detail-strip > div { border-bottom: 1px solid var(--line); }
  .detail-strip > div:nth-child(even) { border-right: 0; }
  .detail-strip > div:last-child { border-bottom: 0; }
  .dns-row { grid-template-columns: 44px minmax(0, 1fr); }
  .dns-row .status { grid-column: 2; justify-self: start; }
  .rollout-steps { grid-template-columns: 1fr; }
  .rollout-steps a + a { border-left: 0; border-top: 1px solid var(--line); }
  .event-list > div { grid-template-columns: 1fr; }
  .event-list p { grid-column: 1; }
}

@media (max-width: 460px) {
  .metric-grid { grid-template-columns: 1fr; }
  .detail-strip { grid-template-columns: 1fr; }
  .detail-strip > div { border-right: 0; }
  .heading-actions { align-items: stretch; flex-direction: column; }
}
