:root {
  color-scheme: light dark;
  --ink: #0d2b33;
  --ink-2: #153f49;
  --ink-text: #d3e5e8;
  --ink-muted: #8cadb3;
  --ink-strong: #ffffff;
  --signal: #4fd1c5;
  --bg: #f2f5f5;
  --panel: #ffffff;
  --panel-2: #f7f9f9;
  --hover: #f1f6f6;
  --line: #dce4e5;
  --line-strong: #b9c7c9;
  --text: #13262b;
  --muted: #5b6f74;
  --accent: #0b7683;
  --accent-hover: #095f6b;
  --accent-ink: #ffffff;
  --ok: #0b7a4b;
  --ok-bg: #e3f4ea;
  --warn: #8a5300;
  --warn-bg: #fff1d6;
  --bad: #b42318;
  --bad-bg: #fde7e4;
  --info-bg: #e6f1f3;
  --radius: 8px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a181c;
    --panel: #102a31;
    --panel-2: #0e242a;
    --hover: #143339;
    --line: #1f3f47;
    --line-strong: #2f5660;
    --text: #e3eef0;
    --muted: #93acb1;
    --accent: #35b9c9;
    --accent-hover: #5ccddb;
    --accent-ink: #042a30;
    --ok: #5fd99b;
    --ok-bg: #12382a;
    --warn: #f2c26b;
    --warn-bg: #3b2c0e;
    --bad: #ff8f84;
    --bad-bg: #411a17;
    --info-bg: #123640;
    --ink: #07161a;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; font-family: var(--font); line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.55rem; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; margin: 0 0 1.1rem; }
h2 { font-size: 1.1rem; font-weight: 650; margin: 2rem 0 .7rem; }
p { margin: 0 0 .9rem; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.6rem 0; }
code, pre { font-family: var(--mono); font-size: .86em; background: var(--info-bg); border-radius: 4px; padding: .1em .4em; }
pre { padding: .8rem 1rem; overflow-x: auto; line-height: 1.55; }
.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- messages ---------- */
.ok, .notice, p.error { padding: .65rem .9rem; border-radius: 6px; border-left: 3px solid; }
.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.notice { background: var(--info-bg); border-color: var(--accent); }
p.error { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.error { color: var(--bad); }

/* ---------- forms and buttons ---------- */
label { display: block; margin-bottom: 1rem; font-size: .9rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; font: inherit; font-weight: 400; color: var(--text);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px;
}
input::placeholder { color: var(--muted); opacity: .8; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.check input { width: auto; margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 1rem; padding: .8rem 1rem .2rem; }
legend { padding: 0 .4rem; font-weight: 600; font-size: .9rem; }
.form { max-width: 580px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.4rem 1.5rem 1.2rem; }
.field { margin-bottom: 1rem; }
.field > label { margin-bottom: 0; }
.field select { margin-top: .5rem; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem; font: inherit; font-size: .9rem; font-weight: 600; line-height: 1.2;
  color: var(--accent-ink); background: var(--accent); border: 1px solid transparent; border-radius: 6px; cursor: pointer; text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-hover); color: var(--accent-ink); }
button.secondary, .button.secondary { color: var(--accent); background: transparent; border-color: var(--line-strong); }
button.secondary:hover, .button.secondary:hover { background: var(--hover); color: var(--accent-hover); }
button.small, .button.small { padding: .3rem .65rem; font-size: .8rem; }
button.link { padding: 0; font-weight: 500; color: var(--accent); background: none; border: 0; }
button:disabled { opacity: .55; cursor: default; }
form.inline { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: 0 .25rem .25rem 0; }
form.inline input, form.inline select { width: auto; margin: 0; }
td form.inline select { padding: .3rem .5rem; font-size: .84rem; }

.pwfield { position: relative; display: flex; }
.pwfield input { flex: 1; margin-top: .3rem; padding-right: 4.8rem; }
.pwtoggle, .inlinebtn { position: absolute; right: .3rem; top: calc(50% + .15rem); transform: translateY(-50%); padding: .2rem .6rem; font-size: .78rem; }
.ping-up { color: var(--ok); font-weight: 600; }
.ping-down { color: var(--bad); }

/* ---------- tables ---------- */
.page table { width: 100%; border-collapse: collapse; background: var(--panel); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .92rem; }
.page th { padding: .65rem .9rem; text-align: left; font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--panel-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.page td { padding: .7rem .9rem; vertical-align: middle; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.page tbody tr:last-child td { border-bottom: 0; }
.page tbody tr:hover { background: var(--hover); }
.page form.inline + table, .page p + table { margin-top: .4rem; }

.pill { display: inline-block; padding: .08rem .55rem; font-size: .78rem; font-weight: 600; border-radius: 99px; background: var(--info-bg); color: var(--muted); white-space: nowrap; }
.pill-active, .pill-online { background: var(--ok-bg); color: var(--ok); }
.pill-suspended { background: var(--warn-bg); color: var(--warn); }
.pill-cancelled { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }

/* ---------- app shell ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 248px; display: flex; flex-direction: column; background: var(--ink); color: var(--ink-text); z-index: 30; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.1rem 1rem; }
.brandmark { flex: none; width: 36px; height: 36px; display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; color: var(--ink); background: var(--signal); border-radius: 9px; }
.brandtext { display: flex; flex-direction: column; min-width: 0; }
.brandname { color: var(--ink-strong); font-weight: 650; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brandsub { color: var(--ink-muted); font-size: .78rem; }
.nav { padding: .4rem .7rem 1rem; flex: 1; }
.navgroup { margin: 1.1rem .6rem .35rem; font-size: .78rem; color: var(--ink-muted); }
.navlink { display: flex; align-items: center; gap: .7rem; padding: .5rem .65rem; margin-bottom: 2px; color: var(--ink-text); text-decoration: none; border-radius: 6px; border-left: 3px solid transparent; }
.navlink svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.navlink:hover { background: var(--ink-2); color: var(--ink-strong); }
.navlink.is-active { background: var(--ink-2); color: var(--ink-strong); border-left-color: var(--signal); font-weight: 600; }
.navlink.is-active svg { stroke: var(--signal); opacity: 1; }
.sidefoot { padding: 1rem 1.2rem 1.2rem; border-top: 1px solid var(--ink-2); font-size: .8rem; color: var(--ink-muted); }
.sidefoot strong { display: block; color: var(--ink-text); font-weight: 600; margin-bottom: .2rem; }

.shell { margin-left: 248px; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .8rem; height: 58px; padding: 0 1.5rem; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar-spacer { flex: 1; }
.menubutton { display: none; padding: .4rem; color: var(--text); background: none; border: 1px solid var(--line-strong); }
.menubutton:hover { background: var(--hover); color: var(--text); }
.menubutton svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.scrim { display: none; }
.page { max-width: 1240px; padding: 1.7rem 1.5rem 3rem; overflow-x: auto; }

.usermenu { position: relative; }
.usermenu summary { display: flex; align-items: center; gap: .6rem; padding: .3rem .4rem .3rem .3rem; border-radius: 99px; cursor: pointer; list-style: none; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover, .usermenu[open] summary { background: var(--hover); }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; font-size: .82rem; font-weight: 700; color: var(--accent-ink); background: var(--accent); border-radius: 50%; }
.whoami { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.who-name { font-weight: 600; font-size: .88rem; }
.who-role { font-size: .75rem; color: var(--muted); }
.chev { width: 14px; height: 14px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; margin-right: .3rem; }
.usermenu .menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; padding: .4rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(8, 30, 36, .18); }
.menu-head { padding: .5rem .7rem .6rem; margin-bottom: .3rem; border-bottom: 1px solid var(--line); font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.menu a, .menu button { display: flex; width: 100%; justify-content: flex-start; padding: .5rem .7rem; font-size: .9rem; font-weight: 500; color: var(--text); background: none; border: 0; border-radius: 6px; text-decoration: none; }
.menu a:hover, .menu button:hover { background: var(--hover); color: var(--text); }
.menu form { margin: 0; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 1.6rem; }
.stat { padding: 1.1rem 1.2rem; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.stat-figure { font-family: var(--mono); font-size: 2.2rem; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { margin-top: .3rem; color: var(--muted); font-size: .88rem; }
.stat-live { background: var(--ink); border-color: var(--ink); }
.stat-live .stat-figure { color: var(--signal); }
.stat-live .stat-label { display: flex; align-items: center; gap: .5rem; color: var(--ink-muted); }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--signal); animation: pulse 2.6s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(79, 209, 197, .6); } 70%, 100% { box-shadow: 0 0 0 9px rgba(79, 209, 197, 0); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }
@media (prefers-color-scheme: dark) { .stat-live { border-color: rgba(79, 209, 197, .45); } }

/* ---------- logs ---------- */
.loglines { margin-top: .6rem; font-family: var(--mono); font-size: .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.logline { padding: .3rem .7rem; border-bottom: 1px solid var(--line); word-break: break-all; }
.logline:last-child { border-bottom: 0; }
.log-bad { color: var(--bad); font-weight: 600; }
.log-good { color: var(--ok); }

/* ---------- sign-in and other single-card pages ---------- */
body:not(.app) { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 1.2rem; padding: 1.5rem; background: var(--ink); color: var(--ink-text); }
body:not(.app) .authbrand { display: flex; align-items: center; gap: .7rem; color: var(--ink-strong); font-weight: 650; }
body:not(.app) .authbrand .brandmark { width: 34px; height: 34px; }
.card { width: min(430px, 92vw); padding: 1.8rem 1.8rem 1.5rem; color: var(--text); background: var(--panel); border-radius: 12px; box-shadow: 0 20px 50px rgba(0, 0, 0, .35); }
.card h1 { font-size: 1.3rem; margin-bottom: 1.2rem; }
.card button[type=submit] { width: 100%; }
.card button.secondary { margin-top: .7rem; }
.qr { display: inline-block; padding: 8px; background: #fff; border-radius: 6px; }
.qr svg { width: 200px; height: 200px; display: block; }

/* ---------- phones and tablets ---------- */
@media (max-width: 920px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(5, 20, 24, .5); }
  .shell { margin-left: 0; }
  .menubutton { display: inline-flex; }
  .topbar { padding: 0 1rem; }
  .page { padding: 1.3rem 1rem 2.5rem; }
  .whoami { display: none; }
  .page table { display: block; overflow-x: auto; white-space: nowrap; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-live { grid-column: 1 / -1; }
  .stat { padding: .9rem 1rem; }
  .stat-figure { font-size: 1.8rem; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- appearance page ---------- */
.swatches { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: .8rem; }
.swatch { display: flex; align-items: center; justify-content: space-between; gap: .6rem; margin: 0; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: var(--radius); }
input[type=color] { width: 46px; height: 32px; padding: 0; margin: 0; background: none; border: 1px solid var(--line-strong); border-radius: 6px; cursor: pointer; }
input[type=file] { display: block; width: 100%; margin: .3rem 0; font: inherit; color: var(--text); }
.logo-preview { display: block; max-width: 200px; max-height: 52px; margin: .4rem 0 .6rem; padding: 6px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.logoplate { display: inline-flex; padding: 5px 9px; background: #fff; border-radius: 8px; }
.brandlogo { display: block; max-width: 168px; max-height: 34px; }
.pv { --pv-sidebar: #0d2b33; --pv-sidebar-text: #ffffff; --pv-accent: #0b7683; --pv-accent-text: #ffffff; --pv-bg: #f2f5f5; --pv-panel: #ffffff; --pv-panel-text: #13262b;
      display: flex; height: 150px; margin: 0 0 1rem; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 10px; }
.pv-side { display: flex; flex-direction: column; gap: .5rem; width: 34%; padding: .8rem; font-size: .8rem; font-weight: 600; color: var(--pv-sidebar-text); background: var(--pv-sidebar); }
.pv-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--pv-accent); }
.pv-line { height: 6px; border-radius: 3px; background: var(--pv-sidebar-text); opacity: .25; }
.pv-main { flex: 1; padding: .9rem; background: var(--pv-bg); }
.pv-panel { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; padding: .8rem; font-size: .8rem; color: var(--pv-panel-text); background: var(--pv-panel); border-radius: 8px; }
.pv-btn { padding: .25rem .7rem; font-weight: 600; color: var(--pv-accent-text); background: var(--pv-accent); border-radius: 5px; }
@media (max-width: 560px) { .swatches { grid-template-columns: 1fr; } }

/* keyboard focus on dark or coloured menus */
.sidebar :focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
.stat-live :focus-visible { outline-color: var(--signal); }

/* subscriber profile */
input[type=tel] {
  display: block; width: 100%; margin-top: .3rem; padding: .55rem .7rem; font: inherit; font-weight: 400; color: var(--text);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px;
}
input[type=tel]:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.form.wide { max-width: 760px; }
.formhead { margin: 1.4rem 0 .8rem; padding-top: 1rem; border-top: 1px solid var(--line); font-size: 1rem; }
.formhead:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.samerow { margin: -.4rem 0 1rem; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.emailrow { display: flex; align-items: center; gap: .5rem; margin-bottom: .5rem; }
.emailrow input { margin-top: 0; flex: 1; font-size: .9rem; }
.emailrow button[hidden] { display: none; }
fieldset.terms { border: 0; padding: 0; margin: 0 0 1rem; }
fieldset.terms legend { padding: 0; margin-bottom: .45rem; font-size: .9rem; font-weight: 500; }
.chips { position: relative; display: flex; flex-wrap: wrap; gap: .4rem; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.chips label {
  margin: 0; padding: .45rem .95rem; font-size: .9rem; font-weight: 500; color: var(--text); cursor: pointer;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 999px;
}
.chips label:hover { background: var(--hover); }
.chips input:checked + label { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.chips input:focus-visible + label { outline: 2px solid var(--text); outline-offset: 2px; }
@media (max-width: 640px) { .formgrid { grid-template-columns: 1fr; } }

/* import and export */
.helplist { margin: 0 0 1rem 1.1rem; padding: 0; }
.helplist li { margin-bottom: .45rem; font-size: .92rem; }
.form.wide + .form.wide { margin-top: 1.2rem; }

/* customers and services */
.custbox { max-width: 760px; margin-bottom: 1.2rem; }
.details { display: grid; grid-template-columns: 11rem 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.details dt { color: var(--muted); font-size: .9rem; }
.details dd { margin: 0; }
.details dd.pre { white-space: pre-line; }
.custline { margin: 0 0 1rem; }
@media (max-width: 640px) { .details { grid-template-columns: 1fr; gap: 0; } .details dd { margin-bottom: .5rem; } }

/* traffic */
.trafsum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 0 0 1.2rem; max-width: 760px; }
.trafsum > div { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .7rem .9rem; }
.tabs { display: flex; gap: .4rem; margin: 0 0 .8rem; flex-wrap: wrap; }
.tabs a { padding: .35rem .8rem; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text); text-decoration: none; }
.tabs a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chart { max-width: 760px; margin: 0 0 1rem; }
.chart svg { width: 100%; height: auto; display: block; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { fill: var(--muted); }
.bar-down { fill: var(--accent); background: var(--accent); }
.bar-up { fill: var(--ok); background: var(--ok); }
.legend { margin: .5rem 0 0; color: var(--muted); font-size: .9rem; }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; vertical-align: -1px; margin-right: .2rem; }
@media (max-width: 640px) { .trafsum { grid-template-columns: 1fr; } }

/* live traffic */
.livenow { display: flex; gap: 2.5rem; align-items: flex-end; margin: 0 0 .8rem; flex-wrap: wrap; }
.livebig { font-size: 1.9rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.live-line-down { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.live-line-up { fill: none; stroke: var(--ok); stroke-width: 2; stroke-linejoin: round; }
.tabs a.livetab::before { content: ""; display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; background: var(--bad); margin-right: .4rem; vertical-align: 1px; }
.tabs a.livetab.active::before { background: var(--accent-ink); }

/* https certificate */
.cert { margin-top: 2rem; }
.cert h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
.cert-facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; margin: 0 0 1rem; }
.cert-facts dt { color: var(--muted); }
.cert-facts dd { margin: 0; }
.cert .actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
