/* ═══════════════════════════════════════════════════════════════════════════
   SheepDog Admin — design system
   Single source of truth for the web admin's look. Served cached from
   /static/admin.css (mtime-versioned), replacing the inline _CSS block.

   Layers:
     1. Tokens        — colors, type, radii, motion
     2. Base          — reset, typography, nav, layout
     3. Components    — cards, tables, tags, pills, buttons, forms, dialogs
     4. Page pieces   — tracker grid, deliverables, filters
     5. Motion        — transitions, view transitions, toasts, loading
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Surfaces — darkest to lightest */
  --bg:            #0e0e12;
  --surface-1:     #18181f;   /* cards, nav, dialog */
  --surface-2:     #1e1e28;   /* stats, inputs, hover rows */
  --surface-3:     #242430;   /* raised hover */
  --border:        #2a2a35;
  --border-strong: #3a3a48;

  /* Text — primary to faintest */
  --text-1:   #f4f4f5;
  --text-2:   #d4d4d8;
  --text-3:   #a1a1aa;
  --text-4:   #7d7d8a;   /* captions (lifted from #71717a for contrast) */
  --text-dim: #5e5e6b;   /* placeholders, disabled (lifted from #52525b) */

  /* Accent + status hues */
  --accent:        #7c9ef8;
  --accent-strong: #3b5de7;
  --accent-hover:  #4a6cf7;
  --green:  #4ade80;  --neon:   #00ff88;  --yellow: #facc15;
  --red:    #f87171;  --orange: #fb923c;  --purple: #c084fc;
  --cyan:   #34d399;  --blue:   #60a5fa;

  /* Radii */
  --r-sm: 6px;  --r-md: 10px;  --r-lg: 14px;  --r-pill: 999px;

  /* Type scale */
  --fs-xs: 11px;  --fs-sm: 13px;  --fs-base: 14px;  --fs-md: 16px;

  /* Motion */
  --ease:  cubic-bezier(.22,.61,.36,1);
  --dur-1: 140ms;   /* hover, focus */
  --dur-2: 260ms;   /* reveals, toasts */

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(0,0,0,.35);
  --shadow-2: 0 10px 32px rgba(0,0,0,.5);
}

/* ── Base ──────────────────────────────────────────────────────────────── */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont,
    "Segoe UI Variable", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text-2);
  font-size: var(--fs-md); line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

::selection { background: rgba(124,158,248,.28); }

/* Nav */
nav {
  background: var(--surface-1); border-bottom: 1px solid var(--border);
  padding: 12px 24px; display: flex; align-items: center; gap: 24px;
  position: sticky; top: 0; z-index: 50;
}
nav .nav-flock-logo { display: flex; align-items: center; opacity: .9;
  transition: opacity var(--dur-1) var(--ease); text-decoration: none; }
nav .nav-flock-logo:hover { opacity: 1; }
nav .nav-flock-logo img { height: 22px; width: auto; display: block; filter: invert(1); }
nav .nav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
nav .brand-logo { display: flex; align-items: center; opacity: .8;
  transition: opacity var(--dur-1) var(--ease); }
nav .brand-logo:hover { opacity: 1; }
nav .brand-logo img { height: 24px; width: auto; display: block; filter: invert(1); }
nav .nav-account-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  color: var(--text-3); border: 1px solid var(--border);
  background: var(--surface-2);
  transition: color var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
nav .nav-account-btn:hover, nav .nav-account-btn.active {
  color: var(--text-1); border-color: var(--border-strong); background: var(--surface-3, #262634);
}
nav .nav-links a {
  color: var(--text-3); margin-right: 4px; font-size: 15px;
  padding: 5px 11px; border-radius: var(--r-sm);
  transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
nav .nav-links a:hover { color: var(--text-1); background: var(--surface-2); text-decoration: none; }
nav .nav-links a.active { color: var(--text-1); background: var(--surface-2); }

/* Layout */
.container { max-width: min(97vw, 2200px); margin: 0 auto; padding: 24px 28px; }
h2 { font-size: 20px; font-weight: 600; color: var(--text-1); margin-bottom: 12px; }
h3 {
  font-size: var(--fs-base); font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .08em; margin: 20px 0 8px;
}

.crumbs { font-size: 15px; color: var(--text-3); margin-bottom: 8px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.crumbs a { color: var(--text-3); }
.crumbs a:hover { color: var(--accent); text-decoration: none; }
.crumb-sep { color: var(--text-dim); }
.crumb-alias { color: var(--text-4); font-size: 13px; }

/* Breadcrumb dropdown — a <details> whose summary is a crumb segment.
   No box; just the label + a slightly bolder caret to hint it's interactive. */
.crumb-menu { position: relative; display: inline-block; }
.crumb-menu > summary {
  list-style: none; -webkit-appearance: none; cursor: pointer;
  color: var(--text-2); display: inline-flex; align-items: center; gap: 4px;
  border-radius: 5px; padding: 1px 3px;
  transition: color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
.crumb-menu > summary::-webkit-details-marker { display: none; }
.crumb-menu > summary::after {
  content: "⌄"; font-size: 14px; font-weight: 700; line-height: 1;
  color: var(--accent); position: relative; top: -2px;
}
.crumb-menu > summary:hover { color: var(--text-1); background: var(--surface-2); }
.crumb-menu[open] > summary { color: var(--text-1); background: var(--surface-2); }

/* Hierarchy nav row (prev / next / up) — its own line under the breadcrumb */
.hnav { display: flex; gap: 6px; margin-bottom: 14px; align-items: center; }

/* ── F-key flow map — mini floating project flowchart ─────────────────── */
#sd-flow {
  position: fixed; inset: 0; z-index: 500; display: flex;
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.5); backdrop-filter: blur(2px);
}
.flow-panel {
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  max-width: min(92vw, 1100px); max-height: 84vh; overflow: auto;
  padding: 16px 18px; min-width: 420px;
}
.flow-head { display: flex; align-items: center; gap: 8px; font-size: 15px;
  margin-bottom: 14px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.flow-body { display: flex; align-items: flex-start; gap: 14px; }
.flow-left { display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.flow-conn-v { width: 1px; align-self: stretch; background: var(--line-strong); }
.flow-rows { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.flow-row { display: flex; align-items: center; gap: 8px; }
.flow-conn { width: 14px; height: 1px; background: var(--line-strong); flex-shrink: 0; }
.flow-shots { display: flex; flex-wrap: wrap; gap: 5px; min-width: 0; }
.flow-node {
  display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  font-size: 13px; white-space: nowrap; cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease),
              transform var(--dur-1) var(--ease);
}
.flow-node:hover { border-color: var(--accent); background: var(--surface-3);
  color: var(--text-1); text-decoration: none; transform: translateY(-1px); }
.flow-node.flow-proj { font-weight: 700; background: var(--accent-soft); border-color: var(--accent-strong); color: var(--accent); }
.flow-node.flow-spot { font-weight: 600; min-width: 120px; }
.flow-node.flow-trk  { color: var(--text-3); }
.flow-node.flow-shot { padding: 2px 8px; font-size: 12px; font-family: ui-monospace, Menlo, monospace; }
.flow-node.flow-super { padding: 2px 8px; font-size: 12px; color: var(--purple); border-color: var(--purple-soft); }
/* status tint on shot nodes */
.flow-shot.sinprogress { border-color: #1e3a5a; }
.flow-shot.sapproved, .flow-shot.sdelivered { border-color: #1d5a36; }
.flow-shot.schangesrequested { border-color: #5a3a1e; }
.flow-shot.sonhold { border-color: #5a1e1e; }
.crumb-pop {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 80;
  min-width: 160px; max-height: 320px; overflow-y: auto;
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: 5px; box-shadow: var(--shadow-2);
  display: flex; flex-direction: column; gap: 1px;
}
.crumb-pop a {
  display: block; padding: 5px 10px; border-radius: 5px; font-size: var(--fs-sm);
  color: var(--text-3); white-space: nowrap;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.crumb-pop a:hover { background: var(--surface-3); color: var(--text-1); text-decoration: none; }
.crumb-pop a.cur { color: var(--accent); background: var(--accent-soft); }
.crumb-pop .crumb-pop-head {
  font-size: var(--fs-xs); color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .06em; padding: 3px 10px 5px;
}
.crumb-nav { display: flex; gap: 5px; margin-left: auto; }

.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.page-head h2 { margin: 0; }

/* ── Project salient strip ──────────────────────────────────────────────── */
.proj-salient-card { display: flex; flex-wrap: wrap; gap: 6px 32px; padding: 14px 18px; }
.proj-salient-field { display: flex; flex-direction: column; gap: 2px; min-width: 80px; }
.proj-salient-label { font-size: 10px; color: var(--text-4); text-transform: uppercase;
  letter-spacing: .06em; font-weight: 600; }

/* ── Project specs collapsible ──────────────────────────────────────────── */
.proj-specs-wrap { margin-bottom: 20px; }
.proj-specs-summary { cursor: pointer; list-style: none; font-size: 12px;
  color: var(--text-4); padding: 4px 0 6px; user-select: none;
  transition: color var(--dur-1) var(--ease); }
.proj-specs-summary::-webkit-details-marker { display: none; }
.proj-specs-summary::before { content: "▶  "; font-size: 9px; opacity: .6; }
details[open] .proj-specs-summary::before { content: "▼  "; }
.proj-specs-summary:hover { color: var(--text-2); }
.proj-specs-body { margin-top: 6px; margin-bottom: 0; }
.proj-specs-cols  { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.two-col-grid     { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.three-col-grid   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.proj-specs-col-head { font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  font-weight: 600; color: var(--text-4); margin-bottom: 10px; }
table.spec-tbl { width: 100%; border-collapse: collapse; }
table.spec-tbl td { padding: 3px 0; vertical-align: top; font-size: 13px; }
td.spec-lbl { color: var(--text-4); width: 110px; white-space: nowrap; padding-right: 12px; }

/* ── Cards & stats ─────────────────────────────────────────────────────── */

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 18px; margin-bottom: 16px;
}
.card-link { cursor: pointer; transition: border-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease); }
.card-link:hover { border-color: var(--accent); }

.stat-scope-bar {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: 8px;
  background: var(--surface-1); border: 1px solid var(--border);
  margin: 16px 0 10px;
}
.stat-scope-btn {
  appearance: none; background: transparent; border: 1px solid transparent;
  color: var(--text-3); font-size: 12px; font-weight: 600;
  padding: 4px 12px; border-radius: 6px; cursor: pointer;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
              border-color var(--dur-1) var(--ease);
}
.stat-scope-btn:hover { color: var(--text-1); }
.stat-scope-btn.active {
  background: var(--accent-soft); color: var(--accent);
  border-color: var(--accent-strong);
}

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.stat {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 13px 20px; min-width: 116px;
}
.stat .val { font-size: 24px; font-weight: 700; color: var(--accent); line-height: 1; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: var(--fs-xs); color: var(--text-4); margin-top: 4px; text-transform: uppercase; }
a.stat { display: block; text-decoration: none; cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
a.stat:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* ── Tables ────────────────────────────────────────────────────────────── */

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }
th {
  text-align: left; padding: 8px 11px; color: var(--text-4); font-weight: 600;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 8px 11px; border-bottom: 1px solid #1a1a22; vertical-align: middle; }
tr:hover td { background: #1c1c26; }

/* Subtle column dividers on data tables (not the deliverables matrix grid) */
.tbl-wrap > table > thead > tr > th:not(:last-child),
.tbl-wrap > table > tbody > tr > td:not(:last-child) {
  border-right: 1px solid #1e1e28;
}
/* Status-pill <select> wrapper — provides the caret on the LEFT side.
   The wrapper carries the background-color class (s-inprog etc.); the inner
   select is transparent so only one background color renders. */
.status-sel-wrap {
  display: inline-block; position: relative; border-radius: var(--r-pill);
  white-space: nowrap; justify-self: start;
}
.status-sel-wrap::before {
  content: "⌄"; position: absolute; left: 6px; top: 50%;
  transform: translateY(-54%); pointer-events: none;
  font-size: 11px; font-weight: 700; color: currentColor; opacity: .7;
}
/* Editable status dropdowns: hug their content, left-align, caret on left via wrapper. */
select.status-pill {
  width: auto; max-width: 190px; min-width: 0;
  text-align: left; text-align-last: left;
  -webkit-appearance: none; appearance: none;
  padding-left: 20px !important; padding-right: 8px !important;
}

/* Numeric columns: right-align with tabular figures so digits line up.
   Text/code columns stay left-aligned (the th default). Tables keep the base
   width:100% so they spread across the card; we only fix alignment here. */
.tbl-wrap > table th.num,
.tbl-wrap > table td.num {
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* Vet — repairs split into Sync / Bind / Danger columns. All buttons
   stay on one row. Note: the global `form { flex-direction: column }` rule
   must be overridden here with `flex-direction: row`. */
.ld-col-h { white-space: nowrap; }
.ld-col { vertical-align: middle; white-space: nowrap; }
.ld-grp { display: flex; flex-direction: row; gap: 4px; align-items: center; flex-wrap: nowrap; }
.ld-grp form { display: inline-flex; flex-direction: row; align-items: center; gap: 3px; margin: 0; flex-wrap: nowrap; }
.btn.btn-icon {
  padding: 4px 8px; min-width: 30px; text-align: center; line-height: 1.1;
  font-size: 14px; flex: 0 0 auto;
}
.ld-mini-sel {
  /* width:auto OVERRIDES the global `input,select{width:100%}` — otherwise the
     dropdown fills the cell and pushes the ⇄ icon onto the next line. */
  width: auto; min-width: 0; max-width: 110px; flex: 0 0 auto;
  padding: 3px 6px; font-size: 11px; border-radius: 6px;
  background: #1a1a24; border: 1px solid var(--border); color: var(--text-2);
}

/* Double-click inline edit (table cells + grid cells) */
[data-inline] { cursor: cell; border-radius: 4px; }
[data-inline]:hover { background: #1e1e2c; box-shadow: inset 0 0 0 1px var(--border); }
[data-inline].is-saving { opacity: .55; }
.inline-input {
  width: 100%; background: #1e2a3a; border: 1px solid var(--accent-strong);
  border-radius: 4px; color: var(--text-1); padding: 3px 6px; font-size: var(--fs-sm);
}

/* Enhanced tables — sortable headers + filter box */
th.th-sort { cursor: pointer; user-select: none; transition: color var(--dur-1) var(--ease); }
th.th-sort:hover { color: var(--text-2); }
th.th-sort::after { content: "⇅"; opacity: .25; margin-left: 5px; font-size: 10px; }
th.th-sort[data-sort="asc"]::after  { content: "↑"; opacity: 1; color: var(--accent); }
th.th-sort[data-sort="desc"]::after { content: "↓"; opacity: 1; color: var(--accent); }
.table-filter {
  width: 260px; max-width: 100%; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-pill); color: var(--text-2);
  padding: 6px 14px; font-size: var(--fs-sm);
}
/* Sticky header inside a scroll container */
.tbl-wrap { position: relative; }
.tbl-wrap table[data-enhance] thead th {
  position: sticky; top: 0; z-index: 5; background: var(--surface-1);
}

/* Dark scrollbars */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: #14141c; }
::-webkit-scrollbar-thumb { background: #3a3a50; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #52527a; }
::-webkit-scrollbar-corner { background: #14141c; }
* { scrollbar-color: #3a3a50 #14141c; scrollbar-width: thin; }

/* ── Tags & pills ──────────────────────────────────────────────────────── */

.tag {
  display: inline-block; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; background: #2a2a40; color: #9999cc;
  white-space: nowrap;
}
.tag.green  { background: #1a3a1a; color: var(--green); }
.tag.blue   { background: #1a2a3a; color: var(--blue); }
.tag.yellow { background: #3a3a1a; color: var(--yellow); }
.tag.red    { background: #3a1a1a; color: var(--red); }
.tag.orange { background: #3a2a1a; color: var(--orange); }
.tag.cyan   { background: #1a3a3a; color: var(--cyan); }
.tag.purple { background: #2a1a3a; color: var(--purple); }
.tier { font-size: var(--fs-xs); }
.empty { color: var(--text-dim); font-style: italic; }

/* ── Deliverables import review grid ───────────────────────────────────── */
.role-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px; margin: 10px 0 14px;
}
.role-cell { display: flex; flex-direction: column; gap: 3px; }
.role-cell label { font-size: 11px; color: var(--text-3); }
.role-cell select { width: 100%; }
.src-row {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px;
}
.src-row label { display: inline-flex; gap: 5px; align-items: center; color: var(--text-2); font-size: 13px; }
.src-row input[type="number"], .src-row input[type="text"], .src-row select { width: auto; }

/* Section-divider rows in the review grid: greyed + struck, re-includable */
tr.is-divider > td { background: #14141c; }
tr.is-divider .div-label {
  color: var(--text-dim); text-decoration: line-through; font-size: 12px; font-weight: 600;
}
tr.row-included  > td { background: rgba(74, 222, 128, 0.05); }
tr.row-excluded  > td { opacity: 0.4; }
tr.row-excluded code { text-decoration: line-through; }

/* ── Visual sheet / header-row picker (import step 1) ─────────────────────── */
.pk-grid { border-collapse: collapse; font-size: 12px; width: max-content; min-width: 100%; }
.pk-grid th, .pk-grid td {
  border: 1px solid #23232e; padding: 4px 8px; white-space: nowrap;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}
.pk-grid thead th { position: sticky; top: 0; z-index: 2; background: #15151c; }
.pk-corner, .pk-rownum {
  position: sticky; left: 0; z-index: 1; background: #15151c;
  color: var(--text-dim); text-align: center; font-variant-numeric: tabular-nums;
  width: 34px; min-width: 34px;
}
.pk-col { cursor: pointer; color: var(--text-3); user-select: none; }
.pk-col:hover { background: #1d1d28; }
.pk-colnum { font-size: 10px; font-weight: 600; letter-spacing: .03em; }
.pk-row { cursor: pointer; }
.pk-row:hover > .pk-cell { background: #1a1a24; }
/* rows above the header = ignored */
tr.pk-ignored > td { opacity: 0.35; background: #101015; }
/* the chosen header row */
tr.pk-header > td { background: rgba(96, 165, 250, 0.16); color: #bfdbfe; font-weight: 600; }
tr.pk-header > .pk-rownum { background: #1e3a5f; color: #bfdbfe; }
/* data rows below the header */
tr.pk-data > .pk-cell { background: rgba(74, 222, 128, 0.05); }
/* excluded column cells (header + body) */
.pk-grid .pk-excluded { opacity: 0.25; text-decoration: line-through; }

/* ── Filename extractor: segment ruler + assignments ─────────────────────── */
.seg-ruler { display: flex; flex-wrap: wrap; gap: 6px; }
.seg-box {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 10px; border-radius: 6px; cursor: pointer;
  background: #1a1a24; border: 1px solid #2a2a35; color: #d4d4d8;
  font-size: 12px; line-height: 1.2;
}
.seg-box:hover { border-color: #3a3a4a; }
.seg-box .seg-num { font-size: 9px; color: var(--text-dim); font-weight: 600; }
.seg-box .seg-val { white-space: nowrap; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.seg-box.sel { background: rgba(96, 165, 250, 0.18); border-color: #60a5fa; color: #bfdbfe; }
.seg-assign {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; margin-bottom: 5px;
  background: #15151c; border: 1px solid #23232e; border-radius: 6px;
}
.seg-assign .seg-fld {
  font-size: 12px; background: #1a2a1a; color: #4ade80;
  border: 1px solid #2d4a2d; border-radius: 4px; padding: 1px 7px; min-width: 84px; text-align: center;
}
.match-rule {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; margin-bottom: 5px;
  background: #15151c; border: 1px solid #23232e; border-radius: 6px; flex-wrap: wrap;
}
/* unsaved-changes cue on the Apply button */
#apply-btn.dirty { box-shadow: 0 0 0 2px rgba(96,165,250,.5); animation: applypulse 1.6s ease-in-out infinite; }
@keyframes applypulse { 0%,100% { opacity: 1; } 50% { opacity: .82; } }

/* ── Source-data panel (review screen): green = captured, dim = ignored ───── */
.src-grid { border-collapse: collapse; font-size: 12px; width: max-content; min-width: 100%; }
.src-grid th, .src-grid td {
  border: 1px solid #23232e; padding: 4px 8px; white-space: nowrap;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; text-align: left;
}
.src-grid thead th { position: sticky; top: 0; z-index: 2; background: #15151c; vertical-align: top; }
.src-rownum {
  position: sticky; left: 0; z-index: 1; background: #15151c;
  color: var(--text-dim); text-align: center; width: 30px; min-width: 30px;
  font-variant-numeric: tabular-nums;
}
.src-colname { font-size: 10px; color: var(--text-3); margin-bottom: 3px; }
.src-badge {
  font-size: 10px; font-weight: 600; border-radius: 3px; padding: 1px 5px;
  background: #1a2a1a; color: #4ade80; border: 1px solid #2d4a2d; display: inline-block;
}
.src-badge.muted { background: transparent; color: var(--text-dim); border-color: #23232e; }
td.src-col-captured { background: rgba(74, 222, 128, 0.06); color: #d4d4d8; }
th.src-col-captured { background: #16211a; }
.src-col-excluded { opacity: 0.3; text-decoration: line-through; }

.status-pill {
  display: inline-block; padding: 2px 8px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; white-space: nowrap;
  min-width: 90px; text-align: center;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.s-notstart { background: #1a1a22; color: var(--text-dim); border: 1px solid var(--border); }
.s-inprog   { background: #1a2a3a; color: var(--blue); }
.s-rendered { background: #2a1a3a; color: var(--purple); }
.s-review   { background: #3a3a1a; color: var(--yellow); }
.s-changes  { background: #3a2a1a; color: var(--orange); }
.s-approved { background: #1a3a1a; color: var(--green); }
.s-flame    { background: #1a3a3a; color: var(--cyan); }
.s-delivered{ background: #1a3a2a; color: #6ee7b7; }
.s-hold     { background: #3a1a1a; color: var(--red); }

/* ── Forms ─────────────────────────────────────────────────────────────── */

form { display: flex; flex-direction: column; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; }
label { font-size: var(--fs-sm); color: var(--text-3); }

input, select, textarea {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text-2);
  padding: 7px 9px; font-size: var(--fs-base); width: 100%;
  /* Dark-mode native widgets: the date-picker calendar, spinners and the
     calendar glyph all honour color-scheme. Set it on the control itself so
     inline-styled inputs inherit it too. */
  color-scheme: dark;
  transition: border-color var(--dur-1) var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
/* Radios/checkboxes must NOT inherit the global width:100%/padding above — in a
   flex <label> they'd stretch to uneven giant circles. Keep them native-sized. */
input[type="radio"], input[type="checkbox"] {
  width: auto; flex: 0 0 auto; padding: 0; margin: 0;
  accent-color: var(--accent);
}
/* Brighten the little calendar/clock glyph so it's visible on dark inputs */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(0.85);
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 16px; border-radius: var(--r-sm); cursor: pointer;
  font-size: var(--fs-base); font-weight: 600; border: none;
  transition: background var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
              transform var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent-strong); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger  { background: #7f1d1d; color: #fca5a5; }
.btn-danger:hover { background: #991b1b; }
.btn-ghost {
  background: var(--border); color: var(--text-2);
}
.btn-ghost:hover { background: var(--border-strong); }
.btn-sm { font-size: var(--fs-sm); padding: 3px 10px; }
.btn-row { display: flex; gap: 8px; margin-top: 4px; }

/* Submitting state — set by admin.js on form submit */
.btn.is-loading { opacity: .6; pointer-events: none; position: relative; }
.btn.is-loading::after {
  content: ""; width: 12px; height: 12px; flex-shrink: 0;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .55s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Alerts */
.alert { padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 12px; font-size: var(--fs-sm); }
.alert-ok   { background: #14291e; border: 1px solid #16a34a; color: #86efac; }
.alert-err  { background: #290f0f; border: 1px solid #dc2626; color: #fca5a5; }
.alert-warn { background: #2a2210; border: 1px solid #a16207; color: #fcd34d; }

/* Pagination */
.pager { display: flex; gap: 8px; margin-top: 12px; align-items: center; font-size: 12px; }
.pager a { padding: 3px 8px; border: 1px solid var(--border); border-radius: 4px; }
.pager span { color: var(--text-4); }

/* Tabs */
.tabs { display: flex; gap: 2px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.tabs a {
  padding: 6px 14px; font-size: var(--fs-sm); color: var(--text-4);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color var(--dur-1) var(--ease);
}
.tabs a:hover { color: var(--text-2); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Tracker grid (spot detail) ────────────────────────────────────────── */

.tracker-scroll { overflow-x: auto; }
.tracker-grid { display: flex; flex-direction: column; gap: 4px; min-width: max-content; }
.tracker-row {
  display: grid; align-items: center; justify-items: start; gap: 8px; padding: 5px 8px;
  background: #1a1a22; border-radius: 5px; font-size: var(--fs-sm);
  width: max-content; min-width: 100%;
  transition: background var(--dur-1) var(--ease);
}
.tracker-row:hover { background: #1e1e2c; }
.overdue-row { background: #1f1515 !important; border-left: 3px solid #7f1d1d; }
.overdue-row:hover { background: #251818 !important; }
.shot-num { font-family: monospace; font-size: 12px; color: var(--text-3); min-width: 48px; }
.tracker-header {
  display: grid; gap: 8px; padding: 4px 8px; justify-items: start;
  font-size: var(--fs-xs); color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .06em; width: max-content; min-width: 100%;
}
/* Only the shot number (first column) is sticky on desktop — the status and
   everything else scrolls under it. */
.tracker-row > *:nth-child(1), .tracker-header > *:nth-child(1) { position: sticky; left: 0; z-index: 2; }
.tracker-row > *:nth-child(1) { background: #1a1a22; box-shadow: 10px 0 8px -8px rgba(0,0,0,.7); }
.tracker-row:hover > *:nth-child(1) { background: #1e1e2c; }
.tracker-header > *:nth-child(1) { background: var(--surface-1); }

/* ── Checkboxes ────────────────────────────────────────────────────────── */

input[type="checkbox"].rowsel,
input[type="checkbox"].modern-cb {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; border: 1.5px solid #3f3f46; border-radius: 4px;
  background: var(--surface-2); cursor: pointer; position: relative;
  transition: all var(--dur-1) var(--ease); flex-shrink: 0;
}
input[type="checkbox"].rowsel:checked,
input[type="checkbox"].modern-cb:checked { background: var(--accent-strong); border-color: var(--accent-strong); }
input[type="checkbox"].rowsel:checked::after,
input[type="checkbox"].modern-cb:checked::after {
  content: ""; position: absolute; left: 4px; top: 1px;
  width: 5px; height: 9px; border: 2px solid #fff;
  border-top: none; border-left: none; transform: rotate(45deg);
}
input[type="checkbox"].rowsel:hover, input[type="checkbox"].modern-cb:hover { border-color: var(--accent); }

/* ── Deliverables ──────────────────────────────────────────────────────── */

.dlv-editable {
  display: inline-block; min-width: 50px; border-radius: 3px;
  outline: none; cursor: text; color: var(--text-3);
  transition: background var(--dur-1) var(--ease);
}
.dlv-editable:hover { background: #1e1e2c; }
.dlv-editable:focus { background: #1e2a3a; outline: 1px solid var(--accent-strong); color: var(--text-2); }
.dlv-editable:empty::before { content: attr(data-placeholder); color: #3a3a50; }
.dlv-editable.is-saving { opacity: .55; }
.dlv-editable.save-fail { outline: 1px solid var(--red); }

/* Filter pills */
.fpill {
  display: inline-block; padding: 5px 13px; border: 1px solid var(--border);
  border-radius: var(--r-pill); font-size: var(--fs-sm); color: var(--text-3);
  background: #16161d; white-space: nowrap;
  transition: border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
              background var(--dur-1) var(--ease);
}
.fpill:hover { border-color: #3f3f46; color: var(--text-1); text-decoration: none; }
.fpill.on { background: #1a2a3a; border-color: var(--accent-strong); color: var(--accent); font-weight: 600; }
/* Exclusive tag filter (tri-state: off → exclusive → non-exclusive/union → off) */
.fpill.on.tag-excl { background: var(--accent-strong); border-color: var(--accent-strong); color: #0a0a0f; }
.fpill-label {
  font-size: 12px; color: var(--text-dim); text-transform: uppercase;
  letter-spacing: .06em; margin-right: 2px;
}

/* ── Dialogs ───────────────────────────────────────────────────────────── */

dialog {
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: 12px; color: var(--text-2); padding: 22px 24px;
  min-width: 460px; max-width: 92vw; box-shadow: var(--shadow-2);
  margin: auto;
}
dialog::backdrop { background: rgba(0,0,0,.55); backdrop-filter: blur(2px); }
dialog h3 { margin-top: 0; }
dialog.dlg-open { animation: dlg-in var(--dur-2) var(--ease); }
@keyframes dlg-in {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.dlg-close {
  position: absolute; top: 12px; right: 14px; background: none;
  border: none; color: var(--text-4); font-size: 18px; cursor: pointer;
  transition: color var(--dur-1) var(--ease);
}
.dlg-close:hover { color: var(--text-1); }

/* ── Toasts (admin.js lifts data-flash alerts here) ────────────────────── */

#toast-rack {
  position: fixed; bottom: 22px; right: 22px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: 11px 16px; font-size: var(--fs-sm);
  color: var(--text-2); box-shadow: var(--shadow-2); max-width: 420px;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.toast.ok::before  { background: var(--neon); box-shadow: 0 0 8px rgba(0,255,136,.6); }
.toast.err::before { background: var(--red);  box-shadow: 0 0 8px rgba(248,113,113,.6); }
.toast .toast-x {
  background: none; border: none; color: var(--text-4); cursor: pointer;
  font-size: 15px; padding: 0 0 0 4px; line-height: 1;
}
.toast .toast-x:hover { color: var(--text-1); }

/* ── Mobile ─────────────────────────────────────────────────────────────── */

#nav-hamburger {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--text-3); padding: 4px 6px; border-radius: var(--r-sm);
  font-size: 20px; line-height: 1; margin-left: auto;
  transition: color var(--dur-1) var(--ease);
}
#nav-hamburger:hover { color: var(--text-1); }

/* Expand-columns button — hidden on desktop, shown via media query */
.tc-expand-btn { display: none; }

@media (max-width: 768px) {
  /* Nav — collapse links behind hamburger */
  nav { flex-wrap: wrap; gap: 0; padding: 10px 16px; }
  nav .nav-flock-logo { flex: 0 0 auto; }
  nav .brand-logo { display: none; }
  #nav-hamburger { display: block; }
  nav .nav-links {
    display: none; flex-direction: column; width: 100%; gap: 2px;
    padding: 8px 0 4px;
  }
  nav.nav-open .nav-links { display: flex; }
  nav .nav-links a { font-size: 15px; padding: 8px 10px; }

  /* Container — tighter on phone */
  .container { padding: 16px 14px; }

  /* Dashboard button grid — hide on mobile, projects lead */
  .dash-btn-grid { display: none; }

  /* Stat row — horizontal scroll strip (no wrap) */
  .stat-row {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 8px; margin-bottom: 12px; padding-bottom: 4px; scrollbar-width: none;
  }
  .stat-row::-webkit-scrollbar { display: none; }
  .stat { flex: 0 0 auto; }

  /* Multi-col grids — collapse to single column */
  .proj-specs-cols,
  .two-col-grid,
  .three-col-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Spot header — allow title + badges to wrap on narrow screens */
  .spot-title-row { flex-wrap: wrap; gap: 8px 12px; }

  /* Tracker expand-columns toggle button */
  .tc-expand-btn {
    display: flex; align-items: center; gap: 5px; margin-bottom: 8px;
    font-size: 12px; color: var(--text-4); background: none; border: none;
    cursor: pointer; padding: 0; transition: color var(--dur-1) var(--ease);
  }
  .tc-expand-btn:hover { color: var(--text-2); }

  /* Tracker grid: glanceable 2-col (shot# + status) by default on mobile */
  .tracker-scroll:not(.tc-expanded) .tracker-grid { min-width: auto; }
  .tracker-scroll:not(.tc-expanded) .tracker-row,
  .tracker-scroll:not(.tc-expanded) .tracker-header {
    grid-template-columns: 64px 1fr !important;
  }
  /* !important required — artist cells carry inline display:inline-flex */
  .tracker-scroll:not(.tc-expanded) .tracker-row > *:nth-child(n+3),
  .tracker-scroll:not(.tc-expanded) .tracker-header > *:nth-child(n+3) {
    display: none !important;
  }

  /* No sticky columns on mobile — iOS Safari doesn't support sticky inside
     overflow-x:auto + flex nesting. Collapsed view never scrolls (2 cols);
     expanded view scrolls freely without broken sticky. */
  .tracker-row > *:nth-child(1), .tracker-header > *:nth-child(1),
  .tracker-row > *:nth-child(2), .tracker-header > *:nth-child(2) { position: static; }
  .tracker-row > *:nth-child(-n+2) { box-shadow: none; }
  .tracker-header > *:nth-child(-n+2) { background: var(--surface-1); }

  /* Breadcrumbs — allow wrapping, keep compact */
  .crumbs { font-size: 13px; gap: 4px; }
  .hnav { flex-wrap: wrap; }

  /* Full-width dialogs */
  dialog { max-width: 96vw !important; margin: 2vh auto !important; }
}

/* ── Motion ────────────────────────────────────────────────────────────── */

/* Cross-page fade (Chrome 126+/Safari 18.2+; others navigate instantly) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) {
  animation-duration: 150ms;
}

/* Pre-paint hide for entrance animation; admin.js (or its safety timeout)
   removes the class. Without JS the class is never added. */
html.anim-init .container > * { opacity: 0; }

/* Status-change pulse (deliverables) */
@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 rgba(124,158,248,.45); }
  100% { box-shadow: 0 0 0 9px rgba(124,158,248,0); }
}
.status-pulse { animation: pulse-ring .5s var(--ease); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html.anim-init .container > * { opacity: 1; }
}

/* ── Project sync-health badge ──────────────────────────────────────────── */
.sync-health {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--fs-sm); color: var(--text-3);
  padding: 7px 12px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-1);
}
.sync-health .sh-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--text-dim);
}
.sync-health.sh-checking .sh-dot { background: var(--text-dim); animation: sh-pulse 1.1s ease-in-out infinite; }
.sync-health.sh-sync    { border-color: #1e3a2a; }
.sync-health.sh-sync    .sh-dot  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.sync-health.sh-sync    .sh-text { color: var(--green); }
.sync-health.sh-drift   { border-color: #5a4a1a; background: #1b1708; }
.sync-health.sh-drift   .sh-dot  { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }
.sync-health.sh-drift   .sh-text { color: var(--yellow); }
.sync-health.sh-pending { border-color: #1e3550; background: #0b1422; }
.sync-health.sh-pending .sh-dot  { background: #7c9ef8; box-shadow: 0 0 6px #7c9ef8; }
.sync-health.sh-pending .sh-text { color: #7c9ef8; }
.sync-health.sh-unknown .sh-dot  { background: var(--text-dim); }
.sync-health .sh-text { flex: 1 1 auto; min-width: 0; }
@keyframes sh-pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

/* ── Vet merge — git-style per-cell conflict table ──────────────────────── */
.merge-tbl td.merge-cell {
  cursor: pointer; user-select: none; position: relative;
  border-radius: var(--r-sm); transition: background .12s, color .12s, box-shadow .12s;
}
.merge-tbl td.merge-cell:hover { box-shadow: inset 0 0 0 1px var(--text-dim); }
/* unresolved mismatch — both sides red */
.merge-cell.mc-mismatch { color: #f87171; background: rgba(248,113,113,.08); }
/* chosen side — green ring + check */
.merge-cell.mc-chosen {
  color: var(--green); background: rgba(74,222,128,.12);
  box-shadow: inset 0 0 0 1px var(--green);
}
.merge-cell.mc-chosen::after {
  content: "✓"; position: absolute; top: 2px; right: 5px;
  font-size: 11px; color: var(--green); opacity: .9;
}
/* losing side — dimmed */
.merge-cell.mc-dim { color: var(--text-dim); opacity: .5; }

/* ── Flock-wide chrome (moved up from deliverables.css per
   docs/flock-ui-guidelines.md rollout step 1 — 2026-07-16). ─────────────── */

/* Disclosure pattern: <details class="card sd-disclose"> with the caret as
   the FIRST summary element. */
details.sd-disclose > summary {
  cursor: pointer; list-style: none; display: flex; align-items: center;
  gap: 10px; user-select: none; margin: -6px -8px; padding: 6px 8px;
  border-radius: 8px;
}
details.sd-disclose > summary::-webkit-details-marker { display: none; }
details.sd-disclose > summary:hover { background: rgba(255, 255, 255, 0.035); }
.sd-caret {
  flex: none; width: 22px; height: 22px; display: inline-flex;
  align-items: center; justify-content: center; border-radius: 6px;
  background: #26263a; color: #a1a1aa; font-size: 12px; line-height: 1;
  transition: transform 0.15s ease;
}
details.sd-disclose[open] > summary .sd-caret { transform: rotate(90deg); }
.sd-summary-hint { color: #52525b; font-size: 12px; }

/* Overflow "⋯" dropdown menus. Outside-click close lives in admin.js. */
details.sd-menu { position: relative; display: inline-block; }
details.sd-menu > summary { list-style: none; cursor: pointer; }
details.sd-menu > summary::-webkit-details-marker { display: none; }
.sd-menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 220;
  background: #1e1e2c; border: 1px solid #3a3a50; border-radius: 10px;
  padding: 6px; min-width: 220px; display: flex; flex-direction: column;
  gap: 2px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}
.sd-menu-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px;
  border-radius: 6px; font-size: 13px; color: #d4d4d8; background: none;
  border: none; text-align: left; cursor: pointer; text-decoration: none;
  width: 100%; font-family: inherit; white-space: nowrap;
}
.sd-menu-item:hover { background: #26263a; color: #f4f4f5; }
.sd-menu-item.danger { color: #f87171; }
.sd-menu-item[disabled] { opacity: 0.4; cursor: default; }
.sd-menu-sep { height: 1px; background: #2a2a3a; margin: 4px 8px; }

/* Contextual selection-bar buttons (bar itself is page-owned). */
.btn-selbar {
  font-size: 12px; padding: 3px 10px; background: transparent;
  color: #b7bfd6; border: 1px solid #33405e; border-radius: 6px;
  cursor: pointer; font-family: inherit; white-space: nowrap;
}
.btn-selbar:hover { color: #fff; border-color: #4a5b85; background: #1d2436; }
.btn-selbar.danger { color: #f87171; border-color: #4a2626; }
.btn-selbar.danger:hover { background: #2a1717; border-color: #6a3030; }

/* Narrow centered dialogs (confirm prompts, small forms). */
.sd-dialog-narrow {
  background: #1e1e2c; border: 1px solid #3a3a50; border-radius: 10px;
  padding: 24px 28px; color: #d4d4d8; box-shadow: 0 20px 60px #000a;
  margin: auto;
}
.sd-dialog-narrow::backdrop { background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(2px); }

/* ── Small utilities (inline-style demotion, 2026-07-16) ────────────────
   Inputs/selects/labels are styled GLOBALLY above — never restyle their
   chrome inline; add only width/layout constraints. */
.form-row { display: flex; flex-direction: row; flex-wrap: wrap;
            gap: 12px; align-items: flex-end; }
.tag.draft { background: #2a2010; color: #fbbf24; border: 1px solid #5a4a1a; }
.sd-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface-2, #1a1a24); border: 1px solid #2a2a35;
  border-radius: 4px; padding: 1px 4px 1px 8px; margin: 2px;
}
.sd-chip code { font-size: 12px; color: var(--text-3); }
.sd-chip.pad { padding: 1px 8px; }          /* chip without a trailing button */
.sd-chip.dup { background: #3a1a1a; border-color: #7f1d1d; }
.sd-chip.dup code { color: #f87171; }

/* People table profile disclosure button — clearly clickable pill next to inline-editable name */
.person-name-cell { font-weight: 500; white-space: nowrap; text-align: left; }
.person-open-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 22px; margin-right: 10px; vertical-align: middle;
  border-radius: 6px;
  background: var(--accent-soft); border: 1px solid var(--accent-strong);
  color: var(--accent); text-decoration: none; cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
              color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.person-open-btn:hover {
  background: var(--accent); border-color: var(--accent);
  color: #fff; text-decoration: none; transform: translateX(1px);
}
.person-open-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
