/* The portal follows DESIGN.md: neutral dark-grey ground, the brand coral for what the machine asserts and the
   primary action, yellow only for the rule that divides sections, state colours only where a state is reported.
   Bad is rose and warn is amber so neither reads as the coral accent. */
:root {
    --bg: #141414;
    --surface: #1b1b1b;
    --surface-2: #222222;
    --surface-3: #2a2a2a;
    --border: #333333;
    --border-2: #3d3d3d;
    --text: #f2f2f2;
    --muted: #9a9a9a;
    --accent: #ef5b50;
    --accent-hi: #f37a71;
    --accent-dim: #4a1f1b;
    --accent-ink: #1b1b1b;
    --line: #ffd24d;
    --good: #46d17f;
    --warn: #f5b041;
    --bad: #ff5c9e;
    --mono: "JetBrains Mono", ui-monospace, monospace;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 Archivo, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hi); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.loading { color: var(--muted); padding: 40px 24px; max-width: 1180px; margin: 0 auto; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

h1, h2, h3 { font-stretch: 118%; letter-spacing: -0.025em; margin: 0; line-height: 1.1; }
h1 { font-size: clamp(30px, 4vw, 44px); font-weight: 700; }
h2 { font-size: 22px; font-weight: 650; }
h1:focus { outline: none; }

/* Top bar */
.top { position: sticky; top: 0; z-index: 20; background: rgb(20 20 20 / 0.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.top-in { max-width: 1180px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); padding: 4px 2px; }
.brand:hover { color: var(--text); }
.brand img { height: 26px; width: auto; display: block; }
.tag { font: 11px var(--mono); color: var(--muted); border: 1px solid var(--border-2); padding: 1px 6px; border-radius: 3px; }
.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; flex: 1 1 auto; }
.nav a { position: relative; padding: 9px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--text); }
.nav a.active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: 2px; height: 2px; background: var(--accent); border-radius: 2px; }
.nav-sep { font: 11px var(--mono); color: var(--muted); padding: 0 6px 0 14px; margin-left: 6px; border-left: 1px solid var(--border); }
.who { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.who .email { font-size: 14px; color: var(--muted); }
.linkbtn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 8px; min-height: 40px; }
.linkbtn:hover { color: var(--text); }

/* Organisation switcher */
.orgsw { position: relative; }
.orgbtn { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px 8px 12px; min-height: 40px; cursor: pointer; }
.orgbtn:hover { border-color: var(--border-2); }
.orgbtn b { font-weight: 600; }
.role { font: 11px var(--mono); color: var(--muted); }
.orgmenu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 260px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px; padding: 6px; box-shadow: 0 18px 40px rgb(0 0 0 / 0.45); }
.menu-lbl { font: 11px var(--mono); color: var(--muted); padding: 8px 10px 6px; }
.orgmenu a { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px; min-height: 44px; border-radius: 6px; color: var(--text); text-decoration: none; }
.orgmenu a:hover { background: var(--surface-3); }
.orgmenu a.on { background: var(--accent-dim); }

/* Page */
.wrap { max-width: 1180px; margin: 0 auto; padding: 40px 24px 120px; }
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.sub { color: var(--muted); margin-top: 10px; max-width: 68ch; }
.stack { display: flex; flex-direction: column; gap: 28px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.center { max-width: 620px; margin: 40px auto 0; }

/* Brackets: the overlay's detection box is the panel. */
.br {
    --c: var(--muted);
    --t: 14px;
    position: relative;
    border: 1px solid var(--border);
    border-radius: 2px;
    padding: 28px;
    background:
        linear-gradient(var(--c), var(--c)) top left / var(--t) 2px no-repeat,
        linear-gradient(var(--c), var(--c)) top left / 2px var(--t) no-repeat,
        linear-gradient(var(--c), var(--c)) top right / var(--t) 2px no-repeat,
        linear-gradient(var(--c), var(--c)) top right / 2px var(--t) no-repeat,
        linear-gradient(var(--c), var(--c)) bottom left / var(--t) 2px no-repeat,
        linear-gradient(var(--c), var(--c)) bottom left / 2px var(--t) no-repeat,
        linear-gradient(var(--c), var(--c)) bottom right / var(--t) 2px no-repeat,
        linear-gradient(var(--c), var(--c)) bottom right / 2px var(--t) no-repeat,
        var(--surface);
    background-origin: border-box;
}
.br.accent { --c: var(--accent); }
.lbl { position: absolute; top: -9px; left: 18px; background: var(--bg); padding: 0 8px; font: 12px/16px var(--mono); color: var(--muted); }
.br.accent > .lbl { color: var(--accent); }
.br.empty { text-align: center; padding: 56px 28px; }
.br.empty h2 { margin-bottom: 10px; }
.br.empty p { margin: 0 auto 24px; max-width: 46ch; }
.br.empty p:last-child { margin-bottom: 0; }

/* The line divides. */
.rule { display: flex; align-items: center; gap: 12px; margin: 44px 0 22px; }
.rule span { font: 12px var(--mono); color: var(--line); }
.rule::after { content: ""; flex: 1; height: 2px; background: var(--line); transform-origin: left; animation: sweep 0.9s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes sweep { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@media (prefers-reduced-motion: reduce) { .rule::after { animation: none; } }

/* State */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; border: 1px solid; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.sm { padding: 3px 10px 3px 8px; font-size: 12px; }
.pill.good { color: var(--good); border-color: rgb(70 209 127 / 0.35); background: rgb(70 209 127 / 0.08); }
.pill.warn { color: var(--warn); border-color: rgb(245 176 65 / 0.4); background: rgb(245 176 65 / 0.08); }
.pill.bad { color: var(--bad); border-color: rgb(255 92 158 / 0.4); background: rgb(255 92 158 / 0.08); }
.pill.neutral { color: var(--muted); border-color: var(--border-2); }
.chip { display: inline-flex; align-items: center; font: 11px var(--mono); padding: 2px 8px; border-radius: 4px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.chip.accent { background: var(--accent-dim); color: #ffd6d2; }

.alert { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; border-radius: 8px; border: 1px solid var(--border-2); background: var(--surface); margin-bottom: 28px; }
.alert > .grow { flex: 1; min-width: 0; }
.alert strong { display: block; margin-bottom: 2px; }
.alert::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 8px; border-radius: 50%; background: var(--accent); }
.alert.warn { border-color: rgb(245 176 65 / 0.45); background: rgb(245 176 65 / 0.07); }
.alert.warn::before { background: var(--warn); }
.alert.bad { border-color: rgb(255 92 158 / 0.45); background: rgb(255 92 158 / 0.07); }
.alert.bad::before { background: var(--bad); }
.alert.good::before { background: var(--good); }
.alert.inline { margin: 16px 0 0; }

/* Controls */
.btn, button.btn, a.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--border-2);
    background: var(--surface-2); color: var(--text); font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: var(--surface-3); border-color: #4a4a4a; color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hi); border-color: var(--accent-hi); color: var(--accent-ink); }
.btn.danger { background: transparent; border-color: rgb(255 92 158 / 0.5); color: var(--bad); }
.btn.danger:hover { background: rgb(255 92 158 / 0.1); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }
.btn.ok { background: rgb(70 209 127 / 0.12); border-color: rgb(70 209 127 / 0.5); color: var(--good); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); }
.inp { min-height: 44px; padding: 0 12px; background: var(--bg); border: 1px solid var(--border-2); border-radius: 8px; width: 100%; }
.inp:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgb(239 91 80 / 0.2); }
select.inp {
    appearance: none; padding-right: 34px;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat;
}
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; align-items: end; }
.chk { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.chk input { width: 18px; height: 18px; accent-color: var(--accent); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-2); border-radius: 10px; overflow: hidden; background: var(--bg); }
.stepper button { width: 52px; height: 56px; background: none; border: 0; font-size: 22px; cursor: pointer; }
.stepper button:hover:not(:disabled) { background: var(--surface-3); }
.stepper button:disabled { color: var(--border-2); cursor: not-allowed; }
.stepper output { min-width: 64px; text-align: center; font: 600 24px/56px var(--mono); border-inline: 1px solid var(--border); }
.stepper.sm button { width: 44px; height: 44px; font-size: 18px; }
.stepper.sm output { line-height: 44px; font-size: 18px; min-width: 52px; }

/* License */
.keyrow { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; }
.key { flex: 1 1 420px; min-width: 0; display: flex; align-items: center; padding: 14px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font-size: 15px; letter-spacing: 0.04em; overflow-wrap: anywhere; user-select: all; }
.keyrow .btn { min-width: 128px; }
.hint { margin-top: 14px; color: var(--muted); font-size: 14px; }
.hint b { color: var(--text); font-weight: 600; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 2px; margin: 28px 0 0; }
.fact { background: var(--bg); padding: 20px 22px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fact dt { font: 12px var(--mono); color: var(--muted); }
.fact dd { margin: 0; font-size: 20px; font-weight: 600; font-stretch: 108%; letter-spacing: -0.01em; }
.fact dd.mono { font-size: 18px; }
.fact .s { font-size: 13px; font-weight: 400; font-stretch: 100%; letter-spacing: 0; color: var(--muted); }
.meter { display: flex; gap: 4px; flex-wrap: wrap; }
.seat { width: 22px; height: 10px; border-radius: 2px; border: 1px solid var(--border-2); }
.seat.used { background: var(--accent); border-color: var(--accent); }
.seat.over { background: var(--warn); border-color: var(--warn); }
.seatrow { display: flex; gap: 28px; align-items: center; flex-wrap: wrap; }
.seatcopy { flex: 1 1 320px; min-width: 0; }
.seatcopy .big { font-weight: 600; margin-bottom: 6px; }
.delta-up { color: var(--accent); }
.delta-down { color: var(--good); }
.iwarn { margin-top: 20px; padding-top: 18px; border-top: 1px dashed var(--border-2); color: var(--warn); font-size: 14px; }

/* Devices */
.stats { display: flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 2px; margin-bottom: 28px; }
.stat { padding: 16px 22px; border-right: 1px solid var(--border); flex: 1 1 140px; }
.stat:last-child { border-right: 0; }
.stat .n { font: 600 26px var(--mono); }
.stat .k { font-size: 13px; color: var(--muted); }
.code-big { font: 600 28px var(--mono); letter-spacing: 0.12em; }
.tblbox { overflow-x: auto; border: 1px solid var(--border); border-radius: 2px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th { font: 12px var(--mono); color: var(--muted); text-align: left; padding: 12px 20px; background: var(--surface); font-weight: 400; }
td { padding: 14px 20px; border-top: 1px solid var(--border); vertical-align: middle; }
tr.confirm td { background: rgb(255 92 158 / 0.06); }
td.right, th.right { text-align: right; }
.dname { font-weight: 600; }
.dkey { font: 12px var(--mono); color: var(--muted); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Plans */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 28px; }
.plan { display: flex; flex-direction: column; gap: 18px; }
.price { display: flex; align-items: baseline; gap: 8px; }
.price .amt { font: 600 34px var(--mono); letter-spacing: -0.02em; }
.feat { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.feat li { display: flex; gap: 10px; align-items: baseline; }
.feat li::before { content: "✓"; color: var(--good); font-weight: 700; width: 14px; flex: none; }
.feat li.no { color: var(--muted); }
.feat li.no::before { content: "–"; color: var(--muted); }
.addon { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; flex-wrap: wrap; }
.total { display: flex; justify-content: space-between; align-items: baseline; border-top: 1px solid var(--border); padding-top: 14px; }
.plan .cta { margin-top: auto; display: grid; gap: 8px; }

/* Checkout steps */
.steps { list-style: none; padding: 0; margin: 24px 0 28px 10px; border-left: 2px solid var(--border-2); }
.steps li { position: relative; padding: 0 0 18px 24px; }
.steps li::before { content: ""; position: absolute; left: -7px; top: 6px; width: 12px; height: 12px; border-radius: 50%; background: var(--bg); border: 2px solid var(--border-2); }
.steps li.done::before { background: var(--good); border-color: var(--good); }
.steps li.now::before { border-color: var(--accent); box-shadow: 0 0 0 4px rgb(239 91 80 / 0.18); }

/* Admin */
.split { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-start; }
.split > .side { flex: 1 1 300px; max-width: 380px; min-width: 0; }
.split > .main { flex: 999 1 520px; min-width: 0; }
.olist { display: flex; flex-direction: column; gap: 2px; margin-top: 18px; }
.oitem { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 1px solid transparent; border-radius: 6px; padding: 12px; min-height: 48px; cursor: pointer; }
.oitem:hover { background: var(--surface-2); }
.oitem.on { background: var(--accent-dim); border-color: rgb(239 91 80 / 0.35); }
.dl { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 12px 20px; margin: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.notice { color: var(--good); font-size: 14px; margin-top: 14px; }
pre.code { margin: 0; padding: 14px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font: 13px var(--mono); overflow-x: auto; color: #d6d6d6; }
.footrow { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

#blazor-error-ui { position: fixed; inset: auto 0 0 0; z-index: 50; padding: 12px 24px; background: #3a1422; color: #ffd0dc; border-top: 1px solid var(--bad); }
#blazor-error-ui a { color: #fff; }

@media (max-width: 1320px) { .who .email { display: none; } }

@media (max-width: 720px) {
    .top-in { padding: 10px 16px; gap: 10px; }
    .nav { order: 3; flex-basis: 100%; overflow-x: auto; flex-wrap: nowrap; }
    .wrap { padding: 28px 16px 100px; }
    .br { padding: 22px 18px; }
    .dl { grid-template-columns: 1fr; }
    .stat { border-right: 0; border-bottom: 1px solid var(--border); }
}

/* Coach */
.lists { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.citem { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 14px 18px; border: 1px solid var(--border); border-radius: 2px; text-decoration: none; color: inherit; }
.citem:hover { background: var(--surface-2); color: inherit; }
.citem .t { font-weight: 600; overflow-wrap: anywhere; }
.citem .big { font: 600 18px var(--mono); white-space: nowrap; }
.citem > div:first-child { min-width: 0; }
.cards { display: flex; flex-direction: column; gap: 28px; }
.linkurl { user-select: all; flex: 1 1 320px; min-width: 0; font: 13px var(--mono); overflow-wrap: anywhere; padding: 11px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 2px; }
table.ctimes { min-width: 0; }
table.ctimes td { padding: 10px 14px; overflow-wrap: anywhere; }
table.ctimes th { padding: 10px 14px; }
.ctimes .big { text-align: right; font: 600 15px var(--mono); white-space: nowrap; }
.ctimes small { display: block; color: var(--muted); font-size: 13px; }
.ctimes .flag { color: var(--warn); }
.ctimes .loose td { color: var(--muted); }
details.fold { margin-top: 18px; }
details.fold > summary { cursor: pointer; color: var(--muted); }

/* Results online */
.rday { border: 1px solid var(--border); border-radius: 2px; }
.rday.on { border-color: var(--border-2); }
.rday .rhead { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.rday.on .rhead { background: var(--surface-2); }
.rbody { padding: 18px; border-top: 1px solid var(--border); }
.rh { font-size: 15px; margin: 26px 0 4px; }
