/* Scott Analytics — dark theme rebuild
 * Aligned to docs/design/ mockups. Section order:
 *   1. Tokens + reset
 *   2. App shell (sidebar / topbar / main)
 *   3. Buttons + form controls
 *   4. Page header + scheduler banner
 *   5. Filter bar + tabs + active-filter pills
 *   6. Bid table (grid layout, compact 44px rows)
 *   7. Pills (score / reco / status / portal / closing)
 *   8. Drawer
 *   9. Bid detail header (big score, metadata strip, layout grid)
 *  10. Cards (AI summary, scope, scoring breakdown bars, signals)
 *  11. Right rail (decision, key dates, stakeholders, similar bids)
 *  12. RFIs + Activity (audit log)
 *  13. Info-sheet content + attachments
 *  14. Search results
 *  15. Login + auth
 *  16. Empty states + utilities
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ---------- 1. Tokens ---------- */
:root {
  --bg: #1a1a1a;
  --card: #252525;
  --card-2: #222;
  --row-alt: #1f1f1f;
  --row-hover: #2a2a2a;
  --border: #2e2e2e;
  --border-2: #3a3a3a;
  --text: #e9e9e9;
  --text-2: #b5b5b5;
  --muted: #7d7d7d;
  --muted-2: #5c5c5c;
  --orange: #ff7a00;
  --orange-dim: #b35500;
  --orange-soft: rgba(255,122,0,.12);
  --green: #2ea043;
  --green-soft: rgba(46,160,67,.14);
  --amber: #e5a23b;
  --amber-soft: rgba(229,162,59,.14);
  --red: #e5484d;
  --red-soft: rgba(229,72,77,.14);
  --blue: #4c8dff;
  --blue-soft: rgba(76,141,255,.14);
  --purple: #a06bff;
  --purple-soft: rgba(160,107,255,.14);

  --sidebar-w: 220px;
  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
.mono { font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #181818; }
::-webkit-scrollbar-thumb { background: #2e2e2e; border-radius: 10px; border: 2px solid #181818; }
::-webkit-scrollbar-thumb:hover { background: #3a3a3a; }

h1 { margin: 0; font-size: 22px; font-weight: 600; letter-spacing: -0.2px; }
h2 { margin: 0 0 10px; font-size: 13px; font-weight: 600; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
h3 { margin: 0; font-size: 10px; font-weight: 600; letter-spacing: 1.4px; color: var(--muted); text-transform: uppercase; }

/* ---------- 2. App shell ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  max-width: 1620px; /* 220px sidebar + 1400px page cap — centers app on ultrawides */
  margin: 0 auto;
}
/* Unauthenticated pages (login, future reset flow) — collapse the sidebar
   column and hide the topbar. Without this, the grid reserves 240px for a
   sidebar that isn't rendered, squeezing content into a narrow slot. */
.layout.layout--auth { grid-template-columns: 1fr; }
.layout.layout--auth .topbar { display: none; }
/* `.page` has a 1400px cap to keep content columns readable on ultrawides —
   but the login wrapper self-centers with `place-items: center` against its
   parent's width, so we need the parent to span the full viewport or the
   card gets offset left on >1400px screens. */
.layout.layout--auth .page { max-width: none; padding: 0; }

/* Sidebar */
.sidebar {
  background: #151515;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
}
.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
}
.brand-logo-lg { width: 96px; height: 96px; }

.modules { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.module {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 12.5px;
  text-decoration: none;
}
.module:hover { background: #1d1d1d; color: var(--text); }
.module-active {
  background: #1a1a1a;
  color: var(--orange);
  box-shadow: inset 2px 0 0 var(--orange);
  border-radius: 4px 6px 6px 4px;
}
.module-disabled { color: var(--muted-2); cursor: default; }
.module-disabled:hover { background: transparent; color: var(--muted-2); }
.module-badge {
  font-size: 9px;
  letter-spacing: 0.8px;
  color: var(--muted-2);
  background: #202020;
  border: 1px solid var(--border);
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
}
.sidebar-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-foot .foot-line { opacity: 0.6; }

/* Mailbox widget — sidebar foot. Two states: connect (not yet linked) and
   connected (polling a real mailbox). Both are plain anchor tags that hit
   /bids/ingest/oauth/start — the "Switch" affordance reruns the consent
   flow, which overwrites the stored credential row. */
.mailbox-widget {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 11.5px;
  color: var(--text-2);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  transition: background 0.12s, border-color 0.12s;
}
.mailbox-widget:hover { background: rgba(255, 255, 255, 0.05); border-color: var(--muted-2); }
.mailbox-widget-connect { color: var(--orange); border-color: rgba(240, 127, 22, 0.35); }
.mailbox-widget-connect:hover { background: rgba(240, 127, 22, 0.08); border-color: var(--orange); }
.mailbox-widget-connect .mailbox-icon { font-size: 13px; }

.mailbox-widget-connected .mailbox-label {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  flex: 1;
  min-width: 0;
}
.mailbox-status-text { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted-2); }
.mailbox-email {
  color: var(--text);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mailbox-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #3ecf8e;
  box-shadow: 0 0 0 2px rgba(62, 207, 142, 0.15);
  flex: none;
}
.mailbox-action {
  font-size: 10px;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.7;
}
.mailbox-widget-connected:hover .mailbox-action { opacity: 1; color: var(--orange); }

/* Flash message — one-shot confirmation (e.g. ?connected=… after OAuth). */
.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin: 0 0 16px;
  font-size: 13px;
}
.flash-success {
  background: rgba(62, 207, 142, 0.08);
  border: 1px solid rgba(62, 207, 142, 0.35);
  color: #8fe3b6;
}
.flash .mono { color: var(--text); }

/* Empty-state CTA — primary action button when there's nothing to show. */
.empty-cta { display: inline-block; margin-top: 16px; }

/* Flash — error variant (paired with .flash-success defined above). */
.flash-error {
  background: rgba(239, 83, 83, 0.08);
  border: 1px solid rgba(239, 83, 83, 0.4);
  color: #f5a5a5;
}
.flash-muted {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--muted-2);
}
.flash-muted strong { color: var(--text); }
.flash-muted a { color: var(--orange); }

/* ---------- Admin / Users page ---------- */
.admin-section { margin-top: 28px; }
.admin-section h2 {
  font-size: 14px;
  color: var(--muted-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 14px;
  font-weight: 600;
}
.admin-section h2 .count {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  margin-left: 6px;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
}

.admin-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  max-width: 640px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}
.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted-2);
}
.admin-form label > span:first-child {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
}
.admin-form input[type="text"],
.admin-form input[type="email"],
.admin-form input[type="password"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
}
.admin-form input:focus {
  outline: none;
  border-color: var(--orange);
}
.admin-form .admin-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  grid-column: span 2;
  text-transform: none;
  color: var(--text-2);
  letter-spacing: 0;
}
.admin-form .admin-checkbox input { margin: 0; }
.admin-form button[type="submit"] { grid-column: span 2; justify-self: start; }

.admin-table {
  width: 100%;
  max-width: 1200px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.admin-table th, .admin-table td {
  padding: 10px 14px;
  text-align: left;
  font-size: 12.5px;
  border-bottom: 1px solid var(--border);
}
/* Name column (2nd) shouldn't wrap — "Joe Scott Sr." was breaking onto two
   lines. Email column stays default-wrap so long addresses still fit; date
   column is short enough that nowrap there is also a freebie. */
.admin-table th:nth-child(2),
.admin-table td:nth-child(2) { white-space: nowrap; }
.admin-table th {
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted-2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10.5px;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table .muted { color: var(--muted-2); }
.admin-table .you { color: var(--muted-2); font-size: 10.5px; }

.role-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.role-admin { background: rgba(240, 127, 22, 0.15); color: var(--orange); border: 1px solid rgba(240, 127, 22, 0.35); }
.role-owner { background: rgba(120, 195, 255, 0.12); color: #9bd0ff; border: 1px solid rgba(120, 195, 255, 0.35); }
.role-developer { background: rgba(180, 130, 255, 0.14); color: #c8a6ff; border: 1px solid rgba(180, 130, 255, 0.4); }
.role-user { background: rgba(255, 255, 255, 0.04); color: var(--muted-2); border: 1px solid var(--border); }
.role-inactive { background: rgba(239, 83, 83, 0.08); color: #f5a5a5; border: 1px solid rgba(239, 83, 83, 0.3); margin-left: 4px; }
.role-shield { color: #9bd0ff; margin-right: 4px; font-size: 12px; }

/* Usage dashboard — stat cards + action mix + sparkline */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 18px 0 6px;
}
.dash-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  /* Cards are anchor tags so they can drive HTMX swaps — strip link styling
     and add a subtle hover so the cursor cue makes intent obvious. */
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.dash-card:hover {
  border-color: rgba(255, 122, 0, 0.45);
  background: rgba(255, 255, 255, 0.04);
  transform: translateY(-1px);
}
.dash-card-active {
  border-color: var(--orange);
  background: rgba(255, 122, 0, 0.08);
  box-shadow: inset 2px 0 0 var(--orange);
}
.dash-card-active .dash-card-label {
  color: var(--orange);
}
.dash-card-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.dash-card-value { font-size: 22px; font-weight: 600; color: var(--text); margin-top: 4px; line-height: 1.1; }
.dash-card-value a { color: var(--orange); text-decoration: none; }
.dash-card-value a:hover { text-decoration: underline; }
.dash-card-of { font-size: 14px; color: var(--muted-2); font-weight: 400; }
.dash-card-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }

.dash-mix { margin: 18px 0 6px; }
.dash-mix-title { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 8px; }
.dash-mix-title .count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted-2);
  text-transform: none;
}
.dash-mix-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dash-mix-list li {
  display: grid;
  grid-template-columns: 200px 1fr 40px;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}
.dash-mix-action { color: var(--muted-2); font-family: var(--mono, monospace); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-mix-bar { background: rgba(255, 255, 255, 0.04); border-radius: 4px; height: 10px; overflow: hidden; }
.dash-mix-bar-fill {
  display: block;
  height: 100%;
  background: var(--orange);
  border-radius: 4px;
  position: relative;
  overflow: hidden;
  /* Grow each bar from the left on mount so the chart "draws itself" — fires
     fresh every time HTMX swaps in a new partial because the element is
     re-inserted into the DOM. Stagger below produces a left-to-right cascade. */
  transform-origin: left center;
  animation: dash-mix-bar-grow 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
/* Continuous shimmer — a faint sheen sweeps left-to-right inside each bar
   every few seconds so the chart reads as "live" data rather than a static
   PNG. Layered on top of the orange fill, runs forever (unless the user has
   prefers-reduced-motion set). */
.dash-mix-bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.22) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: translateX(-100%);
  animation: dash-mix-bar-shimmer 2.8s ease-in-out infinite;
}
@keyframes dash-mix-bar-grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}
@keyframes dash-mix-bar-shimmer {
  0%   { transform: translateX(-100%); }
  55%  { transform: translateX(200%); }
  100% { transform: translateX(200%); }
}
.dash-mix-list li:nth-child(1) .dash-mix-bar-fill { animation-delay: 0ms; }
.dash-mix-list li:nth-child(2) .dash-mix-bar-fill { animation-delay: 60ms; }
.dash-mix-list li:nth-child(3) .dash-mix-bar-fill { animation-delay: 120ms; }
.dash-mix-list li:nth-child(4) .dash-mix-bar-fill { animation-delay: 180ms; }
.dash-mix-list li:nth-child(5) .dash-mix-bar-fill { animation-delay: 240ms; }
.dash-mix-list li:nth-child(6) .dash-mix-bar-fill { animation-delay: 300ms; }
.dash-mix-list li:nth-child(7) .dash-mix-bar-fill { animation-delay: 360ms; }
/* Slight desync on the shimmer so the chart feels like organic motion rather
   than a synchronized strobe. */
.dash-mix-list li:nth-child(2) .dash-mix-bar-fill::after { animation-delay: 0.4s; }
.dash-mix-list li:nth-child(3) .dash-mix-bar-fill::after { animation-delay: 0.8s; }
.dash-mix-list li:nth-child(4) .dash-mix-bar-fill::after { animation-delay: 1.2s; }
.dash-mix-list li:nth-child(5) .dash-mix-bar-fill::after { animation-delay: 1.6s; }
.dash-mix-list li:nth-child(6) .dash-mix-bar-fill::after { animation-delay: 2.0s; }
.dash-mix-list li:nth-child(7) .dash-mix-bar-fill::after { animation-delay: 2.4s; }
/* Health-state recolor: amber for "warn", red for "bad" stages. The shimmer
   on bad bars also speeds up slightly to communicate urgency. */
.dash-mix-bar-fill.health-warn { background: #f59e0b; }
.dash-mix-bar-fill.health-bad  { background: #ef4444; }
.dash-mix-bar-fill.health-bad::after {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.32) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation-duration: 1.8s;
}
@media (prefers-reduced-motion: reduce) {
  .dash-mix-bar-fill,
  .dash-mix-bar-fill::after { animation: none; }
}
.dash-mix-count { color: var(--text); font-family: var(--mono, monospace); text-align: right; }

.spark-cell { width: 90px; }
.spark { display: block; width: 80px; height: 18px; color: var(--orange); }

/* Section titles inside the analytics dashboard */
.dash-section-title {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 18px 0 8px;
  font-weight: 600;
}
.dash-section-title .count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--muted-2);
  text-transform: none;
}

.dash-card-warn { border-color: rgba(239, 83, 83, 0.4); }
.dash-card-warn .dash-card-value { color: #f5a5a5; }

/* Hour-of-day heatmap: grid of 7 days × 24 hours */
.dash-heatmap { margin: 8px 0 6px; overflow-x: auto; }
.heatmap-grid {
  display: grid;
  grid-template-columns: 36px repeat(24, 1fr);
  gap: 2px;
  min-width: 600px;
}
.heatmap-corner { /* empty top-left cell */ }
.heatmap-hour {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  font-family: var(--mono, monospace);
}
.heatmap-day {
  font-size: 11px;
  color: var(--muted-2);
  text-align: right;
  padding-right: 6px;
  font-family: var(--mono, monospace);
  align-self: center;
}
.heatmap-cell {
  aspect-ratio: 1 / 1;
  background: rgba(240, 127, 22, var(--intensity, 0));
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 2px;
  min-height: 14px;
}
/* Cells with data are buttons — make them feel clickable. */
button.heatmap-cell-clickable {
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 90ms ease, border-color 90ms ease, box-shadow 90ms ease;
}
/* Subtle continuous pulse so populated cells read as "live" data, mirroring
   the bar-shimmer treatment but adapted for square cells (gentle white-tint
   opacity sweep instead of horizontal sheen). Each cell gets its own delay
   via --pulse-delay (set inline) so the grid feels organic, not strobing. */
button.heatmap-cell-clickable::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255, 255, 255, 0.22);
  opacity: 0;
  pointer-events: none;
  animation: heatmap-cell-pulse 2.8s ease-in-out infinite;
  animation-delay: var(--pulse-delay, 0s);
}
@keyframes heatmap-cell-pulse {
  0%, 60%, 100% { opacity: 0; }
  30%           { opacity: 1; }
}
button.heatmap-cell-clickable:hover {
  border-color: rgba(255, 122, 0, 0.6);
  transform: scale(1.15);
  z-index: 1;
}
button.heatmap-cell-clickable.heatmap-cell-active {
  border-color: var(--orange);
  box-shadow: 0 0 0 1px var(--orange), 0 0 8px rgba(255, 122, 0, 0.4);
  transform: scale(1.15);
  z-index: 1;
}
@media (prefers-reduced-motion: reduce) {
  button.heatmap-cell-clickable::before { animation: none; }
}

/* Heatmap drilldown panel — appears below the grid when a cell is clicked. */
#heatmap-detail { margin-top: 14px; }
.heatmap-detail-card {
  background: rgba(255, 122, 0, 0.05);
  border: 1px solid rgba(255, 122, 0, 0.25);
  border-radius: 8px;
  padding: 12px 14px;
  animation: heatmap-detail-in 200ms ease-out;
}
@keyframes heatmap-detail-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.heatmap-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.heatmap-detail-label {
  display: block;
  font-size: 12px;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.heatmap-detail-window {
  display: block;
  font-size: 11.5px;
  color: var(--muted-2);
  margin-top: 2px;
}
.heatmap-detail-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted-2);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
}
.heatmap-detail-close:hover { color: var(--text); border-color: var(--orange); }
.heatmap-detail-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.heatmap-detail-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.heatmap-detail-list li:last-child { border-bottom: none; }
.heatmap-detail-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.heatmap-detail-meta {
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.heatmap-detail-meta .dim { opacity: 0.55; }

/* Expandable engagement cards — <details> styling. */
details.dash-card-expandable {
  /* keep .dash-card visual baseline; just remove the default disclosure. */
}
details.dash-card-expandable > summary {
  list-style: none;
  cursor: pointer;
  outline: none;
}
details.dash-card-expandable > summary::-webkit-details-marker { display: none; }
.dash-card-chevron {
  font-size: 10px;
  color: var(--muted-2);
  margin-left: 4px;
  display: inline-block;
  transition: transform 150ms ease;
}
details.dash-card-expandable[open] > summary .dash-card-chevron {
  transform: rotate(180deg);
}
details.dash-card-expandable[open] {
  border-color: rgba(255, 122, 0, 0.35);
  background: rgba(255, 122, 0, 0.04);
}
.dash-card-breakdown {
  list-style: none;
  margin: 12px 0 0;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dash-card-breakdown li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}
.dash-card-breakdown li .bd-bar {
  display: block;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
  grid-column: 1 / 3;
  margin-top: 2px;
}
.dash-card-breakdown li .bd-bar-fill {
  display: block;
  height: 100%;
  background: var(--orange);
  border-radius: 3px;
}
.dash-card-breakdown li .bd-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.dash-card-breakdown li .bd-meta {
  color: var(--muted);
  font-size: 12px;
}
/* When the row has a bar (Total team time breakdown), use a 3-col layout
   so name/bar/meta fit in one row instead of wrapping. */
.dash-card-breakdown li:has(.bd-bar) {
  grid-template-columns: minmax(70px, 1fr) 2fr auto;
}
.dash-card-breakdown li:has(.bd-bar) .bd-bar { grid-column: auto; margin-top: 0; }

/* Action mix and top searches sit side-by-side on wider screens */
.dash-side-by-side {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

.dash-search-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.dash-search-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12.5px;
}
.dash-search-q {
  font-family: var(--mono, monospace);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 12px;
}
.dash-search-count { color: var(--muted-2); font-family: var(--mono, monospace); }

/* Collapsible pipeline overview that sits at the top of /bids */
.dash-collapsible {
  margin: 18px 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.015);
  padding: 0 14px;
}
.dash-collapsible[open] { padding: 0 14px 14px; }
.dash-collapsible > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  user-select: none;
}
.dash-collapsible > summary::-webkit-details-marker { display: none; }
.dash-collapsible > summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.dash-collapsible[open] > summary::before { transform: rotate(90deg); }
.dash-collapsible-title {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  flex: 1;
}
.dash-collapsible-hint { font-size: 11px; color: var(--muted-2); }

.inline-reset {
  display: flex;
  gap: 6px;
  align-items: center;
}
.inline-reset input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 8px;
  color: var(--text);
  font-size: 12px;
  width: 160px;
  font-family: inherit;
}
.inline-reset input:focus { outline: none; border-color: var(--orange); }
.inline-reset .btn-secondary { padding: 5px 12px; font-size: 12px; }

/* Activity log — diff rendering and filter row */
.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}
.admin-filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.admin-filters select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 13px;
  min-width: 160px;
}
.admin-filters select:focus { outline: none; border-color: var(--orange); }

.activity-feed td { vertical-align: top; }
.diff-list { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.diff-list li { padding: 1px 0; }
.diff-field { color: var(--muted-2); font-family: var(--mono, monospace); margin-right: 4px; }
.diff-from { color: #f5a5a5; text-decoration: line-through; }
.diff-arrow { color: var(--muted); margin: 0 4px; }
.diff-to { color: #9bd; }
.diff-note { color: var(--muted-2); font-size: 12px; font-style: italic; margin-top: 4px; }

/* Topbar */
.content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 5;
}
.crumbs { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; min-width: 0; }
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--muted-2); margin: 0 2px; }
.crumbs .leaf { color: var(--text); max-width: 480px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-menu { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--text-2); }
.user-menu .user-name { color: var(--text); }
.linkish {
  background: none;
  border: 0;
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  font-family: inherit;
}
.linkish:hover { color: var(--orange); }
.inline { display: inline; }

.page { padding: 22px 24px 60px; max-width: 1400px; }

/* ---------- 3. Buttons + form controls ---------- */
.btn,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  font-size: 12.5px;
  background: #2a2a2a;
  border: 1px solid var(--border-2);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.12s ease;
  white-space: nowrap;
  font-family: inherit;
}
.btn:hover,
.btn-secondary:hover { background: #333; border-color: #4a4a4a; color: var(--text); }
.btn-primary,
.btn.primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  font-size: 12.5px;
  background: var(--orange);
  border: 1px solid var(--orange);
  border-radius: 6px;
  color: #1a0e00;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.12s ease;
  white-space: nowrap;
  font-family: inherit;
}
.btn-primary:hover,
.btn.primary:hover { background: #ff8a1c; border-color: #ff8a1c; color: #1a0e00; }
.btn-ghost,
.btn.ghost {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  font-size: 12.5px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
}
.btn-ghost:hover,
.btn.ghost:hover { background: #262626; color: var(--text); }
.btn svg, .btn-primary svg, .btn-secondary svg, .btn-ghost svg { width: 14px; height: 14px; }

/* Spinner / loading state for HTMX-driven buttons.
   We match on `.htmx-request` (the class HTMX always toggles during in-flight
   requests) rather than the `[disabled]` attribute — the attribute doesn't
   always propagate cleanly in CSS-matching contexts, and users reported the
   spinner not appearing on Generate-info-sheet / RFIs. */
.btn-label, .btn-loading { display: inline-flex; align-items: center; gap: 6px; }
.btn-loading { display: none; }
button.htmx-request .btn-label,
button[hx-disabled-elt][disabled] .btn-label { display: none; }
button.htmx-request .btn-loading,
button[hx-disabled-elt][disabled] .btn-loading { display: inline-flex; }
button.htmx-request { cursor: progress; opacity: 0.85; }

.spinner-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Top-of-page progress bar — always visible during any HTMX request.
   Fixed above everything so no matter what a user clicks, they get a
   global "app is working" signal. The <div class="hx-progress"> lives in
   base.html and HTMX toggles its `.htmx-request` class automatically when
   targeted via hx-indicator, but we use `body.htmx-request` so it fires
   for ALL in-flight requests without per-button wiring. */
.hx-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: transparent;
  z-index: 9999;
  pointer-events: none;
}
.hx-progress::before {
  content: "";
  display: block;
  height: 100%;
  width: 30%;
  background: linear-gradient(90deg, transparent, var(--orange), transparent);
  opacity: 0;
  transition: opacity 0.15s;
}
body.htmx-request .hx-progress::before {
  opacity: 1;
  animation: hx-progress-slide 1.1s ease-in-out infinite;
}
@keyframes hx-progress-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(400%); }
}

/* Form controls */
input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="date"], input[type="number"], input[type="tel"], input[type="url"],
select, textarea {
  background: #1e1e1e;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  /* color-scheme tells Chromium / Safari to use the dark-mode variant of
     native form widgets — most importantly, the date picker overlay that
     pops up under <input type="date">. Without this the calendar widget
     renders as a bright-white card on our dark theme. */
  color-scheme: dark;
  padding: 8px 10px;
  font-size: 12.5px;
  font-family: inherit;
  width: 100%;
}
select { appearance: none; -webkit-appearance: none; padding-right: 28px; cursor: pointer; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--orange-dim);
  box-shadow: 0 0 0 2px rgba(255,122,0,.18);
}
textarea.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; line-height: 1.55; }

/* ---------- 4. Page header + scheduler banner ---------- */
.page-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.subtitle {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.subtitle .sub-sep { color: var(--muted-2); }
.health { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); display: inline-block; }
.dot.amber { background: var(--amber); box-shadow: 0 0 0 3px var(--amber-soft); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); }
.dot.idle { background: var(--muted-2); box-shadow: none; }
.head-actions, .page-actions { display: flex; gap: 8px; align-items: center; }

/* Scheduler banner (legacy .tick-banner) — flatten into .subtitle on the redesign */
.tick-banner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--muted);
}
.tick-banner-bad { color: var(--amber); }
.tick-err { color: var(--red); }

/* ---------- 5. Filter bar + tabs ---------- */
.filterbar {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.filterbar .select { position: relative; display: inline-flex; align-items: center; }
.filterbar select {
  background: #1e1e1e;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 28px 7px 11px;
  border-radius: 6px;
  font-size: 12.5px;
  min-width: 130px;
  width: auto;
}
.filterbar select:hover { border-color: var(--border-2); }
.filterbar .select:after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.filterbar .search {
  flex: 1;
  display: flex;
  align-items: center;
  background: #1e1e1e;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0 11px;
  height: 34px;
  min-width: 220px;
}
.filterbar .search:focus-within { border-color: var(--orange-dim); }
.filterbar .search svg { width: 14px; height: 14px; color: var(--muted); flex: none; }
.filterbar .search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font-size: 12.5px;
  padding: 0 10px;
  height: 100%;
}
.filterbar .search input::placeholder { color: var(--muted); }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  padding: 0 2px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  font-size: 12.5px;
  color: var(--text-2);
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: 0;
  position: relative;
  top: 1px;
  background: transparent;
  text-decoration: none;
  font-family: inherit;
}
.tab:hover { color: var(--text); background: #1e1e1e; }
.tab-active {
  color: var(--text);
  background: var(--card);
  border-color: var(--border);
  border-bottom: 1px solid var(--card);
}
.tab-active:after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: var(--orange);
  border-radius: 2px 2px 0 0;
}
.tab .count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  background: #2a2a2a;
  color: var(--text-2);
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.tab-active .count { background: var(--orange-soft); color: var(--orange); border-color: transparent; }

/* HTMX in-flight indicator — fade the table area while a tab/sort swap is loading. */
#bid-list { transition: opacity 120ms ease-out; }
#bid-list.htmx-request { opacity: 0.55; }

/* ---------- 6. Bid table ---------- */
.table {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.thead, .row {
  display: grid;
  grid-template-columns:
    44px         /* score */
    minmax(180px, 1fr) /* title */
    72px         /* flags */
    108px        /* portal */
    132px        /* location */
    108px        /* site walk */
    120px        /* closing */
    88px         /* status */
    40px;        /* discard */
  align-items: center;
  gap: 10px;
  padding: 0 14px;
}
.thead {
  height: 32px;
  background: #1e1e1e;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  letter-spacing: 1.1px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}
.thead .th { display: flex; align-items: center; gap: 4px; }
.thead .th.num { justify-content: center; }

/* Sortable column headers — anchor variant of .th. The arrow sits in a
   dedicated span so the active-state color doesn't bleed into the label. */
.thead .th.sortable {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
  border-radius: 3px;
  transition: color 0.1s ease, background 0.1s ease;
}
.thead .th.sortable:hover { color: var(--text); background: #262626; }
.thead .th.sortable .sort-ind {
  font-size: 11px;
  opacity: 0.4;
  font-family: 'JetBrains Mono', monospace;
}
.thead .th.sortable:hover .sort-ind { opacity: 0.7; }
.thead .th.sortable.sort-active { color: var(--orange); }
.thead .th.sortable.sort-active .sort-ind { opacity: 1; color: var(--orange); }

.row {
  height: 44px;
  border-bottom: 1px solid #232323;
  position: relative;
  cursor: pointer;
  transition: background 0.1s ease;
  text-decoration: none;
  color: inherit;
}
.row:last-child { border-bottom: 0; }
.row:nth-child(even) { background: var(--row-alt); }
.row:hover { background: var(--row-hover); }
.row:hover:before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--orange);
}

.title-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.title { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.row:hover .title { color: #fff; }
.new-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--orange); flex: none; box-shadow: 0 0 0 2px rgba(255,122,0,.18); }
.evidence-pill {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: #1f1f1f;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  flex: none;
}
.evidence-docs_included {
  color: #8bcf9a;
  border-color: rgba(93,208,122,.32);
  background: rgba(46,160,67,.08);
}
.evidence-docs_fetch_failed {
  color: #e29a72;
  border-color: rgba(229,122,72,.35);
  background: rgba(229,122,72,.08);
}
.evidence-docs_unavailable {
  color: #c7b37a;
  border-color: rgba(199,179,122,.32);
  background: rgba(199,179,122,.07);
}

.flags-cell { display: flex; gap: 10px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--muted); }
.flag { display: inline-flex; align-items: center; gap: 4px; }
.flag.r { color: #c87a5a; }
.flag.g { color: #7aab81; }
.flag .mark { font-weight: 700; font-size: 12px; line-height: 1; }

.muted-cell { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-cell {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.closing-cell { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--text-2); display: flex; flex-direction: column; line-height: 1.2; }
.closing-cell .date { color: var(--text-2); }
.closing-cell .rel { font-size: 10px; color: var(--muted-2); margin-top: 1px; }
.closing-cell.urgent .date { color: var(--red); }
.closing-cell.urgent .rel { color: #d86a6e; }
.closing-cell.soon .date { color: var(--amber); }
.closing-cell.soon .rel { color: #d49650; }

.dismiss {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #555;
  border-radius: 4px;
  background: transparent;
  border: 0;
  cursor: pointer;
  transition: all 0.12s ease;
  margin-left: auto;
}
.row:hover .dismiss { color: #888; }
.dismiss:hover { background: #3a2a2a; color: #fff !important; }
.dismiss svg { width: 13px; height: 13px; }

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--muted);
  background: #1e1e1e;
  flex-wrap: wrap;
  gap: 12px;
}
.legend { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.legend-item { display: inline-flex; gap: 6px; align-items: center; font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.legend-dot.g { background: var(--green); }
.legend-dot.a { background: var(--amber); }
.legend-dot.r { background: var(--red); }

/* ---------- 7. Pills ---------- */
.score {
  width: 38px;
  height: 28px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
  background: #1a1a1a;
  color: var(--muted);
}
.score.high, .score-5, .score-4 { color: #5dd07a; border-color: rgba(46,160,67,.5); background: rgba(46,160,67,.08); }
.score.mid, .score-3 { color: #e5a23b; border-color: rgba(229,162,59,.45); background: rgba(229,162,59,.08); }
.score.low, .score-2, .score-1, .score-0 { color: #e5484d; border-color: rgba(229,72,77,.45); background: rgba(229,72,77,.08); }
.score-pending { color: var(--muted-2); }

/* Reco pill (kept compact for in-row use) */
.reco {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 3px 8px;
  border-radius: 3px;
  text-transform: uppercase;
}
.reco.pursue { color: #5dd07a; background: var(--green-soft); border: 1px solid rgba(46,160,67,.35); }
.reco.review { color: #e5a23b; background: var(--amber-soft); border: 1px solid rgba(229,162,59,.35); }
.reco.discard { color: #e5484d; background: var(--red-soft); border: 1px solid rgba(229,72,77,.35); }

/* Status pill (also aliased as legacy .pill / .pill-* used elsewhere) */
.status,
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid;
  text-transform: uppercase;
  font-family: 'JetBrains Mono', monospace;
}
.status.new, .pill-new { color: var(--orange); border-color: rgba(255,122,0,.35); background: var(--orange-soft); }
.status.pursuing, .pill-pursuing { color: #5dd07a; border-color: rgba(46,160,67,.35); background: var(--green-soft); }
.status.reviewing, .pill-reviewing { color: #6c9fea; border-color: rgba(76,141,255,.35); background: var(--blue-soft); }
.status.submitted, .pill-submitted { color: #b89cff; border-color: rgba(160,107,255,.35); background: var(--purple-soft); }
.status.won, .pill-won { color: #000; background: #5dd07a; border-color: #5dd07a; }
.status.lost, .pill-lost { color: var(--muted); border-color: var(--border); background: #202020; }
.status.discarded, .pill-discarded { color: var(--muted); border-color: var(--border); background: #202020; text-decoration: line-through; }

/* ---------- 8. Drawer (kept compact, currently unused but ready) ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity 0.2s ease; z-index: 20; }
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 560px;
  max-width: 90vw;
  background: #1c1c1c;
  border-left: 1px solid var(--border);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(.2,.8,.2,1);
  z-index: 21;
  display: flex;
  flex-direction: column;
  box-shadow: -24px 0 60px rgba(0,0,0,.4);
}
.drawer.open { transform: translateX(0); }

/* ---------- 9. Bid detail header ---------- */
.detail-head { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: flex-start; margin-bottom: 16px; }
.title-row { display: flex; gap: 16px; align-items: flex-start; min-width: 0; }
.big-score {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 700;
  flex: none;
  background: #1a1a1a;
  color: var(--muted);
  line-height: 1;
}
.big-score.high { color: #5dd07a; border-color: rgba(46,160,67,.65); background: rgba(46,160,67,.08); }
.big-score.mid { color: #e5a23b; border-color: rgba(229,162,59,.55); background: rgba(229,162,59,.08); }
.big-score.low { color: #e5484d; border-color: rgba(229,72,77,.55); background: rgba(229,72,77,.08); }
.big-score .lbl { font-size: 8.5px; letter-spacing: 1.2px; color: var(--muted); margin-top: 2px; font-weight: 600; }
.detail-title { margin: 0 0 6px; font-size: 22px; font-weight: 600; letter-spacing: -0.2px; line-height: 1.25; }
.title-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.ref-tag { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--muted); border: 1px solid var(--border); padding: 2px 6px; border-radius: 3px; }

.nav-arrows { display: flex; border: 1px solid var(--border-2); border-radius: 6px; overflow: hidden; }
.nav-arrows a, .nav-arrows button {
  background: #2a2a2a;
  border: 0;
  color: var(--text-2);
  padding: 7px 10px;
  cursor: pointer;
  border-right: 1px solid var(--border-2);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.nav-arrows a:last-child, .nav-arrows button:last-child { border-right: 0; }
.nav-arrows a:hover, .nav-arrows button:hover { background: #333; color: var(--text); }
.nav-arrows svg { width: 13px; height: 13px; display: block; }

/* Metadata strip */
.meta-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 18px;
}
.meta-cell {
  padding: 11px 14px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.meta-cell:last-child { border-right: 0; }
.meta-cell .k { font-size: 9.5px; letter-spacing: 1.2px; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.meta-cell .v { font-size: 13px; color: var(--text); font-weight: 500; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta-cell .v.mono { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }
.meta-cell .v.urgent { color: var(--amber); }
.meta-cell .v.link { color: var(--blue); }
.meta-cell .v.link:hover { text-decoration: underline; }
.meta-cell .sub { font-size: 10.5px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.meta-cell .sub.urgent { color: var(--amber); }

/* Source badges — small pills on the Portal meta-cell indicating whether a
   bid arrived via email digest, direct feed, or both. During the CanadaBuys
   cutover we care about seeing both paths land on the same row. */
.source-badges { display: inline-flex; gap: 4px; margin-top: 4px; }
.source-badge {
  font-size: 9.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  line-height: 1.5;
}
.source-badge.source-email { background: rgba(120, 140, 200, 0.15); color: #8fa0d4; }
.source-badge.source-feed { background: rgba(122, 171, 129, 0.15); color: #7aab81; }

/* Detail layout grid — `minmax(0, 1fr)` on both breakpoints so grid tracks
   can shrink below min-content; otherwise a child with nowrap (e.g. the
   detail-tabs row) forces the track wider than the viewport on mobile. */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; }
.detail-grid > * { min-width: 0; }
@media (max-width: 1100px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- 10. Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  overflow: hidden;
}
.card-span { grid-column: 1 / -1; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}
.card-head h2, .card-head h3 { margin: 0; font-size: 10px; letter-spacing: 1.4px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.card-head .right {
  font-size: 10.5px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.card-head .ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 9.5px;
  letter-spacing: 1px;
  color: var(--purple);
  background: var(--purple-soft);
  border: 1px solid rgba(160,107,255,.3);
  padding: 2px 7px;
  border-radius: 3px;
  font-weight: 600;
  text-transform: uppercase;
}
.card-body { padding: 14px 16px; }
.card-body .muted { color: var(--muted); font-size: 12px; }

.summary { font-size: 13px; line-height: 1.6; color: var(--text-2); }
.summary strong { color: var(--text); font-weight: 600; }

/* Scope list */
.scope { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 18px; }
@media (max-width: 800px) { .scope { grid-template-columns: 1fr; } }
.scope li { font-size: 12.5px; color: var(--text-2); padding: 7px 0 7px 18px; position: relative; line-height: 1.4; border-bottom: 1px dashed #272727; }
.scope li:before { content: ""; position: absolute; left: 0; top: 13px; width: 6px; height: 6px; border-radius: 50%; background: var(--orange); opacity: .65; }
.scope li .tag { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; color: var(--muted); margin-left: 6px; letter-spacing: 0.4px; }

/* Scoring breakdown bars */
.sb-overall { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.sb-overall .big { font-family: 'JetBrains Mono', monospace; font-size: 26px; font-weight: 600; color: #5dd07a; }
.sb-overall .lbl { font-size: 11.5px; color: var(--muted); }
.sb-row { display: grid; grid-template-columns: 150px 1fr 48px; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid #272727; }
.sb-row:last-child { border-bottom: 0; }
.sb-row .k { font-size: 12.5px; color: var(--text-2); }
.sb-row .k .hint { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.sb-bar { height: 8px; background: #1c1c1c; border-radius: 4px; overflow: hidden; border: 1px solid #222; position: relative; }
.sb-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #2ea043, #5dd07a); }
.sb-fill.mid { background: linear-gradient(90deg, #c98818, #e5a23b); }
.sb-fill.low { background: linear-gradient(90deg, #b83a3e, #e5484d); }
.sb-val { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; font-weight: 600; color: var(--text); text-align: right; }
.sb-val.h { color: #5dd07a; }
.sb-val.m { color: #e5a23b; }
.sb-val.l { color: #e5484d; }

/* Signals (red/green flags) */
.flags-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 800px) { .flags-grid { grid-template-columns: 1fr; } }
.flag-col h5 { margin: 0 0 8px; font-size: 10px; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; text-transform: uppercase; display: flex; align-items: center; gap: 6px; }
.flag-col h5 .dot { width: 6px; height: 6px; border-radius: 50%; box-shadow: none; }
.flag-col h5 .dot.g { background: var(--green); }
.flag-col h5 .dot.r { background: var(--red); }
.flag-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; }
.flag-list li { font-size: 12px; padding: 7px 10px; border-radius: 4px; display: flex; gap: 8px; align-items: flex-start; line-height: 1.45; }
.flag-list li.g { background: rgba(46,160,67,.05); color: #9fc8a7; }
.flag-list li.r { background: rgba(229,72,77,.06); color: #d8a0a2; }
.flag-list li:before { content: ""; width: 5px; height: 5px; border-radius: 50%; margin-top: 6px; flex: none; }
.flag-list li.g:before { background: var(--green); }
.flag-list li.r:before { background: var(--red); }
.flag-list li.empty {
  background: #1e1e1e;
  border: 1px dashed var(--border);
  color: var(--muted);
}
.flag-list li.empty:before { display: none; }

/* Legacy .flags / .flags-red / .flags-green still rendered by some templates */
.flags { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; font-family: inherit; font-size: 12px; color: var(--text-2); }
.flags-red li { background: rgba(229,72,77,.06); color: #d8a0a2; padding: 7px 10px; border-radius: 4px; }
.flags-green li { background: rgba(46,160,67,.05); color: #9fc8a7; padding: 7px 10px; border-radius: 4px; }

/* ---------- 11. Right rail ---------- */
.decision .big-reco { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: var(--green-soft); border: 1px solid rgba(46,160,67,.3); border-radius: 6px; margin-bottom: 12px; }
.decision .big-reco .mark { width: 36px; height: 36px; border-radius: 50%; background: rgba(46,160,67,.25); color: #5dd07a; display: flex; align-items: center; justify-content: center; flex: none; font-size: 18px; font-weight: 700; }
.decision .big-reco .txt { line-height: 1.3; }
.decision .big-reco .txt .lbl { font-size: 9.5px; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.decision .big-reco .txt .val { color: #5dd07a; font-size: 15px; font-weight: 700; letter-spacing: 0.5px; }
.decision .big-reco.review { background: var(--amber-soft); border-color: rgba(229,162,59,.3); }
.decision .big-reco.review .mark { background: rgba(229,162,59,.25); color: #e5a23b; }
.decision .big-reco.review .txt .val { color: #e5a23b; }
.decision .big-reco.discard { background: var(--red-soft); border-color: rgba(229,72,77,.3); }
.decision .big-reco.discard .mark { background: rgba(229,72,77,.25); color: #e5484d; }
.decision .big-reco.discard .txt .val { color: #e5484d; }

.decision label { font-size: 9.5px; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 5px; text-transform: uppercase; }
.decision select { margin-bottom: 10px; }
.decision .reason-input { margin-bottom: 10px; font-size: 12.5px; min-height: 60px; resize: vertical; }
.decision .btn-primary, .decision .btn { width: 100%; justify-content: center; }

/* Pursue workspace — team scratchpad card on the bid detail page. Sits in
   the right rail between Decision and Key Dates. Shares shape with .decision
   (labels, full-width inputs, full-width submit) but kept as its own class
   for semantic clarity in the HTML. */
.pursue-card label {
  font-size: 9.5px;
  letter-spacing: 1.2px;
  color: var(--muted);
  font-weight: 600;
  display: block;
  margin: 10px 0 5px;
  text-transform: uppercase;
}
.pursue-card label:first-of-type { margin-top: 0; }
.pursue-card input[type="text"],
.pursue-card select { margin-bottom: 4px; }
.pursue-card .pursue-notes {
  margin-bottom: 10px;
  font-size: 12.5px;
  min-height: 80px;
  resize: vertical;
}
.pursue-card .btn-primary { width: 100%; justify-content: center; }
.pursue-card .card-head .right { font-size: 11px; color: var(--text-2); }
.pursue-card .card-head .right .mono { color: var(--text); }
.pursue-card .card-head .sub-sep { color: var(--muted-2); margin: 0 2px; }

/* Key dates */
.dates { list-style: none; padding: 0; margin: 0; }
.dates li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 9px 0; border-bottom: 1px solid #272727; font-size: 12px; }
.dates li:last-child { border-bottom: 0; }
.dates .k { color: var(--text-2); line-height: 1.3; }
.dates .k .sub { display: block; font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.dates .v { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--text); text-align: right; line-height: 1.3; white-space: nowrap; }
.dates .v .rel { display: block; font-size: 10px; color: var(--muted); margin-top: 1px; }
.dates .v.urgent { color: var(--amber); }
.dates .v.urgent .rel { color: var(--amber); }
.dates .v.passed { color: var(--muted-2); }

/* Stakeholders */
.stake { list-style: none; padding: 0; margin: 0; }
.stake li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid #272727; align-items: flex-start; }
.stake li:last-child { border-bottom: 0; }
.stake .avatar { width: 28px; height: 28px; border-radius: 6px; background: #2a2a2a; border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 700; color: var(--text-2); flex: none; }
.stake .avatar.gov { background: rgba(76,141,255,.12); color: #8db2ff; border-color: rgba(76,141,255,.25); }
.stake .avatar.eng { background: rgba(160,107,255,.12); color: #c5acff; border-color: rgba(160,107,255,.25); }
.stake .avatar.comp { background: rgba(229,162,59,.12); color: #e5a23b; border-color: rgba(229,162,59,.25); }
.stake .info { min-width: 0; flex: 1; }
.stake .info .role { font-size: 9.5px; letter-spacing: 1.1px; color: var(--muted); text-transform: uppercase; font-weight: 600; margin-bottom: 1px; }
.stake .info .name { font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stake .info .sub { font-size: 10.5px; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-top: 1px; }

/* Empty state inside cards */
.empty-card { text-align: center; font-size: 12px; color: var(--muted); line-height: 1.5; padding: 18px 8px; }

/* ---------- 12. RFIs + Activity ---------- */
.rfi-list { list-style: none; padding: 0; margin: 0; }
.rfi { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.rfi:last-child { border-bottom: 0; }
.rfi:hover { background: #272727; }
.rfi-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rfi .cat { font-size: 9.5px; letter-spacing: 1.2px; color: var(--muted); font-weight: 600; text-transform: uppercase; padding: 2px 7px; border: 1px solid var(--border); border-radius: 3px; background: #1e1e1e; font-family: 'JetBrains Mono', monospace; }
.rfi .sev { font-size: 9.5px; letter-spacing: 1.1px; font-weight: 700; padding: 2px 7px; border-radius: 3px; font-family: 'JetBrains Mono', monospace; border: 1px solid; text-transform: uppercase; }
.rfi .sev.high, .rfi .sev.contradiction { color: #e5484d; background: var(--red-soft); border-color: rgba(229,72,77,.35); }
.rfi .sev.med, .rfi .sev.medium, .rfi .sev.ambiguity { color: #e5a23b; background: var(--amber-soft); border-color: rgba(229,162,59,.35); }
.rfi .sev.low, .rfi .sev.missing_info { color: var(--muted); background: #1e1e1e; border-color: var(--border); }
.rfi-title { font-size: 13px; color: var(--text); font-weight: 500; flex: 1; min-width: 200px; line-height: 1.35; }
.rfi-body { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.55; }
.rfi-body strong { color: var(--text); font-weight: 600; }
.rfi-cite { font-size: 10.5px; color: var(--muted); font-family: 'JetBrains Mono', monospace; letter-spacing: 0.2px; }

/* Activity log */
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { display: grid; grid-template-columns: 16px 1fr auto; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #272727; font-size: 12px; }
.activity li:last-child { border-bottom: 0; }
.activity .marker { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); margin-top: 5px; }
.activity .marker.muted { background: var(--muted-2); }
.activity .what { color: var(--text-2); line-height: 1.4; }
.activity .what strong { color: var(--text); font-weight: 600; }
.activity .what .reason { display: block; color: var(--muted); margin-top: 4px; font-size: 11.5px; line-height: 1.4; }
.activity .when { font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--muted); white-space: nowrap; text-align: right; line-height: 1.3; }

/* ---------- 13. Info-sheet content + attachments ---------- */
.info-sheet .summary { margin-bottom: 14px; }
.info-sheet h3 { margin: 16px 0 8px; font-size: 11px; letter-spacing: 1.2px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 12.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--text-2); }

.attachments { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
.attachment { background: #1e1e1e; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; }
.att-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.att-name { color: var(--orange); font-size: 12.5px; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-name:hover { text-decoration: underline; }
.att-text { background: #181818; border: 1px solid var(--border); border-radius: 4px; padding: 10px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--text-2); max-height: 320px; overflow: auto; white-space: pre-wrap; }
.att-delete {
  background: transparent;
  border: 0;
  color: var(--muted-2);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 0;
  transition: background 0.1s ease, color 0.1s ease;
}
.att-delete:hover { background: #3a2a2a; color: #e88; }

/* Upload drop zones on the bid-detail Documents panel. Two side-by-side
   boxes (Drawings, Specs) so Tom tags intent at upload time — downstream
   extractors branch on `kind` instead of guessing. HTMX swaps the whole
   card on success. */
.upload-zones { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 4px; }
@media (max-width: 600px) { .upload-zones { grid-template-columns: 1fr; } }
.upload-zone { margin: 0; position: relative; }
.upload-drop-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--orange);
  margin-bottom: 2px;
}
.att-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 14px 0 4px;
}
.att-section .att-count {
  font-size: 10.5px;
  color: var(--muted-2);
  font-weight: 500;
  margin-left: 6px;
}
.upload-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 16px;
  border: 1px dashed #333;
  border-radius: 8px;
  background: #1a1a1a;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
  color: var(--muted);
}
.upload-drop:hover,
.upload-drop.drag-over { border-color: var(--orange); background: #1e1a18; color: var(--text-2); }
.upload-drop.drag-over { border-style: solid; }
.upload-flash {
  font-size: 12px;
  padding: 8px 10px;
  margin: 0 0 10px;
  border-radius: 4px;
  background: rgba(122, 171, 129, 0.10);
  border-left: 3px solid #7aab81;
  color: #a8d3ad;
}
.upload-errors {
  font-size: 12px;
  padding: 8px 10px;
  margin: 0 0 10px;
  border-radius: 4px;
  background: rgba(200, 122, 90, 0.10);
  border-left: 3px solid #c87a5a;
  color: #e6b59f;
}
.upload-errors ul { margin: 4px 0 0; padding-left: 18px; }
.upload-errors li { margin: 2px 0; }
.upload-drop svg { color: var(--muted-2); }
.upload-drop:hover svg,
.upload-drop.drag-over svg { color: var(--orange); }
.upload-label { font-size: 12.5px; }
.upload-hint { font-size: 10.5px; font-family: 'JetBrains Mono', monospace; }
.upload-drop input[type="file"] { display: none; }
.upload-indicator {
  display: none;
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 11px;
  color: var(--orange);
  font-family: 'JetBrains Mono', monospace;
}
.upload-indicator.htmx-request,
.htmx-request .upload-indicator { display: inline; }

.email-preview { background: #181818; border: 1px solid var(--border); border-radius: 4px; padding: 10px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--text-2); max-height: 320px; overflow: auto; white-space: pre-wrap; margin: 8px 0 0; }

/* ---------- 14. Search results ---------- */
.search-form { display: flex; gap: 8px; margin: 12px 0 16px; }
.search-form-inline { margin: 0 0 10px; }
.search-input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  background: #1e1e1e;
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
  transition: border-color 120ms;
}
.search-input::placeholder { color: var(--muted); }
.search-input:focus { border-color: var(--orange-dim); box-shadow: 0 0 0 2px rgba(255,122,0,.18); }

.search-hits { list-style: none; padding: 0; margin: 16px 0 0; }
.search-hit { padding: 14px 0; border-bottom: 1px solid var(--border); }
.search-hit:last-child { border-bottom: none; }
.search-hit-title { font-size: 14px; font-weight: 600; color: var(--text); }
.search-hit-title:hover { color: var(--orange); }
.search-hit-meta { font-size: 11.5px; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }
.search-hit-snippet { font-size: 12.5px; color: var(--text-2); margin-top: 6px; line-height: 1.5; }
.search-hit-snippet mark { background: rgba(255,122,0,.25); color: #ffd9b3; padding: 0 2px; border-radius: 2px; }

/* ---------- 15. Login + auth ---------- */
/* Fixed positioning pulls the wrapper out of the document flow entirely,
   so no ancestor max-width / padding / grid track can offset it. Dead
   center on any viewport size, including ultrawides. */
.login-wrap { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: var(--bg); overflow: auto; }
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 32px;
  border-radius: 12px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 24px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.login-form button { margin-top: 6px; justify-content: center; }
.form-error {
  background: rgba(229,72,77,.08);
  border: 1px solid rgba(229,72,77,.3);
  color: var(--red);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12.5px;
}
.form-success {
  background: rgba(42,136,85,.08);
  border: 1px solid rgba(42,136,85,.3);
  border-left: 3px solid #2a8855;
  color: #2a8855;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12.5px;
}
.login-form-link {
  align-self: center;
  margin-top: 2px;
  color: var(--orange);
  font-size: 12.5px;
  text-decoration: none;
}
.login-form .checkbox-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  color: var(--orange);
  cursor: pointer;
  margin-top: -2px;
  user-select: none;
  align-self: flex-start;
  position: relative;
}
.login-form .checkbox-row input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  inset-inline-start: 0;
}
.login-form .checkbox-row .checkbox-visual {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--orange);
  border-radius: 3px;
  background: transparent;
  flex-shrink: 0;
  transition: background-color .15s ease;
}
.login-form .checkbox-row .checkbox-visual svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: var(--orange);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}
.login-form .checkbox-row .checkbox-visual svg polyline {
  stroke-dasharray: 18;
  stroke-dashoffset: 18;
  transition: stroke-dashoffset .25s cubic-bezier(.55, .15, .35, 1);
}
.login-form .checkbox-row input[type="checkbox"]:checked ~ .checkbox-visual svg polyline {
  stroke-dashoffset: 0;
}
.login-form .checkbox-row input[type="checkbox"]:focus-visible ~ .checkbox-visual {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}
.login-form .checkbox-row span:last-child {
  margin: 0;
  line-height: 1;
}
.password-field {
  position: relative;
  display: block;
}
.password-field input[type="password"],
.password-field input[type="text"] {
  width: 100%;
  padding-right: 38px;
}
.password-field .password-toggle {
  position: absolute;
  right: 4px;
  top: 0;
  height: 100%;
  width: 32px;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  color: var(--orange);
  opacity: 0.75;
  transition: opacity .12s ease, background-color .12s ease;
}
.password-field .password-toggle:hover,
.password-field .password-toggle:focus-visible {
  opacity: 1;
  background: rgba(255, 122, 0, 0.08);
}
.password-field .password-toggle:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
}
.password-field .password-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;
  fill: none;
}
.password-field .password-toggle .icon-eye-off {
  display: none;
}
.password-field .password-toggle.is-on .icon-eye {
  display: none;
}
.password-field .password-toggle.is-on .icon-eye-off {
  display: block;
}
/* Animate the diagonal slash inside the eye-off icon when it appears.
   It's the last <path> in the SVG (the m2 2 20 20 line). Length is
   ~28.3 units in the 24x24 viewBox; round up to 30 so the dash fully
   covers the line at any sub-pixel render. */
.password-field .password-toggle .icon-eye-off path:last-of-type {
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
}
.password-field .password-toggle.is-on .icon-eye-off path:last-of-type {
  animation: password-toggle-draw-slash .28s .04s cubic-bezier(.55, .15, .35, 1) forwards;
}
@keyframes password-toggle-draw-slash {
  to { stroke-dashoffset: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .password-field .password-toggle.is-on .icon-eye-off path:last-of-type {
    animation: none;
    stroke-dashoffset: 0;
  }
}

/* ---------- 16. Empty state + utilities ---------- */
.empty {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 36px 24px;
  text-align: center;
  color: var(--text-2);
}
.empty h3 { color: var(--text); font-size: 14px; text-transform: none; letter-spacing: 0; margin-bottom: 6px; }
.empty p { margin: 6px auto; font-size: 12.5px; max-width: 460px; }

.muted, small { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.recommendation { font-weight: 600; color: var(--text); font-size: 12px; }
.reason { color: var(--text-2); font-size: 12.5px; line-height: 1.5; margin-top: 4px; }
.score-block { display: flex; gap: 12px; align-items: flex-start; }
.score-lg { width: 56px; height: 56px; font-size: 16px; }

/* Card grid layouts */
.cards { display: grid; gap: 12px; }
.cards-1 { grid-template-columns: 1fr; }
.cards-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 800px) { .cards-2 { grid-template-columns: 1fr; } }

/* Criteria editor (from existing /bids/criteria) */
.criteria-editor { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 18px; }
.criteria-editor textarea { min-height: 360px; }

/* ---------- Legacy partial styling ----------
 * Existing _info_sheet.html and _rfis.html render content directly inside
 * .card (no .card-body wrapper) and use class names from the prior design.
 * These rules keep them looking right under the new dark theme.
 */
.card > p,
.card > h3,
.card > h4,
.card > form,
.card > details,
.card > table,
.card > ul,
.card > dl,
.card > div { margin-left: 16px; margin-right: 16px; }
.card > p:first-of-type,
.card > form:first-of-type,
.card > h3:first-of-type { margin-top: 14px; }
.card > p:last-of-type,
.card > form:last-of-type,
.card > ul:last-of-type,
.card > dl:last-of-type { margin-bottom: 14px; }
.card > .card-head { margin-left: 0; margin-right: 0; }

.prose { font-size: 13px; line-height: 1.6; color: var(--text-2); }
.prose strong { color: var(--text); font-weight: 600; }

.info-meta { font-size: 11px; color: var(--muted); margin-top: 12px; }
.warning {
  background: rgba(229,162,59,.08);
  border: 1px solid rgba(229,162,59,.3);
  color: var(--amber);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
}
.error {
  background: rgba(229,72,77,.08);
  border: 1px solid rgba(229,72,77,.3);
  color: var(--red);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
}

.info-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 6px 0 12px; }
.info-table th {
  text-align: left;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 1.1px;
  color: var(--muted);
  text-transform: uppercase;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.info-table td { padding: 8px 8px; border-bottom: 1px solid #272727; color: var(--text-2); vertical-align: top; }
.info-table tr:last-child td { border-bottom: 0; }
.info-table a { color: var(--orange); }

.scope-items { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.scope-badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 3px;
  font-weight: 600;
  letter-spacing: 0.4px;
  border: 1px solid;
  font-family: 'JetBrains Mono', monospace;
}
.scope-badge.scope-in { color: #5dd07a; background: var(--green-soft); border-color: rgba(46,160,67,.35); }
.scope-badge.scope-out { color: var(--muted); background: #1e1e1e; border-color: var(--border); text-decoration: line-through; }

.risk-list { list-style: disc; padding-left: 18px; margin: 4px 0 0; color: var(--text-2); font-size: 12px; }
.risk-list li { margin: 2px 0; }

/* RFI severity labels (existing partial uses .severity-{level}) */
.severity {
  display: inline-flex;
  align-items: center;
  font-size: 9.5px;
  letter-spacing: 1.1px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  border: 1px solid;
  text-transform: uppercase;
  white-space: nowrap;
}
.severity-contradiction, .severity-high { color: #e5484d; background: var(--red-soft); border-color: rgba(229,72,77,.35); }
.severity-ambiguity, .severity-medium, .severity-med { color: #e5a23b; background: var(--amber-soft); border-color: rgba(229,162,59,.35); }
.severity-missing_info, .severity-low { color: var(--muted); background: #1e1e1e; border-color: var(--border); }

.rfi-cat {
  margin: 14px 16px 6px !important;
  font-size: 10px;
  letter-spacing: 1.4px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}
.rfi-list { list-style: none; padding: 0; margin: 0; }
.rfi-list .rfi { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.rfi-list .rfi:last-child { border-bottom: 0; }
.rfi-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rfi-question { font-size: 13px; color: var(--text); font-weight: 500; flex: 1; min-width: 200px; line-height: 1.4; }
.rfi-citation summary { cursor: pointer; font-size: 11.5px; color: var(--muted); }
.rfi-citation pre {
  background: #181818;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--text-2);
  margin: 6px 0 0;
  white-space: pre-wrap;
}

.info-sheet h3 { margin: 16px 16px 6px !important; }

/* ---------- Subcontractor quotes (bid detail "Subs" tab) ---------- */
.sub-quotes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  margin-top: 4px;
}
.sub-quotes-table th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 1.1px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.sub-quotes-table th.num { text-align: right; }
.sub-quotes-table th.action { width: 36px; }
.sub-quotes-table td {
  padding: 10px;
  border-bottom: 1px solid #232323;
  vertical-align: top;
  color: var(--text-2);
}
.sub-quotes-table td.num { text-align: right; color: var(--text); font-weight: 500; white-space: nowrap; }
.sub-quotes-table tr:last-child td { border-bottom: 0; }
.sub-quotes-table .sub-name { color: var(--text); font-weight: 500; }
.sub-quotes-table .sub-contact { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sub-quotes-table .sub-notes { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.sub-quotes-table .sub-date { font-size: 10.5px; color: var(--muted); font-family: 'JetBrains Mono', monospace; margin-top: 2px; }

/* Status pills (one per SubQuoteStatus enum value) */
.sub-status {
  display: inline-flex;
  align-items: center;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  white-space: nowrap;
}
.sub-status-requested   { color: var(--amber); background: var(--amber-soft); border-color: rgba(229,162,59,.35); }
.sub-status-quoted      { color: #5dd07a; background: var(--green-soft); border-color: rgba(46,160,67,.35); }
.sub-status-declined    { color: #e5484d; background: var(--red-soft); border-color: rgba(229,72,77,.35); }
.sub-status-no_response { color: var(--muted); background: #1e1e1e; border-color: var(--border); }
.sub-status-accepted    { color: #6c9fea; background: var(--blue-soft); border-color: rgba(76,141,255,.35); }

/* Inline edit form expanded via <details> */
.sub-edit summary {
  list-style: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 13px;
  color: var(--muted);
}
.sub-edit summary::-webkit-details-marker { display: none; }
.sub-edit summary:hover { color: var(--orange); background: #262626; }
.sub-edit[open] summary { color: var(--orange); }

/* Edit-form container expanded under the row — absolutely positioned would
   overlap; instead it pushes content down and spans the row width below. */
.sub-edit form.sub-form {
  position: absolute;
  right: 0;
  top: 28px;
  width: min(420px, 90vw);
  background: #1c1c1c;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  padding: 14px;
  z-index: 4;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.sub-edit { position: relative; }
.sub-edit form.sub-delete {
  position: absolute;
  right: 0;
  top: 28px;
  display: none;  /* sits under the edit form; toggled open via inline rules below */
}
/* When only the edit form is open, show delete inline below it */
.sub-edit[open] form.sub-delete {
  display: block;
  top: auto;
  bottom: -44px;
  z-index: 4;
}

/* Shared form layout used by both Add and Edit forms */
.sub-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
}
.sub-form label.full { grid-column: 1 / -1; }
.sub-form input[type="text"],
.sub-form input[type="date"],
.sub-form select,
.sub-form textarea {
  font-size: 12.5px;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: var(--text);
}
.sub-form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* Add-form — lives below the rows, expands in-place rather than popping over */
.sub-add {
  margin-top: 14px;
  border-top: 1px dashed var(--border);
  padding-top: 14px;
}
.sub-add > summary {
  list-style: none;
  display: inline-flex;
}
.sub-add > summary::-webkit-details-marker { display: none; }
.sub-add[open] > summary { display: none; }  /* hide the + button once form is open */
.sub-add form.sub-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-top: 0;
  background: #1e1e1e;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

/* ---------- Rate sheet browser (/rates) ---------- */
.rates-section { margin: 0 0 28px; }
.rates-cat {
  margin: 0 0 12px;
  font-size: 11px;
  letter-spacing: 1.4px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}
.rates-group { margin-bottom: 14px; }
.rates-group-label {
  margin: 0 0 6px;
  font-size: 11.5px;
  color: var(--text-2);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
}
.rates-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 12.5px;
}
.rates-table th {
  background: #1e1e1e;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 10px;
  font-weight: 600;
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.rates-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #232323;
  color: var(--text-2);
  vertical-align: top;
}
.rates-table tbody tr:last-child td { border-bottom: 0; }
.rates-table tbody tr:hover { background: var(--row-hover); }
.rates-table .rates-item { color: var(--text); font-weight: 500; }
.rates-table .rates-rate { text-align: right; color: var(--text); font-weight: 500; width: 88px; white-space: nowrap; }
.rates-table .rates-unit { width: 70px; color: var(--text-2); }
.rates-table .rates-notes { font-size: 11.5px; color: var(--muted); }
.rates-table .rates-actions { width: 36px; text-align: right; padding: 4px 8px; }

/* Inline edit / add affordances on /rates (admin-only). */
.rates-cat { display: flex; align-items: center; gap: 10px; }
.rate-add-btn {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  background: transparent;
  color: var(--orange);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.rate-add-btn:hover { background: rgba(249, 115, 22, 0.08); border-color: var(--orange); }
.rate-edit-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 13px;
  line-height: 1;
  border-radius: 3px;
}
.rate-edit-btn:hover { color: var(--orange); background: rgba(249, 115, 22, 0.06); }
.rate-row-edit > td { background: rgba(249, 115, 22, 0.04); }
.rates-edit-cell { padding: 12px !important; }
.rate-edit-form { display: flex; flex-direction: column; gap: 10px; }
.rate-edit-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 3fr;
  gap: 8px;
}
@media (max-width: 900px) {
  .rate-edit-grid { grid-template-columns: 1fr 1fr; }
}
.rate-edit-field { display: flex; flex-direction: column; gap: 2px; font-size: 11px; }
.rate-edit-field span { color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-size: 9.5px; }
.rate-edit-field input {
  background: #1a1a1a;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text);
  padding: 6px 8px;
  font-size: 12.5px;
  font-family: inherit;
}
.rate-edit-field input:focus { outline: none; border-color: var(--orange); }
.rate-edit-actions { display: flex; gap: 8px; align-items: center; }
.rate-delete-btn { color: #c87a5a !important; margin-left: auto; }
.rate-delete-btn:hover { background: rgba(200, 122, 90, 0.12) !important; border-color: #c87a5a !important; }

/* ---------- 17. Responsive (mobile / hamburger nav) ----------
 * Breakpoint: 860px. Below this, the fixed sidebar becomes an off-canvas
 * drawer triggered by the `.nav-toggle` button in the topbar. The drawer
 * slides in via `.sidebar.open`; `.nav-backdrop.open` dims the page behind
 * it. JS toggle lives in base.html.
 *
 * The main dashboard table collapses into a card-per-row layout because
 * its 8-column grid is unreadable below ~900px.
 */

/* Hamburger toggle — hidden by default (desktop), revealed <=860px */
.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-2);
  cursor: pointer;
  padding: 0;
  margin: -8px 4px -8px -8px;
  flex: none;
}
.nav-toggle:hover { background: #262626; color: var(--text); border-color: var(--border); }
.nav-toggle svg { width: 20px; height: 20px; display: block; }

/* Backdrop lives always in DOM, only becomes visible on open */
.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 29;
}
.nav-backdrop.open { opacity: 1; pointer-events: auto; }

@media (max-width: 860px) {
  /* App shell becomes single-column; sidebar pulled out of the grid flow */
  .layout { grid-template-columns: 1fr; }

  /* Sidebar = off-canvas drawer. Fixed, z-index above backdrop, slides in. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    height: 100vh;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(.2,.8,.2,1);
    box-shadow: 6px 0 24px rgba(0, 0, 0, 0.4);
    border-right: 1px solid var(--border);
  }
  .sidebar.open { transform: translateX(0); }

  /* Show the toggle button */
  .nav-toggle { display: inline-flex; }

  /* Topbar spacing: tighten, and allow crumbs to shrink */
  .topbar { padding: 10px 14px; gap: 8px; }
  .crumbs { flex: 1; min-width: 0; font-size: 11.5px; }
  .crumbs .leaf { max-width: none; }
  .user-menu { gap: 10px; font-size: 11.5px; }
  .user-menu .user-name { display: none; }

  /* Lock body scroll when drawer is open */
  body.nav-open { overflow: hidden; }

  /* Tighter page padding */
  .page { padding: 14px 14px 48px; }

  /* Page head stacks */
  .page-head {
    grid-template-columns: 1fr;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 14px;
  }
  .page-head h1 { font-size: 20px; }
  .page-actions { flex-wrap: wrap; }
  .page-actions .btn,
  .page-actions .btn-primary,
  .page-actions .btn-secondary,
  .page-actions .btn-ghost { flex: 1 1 auto; justify-content: center; min-height: 40px; }

  /* Filter bar — stack filters, full-width search */
  .filterbar { padding: 8px; gap: 6px; }
  .filterbar .select,
  .filterbar .search {
    flex: 1 1 100%;
    min-width: 0;
  }
  .filterbar select { width: 100%; min-width: 0; min-height: 40px; }
  .filterbar .search { min-width: 0; height: 40px; }

  /* Tabs: allow horizontal scroll so they don't wrap into many rows */
  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; flex: none; padding: 10px 12px; font-size: 12.5px; min-height: 40px; }

  /* ----- Dashboard table -> card layout ----- */
  .thead { display: none; }
  .table { background: transparent; border: 0; border-radius: 0; overflow: visible; }
  .row {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    grid-template-areas:
      "score title   dismiss"
      "score meta    meta"
      "flags closing status";
    column-gap: 10px;
    row-gap: 6px;
    height: auto;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
  }
  .row:nth-child(even) { background: var(--card); }
  .row:hover { background: var(--card); }
  .row:hover:before { display: none; }
  .row:last-child { border-bottom: 1px solid var(--border); }

  .row > *:nth-child(1) { grid-area: score; align-self: start; }
  .row .title-cell { grid-area: title; align-self: center; flex-wrap: wrap; row-gap: 4px; }
  .row .title { white-space: normal; font-size: 14px; line-height: 1.35; }
  .row .flags-cell { grid-area: flags; font-size: 11px; }
  .row .portal-cell { grid-area: meta; font-size: 11px; color: var(--muted); }
  .row .muted-cell { display: none; } /* location duplicated into meta line is noise on mobile */
  .row .site-walk-cell { display: none; } /* keep the card tight — site walk is desktop-only */
  .row .closing-cell { grid-area: closing; font-size: 11px; flex-direction: row; gap: 6px; align-items: baseline; }
  .row .closing-cell .rel { margin-top: 0; }
  .row > *:nth-last-child(2) { grid-area: status; justify-self: end; align-self: center; }
  .row > *:last-child { grid-area: dismiss; justify-self: end; align-self: start; }

  .row .score { width: 40px; height: 40px; border-radius: 20px; font-size: 13px; }

  .dismiss {
    width: 40px;
    height: 40px;
    color: var(--muted);
  }

  .table-foot {
    background: transparent;
    padding: 6px 4px 0;
    border-top: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  /* ----- Bid detail ----- */
  .detail-head {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-bottom: 14px;
  }
  .title-row { gap: 12px; }
  .big-score { width: 52px; height: 52px; font-size: 18px; }
  .detail-title { font-size: 18px; line-height: 1.3; }
  .title-meta { font-size: 11px; gap: 5px; }

  .nav-arrows { align-self: flex-start; }
  .page-actions .btn-primary { width: 100%; }

  /* Meta strip — 2 columns stacked, no right borders */
  .meta-strip {
    grid-template-columns: 1fr 1fr;
    margin-bottom: 14px;
  }
  .meta-cell {
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 10px 12px;
  }
  .meta-cell:nth-child(2n) { border-right: 0; }
  .meta-cell:nth-last-child(-n+2) { border-bottom: 0; }
  .meta-cell .v { font-size: 12.5px; }

  /* Detail grid — already collapses at 1100, reaffirm and tighten gaps */
  .detail-grid { gap: 12px; }

  /* Cards — slightly reduced padding */
  .card-head { padding: 10px 14px; }
  .card-body { padding: 12px 14px; }

  /* Scoring breakdown row — tighter label column */
  .sb-row { grid-template-columns: 110px 1fr 40px; gap: 8px; }

  /* Activity log — tighter timestamp */
  .activity li { grid-template-columns: 14px 1fr auto; gap: 10px; }
  .activity .when { font-size: 10px; }

  /* KV pairs in info-sheet — stack */
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { color: var(--muted); margin-top: 4px; font-size: 11px; }

  /* Admin: form + table single-column and scroll */
  .admin-form { grid-template-columns: 1fr; padding: 16px; }
  .admin-form .admin-checkbox { grid-column: span 1; }
  .admin-form button[type="submit"] { grid-column: span 1; width: 100%; justify-content: center; }
  .admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-table { min-width: 540px; }
  .inline-reset { flex-wrap: wrap; }
  .inline-reset input { flex: 1 1 120px; width: auto; }

  /* Buttons hit 40px min-height on mobile (44 is our target, but the internal
     padding-plus-font already averages ~40; the critical path is the
     generate-info-sheet / decision submits which span forms). */
  .btn, .btn-primary, .btn-secondary, .btn-ghost {
    min-height: 40px;
    padding: 9px 14px;
    font-size: 13px;
  }
  .linkish { padding: 6px 2px; min-height: 32px; display: inline-flex; align-items: center; }

  /* Decision panel buttons take full width */
  .decision .btn-primary, .decision .btn { width: 100%; }

  /* Flags grid + scope list — already collapse at 800px, reaffirm */
  .flags-grid { grid-template-columns: 1fr; gap: 10px; }
  .scope { grid-template-columns: 1fr; }

  /* Search page input: full-width, bigger tap target */
  .search-form { flex-direction: column; gap: 8px; }
  .search-input { min-height: 40px; }

  /* Rate sheet — hide the NOTES column on mobile. For equipment the note
     is the same "4 Hour Minimum; Fuel Surcharge..." on every row, so
     duplicating it per-row blows up vertical space. Desktop keeps it
     because there's room. Bin/disposal notes are shorter and still useful
     but we hide them uniformly for simplicity. */
  .rates-table .rates-notes { display: none; }
  .rates-table .rates-rate { width: auto; }
  .rates-table th, .rates-table td { padding: 8px 10px; }

  /* Login card: tighter on small viewports (optional — already capped) */
  .login-card { padding: 24px 20px; }
}

/* Even tighter fine-tuning under 400px (small phones) */
@media (max-width: 400px) {
  .page { padding: 12px 12px 44px; }
  .page-head h1 { font-size: 18px; }
  .crumbs { font-size: 11px; }
  .row { grid-template-columns: 40px 1fr 40px; padding: 10px 12px; }
  .row .score { width: 36px; height: 36px; font-size: 12px; }
  .meta-strip { grid-template-columns: 1fr; }
  .meta-cell { border-right: 0; }
  .meta-cell:last-child { border-bottom: 0; }
}

/* ---------- BidMap (Leaflet) ---------------------------------------- */
.bid-map {
  height: calc(100vh - 200px);
  min-height: 480px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #1a1a1a;
}
/* Custom pin: a colored dot with a subtle ring + pulsing halo so the eye
   can pick it out against the map without drowning the basemap. */
.leaflet-marker-icon.bid-pin {
  background: transparent;
  border: 0;
}
.bid-pin-dot {
  display: block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.5);
  position: relative;
  margin: 2px;
}
.bid-pin-dot::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid currentColor;
  opacity: 0;
  animation: bid-pin-pulse 2.4s ease-out infinite;
  color: inherit;
  pointer-events: none;
}
@keyframes bid-pin-pulse {
  0%   { transform: scale(0.9); opacity: 0.6; }
  80%  { transform: scale(1.6); opacity: 0;   }
  100% { transform: scale(1.6); opacity: 0;   }
}
@media (prefers-reduced-motion: reduce) {
  .bid-pin-dot::after { animation: none; }
}

/* Popup styling — dark theme to match the rest of the app. Leaflet's
   default popup is white and bright; override the inner wrapper. */
.leaflet-popup-content-wrapper.bid-popup-wrap,
.bid-popup-wrap .leaflet-popup-content-wrapper {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
}
.bid-popup-wrap .leaflet-popup-tip {
  background: var(--card);
  border: 1px solid var(--border);
  border-top: 0;
  border-left: 0;
}
.bid-popup-wrap .leaflet-popup-content {
  margin: 10px 12px;
  min-width: 220px;
}
.bid-popup-wrap .leaflet-popup-close-button {
  color: var(--muted-2);
}
.bid-popup-wrap .leaflet-popup-close-button:hover {
  color: var(--text);
}
.bid-popup-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.bid-popup-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
}
.bid-popup-status {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.bid-popup-title {
  display: block;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text);
  text-decoration: none;
  margin-bottom: 4px;
  line-height: 1.3;
}
.bid-popup-title:hover { color: var(--orange); }
.bid-popup-meta {
  font-size: 12px;
  color: var(--muted-2);
  display: flex;
  gap: 6px;
  align-items: center;
}
.bid-popup-meta .bid-popup-sep { opacity: 0.5; }

/* Cluster bubble: tweak Leaflet.markercluster's default styling to match
   the orange palette. */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large { background-color: rgba(255, 122, 0, 0.20); }
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(255, 122, 0, 0.85);
  color: #0f172a;
  font-weight: 600;
}

/* --- Portal Credentials admin page --- */
.portal-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 0;
  overflow: hidden;
}
.portal-card > summary {
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  list-style: none;
  user-select: none;
}
.portal-card > summary::-webkit-details-marker { display: none; }
.portal-card > summary::before {
  content: "▸";
  color: var(--muted-2);
  font-size: 12px;
  width: 12px;
  transition: transform 0.15s;
}
.portal-card[open] > summary::before { transform: rotate(90deg); }
.portal-card-name { font-weight: 600; flex: 1; }
.portal-card-status {
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
}
.portal-card-status.configured {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}
.portal-card-status.missing {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted-2);
}
.portal-card-updated {
  font-size: 12px;
  color: var(--muted-2);
  font-family: var(--font-mono, monospace);
}
.portal-form {
  padding: 0 16px 16px 16px;
  border-top: 1px solid var(--border);
}
.portal-login-url {
  margin-top: 12px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted-2);
}
.portal-login-url a { color: var(--orange); text-decoration: none; }
.portal-login-url a:hover { text-decoration: underline; }
.password-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.password-row input { flex: 1; }
.toggle-password {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0 12px;
}
.portal-form .optional {
  font-weight: 400;
  color: var(--muted-2);
  font-size: 12px;
}
.portal-form-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.btn-danger {
  background: transparent;
  border: 1px solid var(--border);
  color: #f87171;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
}
.btn-danger:hover {
  background: rgba(248, 113, 113, 0.10);
  border-color: #f87171;
}

/* --- Portal credential toast (bid detail page) --- */
.portal-creds-toast {
  position: fixed;
  top: 80px;
  right: 24px;
  width: 320px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  font-size: 14px;
}
.portal-creds-toast.hidden { display: none; }
.portal-creds-toast-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-weight: 600;
}
.portal-creds-toast-close {
  background: transparent;
  border: none;
  color: var(--muted-2);
  cursor: pointer;
  font-size: 18px;
  padding: 0 4px;
  line-height: 1;
}
.portal-creds-toast-close:hover { color: var(--text); }
.portal-creds-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.portal-creds-label {
  width: 70px;
  font-size: 12px;
  color: var(--muted-2);
  flex-shrink: 0;
}
.portal-creds-value {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 8px;
  border-radius: 4px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portal-creds-copy {
  background: var(--orange);
  color: #0f172a;
  border: none;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.portal-creds-copy:hover { filter: brightness(1.1); }
.portal-creds-copy.copied {
  background: #4ade80;
}
.portal-creds-error {
  color: #f87171;
  font-size: 12px;
  margin-top: 4px;
}
