/* The external look: one file for everything people outside KTL see.

   Erik, 2026-10-07: "please keep the external and field aesthetics in sync". The look is
   the EX-QAQC bench's: the bench mat, white operation cards, black buttons, an ink header,
   Barlow, and the board's own solder mask, silkscreen and copper for anything that names a
   board.

   One file, three users:
   - the EX-QAQC bench (ffdirect/templates/index.html) loads it from /static/ and keeps its
     own layout rules; the tokens below are its tokens;
   - the CM portal (CM Tool templates/portal/) loads the same bytes from the hub at
     /api/ktl-external.css;
   - the Field Configurator (configurator field_server.py) carries a copy in its
     static/ folder, and tests/campaign/test_external_look.py fails if the copy differs.
   Change it here, copy it to the Configurator, and both lanes pick it up on release.

   Fonts: pages load Barlow, Barlow Condensed and JetBrains Mono from Google Fonts. */

/* ── Tokens ─────────────────────────────────────────────────────────────────────── */
body[data-bench-kind="external"], body.kx {
  --bg: #e3e7e5;          /* the bench mat */
  --panel: #ffffff; --panel2: #f1f3f2; --border: #cdd3d0;
  --ink: #141b18; --muted: #58625d;
  --blue: #141b18;        /* the base sheet's action colour: here, plain black */
  --green: #1a7f37; --red: #c42b1c; --amber: #b7791f;
  --mask: #123f30; --silk: #f4f6f2; --copper: #c08a4a;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --cond: "Barlow Condensed", "Arial Narrow", sans-serif;
  background: var(--bg); color: var(--ink);
  font-family: "Barlow", ui-sans-serif, system-ui, sans-serif;
  font-size: 16px; line-height: 1.45;
}

/* ── Shared components (portal and field app; the bench has its own layout) ──────── */
body.kx { margin: 0; }
/* Components set their own display, which would otherwise win over [hidden]. */
.kx [hidden] { display: none !important; }
.kx * { box-sizing: border-box; }
.kx a { color: var(--ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.kx code, .kx .mono { font-family: var(--mono); font-size: .88em; }
.kx code { background: var(--panel2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
.kx .muted { color: var(--muted); font-size: 14px; }
.kx .bad { color: var(--red); }

/* The ink header: who this is for, and how things stand. */
.kx-bar { background: var(--ink); color: var(--silk); padding: 0 28px; min-height: 58px;
          display: flex; align-items: center; gap: 20px 24px; flex-wrap: wrap;
          position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.kx-bar a { color: var(--silk); }
.kx-brand { display: flex; align-items: center; gap: 10px; font-family: var(--cond); font-size: 21px;
            font-weight: 600; letter-spacing: .01em; color: var(--silk); text-decoration: none; }
.kx-sub { color: #9aa6a0; font-size: 14px; }
.kx-spacer { flex: 1; }
.kx-tabs { display: flex; align-self: stretch; }
.kx-tabs a { display: flex; align-items: center; padding: 0 16px; color: #9aa6a0; font-weight: 600;
             font-size: 15px; text-decoration: none; border-bottom: 3px solid transparent; }
.kx-tabs a.on { color: var(--silk); border-bottom-color: var(--silk); }
.kx-chip { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--silk); }
.kx-chip i { width: 9px; height: 9px; border-radius: 50%; background: #6b7670; box-shadow: 0 0 0 3px rgba(255,255,255,.06); }
.kx-chip.ok i { background: #3fd068; }
.kx-chip.bad { color: #ff9b8f; }
.kx-chip.bad i { background: #ff5a47; }
.kx-chip small { font-weight: 400; font-size: 13px; color: #9aa6a0; }
.kx-bar select { background: #26302c; color: var(--silk); border: 1px solid #3b4843; border-radius: 6px;
                 padding: 6px 10px; font: inherit; font-size: 14px; }

/* A notice under the header (the bench's update banner; the field app's power-user mode). */
.kx-notice { background: #efe6d2; color: #6b4a12; border-bottom: 1px solid #d8c49a; padding: 8px 28px;
             font-size: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.kx-notice b { color: var(--amber); }

/* The page and its cards. */
.kx-page { max-width: 1360px; margin: 0 auto; padding: 28px; display: grid; gap: 20px; }
.kx-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.kx-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 16px 20px; min-width: 0; }
.kx-card.on { border: 1px solid var(--ink); box-shadow: inset 6px 0 0 var(--ink); }
.kx-card h2, .kx-h { font-family: var(--cond); font-size: 20px; font-weight: 600; margin: 0 0 10px; color: var(--ink); }
.kx-h1 { font-family: var(--cond); font-size: 30px; font-weight: 600; margin: 0; line-height: 1.1; }
.kx-label { font-size: 12.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.kx-list { display: grid; gap: 8px; }
.kx-row { display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; }
button.kx-item { text-align: left; font: inherit; color: var(--ink); cursor: pointer; width: 100%;
                 display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 14px; }
button.kx-item:hover { border-color: var(--ink); }
.kx-item b { font-family: var(--cond); font-size: 20px; font-weight: 600; }

/* Status as the bench words it: a dot and a word. */
.kx-state { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.kx-state::before { content: ""; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid currentColor; }
.kx-state.ok { color: var(--green); } .kx-state.ok::before { background: currentColor; }
.kx-state.bad { color: var(--red); } .kx-state.bad::before { background: currentColor; }
.kx-state.warn { color: var(--amber); } .kx-state.warn::before { background: currentColor; }

/* Buttons: black, or outlined; the plate's own outline on the plate. */
.kx-btn, .kx button:not(.kx-item):not(.kx-plain) {
  font: inherit; font-size: 15px; font-weight: 600; border-radius: 6px; cursor: pointer;
  background: var(--ink); color: var(--silk); border: 1.5px solid var(--ink); padding: 8px 16px; min-height: 40px; }
.kx-btn.ghost, .kx button.ghost { background: transparent; color: var(--ink); }
.kx button:disabled { opacity: .45; cursor: default; }
.kx button:focus-visible, .kx a:focus-visible, .kx input:focus-visible, .kx select:focus-visible {
  outline: 2px solid var(--ink); outline-offset: 2px; }

/* Inputs. */
.kx input[type=text], .kx input[type=number], .kx input[type=password], .kx-main select {
  font: inherit; font-size: 15px; color: var(--ink); background: var(--panel); border: 1px solid var(--border);
  border-radius: 6px; padding: 8px 10px; }
.kx input:focus, .kx-main select:focus { outline: none; border-color: var(--ink); }
.kx input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--ink); }

/* Tables. */
.kx table { border-collapse: collapse; width: 100%; font-size: 15px; }
.kx th, .kx td { text-align: left; vertical-align: top; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--border); }
.kx th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.kx td.mono { font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; }

/* The plate: a board, as the board itself looks. Solder mask, silkscreen, four copper
   fiducials. For the one thing on a page meant to be read from across the room. */
.kx-plate { position: relative; background: var(--mask); color: var(--silk); border-radius: 10px; padding: 22px 24px 20px;
  background-image:
    radial-gradient(circle at 14px 14px, var(--copper) 0 4px, transparent 4.5px),
    radial-gradient(circle at calc(100% - 14px) 14px, var(--copper) 0 4px, transparent 4.5px),
    radial-gradient(circle at 14px calc(100% - 14px), var(--copper) 0 4px, transparent 4.5px),
    radial-gradient(circle at calc(100% - 14px) calc(100% - 14px), var(--copper) 0 4px, transparent 4.5px); }
.kx-plate .kx-plate-lbl { font-size: 14px; color: #a9c2b6; }
.kx-plate .kx-plate-big { display: block; font-family: var(--cond); font-weight: 700; font-size: 56px; line-height: 1;
                          letter-spacing: .02em; font-variant-numeric: tabular-nums; margin: 4px 0 10px; }
.kx-plate a, .kx-plate .muted { color: #cfe0d7; }
.kx-plate button, .kx-plate .kx-btn { background: transparent; color: var(--silk); border: 1.5px solid rgba(244,246,242,.7); }

/* A short message that comes and goes. */
.kx-toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
            background: var(--ink); color: var(--silk); border-radius: 8px; padding: 10px 16px; font-size: 15px;
            max-width: calc(100vw - 32px); z-index: 10; }
.kx-toast.bad { background: var(--red); }

@media (max-width: 640px) {
  .kx-bar { padding: 8px 16px; min-height: 52px; }
  .kx-page { padding: 16px; }
  .kx-notice { padding: 8px 16px; }
  .kx-tabs { width: 100%; overflow-x: auto; }
}
