/* Netmana client portal. Brand tokens match netmana.net (style.css :root). */
:root {
  --midnight: #0a0f1a;
  --navy: #1a2744;
  --gold: #c8a24d;
  --gold-text: #7a5d1c;
  --pearl: #f5f2eb;
  --pearl-warm: #faf8f3;
  --surface: #ffffff;
  --line: #e6e0d2;
  --line-soft: #f0ebdf;
  --line-strong: #cfc7b4;
  --ink: #1a2744;
  --muted: #4f5a70;
  --label: #5b6478;
  --on-dark: #f5f2eb;
  --on-dark-muted: #c9cfdb;
  --good: #0ca30c;
  --warn: #fab219;
  --bad: #d03b3b;
  --none: #ddd7c9;
  --good-bg: #e1f0e5; --good-fg: #1b5e33;
  --warn-bg: #fdf0d2; --warn-fg: #6e4a00;
  --bad-bg: #fbe3d3;  --bad-fg: #7a3410;
  --neutral-bg: #eceff5; --neutral-fg: #33405c;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --seq-light: #cde2fb;
  --seq-dark: #0d366b;
  --radius: 14px;
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'Outfit', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--pearl); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; }
a { color: var(--gold-text); }
a:hover { color: #5c4512; }
img { max-width: 100%; }
.mono { font-family: var(--mono); }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Header */
.top { background: var(--midnight); color: var(--on-dark); }
.wrap-x { max-width: 1180px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.viewas { background: var(--gold); color: var(--midnight); font-size: 14px; padding: 8px 0; }
.viewas a { color: var(--midnight); font-weight: 600; }
.top-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; }
.brand img { width: 44px; height: 44px; filter: invert(1); }
.brand-label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--gold); }
.who { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.who-text { text-align: right; }
.who-name { font-weight: 500; }
.who-sub { font-size: 13px; color: var(--on-dark-muted); }
.tabs { display: flex; flex-wrap: wrap; gap: 28px; padding-top: 8px; }
.tab { display: inline-flex; align-items: center; min-height: 44px; padding: 10px 2px 12px; color: var(--on-dark-muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; }
.tab:hover { color: var(--on-dark); }
.tab.on { color: var(--gold); font-weight: 600; border-bottom-color: var(--gold); }

/* Layout */
.wrap { max-width: 1180px; margin: 0 auto; padding: 36px 24px 64px; }
.wrap.narrow { max-width: 560px; padding-top: 96px; text-align: center; }
.msg-logo { margin-bottom: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; }
.row-gap { display: flex; align-items: center; gap: 12px; }
.row-gap.wrapping { flex-wrap: wrap; }
.split { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.split .grow { flex: 999 1 520px; min-width: 0; }
.split .side { flex: 1 1 300px; min-width: 0; }
.foot { border-top: 1px solid var(--line); }
.foot-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding-top: 20px; padding-bottom: 20px; color: var(--muted); font-size: 14px; }

/* Type */
.h1 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1.1; }
.h2 { margin: 0; font-family: var(--serif); font-weight: 400; font-size: 30px; line-height: 1.15; }
.h3 { margin: 0 0 12px; font-size: 20px; font-weight: 600; }
.h4 { margin: 0; font-size: 17px; font-weight: 600; }
.lede { margin: 6px 0 0; color: var(--muted); }
.back { font-size: 14px; text-decoration: none; }

/* Surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; min-width: 0; }
.panel.soft { background: var(--pearl-warm); border-style: dashed; border-color: var(--line-strong); }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.tile-label { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--label); }
.tile-value { font-size: 30px; font-weight: 500; margin-top: 4px; }
.tile-note { font-size: 13px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.card-title { font-family: var(--serif); font-size: 28px; line-height: 1.1; }
.card .btn { align-self: flex-start; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; font-size: 14px; }
.kv.kv-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 18px; }
.kv.kv-tight { max-width: 420px; }
.kv dt { color: var(--label); font-size: 12px; }
.kv dd { margin: 0; font-weight: 500; }

/* Alerts and flashes */
.alert { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; background: #fdf1e7; border: 1px solid #efcdb0; border-radius: var(--radius); color: #5a3a24; }
.alert-title { font-weight: 600; color: var(--bad-fg); }
.flash { padding: 12px 16px; border-radius: 10px; background: var(--good-bg); color: var(--good-fg); font-weight: 500; }
.flash.err { background: var(--bad-bg); color: var(--bad-fg); }

/* Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.badge.good { background: var(--good-bg); color: var(--good-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.bad { background: var(--bad-bg); color: var(--bad-fg); }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral-fg); }

/* Buttons and pills */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 10px; font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; border: 1px solid transparent; white-space: nowrap; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.primary:hover { background: #24345a; color: #fff; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { border-color: var(--navy); color: var(--ink); }
.btn.danger { background: var(--surface); color: var(--bad-fg); border-color: #e9b9a0; }
.btn.danger:hover { border-color: var(--bad); }
.btn.ghost { background: transparent; color: var(--on-dark); border-color: #3a4560; font-size: 14px; }
.btn.ghost:hover { border-color: var(--on-dark-muted); color: var(--on-dark); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 500; }
.pill.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--pearl-warm); font-size: 13px; }
.chip-form { display: inline-flex; align-items: center; gap: 2px; margin: 0; }
.chip-x { border: none; background: none; color: var(--bad-fg); font-size: 18px; cursor: pointer; min-width: 32px; min-height: 32px; }
.link-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.t { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 14px; }
.t th { text-align: left; font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--label); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.t td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.t th:first-child, .t td:first-child { padding-left: 0; }
.t th:last-child, .t td:last-child { padding-right: 0; }
.t .num { text-align: right; white-space: nowrap; }
.t tfoot td { border-bottom: none; border-top: 1px solid var(--line); }

/* Billing */
.open-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.open-row:first-of-type { border-top: none; }
.row-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.open-right { display: flex; align-items: center; gap: 16px; }
.amount { font-size: 22px; font-weight: 500; }
#paypal-amount-options { display: grid; gap: 12px; min-width: 0; margin: 16px 0; padding: 16px; border: 1px solid var(--line); border-radius: 10px; }
#paypal-amount-options label:has(input[type="radio"]) { display: flex; align-items: center; gap: 10px; cursor: pointer; }
#paypal-amount-options input[type="radio"] { width: 18px; height: 18px; min-height: 18px; flex: 0 0 18px; margin: 0; padding: 0; }
#paypal-amount:disabled { color: var(--muted); background: var(--line-soft); }
.pay-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 32px; }
.pay-bank .h4 { margin-bottom: 12px; }
#paypal-buttons { margin-top: 14px; max-width: 420px; }
.pay-error { color: var(--bad-fg); font-weight: 500; }

/* Charts */
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.readout { font-size: 14px; min-height: 21px; }
.strip { display: flex; gap: 2px; height: 44px; }
.strip-cell { flex: 1 1 0; min-width: 0; border-radius: 2px; }
.strip-cell.hl { outline: 2px solid var(--navy); outline-offset: 1px; }
.s-good { background: var(--good); }
.s-warn { background: var(--warn); }
.s-bad { background: var(--bad); }
.s-none { background: var(--none); }
.axis { display: flex; justify-content: space-between; margin-top: 6px; font-family: var(--mono); font-size: 12px; color: var(--label); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.line-chart { padding-left: 44px; }
.plot { position: relative; height: 200px; }
.plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.plot path { fill: none; stroke: var(--series-1); stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.gridline { position: absolute; left: 0; right: 0; border-top: 1px solid #ece6d8; }
.gridline.base { border-top-color: var(--line-strong); }
.gridline span { position: absolute; left: -44px; transform: translateY(-50%); font-family: var(--mono); font-size: 11px; color: var(--label); }
.cross { position: absolute; top: 0; bottom: 0; border-left: 1px solid #b3ab98; pointer-events: none; }
.dot { position: absolute; width: 10px; height: 10px; border-radius: 999px; background: var(--series-1); border: 2px solid var(--surface); transform: translate(-50%, 50%); pointer-events: none; }
.hits { position: absolute; inset: 0; display: flex; }
.hits span { flex: 1 1 0; height: 100%; }
.bars { display: flex; align-items: flex-end; gap: 28px; height: 220px; padding: 0 8px; border-bottom: 1px solid var(--line-strong); margin-top: 18px; }
.bar-col { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; min-width: 0; }
.bar-val { font-size: 13px; font-weight: 500; white-space: nowrap; }
.bar { width: 100%; max-width: 96px; background: var(--navy); border-radius: 4px 4px 0 0; }
.bar.empty { height: 40px; background: none; border: 1px dashed #b3ab98; border-bottom: none; }
.bar-labels { display: flex; gap: 28px; padding: 8px 8px 0; }
.bar-labels div { flex: 1 1 0; text-align: center; font-family: var(--mono); font-size: 12px; color: var(--label); }
.share { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; }
.share-head { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.share-label { font-weight: 500; }
.share-track { height: 10px; background: #efe9dc; border-radius: 999px; overflow: hidden; }
.share-fill { height: 100%; background: var(--gold); border-radius: 999px; }
.events { list-style: none; margin: 12px 0 0; padding: 0; }
.events li { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.ev-dot { flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 999px; }
.events li > div { flex: 1 1 auto; min-width: 0; }
.ev-head { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; flex-wrap: wrap; }

/* Forms */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 20px; align-items: start; }
.mark-paid { white-space: normal; }
.mark-paid[open] { min-width: 260px; max-width: 36rem; }
.mark-paid .form { text-align: left; }
.mark-paid .form p { grid-column: 1 / -1; }
.t .mark-paid { margin-top: 8px; }
.form.compact { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.panel > .form.compact:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full, .form-actions, .field.check { grid-column: 1 / -1; }
.field label { font-size: 14px; font-weight: 500; }
.field.check label { display: flex; gap: 10px; align-items: center; font-weight: 400; }
.field.check input { width: 18px; height: 18px; }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .pill:focus-visible, .tab:focus-visible, a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.help { font-size: 13px; color: var(--muted); }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; }
form.inline { display: inline; margin: 0; }
.lines { display: flex; flex-direction: column; gap: 8px; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) 90px 140px; gap: 8px; }
.line.head span { font-size: 12px; color: var(--label); font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.token-box { margin: 12px 0 16px; padding: 16px; border: 1px solid var(--gold); border-radius: 12px; background: #fbf6ea; }
.token { display: block; word-break: break-all; font-size: 15px; padding: 8px 0; }
.code { background: var(--midnight); color: var(--on-dark); padding: 12px 14px; border-radius: 10px; overflow-x: auto; font-size: 13px; }
.type-sum { cursor: pointer; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; min-height: 32px; }
details[open] .type-sum { margin-bottom: 16px; }

@media (max-width: 640px) {
  .h1 { font-size: 36px; }
  .who-text { text-align: left; }
  .tabs { gap: 18px; }
  .strip { gap: 2px; }
  .bars, .bar-labels { gap: 12px; }
  .line { grid-template-columns: minmax(0, 1fr) 64px 100px; }
}

@media print {
  .top, .foot, .tabs, .btn, .back, .pay-grid { display: none !important; }
  body { background: #fff; }
  .panel { border: none; padding: 0; }
}

/* Shared, server-rendered metrics. All text uses ink/muted; series never encode status. */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.metrics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.metric-chart { min-width: 0; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg text { fill: var(--muted); font: 12px var(--sans); }
.chart-grid line { stroke: var(--line-soft); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-baseline { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.series-1 { fill: var(--series-1); background: var(--series-1); }
.series-2 { fill: var(--series-2); background: var(--series-2); }
.series-3 { fill: var(--series-3); background: var(--series-3); }
.chart-bar { stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-hit { fill: transparent; }
.no-data { stroke: var(--muted); stroke-width: 1; }
.series-legend { margin: 8px 0; }
.chart-totals { color: var(--ink); margin: 8px 0; }
.chart-table { margin-top: 16px; color: var(--ink); font-size: 14px; }
.chart-table summary { cursor: pointer; min-height: 32px; padding: 4px 0; color: var(--muted); }
.chart-table .t { min-width: 0; }
.chart-table .t th, .chart-table .t td { font-family: var(--sans); font-size: 13px; text-transform: none; letter-spacing: 0; padding: 8px; }
.chart-table .t th[scope="row"] { font-weight: 400; }
.horizontal-row { margin: 16px 0; }
.horizontal-svg { display: block; height: 14px; margin-top: 6px; }
.horizontal-track { fill: var(--line-soft); }
.share-head > span { min-width: 0; overflow-wrap: anywhere; }
.share-head > strong { flex-shrink: 0; font-weight: 500; }
.health-row { padding: 24px 0; border-top: 1px solid var(--line); }
.health-row:last-child { padding-bottom: 0; }
.health-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; margin-bottom: 20px; }
.health-summary > :first-child { flex: 1 1 220px; }
.health-summary .device-counts { font-size: 14px; }
.due-date { font-size: 26px; }
[data-tip]:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.chart-tooltip { position: fixed; z-index: 100; background: var(--ink); color: var(--surface); border-radius: 6px; padding: 8px 12px; font-size: 13px; max-width: min(320px, calc(100vw - 24px)); pointer-events: none; box-shadow: 0 3px 14px #0002; }
.line-point { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--series-1); transform: translate(-50%, 50%); }
@media (max-width: 640px) {
  .metrics-grid { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 18px; }
  .cards { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 18px; min-width: 0; }
  .card-top { flex-wrap: wrap; }
  .chart-svg text { font-size: 21px; }
  .chart-svg .sparse-label { display: none; }
  .chart-svg .chart-x tspan { font-size: 17px; }
  .health-summary { gap: 12px 20px; }
  .health-summary > :first-child { flex-basis: 180px; }
  .chart-table .t { min-width: 300px; }
  .chart-table { max-width: 100%; }
  .chart-totals { font-size: 14px; }
}

/* Public pages (API guide, sign-out): header links on the dark bar, and long code that wraps on phones. */
.top a:not(.brand) { color: var(--on-dark); }
main code { overflow-wrap: anywhere; }

/* Sign-in */
.signin-body { background: var(--pearl); }
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.signin-side { background: var(--midnight); color: var(--on-dark); padding: 40px 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.signin-pitch { max-width: 440px; }
.signin-title { margin: 0 0 24px; font-family: var(--serif); font-weight: 400; font-size: 46px; line-height: 1.08; }
.signin-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 12px; color: var(--on-dark-muted); }
.signin-list li { display: flex; gap: 12px; align-items: baseline; }
.signin-list li::before { content: ''; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--gold); transform: translateY(-2px); }
.signin-foot { margin: 0; font-size: 13px; color: var(--on-dark-muted); }
.signin-main { display: grid; place-items: center; padding: 48px 24px; }
.signin-panel { width: 100%; max-width: 420px; }
.signin-loading { padding: 48px 0; text-align: center; }
.signin-help { margin: 20px 4px 0; text-align: center; }
@media (max-width: 860px) {
  .signin { grid-template-columns: 1fr; min-height: 0; }
  .signin-side { padding: 20px 16px 24px; gap: 16px; }
  .signin-title { font-size: 30px; margin-bottom: 0; }
  .signin-list, .signin-foot { display: none; }
  .signin-main { padding: 24px 16px 40px; place-items: start center; }
}
