:root {
  --bg: #F4F6F8; --card: #FFFFFF; --line: #E3E8EE; --text: #111827; --muted: #5B6676;
  --accent: #0F766E; --accent-dark: #0B5A54; --accent-soft: #E6F4F2; --gold: #2DD4BF;
  --ok: #059669; --ok-soft: #DCFCE7; --warn: #D97706; --bad: #DC2626; --bad-soft: #FEE2E2;
  --rail: #0B1F2A; --on-accent: #FFFFFF;
  --pill: #E3E8EE; --pill-text: #1F2937; --btn-line: #CBD5E1; --input: #FFFFFF; --input-line: #94A3B8;
  --bar: #CFE8E4; --meter: #E8EDF2; --alt: #0D9488;
  --ok-text: #14532D; --bad-text: #7F1D1D; --bad-strong: #B91C1C; --warn-bg: #FEF3C7; --warn-text: #78350F;
  --info-bg: #E0F2FE; --info-text: #0C4A6E; --chip-up: #047857;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E1620; --card: #16212C; --line: #243241; --text: #E5EDF3; --muted: #93A4B3;
  --accent: #14B8A6; --accent-dark: #2DD4BF; --accent-soft: #0F2F2D; --on-accent: #04201E;
  --ok-soft: #0F3B2C; --ok-text: #86EFAC; --bad-soft: #4A1D1D; --bad-text: #FCA5A5; --bad-strong: #FCA5A5;
  --warn-bg: #4A3511; --warn-text: #FCD34D; --info-bg: #0E2F45; --info-text: #7DD3FC; --chip-up: #86EFAC;
  --pill: #243241; --pill-text: #CBD5E1; --btn-line: #334456; --input: #0E1620; --input-line: #3B4D61;
  --bar: #164E4A; --meter: #243241; --alt: #5EEAD4; --rail: #060E14;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: 16px; font-weight: 650; }
.muted { color: var(--muted); margin: 4px 0 0; }
small { color: var(--muted); }

/* ---- layout: dark icon rail on the left */
.shell { display: flex; min-height: 100vh; }
.rail { width: 84px; flex: 0 0 84px; background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 16px 0; gap: 18px; position: sticky; top: 0; height: 100vh; }
.rail-logo { width: 44px; height: 44px; border-radius: 12px; background: #2DD4BF; display: flex; align-items: center; justify-content: center; }
.rail-logo svg { width: 24px; height: 24px; stroke: #0B1F2A; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.rail nav { display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 0 8px; overflow-y: auto; }
.rail nav a { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 2px; border-radius: 12px; color: #9FB1BB; text-decoration: none; font-size: 10.5px; font-weight: 600; }
.rail nav a svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail nav a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.rail nav a.on { background: rgba(45, 212, 191, 0.16); color: #5EEAD4; }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.linklike { background: none; border: 0; padding: 0; color: #9FB1BB; font: inherit; font-size: 11px; text-decoration: underline; cursor: pointer; }
.main { flex: 1 1 auto; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 20px; }

.head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--btn-line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { color: var(--text); border-color: var(--input-line); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-dark); color: var(--on-accent); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn.ok { border-color: var(--ok); color: var(--ok); }
.btn.danger { border-color: var(--bad); color: var(--bad-strong); }

/* ---- messages */
.banner { padding: 12px 16px; border-radius: 12px; background: var(--warn-bg); color: var(--warn-text); font-weight: 600; }
.msg { padding: 12px 16px; border-radius: 12px; font-weight: 500; background: var(--info-bg); color: var(--info-text); }
.msg.success { background: var(--ok-soft); color: var(--ok-text); }
.msg.error { background: var(--bad-soft); color: var(--bad-text); }
.msg.warning { background: var(--warn-bg); color: var(--warn-text); }

/* ---- cards and panels */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi, .card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi .label, .card .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.kpi .value, .card .value { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.kpi .sub, .card .sub { color: var(--muted); font-size: 12.5px; }
.cards { display: flex; flex-wrap: wrap; gap: 16px; }
.card { flex: 1 1 200px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.chip.up { background: var(--ok-soft); color: var(--chip-up); }
.chip.down { background: var(--bad-soft); color: var(--bad-text); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
.grid-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.cols > .panel { flex: 1 1 360px; }
@media (max-width: 1000px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #9FB1BB; flex: 0 0 9px; }
i.dot { font-style: normal; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.info { background: #60A5FA; }

/* ---- charts and meters */
.big-number { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.big-number small { font-size: 13px; font-weight: 500; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; font-size: 13px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.meter { height: 8px; background: var(--meter); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--accent); border-radius: 999px; }
.meter.hot .meter-fill { background: var(--bad); }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding-top: 6px; }
.barcol { flex: 1 1 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.bar { width: 100%; background: var(--bar); border-radius: 8px 8px 3px 3px; min-height: 4px; }
.bar.today { background: var(--accent); }
.barval { font-size: 10.5px; color: var(--muted); height: 14px; white-space: nowrap; }
.barlabel { font-size: 12px; color: var(--muted); }
.plan-row { display: flex; flex-direction: column; gap: 6px; }
.plan-top { display: flex; justify-content: space-between; }

/* ---- lists */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-row small { display: block; }
.list-end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.grow { flex: 1 1 auto; }

/* ---- tabs and search */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tab { min-height: 44px; display: inline-flex; align-items: center; padding: 0 16px; border-radius: 10px; border: 1px solid var(--btn-line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.tab.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.tab.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.search { display: flex; flex-wrap: wrap; gap: 8px; }
.search input { flex: 1 1 240px; min-height: 44px; padding: 0 14px; border: 1px solid var(--input-line); border-radius: 10px; font: inherit; background: var(--input); color: var(--text); }

/* ---- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 420px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 10px 8px; }
td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
td small { display: block; font-size: 12px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.row-actions form { margin: 0; }
details.acts { display: block; }
details.acts > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border: 1px solid var(--line, #334155); border-radius: 8px; font-weight: 600; user-select: none; }
details.acts > summary::-webkit-details-marker { display: none; }
details.acts > summary::after { content: "\25BE"; }
details.acts[open] > summary::after { content: "\25B4"; }
details.acts > .row-actions { position: fixed; z-index: 60; margin: 0; padding: 8px; flex-direction: column; align-items: stretch; flex-wrap: nowrap; min-width: 190px; max-height: 80vh; overflow-y: auto; background: var(--panel, #172130); border: 1px solid var(--line, #334155); border-radius: 10px; box-shadow: 0 12px 32px rgba(0,0,0,.5); }
details.acts > .row-actions .btn, details.acts > .row-actions form, details.acts > .row-actions button { width: 100%; text-align: left; justify-content: flex-start; }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--pill); color: var(--pill-text); white-space: nowrap; }
.pill.active, .pill.yes { background: var(--ok-soft); color: var(--ok-text); }
.pill.due { background: var(--warn-bg); color: var(--warn-text); }
.pill.overdue, .pill.suspended, .pill.no { background: var(--bad-soft); color: var(--bad-text); }
.pill.unmanaged { background: var(--pill); color: var(--pill-text); }

/* ---- forms */
.form { max-width: 560px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; }
.field input[type=text], .field input[type=number], .field input[type=password], .field input[type=date], .field input[type=file], .field select, .field textarea { min-height: 44px; padding: 8px 12px; border: 1px solid var(--input-line); border-radius: 10px; font: inherit; background: var(--input); color: var(--text); }
.field input[type=checkbox] { width: 20px; height: 20px; }
.field .help { color: var(--muted); font-size: 12px; }
.field .error { color: var(--bad-strong); font-size: 13px; font-weight: 600; }
.checkrow { flex-direction: row; align-items: center; gap: 10px; }

.login { max-width: 380px; margin: 12vh auto; padding: 24px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; display: flex; flex-direction: column; gap: 16px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.kv:first-of-type { border-top: 0; }
.kv b { text-align: right; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---- small screens: the rail becomes a bar along the top */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .rail { width: 100%; flex: none; height: auto; position: static; flex-direction: row; padding: 8px 10px; gap: 8px; }
  .rail nav { flex-direction: row; overflow-x: auto; padding: 0; }
  .rail nav a { min-width: 64px; }
  .rail-foot { margin: 0 0 0 auto; }
  .main { padding: 16px; }
}

/* ---- live indicator */
.live-badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--pill); color: var(--pill-text); margin-right: 6px; }
.live-badge .live-dot { width: 8px; height: 8px; border-radius: 50%; background: #94A3B8; display: inline-block; }
.live-badge.on { background: var(--ok-soft); color: var(--ok-text); }
.live-badge.on .live-dot { background: var(--ok); animation: pulse 1.6s ease-in-out infinite; }
.live-badge.off { background: var(--bad-soft); color: var(--bad-text); }
.live-badge.off .live-dot { background: var(--bad); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.big-number .alt { color: var(--alt); }
.live-chart { min-height: 120px; }
[hidden] { display: none !important; }

/* ---- theme switch (in the rail) */
.theme-btn { background: none; border: 0; color: #9FB1BB; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 3px; font: inherit; font-size: 10.5px; font-weight: 600; padding: 6px 4px; border-radius: 10px; }
.theme-btn:hover { background: rgba(255,255,255,0.07); color: #fff; }
.theme-btn svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .sun { display: block; }
:root[data-theme="dark"] .theme-btn .moon { display: none; }

/* support and outages */
.banner.bad { background: var(--bad-soft); color: var(--bad-text); display: block; text-decoration: none; }
.banner.bad:hover { color: var(--bad-text); text-decoration: underline; }
.pill.urgent, .pill.flag { background: var(--bad-soft); color: var(--bad-text); }
.pill.high, .pill.open, .pill.repeat { background: var(--warn-bg); color: var(--warn-text); }
.pill.resolved, .pill.closed { background: var(--ok-soft); color: var(--ok-text); }
.pill.normal, .pill.low, .pill.assigned, .pill.in_progress, .pill.waiting { background: var(--pill); color: var(--pill-text); }
a.pill { text-decoration: none; }
b.late { color: var(--bad-strong); }
.form.tight { max-width: none; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.form.tight:last-child { border-bottom: 0; }
.field textarea[readonly] { background: var(--bg); }

.chart { max-height: 280px; }
.charts-row { align-items: stretch; }

/* phone: top bar with a three-line menu button */
.menu-btn { display: none; }
@media (max-width: 760px) {
  .rail { flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 8px 14px; gap: 0; z-index: 20; position: sticky; top: 0; }
  .menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.18); background: transparent; color: #fff; cursor: pointer; margin-left: auto; }
  .menu-btn svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
  .rail nav, .rail-foot { display: none; width: 100%; }
  .rail.open nav { display: flex; flex-direction: column; gap: 2px; padding: 10px 0 4px; overflow: visible; }
  .rail.open .rail-foot { display: flex; flex-direction: row; align-items: center; justify-content: space-between; margin: 0; padding: 8px 0 6px; border-top: 1px solid rgba(255,255,255,0.12); }
  .rail nav a { flex-direction: row; justify-content: flex-start; gap: 14px; padding: 12px 10px; font-size: 15px; min-width: 0; }
  .rail nav a svg { width: 22px; height: 22px; }
}

.brand, .nav-group { display: none; }
.rail-logo svg { stroke-width: 1.8; }
@media (max-width: 760px) {
  .brand { display: flex; flex-direction: column; margin-left: 10px; line-height: 1.2; }
  .brand b { color: #fff; font-size: 15px; letter-spacing: .02em; }
  .brand small { color: #9FB1BB; font-size: 10.5px; letter-spacing: .08em; }
  .rail.open .nav-group { display: block; color: #7F93A0; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 12px 10px 4px; }
  .rail .menu-btn { margin-left: auto; }
  .rail .rail-logo { flex: 0 0 44px; }
}

/* desktop: title under the logo */
@media (min-width: 761px) {
  .brand { display: flex; flex-direction: column; align-items: center; margin-top: -10px; line-height: 1.15; }
  .brand b { color: #fff; font-size: 10px; letter-spacing: .06em; text-align: center; width: 70px; }
  .brand small { display: none; }
}

.rail-logo img { width: 34px; height: 34px; display: block; }
.login-logo { align-self: center; width: 64px; height: 64px; border-radius: 16px; background: #2DD4BF; display: flex; align-items: center; justify-content: center; }
.login-logo img { width: 46px; height: 46px; }

/* desktop: full sidebar with the logo and title side by side */
@media (min-width: 761px) {
  .rail { display: grid; grid-template-columns: 44px 1fr; grid-template-rows: auto minmax(0, 1fr) auto; column-gap: 12px; row-gap: 14px; width: 236px; flex: 0 0 236px; align-items: center; align-content: start; justify-items: stretch; padding: 18px 12px 14px; }
  .rail-logo { grid-column: 1; grid-row: 1; }
  .brand { grid-column: 2; grid-row: 1; align-items: flex-start; margin: 0; }
  .brand b { width: auto; font-size: 15px; letter-spacing: .03em; text-align: left; }
  .brand small { display: block; color: #9FB1BB; font-size: 9.5px; letter-spacing: .08em; }
  .rail nav { grid-column: 1 / -1; grid-row: 2; padding: 0; overflow-y: auto; gap: 2px; align-self: stretch; }
  .rail nav a { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 10px 12px; font-size: 14px; }
  .rail nav a svg { width: 20px; height: 20px; flex: 0 0 20px; }
  .nav-group { display: block; color: #7F93A0; font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; padding: 14px 12px 4px; }
  .rail-foot { grid-column: 1 / -1; grid-row: 3; flex-direction: row; justify-content: space-between; align-items: center; margin: 0; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.12); width: 100%; }
}

/* multi-ISP: router switcher, setup script box, platform table */
.rswitch { padding: 0 12px 8px; }
.rswitch select { width: 100%; font-size: 13px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: inherit; }
pre.script { background: #0f172a; color: #e2e8f0; padding: 14px 16px; border-radius: 12px; font-size: 12.5px; line-height: 1.5; overflow-x: auto; white-space: pre-wrap; word-break: break-all; max-height: 360px; overflow-y: auto; }
.steps { margin: 8px 0 0 18px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.login.wide { max-width: 460px; margin: 6vh auto; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 2px 0; }
.row-form input[type=number], .row-form select { width: auto; max-width: 130px; }
.mods { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
