/* Board Processing — Data tab (frontend/data.css).
   Everything is scoped under .bd and painted only with the shared Andean
   tokens from vendor/andean/andean.css, so the same file works on the
   station and the cloud site, dark (default) and light ([data-theme="light"]).
   Monochrome, square corners, hairline dividers, light prose (300) and
   tabular numerals (400) in the table. The accent gradient appears once:
   the 2 px bar under/beside the active class in the rail. Photos are the
   only colour on the page; the single semantic colour is the fail red,
   used for text only. */

.bd {
  --bd-fail: #E5484D;
  --bd-rail: 168px;
  --bd-drawer: 520px;
  position: relative;
  font-family: var(--font);
  font-weight: 300;
  font-size: 14px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 60vh;
}
.bd, .bd * { box-sizing: border-box; }
.bd [hidden] { display: none !important; }
.bd a { color: inherit; text-decoration: none; }
.bd .bd-mono { font-family: var(--mono); }
.bd .bd-muted { color: var(--color-text-muted); }
.bd .bd-faint { color: var(--color-text-faint); }
.bd .bd-fail { color: var(--bd-fail) !important; }
.bd .bd-label {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--color-text-faint);
}

/* ---- controls (self-sufficient: the cloud site may not ship style.css) */
.bd button {
  font-family: var(--font); font-weight: 300; font-size: 13px; line-height: 1.3;
  color: var(--color-text); background: var(--color-bg);
  border: 1px solid var(--color-border); border-radius: 0;
  padding: 7px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease;
}
.bd button:hover:not(:disabled) { background: var(--color-hover-surface); border-color: var(--color-border-strong); }
.bd button:focus-visible { outline: 1px solid var(--color-border-strong); outline-offset: 2px; }
.bd button:disabled { color: var(--color-text-faint); border-color: var(--color-border-subtle); cursor: not-allowed; }
.bd button.bd-primary { color: var(--color-text-primary); border-color: var(--color-border-strong); }
.bd button.bd-ghost { border-color: transparent; color: var(--color-text-muted); padding: 4px 8px; }
.bd button.bd-ghost:hover:not(:disabled) { color: var(--color-text-primary); border-color: transparent; }
.bd input, .bd select, .bd textarea {
  font-family: var(--font); font-weight: 300; font-size: 13px;
  color: var(--color-text); background: var(--color-bg);
  border: 1px solid var(--color-border); border-radius: 0;
  padding: 6px 9px;
}
.bd input:focus, .bd select:focus, .bd textarea:focus { outline: none; border-color: var(--color-text-secondary); }
.bd input::placeholder, .bd textarea::placeholder { color: var(--color-text-faint); }
.bd input[type="date"] { font-family: var(--mono); font-size: 12px; }
.bd input[type="checkbox"] { accent-color: var(--color-text-muted); margin: 0 6px 0 0; vertical-align: -1px; }

/* ---- sign-in gate: the shared .andean-gate, inset in the page rather than full-height */
.bd .bd-gate { min-height: 60vh; }

/* ---- header row */
.bd-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px;
  padding: 18px 0 12px;
  border-bottom: 1px solid var(--color-border-subtle);
}
.bd-head h2 { margin: 0; font-size: 22px; font-weight: 300; letter-spacing: -0.01em; color: var(--color-text-primary); }
.bd-counts { color: var(--color-text-muted); font-size: 13px; white-space: nowrap; }
.bd-counts .bd-unsent { margin-left: 8px; font-style: italic; }
.bd-search { flex: 1 1 200px; min-width: 160px; max-width: 360px; }
.bd-chips { display: inline-flex; border: 1px solid var(--color-border-subtle); }
.bd-chips button {
  border: 0; border-right: 1px solid var(--color-border-subtle);
  padding: 6px 10px; font-size: 12px; color: var(--color-text-muted);
}
.bd-chips button:last-child { border-right: 0; }
.bd-chips button.active { color: var(--color-text-primary); background: var(--color-hover-surface); }
.bd-daterange { display: inline-flex; align-items: center; gap: 6px; color: var(--color-text-faint); font-size: 12px; }
.bd-toggle { display: inline-flex; align-items: center; font-size: 12px; color: var(--color-text-muted); white-space: nowrap; cursor: pointer; }
.bd-user { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--color-text-muted); }
.bd-user .bd-mono { color: var(--color-text); }

/* slim status line: Supabase errors, load state; never a dialog */
.bd-status {
  padding: 6px 0; font-size: 12px; color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border-subtle);
  min-height: 0;
}
.bd-status.bd-fail { color: var(--bd-fail); }

/* ---- body: rail | main */
.bd-body { display: grid; grid-template-columns: var(--bd-rail) 1fr; align-items: start; }
.bd-rail {
  border-right: 1px solid var(--color-border-subtle);
  padding: 14px 0; position: sticky; top: 0;
}
.bd-rail a {
  position: relative; display: flex; justify-content: space-between; gap: 10px;
  padding: 7px 14px 7px 16px; font-size: 13px; color: var(--color-text-muted); cursor: pointer;
  transition: color 200ms ease;
}
.bd-rail a:hover { color: var(--color-text-primary); }
.bd-rail a.active { color: var(--color-text-primary); }
.bd-rail a.active::before {
  content: ""; position: absolute; left: 0; top: 6px; bottom: 6px; width: 2px;
  background: var(--accent-gradient);
}
.bd-rail .bd-n { font-family: var(--mono); font-size: 11px; color: var(--color-text-faint); font-variant-numeric: tabular-nums; }
.bd-main { min-width: 0; padding-left: 20px; }

/* ---- stats strip */
.bd-stats {
  display: flex; flex-wrap: wrap; gap: 6px 36px;
  padding: 14px 0 12px; border-bottom: 1px solid var(--color-border-subtle);
}
.bd-stat .bd-label { display: block; margin-bottom: 2px; }
.bd-stat .bd-v { font-family: var(--mono); font-size: 18px; font-weight: 400; color: var(--color-text-primary); font-variant-numeric: tabular-nums; }
.bd-stat .bd-v small { font-size: 12px; font-weight: 300; color: var(--color-text-muted); margin-left: 6px; }

/* ---- table */
.bd-tablewrap { width: 100%; }
.bd table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bd thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--color-bg);
  text-align: left; padding: 10px 10px 8px;
  font-weight: 300; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--color-text-faint);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
.bd td {
  padding: 8px 10px; vertical-align: middle;
  border-bottom: 1px solid var(--color-border-subtle);
  font-weight: 400; font-variant-numeric: tabular-nums;
}
.bd th.bd-r, .bd td.bd-r { text-align: right; }
.bd tbody tr[data-id] { cursor: pointer; transition: background 150ms ease; }
.bd tbody tr[data-id]:hover { background: var(--color-hover-surface); }
.bd tbody tr.bd-row--deleted td { color: var(--color-text-faint); }
.bd tbody tr.bd-row--deleted td:not(.bd-thumbcell):not(.bd-tags) { text-decoration: line-through; }
.bd tbody tr.bd-row--pending td { font-style: italic; color: var(--color-text-muted); }
.bd td.bd-thumbcell { width: 76px; padding: 4px 10px 4px 0; }
.bd .bd-thumb, .bd .bd-nothumb {
  display: block; width: 64px; height: 48px; object-fit: cover;
  border: 1px solid var(--color-border-subtle); background: var(--color-hover-surface);
}
.bd .bd-nothumb { background: transparent; }
.bd td .bd-id { font-family: var(--mono); font-size: 15px; letter-spacing: 0.06em; color: var(--color-text-primary); }
.bd td .bd-no { font-family: var(--mono); font-size: 11px; color: var(--color-text-muted); }
.bd td .bd-mono { font-size: 12px; }
.bd td .bd-range { font-size: 11px; color: var(--color-text-muted); display: block; }
.bd td.bd-key { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bd td.bd-tags { white-space: nowrap; }
.bd .bd-empty { padding: 40px 10px; text-align: center; color: var(--color-text-muted); font-weight: 300; }

/* small-caps hairline tag: the only way a row states its condition */
.bd .bd-tag {
  display: inline-block; margin: 0 4px 2px 0; padding: 0 6px;
  border: 1px solid var(--color-border); font-size: 11px; line-height: 1.5;
  font-variant: small-caps; letter-spacing: 0.06em; font-weight: 300; font-style: normal;
  color: var(--color-text-muted); white-space: nowrap; text-decoration: none;
}
.bd .bd-tag.bd-fail { border-color: var(--bd-fail); }

/* skeleton rows while loading: hairline-grey blocks, a slow opacity pulse */
.bd .bd-skel { display: inline-block; height: 12px; width: 70%; background: var(--color-border-subtle); animation: bd-pulse 1.4s ease-in-out infinite; }
.bd .bd-skel.bd-skel-img { width: 64px; height: 48px; }
@keyframes bd-pulse { 50% { opacity: 0.35; } }

.bd-foot { padding: 14px 0; font-family: var(--mono); font-size: 11px; color: var(--color-text-faint); }

/* ---- drawer */
.bd-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--bd-drawer); z-index: 60;
  background: var(--color-bg); color: var(--color-text);
  border-left: 1px solid var(--color-border);
  overflow-y: auto; overflow-x: hidden;
  font-family: var(--font); font-weight: 300; font-size: 13px;
}
.bd-drawer, .bd-drawer * { box-sizing: border-box; }
.bd-dh {
  position: sticky; top: 0; z-index: 3; background: var(--color-bg);
  padding: 18px 22px 12px; border-bottom: 1px solid var(--color-border-subtle);
}
.bd-dh-top { display: flex; align-items: flex-start; gap: 12px; }
.bd-dh .bd-id { font-family: var(--mono); font-size: 28px; letter-spacing: 0.1em; color: var(--color-text-primary); line-height: 1.1; }
.bd-dh .bd-no { font-family: var(--mono); font-size: 12px; color: var(--color-text-muted); margin-left: 10px; }
.bd-dh .bd-sub { margin-top: 6px; color: var(--color-text-muted); font-size: 12px; }
.bd-dh .bd-sub .bd-mono { font-size: 12px; }
.bd-dh .bd-tags { margin-top: 8px; }
.bd-dh .bd-x { margin-left: auto; flex: 0 0 auto; }
.bd-dh-edit { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.bd-dh-edit input { font-family: var(--mono); letter-spacing: 0.08em; }
.bd-dactions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 22px 0; }
.bd-dactions .bd-spacer { flex: 1; }
.bd-dmsg { padding: 8px 22px 0; font-size: 12px; color: var(--color-text-muted); min-height: 0; }
.bd-dmsg.bd-fail { color: var(--bd-fail); }
.bd-dsec { padding: 16px 22px; border-bottom: 1px solid var(--color-border-subtle); }
.bd-dsec:last-child { border-bottom: 0; padding-bottom: 40px; }
.bd-dsec > .bd-label { display: block; margin-bottom: 10px; }
.bd-dsec details > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--color-text-faint);
}
.bd-dsec details > summary::-webkit-details-marker { display: none; }
.bd-dsec details > summary::before { content: "+"; font-family: var(--mono); width: 1em; color: var(--color-text-faint); }
.bd-dsec details[open] > summary::before { content: "−"; }
.bd-dsec details > summary:hover { color: var(--color-text); }
.bd-dsec details > .bd-dbody { margin-top: 12px; }

/* photos */
.bd-photo { margin-bottom: 18px; }
.bd-photo img { display: block; width: 100%; height: auto; border: 1px solid var(--color-border-subtle); cursor: zoom-in; background: var(--color-hover-surface); min-height: 60px; }
.bd-photo img.bd-mask { cursor: default; margin-top: 6px; }
.bd-photo .bd-cap { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 11px; color: var(--color-text-muted); font-family: var(--mono); }
.bd-photo .bd-cap .bd-spacer { flex: 1; }
.bd-photo .bd-cap button { font-size: 11px; padding: 3px 8px; }

/* two-column hairline grid: measurements, fields, provenance */
.bd-kv { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; }
.bd-kv > div { padding: 6px 0; border-bottom: 1px solid var(--color-border-subtle); min-width: 0; }
.bd-kv > div:nth-last-child(-n+2) { border-bottom: 0; }
.bd-kv .bd-k { color: var(--color-text-muted); padding-right: 10px; }
.bd-kv .bd-v { font-weight: 400; font-variant-numeric: tabular-nums; color: var(--color-text); word-break: break-word; }
.bd-kv .bd-v .bd-range { color: var(--color-text-muted); font-size: 12px; margin-left: 6px; }
.bd-kv .bd-v.bd-empty-v { color: var(--color-text-faint); font-weight: 300; }
.bd-kv input, .bd-kv textarea, .bd-kv select { width: 100%; font-size: 13px; padding: 4px 8px; }
.bd-kv input.bd-mono { font-family: var(--mono); }
.bd pre.bd-pre {
  margin: 0; padding: 8px 10px; white-space: pre-wrap; word-break: break-word;
  font-family: var(--mono); font-size: 12px; font-weight: 300; line-height: 1.5;
  color: var(--color-text); border: 1px solid var(--color-border-subtle); background: transparent;
}
.bd .bd-prose { margin: 0 0 10px; font-weight: 300; color: var(--color-text); white-space: pre-wrap; }
.bd textarea.bd-notes { width: 100%; min-height: 90px; resize: vertical; }
.bd .bd-note { white-space: pre-wrap; word-break: break-word; }

/* small tables inside the drawer (strips, workbook cells, assumptions) */
.bd .bd-mini { width: 100%; border-collapse: collapse; font-size: 12px; margin: 6px 0 10px; }
.bd .bd-mini th, .bd .bd-mini td { padding: 4px 8px; border-bottom: 1px solid var(--color-border-subtle); text-align: left; vertical-align: top; }
.bd .bd-mini th { font-weight: 300; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-faint); }
.bd .bd-mini td { font-family: var(--mono); font-weight: 400; font-variant-numeric: tabular-nums; }
.bd .bd-mini td.bd-r, .bd .bd-mini th.bd-r { text-align: right; }
.bd .bd-mini td.bd-prose-cell { font-family: var(--font); font-weight: 300; }
.bd .bd-side-h { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-text-muted); margin: 10px 0 4px; }

/* ---- lightbox: the original, fitted; ← → step; Esc closes */
.bd-lb {
  position: fixed; inset: 0; z-index: 80;
  background: var(--color-bg);
  display: flex; align-items: center; justify-content: center;
}
.bd-lb img { max-width: 100vw; max-height: 100vh; width: auto; height: auto; object-fit: contain; display: block; }
.bd-lb .bd-lb-cap {
  position: absolute; left: 16px; bottom: 14px; font-family: var(--mono); font-size: 12px;
  color: var(--color-text-muted); background: var(--color-bg); padding: 4px 8px;
}
.bd-lb .bd-lb-x { position: absolute; top: 12px; right: 14px; }
.bd-lb .bd-lb-nav { position: absolute; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 18px; padding: 10px 14px; }
.bd-lb .bd-lb-prev { left: 12px; }
.bd-lb .bd-lb-next { right: 12px; }
.bd-lb .bd-lb-state { position: absolute; top: 16px; left: 16px; font-size: 12px; color: var(--color-text-muted); }

/* ---- responsive: rail becomes a strip, drawer goes full-screen */
@media (max-width: 900px) {
  .bd-body { grid-template-columns: 1fr; }
  .bd-rail {
    position: static; border-right: 0; border-bottom: 1px solid var(--color-border-subtle);
    display: flex; overflow-x: auto; padding: 0; gap: 0;
  }
  .bd-rail a { padding: 10px 14px; white-space: nowrap; gap: 8px; }
  .bd-rail a.active::before { left: 14px; right: 14px; top: auto; bottom: 0; width: auto; height: 2px; }
  .bd-main { padding-left: 0; }
  .bd-tablewrap { overflow-x: auto; }   /* sticky thead only applies ≥900px (this clips it) */
  .bd table { min-width: 860px; }
  .bd-drawer { width: 100vw; border-left: 0; }
  .bd-user { margin-left: 0; }
}
