/* ServerWatch portal — dark ops theme, matching the mobile app's status colours. */
:root {
    --bg: #0f1720;
    --surface: #17212b;
    --surface-2: #1e2a36;
    --border: #2a3947;
    --text: #e6edf3;
    --muted: #8fa3b5;
    --crit: #d64545;
    --crit-bg: #2e1b1e;
    --warn: #c77e1a;
    --warn-bg: #2c2415;
    --ok: #2f8f57;
    --ok-bg: #16291f;
    --accent: #4f8cc9;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { font-size: 14px; font-weight: 600; margin: 22px 0 8px; }
h3 { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.boot { padding: 40px; color: var(--muted); }

/* ---- shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 190px; flex-shrink: 0; background: var(--surface);
    border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 14px 0;
    /* Pinned: page content scrolls, the menu does not. If the menu itself ever
       overflows (small window), it scrolls independently. */
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { font-weight: 600; font-size: 15px; padding: 0 16px 14px; }
.nav-item { display: block; padding: 9px 16px; color: var(--muted); border-left: 2px solid transparent; }
.nav-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); border-left-color: var(--accent); }
.sidebar-foot { margin-top: auto; padding: 12px 16px; border-top: 1px solid var(--border); }
.user { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.content { flex: 1; padding: 20px 24px 60px; min-width: 0; }

.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.page-head h1 { flex: 1; }
.head-actions { display: flex; gap: 6px; }

/* ---- kpis ---- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 12px 14px; display: flex; flex-direction: column; border-left-width: 4px;
}
.kpi .n { font-size: 26px; font-weight: 600; line-height: 1.1; }
.kpi .l { font-size: 11px; color: var(--muted); letter-spacing: .4px; }
.kpi.crit { border-left-color: var(--crit); }
.kpi.warn { border-left-color: var(--warn); }
.kpi.ok { border-left-color: var(--ok); }

/* ---- server tiles (wall view) ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 8px; }
.tile { border-radius: 8px; padding: 9px 11px; border: 1px solid var(--border); background: var(--surface); }
.tile.crit { background: var(--crit-bg); border-color: var(--crit); }
.tile.warn { background: var(--warn-bg); border-color: var(--warn); }
.tile.ok { background: var(--ok-bg); border-color: #24513a; }
.tile-name { font-size: 12px; font-weight: 600; }
.tile-sub { font-size: 11px; color: var(--muted); font-family: Consolas, monospace; margin-top: 2px; }

/* ---- tables ---- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.table th {
    text-align: left; font-size: 11px; font-weight: 600; color: var(--muted);
    padding: 8px 10px; border-bottom: 1px solid var(--border); text-transform: uppercase; letter-spacing: .3px;
}
.table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.sel { background: #1b2b3a; }
.table.compact td { padding: 5px 8px; }

/* ---- bits ---- */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.dot.crit { background: var(--crit); }
.dot.warn { background: var(--warn); }
.pill {
    display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .4px;
    padding: 2px 8px; border-radius: 10px; text-transform: uppercase; background: #2a3947; color: var(--text);
}
.pill.crit, .pill.critical { background: var(--crit); color: #fff; }
.pill.warn, .pill.warning { background: var(--warn); color: #1c1408; }
.pill.ok, .pill.healthy { background: var(--ok); color: #fff; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 10px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) {
    .two-col { grid-template-columns: 1fr; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .shell { flex-direction: column; }

    /* Sidebar becomes a slim sticky top bar: logo + icon-only nav in one row.
       A vertical menu pushed the whole dashboard below the fold on phones. */
    .sidebar {
        width: 100%; height: auto; overflow: visible;
        position: sticky; top: 0; z-index: 100;
        flex-direction: row; align-items: center; gap: 0;
        padding: 4px 6px; border-right: none; border-bottom: 1px solid var(--border);
    }
    /* Fixed-width end slots (logo left, sign-out right) so the six nav cells
       divide the remaining width evenly — one rhythm across the whole bar. */
    .brand-row { padding: 0; width: 46px; flex-shrink: 0; justify-content: center; }
    .brand { gap: 0; }
    .logo { width: 24px; height: 24px; }
    .brand-word { display: none; }
    .collapse-btn { display: none; }
    /* Symmetric transparent borders keep icons vertically centred — a bottom-only
       2px underline visibly pushed every icon up. */
    .nav-item {
        flex: 1; justify-content: center; padding: 12px 0;
        border-left: none; border-top: 2px solid transparent; border-bottom: 2px solid transparent;
    }
    .nav-item.active { border-left-color: transparent; border-bottom-color: var(--accent); background: none; }
    .nav-label { display: none; }
    .sidebar-foot {
        margin: 0; padding: 0; width: 46px; flex-shrink: 0; border-top: none;
        display: flex; align-items: center; justify-content: center;
    }
    .sidebar-foot .foot-full, .sidebar-foot .foot-d { display: none; }
    .sidebar-foot .foot-m { display: inline-block; }

    .content { padding: 14px 12px 40px; }
    .page-head, .head-actions { flex-wrap: wrap; }
    /* Wide tables scroll inside themselves instead of stretching the page. */
    .table { display: block; overflow-x: auto; }
}

/* ---- controls ---- */
button {
    font: inherit; background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 6px; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: #3d5468; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.small { padding: 4px 10px; font-size: 12px; }
button.link { background: none; border: none; color: var(--accent); padding: 0; }
button:disabled { opacity: .55; cursor: default; }

input, .search, textarea, select {
    font: inherit; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px;
}
textarea { resize: vertical; }
select option { background: var(--surface); color: var(--text); }
input:focus, textarea:focus, select:focus { outline: 1px solid var(--accent); border-color: var(--accent); }
.search { width: 260px; }
input[type=checkbox] { width: 14px; height: 14px; accent-color: var(--accent); }

.filters { display: flex; gap: 6px; margin-bottom: 12px; }
.chip { font-size: 12px; padding: 5px 12px; border-radius: 14px; }
.chip.on { border-color: var(--accent); color: var(--text); }
.chip.on.crit { border-color: var(--crit); }
.chip.on.warn { border-color: var(--warn); }
.chip.on.ok { border-color: var(--ok); }

.bulk-bar {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 10px;
    background: var(--surface-2); border: 1px solid var(--accent); border-radius: 8px; font-size: 13px;
}

/* ---- login ---- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 28px 30px; width: 330px; display: flex; flex-direction: column;
}
.login-card h1 { text-align: center; }
.login-card p.muted { text-align: center; margin: 4px 0 18px; }
.login-card label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.login-card input { margin-bottom: 14px; }
.login-card button.primary { padding: 9px; margin-top: 4px; }
.error { color: var(--crit); font-size: 13px; margin: 0 0 10px; }

#blazor-error-ui {
    background: var(--warn); color: #1c1408; bottom: 0; display: none;
    left: 0; padding: 10px 14px; position: fixed; width: 100%; z-index: 1000;
}

/* ---- vitals ---- */
.vitals { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-bottom: 6px; }
.vital { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }
.vital.clickable { cursor: pointer; }
.vital.clickable:hover { outline: 1px solid var(--border); }
.v-label { font-size: 11px; color: var(--muted); }
.v-value { font-size: 21px; font-weight: 600; margin: 2px 0 6px; }
.v-value.small { font-size: 15px; }
.v-sub { font-size: 11px; color: var(--muted); font-weight: 400; }
.v-foot { font-size: 11px; color: var(--muted); margin-top: 3px; }
.disk-row { display: flex; align-items: center; gap: 8px; margin: 5px 0; }
.disk-letter { font-size: 11px; width: 14px; color: var(--muted); }
.disk-free { font-size: 11px; font-family: Consolas, monospace; color: var(--muted); white-space: nowrap; }
.disk-free.crit { color: var(--crit); }
.disk-free.warn { color: var(--warn); }

.meter { position: relative; flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,.09); overflow: visible; }
.meter-fill { height: 6px; border-radius: 3px; background: var(--ok); }
.meter-fill.crit { background: var(--crit); }
.meter-fill.warn { background: var(--warn); }
.meter-tick { position: absolute; top: -2px; width: 2px; height: 10px; background: rgba(255,255,255,.35); }

.spark { width: 100%; height: 24px; margin-top: 5px; display: block; }
.spark-line { stroke: var(--ok); }
.spark-line.crit { stroke: var(--crit); }
.spark-line.warn { stroke: var(--warn); }

/* ---- component rows ---- */
.w16 { width: 16px; }
.svc-chip {
    font-size: 11px; padding: 2px 8px; margin: 0 4px 3px 0; border-radius: 5px;
    background: rgba(255,255,255,.07); border: none; color: var(--ok); cursor: pointer;
}
.svc-chip.crit { color: var(--crit); }
.svc-chip.warn { color: var(--warn); }
.svc-chip:disabled { cursor: default; }
.svc-chip:hover:not(:disabled) { background: rgba(255,255,255,.14); }
.row-action { background: none; border: none; color: var(--accent); padding: 0 4px; cursor: pointer; font-size: 13px; }
.query-row { white-space: normal; word-break: break-word; }
tr.clickable { cursor: pointer; }
.role-chip {
    font-size: 10px; color: var(--muted); border: 1px solid var(--border);
    border-radius: 4px; padding: 1px 5px; margin-left: 5px;
}

/* ---- modals ---- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex;
    align-items: center; justify-content: center; z-index: 500; padding: 20px;
}
.modal {
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
    padding: 18px 20px; width: 420px; max-width: 100%; max-height: 90vh; overflow: auto;
}
.modal.wide { width: 780px; }
.modal.xwide { width: 960px; }

/* ---- server detail modal ---- */
.sdm-title { display: flex; align-items: center; gap: 7px; min-width: 0; }
.sdm-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sdm-meta { margin: 0 0 12px; }
.xsmall { font-size: 11px; }

.sdm-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.sdm-tile { background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; }
.sdm-tile .t-label { color: var(--muted); font-size: 12px; }
.sdm-tile .t-value { font-size: 23px; font-weight: 600; margin-top: 1px; }
.sdm-tile .t-sub { color: var(--muted); font-size: 11px; font-family: Consolas, monospace; margin-top: 2px; }

.sdm-chart-card { background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.sdm-chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.sdm-chart-title { font-size: 13px; }
.sdm-toggles { display: flex; gap: 6px; }
.sdm-toggle { font-size: 12px; background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 6px; padding: 3px 10px; cursor: pointer; }
.sdm-toggle:hover:not(:disabled) { color: var(--text); }
.sdm-toggle.on { background: rgba(255,255,255,.08); color: var(--text); border-color: #3d5468; }
.sdm-toggle:disabled { opacity: .5; cursor: default; }
.sdm-subtoggles { display: flex; gap: 6px; margin: 2px 0 8px; }
.sdm-view-row { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; }
.sdm-view-switch { display: flex; gap: 6px; }
.peak-line { stroke: var(--warn); stroke-width: 1; stroke-dasharray: 3 3; }
.sdm-nochart { padding: 24px 0; text-align: center; }

.sdm-checks-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; }
.sdm-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; font-family: Consolas, monospace; font-size: 13px; }
.sdm-check { display: flex; align-items: center; gap: 8px; min-width: 0; }
.sdm-check > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sdm-top { margin: 14px 0 4px; }
.sdm-top-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.sdm-top-col { background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; min-width: 0; }
.sdm-top-title { color: var(--muted); font-size: 11px; margin-bottom: 6px; }
.sdm-top-row { display: flex; justify-content: space-between; gap: 8px; font-family: Consolas, monospace; font-size: 11.5px; padding: 2px 0; min-width: 0; }
.sdm-top-name { color: #c9d4de; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sdm-top-val { color: var(--muted); white-space: nowrap; flex-shrink: 0; }
@media (max-width: 720px) { .sdm-top-grid { grid-template-columns: 1fr; } }

.sdm-svc-panel { background: rgba(255,255,255,.03); border: 1px solid var(--border); border-radius: 10px; padding: 6px 14px 12px; margin: 14px 0; }
.sdm-svc-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 4px; }
.sdm-svc-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.sdm-svc-row:last-of-type { border-bottom: none; }
.sdm-svc-name { font-family: Consolas, monospace; font-size: 13px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.sdm-svc-foot { padding-top: 8px; }
.sdm-act { font-size: 12px; background: rgba(255,255,255,.06); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 5px 13px; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.sdm-act:hover { background: rgba(255,255,255,.12); }
.sdm-act.go { color: var(--ok); border-color: #2f6d47; }

.sdm-foot { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--border); padding-top: 14px; margin-top: 6px; gap: 10px; }
.sdm-clients { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.client-chip { font-size: 12px; background: rgba(255,255,255,.06); border-radius: 20px; padding: 3px 11px; color: var(--text); text-decoration: none; }
.client-chip:hover { background: rgba(255,255,255,.12); }
.sdm-foot-actions { display: flex; gap: 8px; flex-shrink: 0; }

@media (max-width: 720px) {
    .sdm-tiles { grid-template-columns: repeat(2, 1fr); }
    .sdm-checks { grid-template-columns: 1fr; }
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.chart { width: 100%; height: 260px; }
.grid-line { stroke: rgba(255,255,255,.10); stroke-width: 1; }
.axis { fill: var(--muted); font-size: 11px; font-family: Consolas, monospace; }
.legend { display: flex; gap: 14px; margin-bottom: 6px; }
.legend-item { font-size: 12px; color: var(--muted); }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.field-label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px; }
.wide-input { width: 100%; }
.inline { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.kpi.clickable { cursor: pointer; }
.kpi.on { border-color: var(--accent); }

/* Red dot on the Alerts nav item while pushes are unseen. */
.nav-dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%;
    background: var(--crit); margin-left: 6px; vertical-align: middle;
}

.kpis-3 { grid-template-columns: repeat(3, 1fr); margin-bottom: 14px; }
@media (max-width: 900px) { .kpis-3 { grid-template-columns: repeat(3, 1fr); } }

/* ---- responsive list layouts: table on desktop, cards on phones ---- */
.m-only { display: none; }
.mcard {
    display: block; background: var(--surface); border: 1px solid var(--border);
    border-radius: 9px; padding: 10px 12px; margin-bottom: 8px;
    color: var(--text); text-decoration: none;
}
a.mcard:hover { text-decoration: none; border-color: #3d5468; }
.mcard-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.mcard-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mcard-line { font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.mcard.sel { border-color: var(--accent); background: #1b2b3a; }
.crit-text { color: var(--crit); }
@media (max-width: 720px) {
    .d-only { display: none; }
    .m-only { display: block; }
    .rtype-grid.m-only { display: grid; }
}

/* ---- sidebar icons + collapse ---- */
.brand-row { display: flex; align-items: center; justify-content: space-between; padding: 0 12px 14px 16px; }
.brand-row .brand { padding: 0; }
.collapse-btn {
    background: none; border: 1px solid var(--border); border-radius: 6px;
    color: var(--muted); width: 26px; height: 26px; padding: 0; line-height: 1;
    cursor: pointer; flex-shrink: 0;
}
.collapse-btn:hover { color: var(--text); border-color: #3d5468; }

.nav-item { display: flex; align-items: center; gap: 10px; }
.nav-ico { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; position: relative; }
.nav-ico svg { width: 19px; height: 19px; display: block; }
.ico-dot { position: absolute; top: -2px; right: -3px; margin-left: 0; }

/* brand mark */
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark { display: flex; flex-shrink: 0; }
.logo { width: 26px; height: 26px; display: block; }

.sidebar { transition: width .15s ease; }
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .brand-row { padding: 0 0 14px; flex-direction: column; gap: 8px; align-items: center; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 11px 0; }
.sidebar.collapsed .sidebar-foot { padding: 12px 0; text-align: center; }
.foot-ico { font-size: 16px; }
.foot-m { display: none; } /* phone sign-out icon — shown only by the mobile bar rules */

/* Collapsed sidebar stays icon-width on phones too. */
/* On phones the top bar IS the collapsed presentation — desktop collapse state
   must not override it. */
@media (max-width: 900px) {
    .sidebar.collapsed { width: 100%; }
    .sidebar.collapsed .brand-row { padding: 0 6px 0 4px; flex-direction: row; gap: 0; }
    .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 9px 10px; }
    .sidebar.collapsed .sidebar-foot { padding: 0 6px; text-align: left; }
}

/* ---- overview server tiles with resource meters ---- */
.stile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.stile-click { cursor: pointer; display: flex; }
.stile-click > .stile { flex: 1; transition: border-color .12s ease, background .12s ease; }
.stile-click:hover > .stile { border-color: #3d5468; background: rgba(255,255,255,.03); }
.stile-click:focus-visible { outline: none; }
.stile-click:focus-visible > .stile { border-color: var(--accent); }
.stile {
    background: var(--surface); border: 1px solid var(--border);
    border-left: 3px solid var(--ok); border-radius: 0 8px 8px 0; padding: 8px 10px;
    overflow: hidden; min-width: 0;
}
.stile.stale { opacity: .7; }
.stile-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.stile-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stile-meters {
    display: grid; grid-template-columns: 28px 1fr 48px; gap: 4px 6px;
    align-items: center; font-size: 10.5px;
}
.stile-meters .meter, .stile-meters .meter-fill { height: 4px; }
.m-label { color: var(--muted); font-family: Consolas, monospace; overflow: hidden; white-space: nowrap; }
.m-value { text-align: right; font-family: Consolas, monospace; color: var(--muted); white-space: nowrap; }
.m-value.crit { color: var(--crit); }
.m-value.warn { color: var(--warn); }
.stile .spark { height: 16px; margin-top: 4px; }
.stile-foot { font-size: 9.5px; color: var(--muted); margin-top: 1px; }
.stile-foot.crit { color: var(--crit); }
.stile-foot.warn { color: var(--warn); }
.stile-foot-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 1px; }
.stile-foot-row .stile-foot { margin-top: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-badge {
    flex-shrink: 0; font-family: Consolas, monospace; font-size: 9.5px; font-weight: 600;
    border-radius: 20px; padding: 1px 7px; white-space: nowrap;
}
.queue-badge.ok { background: var(--ok); color: #0f2419; }
.queue-badge.warn { background: var(--warn); color: #1c1408; }
.queue-badge.crit { background: var(--crit); color: #fff; }

/* ---- alert report ---- */
.range-btn { background: none; border: 1px solid var(--border); color: var(--muted); border-radius: 6px; padding: 4px 12px; cursor: pointer; text-decoration: none; }
.range-btn:hover { color: var(--text); text-decoration: none; }
.range-btn.on { background: var(--surface-2); color: var(--text); border-color: #3d5468; }
.rep-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 16px; }
@media (max-width: 900px) { .rep-kpis { grid-template-columns: repeat(2, 1fr); } }
.rep-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; display: flex; flex-direction: column; }
.rep-kpi .l { color: var(--muted); font-size: 10px; letter-spacing: .4px; }
.rep-kpi .n { font-size: 20px; font-weight: 600; }
.rep-kpi .s { color: var(--muted); font-size: 10.5px; font-family: Consolas, monospace; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.share-bar { height: 5px; background: rgba(255,255,255,.06); border-radius: 3px; }
.share-fill { height: 5px; border-radius: 3px; background: var(--warn); }
.share-fill.crit { background: var(--crit); }

/* Alert-type cards: auto-fit — 3-4 across on desktop, 1 across on phones. */
.rtype-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.rtype-card { background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; }
.rtype-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.rtype-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.rtype-count { color: var(--muted); flex-shrink: 0; }
.rtype-stats { display: flex; gap: 16px; margin-top: 9px; font-size: 12.5px; }
.rtype-stats em { display: block; font-style: normal; color: var(--muted); font-size: 9.5px; letter-spacing: .3px; }
.rtype-foot { display: flex; justify-content: space-between; font-size: 11px; margin-top: 8px; padding-top: 7px; border-top: 1px solid rgba(255,255,255,.05); }
.rep-dist { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.rep-dist > .muted { flex-shrink: 0; }
.dist-strip { flex: 1; display: flex; height: 16px; border-radius: 4px; overflow: hidden; font-size: 9px; font-weight: 600; text-align: center; line-height: 16px; color: #0f1720; }
.dist-seg { overflow: hidden; white-space: nowrap; }
.dist-seg.b-fast { background: #2f8f57; }
.dist-seg.b-ok { background: #57d08a; }
.dist-seg.b-slow { background: #c77e1a; }
.dist-seg.b-slower { background: #e0a53a; }
.dist-seg.b-worst { background: #d64545; color: #fff; }

/* ---- phone layout: the detail modal takes the whole screen ---- */
@media (max-width: 720px) {
    .modal-backdrop { padding: 0; }
    .modal, .modal.wide, .modal.xwide {
        width: 100%; height: 100vh; max-height: 100vh; border-radius: 0;
    }
    .sdm-chart-head, .sdm-toggles, .sdm-svc-row { flex-wrap: wrap; gap: 6px; }
    .sdm-foot { flex-direction: column; align-items: stretch; gap: 10px; }
    .sdm-foot-actions { justify-content: flex-end; }
    .rep-dist { flex-direction: column; align-items: stretch; gap: 6px; }
}

/* compact overview tile (A2): CPU/RAM/NET chips + one line per drive */
.stile-name { flex: 1 1 auto; min-width: 0; }
.stile-head .role-chip, .stile-head .queue-badge { flex-shrink: 0; }
.stile-head .queue-badge { margin-left: auto; }

.stile-chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; font-family: Consolas, monospace; margin: 2px 0 8px; }
.chip-l { display: block; color: var(--muted); font-size: 9px; }
.chip-v { display: block; font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; }
.chip-v.warn { color: var(--warn); }
.chip-v.crit { color: var(--crit); }
.chip-u { font-size: 9px; }
.chip-bar { height: 3px; background: var(--border); border-radius: 2px; margin-top: 3px; }
.chip-fill { height: 3px; border-radius: 2px; background: var(--ok); }
.chip-fill.warn { background: var(--warn); }
.chip-fill.crit { background: var(--crit); }

.stile-disk { display: flex; align-items: center; gap: 7px; font-family: Consolas, monospace; font-size: 10.5px; color: #c9d4de; margin-bottom: 3px; min-width: 0; }
.d-label { color: var(--muted); width: 16px; flex-shrink: 0; }
.d-bar { flex: 1 1 0; min-width: 14px; height: 4px; background: var(--border); border-radius: 2px; }
.d-fill { display: block; height: 4px; border-radius: 2px; background: var(--ok); }
.d-fill.warn { background: var(--warn); }
.d-fill.crit { background: var(--crit); }
.d-free { white-space: nowrap; text-align: right; flex-shrink: 0; }
.d-free.warn { color: var(--warn); }
.d-free.crit { color: var(--crit); }
.d-io { white-space: nowrap; color: #6b7480; flex-shrink: 0; }
.stile-io-unit { color: #6b7480; font-size: 9px; font-family: Consolas, monospace; }
.stile-stale { text-align: center; padding: 18px 0 14px; font-size: 11px; color: var(--muted); }
.stale-ico { font-size: 17px; margin-bottom: 4px; }
.stale-last { font-size: 10px; margin-top: 3px; font-family: Consolas, monospace; }

/* ---- top-query copy dialog ---- */
.query-stats { margin-bottom: 8px; }
.query-text {
    width: 100%; min-height: 260px; resize: vertical;
    font-family: Consolas, "Cascadia Mono", monospace; font-size: 12px; line-height: 1.5;
    background: var(--bg); color: var(--text); border: 1px solid var(--border);
    border-radius: 6px; padding: 10px; white-space: pre-wrap;
}

/* ---- agent config editor ---- */
.cfg-meta { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.cfg-grid label, .cfg-wide { font-size: 12px; color: var(--muted); display: block; }
.cfg-grid input, .cfg-grid select, .cfg-wide textarea { width: 100%; margin-top: 3px; }
.cfg-wide { margin-bottom: 12px; }
.cfg-wide textarea { font-family: Consolas, monospace; font-size: 12px; }
.cfg-inline { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.cfg-narrow { width: 170px; }
.cfg-diff { line-height: 1.8; margin-bottom: 8px; max-height: 260px; overflow-y: auto; }
.diff-old { color: var(--crit); text-decoration: line-through; }
.diff-new { color: var(--ok); }
.head-actions { display: flex; align-items: center; gap: 10px; }

/* ---- dark scrollbars everywhere ---- */
* { scrollbar-color: #3d5468 var(--surface); scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: #3d5468; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #4d6a85; }
::-webkit-scrollbar-corner { background: var(--surface); }

/* Per-drive read/write activity, indented under its meter row. */
.disk-io { font-size: 10.5px; font-family: Consolas, monospace; color: var(--muted); margin: -2px 0 5px 22px; }

/* Combined disk activity on overview tiles — one line, all drives summed. */
.stile-io { font-size: 10px; font-family: Consolas, monospace; color: var(--muted); margin-top: 3px; }

/* Kept LAST: .rtype-grid's display:grid outranks .m-only's hide by file order,
   so the phone-only grid needs this compound override at the end of the sheet. */
.rtype-grid.m-only { display: none; }
@media (max-width: 720px) {
    .rtype-grid.m-only { display: grid; }
}

/* Kept LAST: mobile top-bar geometry. The desktop .brand-row/.sidebar-foot base
   rules sit later in the sheet than the main mobile block and reasserted their
   paddings (the logo rode 14px high). Collapsed-state selectors included so a
   desktop-collapsed session presents identically on a phone. */
@media (max-width: 900px) {
    .brand-row, .sidebar.collapsed .brand-row {
        padding: 0; margin: 0; width: 50px; flex-shrink: 0; flex-direction: row;
        justify-content: center; gap: 0;
    }
    .sidebar-foot, .sidebar.collapsed .sidebar-foot {
        margin: 0; padding: 0; width: 50px; flex-shrink: 0; border-top: none;
        display: flex; align-items: center; justify-content: center; text-align: center;
        border-left: 1px solid var(--border);
    }
}

/* Kept LAST: agent-config form on phones — fixed-width inline inputs crushed
   the URL fields. Rows wrap: name on its own line, URL + remove beside it. */
@media (max-width: 720px) {
    .cfg-meta { flex-wrap: wrap; gap: 8px; }
    .cfg-inline { flex-wrap: wrap; }
    .cfg-inline .cfg-narrow { flex: 1 1 100%; width: 100%; }
    .cfg-inline input { min-width: 0; }
    .cfg-narrow { width: 100%; margin-top: 4px; }
    .cfg-grid { grid-template-columns: 1fr 1fr; }
}

.mcard-actions { margin-top: 8px; display: flex; justify-content: flex-end; }
