/* momomonitor — 3MO design tokens and components */
:root {
  --blue: #0077C8;
  --blue-600: #00609f;
  --blue-50: #e6f1fa;
  --navy: #112337;
  --navy-700: #1a3149;
  --navy-600: #24405e;
  --green: #008060;
  --green-50: #e3f3ee;
  --amber: #ffc107;
  --amber-text: #8a6100;
  --amber-50: #fff6db;
  --red: #dc3545;
  --red-50: #fbe9eb;
  --down: #7a1c27;
  --purple: #6f42c1;
  --grey-50: #f8f9fa;
  --grey-100: #f1f3f5;
  --grey-200: #e9ecef;
  --grey-300: #dee2e6;
  --grey-400: #ced4da;
  --grey-500: #adb5bd;
  --grey-600: #6c757d;
  --grey-700: #495057;
  --grey-900: #212529;

  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: var(--grey-50);
  --border: #e1e5ea;
  --border-strong: var(--grey-300);
  --text: var(--grey-900);
  --text-2: var(--grey-700);
  --muted: var(--grey-600);
  --link: var(--blue);
  --code-bg: #f4f6f8;
  --shadow: 0 1px 2px rgba(17, 35, 55, .05), 0 1px 1px rgba(17, 35, 55, .03);
  --shadow-lg: 0 12px 40px rgba(17, 35, 55, .22);

  --chart-text: #6c757d;
  --chart-grid: #edf0f3;
  --chart-cross: rgba(17, 35, 55, .45);

  --font: "Gotham A", "Gotham B", Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 8px;
  --sidebar-w: 224px;
  --topbar-h: 54px;
}

[data-theme="dark"] {
  --bg: #0c1622;
  --surface: #13202f;
  --surface-2: #182839;
  --border: #22364b;
  --border-strong: #2c445d;
  --text: #e6ebf0;
  --text-2: #c2ccd6;
  --muted: #8b9aab;
  --link: #4ea8e6;
  --code-bg: #0f1b28;
  --grey-50: #182839;
  --grey-100: #1b2d40;
  --grey-200: #22364b;
  --grey-300: #2c445d;
  --blue-50: #10314d;
  --green-50: #0d3027;
  --amber-50: #3a3010;
  --amber-text: #ffd45e;
  --red-50: #3d1a20;
  --chart-text: #8b9aab;
  --chart-grid: #1f3145;
  --chart-cross: rgba(230, 235, 240, .45);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; line-height: 1.25; }
code, pre, .mono { font-family: var(--font-mono); font-size: 12.5px; }
code { background: var(--code-bg); padding: 1px 5px; border-radius: 4px; word-break: break-word; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ layout */
#app { display: flex; min-height: 100vh; }
#sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: var(--navy); color: #c9d4df; display: flex; flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, .04);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px 18px; color: #fff; text-decoration: none !important; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.wordmark { font-size: 18px; letter-spacing: -.2px; font-weight: 300; color: #fff; }
.wordmark b { font-weight: 700; }
.wordmark-dark { color: var(--navy); }
[data-theme="dark"] .wordmark-dark { color: #fff; }
.by { font-size: 10.5px; text-transform: uppercase; letter-spacing: .9px; color: #8ea3b8; margin-top: 3px; }
.nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 6px;
  color: #c9d4df; text-decoration: none !important; font-weight: 500; position: relative;
}
.nav-item svg { flex: none; opacity: .85; }
.nav-item:hover { background: var(--navy-700); color: #fff; }
.nav-item.active { background: var(--navy-600); color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--blue); }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.nav-badge-critical { background: var(--red); color: #fff; }
.nav-badge-warning { background: var(--amber); color: #3b2c00; }
.sidebar-foot { padding: 12px 18px 16px; font-size: 12px; color: #8ea3b8; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid rgba(255, 255, 255, .06); }
.mode-demo { background: rgba(255, 193, 7, .16); color: #ffd45e; border: 1px solid rgba(255, 193, 7, .35); border-radius: 10px; padding: 1px 8px; font-size: 11px; font-weight: 600; }
#sidebar-scrim { display: none; }

#main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
#topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
#topbar .menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 15px; white-space: nowrap; overflow: hidden; }
.crumbs a { color: var(--muted); }
.crumb-cur { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { color: var(--grey-400); }
.topbar-spacer { flex: 1; }
.range-picker { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; background: var(--surface); }
.range-picker button { border: 0; background: none; padding: 5px 10px; font-size: 12.5px; cursor: pointer; color: var(--text-2); border-right: 1px solid var(--border); }
.range-picker button:last-child { border-right: 0; }
.range-picker button:hover { background: var(--grey-100); }
.range-picker button.active { background: var(--blue); color: #fff; font-weight: 600; }
.refresh { display: flex; align-items: center; gap: 6px; }
.updated { font-size: 12px; color: var(--muted); min-width: 108px; }
.auto-toggle { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--text-2); width: 32px; height: 32px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { background: var(--grey-100); color: var(--text); }
.icon-btn.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.user-menu { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 18px; padding: 4px 12px 4px 8px; cursor: pointer; font-size: 13px; }
.user-btn:hover { border-color: var(--border-strong); }
.user-pop { position: absolute; right: 0; top: 40px; min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.user-pop-head { padding: 8px 10px; display: flex; flex-direction: column; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-pop-row { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; border-radius: 5px; color: var(--text); font-size: 13px; cursor: pointer; }
a.user-pop-row:hover, button.user-pop-row:hover { background: var(--grey-100); text-decoration: none; }
div.user-pop-row { cursor: default; font-size: 12px; }

#page { flex: 1; outline: none; }
.page { padding: 20px 24px 48px; max-width: 1680px; display: flex; flex-direction: column; gap: 16px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; letter-spacing: -.2px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); font-weight: 600; margin: 8px 0 -4px; display: flex; align-items: center; gap: 8px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.grid-charts { grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr)); }
.grid-kpi { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 12px; }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------ cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 16px 0; }
.card-head h3 { font-size: 14px; font-weight: 600; }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.card-body { padding: 12px 16px 14px; }
.card-body.flush { padding: 8px 0 0; }
.card-body.flush .table th:first-child, .card-body.flush .table td:first-child { padding-left: 16px; }
.card-body.flush .table th:last-child, .card-body.flush .table td:last-child { padding-right: 16px; }
.chart-card .card-body { padding: 8px 12px 10px; }

/* status banner */
.banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius); border: 1px solid; }
.banner-icon { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; color: #fff; }
.banner-title { font-weight: 700; font-size: 16px; }
.banner-text { color: var(--text-2); }
.banner-ok { background: var(--green-50); border-color: rgba(0, 128, 96, .25); }
.banner-ok .banner-icon { background: var(--green); }
.banner-warning { background: var(--amber-50); border-color: rgba(255, 193, 7, .5); }
.banner-warning .banner-icon { background: var(--amber); color: #3b2c00; }
.banner-critical, .banner-down { background: var(--red-50); border-color: rgba(220, 53, 69, .3); }
.banner-critical .banner-icon, .banner-down .banner-icon { background: var(--red); }

/* pills & dots */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; white-space: nowrap; line-height: 18px; border: 1px solid transparent; }
.pill-ok, .pill-good, .pill-resolved, .pill-up { background: var(--green-50); color: var(--green); }
.pill-warning { background: var(--amber-50); color: var(--amber-text); border-color: rgba(255, 193, 7, .45); }
.pill-critical, .pill-firing, .pill-error { background: var(--red-50); color: var(--red); border-color: rgba(220, 53, 69, .25); }
.pill-down { background: var(--down); color: #fff; }
.pill-info, .pill-open { background: var(--blue-50); color: var(--blue); }
.pill-ignored, .pill-unknown, .pill-stale, .pill-silenced { background: var(--grey-200); color: var(--grey-700); }
[data-theme="dark"] .pill-ignored, [data-theme="dark"] .pill-unknown, [data-theme="dark"] .pill-stale, [data-theme="dark"] .pill-silenced { color: var(--text-2); }
.pill-new { background: var(--purple); color: #fff; }
.pill-acked { background: var(--blue-50); color: var(--blue); }
.tag { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 4px; font-size: 11.5px; background: var(--grey-100); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.tag b { font-weight: 600; margin-right: 3px; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--grey-400); flex: none; }
.dot-ok { background: var(--green); }
.dot-warning { background: var(--amber); }
.dot-critical { background: var(--red); box-shadow: 0 0 0 3px rgba(220, 53, 69, .18); }
.dot-down { background: var(--down); box-shadow: 0 0 0 3px rgba(122, 28, 39, .2); }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 13px; font-weight: 500; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none !important; line-height: 1.35; }
.btn:hover { background: var(--grey-100); }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-600); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #bb2d3b; }
.btn-ghost { border-color: transparent; background: none; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 9px; }
.btn-hero { padding: 8px 16px; font-size: 14px; font-weight: 600; }

/* KPI */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 14px; box-shadow: var(--shadow); position: relative; overflow: hidden; min-width: 0; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; }
.kpi-ok::before { background: var(--green); }
.kpi-warning::before { background: var(--amber); }
.kpi-critical::before { background: var(--red); }
.kpi-label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 22px; font-weight: 600; margin-top: 2px; letter-spacing: -.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-warning .kpi-value { color: var(--amber-text); }
.kpi-critical .kpi-value { color: var(--red); }

/* meter */
.meter { height: 5px; border-radius: 3px; background: var(--grey-200); overflow: hidden; }
.meter > div { height: 100%; border-radius: 3px; }
.meter-ok > div { background: var(--green); }
.meter-warning > div { background: var(--amber); }
.meter-critical > div { background: var(--red); }
.meter-info > div { background: var(--blue); }

/* ------------------------------------------------------------ server cards */
.srv { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-top: 3px solid var(--green); border-radius: var(--radius); background: var(--surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); color: inherit; text-decoration: none !important; transition: box-shadow .15s, transform .15s; position: relative; }
.srv:hover { box-shadow: 0 4px 14px rgba(17, 35, 55, .12); }
.srv-warning { border-top-color: var(--amber); }
.srv-critical { border-top-color: var(--red); }
.srv-down { border-top-color: var(--down); background: linear-gradient(var(--red-50), var(--surface) 60px); }
.srv-stale { opacity: .7; border-top-color: var(--grey-500); }
.srv-head { display: flex; align-items: center; gap: 8px; }
.srv-name { font-weight: 700; font-size: 15px; color: var(--text); }
.srv-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srv-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; }
.srv-metric .lbl { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 4px; }
.srv-metric .lbl b { color: var(--text); font-weight: 600; font-size: 12.5px; }
.srv-metric .meter { margin-top: 4px; }
.srv-php { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); padding-top: 8px; border-top: 1px dashed var(--border); }
.srv-php b { font-weight: 600; color: var(--text); }
.srv-del { position: absolute; top: 8px; right: 8px; }
.srv-down-msg { font-size: 13px; color: var(--red); font-weight: 600; }

/* ------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); user-select: none; }
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--text); }
.table th.sorted { color: var(--blue); }
.table th.sorted.desc::after { content: " ↓"; }
.table th.sorted.asc::after { content: " ↑"; }
.table td { padding: 8px 10px; border-bottom: 1px solid var(--grey-200); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--grey-50); }
.table tr.clickable { cursor: pointer; }
.table tr.selected td { background: var(--blue-50) !important; }
.table .num { text-align: right; white-space: nowrap; }
.table-empty { text-align: center; color: var(--muted); padding: 28px !important; }
.table td.tx-name { font-family: var(--font-mono); font-size: 12.5px; max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.title-cell { max-width: 0; width: 100%; min-width: 220px; }
.title-cell .t { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.title-cell .s { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-compact td { padding: 5px 10px; }
.share { display: flex; align-items: center; gap: 6px; justify-content: flex-end; }
.share-bar { width: 70px; height: 6px; background: var(--grey-200); border-radius: 3px; overflow: hidden; }
.share-bar > div { height: 100%; background: var(--blue); }
.md-table { font-size: 12.5px; margin: 8px 0; }
.md-table td, .md-table th { padding: 5px 9px; }

/* ------------------------------------------------------------ charts */
.chart { position: relative; }
.chart-canvas { position: relative; width: 100%; }
.chart-canvas canvas { position: absolute; left: 0; top: 0; display: block; }
.chart-overlay { cursor: crosshair; }
.chart-tip { position: absolute; z-index: 10; pointer-events: none; background: rgba(17, 35, 55, .96); color: #fff; border-radius: 6px; padding: 7px 10px; font-size: 12px; min-width: 150px; max-width: 360px; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); }
.tip-time { font-weight: 600; margin-bottom: 4px; color: #b9c8d8; font-size: 11.5px; }
.tip-row { display: flex; justify-content: space-between; gap: 14px; line-height: 1.6; }
.tip-row span { display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip-row i { width: 8px; height: 8px; border-radius: 2px; flex: none; display: inline-block; }
.tip-row b { font-weight: 600; white-space: nowrap; }
.tip-total { border-top: 1px solid rgba(255, 255, 255, .2); margin-top: 3px; padding-top: 3px; }
.tip-more { color: #b9c8d8; font-size: 11px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 2px 4px; margin-top: 6px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 2px 6px; border-radius: 4px; font-size: 12px; color: var(--text-2); cursor: pointer; max-width: 100%; }
.legend-item:hover { background: var(--grey-100); }
.legend-item i { width: 10px; height: 10px; border-radius: 2px; flex: none; display: inline-block; }
.legend-item b { font-weight: 600; color: var(--text); margin-left: 2px; }
.legend-item.off { opacity: .4; }
.legend-inline { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); margin-top: 8px; }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.legend-inline i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.spark { display: block; }
.srv .spark { width: 100%; }
.donut-center { font-size: 18px; font-weight: 700; fill: var(--text); }
.donut-sub { font-size: 10.5px; fill: var(--muted); }

.stackbar { display: flex; height: 26px; border-radius: 5px; overflow: hidden; background: var(--grey-200); }
.stackbar-seg { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; min-width: 2px; border-right: 1px solid rgba(255, 255, 255, .35); }
.stackbar-seg:last-child { border-right: 0; }
.stackbar-seg span { padding: 0 6px; overflow: hidden; text-overflow: ellipsis; }

.barlist { display: flex; flex-direction: column; gap: 6px; }
.barlist-row { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.barlist-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barlist-bar { height: 8px; background: var(--grey-200); border-radius: 4px; overflow: hidden; }
.barlist-bar > div { height: 100%; border-radius: 4px; }
.barlist-val { font-weight: 600; white-space: nowrap; min-width: 54px; text-align: right; }

/* ------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { padding: 9px 14px; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.tab-badge { display: inline-block; font-size: 11px; background: var(--grey-200); border-radius: 8px; padding: 0 6px; margin-left: 4px; color: var(--text-2); }
.tab-badge.warn { background: var(--amber); color: #3b2c00; }
.tab-badge.crit { background: var(--red); color: #fff; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 6px; overflow: hidden; }
.segmented button, .segmented a { border: 0; background: var(--surface); padding: 4px 10px; font-size: 12.5px; cursor: pointer; border-right: 1px solid var(--border); color: var(--text-2); text-decoration: none !important; }
.segmented > :last-child { border-right: 0; }
.segmented .active { background: var(--blue); color: #fff; }

/* ------------------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
input, select, textarea { font: inherit; font-size: 13px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; padding: 6px 9px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(0, 119, 200, .35); outline-offset: 0; border-color: var(--blue); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { min-width: 220px; }
.select-lg { font-size: 14px; font-weight: 600; padding: 6px 10px; }

/* ------------------------------------------------------------ alerts / empty / skeleton */
.alert { padding: 10px 14px; border-radius: 6px; border: 1px solid; font-size: 13px; }
.alert-critical { background: var(--red-50); border-color: rgba(220, 53, 69, .3); color: var(--text); }
.alert-warning { background: var(--amber-50); border-color: rgba(255, 193, 7, .5); }
.alert-info { background: var(--blue-50); border-color: rgba(0, 119, 200, .25); }
.alert-ok { background: var(--green-50); border-color: rgba(0, 128, 96, .25); }
.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty-icon { color: var(--grey-400); margin-bottom: 6px; }
.empty-title { font-weight: 600; color: var(--text-2); font-size: 14px; }
.empty-text { font-size: 13px; margin-top: 4px; max-width: 520px; margin-left: auto; margin-right: auto; }
.empty-action { margin-top: 12px; }
.empty-sm { padding: 18px 12px; }
.skeleton { border-radius: 6px; background: linear-gradient(90deg, var(--grey-200) 25%, var(--grey-100) 37%, var(--grey-200) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.page-loading { gap: 16px; }

/* ------------------------------------------------------------ code */
pre.code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; overflow-x: auto; margin: 6px 0; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
pre.code code { background: none; padding: 0; }
pre.code.lang-sql { border-left: 3px solid var(--blue); }
.code-area { width: 100%; font-family: var(--font-mono); font-size: 12px; }
.copyline { display: flex; flex-direction: column; gap: 4px; }
.copyline-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.copyline-box { display: flex; align-items: center; gap: 8px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 6px 6px 6px 10px; }
.copyline-box code { flex: 1; background: none; padding: 0; white-space: pre-wrap; word-break: break-all; font-size: 12.5px; line-height: 1.5; }
.stack-frames { list-style: none; margin: 0; padding: 0; font-family: var(--font-mono); font-size: 12px; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.stack-frames li { padding: 6px 10px; border-bottom: 1px solid var(--grey-200); word-break: break-all; }
.stack-frames li:last-child { border-bottom: 0; }
.stack-frames li:first-child { background: var(--red-50); font-weight: 600; }
.stack-frames .loc { color: var(--muted); }

/* markdown */
.md { font-size: 13.5px; line-height: 1.6; }
.md h3, .md h4, .md h5, .md h6 { margin: 18px 0 8px; }
.md h4 { font-size: 16px; }
.md h5 { font-size: 14px; }
.md p { margin: 8px 0; }
.md ul, .md ol { margin: 6px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md blockquote { margin: 8px 0; padding: 4px 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md > :first-child { margin-top: 0; }

/* definition list */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 20px; }
.fact .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.fact .v { font-size: 13.5px; margin-top: 1px; word-break: break-word; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

/* lists */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--grey-200); color: inherit; text-decoration: none !important; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--grey-50); }
.list-item .main { flex: 1; min-width: 0; }
.list-item .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.list-item .s { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .r { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }

/* diagnose */
.verdict { font-size: 15px; line-height: 1.5; padding: 14px 16px; border-radius: 8px; border: 1px solid; }
.suspect { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; display: grid; grid-template-columns: 56px 1fr; gap: 12px; background: var(--surface); }
.suspect-score { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-direction: column; font-weight: 700; font-size: 17px; border: 3px solid var(--grey-300); line-height: 1; }
.suspect-score small { font-size: 9px; font-weight: 600; color: var(--muted); text-transform: uppercase; margin-top: 2px; }
.suspect-score.high { border-color: var(--red); color: var(--red); }
.suspect-score.medium { border-color: var(--amber); color: var(--amber-text); }
.suspect-score.low { border-color: var(--grey-400); color: var(--grey-600); }
.suspect h4 { font-size: 14.5px; margin-bottom: 6px; }
.suspect ul { margin: 4px 0; padding-left: 18px; font-size: 13px; }
.suspect .next { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 8px; }

/* CWV */
.cwv { font-weight: 600; }
.cwv-good { color: var(--green); }
.cwv-ni { color: var(--amber-text); }
.cwv-poor { color: var(--red); }
.cwv-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; }
.cwv-card .name { font-size: 12px; color: var(--muted); }
.cwv-card .lbl { font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.cwv-card .val { font-size: 28px; font-weight: 600; letter-spacing: -.5px; }
.cwv-card .thr { font-size: 11.5px; color: var(--muted); }
.ratingbar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--grey-200); }
.rb-good { background: var(--green); }
.rb-ni { background: var(--amber); }
.rb-poor { background: var(--red); }
.apdex-good { color: var(--green); font-weight: 600; }
.apdex-ok { color: var(--text); }
.apdex-ni { color: var(--amber-text); font-weight: 600; }
.apdex-poor { color: var(--red); font-weight: 600; }
.err-hi { color: var(--red); font-weight: 600; }

/* flame graph */
.flame { position: relative; }
.flame-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 12px; color: var(--muted); min-height: 26px; }
.flame-crumb { font-family: var(--font-mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flame-wrap { position: relative; }
.flame-wrap canvas { display: block; }
.flame-name { font-family: var(--font-mono); color: #fff; word-break: break-all; white-space: normal; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(12, 22, 34, .55); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto; animation: fade .12s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 10px; box-shadow: var(--shadow-lg); width: min(560px, 100%); display: flex; flex-direction: column; max-height: 88vh; }
.modal-wide { width: min(1180px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-body p { margin: 0; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* toast */
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--navy); color: #fff; padding: 10px 14px; border-radius: 6px; font-size: 13px; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: all .2s; max-width: 380px; border-left: 4px solid var(--blue); }
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--green); }
.toast-error { border-left-color: var(--red); }

/* login */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, #1d3b5c 0, var(--navy) 55%) fixed; }
.login-card { width: min(380px, 100%); background: var(--surface); border-radius: 12px; padding: 28px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { font-size: 18px; }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.login-brand .by { color: var(--muted); }
.login-foot { font-size: 12px; margin: 4px 0 0; text-align: center; }

/* misc */
.hostfacts-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.kbd { font-family: var(--font-mono); font-size: 11px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; }
.inline-list { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; }
.hint-box { border-left: 3px solid var(--blue); background: var(--blue-50); padding: 10px 14px; border-radius: 0 6px 6px 0; font-size: 13.5px; }
.status-line { display: flex; align-items: center; gap: 8px; }
.trace-hot { font-family: var(--font-mono); font-size: 12.5px; word-break: break-word; line-height: 1.7; }
.trace-hot .arrow { color: var(--muted); margin: 0 4px; }
.trace-hot .leaf { color: var(--red); font-weight: 600; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1200px) {
  .split { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  #sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  body.nav-open #sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open #sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(12, 22, 34, .4); }
  #main { margin-left: 0; }
  #topbar .menu-btn { display: inline-flex; }
  .updated { display: none; }
  .page { padding: 16px 16px 40px; }
  .span-2 { grid-column: auto; }
}
@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  #topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; }
  .range-picker { order: 10; width: 100%; overflow-x: auto; }
  .auto-toggle span, .user-btn span { display: none; }
}
