/* Watchtower — design tokens */
:root {
  color-scheme: light;
  --page: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e8e7e1;
  --grid: #ecebe6;
  --baseline: #c3c2b7;
  --ring: rgba(11, 11, 11, .08);
  --accent: #2a78d6;
  --accent-soft: #cde2fb;
  --accent-ink: #1c5cab;
  --good: #0ca30c; --good-ink: #006300;
  --warning: #fab219; --warning-ink: #8a5a00;
  --serious: #ec835a;
  --critical: #d03b3b; --critical-ink: #b02a2a;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 1px 1px rgba(11, 11, 11, .02);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #222220;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --line: #2c2c2a;
    --grid: #2a2a28;
    --baseline: #383835;
    --ring: rgba(255, 255, 255, .08);
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, .2);
    --accent-ink: #86b6ef;
    --good-ink: #0ca30c;
    --warning-ink: #fab219;
    --critical-ink: #e66767;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --shadow: none;
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 24px; line-height: 1.25; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
p { margin: 0; }
code { font: 12.5px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--line); padding: 2px 5px; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ico { flex: none; vertical-align: middle; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* App shell */
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 20px 14px; border-right: 1px solid var(--line); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 650; font-size: 15px; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; }
.brand small { display: block; font-weight: 400; font-size: 11.5px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.nav a.on { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.nav a.on .ico { color: var(--accent); }
.side-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 12px 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
.side-foot form { margin-left: auto; }
.content { padding: 28px 32px 48px; max-width: 1280px; width: 100%; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0; }
  .brand small { display: none; }
  .nav { flex-direction: row; overflow-x: auto; flex: 1; scrollbar-width: none; }
  .nav a { padding: 7px 9px; white-space: nowrap; }
  .nav a span { display: none; }
  .side-foot { margin: 0; padding: 0; border: 0; }
  .side-foot .who { display: none; }
  .content { padding: 20px 16px 40px; }
}

/* Page header */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin-bottom: 22px; }
.page-head .titles { flex: 1 1 260px; min-width: 0; }
.page-head p { color: var(--muted); margin-top: 4px; }
.page-head .tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.crumb { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.crumb:hover { color: var(--ink); text-decoration: none; }

/* Cards & layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { flex: 1; display: flex; align-items: center; gap: 8px; }
.card-head .sub { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 16px 20px 0; }
.grid { display: grid; gap: 16px; margin-bottom: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.kpis.with-hero { grid-template-columns: minmax(260px, 1.6fr) repeat(auto-fit, minmax(170px, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.cols-1-1-1 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1100px) { .cols-3-1, .cols-1-1-1 { grid-template-columns: minmax(0, 1fr); } .kpis.with-hero { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
@media (max-width: 760px) { .cols-2 { grid-template-columns: minmax(0, 1fr); } .kpis, .kpis.with-hero { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } .stat .stat-value { font-size: 21px; } .stat.hero { grid-column: 1 / -1; } .stat.hero .stat-value { font-size: 38px; } .card { padding: 16px; } .page-head .tools { width: 100%; } .search input { width: 100%; } .card-head .search { flex: 1 1 100%; } }

/* Stat tiles */
.stat { display: flex; flex-direction: column; gap: 6px; color: inherit; position: relative; }
a.stat:hover { text-decoration: none; border-color: var(--baseline); }
.stat-head { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.stat-ico { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.stat-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; line-height: 1.15; }
.stat-value small { font-size: 14px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.stat-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12.5px; }
.stat.hero .stat-value { font-size: 48px; letter-spacing: -.03em; }
.stat .chart-spark { margin-top: auto; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 12px; padding: 1px 7px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.delta span { font-size: 8px; }
.delta.good { color: var(--good-ink); background: color-mix(in srgb, var(--good) 12%, transparent); }
.delta.bad { color: var(--critical-ink); background: color-mix(in srgb, var(--critical) 12%, transparent); }
.delta.flat { color: var(--muted); background: var(--surface-2); font-weight: 500; }

/* Meters, pills, legend, segmented bar, hbars */
.meter { height: 8px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.meter.warning { background: color-mix(in srgb, var(--warning) 25%, transparent); }
.meter.warning span { background: var(--warning); }
.meter.critical { background: color-mix(in srgb, var(--critical) 22%, transparent); }
.meter.critical span { background: var(--critical); }
.meter.good { background: color-mix(in srgb, var(--good) 20%, transparent); }
.meter.good span { background: var(--good); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 99px; font-size: 12px; font-weight: 550; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.pill.good .ico { color: var(--good); }
.pill.warning .ico { color: var(--warning); }
.pill.critical .ico { color: var(--critical); }
.pill.neutral .ico { color: var(--muted); }
.tag { display: inline-block; min-width: 46px; text-align: center; padding: 1px 7px; border-radius: 6px; font: 600 11.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 12px 0 0; padding: 0; font-size: 12.5px; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 7px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.sw.line { width: 14px; height: 3px; border-radius: 2px; }
.s1 { background: var(--s1); } .s2 { background: var(--s2); } .s3 { background: var(--s3); } .s4 { background: var(--s4); }
.scritical { background: var(--critical); } .sgood { background: var(--good); }
.s5 { background: var(--s5); } .s6 { background: var(--s6); } .s7 { background: var(--s7); } .s8 { background: var(--s8); }
.segbar { display: flex; gap: 2px; height: 28px; }
.seg { min-width: 3px; border-radius: 4px; color: #fff; font-size: 11.5px; font-weight: 600; line-height: 28px; padding: 0 8px; white-space: nowrap; overflow: hidden; cursor: default; }
.seg.s4 { color: #0b0b0b; }
.hbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.hb-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 5px; }
.hb-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hb-track { height: 6px; border-radius: 99px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.hb-track span { display: block; height: 100%; border-radius: 99px; background: var(--s1); }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart text { font: 11px var(--font); fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .base-line { stroke: var(--baseline); stroke-width: 1; }
.chart .cross { stroke: var(--baseline); stroke-width: 1; }
.chart-spark { margin: 4px -4px -4px; }
.tip { position: fixed; z-index: 50; pointer-events: none; min-width: 140px; max-width: 280px; padding: 9px 11px; border-radius: 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, .14); font-size: 12.5px; opacity: 0; transform: translateY(4px); transition: opacity .08s, transform .08s; }
.tip.show { opacity: 1; transform: none; }
.tip b { display: block; font-weight: 600; margin-bottom: 4px; color: var(--ink-2); }
.tip .row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .row span:first-child { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip .row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
details.datatable { margin-top: 12px; }
details.datatable summary { cursor: pointer; color: var(--muted); font-size: 12.5px; width: max-content; }
details.datatable summary:hover { color: var(--ink); }
details.datatable .table-wrap { max-height: 280px; overflow: auto; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
td.break { overflow-wrap: anywhere; max-width: 380px; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.cell-main { font-weight: 550; color: var(--ink); }
.cell-sub { display: block; color: var(--muted); font-size: 12px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Controls */
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; font: 500 13px/1 var(--font); height: 34px; padding: 0 13px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; box-shadow: var(--shadow); }
button:hover, .btn:hover { border-color: var(--baseline); text-decoration: none; }
button:focus-visible, .btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.06); }
button.danger { color: var(--critical-ink); }
button.danger:hover { border-color: var(--critical); }
button.sm, .btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
button.icon-only { width: 30px; padding: 0; height: 30px; }
.btn.ghost, button.ghost { background: transparent; box-shadow: none; }
input, select { font: 13.5px var(--font); height: 36px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-width: 0; }
input[type=checkbox] { height: auto; accent-color: var(--accent); }
label.check { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
form.inline { display: inline; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.form-row .grow { flex: 1 1 200px; }
.form-row .grow input { width: 100%; }
.seg-ctl { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.seg-ctl a { padding: 5px 11px; border-radius: 7px; font-size: 12.5px; font-weight: 550; color: var(--ink-2); }
.seg-ctl a:hover { text-decoration: none; color: var(--ink); }
.seg-ctl a.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 1px var(--line); }
.search { position: relative; }
.search .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 32px; width: 240px; max-width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 28px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; box-shadow: none; background: var(--surface-2); }
.chip.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip b { font-weight: 600; opacity: .6; margin-left: 2px; }

/* Alerts */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: 11px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; }
.alert .ico { margin-top: 1px; }
.alert.ok .ico { color: var(--good); }
.alert.bad { border-color: color-mix(in srgb, var(--critical) 40%, var(--line)); }
.alert.bad .ico { color: var(--critical); }
.alert.warn .ico { color: var(--warning); }

/* Overview bits */
.vps-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.vps-head .ttl { flex: 1; min-width: 0; }
.vps-head .ttl b { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res { display: grid; gap: 14px; }
.res-row .lbl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.res-row .lbl b { font-weight: 600; font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.facts div { font-size: 12px; color: var(--muted); }
.facts b { display: block; font-size: 14px; color: var(--ink); font-weight: 600; margin-top: 2px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list .main { flex: 1; min-width: 0; }
.list .main b { display: block; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .main span { color: var(--muted); font-size: 12px; }
.feed li { align-items: flex-start; }
.feed .dot { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); flex: none; }
.feed .dot.bad { color: var(--critical); }
.zone-name { display: flex; align-items: center; gap: 10px; }
.zone-name .avatar { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; }
.spark-cell { width: 140px; }
.spark-cell .chart { height: 32px !important; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent), var(--page); }
.login { width: 100%; max-width: 360px; padding: 28px; }
.login .brand { padding: 0 0 20px; }
.login h1 { font-size: 20px; margin-bottom: 4px; }
.login p { color: var(--muted); margin-bottom: 20px; }
.login .field { margin-bottom: 12px; }
.login input { width: 100%; }
.login button { width: 100%; height: 38px; margin-top: 6px; }
.zone-name .avatar.s4, .zone-name .avatar.s5 { color: #0b0b0b; }

/* DNS: add panel, filter bar, bulk selection, external links */
.add-panel { padding: 16px 20px 18px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-2); margin-top: 14px; }
.add-panel h3 { margin-bottom: 12px; }
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 20px; }
.filter-bar .chips { flex: 1 1 auto; }
.bulk-bar { display: flex; align-items: center; gap: 10px; padding: 8px 20px; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); border-top: 1px solid var(--line); font-size: 13px; position: sticky; top: 0; z-index: 3; }
.bulk-bar[hidden] { display: none; }
.bulk-bar span { margin-right: auto; }
th.sel, td.sel { width: 36px; padding-right: 0; }
td.sel input, th.sel input { width: 16px; height: 16px; margin: 0; vertical-align: middle; cursor: pointer; }
tr.selected td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
a.ext { color: inherit; display: inline-flex; align-items: center; gap: 5px; }
a.ext .ico { color: var(--muted); opacity: 0; transition: opacity .1s; }
a.ext:hover { color: var(--accent); }
a.ext:hover .ico, a.ext:focus-visible .ico { opacity: 1; color: var(--accent); }
@media (hover: none) { a.ext .ico { opacity: .6; } }
@media (max-width: 760px) { .filter-bar, .bulk-bar, .add-panel { padding-left: 16px; padding-right: 16px; } }
td.break.cell-main { min-width: 170px; }

/* Subdomains */
.site-picker { margin-bottom: 16px; }
a.chip { display: inline-flex; align-items: center; border: 1px solid var(--line); color: var(--ink-2); font-weight: 500; }
a.chip:hover { text-decoration: none; border-color: var(--baseline); color: var(--ink); }
a.chip.on { color: var(--surface); }
.input-suffix, .input-prefix { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); overflow: hidden; }
.input-suffix:focus-within, .input-prefix:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.input-suffix input, .input-prefix input { border: 0; border-radius: 0; flex: 1; min-width: 0; outline: none; }
.input-suffix span, .input-prefix span { display: flex; align-items: center; padding: 0 11px; background: var(--surface-2); color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.input-suffix span { border-left: 1px solid var(--line); }
.input-prefix span { border-right: 1px solid var(--line); }
.sub-options { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 14px; }
.sub-options .field { width: min(460px, 100%); }
.dns-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
