/* ===== Design tokens ===================================================== */
:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8fafc; --border: #e4e8ef; --border-strong: #cfd6e2;
  --text: #0f172a; --text-2: #334155; --muted: #64748b;
  --brand: #0f2a4a; --brand-2: #16365e; --accent: #2563eb; --accent-soft: #e8efff; --violet: #7c3aed;
  --ok: #15803d; --ok-soft: #e7f6ec; --warn: #b45309; --warn-soft: #fdf3e2; --bad: #c81e1e; --bad-soft: #fdecec;
  --off: #64748b; --off-soft: #eef1f5;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .05);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
  --radius: 12px; --sidebar: 248px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #0f1729; --border: #1f2a40; --border-strong: #2c3a56;
  --text: #e8edf6; --text-2: #c3cddd; --muted: #8b98ae;
  --brand: #0a1426; --brand-2: #13213b; --accent: #5b8cff; --accent-soft: #18264a; --violet: #a78bfa;
  --ok: #34d399; --ok-soft: #0f2e25; --warn: #fbbf24; --warn-soft: #33270c; --bad: #f87171; --bad-soft: #3a1518;
  --off: #94a3b8; --off-soft: #1c2638;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #0f1729; --border: #1f2a40; --border-strong: #2c3a56;
    --text: #e8edf6; --text-2: #c3cddd; --muted: #8b98ae;
    --brand: #0a1426; --brand-2: #13213b; --accent: #5b8cff; --accent-soft: #18264a; --violet: #a78bfa;
    --ok: #34d399; --ok-soft: #0f2e25; --warn: #fbbf24; --warn-soft: #33270c; --bad: #f87171; --bad-soft: #3a1518;
    --off: #94a3b8; --off-soft: #1c2638;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

/* ===== Base ============================================================== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h2.section { font-size: 15px; font-weight: 650; margin: 26px 0 12px; display: flex; align-items: center; gap: 8px; }
h2.section .count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--off-soft); padding: 1px 8px; border-radius: 99px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
svg.i { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ===== Shell ============================================================= */
.shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); background: var(--brand); color: #cdd8ea; display: flex; flex-direction: column; z-index: 40; transition: transform .2s; }
.brand { display: flex; gap: 12px; align-items: center; padding: 20px 18px 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.logo { width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, #3b82f6, #1d4ed8); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 16px; flex: none; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: #8ea3c4; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; }
.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #6f86aa; padding: 16px 10px 6px; }
.nav button { display: flex; align-items: center; gap: 11px; width: 100%; border: 0; background: none; color: #c3cfe3; font: inherit; font-size: 13.5px; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; }
.nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav button.active { background: rgba(59,130,246,.18); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #3b82f6; }
.nav .badge { margin-left: auto; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 7px; line-height: 18px; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.07); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #23446f; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.user-card .who { flex: 1; min-width: 0; }
.user-card .who b { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card .who span { font-size: 11.5px; color: #8ea3c4; text-transform: capitalize; }
.icon-btn { border: 0; background: none; color: inherit; cursor: pointer; padding: 7px; border-radius: 8px; display: grid; place-items: center; }
.icon-btn:hover { background: rgba(127,127,127,.14); }

.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 12px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar .title { flex: 1; min-width: 0; }
.topbar h1 { font-size: 19px; font-weight: 700; }
.topbar .crumb { font-size: 12px; color: var(--muted); }
.topbar .tools { display: flex; align-items: center; gap: 10px; }
.menu-btn { display: none; color: var(--text); }
.content { padding: 22px 28px 48px; max-width: 1440px; width: 100%; }
.page { display: none; animation: fade .18s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.updated { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

/* ===== Controls ========================================================== */
.btn { display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); background: var(--bad-soft); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg.i { width: 16px; height: 16px; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; padding: 0 3px; font-weight: 500; }
.link.danger { color: var(--bad); }
.link:hover { text-decoration: underline; }
input, select, textarea { font: inherit; font-size: 13.5px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; outline: none; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; min-height: 84px; resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }
.select-site { min-width: 220px; font-weight: 600; }
.seg { display: inline-flex; background: var(--off-soft); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; font: inherit; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 5px 12px; border-radius: 7px; cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.field input, .field select, .field textarea { font-weight: 400; }
.field .hint { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }

/* ===== Cards & KPIs ===================================================== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14px; font-weight: 650; }
.grid { display: grid; gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; }
.kpi .ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.kpi .ic.ok { background: var(--ok-soft); color: var(--ok); } .kpi .ic.warn { background: var(--warn-soft); color: var(--warn); }
.kpi .ic.bad { background: var(--bad-soft); color: var(--bad); } .kpi .ic.violet { background: color-mix(in srgb, var(--violet) 14%, transparent); color: var(--violet); }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .value { font-size: 23px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 2px; }
.kpi .value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi .value.bad { color: var(--bad); } .kpi .value.ok { color: var(--ok); } .kpi .value.warn { color: var(--warn); }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.split { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.chart { position: relative; height: 300px; padding: 14px 16px 10px; }
.chart.tall { height: 340px; } .chart.short { height: 240px; }

/* ===== Status ============================================================ */
.hero { display: flex; align-items: center; gap: 16px; padding: 18px 22px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); margin-bottom: 16px; }
.hero .state-ic { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.hero h2 { font-size: 17px; font-weight: 700; }
.hero p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.hero .right { margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); }
.hero.ok .state-ic { background: var(--ok-soft); color: var(--ok); }
.hero.degraded .state-ic { background: var(--warn-soft); color: var(--warn); }
.hero.down .state-ic { background: var(--bad-soft); color: var(--bad); }
.hero.offline .state-ic { background: var(--off-soft); color: var(--off); }
.hero.down { border-color: color-mix(in srgb, var(--bad) 40%, var(--border)); }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 650; padding: 2px 9px; border-radius: 99px; white-space: nowrap; text-transform: capitalize; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.nodot::before { display: none; }
.pill.ok, .pill.up, .pill.healthy, .pill.online { background: var(--ok-soft); color: var(--ok); }
.pill.warning, .pill.degraded, .pill.slow { background: var(--warn-soft); color: var(--warn); }
.pill.critical, .pill.down, .pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.offline, .pill.unknown, .pill.paused, .pill.off, .pill.viewer { background: var(--off-soft); color: var(--off); }
.pill.admin { background: color-mix(in srgb, var(--violet) 15%, transparent); color: var(--violet); }
.pill.operator { background: var(--accent-soft); color: var(--accent); }
.pill.info { background: var(--accent-soft); color: var(--accent); }

/* ===== Site cards ======================================================== */
.sites { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.site { padding: 16px 18px; cursor: pointer; transition: transform .12s, box-shadow .12s, border-color .12s; position: relative; overflow: hidden; }
.site::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--ok); }
.site.degraded::before { background: var(--warn); } .site.down::before { background: var(--bad); } .site.offline::before { background: var(--off); }
.site:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.site-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.site h3 { font-size: 15px; font-weight: 650; }
.site .loc { font-size: 12px; color: var(--muted); }
.site .metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.site .metric b { display: block; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.site .metric span { font-size: 11px; color: var(--muted); }
.site .foot { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }

/* ===== Tables ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; color: var(--text-2); }
td.wrap { white-space: normal; min-width: 240px; }
td.strong, td b { color: var(--text); font-weight: 600; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.detail td { background: var(--surface-2); white-space: normal; }
td.low, span.low { color: var(--bad); font-weight: 650; }
td.empty, .empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.empty-state { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty-state svg.i { width: 40px; height: 40px; stroke-width: 1.4; color: var(--border-strong); margin-bottom: 8px; }
.empty-state h3 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.hops { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; border-collapse: collapse; margin-top: 8px; width: auto; }
.hops td { padding: 3px 18px 3px 0; border: 0; background: none !important; }
.hops .hop-n { color: var(--muted); }

/* ===== Incident list ===================================================== */
.inc-list { display: flex; flex-direction: column; }
.inc-item { display: flex; gap: 14px; align-items: flex-start; padding: 13px 20px; border-bottom: 1px solid var(--border); }
.inc-item:last-child { border-bottom: 0; }
.inc-item .sev { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--warn-soft); color: var(--warn); }
.inc-item .sev.critical { background: var(--bad-soft); color: var(--bad); }
.inc-item .sev.resolved { background: var(--ok-soft); color: var(--ok); }
.inc-item .body { flex: 1; min-width: 0; }
.inc-item .body b { color: var(--text); font-weight: 650; }
.inc-item .body p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.inc-item .dur { text-align: right; font-size: 12px; color: var(--muted); white-space: nowrap; }
.inc-item .dur b { display: block; font-size: 14px; color: var(--text); font-variant-numeric: tabular-nums; }

/* ===== Report builder ==================================================== */
.report-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.rtype { text-align: left; border: 1.5px solid var(--border); background: var(--surface); border-radius: 12px; padding: 16px; cursor: pointer; font: inherit; color: var(--text); display: flex; gap: 12px; transition: border-color .12s, background .12s; }
.rtype:hover { border-color: var(--border-strong); }
.rtype.active { border-color: var(--accent); background: var(--accent-soft); }
.rtype .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--accent); flex: none; border: 1px solid var(--border); }
.rtype b { display: block; font-size: 14px; }
.rtype span { font-size: 12px; color: var(--muted); }
.export-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.export-btns .btn { padding: 10px 18px; }

/* ===== Modal & toast ===================================================== */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 18, 35, .55); backdrop-filter: blur(2px); z-index: 60; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { width: min(720px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal.narrow { width: min(460px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
.modal-foot .msg { margin-right: auto; color: var(--bad); font-size: 12.5px; align-self: center; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--surface); padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 9px; animation: fade .2s; max-width: 380px; }
.toast.err { background: var(--bad); color: #fff; }

/* ===== Login ============================================================ */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(1200px 600px at 10% 10%, #1e3a8a 0%, transparent 60%), linear-gradient(160deg, #0f2a4a, #0a1a30); color: #dbe5f5; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art .brand { padding: 0; border: 0; }
.login-art h2 { font-size: 34px; line-height: 1.2; color: #fff; font-weight: 750; max-width: 460px; letter-spacing: -.02em; }
.login-art p { color: #9fb3d4; max-width: 440px; font-size: 15px; }
.login-art ul { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 12px; }
.login-art li { display: flex; gap: 10px; align-items: center; color: #c9d6ec; }
.login-art li svg.i { color: #60a5fa; }
.login-art .grid-bg { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 40px 40px; mask-image: linear-gradient(to bottom, #000, transparent); pointer-events: none; }
.login-form { display: grid; place-items: center; padding: 32px 20px; background: var(--surface); }
.login-form form { width: min(380px, 100%); display: grid; gap: 16px; }
.login-form h1 { font-size: 24px; font-weight: 750; }
.login-form .err { color: var(--bad); font-size: 13px; min-height: 18px; }
.login-form .btn { justify-content: center; padding: 11px; font-size: 14px; }

/* ===== Print ============================================================ */
@media print {
  .sidebar, .topbar, .toolbar, .no-print { display: none !important; }
  .main { margin: 0; } .content { padding: 0; }
  body { background: #fff; }
}

/* ===== Responsive ======================================================= */
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: grid; }
  .topbar { padding: 10px 16px; flex-wrap: wrap; }
  .content { padding: 16px 16px 40px; }
  .select-site { min-width: 0; max-width: 190px; }
  .login { grid-template-columns: 1fr; }
  .login-art { display: none; }
}
@media (max-width: 520px) { .hero .right { display: none; } .hero { padding: 14px 16px; } .kpis { grid-template-columns: 1fr 1fr; } .kpi { padding: 12px; } .kpi .ic { display: none; } .kpi .value { font-size: 19px; } }

/* ===== Layout guards (nothing may overlap or push past its box) ========= */
.main, .content, .card, .kpi, .split > *, .sites > *, .grid > *, .hero > div, .kpi > div:last-child, .site-top > div { min-width: 0; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi .value, .kpi .sub, .kpi .label, .hero p, .inc-item .body p, td.wrap { overflow-wrap: anywhere; }
.site h3, .site .loc, .user-card .who b, .topbar h1, .topbar .crumb, .brand-name, .brand-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site .metric { min-width: 0; } .site .metric b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site .foot span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .tools { flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.brand > div:last-child { min-width: 0; }
.chart canvas { max-width: 100%; }
@media (max-height: 700px) and (min-width: 901px) {
  .brand { padding: 14px 18px 12px; } .nav-label { padding: 10px 10px 4px; } .nav button { padding: 6px 10px; } .user-card { padding: 10px 16px; }
}
@media (max-width: 1280px) and (min-width: 901px) { .content { padding: 20px 20px 40px; } .topbar { padding: 12px 20px; } }

/* ===== Loaders ========================================================== */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 100; pointer-events: none; opacity: 0; transition: opacity .2s; }
.progress.on { opacity: 1; }
.progress::before { content: ""; position: absolute; inset: 0; width: 40%; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: progress 1.1s ease-in-out infinite; }
@keyframes progress { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.skel { position: relative; overflow: hidden; background: var(--off-soft); border-radius: 8px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent); animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skel-line { height: 12px; margin: 8px 0; }
.skel-kpi { height: 96px; border-radius: var(--radius); }
.skel-card { height: 300px; border-radius: var(--radius); }
.skel-row { height: 44px; margin: 0; border-radius: 0; border-bottom: 1px solid var(--border); }
.spinner { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; flex: none; }
.spinner.lg { width: 34px; height: 34px; border-width: 3px; color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.loading { pointer-events: none; opacity: .85; }
.btn.loading svg.i { display: none; }
.chart-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; gap: 8px; }
.splash { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: grid; place-items: center; transition: opacity .3s; }
.splash.hide { opacity: 0; pointer-events: none; }
.splash .box { display: grid; justify-items: center; gap: 16px; color: var(--muted); font-size: 13px; }
.splash .logo { width: 52px; height: 52px; font-size: 22px; border-radius: 14px; }
.more-row td { text-align: center; padding: 14px; color: var(--muted); }

/* Buttons and code never spill out of narrow cards */
.btn { max-width: 100%; }
.rtype .btn, .card-pad .btn, .export-btns .btn { white-space: normal; text-align: left; line-height: 1.3; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .92em; background: var(--off-soft); padding: 1px 5px; border-radius: 4px; overflow-wrap: anywhere; word-break: break-word; }
.rtype > div { min-width: 0; }
.report-types.wide { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.hops { display: block; max-width: 100%; overflow-x: auto; }
