:root {
  --bg: #f4f5f7; --surface: #fff; --text: #1b2330; --muted: #5d6878; --line: #dde1e7;
  --accent: #0b5fb0; --accent-text: #fff; --ok: #19703c; --ok-bg: #e3f4e9; --bad: #a3261d; --bad-bg: #fbe7e5;
  --warn: #7a4d00; --warn-bg: #fdf1d3; --code-bg: #eef0f3;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --surface: #1b212a; --text: #e6eaf0; --muted: #9aa5b4; --line: #2e3744;
    --accent: #5aa7ee; --accent-text: #0c1117; --ok: #7dd79c; --ok-bg: #173323; --bad: #ff9c92; --bad-bg: #3d1c19;
    --warn: #f2c86b; --warn-bg: #3a2e12; --code-bg: #262e39;
  }
}
* { box-sizing: border-box; }
/* Rows that set their own display would otherwise ignore the hidden attribute. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 "Segoe UI", system-ui, sans-serif; }
h1, h2 { margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.3rem; } h2 { font-size: 1.1rem; }
a { color: var(--accent); }
code { background: var(--code-bg); padding: .1rem .35rem; border-radius: 4px; font: 13px Consolas, monospace; word-break: break-all; }
.muted, small { color: var(--muted); } small { display: block; font-size: .8rem; margin-top: .15rem; }
.error { color: var(--bad); min-height: 1.2em; margin: .5rem 0 0; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; } .brand span { color: var(--muted); font-weight: 400; margin-left: .4rem; }
.top-right { display: flex; align-items: center; gap: .9rem; }
main { max-width: 1080px; margin: 0 auto; padding: 1.25rem 16px 3rem; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.card.narrow { max-width: 420px; margin: 3rem auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.row { display: flex; gap: .5rem; align-items: center; }

.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: .6rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; border-radius: 0; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

label { display: block; font-size: .9rem; font-weight: 600; }
input, select, textarea { display: block; width: 100%; margin-top: .25rem; padding: .5rem .6rem; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.check input { width: auto; margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem 1rem; align-items: start; }
.grid .wide, .grid .actions, .grid .check { grid-column: 1 / -1; }
.actions { margin-top: .9rem; }

button { font: inherit; padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; }
button:hover { border-color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
button.small { padding: .25rem .55rem; font-size: .85rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
.lines { margin-top: 1rem; } .lines input, .lines select { margin: 0; } .lines td { vertical-align: middle; }
.lines input[type=number] { text-align: right; min-width: 6rem; }

.pill { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--code-bg); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

.notice, .warn, .keybox { border-radius: 6px; padding: .7rem .9rem; margin-bottom: 1rem; }
.notice { background: var(--ok-bg); color: var(--ok); } .notice.bad { background: var(--bad-bg); color: var(--bad); }
.warn { background: var(--warn-bg); color: var(--warn); }
.keybox { border: 1px dashed var(--accent); margin: 1rem 0 0; }
.keyrow { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }

.terminal { border-top: 1px solid var(--line); padding: .9rem 0; }
.terminal:first-child { border-top: 0; }
.terminal-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: baseline; }
.terminal-name { font-weight: 600; font-size: 1.05rem; margin-right: .5rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .4rem 1rem; margin: .6rem 0; }
.facts div span { display: block; font-size: .78rem; color: var(--muted); }
.terminal .row { flex-wrap: wrap; }

.result { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1.25rem; align-items: start; }
.result .qr svg { width: 190px; height: 190px; background: #fff; padding: 6px; border-radius: 6px; display: block; }
.result dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1rem; margin: .6rem 0; }
.result dt { color: var(--muted); } .result dd { margin: 0; word-break: break-all; }
details { margin-top: .8rem; } pre { background: var(--code-bg); padding: .7rem; border-radius: 6px; overflow-x: auto; font: 12px Consolas, monospace; }
@media (max-width: 620px) { .result { grid-template-columns: 1fr; } }

.alerts { border-color: var(--bad); }
.alerts h2 { color: var(--bad); }
.alerts ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.alerts li { margin: .25rem 0; }

/* Cards for the gateway's own settings: shown to operators only. */
body:not(.operator) .op-only { display: none !important; }
#business-picker { width: auto; margin: 0; padding: .3rem .5rem; }

/* The setup checklist on the Terminals tab. */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { padding: .4rem 0; border-top: 1px solid var(--line); }
.checklist li:first-child { border-top: 0; }
.checklist li.done { color: var(--muted); }
.checklist .tick { display: inline-block; width: 1.2rem; color: var(--ok); font-weight: 700; }
.checklist small { margin-left: 1.5rem; }
