/* Layout: a field instrument. Tool rail on the left, the photo as the work surface, the sheet underneath.
   Branding is per company (tenant): PS.applyBrand in common.js sets --color-brand, --color-deep and --color-accent
   on the page from the signed-in company's settings, and swaps in its logo. The values below are the neutral look
   shown before anyone is signed in and for companies that have not chosen colours.
   Semantic colors (--power, --comm, --unk, --ok) are NOT brand colors: they carry meaning on the photos and in the
   sheet, so they never change per company. */
:root {
  --color-brand: #2f4858; --color-deep: #1c2c36; --color-accent: #8fb8cc; --color-text: #26323a;
  --font-display: "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif; --font-body: Georgia, "Times New Roman", serif; --font-mono: "Cascadia Mono", Consolas, "SF Mono", monospace;
  --tracking-display: -0.015em; --tracking-kicker: 0.13em;
  --bg: #f3f5f6; --panel: #ffffff; --panel-2: #f6f8f9; --ink: var(--color-text); --muted: #5f6b72; --line: #d6dbde;
  --accent: var(--color-brand); --accent-ink: #ffffff; --stage: #1a1e21; --deep: var(--color-deep); --link: var(--color-brand);
  --power: #b93226; --comm: #0a6f8f; --unk: #a35f00; --ok: #2b7a4b; --focus: var(--color-brand);
  --f-display: var(--font-display);
  --f-body: var(--font-body);
  --f-mono: var(--font-mono);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14181b; --panel: #1d2327; --panel-2: #252d32; --ink: #eceff1; --muted: #aab4ba; --line: #36424a;
    --accent: var(--color-accent); --accent-ink: #14181b; --stage: #0b0e10; --link: var(--color-accent);
    --power: #ff8272; --comm: #5ccbee; --unk: #ffb65c; --ok: #6fd39a; --focus: var(--color-accent); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14181b; --panel: #1d2327; --panel-2: #252d32; --ink: #eceff1; --muted: #aab4ba; --line: #36424a;
  --accent: var(--color-accent); --accent-ink: #14181b; --stage: #0b0e10; --link: var(--color-accent);
  --power: #ff8272; --comm: #5ccbee; --unk: #ffb65c; --ok: #6fd39a; --focus: var(--color-accent); color-scheme: dark;
}
* { box-sizing: border-box; }
/* UI (labels, tables, buttons) is the brand display face; running prose is the brand body face. */
body { background: var(--bg); color: var(--ink); font-family: var(--f-display); font-size: 15px; line-height: 1.45; margin: 0; }
.sub, .note, .top p, .verdict, .empty, .warnbox p, .item .grow { font-family: var(--f-body); }

/* brand band: NCWCOM wordmark (white knockout) on house purple */
.brandbar { background: var(--color-brand); color: #fff; border-bottom: 4px solid var(--deep); padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.brandbar .in { max-width: 1500px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 8px 20px; flex-wrap: wrap; }
.brandbar a.logo { display: flex; align-items: center; gap: 14px; color: #fff; text-decoration: none; min-width: 0; }
.brandbar img { height: 42px; width: auto; display: block; }
.brandbar .co { font-weight: 800; font-size: 22px; letter-spacing: var(--tracking-display); line-height: 1; }
.brandbar [hidden] { display: none; }
.brandbar a.logo:not(.has-mark) .app { border-left: 0; padding-left: 0; }
.brandbar .app { font-weight: 700; font-size: 20px; letter-spacing: var(--tracking-display); padding-left: 14px; border-left: 2px solid var(--color-accent); line-height: 1.1; }
.brandbar .who { color: #fff; font-size: 13px; }
.brandbar a { color: #fff; }
.brandbar .btn, .brandbar .btn.ghost, .brandbar a.btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.7); }
.brandbar .btn:hover, .brandbar .btn.ghost:hover { background: var(--deep); }
@media (max-width: 520px) { .brandbar img { height: 34px; } .brandbar .app { font-size: 16px; padding-left: 10px; } }
.wrap { max-width: 1500px; margin: 0 auto; padding-inline: 16px; padding-block: 14px 40px; display: flex; flex-direction: column; gap: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* header: the banded rule is the survey stick */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; }
.top h1 { font-family: var(--f-display); font-weight: 800; font-size: 30px; line-height: 1; letter-spacing: var(--tracking-display); margin: 0; text-wrap: balance; color: var(--color-brand); }
.top p { margin: 4px 0 0; color: var(--muted); max-width: 62ch; }
.stickrule { height: 8px; border: 1px solid var(--deep); background: repeating-linear-gradient(90deg, var(--deep) 0 48px, var(--panel) 48px 96px); }
.badge { font-family: var(--f-display); font-weight: 600; font-size: 14px; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); white-space: nowrap; }

.grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; align-items: start; }
.rail { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); padding: 12px; min-width: 0; }
.card > h2, .sect-h { font-family: var(--f-display); font-weight: 700; font-size: 13px; letter-spacing: var(--tracking-kicker); text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }

/* steps */
.steps { display: flex; flex-direction: column; gap: 6px; }
.step { display: grid; grid-template-columns: 30px 1fr; gap: 2px 10px; align-items: center; text-align: left; width: 100%; padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line); cursor: pointer; }
.step .n { grid-row: span 2; font-family: var(--f-display); font-weight: 700; font-size: 22px; width: 30px; height: 30px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); }
.step .t { font-family: var(--f-display); font-weight: 600; font-size: 18px; line-height: 1.1; }
.step .d { font-size: 13px; color: var(--muted); line-height: 1.25; }
.step[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.step[aria-pressed="true"] .d { color: var(--accent-ink); }
.step[aria-pressed="true"] .n { background: var(--accent-ink); color: var(--accent); border-color: var(--accent-ink); }
.step.done .n { border-color: var(--ok); color: var(--ok); }
.step[aria-pressed="true"].done .n { color: var(--accent); border-color: var(--accent-ink); }
.step[aria-pressed="true"] .d { opacity: .92; }
.step:hover { border-color: var(--ink); }

.btn { font-family: var(--f-display); font-weight: 600; font-size: 16px; letter-spacing: .03em; padding: 6px 12px; background: var(--panel); border: 1px solid var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--deep); border-color: var(--deep); color: #fff; }
.btn.small { font-size: 14px; padding: 3px 8px; }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* fields */
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fields .wide { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); letter-spacing: .03em; min-width: 0; }
label.f input, label.f select, label.f textarea { background: var(--panel-2); border: 1px solid var(--line); padding: 5px 7px; color: var(--ink); font-size: 14px; min-width: 0; width: 100%; border-radius: 0; }
label.f textarea { resize: vertical; min-height: 44px; }
details > summary { cursor: pointer; font-family: var(--f-display); font-weight: 600; font-size: 15px; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
details[open] > summary { margin-bottom: 8px; }
.note { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.item { display: flex; gap: 6px; align-items: center; font-size: 13px; background: var(--panel-2); border: 1px solid var(--line); padding: 4px 6px; }
.item input { width: 62px; background: var(--panel); border: 1px solid var(--line); padding: 3px 5px; color: var(--ink); font-family: var(--f-mono); font-size: 13px; }
.item .grow { flex: 1; min-width: 0; }
.x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 6px; }
.x:hover { color: var(--power); }

/* viewer */
.viewer { position: relative; background: var(--stage); border: 1px solid var(--line); height: min(74vh, 900px); min-height: 380px; overflow: hidden; touch-action: none; }
.viewer canvas#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.viewer.drop { outline: 3px dashed var(--accent); outline-offset: -6px; }
.loupe { position: absolute; top: 10px; right: 10px; width: 150px; height: 150px; border: 2px solid var(--accent); background: var(--stage); pointer-events: none; }
.vtools { position: absolute; left: 10px; top: 10px; display: flex; gap: 6px; flex-wrap: wrap; }
.vtools .btn { background: var(--panel); }
.hint { position: absolute; left: 10px; right: 10px; bottom: 10px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; pointer-events: none; }
.hint span { background: var(--panel); color: var(--ink); border: 1px solid var(--line); padding: 4px 9px; font-size: 14px; }
.hint .mode { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-family: var(--f-display); font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
.sample { position: absolute; right: 170px; top: 10px; background: var(--accent); color: var(--accent-ink); font-family: var(--f-display); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; font-size: 14px; }

.calib { display: flex; gap: 8px 14px; flex-wrap: wrap; align-items: baseline; }
.calib .big { font-family: var(--f-display); font-weight: 700; font-size: 26px; line-height: 1; }
.chip { font-size: 13px; padding: 2px 8px; border: 1px solid var(--line); background: var(--panel-2); }
.chip.warn { border-color: var(--unk); color: var(--unk); }
.chip.good { border-color: var(--ok); color: var(--ok); }

/* sheet */
.tablebox { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 720px; }
th { font-family: var(--f-display); font-weight: 600; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--ink); white-space: nowrap; }
td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .h { font-family: var(--f-display); font-weight: 700; font-size: 21px; line-height: 1; white-space: nowrap; }
td .dec { font-family: var(--f-mono); font-size: 12px; color: var(--muted); }
td.pm, td.gap { font-family: var(--f-mono); font-size: 13px; white-space: nowrap; }
td.gap.tight { color: var(--power); font-weight: 500; }
td select, td input { background: var(--panel-2); border: 1px solid var(--line); padding: 4px 6px; width: 100%; min-width: 110px; border-radius: 0; }
tr .tag { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 4px; font-family: var(--f-display); font-weight: 700; font-size: 17px; color: var(--panel); background: var(--muted); }
tr.c-p .tag { background: var(--power); } tr.c-c .tag { background: var(--comm); } tr.c-u .tag { background: var(--unk); } tr.c-o .tag { background: var(--ok); } tr.c-t .tag { background: var(--ink); }
.empty { color: var(--muted); padding: 14px 4px; }

.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 150px)) minmax(0, 1fr); gap: 10px 14px; align-items: end; }
.verdict { font-size: 15px; padding: 8px 10px; border-left: 4px solid var(--muted); background: var(--panel-2); min-width: 0; }
.verdict.yes { border-color: var(--ok); } .verdict.no { border-color: var(--power); }
.verdict b { font-family: var(--f-display); font-size: 19px; font-weight: 700; letter-spacing: .01em; }
.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; font-size: 14px; max-width: min(92vw, 520px); z-index: 20; }

@media (max-width: 900px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  .rail { display: contents; }
  .rail > .card { order: 3; }
  .rail > .card:first-child { order: 1; }
  .main { order: 2; }
  .steps { flex-direction: row; overflow-x: auto; padding-bottom: 2px; }
  .step { min-width: 150px; }
  .step .d { display: none; }
  .viewer { height: 68vh; }
  .loupe { width: 110px; height: 110px; }
  .sample { right: auto; left: 132px; top: 10px; }
  .slots { grid-template-columns: 1fr 1fr; }
  .slots .verdict { grid-column: 1 / -1; }
  .top h1 { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* ---------- pole line pages ---------- */
[hidden] { display: none !important; }
a { color: var(--link); }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.bar h1 { font-family: var(--f-display); font-weight: 800; font-size: 28px; line-height: 1; margin: 0; letter-spacing: var(--tracking-display); color: var(--color-brand); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bar h1, :root:not([data-theme="light"]) .top h1 { color: var(--color-accent); } }
:root[data-theme="dark"] .bar h1, :root[data-theme="dark"] .top h1 { color: var(--color-accent); }
.bar .who { font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.crumbs { font-family: var(--f-display); font-size: 16px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.crumbs a { color: var(--muted); }
h2.page { font-family: var(--f-display); font-weight: 800; letter-spacing: var(--tracking-display); font-size: 26px; line-height: 1.05; margin: 0; text-wrap: balance; }
.sub { color: var(--muted); margin: 2px 0 0; }
.stack { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: end; }
.formgrid .wide { grid-column: 1 / -1; }
label.f input, label.f select, label.f textarea { font-size: 16px; padding: 8px 9px; }
.btn.big { font-size: 20px; padding: 12px 18px; }
.btn.danger { border-color: var(--power); color: var(--power); }
.warnbox { border: 2px solid var(--power); background: var(--panel); padding: 10px 12px; }
.linecards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.linecard { background: var(--panel); border: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--ink); min-width: 0; }
.linecard:hover { border-color: var(--ink); }
.linecard b { font-family: var(--f-display); font-size: 22px; line-height: 1.1; overflow-wrap: anywhere; }
.linecard span { color: var(--muted); font-size: 13px; }
.poles td { vertical-align: top; }
.poles .num { font-family: var(--f-display); font-weight: 700; font-size: 22px; line-height: 1.1; overflow-wrap: anywhere; }
.poles .thumbs { display: flex; gap: 6px; }
.poles .thumbs img { width: 54px; height: 72px; object-fit: cover; border: 1px solid var(--line); background: var(--stage); display: block; }
.poles .mono, .mono { font-family: var(--f-mono); font-size: 12.5px; }
.poles .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.seqbtn { display: flex; flex-direction: column; gap: 2px; align-items: center; }
.seqbtn button { border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); width: 26px; height: 20px; line-height: 1; cursor: pointer; padding: 0; }
.seqbtn b { font-family: var(--f-display); font-size: 20px; }
.chip.todo { border-color: var(--unk); color: var(--unk); } .chip.done { border-color: var(--ok); color: var(--ok); }
.cap { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; align-items: start; }
.cap .card h2 { display: flex; gap: 8px; align-items: center; }
.cap .card h2 i { font-style: normal; background: var(--ink); color: var(--panel); width: 24px; height: 24px; display: inline-grid; place-items: center; font-size: 16px; }
.shot { width: 100%; max-height: 300px; object-fit: contain; background: var(--stage); border: 1px solid var(--line); display: block; }
.gps { font-family: var(--f-mono); font-size: 14px; padding: 8px 10px; background: var(--panel-2); border: 1px solid var(--line); overflow-wrap: anywhere; }
.gps.good { border-color: var(--ok); } .gps.live { border-color: var(--accent); }
.gps b { font-family: var(--f-display); font-size: 22px; font-weight: 700; display: block; }
.camwrap { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; padding: env(safe-area-inset-top, 0px) 0 env(safe-area-inset-bottom, 0px); }
.camwrap video { flex: 1; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.camhud { position: absolute; left: 12px; top: calc(12px + env(safe-area-inset-top, 0px)); background: rgba(0,0,0,.65); color: #fff; padding: 6px 10px; font-family: var(--f-mono); font-size: 14px; }
.cambar { display: flex; gap: 12px; justify-content: center; align-items: center; padding: 12px; background: #000; }
.cambar .shutter { width: 72px; height: 72px; border-radius: 50%; border: 5px solid #fff; background: var(--accent); cursor: pointer; }
.cambar .btn { background: #222; color: #fff; border-color: #777; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 40; display: grid; place-items: center; padding: 16px; overflow: auto; }
.modal .card { width: min(100%, 560px); max-height: 100%; overflow: auto; }
.savebar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); padding-block: 6px; }
.dirty { color: var(--unk); font-size: 13px; }
@media (max-width: 900px) { .bar h1 { font-size: 24px; } table.poles { min-width: 760px; } }

a.btn { color: var(--ink); text-decoration: none; display: inline-block; }
a.btn.primary { color: var(--accent-ink); }
a.btn.primary:hover { color: #fff; }
a.btn.ghost { color: var(--muted); }
.cap .btn { white-space: normal; }
