:root {
  --bg: #0b0e14;
  --bg2: #131825;
  --bg3: #171d2c;
  --border: #222a3a;
  --text: #e8ecf4;
  --muted: #8a94a8;
  --accent: #3b82f6;
  --up: #22c55e;
  --down: #ef4444;
  --warn: #f59e0b;
  --side: #0e1219;
  --land: #1d2536;
  --land-stroke: #2a3553;
  --act-bg: #1b2336;
}

/* Light theme — same variables, different values. data-theme is per-user
   (Account page); "auto" follows the OS. */
html[data-theme="light"] {
  --bg: #f3f5f9; --bg2: #ffffff; --bg3: #e9edf4; --border: #d7dee9;
  --text: #18212f; --muted: #5e6a7e; --accent: #2563eb;
  --up: #16a34a; --down: #dc2626; --warn: #d97706;
  --side: #ffffff; --land: #dde4ee; --land-stroke: #c3cddc; --act-bg: #e3ebfa;
}
@media (prefers-color-scheme: light) {
  html[data-theme="auto"] {
    --bg: #f3f5f9; --bg2: #ffffff; --bg3: #e9edf4; --border: #d7dee9;
    --text: #18212f; --muted: #5e6a7e; --accent: #2563eb;
    --up: #16a34a; --down: #dc2626; --warn: #d97706;
    --side: #ffffff; --land: #dde4ee; --land-stroke: #c3cddc; --act-bg: #e3ebfa;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--bg3); padding: 2px 6px; border-radius: 4px; font-size: 0.9em; }
code.block { display: block; padding: 10px 12px; overflow-x: auto; margin: 8px 0; white-space: pre-wrap; word-break: break-all; }

body.with-side { display: flex; min-height: 100vh; }
aside {
  width: 204px; flex-shrink: 0; background: var(--side); border-right: 1px solid var(--border);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; align-self: flex-start; height: 100vh; overflow-y: auto;
}
.side-logo { font-weight: 700; font-size: 1.1em; color: var(--text); padding: 6px 12px 16px; display: block; }
.side-logo:hover { text-decoration: none; }
aside a { display: flex; align-items: center; gap: 9px; color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 500; }
aside a:hover { color: var(--text); text-decoration: none; background: var(--bg2); }
aside a.act { background: var(--act-bg); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.navnum { margin-left: auto; background: var(--down); color: #fff; font-size: .72em; border-radius: 99px; padding: 0 7px; font-weight: 700; }
.side-sec { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 10px; }
.side-sec h4 { color: var(--muted); font-size: .7em; text-transform: uppercase; letter-spacing: .08em; padding: 2px 12px 6px; margin: 0; }
.side-sec a { padding: 5px 12px; font-size: .94em; }
.side-bottom { margin-top: auto; }
.side-bottom form { padding: 0 6px; }
.side-ver { padding: 6px 12px 2px; display: block; opacity: .6; }
.gdot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.gdot-up { background: var(--up); } .gdot-down { background: var(--down); } .gdot-warn { background: var(--warn); } .gdot-pending { background: var(--muted); }
.shell { flex: 1; min-width: 0; }
/* mobile top bar + slide-in nav (desktop hides these) */
.mobile-top { display: none; }
@media (max-width: 760px) {
  body.with-side { display: block; }
  .mobile-top {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 40;
    background: var(--side); border-bottom: 1px solid var(--border); padding: 8px 12px;
  }
  .nav-toggle { background: none; border: 0; color: var(--text); font-size: 1.5em; line-height: 1; cursor: pointer; padding: 2px 6px; }
  .mobile-logo { font-weight: 700; color: var(--text); }
  .mobile-top .navnum { margin-left: auto; }
  aside {
    position: fixed; top: 0; left: 0; bottom: 0; width: 270px; max-width: 85vw; height: 100vh;
    flex-direction: column; transform: translateX(-100%); transition: transform .2s ease; z-index: 60;
    box-shadow: 2px 0 16px rgba(0,0,0,.5);
  }
  body.nav-open aside { transform: translateX(0); }
  body.nav-open::after { content: ''; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 55; }
  .side-sec, .side-bottom { display: block; }
  main { margin: 14px auto; padding: 0 14px; }
  .card { padding: 14px 14px; }
  .page-head h1, h1 { font-size: 1.3em; }
  /* wide data tables scroll horizontally inside a .tscroll wrapper */
  .tscroll > .table { width: max-content; min-width: 100%; white-space: nowrap; }
  .topo-wrap { height: 62vh; }
}
.spacer { flex: 1; }

main { max-width: 760px; margin: 24px auto; padding: 0 22px; }
main.wide { max-width: 1180px; }

h1 { font-size: 1.5em; margin: 0 0 4px; }
h2 { font-size: 1.2em; }
h3 { font-size: 1.02em; margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.86em; }

.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.dash-filter {
  background: var(--bg2); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 12px; font-size: 0.92em; width: 200px;
}
.dash-filter:focus { outline: none; border-color: var(--accent); }
.page-head h1 { margin: 0; }
.chips { display: flex; gap: 8px; }
.chip { background: var(--bg3); border: 1px solid var(--border); border-radius: 99px; padding: 2px 12px; font-size: 0.85em; color: var(--muted); }
.chip-up { color: var(--up); }
.chip-down { color: var(--down); }

.btn {
  display: inline-block; background: var(--bg3); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 7px 14px; font-size: 0.92em; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); border-color: var(--accent); }
.btn-danger { color: var(--down); border-color: #5c2a26; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-sm { padding: 3px 10px; font-size: 0.85em; }
form.inline { display: inline; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell form, .actions-cell a { margin-left: 6px; }

.badge {
  display: inline-block; border-radius: 99px; padding: 1px 10px;
  font-size: 0.78em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-up { background: rgba(34,197,94,.14); color: var(--up); }
.badge-down { background: rgba(239,68,68,.14); color: var(--down); }
.badge-warn { background: rgba(245,158,11,.14); color: var(--warn); }
.badge-pending { background: var(--bg3); color: var(--muted); }
.badge-paused { background: var(--bg3); color: var(--muted); }
.badge-maint { background: rgba(59,130,246,.14); color: var(--accent); }

.table { width: 100%; border-collapse: collapse; background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.05em; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table.small td, .table.small th { padding: 6px 10px; font-size: 0.88em; }

.card { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin: 16px 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .cols { grid-template-columns: 1fr; } }

.empty { background: var(--bg2); border: 1px dashed var(--border); border-radius: 10px; padding: 36px; text-align: center; color: var(--muted); }

.form label { display: block; margin: 10px 0; font-size: 0.92em; color: var(--muted); }
.form input, .form select, .form textarea {
  display: block; width: 100%; margin-top: 4px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; font-size: 1em;
  font-family: inherit;
}
.form textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
.form input:focus, .form select:focus, .form textarea:focus { outline: none; border-color: var(--accent); }
.input-sm {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 8px; font-size: 0.85em; width: 140px;
}
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 14px; }
label.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; color: var(--text); }
label.check input { width: auto; display: inline; margin: 0; }

.flash { border-radius: 8px; padding: 10px 14px; margin: 0 0 16px; font-size: 0.93em; }
.flash-ok { background: #16351f; color: var(--up); }
.flash-err { background: #3d1715; color: #f0a8a0; }
.flash-warn { background: #33301a; color: #e8d98a; }
.flash-maint { background: #16283f; color: #9cc0f5; }

.stats { display: flex; gap: 14px; flex-wrap: wrap; margin: 16px 0; }
.stat { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 18px; min-width: 120px; }
.stat-v { font-size: 1.3em; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-v.bad { color: var(--down); }
.stat-l { color: var(--muted); font-size: 0.8em; text-transform: uppercase; letter-spacing: 0.05em; }

.bars { display: flex; gap: 2px; align-items: stretch; height: 30px; margin-top: 8px; padding-top: 6px; }
.bar { flex: 1; border-radius: 2px; min-width: 3px; position: relative; }
@media (max-width: 600px) { .bars { gap: 1px; } .bar { min-width: 0; border-radius: 1px; } }
.bar.note::after {
  content: ''; position: absolute; top: -6px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--text);
}
.bar.ok { background: var(--up); }
.bar.warn { background: var(--warn); }
.bar.bad { background: var(--down); }
.bar.na { background: var(--bg3); }

.events { list-style: none; padding: 0; margin: 0; }
.ev-comment { display: flex; gap: 6px; margin-top: 6px; }
.ev-comment input {
  flex: 1; background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 6px; padding: 4px 8px; font-size: 0.85em;
}
.events li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.events li:last-child { border-bottom: none; }

.auth-card { max-width: 360px; margin: 10vh auto 0; background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 28px 30px; }
.auth-card h1 { text-align: center; }
.auth-card h2 { color: var(--muted); font-size: 1em; font-weight: 400; text-align: center; margin-top: -4px; }
.auth-card label { display: block; margin: 12px 0; color: var(--muted); font-size: 0.9em; }
.auth-card input { display: block; width: 100%; margin-top: 4px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 9px 11px; font-size: 1em; }
.auth-card button { width: 100%; margin-top: 14px; }

/* dashboard summary + tiles */
.summary { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.sum-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 22px; text-align: center; min-width: 90px;
}
.sum-v { font-size: 1.6em; font-weight: 700; font-variant-numeric: tabular-nums; }
.sum-l { color: var(--muted); font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.05em; }
.sum-up .sum-v { color: var(--up); }
.sum-down .sum-v { color: var(--down); }
.sum-warn .sum-v { color: var(--warn); }
.sum-maint .sum-v { color: var(--accent); }

/* 12-column snap grid (Grafana-style): tiles carry an inline
   "grid-column: span N" + optional min-height set by drag-resize. */
/* align-items start: a tile's height is its own (content or drag-set), not
   stretched to the tallest tile in the row — so tiles can be made shorter */
.tiles { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; align-items: start; }
.tiles.resizing {
  background-image: linear-gradient(to right, var(--border) 1px, transparent 1px),
    linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: calc(100% / 12) 34px;
  border-radius: 10px;
}
.tile-rs {
  position: absolute; right: 3px; bottom: 0; cursor: nwse-resize;
  color: var(--muted); opacity: 0; font-size: 0.72em; user-select: none; touch-action: none;
  padding: 2px 4px; line-height: 1;
}
.tile:hover .tile-rs { opacity: 0.7; }
[data-readonly] .tile-rs { display: none; }
@media (max-width: 1100px) { .tile { grid-column: span 6 !important; } }
@media (max-width: 700px) { .tiles { grid-template-columns: 1fr; } .tile { grid-column: 1 / -1 !important; min-height: 0 !important; } }
.tile {
  display: flex; flex-direction: column; position: relative; background: var(--bg2); border: 1px solid var(--border);
  border-left: 4px solid var(--muted); border-radius: 10px; padding: 14px 16px;
  color: var(--text); text-decoration: none; transition: border-color 0.15s, transform 0.1s;
  min-width: 0; overflow: hidden;
  container-type: inline-size;
}
.tile:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); }
.tile-up { border-left-color: var(--up); }
.tile-down { border-left-color: var(--down); background: linear-gradient(180deg, rgba(231, 76, 60, 0.08), transparent 60%), var(--bg2); }
.tile-warn { border-left-color: var(--warn); background: linear-gradient(180deg, rgba(241, 196, 15, 0.07), transparent 60%), var(--bg2); }
.tile-maint { border-left-color: var(--accent); }
.tile-paused { border-left-color: var(--muted); opacity: 0.75; }
.tile-pending { border-left-color: var(--muted); }
.tile-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tile-sub { margin: 3px 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; }
.tile .spark { color: var(--accent); }
.tile-down .spark { color: var(--down); }
.tile.dragging { opacity: 0.4; border-style: dashed; }
/* legacy size classes keep their inner styling; the grid span itself now
   comes from the tile's inline style (tile_w) */
.tile-panel-chart .chart { margin: 4px 0 0; }
.tile-panel-chart .chart svg { height: 110px; }
.tile-panel-chart .chart-meta { font-size: 0.82em; flex-wrap: wrap; }
/* content adapts to the drag-set box: graphs stretch into free height, the
   big number scales with tile width (container query units) */
.tile > .spark { flex: 1 1 34px; min-height: 26px; height: auto; }
.tile-parent { margin: -4px 0 8px; opacity: 0.85; }
.group-head { display: flex; align-items: baseline; gap: 12px; margin: 26px 0 12px; }
.group-head:first-of-type { margin-top: 8px; }
.group-head h2 { margin: 0; font-size: 1.05em; }
.tiles + .group-head { margin-top: 30px; }
.tiles:empty { min-height: 70px; border: 1px dashed var(--border); border-radius: 10px; }
.compare-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0 14px; }

/* charts */
.tile-gauge { text-align: center; }
.gauge { display: block; width: 116px; height: 66px; margin: 0 auto; }
.gauge-v { font-size: 13px; font-weight: 700; }
.tile-num {
  font-size: clamp(1.3rem, 12cqw, 4.5rem);
  font-weight: 700; text-align: center; margin: 2px 0 0; font-variant-numeric: tabular-nums;
  flex: 1 0 auto; display: flex; align-items: center; justify-content: center; min-height: 0;
}
.tile-gauge { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: center; }
.spark { display: block; width: 100%; height: 34px; }
.spark-empty { height: 34px; }
.chart { margin: 10px 0; }
.chart svg { display: block; width: 100%; height: 150px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.chart-meta { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; font-size: 0.92em; }
.chart-empty { padding: 24px; text-align: center; background: var(--bg); border: 1px dashed var(--border); border-radius: 8px; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.legend-item { margin-left: 12px; white-space: nowrap; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.rel-list { list-style: none; padding: 0; margin: 0 0 10px; }
.rel-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }
.rel-list li:last-child { border-bottom: none; }
/* aligned 3-column layout: name | "depends on this" | component picker */
.rel-row { display: grid; grid-template-columns: 1fr 130px 150px; align-items: center; gap: 10px; padding: 3px 0; }
.rel-row > label.check { margin: 0; }
.rel-row .rel-dep { justify-self: start; font-size: 0.85em; color: var(--muted); white-space: nowrap; }
.rel-row .rel-pm { justify-self: stretch; }
.rel-none { display: block; margin: 8px 0 4px; font-size: 0.85em; color: var(--muted); }
@media (max-width: 640px) { .rel-row { grid-template-columns: 1fr auto; } .rel-row .rel-pm { grid-column: 1 / -1; justify-self: start; } }
details summary { cursor: pointer; margin: 8px 0; color: var(--muted); font-size: 0.88em; }

/* form builders */
.builder-rows { margin: 8px 0; }
.b-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; flex-wrap: wrap; }
.b-row select, .b-row input { display: inline-block; width: auto; flex: 1 1 110px; margin-top: 0; min-width: 90px;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 7px; padding: 7px 9px; font-size: 0.93em; }
.b-row .b-sev { flex: 0 0 140px; }
.b-row [data-val] { flex: 0 1 110px; }
.b-row [data-del] { flex: 0 0 auto; }
.b-row span { flex: 0 0 auto; }
details.adv { margin-top: 8px; }
details.adv textarea { margin-top: 6px; }

/* threshold sliders */
.thresh { margin: 10px 0; }
.thresh-slider { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.thresh-slider input[type=range] { flex: 1; accent-color: var(--accent); margin: 0; }
.thresh-slider output { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.thresh.off .thresh-slider { opacity: 0.35; }
@media (max-width: 760px) { .chart-grid { grid-template-columns: 1fr; } }

/* public status page */
.ps-body { background: var(--bg); }
.ps-main { max-width: 720px; margin: 6vh auto; padding: 0 18px; }
.ps-logo { max-height: 48px; max-width: 240px; margin-bottom: 10px; display: block; }
.ps-banner { border-radius: 10px; padding: 14px 18px; font-weight: 600; margin: 18px 0 26px; }
.ps-up { background: #16351f; color: var(--up); }
.ps-down { background: #3d1715; color: var(--down); }
.ps-warn { background: #33301a; color: var(--warn); }
.ps-partial { background: #3a2516; color: #e67e22; }
.ps-na { background: var(--bg3); color: var(--muted); }
.ps-monitor { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 18px; margin: 12px 0; }
.ps-ann {
  background: var(--bg2); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 12px 16px; margin: 12px 0;
}
.ps-ann-active { background: #16283f; border-left-color: var(--accent); }
.ps-sub { margin: 18px 0; }
.ps-sub summary { color: var(--muted); cursor: pointer; }
.ps-sub form { display: flex; gap: 8px; margin-top: 8px; }
.ps-sub input {
  flex: 1; background: var(--bg2); color: var(--text); border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 12px; font-size: 1em;
}
.ps-spark { display: flex; align-items: center; gap: 10px; margin-top: 8px; color: var(--accent); }
.ps-spark .spark { height: 26px; }
.ps-row { display: flex; align-items: center; gap: 10px; }
.ps-name { font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-up { background: var(--up); box-shadow: 0 0 8px var(--up); }
.dot-down { background: var(--down); box-shadow: 0 0 8px var(--down); }
.dot-warn { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.dot-maint { background: var(--accent); box-shadow: 0 0 8px var(--accent); }
.dot-na { background: var(--muted); }
footer { margin-top: 34px; text-align: center; }
.app-footer { margin: 40px 0 14px; text-align: center; opacity: 0.7; }


/* overview page */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
.kpi { background: var(--bg2); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; display: flex; gap: 12px; align-items: center; }
.kpi-ic { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.05em; flex-shrink: 0; }
.kpi small { color: var(--muted); display: block; font-size: .78em; }
.kpi b { font-size: 1.18em; }
.kpi-sub { display: block; font-size: .74em; color: var(--muted); }
.ovw-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 16px; margin-bottom: 16px; }
.ovw-grid-rev { grid-template-columns: 1fr 1.45fr; }
.ovw-grid .card { margin: 0; }
@media (max-width: 900px) { .ovw-grid, .ovw-grid-rev { grid-template-columns: 1fr; } }
.worldmap { width: 100%; height: auto; display: block; }
.worldmap .land { fill: var(--land); stroke: var(--land-stroke); stroke-width: 1; }
.worldmap .land path { vector-effect: non-scaling-stroke; } /* hairline borders at any zoom */
/* font-size comes from the SVG attribute (scaled with the viewBox zoom) — don't override it here */
.map-name { fill: var(--text); font-weight: 600; }
.map-sub { fill: var(--muted); }
.center-legend { justify-content: center; display: flex; margin-top: 6px; font-size: .82em; color: var(--muted); }
.perf-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--bg3); }
.perf-row:last-child { border-bottom: none; }
.perf-row span:first-child { width: 120px; color: var(--muted); flex-shrink: 0; }
.perf-row .spark { height: 24px; }
.perf-row b { width: 76px; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.feed-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--bg3); }
.feed-row:last-child { border-bottom: none; }
.feed-row .t { flex: 1; min-width: 0; }
.feed-row .t small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feed-row .ago { white-space: nowrap; }
.sev { font-size: .72em; font-weight: 700; border-radius: 6px; padding: 2px 9px; white-space: nowrap; }
.sev-c { background: rgba(239,68,68,.16); color: var(--down); }
.sev-w { background: rgba(245,158,11,.16); color: var(--warn); }
.sev-u { background: rgba(34,197,94,.16); color: var(--up); }
.sev-i { background: rgba(56,189,248,.16); color: #38bdf8; }
.av-row { display: flex; align-items: center; gap: 12px; padding: 6px 0; }
.av-row span:first-child { width: 120px; color: var(--muted); flex-shrink: 0; }
.av-row .av-bar { flex: 1; height: 7px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.av-row .av-bar i { display: block; height: 100%; border-radius: 99px; }
.av-row b { width: 64px; text-align: right; font-variant-numeric: tabular-nums; }
.ovw-table td, .ovw-table th { padding: 8px 12px; }
.mon-link { font-weight: 600; }
.st-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.pbar { display: inline-flex; align-items: center; gap: 8px; }
.pbar-t { width: 70px; height: 6px; background: var(--bg3); border-radius: 99px; overflow: hidden; display: inline-block; }
.pbar-t i { display: block; height: 100%; border-radius: 99px; }

/* ---------- customizable overview panels ---------- */
.ovw-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ovw-panel { min-width: 0; }
.ovw-panel.span2 { grid-column: span 2; }
.ovw-panel > .card { margin: 0; height: 100%; box-sizing: border-box; }
.ovw-panel.dragging { opacity: 0.4; outline: 1px dashed var(--accent); border-radius: 10px; }
.ovw-panel h3.drag-handle { cursor: grab; }
@media (max-width: 900px) { .ovw-panels { grid-template-columns: 1fr; } .ovw-panel.span2 { grid-column: auto; } }

/* ---------- draggable dashboard group sections ---------- */
.ghandle { cursor: grab; color: var(--muted); user-select: none; font-size: 0.95em; }
.group-head[data-ghandle] { cursor: grab; }
.group-head[data-ghandle]:hover .ghandle { color: var(--text); }
section[data-gsec].dragging { opacity: 0.4; outline: 1px dashed var(--accent); border-radius: 10px; }

/* ---------- devices tree ---------- */
.dev-group { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; overflow: hidden; }
.dev-group > summary { display: flex; align-items: center; gap: 10px; padding: 11px 14px; cursor: pointer; list-style: none; font-weight: 600; }
.dev-group > summary::-webkit-details-marker { display: none; }
.dev-caret { color: var(--muted); font-size: 0.75em; transition: transform 0.15s; }
.dev-group[open] .dev-caret { transform: rotate(90deg); }
.dev-rows { border-top: 1px solid var(--border); }
.dev-mon { border-bottom: 1px solid var(--border); }
.dev-mon:last-child { border-bottom: none; }
.dev-mon > summary { list-style: none; cursor: pointer; }
.dev-mon > summary::-webkit-details-marker { display: none; }
.dev-row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; }
.dev-mon > summary:hover { background: var(--bg3); }
.dev-chev { color: var(--muted); font-size: 0.85em; transition: transform 0.15s; margin-left: 2px; }
.dev-mon[open] .dev-chev { transform: rotate(180deg); }
.dev-strip { display: flex; flex-wrap: wrap; gap: 16px; padding: 0 14px 9px; color: var(--muted); font-size: 0.85em; }
.dev-strip b { color: var(--text); font-weight: 500; }
.dev-mon[open] .dev-strip { display: none; }
.dev-detail { padding: 4px 14px 14px; }
.dev-err { margin-bottom: 8px; color: var(--down); }
.dev-chips { margin-top: 10px; }
.mcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.mcard { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px 7px; min-width: 0; }
.mcard-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 0.78em; white-space: nowrap; }
/* the avg/max subtitle shrinks with ellipsis so it can never push the style
   button out of the card */
.mcard-h span:last-of-type { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; margin-left: auto; }
.mcard-v { font-size: 1.22em; font-weight: 600; margin: 2px 0 5px; }
.mcard .spark { width: 100%; height: 28px; display: block; }
.dev-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot-pending { background: var(--muted); }
.dot-paused { background: var(--bg3); border: 1px solid var(--muted); box-sizing: border-box; }
.dev-name { font-weight: 500; }
.dev-elbow { color: var(--muted); margin-right: -4px; }
.dev-type { background: var(--bg3); border: 1px solid var(--border); border-radius: 4px; padding: 1px 7px; font-size: 0.75em; color: var(--muted); }
.dev-snap { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 32%; }
.dev-when { min-width: 70px; text-align: right; }
@media (max-width: 700px) { .dev-snap, .dev-when { display: none; } }

.gauge-track { stroke: var(--bg3); }

/* overview "⚙ Panels" dropdown */
.ovw-cfg { position: relative; }
.ovw-cfg > summary { list-style: none; cursor: pointer; }
.ovw-cfg > summary::-webkit-details-marker { display: none; }
.ovw-cfg-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; min-width: 200px; box-shadow: 0 8px 24px rgba(0,0,0,.35);
  white-space: nowrap;
}

/* auto-compact: applied by a ResizeObserver based on the tile's real height */
.tile-short .tile-sub, .tile-short .tile-parent { display: none; }
.tile-mini .tile-sub, .tile-mini .tile-parent, .tile-mini > .spark,
.tile-mini .tile-gauge, .tile-mini .tile-num + div { display: none; }
.tile-mini .tile-num { font-size: 1.15rem; margin: 0; }

/* metric card style switcher */
.mcard-cfg {
  background: transparent; border: 1px solid var(--border); border-radius: 5px;
  color: var(--muted); cursor: pointer; font-size: 0.85em; line-height: 1;
  padding: 1px 6px; opacity: 0; flex-shrink: 0;
}
.mcard:hover .mcard-cfg { opacity: 0.85; }
.mcard-cfg:hover { color: var(--text); border-color: var(--muted); }
.mcard-gauge { text-align: center; }
.mcard-gauge .gauge { width: 120px; height: 68px; }
.mcard-v.mcard-big { font-size: 2em; margin: 8px 0 6px; }

/* explore page */
.explore-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.explore-ranges { display: flex; gap: 6px; flex-wrap: wrap; }
.explore-add { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.explore-add select { min-width: 260px; }
.explore-add .btn { white-space: nowrap; }
.mcard-h a.mcard-cfg { text-decoration: none; text-align: center; }

/* controls shown but not yet usable (e.g. agent OS not detected yet) */
.is-disabled { opacity: 0.55; }
.is-disabled input, .is-disabled .btn { cursor: not-allowed; }

.dev-ico { font-size: 0.95em; flex-shrink: 0; width: 1.3em; text-align: center; }

.rel-pm { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px; font-size: 0.85em; }

/* detected dependency suggestions */
.rel-suggest { margin-bottom: 12px; }
.rel-sug-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: rgba(59,130,246,.10); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; font-size: 0.9em; }

.rel-group { margin-bottom: 12px; }
.rel-h { margin: 6px 0; font-size: 0.9em; font-weight: 600; }
.chip-dep { color: var(--accent); border-color: var(--accent); }

/* ---------- topology map ---------- */
.topo-wrap { position: relative; height: 72vh; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); cursor: grab; touch-action: none; }
.topo-wrap:active { cursor: grabbing; }
.topo-canvas { position: absolute; top: 0; left: 0; transform-origin: 0 0; }
.topo-edges { position: absolute; top: 0; left: 0; overflow: visible; pointer-events: none; }
.topo-edge { stroke: var(--muted); stroke-width: 1.5; opacity: 0.55; }
.topo-edge.parent { opacity: 0.85; }
.topo-edge:not(.parent) { stroke-dasharray: 5 4; }
.topo-elabel { fill: var(--muted); font-size: 10px; text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 3px; }
.topo-elabel.mid { fill: var(--accent); }
.topo-nodes { position: absolute; top: 0; left: 0; }
.topo-node {
  position: absolute; width: 168px; background: var(--bg2); border: 1px solid var(--border);
  border-left: 3px solid var(--muted); border-radius: 8px; padding: 8px 10px; cursor: grab;
  box-shadow: 0 2px 8px rgba(0,0,0,.25); user-select: none;
}
.topo-node.dragging { cursor: grabbing; box-shadow: 0 6px 18px rgba(0,0,0,.45); z-index: 5; }
.topo-node.state-up { border-left-color: var(--up); }
.topo-node.state-down { border-left-color: var(--down); }
.topo-node.state-warn { border-left-color: var(--warn); }
.topo-node.state-maint { border-left-color: var(--accent); }
.topo-node.state-paused { border-left-color: var(--muted); opacity: 0.7; }
.tn-head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 0.9em; }
.tn-head a { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-ico { flex-shrink: 0; }
.tn-sub { font-size: 0.72em; text-transform: uppercase; letter-spacing: .04em; }
.tn-stat { font-size: 0.8em; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.topo-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; align-items: center; }
.topo-legend span { display: inline-flex; align-items: center; gap: 5px; }
.topo-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* topology editing */
.topo-hit { stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.topo-wrap.linking { cursor: crosshair; }
.topo-wrap.linking .topo-node { cursor: crosshair; }
.topo-node.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 2px 8px rgba(0,0,0,.3); z-index: 6; }
.topo-bar {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; display: flex; align-items: center; gap: 8px; font-size: 0.88em;
  box-shadow: 0 4px 16px rgba(0,0,0,.4); white-space: nowrap;
}
.topo-bar .btn { padding: 3px 10px; }

.topo-ctrls { position: absolute; right: 12px; bottom: 12px; z-index: 12; display: flex; flex-direction: column; gap: 6px; }
.topo-ctrls button {
  width: 38px; height: 38px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text); font-size: 1.2em; line-height: 1; cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.topo-ctrls button:hover { border-color: var(--accent); }

.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

/* ---------- topology v2 visual upgrade ---------- */
.topo-canvas { background-image: radial-gradient(var(--border) 1px, transparent 1px); background-size: 24px 24px; }
.topo-node {
  width: 176px; padding: 9px 11px; border-radius: 10px; border-left-width: 3px;
  display: flex; flex-direction: column; gap: 5px; transition: transform .12s, box-shadow .12s, border-color .12s, opacity .12s;
}
.topo-node:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.45); z-index: 7; }
.tn-head { display: flex; align-items: center; gap: 9px; }
.tn-ico { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.05em; background: var(--bg3); flex-shrink: 0; }
.tn-name { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.tn-name a { font-weight: 600; font-size: 0.92em; color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tn-sub { font-size: 0.62em; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); }
.tn-stat { font-size: 0.78em; color: var(--muted); font-variant-numeric: tabular-nums; }
.tn-status { position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.state-up .tn-status { background: var(--up); box-shadow: 0 0 7px var(--up); }
.state-down .tn-status { background: var(--down); box-shadow: 0 0 9px var(--down); animation: topopulse 1.6s ease-in-out infinite; }
.state-warn .tn-status { background: var(--warn); box-shadow: 0 0 7px var(--warn); }
.state-maint .tn-status { background: var(--accent); }
.state-down { box-shadow: 0 0 0 1px var(--down), 0 0 16px -4px var(--down); }
@keyframes topopulse { 50% { opacity: .35; } }
/* type-coloured icon chips */
.type-snmp .tn-ico { background: rgba(59,130,246,.18); }
.type-agent .tn-ico { background: rgba(34,197,94,.16); }
.type-http .tn-ico, .type-tcp .tn-ico, .type-ping .tn-ico { background: rgba(168,139,250,.18); }

.topo-edge { stroke: var(--muted); stroke-width: 1.6; opacity: .5; }
.topo-edge.parent { stroke: var(--accent); opacity: .8; marker-end: url(#topoArrow); }
.topo-edge:not(.parent) { stroke-dasharray: 5 4; }
.topo-edge.down { stroke: var(--down); opacity: .9; }
.topo-flow { stroke: var(--up); stroke-width: 2.2; stroke-dasharray: 2 10; stroke-linecap: round; opacity: .9; pointer-events: none; animation: topoflow .7s linear infinite; }
@keyframes topoflow { to { stroke-dashoffset: -12; } }
.topo-elabel { fill: var(--muted); font-size: 10px; text-anchor: middle; paint-order: stroke; stroke: var(--bg); stroke-width: 3.5px; stroke-linejoin: round; }
.topo-elabel.mid { fill: var(--accent); font-weight: 600; }
/* hover focus: dim everything except the hovered node and its links */
.has-hl .topo-node:not(.hl) { opacity: .32; }
.has-hl .topo-edge:not(.hl) { opacity: .08; }
.has-hl .topo-flow:not(.hl), .has-hl .topo-elabel:not(.hl) { opacity: .12; }
.topo-node.hl { border-color: var(--accent); }

/* group status: overlapping dots for mixed states (green+red, green+yellow…) */
.gdots { display: inline-flex; align-items: center; flex-shrink: 0; }
.gdots .gdot { box-shadow: 0 0 0 1.5px var(--side); }
.gdots .gdot + .gdot { margin-left: -3px; }
