:root {
  color-scheme: dark;
  --bg: #0A0A0A;
  --panel: #111111;
  --field: #171717;
  --text: #F5F5F5;
  --muted: #A8A8A8;
  --faint: #737373;
  --accent: #f5c400de;
  --accent-solid: #f5c400;
  --accent-soft: #FFF4D6;
  --danger: #FF4D4D;
  --ok: #1FCF7C;
  --line: rgba(255,255,255,.12);
  --line-strong: rgba(255,255,255,.22);
  --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; max-width: 100%; overflow-x: hidden; background: var(--bg); }

body {
  margin: 0;
  max-width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  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; }
[hidden] { display: none !important; }

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

.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: 12px;
  top: 10px;
  z-index: 10000;
  padding: 8px 12px;
  border: 1px solid var(--bg);
  background: var(--accent-solid);
  color: var(--bg);
  font-weight: 800;
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

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

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 100;
  display: flex;
  width: 208px;
  flex-direction: column;
  padding: calc(22px + var(--safe-top)) 0 calc(16px + var(--safe-bottom));
  border-right: 1px solid var(--line);
  background: #0d0d0d;
}

.sidebar-brand {
  display: block;
  margin: 0 20px 25px;
  color: var(--text);
  text-decoration: none;
}
.sidebar-brand strong,
.sidebar-brand small { display: block; }
.sidebar-brand strong { font-size: 15px; font-weight: 800; }
.sidebar-brand small { margin-top: 1px; color: var(--faint); font-family: var(--mono); font-size: 11px; }

.sidebar-nav { border-top: 1px solid var(--line); }
.nav-item {
  display: block;
  width: 100%;
  min-height: 38px;
  padding: 9px 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-size: 13px;
  font-weight: 650;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,.025); }
.nav-item.is-active { border-left-color: var(--accent-solid); background: var(--panel); color: var(--text); }

.sidebar-account {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 7px 9px;
  align-items: center;
  margin-top: auto;
  padding: 15px 20px 0;
  border-top: 1px solid var(--line);
}
.account-initials {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line-strong);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}
.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: 11px; }
.account-copy small { color: var(--faint); font-family: var(--mono); font-size: 10px; }
.sidebar-account form { grid-column: 2; }

.text-button,
.text-link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 3px;
}
.text-button:hover,
.text-link:hover { color: var(--text); }

.main-content {
  grid-column: 2;
  min-width: 0;
  width: 100%;
  max-width: 1540px;
  padding: calc(28px + var(--safe-top)) 32px calc(52px + var(--safe-bottom));
}

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

.preview-notice {
  display: flex;
  width: fit-content;
  margin-bottom: 20px;
  border: 1px solid rgba(245,196,0,.45);
  color: var(--accent-solid);
  font-family: var(--mono);
  font-size: 10px;
}
.preview-notice span { padding: 5px 8px; }
.preview-notice span + span { border-left: 1px solid rgba(245,196,0,.45); color: var(--muted); }

.loading-state { padding: 28vh 0; color: var(--muted); text-align: center; }

.page-heading {
  display: flex;
  min-height: 46px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line-strong);
}
.page-heading h1 {
  margin: 0;
  padding-bottom: 13px;
  font-size: 24px;
  line-height: 1;
  letter-spacing: -.02em;
  font-weight: 700;
}
.heading-actions { display: flex; gap: 6px; }

.primary-button,
.secondary-button,
.danger-button {
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
}
.primary-button { border: 1px solid var(--accent-solid); background: var(--accent-solid); color: #111; }
.primary-button:hover { background: #ffce24; }
.secondary-button { border: 1px solid var(--line-strong); background: transparent; color: var(--text); }
.secondary-button:hover { border-color: var(--muted); background: var(--panel); }
.danger-button { border: 1px solid rgba(255,77,77,.65); background: transparent; color: var(--danger); }
.danger-button:hover { background: rgba(255,77,77,.08); }
.primary-button:disabled,
.secondary-button:disabled { cursor: wait; opacity: .5; }

.status-board {
  display: grid;
  grid-template-columns: minmax(250px, 1.15fr) minmax(520px, 2.85fr);
  margin-bottom: 22px;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
}
.overall-status {
  display: flex;
  min-height: 88px;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 16px 0;
  border-right: 1px solid var(--line);
}
.overall-status h2 { margin: 0; font-size: 19px; line-height: 1.2; }
.overall-status p { margin: 3px 0 0; color: var(--faint); font-family: var(--mono); font-size: 10px; }
.overall-dot { width: 10px; height: 10px; flex: 0 0 auto; background: var(--ok); }
.overall-dot.is-danger { background: var(--danger); }
.overall-dot.is-warning { background: var(--accent-solid); }

.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin: 0; }
.metric-strip div { min-width: 0; padding: 17px 16px; border-right: 1px solid var(--line); }
.metric-strip div:last-child { border-right: 0; }
.metric-strip dt { min-height: 30px; color: var(--faint); font-size: 11px; }
.metric-strip dd { margin: 0; font-family: var(--mono); font-size: 18px; font-weight: 700; }

.ledger-section,
.audit-section,
.incident-summary { border: 1px solid var(--line); background: transparent; }
.overview-failures { margin-top: 12px; }
.section-heading {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.section-heading h2 { margin: 0; font-size: 13px; }

.table-scroll { overflow-x: auto; scrollbar-color: var(--line-strong) transparent; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; font-size: 12px; }
.data-table th {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #0d0d0d;
  color: var(--faint);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); color: #dedede; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: rgba(255,255,255,.025); }
.endpoint-name { min-width: 140px; }
.endpoint-name strong,
.endpoint-name small { display: block; }
.endpoint-name strong { font-size: 12px; }
.endpoint-name small {
  max-width: 340px;
  margin-top: 2px;
  overflow: hidden;
  color: var(--faint);
  font-family: var(--mono);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.muted-cell { color: var(--faint) !important; }
.mono-cell { font-family: var(--mono); font-size: 10px; white-space: nowrap; }
.row-detail { display: block; max-width: 300px; margin-top: 3px; color: var(--faint); font-size: 9px; line-height: 1.3; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  white-space: nowrap;
}
.status-pill::before { content: ""; width: 7px; height: 7px; background: var(--faint); }
.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: 2px; min-width: 118px; }
.history-signal { width: 3px; height: 14px; background: rgba(168,168,168,.18); }
.history-signal--up { background: rgba(31,207,124,.8); }
.history-signal--slow { background: var(--accent-solid); }
.history-signal--failed { background: var(--danger); }

.filter-row { display: flex; align-items: flex-end; gap: 8px; margin-bottom: 10px; }
.filter-row label { width: min(260px, 100%); }
label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 650; }
label > span { color: var(--faint); font-size: 9px; font-weight: 400; }
input,
select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  padding: 7px 9px;
  background: var(--field);
  color: var(--text);
  font-size: 16px;
}
input::placeholder { color: var(--faint); opacity: 1; }
input:hover,
select:hover { border-color: var(--muted); }
input:focus,
select:focus { border-color: var(--accent-solid); }
.compact-select { min-width: 90px; min-height: 30px; padding: 4px 7px; font-size: 12px; }

.table-actions { display: flex; justify-content: flex-end; gap: 5px; }
.table-action {
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}
.table-action:hover { color: var(--text); border-color: var(--muted); }
.empty-state { margin: 0; padding: 22px 14px; color: var(--faint); text-align: center; }

.incident-summary { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 10px; }
.incident-stat { padding: 12px; border-right: 1px solid var(--line); }
.incident-stat:last-child { border-right: 0; }
.incident-stat span { display: block; color: var(--faint); font-size: 10px; }
.incident-stat strong { display: block; margin-top: 2px; font-family: var(--mono); font-size: 18px; }

.audit-section { margin-top: 12px; }
.audit-list { display: grid; grid-template-columns: 1fr 1fr; margin: 0; padding: 0; list-style: none; }
.audit-list li { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.audit-list li:nth-child(odd) { border-right: 1px solid var(--line); }
.audit-list li:nth-last-child(-n+2) { border-bottom: 0; }
.audit-list strong { display: block; font-size: 11px; }
.audit-list span { display: block; margin-top: 2px; color: var(--faint); font-size: 10px; }

.settings-form { display: grid; gap: 0; border-top: 1px solid var(--line-strong); }
.settings-section {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 28px;
  padding: 20px 0;
  border-bottom: 1px solid var(--line-strong);
}
.settings-copy h2 { margin: 0; font-size: 14px; }
.settings-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 860px; }
.wide-field { grid-column: 1 / -1; }
.toggle-field { display: flex; gap: 9px; align-items: flex-start; padding: 7px 0; cursor: pointer; }
.toggle-field input { width: 16px; height: 16px; 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: 11px; }
.toggle-field small { margin-top: 2px; color: var(--faint); font-size: 10px; font-weight: 400; }
.configuration-record { display: grid; border: 1px solid var(--line); }
.configuration-record > div { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.configuration-record > div:last-of-type { border-bottom: 0; }
.configuration-record span { color: var(--faint); font-size: 10px; }
.configuration-record strong { font-size: 11px; }
.configuration-record code { overflow-wrap: anywhere; color: var(--muted); font-family: var(--mono); font-size: 10px; }
.settings-link { display: block; padding: 9px 10px; border-top: 1px solid var(--line); color: var(--text); font-size: 11px; text-underline-offset: 3px; }

.form-actions { display: flex; align-items: center; gap: 6px; margin-top: 18px; }
.form-actions .form-spacer { flex: 1; }
.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 10;
  justify-content: flex-end;
  min-height: 48px;
  margin-top: 0;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-strong);
  background: rgba(10,10,10,.97);
}
.sticky-actions p { margin-right: auto; color: var(--muted); font-size: 11px; }

.toast {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1000;
  max-width: min(380px, calc(100vw - 32px));
  padding: 9px 12px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent-solid);
  background: var(--panel);
  color: var(--text);
  font-size: 11px;
}
.toast.is-error { border-left-color: var(--danger); }

.form-dialog {
  width: min(720px, calc(100vw - 28px));
  max-height: min(860px, calc(100vh - 28px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--panel);
  color: var(--text);
}
.form-dialog--small { width: min(430px, calc(100vw - 28px)); }
.form-dialog::backdrop { background: rgba(0,0,0,.82); }
.form-dialog form { padding: 18px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.dialog-heading h2 { margin: 0; font-size: 18px; }
.close-button { width: 28px; height: 28px; border: 1px solid var(--line-strong); border-radius: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-dialog--small label + label { margin-top: 12px; }

.login-body { display: grid; min-height: 100vh; place-items: center; padding: 26px 16px; }
.login-shell { width: min(390px, 100%); }
.brand-lockup { display: flex; gap: 7px; margin-bottom: 13px; font-size: 12px; }
.brand-lockup strong { font-weight: 800; }
.brand-lockup span { color: var(--faint); font-family: var(--mono); }
.login-panel { padding: 22px 0 0; border-top: 2px solid var(--accent-solid); }
.login-panel h1 { margin: 0 0 18px; font-size: 24px; line-height: 1; }
.local-login-form { display: grid; gap: 11px; }
.local-login-form .primary-button { width: 100%; margin-top: 2px; }
.login-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; color: var(--faint); font-size: 10px; }
.login-divider::before,
.login-divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.google-button { display: block; text-align: center; text-decoration: none; }
.login-access { margin: 12px 0 0; color: var(--faint); font-size: 10px; }
.notice { margin-bottom: 12px; padding: 8px 9px; border-left: 2px solid var(--accent-solid); background: var(--panel); color: var(--muted); font-size: 11px; }
.notice--danger { border-left-color: var(--danger); color: var(--text); }

@media (max-width: 980px) {
  .main-content { padding-inline: 22px; }
  .status-board { grid-template-columns: 1fr; }
  .overall-status { border-right: 0; border-bottom: 1px solid var(--line); }
  .endpoint-summary-table th:nth-child(4),
  .endpoint-summary-table td:nth-child(4) { display: none; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .main-content { padding: 0 14px calc(44px + var(--safe-bottom)); }
  .mobile-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    min-height: calc(52px + var(--safe-top));
    align-items: center;
    justify-content: space-between;
    margin-inline: -14px;
    padding: var(--safe-top) 14px 0;
    border-bottom: 1px solid var(--line);
    background: rgba(10,10,10,.97);
  }
  .mobile-brand { font-size: 12px; font-weight: 800; text-decoration: none; }
  .mobile-brand span { color: var(--faint); font-family: var(--mono); font-weight: 400; }
  .menu-button { min-height: 30px; padding: 5px 8px; border: 1px solid var(--line-strong); border-radius: 2px; background: transparent; font-size: 11px; }
  .mobile-nav { position: sticky; top: calc(52px + var(--safe-top)); z-index: 90; grid-template-columns: repeat(3, 1fr); margin: 0 -14px 16px; border-bottom: 1px solid var(--line); }
  .mobile-nav:not([hidden]) { display: grid; }
  .mobile-nav button { min-height: 38px; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 11px; }
  .mobile-nav button.is-active { color: var(--accent-solid); }
  .preview-notice { margin-top: 16px; }
  .page-heading { margin-top: 20px; }
  .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: 1px solid var(--line); }
  .view,
  .ledger-section,
  .table-scroll,
  .settings-section,
  .settings-fields { min-width: 0; max-width: 100%; }
  .table-scroll { overflow: visible; }
  .data-table,
  .data-table tbody,
  .data-table tr,
  .data-table td { display: block; width: 100%; }
  .data-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
  }
  .data-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 16px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
  }
  .data-table tbody tr:last-child { border-bottom: 0; }
  .data-table td {
    min-width: 0;
    padding: 5px 0;
    border: 0;
    overflow-wrap: anywhere;
  }
  .data-table td::before {
    display: block;
    margin-bottom: 3px;
    color: var(--faint);
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 400;
  }
  .data-table td:first-child,
  .data-table td:last-child { grid-column: 1 / -1; }
  .data-table td:first-child { padding-bottom: 8px; }
  .data-table td:last-child { padding-top: 8px; }
  .endpoint-name { min-width: 0; }
  .endpoint-name small { max-width: 100%; overflow-wrap: anywhere; white-space: normal; }
  .table-actions { justify-content: flex-start; }
  .history-signals { min-width: 0; }

  .endpoint-summary-table td:nth-child(1)::before,
  .endpoints-table td:nth-child(1)::before,
  .incidents-table td:nth-child(1)::before { content: "page"; }
  .endpoint-summary-table td:nth-child(2)::before,
  .endpoints-table td:nth-child(2)::before { content: "status"; }
  .endpoint-summary-table td:nth-child(3)::before,
  .endpoints-table td:nth-child(5)::before { content: "response"; }
  .endpoint-summary-table td:nth-child(4)::before { content: "last checked"; }
  .endpoint-summary-table td:nth-child(5)::before { content: "last 24 checks"; }
  .endpoints-table td:nth-child(3)::before { content: "rule"; }
  .endpoints-table td:nth-child(4)::before { content: "frequency"; }
  .endpoints-table td:nth-child(6)::before,
  .users-table td:nth-child(6)::before { content: "actions"; }
  .incidents-table td:nth-child(2)::before { content: "state"; }
  .incidents-table td:nth-child(3)::before { content: "started"; }
  .incidents-table td:nth-child(4)::before { content: "duration"; }
  .incidents-table td:nth-child(5)::before { content: "cause"; }
  .checks-table td:nth-child(1)::before { content: "checked"; }
  .overview-failures-table td:nth-child(1)::before { content: "checked"; }
  .checks-table td:nth-child(2)::before { content: "page"; }
  .overview-failures-table td:nth-child(2)::before { content: "page"; }
  .checks-table td:nth-child(3)::before { content: "result"; }
  .overview-failures-table td:nth-child(3)::before { content: "result"; }
  .checks-table td:nth-child(4)::before { content: "http"; }
  .overview-failures-table td:nth-child(4)::before { content: "http"; }
  .checks-table td:nth-child(5)::before { content: "response"; }
  .overview-failures-table td:nth-child(5)::before { content: "response"; }
  .checks-table td:nth-child(6)::before { content: "detail"; }
  .overview-failures-table td:nth-child(6)::before { content: "reason"; }
  .users-table td:nth-child(1)::before { content: "user"; }
  .users-table td:nth-child(2)::before { content: "role"; }
  .users-table td:nth-child(3)::before { content: "google"; }
  .users-table td:nth-child(4)::before { content: "last sign-in"; }
  .users-table td:nth-child(5)::before { content: "access"; }
  .settings-section { grid-template-columns: 1fr; gap: 13px; }
  .audit-list { grid-template-columns: 1fr; }
  .audit-list li:nth-child(odd) { border-right: 0; }
  .audit-list li:nth-last-child(-n+2) { border-bottom: 1px solid var(--line); }
  .audit-list li:last-child { border-bottom: 0; }
}

@media (max-width: 540px) {
  .page-heading { align-items: flex-start; }
  .page-heading h1 { font-size: 21px; }
  .heading-actions { flex-wrap: wrap; justify-content: flex-end; }
  .filter-row { display: grid; }
  .filter-row label { width: 100%; }
  .settings-fields,
  .form-grid { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
  .configuration-record > div { grid-template-columns: 1fr; gap: 3px; }
  .incident-summary { grid-template-columns: 1fr; }
  .incident-stat { border-right: 0; border-bottom: 1px solid var(--line); }
  .incident-stat:last-child { border-bottom: 0; }
  .form-dialog form { padding: 14px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .form-spacer { display: none; }
  .sticky-actions { flex-wrap: nowrap; }
}

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