/* Token names and values follow the MKA-925 admin style sheet. Rules below :root use the names only. */
@font-face { font-family: "Fira Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/fira-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Fira Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/fira-sans-latin-600-normal.woff2") format("woff2"); }

:root {
    --surface-app: #F3ECDD;
    --surface-panel: #FAF6EC;
    --surface-raised: #FFFDF8;
    --surface-sunken: #E8DFCB;
    --ink-strong: #231D18;
    --ink-muted: #5A5044;
    --ink-inverse: #FAF6EC;
    --line-control: #7A6D5C;
    --line-rule: #D8CDB6;
    --brand-felt: #2F6B4A;
    --accent-primary: #1F5C7A;
    --accent-positive: #2D6A47;
    --accent-caution: #A63F1C;
    --accent-warm: #B8721E;
    --brand-ink: #231D18;
    --brand-cream: #F3ECDD;
    --brand-brass: #D9A441;
    --board-slate: #2C3841;
    --board-chalk-dim: #B8B4A6;
    --font: "Fira Sans", "DejaVu Sans", sans-serif;
    --font-mono: "Fira Mono", "DejaVu Sans Mono", monospace;
}
* { box-sizing: border-box; }
body { margin: 0; font: 400 14px/20px var(--font); color: var(--ink-strong); background: var(--surface-app); font-variant-numeric: tabular-nums lining-nums; }
h1 { margin: 0 0 24px; font-size: 28px; line-height: 36px; font-weight: 600; }
h2 { margin: 32px 0 16px; font-size: 16px; line-height: 24px; font-weight: 600; }
h3 { margin: 24px 0 8px; font-size: 16px; line-height: 24px; font-weight: 600; }
p { margin: 0 0 12px; }
code, pre { font-family: var(--font-mono); font-size: 13px; line-height: 20px; }
a { color: var(--accent-primary); }
:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side-nav { background: var(--brand-ink); color: var(--brand-cream); display: flex; flex-direction: column; padding: 16px 0; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 24px 24px; font-size: 16px; font-weight: 600; }
.brand .mark { width: 32px; height: 32px; flex: none; }
.brand small { display: block; font-size: 10px; line-height: 12px; letter-spacing: 0.12em; font-weight: 400; color: var(--board-chalk-dim); }
.side-nav a { color: var(--brand-cream); text-decoration: none; padding: 0 24px; line-height: 40px; border-left: 4px solid transparent; }
.side-nav a:hover { background: var(--board-slate); }
.side-nav a.active { border-left-color: var(--brand-brass); background: var(--board-slate); font-weight: 600; }
.side-nav :focus-visible { outline-color: var(--brand-cream); }
.who { margin-top: auto; padding: 16px 24px 0; border-top: 1px solid var(--board-chalk-dim); display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.who button { background: transparent; color: var(--brand-cream); border-color: var(--board-chalk-dim); }
.main-column { min-width: 0; }
.top-bar { height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 32px; background: var(--surface-panel); border-bottom: 1px solid var(--line-rule); }
.breadcrumb { margin: 0; flex: 1; color: var(--ink-muted); }
.breadcrumb strong { color: var(--ink-strong); font-weight: 600; }
.env-tag { background: var(--brand-brass); color: var(--ink-strong); padding: 0 8px; border-radius: 2px; font-size: 12px; line-height: 22px; font-weight: 600; letter-spacing: 0.06em; }
.content { padding: 32px; max-width: 1360px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.tile, .panel { background: var(--surface-raised); border: 1px solid var(--line-rule); padding: 20px; }
.tile-label { color: var(--ink-muted); margin-bottom: 8px; font-size: 12px; line-height: 16px; text-transform: uppercase; letter-spacing: 0.06em; }
.skeleton { height: 32px; background: var(--surface-sunken); }
.empty { color: var(--ink-muted); }
.bare { max-width: 380px; margin: 25vh auto 32px; padding: 0 16px; }
.bare .brand { padding: 0 0 24px; }
.bare .brand small { color: var(--ink-muted); }
.mk-bg { fill: var(--brand-cream); }
.mk-pip { fill: var(--brand-ink); }
.mk-accent { fill: var(--brand-brass); }
.bare .mk-bg { fill: var(--brand-ink); }
.bare .mk-pip { fill: var(--brand-cream); }
.card { background: var(--surface-raised); border: 1px solid var(--line-rule); padding: 24px; display: grid; gap: 16px; }
.card h1 { font-size: 20px; line-height: 28px; margin: 0; }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--surface-raised); border: 1px solid var(--line-rule); }
th, td { text-align: left; padding: 0 16px; height: 48px; border-bottom: 1px solid var(--line-rule); }
th { height: 40px; background: var(--surface-sunken); font-weight: 600; }
td input { width: 100%; }
tr.read td { color: var(--ink-muted); }
.muted { color: var(--ink-muted); }

/* Controls */
label { display: grid; gap: 4px; color: var(--ink-muted); }
input, textarea, select { font: inherit; min-height: 40px; padding: 0 12px; border: 2px solid var(--line-control); border-radius: 4px; background: var(--surface-raised); color: var(--ink-strong); }
textarea { padding: 8px 12px; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--accent-caution); }
button { font: inherit; min-height: 40px; padding: 0 16px; background: var(--brand-felt); color: var(--ink-inverse); border: 2px solid var(--brand-felt); border-radius: 4px; cursor: pointer; transition: background-color 120ms ease-out; }
button:disabled { opacity: 0.5; cursor: default; }
button.secondary { background: var(--surface-raised); color: var(--ink-strong); border-color: var(--line-control); }
button.danger { background: var(--accent-caution); border-color: var(--accent-caution); color: var(--ink-inverse); }
@media (prefers-reduced-motion: reduce) { button { transition: none; } }
.error { color: var(--accent-caution); font-size: 12px; line-height: 16px; font-weight: 600; margin: 0; }
.qr { width: 220px; background: var(--surface-raised); }
.qr svg { width: 100%; height: auto; display: block; }
.secret { font-family: var(--font-mono); font-size: 20px; line-height: 28px; letter-spacing: 0.04em; margin: 0; }
.help { font-size: 12px; line-height: 16px; color: var(--ink-muted); margin: 0; }
.filters { display: flex; gap: 16px; align-items: end; margin-bottom: 16px; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; border-bottom: 1px solid var(--line-rule); }
.tabs .tab { background: transparent; color: var(--ink-strong); border-color: transparent; border-radius: 0; border-bottom: 3px solid transparent; }
.tabs .tab.active { border-bottom-color: var(--brand-felt); font-weight: 600; }
.actions, .row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
td.row-actions, td .row-actions { margin: 0; }

/* Status: dot plus word, never colour alone */
.status { display: inline-flex; align-items: center; gap: 8px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-muted); flex: none; }
.status.ok .dot { background: var(--accent-positive); }
.status.bad .dot, .status.refused .dot, .status.failed .dot { background: var(--accent-caution); }
.status.info .dot { background: var(--accent-primary); }
.status.pending .dot { background: var(--accent-warm); }
td .status { margin-left: 8px; }
.badge { border: 1px solid var(--line-rule); border-radius: 2px; padding: 0 8px; font-size: 12px; line-height: 20px; }

/* Banner: 48 high, ink.strong text, border carries the kind */
.banner { margin: 0 0 16px; min-height: 48px; padding: 8px 16px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--line-rule); border-left-width: 4px; background: var(--surface-raised); }
.banner .banner-body { flex: 1; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; }
.banner .banner-body > :last-child { margin-bottom: 0; }
.banner.error { border-color: var(--accent-caution); color: var(--ink-strong); font-size: 14px; line-height: 20px; font-weight: 400; }
.banner.warn { border-color: var(--accent-warm); }
.banner.info { border-color: var(--accent-primary); }
.banner.error .dot { background: var(--accent-caution); }
.banner.warn .dot { background: var(--accent-warm); }
.banner.info .dot { background: var(--accent-primary); }
.banner .status { font-weight: 600; }

/* Modal */
.scrim { position: fixed; inset: 0; background: color-mix(in srgb, var(--ink-strong) 60%, transparent); display: grid; place-items: center; z-index: 10; }
.modal { background: var(--surface-raised); border: 1px solid var(--line-rule); padding: 24px; width: min(640px, 90vw); max-height: 90vh; overflow: auto; display: grid; gap: 16px; }
.modal h2, .modal h3 { margin: 0; }
.modal .banner { margin: 0; }
.modal .actions { justify-content: flex-end; margin: 0; position: sticky; bottom: -24px; background: var(--surface-raised); padding: 12px 0 24px; margin-bottom: -24px; }

pre.json { background: var(--surface-raised); border: 1px solid var(--line-rule); padding: 16px; overflow: auto; max-height: 360px; }
.del { background: color-mix(in srgb, var(--accent-caution) 10%, transparent); }
.add { background: color-mix(in srgb, var(--accent-positive) 10%, transparent); }

th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
.modal select { width: 100%; }

/* Dashboard */
.tile-value { font-size: 28px; line-height: 36px; font-weight: 600; font-variant-numeric: tabular-nums; }
.caution { color: var(--accent-caution); font-weight: 600; }

td.reason { max-width: 420px; padding-top: 8px; padding-bottom: 8px; }
td.reason > div { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.dashboard { max-width: 1136px; }
.panels { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; margin-top: 24px; }
.panel { padding: 0; }
.panel h2 { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line-rule); }
.panel table { border: 0; }
.panel tr:last-child td { border-bottom: 0; }
.dashboard .help { margin-top: 16px; }
.tile-value .badge { font-size: 14px; line-height: 28px; padding: 0 12px; }

/* Tournaments (MKA-1072) */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.page-head .row-actions { margin: 0 0 16px; align-items: flex-start; }
a.button { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; background: var(--brand-felt); color: var(--ink-inverse); border: 2px solid var(--brand-felt); border-radius: 4px; text-decoration: none; }
a.button.secondary { background: var(--surface-raised); color: var(--ink-strong); border-color: var(--line-control); }
.tabs a.tab { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; color: var(--ink-strong); text-decoration: none; border-bottom: 3px solid transparent; }
.tabs a.tab.active { border-bottom-color: var(--brand-felt); font-weight: 600; }
.tabs .count { color: var(--ink-muted); margin-left: 4px; }
.tournament-table code.id { display: inline-block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.fill { display: inline-block; width: 80px; height: 8px; background: var(--surface-sunken); vertical-align: middle; margin-right: 8px; }
.fill > span { display: block; height: 100%; background: var(--brand-felt); }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
.with-reason { display: flex; flex-direction: column; gap: 4px; max-width: 220px; }
.with-reason .muted { font-size: 12px; line-height: 16px; }
.card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card h2 { margin: 0; }
.card .big { font-size: 28px; line-height: 36px; font-weight: 600; margin: 0; }
dl.facts, dl.totals { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; }
dl.facts dt, dl.totals dt { color: var(--ink-muted); }
dl.facts dd, dl.totals dd { margin: 0; }
dl.totals dd { text-align: right; }
ul.links { margin: 0; padding-left: 20px; }
.pay-table caption { text-align: left; padding-bottom: 8px; }
.form-layout { display: grid; grid-template-columns: minmax(0, 760px) 352px; gap: 24px; align-items: start; }
.form-layout fieldset { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 16px; }
.form-layout .grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-layout label { display: grid; gap: 4px; }
.form-layout label.check { display: flex; align-items: center; gap: 8px; }
.form-layout label.switch { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
input.switch, input[role="switch"] { appearance: none; width: 40px; height: 24px; border-radius: 12px; border: 1px solid var(--line-rule); background: var(--surface-raised); position: relative; cursor: pointer; flex: none; padding: 0; }
input.switch::after, input[role="switch"]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--ink-muted); transition: transform 120ms; }
input.switch:checked, input[role="switch"]:checked { background: var(--accent-primary); border-color: var(--accent-primary); }
input.switch:checked::after, input[role="switch"]:checked::after { background: var(--ink-inverse); transform: translateX(16px); }
input[role="switch"]:disabled { opacity: 0.5; cursor: default; }
.form-layout .preview { position: sticky; top: 16px; background: var(--surface-raised); border: 1px solid var(--line-rule); padding: 24px; display: grid; gap: 16px; }
.form-layout .preview h2 { margin: 0; }
.form-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; padding: 16px 0; border-top: 1px solid var(--line-rule); }
.badge.changed { margin-left: 8px; color: var(--accent-warm); border-color: var(--accent-warm); }
.template-table input:not([type="checkbox"]) { width: 100%; max-width: 240px; }
.draft-panel { margin-top: 24px; max-width: 760px; }
.draft-panel .when { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.sub-tabs { margin-top: -8px; }
