/* TA2CX console: the TA2CX PWA design language (ta2cx-pwa-design-language.md,
   from Navigation Instruments), plus the console's own components drawn the
   same way. Hard rules: monospace everywhere; real upper case in the DOM
   (this file never uses text-transform); border-radius 0 everywhere; outline
   buttons, filled only for "on" states; hover = color-mix(..., var(--bg)). */

/* ── 3. Typography ───────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Intel One Mono';
  src: url("../fonts/IntelOneMono-Regular.61c991ec3193.woff2") format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Intel One Mono';
  src: url("../fonts/IntelOneMono-Bold.4d6f48c3b565.woff2") format('woff2');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ── 2. Color system ─────────────────────────────────────────────────────── */
:root {
  --bg:    #000000;
  --s1:    #060606;
  --s2:    #040404;
  --s3:    #0a0a0a;
  --b1:    #2a2a2a;
  --b2:    #444444;
  --tx:    #f0f0f0;
  --tx2:   #d8d8d8;
  --tx3:   #aaaaaa;
  --acc:   #008FBF;
  --acc2:  #5c9bff;
  --warn:  #e6a817;
  --err:   #e05555;
  --ok:    #4ecf6e;
  --mn: 'Intel One Mono','Menlo','Consolas','DejaVu Sans Mono','Courier New',monospace;
  color-scheme: dark;
}
:root.light {
  --bg:    #f4f4f4;
  --s1:    #ffffff;
  --s2:    #ebebeb;
  --s3:    #dcdcdc;
  --b1:    #c8c8c8;
  --b2:    #999999;
  --tx:    #111111;
  --tx2:   #444444;
  --tx3:   #777777;
  --acc:   #006e9a;
  --acc2:  #0050b0;
  --warn:  #8a5c00;
  --err:   #b01e1e;
  --ok:    #1a7a32;
  color-scheme: light;
}
/* System-preference fallback for users who haven't toggled explicitly */
@media (prefers-color-scheme: light) {
  :root:not(.dark) {
    --bg:    #f4f4f4;
    --s1:    #ffffff;
    --s2:    #ebebeb;
    --s3:    #dcdcdc;
    --b1:    #c8c8c8;
    --b2:    #999999;
    --tx:    #111111;
    --tx2:   #444444;
    --tx3:   #777777;
    --acc:   #006e9a;
    --acc2:  #0050b0;
    --warn:  #8a5c00;
    --err:   #b01e1e;
    --ok:    #1a7a32;
    color-scheme: light;
  }
}

/* ── Base ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; border-radius: 0; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--tx); font-family: var(--mn);
  font-size: 14px; line-height: 1.5; min-height: 100dvh;
  display: flex; flex-direction: column;
}
button, input, select, textarea { font: inherit; color: inherit; border-radius: 0; }
a { color: var(--acc2); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 16px; letter-spacing: .03em; }
h2 { font-size: 13px; letter-spacing: .04em; color: var(--tx2); }
h3 { font-size: 12px; letter-spacing: .04em; color: var(--tx3); }
p { margin: 0; max-width: 72ch; }
::selection { background: var(--acc2); color: var(--bg); }
:focus-visible { outline: 1px dashed var(--acc2); outline-offset: 2px; }
[hidden], .is-hidden { display: none !important; }
.muted { color: var(--tx3); }
.small { font-size: 12px; }
.mono-num { font-variant-numeric: tabular-nums; }

/* ── Header (full width; title and buttons reach the edges) ─────────────── */
header.app-header { border-bottom: 1px solid var(--b1); background: var(--bg); position: sticky; top: 0; z-index: 10; }
.header-inner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 16px;
}
.logo { display: flex; align-items: baseline; gap: 8px; min-width: 0; overflow: hidden; text-decoration: none; }
.logo b { color: var(--tx); font-weight: 700; font-size: 15px; flex: none; }
.logo .sub { color: var(--acc2); font-weight: 400; font-size: 12px; letter-spacing: .04em; overflow: hidden; text-overflow: ellipsis; }

/* ── 5. Header icon buttons ──────────────────────────────────────────────── */
.hdr-right { display: flex; gap: 8px; flex: none; align-items: center; }
.btn-sm {
  background: transparent; border: 1px solid var(--acc2); color: var(--acc2);
  display: inline-flex; align-items: center; justify-content: center; line-height: 0;
  padding: 7px; border-radius: 0; cursor: pointer;
}
.btn-sm:hover { background: color-mix(in srgb, var(--acc2) 10%, var(--bg)); }
.btn-sm.on { background: var(--acc); border-color: var(--acc); color: var(--bg); }
.btn-sm svg { width: 16px; height: 16px; display: block; }
.btn-sm:disabled { opacity: .4; cursor: not-allowed; }
.hdr-user { font-size: 11px; color: var(--tx3); letter-spacing: .04em; white-space: nowrap; }
form.inline { display: inline; margin: 0; }

/* ── Navigation (console sections) ───────────────────────────────────────── */
nav.tabs { border-bottom: 1px solid var(--b1); overflow-x: auto; scrollbar-width: none; }
nav.tabs ul { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0 16px; }
nav.tabs a {
  display: block; padding: 9px 10px 7px; color: var(--tx3); text-decoration: none;
  font-size: 12px; font-weight: 700; letter-spacing: .04em; white-space: nowrap;
  border-bottom: 2px solid transparent;
}
nav.tabs a:hover { color: var(--tx); }
nav.tabs a[aria-current="page"] { color: var(--tx); border-bottom-color: var(--acc2); }
nav.tabs .nav-end { margin-left: auto; display: flex; align-items: center; padding: 0 6px 0 12px; }
nav.tabs .nav-btn {
  background: transparent; border: 0; color: var(--tx3); cursor: pointer; white-space: nowrap;
  font-family: var(--mn); font-size: 12px; font-weight: 700; letter-spacing: .04em;
  padding: 9px 10px 7px; border-bottom: 2px solid transparent;
}
nav.tabs .nav-btn:hover { color: var(--err); }

/* ── 7. Layout ───────────────────────────────────────────────────────────── */
/* Never overflow-x on html/body (§7: it breaks touch scrolling on Android). */
main.app {
  width: 100%; max-width: 480px; margin: 0 auto; padding: 14px 16px 28px 16px; flex: 1;
  display: flex; flex-direction: column; gap: 14px; overflow-x: hidden;
}
@media (min-width: 760px) {
  main.app { max-width: 920px; }
}
main.app.entrance-main { max-width: 420px; padding-top: 28px; }
main.app > .messages { margin: 0; }
hr.rule { border: 0; border-top: 1px solid var(--b1); margin: 4px 0; width: 100%; }
img.img { max-width: 100%; height: auto; background: #ffffff; padding: 8px; align-self: flex-start; }
details.details > summary {
  cursor: pointer; padding: 10px 12px; font-size: 12px; font-weight: 700; letter-spacing: .04em; color: var(--acc2);
}
details.details[open] > summary { border-bottom: 1px solid var(--b1); }
ul.plain { list-style: none; margin: 0; padding: 0; }
.align-right { text-align: right; }
.align-center { text-align: center; }
code, .code { font-family: var(--mn); font-size: .95em; color: var(--tx2); overflow-wrap: anywhere; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }

/* ── 4. Buttons and notices ──────────────────────────────────────────────── */
button.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: transparent; color: var(--acc2); border: 1px solid var(--acc2);
  font-family: var(--mn); font-size: 13px; font-weight: 700; letter-spacing: .03em;
  padding: 11px 14px; border-radius: 0; cursor: pointer; text-decoration: none; line-height: 1.2;
}
button.btn:hover, a.btn:hover { background: color-mix(in srgb, var(--acc2) 10%, var(--bg)); }
button.btn:active, a.btn:active { transform: translateY(1px); }
button.btn.stop, a.btn.stop { border-color: var(--err); color: var(--err); }
button.btn.stop:hover, a.btn.stop:hover { background: color-mix(in srgb, var(--err) 12%, var(--bg)); }
button.btn:disabled { opacity: .4; cursor: not-allowed; }
button.btn.small, a.btn.small { padding: 6px 10px; font-size: 12px; }
button.btn svg, a.btn svg { width: 16px; height: 16px; flex: none; }

.notice {
  font-size: 11.5px; line-height: 1.5; color: var(--tx2); background: var(--s1);
  border: 1px solid var(--b1); border-left: 3px solid var(--warn); padding: 9px 11px; border-radius: 0;
  margin-bottom: 14px;
}
.stack > .notice, .messages .notice, .panel-body > .notice, form .notice { margin-bottom: 0; }
.notice.err { border-left-color: var(--err); }
.notice.ok { border-left-color: var(--ok); }
.notice.info { border-left-color: var(--acc2); }
.notice b { color: var(--tx); }
.messages { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }

/* ── Panels ──────────────────────────────────────────────────────────────── */
.panel { background: var(--s1); border: 1px solid var(--b1); }
.panel-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-bottom: 1px solid var(--b1);
}
.panel-head h2 { flex: 1; }
.panel-body { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.label { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--tx3); }

/* ── Status (§6: colour = certainty) ─────────────────────────────────────── */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--b2); flex: none; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--err); }
.dot.acc { background: var(--acc2); }
.state { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; letter-spacing: .04em; white-space: nowrap; }
.state.ok { color: var(--ok); }
.state.warn { color: var(--warn); }
.state.err { color: var(--err); }
.state.off { color: var(--tx3); }
.state.acc { color: var(--acc2); }

/* ── Segmented switch (one choice filled, the rest outlined) ─────────────── */
.seg { display: inline-flex; }
.seg button {
  background: transparent; border: 1px solid var(--b2); color: var(--tx2);
  font-family: var(--mn); font-size: 12px; font-weight: 700; letter-spacing: .03em;
  padding: 7px 10px; cursor: pointer; margin-left: -1px;
}
.seg button:first-child { margin-left: 0; }
.seg button:hover { background: color-mix(in srgb, var(--acc2) 10%, var(--bg)); color: var(--tx); position: relative; }
.seg button.on { background: var(--acc); border-color: var(--acc); color: var(--bg); position: relative; z-index: 1; }

/* ── Site switch list ────────────────────────────────────────────────────── */
.sites { display: flex; flex-direction: column; }
.site {
  display: grid; gap: 10px 16px; padding: 12px; border-bottom: 1px solid var(--b1);
  grid-template-columns: 1fr;
}
.site:last-child { border-bottom: 0; }
.site-name { font-weight: 700; letter-spacing: .03em; }
.site-desc { font-size: 12px; color: var(--tx3); }
.site-hosts { font-size: 11px; color: var(--tx3); overflow-wrap: anywhere; }
.site-switch { display: flex; flex-direction: column; gap: 6px; }
.site.site-simple { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.site-state { display: flex; justify-content: flex-end; }
@media (min-width: 760px) {
  .site { grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; }
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.field label, .field .label { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--tx3); }
.field input[type="text"], .field input[type="password"], .field input[type="number"],
.field input[type="email"], .field input[type="datetime-local"], .field select, .field textarea,
input.input, select.input {
  background: var(--s2); border: 1px solid var(--b2); color: var(--tx);
  padding: 10px 11px; width: 100%; font-family: var(--mn); font-size: 14px;
}
.field input:focus, .field select:focus, .field textarea:focus, input.input:focus { border-color: var(--acc2); outline: none; }
.field .help { font-size: 11.5px; color: var(--tx3); }
.field.check { flex-direction: row; align-items: center; gap: 9px; flex-wrap: wrap; }
.field.check .help, .field.check .errorlist { flex-basis: 100%; padding-left: 25px; }
.field input[type="checkbox"], .field input[type="radio"] { appearance: none; width: 16px; height: 16px; margin: 0; border: 1px solid var(--acc2); background: transparent; display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.field input[type="checkbox"]:checked, .field input[type="radio"]:checked { background: var(--acc); border-color: var(--acc); }
.field input[type="checkbox"]:checked::after, .field input[type="radio"]:checked::after { content: ""; width: 6px; height: 6px; background: var(--bg); }
.field > div > div > label { display: inline-flex; align-items: center; gap: 9px; font-size: 12px; color: var(--tx2); letter-spacing: .03em; font-weight: 400; cursor: pointer; }
.field > div { display: flex; flex-direction: column; gap: 6px; }
.field.check label { font-size: 12px; color: var(--tx2); letter-spacing: .03em; }
.errorlist { list-style: none; margin: 0; padding: 0; color: var(--err); font-size: 12px; }
form.stack { gap: 14px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--tx3); padding: 8px 10px; border-bottom: 1px solid var(--b1); white-space: nowrap; }
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--b1); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: 0; }

/* ── Secret shown once (app password) ────────────────────────────────────── */
.secret {
  display: block; padding: 12px; border: 1px solid var(--acc2); background: var(--s2);
  font-size: 15px; letter-spacing: .02em; overflow-wrap: anywhere; user-select: all;
}

/* ── Sign-in pages ───────────────────────────────────────────────────────── */
.entrance { max-width: 420px; margin: 0 auto; width: 100%; }

/* ── Console page helpers ────────────────────────────────────────────────── */
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stats > div { display: flex; flex-direction: column; gap: 2px; }
.num { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.warn-text { color: var(--warn); }
.err-text { color: var(--err); }
.ok-text { color: var(--ok); }
.nowrap { white-space: nowrap; }
tr.row-off td { color: var(--tx3); }
.kv { display: inline-block; margin-right: 8px; overflow-wrap: anywhere; }
.details-cell { max-width: 360px; }
.filters .input { width: auto; min-width: 0; flex: 1 1 140px; }
.filters select.input { flex: 0 1 220px; }

/* ── Monitor charts (inline SVG polylines) ───────────────────────────────── */
svg.spark { width: 120px; height: 28px; display: block; color: var(--acc2); }
svg.chart { width: 100%; height: 120px; display: block; color: var(--acc2); border-bottom: 1px solid var(--b1); }
.spark-cell { min-width: 130px; }
.charts { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .charts { grid-template-columns: 1fr 1fr; } }
a.btn.on { background: var(--acc); border-color: var(--acc); color: var(--bg); }

/* ── Footer (version, bottom left) ───────────────────────────────────────── */
footer.app-footer { padding: 6px 16px 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.lang-form { margin: 0; display: flex; gap: 6px; align-items: center; }
.lang-select { background: transparent; color: var(--tx3); border: 1px solid var(--b1); font-family: var(--mn); font-size: 11px; padding: 3px 6px; }
.version { font-size: 9px; color: var(--tx3); letter-spacing: .04em; }
