:root {
  color-scheme: dark;
  --bg: #0A0A0A;
  --card: #1a1a1a;
  --elev: #1a1a1a;
  --badge: #1E1F22;
  --text: #F5F5F5;
  --text-subtle: #EDEDED;
  --muted: #A8A8A8;
  --accent: #f5c400de;
  --accent-solid: #f5c400;
  --accent-soft: #FFF4D6;
  --danger: #FF4D4D;
  --ok: #1FCF7C;
  --edge-colour: rgba(255,255,255,0.08);
  --edge-strong: rgba(255,255,255,0.16);
  --edge: 1px solid var(--edge-colour);
  --radius: 16px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--accent-solid);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 10000;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--accent-solid);
  color: var(--bg);
  font-weight: 800;
  transform: translateY(-150%);
}
.skip-link:focus { transform: translateY(0); }

.app-shell { display: grid; grid-template-columns: 256px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 256px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: calc(24px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
  border-right: var(--edge);
  background: var(--card);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  min-width: 0;
  margin: 0 6px 30px;
}
.sidebar-brand img { flex: 0 0 auto; }
.sidebar-brand span { min-width: 0; }
.sidebar-brand strong, .sidebar-brand small { display: block; }
.sidebar-brand strong { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.sidebar-brand small { color: var(--muted); font-size: 13px; font-weight: 600; }

.sidebar-nav { display: grid; gap: 4px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 9px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
  transition: background .18s ease, color .18s ease;
}
.nav-item:hover { background: var(--edge-colour); color: var(--text); }
.nav-item.is-active { background: var(--accent); color: var(--accent-soft); }
.nav-glyph {
  display: grid;
  width: 20px;
  place-items: center;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 800;
}

.sidebar-account {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 9px 10px;
  align-items: center;
  margin-top: auto;
  padding: 16px 6px 0;
  border-top: var(--edge);
}
.account-initials {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: var(--edge);
  border-radius: 50%;
  background: var(--badge);
  font-size: 12px;
  font-weight: 800;
}
.account-copy { min-width: 0; }
.account-copy strong, .account-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-copy strong { font-size: 13px; }
.account-copy small { color: var(--muted); font-size: 12px; }
.sidebar-account form { grid-column: 2; }
.text-button, .text-link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--edge-strong);
  text-underline-offset: 4px;
  font-size: 13px;
  font-weight: 700;
}
.text-button:hover, .text-link:hover { color: var(--text); }

.main-content {
  grid-column: 2;
  width: 100%;
  max-width: 1600px;
  padding: calc(42px + var(--safe-top)) 44px calc(72px + var(--safe-bottom));
}

.mobile-header, .mobile-nav { display: none; }

.preview-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -14px 0 28px;
  padding: 10px 14px;
  border: 1px solid rgba(245,196,0,0.32);
  border-radius: var(--radius-sm);
  background: rgba(245,196,0,0.07);
  color: var(--text-subtle);
  font-size: 13px;
}
.preview-notice span {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-soft);
  font-weight: 800;
}
.preview-notice p { margin: 0; }

.loading-state { padding: 30vh 0; color: var(--muted); text-align: center; }
.view { animation: view-in .16s ease both; }
@keyframes view-in { from { opacity: .35; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 28px;
  margin-bottom: 30px;
}
.page-heading h1 { margin: 2px 0 6px; color: var(--text); font-size: clamp(30px, 4vw, 48px); line-height: 1.04; letter-spacing: -.025em; font-weight: 700; }
.page-heading p:not(.section-label) { max-width: 660px; margin: 0; color: var(--muted); font-size: 16px; }
.section-label, .eyebrow {
  margin: 0;
  color: var(--accent-solid);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.2;
  letter-spacing: .08em;
  font-weight: 700;
}
.heading-actions { display: flex; gap: 8px; flex: 0 0 auto; }

.primary-button, .secondary-button, .danger-button {
  min-height: 44px;
  padding: 10px 17px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.primary-button { border: 1px solid transparent; background: var(--accent); color: var(--accent-soft); }
.primary-button:hover { background: var(--accent-solid); transform: translateY(-1px); }
.secondary-button { border: var(--edge); background: var(--badge); color: var(--text); }
.secondary-button:hover { border-color: var(--edge-strong); background: var(--card); }
.danger-button { border: 1px solid rgba(255,77,77,.34); background: rgba(255,77,77,.08); color: var(--danger); }
.danger-button:hover { background: rgba(255,77,77,.15); }
.primary-button:disabled, .secondary-button:disabled { cursor: wait; opacity: .55; transform: none; }

.status-board {
  overflow: hidden;
  margin-bottom: 26px;
  border: var(--edge);
  border-radius: var(--radius);
  background: var(--card);
}
.overall-status { display: flex; align-items: center; gap: 18px; min-height: 132px; padding: 28px 30px; }
.overall-status h2 { margin: 3px 0 6px; color: var(--text-subtle); font-size: clamp(22px, 3vw, 32px); line-height: 1.15; }
.overall-status p:last-child { margin: 0; color: var(--muted); font-size: 14px; }
.overall-dot { width: 18px; height: 18px; flex: 0 0 auto; border: 5px solid rgba(31,207,124,.15); border-radius: 50%; background: var(--ok); box-sizing: content-box; }
.overall-dot.is-danger { border-color: rgba(255,77,77,.15); background: var(--danger); }
.overall-dot.is-warning { border-color: rgba(245,196,0,.15); background: var(--accent-solid); }
.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; border-top: var(--edge); }
.metric-strip div { min-width: 0; padding: 17px 22px; border-right: var(--edge); }
.metric-strip div:last-child { border-right: 0; }
.metric-strip dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.metric-strip dd { margin: 4px 0 0; color: var(--text); font-family: var(--mono); font-size: 20px; font-weight: 700; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(260px, .7fr); gap: 18px; align-items: start; }
.ledger-section, .activity-section, .audit-section, .incident-summary {
  border: var(--edge);
  border-radius: var(--radius);
  background: var(--card);
}
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; min-height: 74px; padding: 18px 20px 14px; border-bottom: var(--edge); }
.section-heading h2 { margin: 3px 0 0; color: var(--text-subtle); font-size: 18px; line-height: 1.2; }

.table-scroll { overflow-x: auto; scrollbar-color: var(--edge-strong) transparent; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.data-table th { padding: 11px 16px; border-bottom: var(--edge); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.data-table td { padding: 14px 16px; border-bottom: var(--edge); color: var(--text-subtle); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(255,255,255,.018); }
.endpoint-name { min-width: 148px; }
.endpoint-name strong, .endpoint-name small { display: block; }
.endpoint-name strong { font-size: 14px; }
.endpoint-name small { max-width: 300px; margin-top: 3px; overflow: hidden; color: var(--muted); font-family: var(--mono); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.muted-cell { color: var(--muted) !important; }
.mono-cell { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.row-detail { display: block; max-width: 280px; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 500; line-height: 1.3; }
.compact-select { min-width: 92px; min-height: 36px; padding: 6px 9px; font-size: 13px; }
.inline-toggle { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.inline-toggle input { width: 17px; height: 17px; min-height: 0; accent-color: var(--accent-solid); }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: var(--edge);
  border-radius: 999px;
  background: var(--badge);
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-pill--up::before, .status-pill--recovered::before { background: var(--ok); }
.status-pill--down::before, .status-pill--failed::before, .status-pill--open::before { background: var(--danger); }
.status-pill--slow::before, .status-pill--at-risk::before { background: var(--accent-solid); }

.history-signals { display: flex; align-items: center; gap: 3px; min-width: 102px; }
.history-signal { width: 4px; height: 18px; border-radius: 2px; background: rgba(168,168,168,.22); }
.history-signal--up { background: rgba(31,207,124,.78); }
.history-signal--slow { background: var(--accent); }
.history-signal--failed { background: var(--danger); }

.activity-list, .audit-list { margin: 0; padding: 0; list-style: none; }
.activity-list li, .audit-list li { position: relative; padding: 15px 18px 15px 36px; border-bottom: var(--edge); }
.activity-list li:last-child, .audit-list li:last-child { border-bottom: 0; }
.activity-list li::before { content: ""; position: absolute; left: 18px; top: 21px; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.activity-list li.activity--down::before { background: var(--danger); }
.activity-list li.activity--recovered::before { background: var(--ok); }
.activity-list strong, .audit-list strong { display: block; color: var(--text-subtle); font-size: 13px; }
.activity-list span, .audit-list span { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.empty-activity { color: var(--muted); font-size: 13px; }

.filter-row { display: flex; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.filter-row label { width: min(280px, 100%); }
label { display: grid; gap: 7px; color: var(--text-subtle); font-size: 13px; font-weight: 700; }
label > span { color: var(--muted); font-size: 11px; font-weight: 500; }
input, select {
  width: 100%;
  min-height: 44px;
  border: var(--edge);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--badge);
  color: var(--text);
  font-size: 16px;
}
input::placeholder { color: var(--muted); opacity: .66; }
input:hover, select:hover { border-color: var(--edge-strong); }
input:focus, select:focus { border-color: var(--accent-solid); }

.table-actions { display: flex; justify-content: flex-end; gap: 6px; }
.table-action {
  min-height: 34px;
  padding: 6px 10px;
  border: var(--edge);
  border-radius: 999px;
  background: transparent;
  color: var(--text-subtle);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.table-action:hover { background: var(--badge); }
.empty-state { margin: 0; padding: 28px 20px; color: var(--muted); text-align: center; }

.incident-summary { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.incident-stat { padding: 20px; border-right: var(--edge); }
.incident-stat:last-child { border-right: 0; }
.incident-stat span { display: block; color: var(--muted); font-size: 12px; }
.incident-stat strong { display: block; margin-top: 3px; font-family: var(--mono); font-size: 24px; }

.audit-section { margin-top: 18px; }
.audit-list { display: grid; grid-template-columns: 1fr 1fr; }
.audit-list li:nth-child(odd) { border-right: var(--edge); }

.settings-form { display: grid; gap: 14px; }
.settings-section { display: grid; grid-template-columns: minmax(220px, .7fr) minmax(0, 1.3fr); gap: 36px; padding: 24px; border: var(--edge); border-radius: var(--radius); background: var(--card); }
.settings-copy h2 { margin: 5px 0 7px; font-size: 19px; }
.settings-copy > p:last-child { max-width: 320px; margin: 0; color: var(--muted); font-size: 13px; }
.settings-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.wide-field { grid-column: 1 / -1; }
.toggle-field { display: flex; gap: 11px; align-items: flex-start; padding: 10px 0; cursor: pointer; }
.toggle-field input { width: 19px; height: 19px; min-height: 0; margin: 1px 0 0; accent-color: var(--accent-solid); }
.toggle-field > span { display: block; color: var(--text); }
.toggle-field strong, .toggle-field small { display: block; }
.toggle-field strong { font-size: 13px; }
.toggle-field small { margin-top: 3px; color: var(--muted); font-weight: 400; line-height: 1.35; }
.configuration-record { display: grid; gap: 0; border: var(--edge); border-radius: var(--radius-sm); overflow: hidden; }
.configuration-record > div { display: grid; grid-template-columns: 130px 1fr; gap: 16px; padding: 13px 15px; border-bottom: var(--edge); }
.configuration-record span { color: var(--muted); font-size: 12px; }
.configuration-record strong { font-size: 13px; }
.configuration-record code { overflow-wrap: anywhere; color: var(--text-subtle); font-family: var(--mono); font-size: 12px; }
.configuration-record p { margin: 0; padding: 14px 15px; color: var(--muted); font-size: 12px; }
.sticky-actions { position: sticky; bottom: 14px; z-index: 10; justify-content: flex-end; min-height: 64px; padding: 10px 12px; border: var(--edge); border-radius: 999px; background: rgba(18,18,18,.96); }
.sticky-actions p { margin-right: auto; color: var(--muted); font-size: 13px; }

.toast {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border: var(--edge);
  border-radius: 999px;
  background: var(--badge);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.toast.is-error { border-color: rgba(255,77,77,.42); }

.form-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(880px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--edge-strong);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
}
.form-dialog--small { width: min(480px, calc(100vw - 32px)); }
.form-dialog::backdrop { background: rgba(0,0,0,.78); }
.form-dialog form { padding: 22px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.dialog-heading h2 { margin: 4px 0 0; font-size: 24px; }
.close-button { width: 40px; height: 40px; border: var(--edge); border-radius: 50%; background: var(--badge); color: var(--muted); cursor: pointer; font-size: 24px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 24px; }
.form-actions .form-spacer { flex: 1; }
.form-note { margin: 16px 0 0; color: var(--muted); font-size: 12px; }
.form-dialog--small label + label { margin-top: 16px; }

.login-body { display: grid; place-items: center; min-height: 100vh; padding: 32px 18px; }
.login-shell { width: min(500px, 100%); }
.brand-lockup { margin-bottom: 24px; }
.brand-mark { font-size: 25px; font-weight: 800; }
.brand-tagline { color: var(--muted); font-size: 14px; }
.login-panel { padding: 30px; border: var(--edge); border-radius: var(--radius); background: var(--card); }
.login-panel h1 { margin: 5px 0 12px; font-size: clamp(30px, 8vw, 44px); line-height: 1.06; letter-spacing: -.025em; }
.login-copy { margin: 0 0 24px; color: var(--muted); }
.google-button { display: block; margin-top: 18px; text-align: center; text-decoration: none; }
.local-login-form { display: grid; gap: 14px; margin-top: 22px; }
.local-login-form .primary-button { width: 100%; margin-top: 2px; }
.login-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0 2px; color: var(--muted); font-size: 12px; }
.login-divider::before, .login-divider::after { content: ""; height: 1px; flex: 1; background: var(--edge-colour); }
.login-access { margin: 18px 0 0; color: var(--muted); font-size: 12px; }
.notice { padding: 12px 14px; border: 1px solid rgba(245,196,0,.28); border-radius: var(--radius-sm); background: rgba(245,196,0,.06); color: var(--text-subtle); font-size: 13px; }
.notice--danger { border-color: rgba(255,77,77,.35); background: rgba(255,77,77,.07); }
.login-shell footer { margin-top: 20px; color: var(--muted); text-align: center; font-size: 12px; }
.settings-link { display: block; padding: 13px 15px; border-top: var(--edge); color: var(--text-subtle); font-size: 13px; font-weight: 800; text-underline-offset: 4px; }

@media (max-width: 1120px) {
  .main-content { padding-inline: 28px; }
  .overview-grid { grid-template-columns: 1fr; }
  .activity-list { display: grid; grid-template-columns: 1fr 1fr; }
  .activity-list li:nth-child(odd) { border-right: var(--edge); }
  .endpoint-summary-table th:nth-child(4), .endpoint-summary-table td:nth-child(4) { display: none; }
}

@media (max-width: 800px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .main-content { padding: 0 18px calc(54px + var(--safe-bottom)); }
  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: calc(62px + var(--safe-top));
    margin-inline: -18px;
    padding: var(--safe-top) 18px 0;
    border-bottom: var(--edge);
    background: rgba(10,10,10,.96);
  }
  .mobile-brand { text-decoration: none; font-weight: 800; }
  .mobile-brand span { color: var(--muted); font-weight: 600; }
  .menu-button { min-height: 38px; padding: 7px 12px; border: var(--edge); border-radius: 999px; background: var(--badge); font-size: 13px; font-weight: 800; }
  .mobile-nav { position: sticky; top: calc(62px + var(--safe-top)); z-index: 90; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 0 -18px 22px; border-bottom: var(--edge); background: var(--edge-colour); }
  .mobile-nav button { min-height: 44px; border: 0; background: var(--card); color: var(--muted); font-size: 12px; font-weight: 700; }
  .mobile-nav button.is-active { color: var(--accent-solid); }
  .preview-notice { align-items: flex-start; margin: 18px 0 22px; }
  .page-heading { align-items: flex-start; margin-top: 28px; }
  .page-heading h1 { font-size: 36px; }
  .metric-strip { grid-template-columns: 1fr 1fr; }
  .metric-strip div:nth-child(2) { border-right: 0; }
  .metric-strip div:nth-child(-n+2) { border-bottom: var(--edge); }
  .settings-section { grid-template-columns: 1fr; gap: 20px; }
  .activity-list, .audit-list { grid-template-columns: 1fr; }
  .activity-list li:nth-child(odd), .audit-list li:nth-child(odd) { border-right: 0; }
}

@media (max-width: 560px) {
  .page-heading { display: block; }
  .page-heading .primary-button { margin-top: 18px; }
  .heading-actions { width: 100%; margin-top: 18px; }
  .heading-actions button { flex: 1; }
  .overall-status { padding: 23px 20px; }
  .metric-strip div { padding: 14px 16px; }
  .filter-row { display: grid; }
  .filter-row label { width: 100%; }
  .settings-fields, .form-grid { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
  .form-dialog form { padding: 18px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .form-spacer { display: none; }
  .form-actions button { flex: 1; }
  .sticky-actions { border-radius: var(--radius); }
  .configuration-record > div { grid-template-columns: 1fr; gap: 4px; }
  .incident-summary { grid-template-columns: 1fr; }
  .incident-stat { border-right: 0; border-bottom: var(--edge); }
  .incident-stat:last-child { border-bottom: 0; }
}

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