/* Bay scans, BATS Wireless branding: dark, Inter, BATS red as the single accent (also "live / recording"). */
:root {
  --bg: #111214;
  --panel: #181a1e;
  --panel-2: #1f2228;
  --line: #2a2e35;
  --line-strong: #3a3f48;
  --text: #f1f3f5;
  --muted: #c9ced6;
  --dim: #8f97a3;
  --red: #cc0a2f;
  --red-hi: #e3173f;
  --survey: #4d8fd1;          /* measured data */
  --ok: #3fb37f;
  --warn: #e0a43a;
  --bad: #e5484d;
  --focus: #88c0ff;
  --radius: 10px;
  --radius-sm: 6px;
  --ink-2: var(--dim);        /* used by chart.js */
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--line);
  --bs-body-font-family: "Inter", system-ui, sans-serif;
  --bs-link-color: #8fbdf0;
  --bs-link-hover-color: #b5d4f6;
  --bs-link-color-rgb: 143, 189, 240;
  --bs-secondary-color: var(--dim);
}
body { background: var(--bg); color: var(--text); font-size: .97rem; line-height: 1.5; }
h1, h2, h3 { font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; margin: 0; }
a { text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.text-secondary { color: var(--dim) !important; }

/* ---------- chrome */
.topbar { display: flex; align-items: center; gap: 2rem; padding: .55rem 1.5rem; background: #0b0c0e; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: .9rem; color: #fff; text-decoration: none; font-weight: 700; font-size: .95rem; }
.brand img { height: 26px; width: auto; display: block; }
.brand span { padding-left: .9rem; border-left: 1px solid var(--line-strong); color: var(--muted); font-weight: 600; }
.topnav { display: flex; gap: 1.4rem; flex-wrap: wrap; }
.topnav a { color: var(--dim); text-decoration: none; font-weight: 500; padding: .35rem 0; border-bottom: 2px solid transparent; }
.topnav a:hover { color: #fff; }
.topnav a.active { color: #fff; border-bottom-color: var(--red); }
.who { margin-left: auto; }
.page { max-width: 1440px; margin: 0 auto; padding: 1.5rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.narrow { max-width: 30rem; }
.narrow-text { max-width: 44rem; }
#toasts .alert { margin-bottom: 1rem; }

/* ---------- buttons */
.btn { font-weight: 600; border-radius: var(--radius-sm); }
.btn-ink { background: #fff; color: #111214; border: 1px solid #fff; }
.btn-ink:hover { background: var(--muted); border-color: var(--muted); color: #111214; }
.btn-go { background: var(--red); color: #fff; border: 1px solid var(--red); }
.btn-go:hover { background: var(--red-hi); border-color: var(--red-hi); color: #fff; }
.btn-quiet { background: transparent; color: var(--text); border: 1px solid var(--line-strong); }
.btn-quiet:hover { background: var(--panel-2); color: #fff; border-color: var(--line-strong); }
.btn-check:checked + .btn-quiet { background: #fff; color: #111214; border-color: #fff; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .9rem; }

/* ---------- forms */
.form-control, .form-select { background-color: var(--bg); border-color: var(--line-strong); color: var(--text); }
.form-control:focus, .form-select:focus { background-color: var(--bg); border-color: var(--focus); box-shadow: none; color: var(--text); }
.form-control::placeholder { color: #6b727d; }
.input-group-text { background: var(--panel-2); border-color: var(--line-strong); color: var(--dim); }
.form-text { color: var(--dim); }

/* ---------- panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.panel-title { font-size: .98rem; font-weight: 700; margin: 0 0 .6rem; color: #fff; }
.opt { font-weight: 400; color: var(--dim); font-size: .85em; }
.tag { font-size: .72rem; font-weight: 600; padding: .05rem .4rem; border-radius: 4px; background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--dim); vertical-align: middle; }

/* ---------- dashboard */
.dash { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.25rem; align-items: start; }
.dash-rail { display: grid; gap: 1rem; }
@media (max-width: 1000px) { .dash { grid-template-columns: 1fr; } }

.hero-viewer { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: radial-gradient(120% 100% at 50% 10%, #22262c 0%, #121316 70%); }
.viewer { height: min(62vh, 620px); min-height: 360px; position: relative; }
.hero-viewer.tall .viewer { height: min(70vh, 720px); }
.viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.viewer.loading::after { content: "Loading the point cloud…"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--dim); }
.viewer-empty { display: grid; place-items: center; color: var(--dim); padding: 2rem; text-align: center; }
.viewer-error { padding: 2rem; color: var(--bad); }
.readout { position: absolute; left: 1.4rem; top: 1.1rem; pointer-events: none; }
.readout-label { margin: 0; font-weight: 600; color: var(--muted); }
.readout-value { margin: .1rem 0 0; font-weight: 800; font-size: clamp(3rem, 6.2vw, 5.4rem); line-height: 1; letter-spacing: -0.035em; color: #fff; font-variant-numeric: tabular-nums; }
.readout-value .unit { font-size: .36em; font-weight: 600; letter-spacing: 0; margin-left: .25em; color: var(--muted); }
.readout-sub { margin: .45rem 0 0; color: var(--dim); max-width: 22rem; }
.readout-value::after { content: ""; display: block; width: 2.2rem; height: 3px; background: var(--red); margin-top: .7rem; }
.readout-label, .readout-sub, .readout-value { text-shadow: 0 1px 8px #000c; }
.viewer-tools { position: absolute; right: .75rem; top: .75rem; display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.viewer-tools button { font: inherit; font-size: .82rem; font-weight: 600; background: #111214d9; color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: .22rem .6rem; }
.viewer-tools button:hover { border-color: var(--muted); }
.viewer-tools button[aria-pressed="false"] { opacity: .5; text-decoration: line-through; }
.viewer-count { font-size: .78rem; color: var(--dim); background: #111214b3; border-radius: 4px; padding: .15rem .45rem; }
.viewer-legend { position: absolute; left: 1.4rem; bottom: .8rem; display: flex; flex-wrap: wrap; gap: .3rem 1rem; font-size: .82rem; color: var(--dim); pointer-events: none; }
.sw { display: inline-block; width: 18px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: middle; }
.sw-ramp { background: linear-gradient(90deg, #5c6d7c, #9c8a68, #d9a441, #f4d27a); }
.sw-fill { background: #4d8fd180; }
.sw-path { height: 3px; background: var(--red); }
.sw-bay { height: 10px; border: 2px solid var(--muted); border-top: 0; border-radius: 0; background: #c9ced61f; }

.metrics { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 1rem; overflow: hidden; }
.metrics > div { background: var(--panel); padding: .75rem .95rem; display: flex; flex-direction: column; justify-content: center; }
.metrics span { font-size: .82rem; color: var(--dim); }
.metrics strong { font-size: 1.1rem; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.warnings { margin: 1rem 0 0; padding: .7rem 1rem .7rem 2rem; background: #2a2110; border: 1px solid #5c4716; color: #f3d9a4; border-radius: var(--radius); }
.chart-panel { margin-top: 1rem; }
.chart-box { height: 240px; position: relative; }
.empty-hero { background: var(--panel); border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 3rem 2rem; max-width: 52rem; }
.empty-hero h1, .empty-hero h2 { font-size: 1.8rem; margin-bottom: .5rem; }
.empty-hero p { max-width: 38rem; color: var(--dim); }

/* status */
.status-head { display: flex; align-items: center; justify-content: space-between; }
.status-head .panel-title { margin: 0; }
.pill { display: inline-flex; align-items: center; gap: .45rem; font-weight: 700; font-size: .85rem; padding: .2rem .7rem; border-radius: 999px; background: var(--panel-2); color: var(--dim); border: 1px solid var(--line-strong); }
.pill-idle, .pill-done { color: var(--ok); border-color: #2c5e45; background: #16251e; }
.pill-recording { background: var(--red); border-color: var(--red); color: #fff; }
.pill-processing, .pill-uploading { color: #8fbdf0; border-color: #2f4f73; background: #16212e; }
.pill-error { color: var(--bad); border-color: #6b2a2d; background: #2a1517; }
.dot { width: .5rem; height: .5rem; border-radius: 50%; background: #fff; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
.status-recording { box-shadow: inset 3px 0 0 var(--red); margin: -1rem -1.1rem; padding: 1rem 1.1rem; }
.elapsed { font-size: 2.8rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin: .7rem 0 .2rem; font-variant-numeric: tabular-nums; }
.status-msg { margin: .6rem 0 .4rem; color: var(--muted); }
.progress { height: .5rem; margin-top: .8rem; background: var(--panel-2); }
.progress-bar { background: var(--survey); transition: width .4s; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: .2rem .9rem; margin: .4rem 0 0; font-size: .9rem; }
.facts dt { font-weight: 500; color: var(--dim); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
.facts.wide { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
.walk-tip { margin-top: .9rem; font-size: .9rem; }
.walk-tip summary { cursor: pointer; color: var(--bs-link-color); font-weight: 600; }
.walk-tip ol { padding-left: 1.2rem; margin: .5rem 0 0; color: var(--muted); }
.recent { list-style: none; margin: 0 0 .5rem; padding: 0; }
.recent li + li { border-top: 1px solid var(--line); }
.recent a { display: grid; grid-template-columns: 1fr auto; padding: .5rem 0; color: inherit; text-decoration: none; }
.recent a:hover .r-name { text-decoration: underline; }
.r-name { font-weight: 600; } .r-name em { font-style: normal; font-weight: 500; color: var(--dim); font-size: .85em; }
.r-val { font-variant-numeric: tabular-nums; font-weight: 700; }
.r-when { grid-column: 1 / -1; font-size: .78rem; color: var(--dim); }
.state { font-size: .8rem; font-weight: 600; color: var(--dim); }
.state-recording { color: var(--red-hi); } .state-processing, .state-uploading { color: #8fbdf0; }
.state-done { color: var(--ok); } .state-error { color: var(--bad); } .state-cancelled { text-decoration: line-through; }

/* tables, detail */
.table { --bs-table-bg: var(--panel); --bs-table-color: var(--text); --bs-table-border-color: var(--line); margin: 0; }
.table th { font-weight: 600; color: var(--dim); font-size: .85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--ok); } .down { color: var(--bad); }
.detail-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
.detail-grid .span-2 { grid-column: span 2; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } .detail-grid .span-2 { grid-column: auto; } }
.admin-tools { margin-top: 1rem; }
.signin-card { background: var(--bg); color: var(--text); border: 1px solid var(--line-strong); padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .92rem; }

/* bays */
.bay-list { display: grid; gap: .75rem; }
.bay { display: grid; grid-template-columns: 140px minmax(0, 1fr) auto; gap: 1.25rem; align-items: center; }
.bay h2 { font-size: 1.1rem; margin: 0 0 .15rem; }
.bay-sketch { color: var(--muted); display: grid; place-items: center; }
.bay-actions { display: flex; gap: .4rem; }
@media (max-width: 700px) { .bay { grid-template-columns: 1fr; } .bay-sketch { justify-items: start; } }
.form-cols { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 2rem; }
@media (max-width: 900px) { .form-cols { grid-template-columns: 1fr; } }
.dim-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
@media (max-width: 560px) { .dim-grid { grid-template-columns: 1fr; } }
.bay-form legend.form-label { font-size: 1rem; font-weight: 400; margin-bottom: .5rem; }
.bay-diagram { margin: 0; color: var(--muted); }
.bay-diagram svg { width: 100%; max-width: 340px; display: block; }
.bay-diagram text { font: 500 11px "Inter", sans-serif; fill: var(--dim); }
.bay-diagram .dimline path { stroke: var(--survey); fill: none; }
.bay-diagram figcaption { font-size: .85rem; color: var(--dim); }
fieldset.panel legend { float: none; width: auto; padding: 0; }
.danger-zone { border-color: #5a2629; }

/* login */
.login-page { background: var(--bg); }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 460px) 1fr; }
.login-panel { padding: 3.5rem 3rem; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
.login-logo { width: 150px; height: auto; display: block; }
.login-panel h1 { font-size: 1.9rem; margin: 2.2rem 0 .4rem; }
.lead-quiet { color: var(--dim); margin-bottom: 1.6rem; }
.login-art { color: var(--muted); display: flex; align-items: flex-end; overflow: hidden; position: relative; }
.login-art svg { width: 100%; height: 100%; }
@media (max-width: 800px) { .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; } .login-panel { padding: 2rem 1.25rem; } }

@media (max-width: 700px) {
  .readout { position: static; padding: 1rem 1rem 0; }
  .viewer { height: 52vh; min-height: 300px; }
  .viewer-tools { top: auto; bottom: .6rem; right: .6rem; }
  .viewer-count { display: none; }
  .viewer-legend { position: static; padding: .4rem 1rem .8rem; }
}
@media (max-width: 600px) { .page { padding: 1rem; } .topbar { gap: 1rem; padding: .6rem 1rem; flex-wrap: wrap; } .brand span { display: none; } }
.viewer-legend { background: #111214d9; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .3rem .7rem; color: var(--muted); }
.readout-sub { max-width: 30rem; }
.brand img { height: 30px; }
@media (max-width: 700px) { .viewer-legend { border: 0; border-radius: 0; background: transparent; } }
.server-job { margin-top: 1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.server-job .panel-title { font-size: .92rem; }
