:root {
  --bg: #15181d;
  --side: #1b1f26;
  --panel: #20252d;
  --panel-2: #272d36;
  --line: #323944;
  --text: #e6e9ee;
  --muted: #8b95a5;
  --accent: #1a9fff;
  --accent-2: #0f7fd6;
  --live: #22c55e;
  --warn: #f5a524;
  --bad: #ef4444;
  --idle: #64748b;
  --radius: 8px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; }
[hidden] { display: none !important; }
a { color: var(--accent); }
svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- buttons, inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 7px 12px; border-radius: 6px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #46505e; background: #2e3540; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: #ffb4b4; }
.btn.danger:hover { background: #3a2023; border-color: #6b2b30; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.wide { width: 100%; justify-content: center; padding: 10px; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--panel-2); border-color: var(--line); }
.icon-btn.on { color: var(--accent); }
input, select, textarea { width: 100%; background: #12151a; color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px; font: inherit; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px #1a9fff33; }
label { display: grid; gap: 5px; color: var(--muted); font-size: 12.5px; }
label > input, label > select { color: var(--text); font-size: 14px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.check input { width: auto; }
.hint { font-size: 12px; color: var(--muted); }
.form-error { color: #ff8a8a; min-height: 1.2em; font-size: 13px; }

/* switch */
.switch { position: relative; width: 38px; height: 21px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #3a424e; border-radius: 21px; transition: .15s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 15px; height: 15px; left: 3px; top: 3px; background: #cfd5dd; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(17px); background: #fff; }
.switch input:disabled + span { opacity: .5; cursor: default; }

/* ---------- sign-in */
.screen { min-height: 100%; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 50% -10%, #1d2a3a 0%, var(--bg) 60%); }
.login-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px;
  display: grid; gap: 14px; box-shadow: 0 20px 60px #0008; }
.login-card h1 { font-size: 22px; }
.login-card p { margin: 0; }

/* ---------- shell */
#shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100%; }
.sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px; font-weight: 700; font-size: 16px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.brand-mark.big { width: 48px; height: 48px; border-radius: 11px; }
.brand-mark.big svg { width: 28px; height: 28px; }
.brand-logo { display: block; max-width: 180px; max-height: 40px; object-fit: contain; }
.brand-logo.big { max-width: 280px; max-height: 80px; }
.logo-sample { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 12px 14px;
  background: var(--side); border: 1px solid var(--line); border-radius: 8px; justify-self: start; min-width: 220px; width: max-content; max-width: 100%; }
.logo-sample img { max-width: 180px; max-height: 40px; object-fit: contain; }
.logo-sample.big { flex-direction: column; align-items: flex-start; font-size: 22px; padding: 20px 24px; background: var(--panel); }
.logo-sample.big img { max-width: 280px; max-height: 80px; }
#nav { display: grid; gap: 2px; padding: 10px 8px; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; }
#nav a:hover { color: var(--text); background: var(--panel); }
#nav a.active { color: #fff; background: #1a9fff22; box-shadow: inset 3px 0 0 var(--accent); }
.nav-group { margin: 14px 12px 4px; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: #6b7585; }
.sidebar-foot { margin-top: auto; padding: 12px 16px; font-size: 12px; border-top: 1px solid var(--line); display: grid; gap: 4px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--side);
  position: sticky; top: 0; z-index: 5; }
.topbar h2 { font-size: 17px; }
.top-chips { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
.menu-btn { display: none; }
.user-menu { position: relative; }
.role-tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  min-width: 180px; padding: 4px; box-shadow: 0 10px 30px #0009; z-index: 20; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 8px 10px;
  border-radius: 5px; font: inherit; cursor: pointer; }
.menu button:hover { background: var(--panel-2); }
#page { padding: 20px; display: grid; gap: 18px; align-content: start; }
.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: 8px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.banner.warn { background: #3a2c10; border: 1px solid #6b5016; color: #ffd98a; }

/* chips / status */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; }
.dot.live { background: var(--live); box-shadow: 0 0 0 3px #22c55e33; }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.dot.wait { background: var(--accent); }
.state { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.state.live { color: var(--live); }
.state.wait { color: #7cc4ff; }
.state.warn { color: var(--warn); }
.state.bad { color: var(--bad); }
.state.idle { color: var(--muted); }
.tag { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: #1a9fff22; color: #7cc4ff; text-transform: uppercase; }

/* ---------- dashboard */
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; font-weight: 600; }
.stat span { color: var(--muted); font-size: 12px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.empty { text-align: center; padding: 40px 20px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); flex-wrap: wrap; }
.card-head h3 { font-size: 15px; }
.card-head .spacer { flex: 1; }

/* one row per input: preview · input · arrow · destinations */
.in-list { display: grid; gap: 10px; }
.in-row { display: grid; grid-template-columns: 236px minmax(170px, 230px) 22px minmax(0, 1fr); gap: 14px; padding: 10px; align-items: start; overflow: visible; }
.pv { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 10px; gap: 4px; }
.pv .vu { width: 10px; padding: 2px 1px; gap: 1px; }
.pv-off { display: none; }
.pv.off .player, .pv.off .vu { display: none; }
.pv.off .pv-off { display: grid; place-items: center; grid-column: 1 / -1; aspect-ratio: 16 / 9; width: 100%; max-height: 64px; border: 1px dashed var(--line); border-radius: 6px; }
.player { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 6px; overflow: hidden; min-width: 0; }
.player video, .player canvas { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.player .nosignal { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: #9aa4b2;
  background: repeating-linear-gradient(90deg, #1b1f26 0 12.5%, #20252d 12.5% 25%); font-size: 11.5px; }
.player .nosignal b { display: block; font-size: 12.5px; color: #cfd5dd; letter-spacing: .08em; }
.player .overlay { position: absolute; left: 5px; top: 5px; display: flex; gap: 4px; pointer-events: none; }
.player .overlay span { background: #000a; color: #fff; font-size: 10.5px; padding: 1px 5px; border-radius: 3px; font-family: var(--mono); }
.player .controls { position: absolute; right: 5px; bottom: 5px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.player:hover .controls, .player:focus-within .controls, .player .controls:has(.on) { opacity: 1; }
.player .controls button { background: #000b; color: #fff; border: 1px solid #ffffff30; border-radius: 4px; padding: 3px 5px; font: inherit;
  cursor: pointer; display: inline-flex; align-items: center; }
.player .controls button.on { background: var(--accent); border-color: var(--accent); }
.player .controls svg { width: 14px; height: 14px; }
.player:fullscreen .nosignal { font-size: 15px; }
.vu { align-self: stretch; width: 18px; background: #0c0e12; border-radius: 4px; display: flex; gap: 2px; padding: 3px 2px; }
.vu i { flex: 1; position: relative; background: #1d222a; border-radius: 2px; overflow: hidden; }
.vu i b { position: absolute; left: 0; right: 0; bottom: 0; height: 0;
  background: linear-gradient(to top, #22c55e 0%, #22c55e 65%, #f5a524 80%, #ef4444 95%); background-size: 100% var(--h, 100px); background-position: bottom; }

.in-info { display: grid; gap: 5px; min-width: 0; align-content: start; }
.in-title { display: flex; align-items: center; gap: 8px; }
.in-title h3 { font-size: 15px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.in-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rate-line { display: flex; align-items: baseline; gap: 6px; }
.rate-line b { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dir { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.in-media { font-size: 12px; color: var(--muted); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.in-actions { display: flex; gap: 6px; align-items: center; margin-top: 2px; flex-wrap: wrap; }
.arrow { color: #46505e; align-self: center; display: grid; place-items: center; }
.arrow svg { width: 22px; height: 22px; }

.route { min-width: 0; display: grid; gap: 4px; align-content: start; }
.route-head { display: flex; align-items: center; gap: 10px; font-size: 11.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.route-head span { flex: 1; }
.dests { display: grid; gap: 4px; }
.dest { background: #1a1e25; border: 1px solid #2a303a; border-radius: 6px; padding: 4px 6px 4px 10px; min-width: 0; }
.d-main { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 28px; }
.d-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.d-main .grow { flex: 1; }
.d-main .tag { flex: none; }
.tag.re { background: #f5a52422; color: #f5c46b; }
.d-state { font-size: 11.5px; font-weight: 600; white-space: nowrap; color: var(--muted); }
.d-state.live { color: var(--live); } .d-state.warn { color: var(--warn); } .d-state.bad { color: var(--bad); } .d-state.wait { color: #7cc4ff; }
.d-rate { font-family: var(--mono); font-size: 12px; white-space: nowrap; min-width: 92px; text-align: right; color: var(--text); }
.d-rate:empty { min-width: 0; }
.icon-btn.sm { width: 26px; height: 26px; }
.d-err { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0 0 2px 16px; color: #ff9b9b; font: inherit; font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.d-err:hover { text-decoration: underline; }
.dest-empty { color: var(--muted); font-size: 12.5px; padding: 8px 10px; border: 1px dashed var(--line); border-radius: 6px; }

.info { display: grid; gap: 12px; align-content: start; min-width: 0; }
.info h4 { margin: 0 0 4px; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* stream log */
.log-tools select, .log-tools input { width: auto; min-width: 150px; padding: 5px 8px; font-size: 13px; }
.log-tools input { min-width: 180px; }
.log { background: #12151a; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.log .empty { border: 0; }
.log-row { display: grid; grid-template-columns: 76px 64px minmax(80px, 200px) 64px minmax(0, 1fr); gap: 10px; padding: 4px 10px;
  border-top: 1px solid #1f242c; font-size: 12.5px; align-items: baseline; }
.log-row:first-child { border-top: 0; }
.log-row time, .log-row .src { color: var(--muted); font-family: var(--mono); font-size: 11.5px; white-space: nowrap; }
.log-row .lv { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.log-row .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-row .msg { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }
.log-row .cnt { color: var(--muted); font-weight: 600; }
.log-row.lv-warn { background: #f5a5240a; } .log-row.lv-warn .lv { color: var(--warn); }
.log-row.lv-error { background: #ef444414; } .log-row.lv-error .lv { color: var(--bad); } .log-row.lv-error .msg { color: #ffb4b4; }
.url-row { display: flex; align-items: center; gap: 6px; background: #12151a; border: 1px solid var(--line); border-radius: 6px; padding: 4px 4px 4px 8px; min-width: 0; }
.url-row .tag { flex: none; }
.url-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.url-list { display: grid; gap: 5px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }


/* ---------- forms and tables */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 14px; }
.panel h3 { font-size: 15px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.port-row { display: grid; grid-template-columns: 150px 120px 1fr; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid #2a303a; }
.port-row:first-of-type { border-top: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #2a303a; vertical-align: middle; }
th { font-size: 11.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
.ok { color: var(--live); }
.no { color: var(--bad); }
.console { background: #0b0d10; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-family: var(--mono); font-size: 12px;
  white-space: pre-wrap; max-height: 360px; overflow: auto; margin: 0; color: #c9d1d9; }

/* ---------- dialog, toasts */
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(560px, calc(100% - 32px));
  box-shadow: 0 30px 80px #000c; }
dialog::backdrop { background: #0009; }
#dialog-form { display: grid; gap: 14px; padding: 20px; }
#dialog-form h3 { font-size: 17px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.secret-box { background: #12151a; border: 1px dashed var(--accent); border-radius: 8px; padding: 12px; font-family: var(--mono); font-size: 16px;
  text-align: center; user-select: all; overflow-wrap: anywhere; }
.service-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.service-pick label { display: block; }
.service-pick input { position: absolute; opacity: 0; width: 0; }
.service-pick span { display: block; text-align: center; padding: 8px 4px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); cursor: pointer; font-size: 12.5px; }
.service-pick input:checked + span { border-color: var(--accent); background: #1a9fff22; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--panel-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 6px;
  box-shadow: 0 10px 30px #0009; max-width: 360px; }
.toast.bad { border-left-color: var(--bad); }

/* ---------- address builder */
.field { display: grid; gap: 6px; }
.field-label { color: var(--muted); font-size: 12.5px; }
.urlb { display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: #1a1e25; }
.urlb-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.urlb-head select { width: auto; min-width: 150px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { background: none; border: 0; color: var(--muted); padding: 6px 12px; font: inherit; font-size: 12.5px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: #1a9fff22; color: var(--text); }
.urlb-fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
.part { display: grid; gap: 5px; grid-column: span 3; align-content: start; }
.part-label { color: var(--muted); font-size: 12.5px; }
.part.part-wide { grid-column: span 4; }
.part.part-wide + .part { grid-column: span 2; }
.part.part-full { grid-column: 1 / -1; }
.part .seg { justify-self: start; }
.urlb-out code { white-space: normal; overflow-wrap: anywhere; }
.urlb-format code { font-family: var(--mono); color: #c9d1d9; }
.urlb-msg { font-size: 12.5px; min-height: 1.2em; }
.urlb-msg.ok { color: var(--live); }
.urlb-msg.bad, .urlb-msg .bad, .urlb .bad { color: #ff8a8a; }
.urlb-msg .ok { color: var(--live); }

/* ---------- Kiloview-style forms: label on the left, control on the right */
.kv-form { display: grid; gap: 12px; }
.kv-section { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: #7cc4ff;
  border-bottom: 1px solid var(--line); padding: 8px 0 6px; margin-top: 4px; }
.kv-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 16px; align-items: start; }
.kv-label { color: #aeb7c4; font-size: 13px; text-align: right; padding-top: 8px; }
.kv-ctl { display: grid; gap: 6px; min-width: 0; }
.kv-ctl > select, .kv-ctl > input { max-width: 520px; }
.seg.yn { justify-self: start; }
.kv-text { padding-top: 8px; }
.kv-form > h3 { font-size: 15px; }
.seg.yn button { min-width: 56px; }

/* ---------- admin tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs a { padding: 9px 16px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: #fff; border-bottom-color: var(--accent); }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 16px; color: var(--muted); font: inherit; cursor: pointer; white-space: nowrap; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: #fff; border-bottom-color: var(--accent); }
.src-panel { display: grid; gap: 14px; border: 1px solid var(--line); border-radius: 8px; padding: 0 14px 14px; }
.src-tabs { margin: 0 -14px; padding: 0 8px; }
.tab-body { display: grid; gap: 18px; align-content: start; }

/* ---------- installer terminal */
.term-dialog { width: min(1100px, calc(100% - 32px)); }
.term-panel { display: grid; gap: 12px; padding: 16px; }
.term { background: #0b0d10; border: 1px solid var(--line); border-radius: 6px; padding: 6px; height: min(520px, 62vh); }
.term.plain { height: auto; display: grid; gap: 8px; }
.term .xterm { height: 100%; }

/* ---------- welcome tour */
.tour { position: fixed; inset: 0; z-index: 100; }
.tour.dim { background: #000a; }
.tour-hole { position: fixed; border-radius: 8px; box-shadow: 0 0 0 9999px #000a, 0 0 0 2px var(--accent) inset; pointer-events: none;
  transition: all .2s; }
.tour-tip { position: fixed; width: min(340px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--accent); border-radius: 10px;
  padding: 16px; box-shadow: 0 20px 60px #000c; display: grid; gap: 8px; }
.tour-tip h3 { font-size: 16px; }
.tour-tip p { margin: 0; color: #c3cad5; }
.tour-step { font-size: 11.5px; color: var(--muted); }
.tour-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.tour-actions .grow { flex: 1; }

/* ---------- help */
.manual-wrap { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.manual-toc { position: sticky; top: 70px; display: grid; gap: 2px; font-size: 13px; }
.manual-toc b { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.manual-toc a { color: var(--muted); text-decoration: none; padding: 4px 8px; border-radius: 5px; }
.manual-toc a:hover { color: var(--text); background: var(--panel); }
.manual-toc .btn { margin-top: 12px; justify-self: start; }
.manual { max-width: 880px; line-height: 1.6; }
.manual h1 { font-size: 24px; margin-bottom: 6px; }
.manual h2 { font-size: 19px; margin: 34px 0 10px; padding-top: 14px; border-top: 1px solid var(--line); scroll-margin-top: 70px; }
.manual h3 { font-size: 15px; margin: 20px 0 6px; }
.manual h4 { font-size: 14px; margin: 16px 0 6px; color: var(--muted); }
.manual p, .manual li { color: #c9d0da; }
.manual code { font-family: var(--mono); font-size: 12.5px; background: #12151a; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.manual figure { margin: 14px 0 18px; }
.manual figure img { display: block; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px #0007; }
.manual figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.manual .note { border-left: 3px solid var(--accent); background: #1a9fff14; padding: 8px 12px; border-radius: 0 6px 6px 0; }
.manual .kbd { font-family: var(--mono); font-size: 12px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; }
.manual table { margin: 8px 0 14px; font-size: 13px; }

/* ---------- small screens */
@media (max-width: 1100px) {
  .in-row { grid-template-columns: 200px minmax(0, 1fr); }
  .in-row .arrow { display: none; }
  .in-row .route { grid-column: 1 / -1; }
}
/* tablets and phones: the menu slides in from the left with the ☰ button (computers keep it open) */
@media (max-width: 1100px), (pointer: coarse) and (max-width: 1366px) {
  #shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .22s ease;
    overflow-y: auto; }
  #shell.nav-open .sidebar { transform: none; box-shadow: 0 0 60px #000c; }
  #shell.nav-open::after { content: ""; position: fixed; inset: 0; background: #0007; z-index: 25; }
  .menu-btn { display: inline-grid; width: 40px; height: 40px; place-items: center; }
  #nav a { padding: 12px 14px; }            /* bigger to tap */
  .btn, select, input { min-height: 36px; }
  .topbar { flex-wrap: wrap; row-gap: 6px; }
  .top-chips { order: 5; width: 100%; margin-left: 0; }
  .company-pick select { min-width: 0; max-width: 46vw; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .toolbar { flex-wrap: wrap; }
  .backup-top .chip { white-space: normal; }
}
@media (max-width: 800px) {
  #page { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .top-chips { display: none; }
  .banner { margin: 12px 16px 0; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .port-row { grid-template-columns: 1fr 100px; }
  .port-row .hint { grid-column: 1 / -1; }
  .in-row { grid-template-columns: 1fr; }
  .log-row { grid-template-columns: 64px 1fr; }
  .log-row .who, .log-row .src { display: none; }
  .log-row .msg { grid-column: 1 / -1; }
  .d-rate { min-width: 0; }
  .d-main { flex-wrap: wrap; row-gap: 2px; }
  .d-main .grow { flex: 1 0 100%; height: 0; }
  .d-main .d-state { margin-left: 16px; }
  .d-main .d-rate { flex: 1; text-align: left; }
  .service-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .urlb-fields { grid-template-columns: 1fr; }
  .part, .part.part-wide, .part.part-wide + .part { grid-column: 1 / -1; }
  .kv-row { grid-template-columns: 1fr; gap: 6px; }
  .kv-label { text-align: left; padding-top: 0; }
  .manual-wrap { grid-template-columns: 1fr; }
  .manual-toc { position: static; }
  .hide-small { display: none; }
  .term { height: 340px; }
}

/* plain words first, the technical term as a small hint beside them */
.term { font-size: 10.5px; font-weight: 600; letter-spacing: .04em; color: var(--muted); border: 1px solid var(--line);
  border-radius: 4px; padding: 0 5px; margin-left: 4px; vertical-align: 1px; text-transform: lowercase; }
.src-tabs button { text-align: left; line-height: 1.25; }
.src-tabs button small { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
.dest.placeholder { border-style: dashed; background: transparent; }
.dest.placeholder .d-name { color: var(--muted); }
.sidebar-foot .version { color: var(--muted); opacity: .8; }

/* the footer disclaimer (Admin ▸ Branding) */
.app-footer { padding: 10px 20px 14px; font-size: 11.5px; color: var(--muted); white-space: pre-wrap; text-align: center; margin-top: auto; }
.screen .app-footer { max-width: 560px; margin: 16px auto 0; padding: 0 16px; }

/* messages from an administrator: stay on screen until "OK, got it" */
.messages { position: fixed; top: 64px; right: 16px; width: min(380px, calc(100vw - 32px)); display: grid; gap: 10px; z-index: 60; }
.msg { background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 8px;
  padding: 12px 14px; display: grid; gap: 8px; box-shadow: 0 8px 24px #0008; }
.msg.warning { border-left-color: var(--warn); }
.msg-head { font-size: 12.5px; }
.msg-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.pick-users { display: grid; gap: 6px; max-height: 220px; overflow: auto; }
.warn-tag { background: #f5a52422; color: var(--warn); }

/* the sign-out countdown */
.signout { position: fixed; inset: 0; background: #000b; display: grid; place-items: center; z-index: 100; padding: 16px; }
.signout-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: min(420px, 100%);
  text-align: center; display: grid; gap: 10px; }
.signout-card .toolbar { justify-content: center; }
.signout-count { font-size: 56px; font-weight: 700; line-height: 1; color: var(--warn); font-variant-numeric: tabular-nums; }

/* companies and the admin portal */
#company-box:empty { display: none; }
.company-chip span svg, .company-pick span svg { width: 15px; height: 15px; fill: currentColor; }
.company-pick { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.company-pick select { width: auto; min-width: 140px; padding: 5px 8px; }
.nav-note { margin: 14px 12px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.staff-tag { background: #1a9fff22; color: var(--accent); }
body.portal .sidebar { box-shadow: inset 0 3px 0 var(--accent); }
.net-block + .net-block { margin-top: 8px; }
.net-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin: 4px 0; }
.net-head code { color: var(--text); }
tr.off-row td { opacity: .55; }
tr.off-row td:last-child, tr.off-row td:nth-last-child(3) { opacity: 1; }
.tabs a small { margin-left: 6px; color: var(--muted); font-size: 11.5px; }
.pager { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; }
.pager select { padding: 4px 6px; }
.backup-top { padding: 10px 14px; margin-bottom: 12px; }
.pause-sw { gap: 8px; margin-right: 18px; }
.warn-chip { border-color: #6b5016; }
.log.no-src .log-row { grid-template-columns: 76px 64px minmax(80px, 200px) minmax(0, 1fr); }

/* admin portal ▸ System: the monitors */
.monitor-head { padding: 10px 14px; margin-bottom: 12px; }
.mon-cards .stat.mon { display: grid; gap: 4px; }
.mon-cards .stat.mon > span { order: -1; color: var(--muted); font-size: 12px; }
.meter { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin: 4px 0; }
.meter i { display: block; height: 100%; background: var(--accent); }
.meter.warm i { background: var(--warn); }
.meter.hot i { background: var(--bad); }
.spark { height: 46px; color: var(--accent); }
.spark svg { width: 100%; height: 100%; display: block; }
.spark2 { display: grid; }
.spark2 .spark { height: 23px; }
.spark svg.rx { color: var(--live); }
.spark svg.tx { color: var(--accent); }
.mon-co { cursor: pointer; }
.mon-co:hover td { background: #ffffff08; }
.mon-sub td { font-size: 12.5px; background: #00000022; }
.mon-sub td:first-child { padding-left: 28px; }
