:root {
  color-scheme: light;
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7d7c77;
  --grid: #e8e7e3;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --good: #0f7b3e;
  --good-bg: #e3f4ea;
  --warn: #8a5a00;
  --warn-bg: #fdf1d6;
  --bad: #b42323;
  --bad-bg: #fbe5e5;
  --shadow: 0 1px 2px rgb(0 0 0 / .05), 0 4px 16px rgb(0 0 0 / .04);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2e2e2b;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --grid: #2a2a27;
    --accent: #3987e5;
    --series-1: #3987e5;
    --series-2: #d95926;
    --good: #5cc98a;
    --good-bg: #16301f;
    --warn: #f0b84a;
    --warn-bg: #33270e;
    --bad: #f07a7a;
    --bad-bg: #3a1717;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86; --grid: #2a2a27;
  --accent: #3987e5; --series-1: #3987e5; --series-2: #d95926;
  --good: #5cc98a; --good-bg: #16301f; --warn: #f0b84a; --warn-bg: #33270e;
  --bad: #f07a7a; --bad-bg: #3a1717; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; color: var(--text); }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; }
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a { padding: 6px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--surface-2); color: var(--text); }
.topbar .spacer { flex: 1; }
main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .spacer { flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 16px 20px 0; }
.card-head .spacer { flex: 1; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: 2fr 1fr; margin-bottom: 16px; }
.halves { grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
@media (max-width: 900px) { .two, .halves { grid-template-columns: 1fr; } }

.kpi .label { color: var(--text-2); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 650; margin-top: 4px; letter-spacing: -.01em; }
.kpi .delta { font-size: 12px; margin-top: 2px; color: var(--muted); }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }

/* controls */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; color: var(--text-2); padding: 0 12px; height: 32px; font: inherit; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--surface-2); color: var(--text); font-weight: 600; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px;
  height: 36px; padding: 0 12px; width: 100%;
}
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 500; margin-bottom: 6px; }
label.field small { display: block; color: var(--muted); margin-top: 4px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
td.r, th.r { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }

.site-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.avatar { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-weight: 700; color: #fff; flex: none; font-size: 14px; }
.site-name { font-weight: 600; color: var(--text); }
.site-url { color: var(--muted); font-size: 12px; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.up { color: var(--good); background: var(--good-bg); }
.badge.down, .badge.error { color: var(--bad); background: var(--bad-bg); }
.badge.pending { color: var(--text-2); background: var(--surface-2); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge svg { width: 12px; height: 12px; }

.bar-list { list-style: none; margin: 0; padding: 8px 20px 18px; }
.bar-list li { position: relative; display: flex; justify-content: space-between; gap: 12px; padding: 6px 10px; margin-top: 4px; border-radius: 6px; overflow: hidden; }
.bar-list li .fill { position: absolute; inset: 0 auto 0 0; background: color-mix(in srgb, var(--series-1) 14%, transparent); border-radius: 6px; }
.bar-list li span { position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; font-size: 17px; }

/* charts */
.chart { position: relative; padding: 8px 12px 12px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.legend { display: flex; gap: 16px; padding: 4px 20px 0; flex-wrap: wrap; color: var(--text-2); font-size: 13px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 24px rgb(0 0 0 / .14);
  padding: 8px 10px; font-size: 12px; min-width: 140px;
}
.tooltip .t-head { color: var(--muted); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .t-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.tooltip .t-row b { font-variant-numeric: tabular-nums; }

.uptime-strip { display: flex; gap: 2px; padding: 4px 20px 18px; }
.uptime-strip span { flex: 1; height: 26px; border-radius: 3px; background: var(--good); opacity: .85; }
.uptime-strip span.bad { background: var(--bad); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgb(0 0 0 / .45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { width: min(520px, 100%); max-height: 90vh; overflow: auto; }
.modal .card-pad { padding: 24px; }
.modal h2 { font-size: 18px; margin-bottom: 4px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.steps { margin: 12px 0 18px; padding-left: 20px; color: var(--text-2); }
.steps li { margin-bottom: 4px; }
.error-msg { color: var(--bad); background: var(--bad-bg); padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; }

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth { width: min(400px, 100%); }
.auth .card-pad { padding: 28px; }
.auth h1 { margin: 14px 0 4px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; z-index: 60; font-weight: 500; }

.lead-data { font-size: 12px; color: var(--text-2); max-width: 420px; }
.lead-data div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; padding: 14px 20px 18px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; overflow-wrap: anywhere; }

.hide-sm { }
@media (max-width: 720px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .nav { margin-left: 0; order: 3; width: 100%; }
  main { padding: 16px; }
  .hide-sm { display: none; }
  th, td { padding: 10px 12px; }
}

/* Astro version additions */
.thirds { grid-template-columns: repeat(3, 1fr); margin-bottom: 16px; }
@media (max-width: 1000px) { .thirds { grid-template-columns: 1fr; } }
.modal.wide { width: min(760px, 100%); }
h3.step { font-size: 14px; font-weight: 600; margin: 18px 0 8px; }
.code { position: relative; }
.code pre {
  margin: 0; padding: 12px 14px; padding-right: 72px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  font: 12.5px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow-x: auto; white-space: pre; color: var(--text);
}
.code .copy { position: absolute; top: 6px; right: 6px; }
code { font: 12.5px ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.site-url .badge { font-size: 11px; padding: 0 7px; }

/* 2FA */
.banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; max-width: 1280px; margin: 16px auto 0; padding: 10px 16px; background: var(--warn-bg); color: var(--text); border-radius: 10px; width: calc(100% - 48px); }
.banner svg { width: 16px; height: 16px; color: var(--warn); flex: none; }
.banner span { flex: 1; min-width: 200px; }
input.otp { font: 600 22px/1 ui-monospace, Consolas, monospace; letter-spacing: .3em; text-align: center; height: 48px; }
.recovery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.recovery-grid code { text-align: center; padding: 8px; font-size: 14px; letter-spacing: .05em; }
@media (max-width: 720px) { .banner { width: calc(100% - 32px); } }
