/* =========================================================================
 * Doka Pocket CRM — app.css
 * Engineer's Notebook system: Fraunces display / DM Sans UI / JetBrains
 * Mono data, warm paper with rust accent. Status carries the color:
 * Pre Bid = yellow, Quotation = ocean blue, Sales Order = green.
 * ========================================================================= */

:root {
  --paper: #F6F2E9;
  --card: #FFFDF7;
  --ink: #2B2A26;
  --ink-soft: #6B675C;
  --line: #DDD5C4;
  --line-soft: #EAE3D4;
  --rust: #B3502D;
  --rust-deep: #8F3E21;
  --amber: #E0A41B;
  --teal: #1F6F9C;
  --green: #4A7A43;
  --purple: #6E4FA3;
  --warn-bg: #F6E3DC;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --nav-h: 58px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(43, 42, 38, .10), 0 4px 14px rgba(43, 42, 38, .06);
}

* { box-sizing: border-box; }

/* Author display values (flex, etc.) must never override the hidden
 * attribute — without this, the empty full-screen detail overlay paints
 * over the entire app on load. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
body.no-scroll { overflow: hidden; }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 2px;
}
h1, h2, h3 { margin: 0; font-family: var(--font-display); font-weight: 640; }
.muted { color: var(--ink-soft); }
.pad { padding: 12px; }

/* ---- buttons & inputs --------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px;
  border: 1.5px solid var(--ink);
  border-radius: var(--radius);
  background: var(--card);
  font-weight: 500;
  min-height: 42px;
}
.btn-primary { background: var(--rust); border-color: var(--rust-deep); color: #FFF8F0; }
.btn-primary:active { background: var(--rust-deep); }
.btn-ghost { border-color: var(--line); color: var(--ink-soft); }
.btn-ghost.danger { color: var(--rust-deep); border-color: var(--rust); }
.btn-link { border-color: var(--teal); color: var(--teal); text-decoration: none; font-weight: 500; }

.file-btn { position: relative; overflow: hidden; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.text-input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  font: inherit;
  color: var(--ink);
}
.text-input:focus { border-color: var(--rust); outline: none; }

.icon-btn {
  width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 20px;
}
.icon-btn:active { background: var(--line-soft); }

/* ---- setup --------------------------------------------------------------- */

.setup {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 18px;
}
.setup-card { width: 100%; max-width: 420px; text-align: center; }
.brand {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--rust); margin-bottom: 18px;
}
.brand-rule { flex: 0 0 34px; height: 1px; background: var(--rust); opacity: .5; }
.setup-card h1 { font-size: 34px; line-height: 1.1; margin-bottom: 12px; }
.setup-sub { color: var(--ink-soft); margin: 0 0 22px; }
.setup-status { margin-top: 16px; min-height: 24px; font-family: var(--font-mono); font-size: 13px; }
.setup-error { color: var(--rust-deep); }
.setup-choice { width: 100%; }
.setup-or {
  display: flex; align-items: center; gap: 12px;
  margin: 14px 0;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--ink-soft);
}
.setup-or span { flex: 1; height: 1px; background: var(--line); }
.spinner {
  display: inline-block; width: 14px; height: 14px; margin-right: 8px;
  border: 2px solid var(--line); border-top-color: var(--rust);
  border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.identity-list {
  margin: 14px 0 10px;
  max-height: 44dvh; overflow-y: auto;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--card);
  text-align: left;
}
.identity-row {
  width: 100%;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.identity-row:last-child { border-bottom: 0; }
.identity-row:active { background: var(--paper); }
.identity-count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); }

/* ---- top bar -------------------------------------------------------------- */

.tab { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
.tab-scroll { min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px 8px;
}
.search-row { display: flex; gap: 8px; }
.search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 22px;
  background: var(--card);
  font: inherit;
  min-width: 0;
}
.search-input:focus { border-color: var(--rust); outline: none; }

/* Sample-mode banner (RLS-scoped live data replaces it after sign-in). */
.demo-banner {
  background: var(--warn-bg); color: var(--rust-deep);
  border-bottom: 1px solid var(--rust);
  text-align: center; font-size: 12.5px; font-weight: 600;
  padding: 6px 10px;
}
.demo-signin {
  color: var(--rust-deep); font-weight: 700; text-decoration: underline;
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
}

/* Clerk's prebuilt sign-in mounts here. */
.clerk-mount { display: flex; justify-content: center; margin: 6px 0 14px; min-height: 320px; }

.chip-row {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 8px 0 2px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  padding: 6px 12px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  font-size: 13px; font-weight: 500;
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.st-prebid.on { background: var(--amber); border-color: var(--amber); color: var(--ink); }
.chip.st-quote.on { background: var(--teal); border-color: var(--teal); }
.chip.st-order.on { background: var(--green); border-color: var(--green); }
.chip-filters { border-style: dashed; }
.chip-filters.on { border-style: solid; }
.chip-flag { color: var(--rust-deep); border-color: var(--warn-bg); }
.chip-flag.on { background: var(--rust); border-color: var(--rust-deep); color: #FFF8F0; }

.kpi-sort-row { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.kpi-strip { display: flex; gap: 14px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.kpi-strip::-webkit-scrollbar { display: none; }
.kpi { display: flex; flex-direction: column; line-height: 1.15; flex: 0 0 auto; }
.kpi-value { font-family: var(--font-mono); font-weight: 600; font-size: 14px; }
.kpi-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.kpi.warn .kpi-value { color: var(--rust-deep); }
.sort-select {
  flex: 0 0 auto; max-width: 132px;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--card);
  font-size: 12px; padding: 6px 6px;
  color: var(--ink-soft);
}

/* ---- project cards (the "ticket stub") ----------------------------------- */

.project-list { padding: 10px 12px 0; display: flex; flex-direction: column; gap: 10px; }

.project-card {
  position: relative;
  display: flex;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
}
.card-spine { flex: 0 0 5px; background: var(--ink-soft); }
.project-card.st-prebid .card-spine { background: var(--amber); }
.project-card.st-quote .card-spine { background: var(--teal); }
.project-card.st-order .card-spine { background: var(--green); }

.card-body { flex: 1; padding: 10px 44px 10px 12px; min-width: 0; }
.card-top { display: flex; align-items: center; gap: 8px; }
.card-num { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); letter-spacing: .04em; }
.card-status {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em;
  padding: 2px 7px; border-radius: 4px; color: #FFFDF7;
  background: var(--ink-soft);
}
.card-status.st-prebid { background: var(--amber); color: var(--ink); }
.card-status.st-quote { background: var(--teal); }
.card-status.st-order { background: var(--green); }
.card-pend {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  background: var(--warn-bg); color: var(--rust-deep);
  border: 1px solid var(--rust);
  border-radius: 9px; padding: 0 6px;
}
.card-pend-ico { width: 11px; height: 11px; vertical-align: -1.5px; margin-right: 3px; }
.card-flag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
  background: var(--warn-bg); color: var(--rust-deep);
  border: 1px solid var(--rust);
  border-radius: 9px; padding: 1px 7px;
  white-space: nowrap;
}
.card-name {
  font-size: 16.5px; line-height: 1.2;
  margin: 4px 0 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--ink-soft); }
.card-figures { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 7px; }
.fig { font-family: var(--font-mono); font-size: 13px; font-weight: 600; display: flex; flex-direction: column; line-height: 1.1; }
.fig i { font-style: normal; font-family: var(--font-body); font-weight: 400; font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-soft); }
.fig.warn { color: var(--rust-deep); }

.card-star {
  position: absolute; top: 6px; right: 4px;
  width: 38px; height: 38px;
  font-size: 19px; color: var(--line);
  display: flex; align-items: center; justify-content: center;
}
.card-star.on { color: var(--amber); }

.list-sentinel { height: 8px; }

/* ---- empty states ----------------------------------------------------------- */

.empty-state { text-align: center; padding: 56px 28px; color: var(--ink-soft); }
.empty-mark { font-size: 34px; color: var(--line); margin-bottom: 10px; }
.empty-state h2 { color: var(--ink); font-size: 21px; margin-bottom: 6px; }

/* ---- bottom navigation -------------------------------------------------------- */

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.nav-btn {
  position: relative;
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 11px; font-weight: 500;
  color: var(--ink-soft);
}
.nav-btn .nav-ico { font-size: 18px; line-height: 1; }
.nav-btn .nav-svg { width: 20px; height: 20px; display: block; }
.nav-btn.active { color: var(--rust); }
.nav-btn.active::after {
  content: ""; position: absolute; top: 0; left: 28%; right: 28%;
  height: 2.5px; background: var(--rust); border-radius: 0 0 3px 3px;
}
.nav-badge {
  position: absolute; top: 6px; right: calc(50% - 26px);
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--rust); color: #FFF8F0;
  border-radius: 9px;
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* ---- overlays: sheet + modal ----------------------------------------------------
 * Leaflet's own panes/controls climb to z-index 1000, so every app overlay
 * that can appear over the map tab must sit above that. Layer order:
 *   map internals  ≤ 1000
 *   detail view      2000
 *   filter / edit    2100
 *   toast            2200
 */

.overlay { position: fixed; inset: 0; z-index: 2100; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(43, 42, 38, .42); }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: 86dvh;
  background: var(--paper);
  border-radius: 16px 16px 0 0;
  display: flex; flex-direction: column;
  animation: sheet-up .22s ease-out;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-grip { width: 38px; height: 4px; background: var(--line); border-radius: 2px; margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 4px; }
.sheet-head h2 { font-size: 21px; }
.sheet-scroll { overflow-y: auto; padding: 4px 16px 12px; }
.sheet-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.sheet-foot .btn { width: 100%; }

.facet { margin: 14px 0; }
.facet h3 { font-size: 13px; font-family: var(--font-body); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin-bottom: 8px; }
.facet-search { margin-bottom: 8px; }
.facet-options { display: flex; flex-wrap: wrap; gap: 7px; }
.facet-tall { max-height: 180px; overflow-y: auto; align-content: flex-start; }
.facet-opt {
  padding: 7px 11px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  font-size: 13px;
}
.facet-opt.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.facet-opt.on .facet-count { color: var(--line); }
.facet-count { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); }

.modal-panel {
  position: absolute; left: 14px; right: 14px; top: 50%;
  transform: translateY(-50%);
  background: var(--paper);
  border-radius: 14px;
  padding: 20px 16px;
  box-shadow: 0 12px 40px rgba(43, 42, 38, .3);
  display: flex; flex-direction: column; gap: 12px;
  max-height: 80dvh; overflow-y: auto;
}
.modal-panel h2 { font-size: 21px; }
.edit-current { font-size: 13.5px; color: var(--ink-soft); }
.edit-current strong { font-family: var(--font-mono); color: var(--ink); font-weight: 600; }
.edit-note { font-size: 12.5px; color: var(--ink-soft); margin: 0; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }

/* ---- detail view ----------------------------------------------------------------- */

.detail-view {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--paper);
  display: flex; flex-direction: column;
}
.detail-head {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 10px 10px 12px;
  border-bottom: 4px solid var(--ink-soft);
  background: var(--card);
}
.detail-head.st-prebid { border-bottom-color: var(--amber); }
.detail-head.st-quote { border-bottom-color: var(--teal); }
.detail-head.st-order { border-bottom-color: var(--green); }
.detail-title { flex: 1; min-width: 0; }
.detail-num { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); }
.detail-title h2 { font-size: 21px; line-height: 1.15; margin: 2px 0 6px; }
.detail-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.detail-star { position: static; flex: 0 0 38px; }

.detail-scroll { flex: 1; overflow-y: auto; padding: 12px 14px; }
.detail-hint {
  font-size: 12.5px; color: var(--ink-soft);
  font-family: var(--font-mono);
  margin-bottom: 12px;
}
.detail-flag {
  background: var(--warn-bg);
  border: 1px solid var(--rust);
  border-radius: var(--radius);
  padding: 11px 14px;
  margin-bottom: 16px;
}
.detail-flag-head {
  font-weight: 700; font-size: 13px; color: var(--rust-deep);
  letter-spacing: .02em; margin-bottom: 4px;
}
.detail-flag ul { margin: 0; padding-left: 18px; }
.detail-flag li { font-size: 13px; color: var(--ink); margin: 2px 0; }
.dgroup { margin-bottom: 20px; }
.dgroup h3 {
  font-family: var(--font-body); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: var(--rust);
  border-bottom: 1px solid var(--line); padding-bottom: 5px; margin-bottom: 2px;
}
.dgroup-rows { background: var(--card); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.drow {
  display: flex; justify-content: space-between; align-items: baseline; gap: 14px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.drow:last-child { border-bottom: 0; }
.drow.editable, .drow.customer-link-row { cursor: pointer; }
.drow.editable:active, .drow.customer-link-row:active { background: var(--paper); }
.drow-label { font-size: 13px; color: var(--ink-soft); flex: 0 1 46%; }
.drow-edit { width: 12px; height: 12px; margin-left: 6px; color: var(--rust); opacity: .7; vertical-align: -1px; }
.drow-value {
  font-family: var(--font-mono); font-size: 13.5px; font-weight: 500;
  text-align: right; flex: 1; min-width: 0; overflow-wrap: anywhere;
}
.drow-value.warn { color: var(--rust-deep); }
.drow.has-pending { background: #FBF4E4; }
.drow-pending { display: block; color: var(--rust); font-weight: 600; font-size: 12.5px; }
.link-row { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 6px; }

.note-item {
  background: var(--card); border: 1px solid var(--line-soft); border-left: 3px solid var(--amber);
  border-radius: 8px; padding: 9px 12px; margin: 8px 0; font-size: 14px;
}
.note-ts { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); margin-bottom: 2px; }
.note-add { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.detail-pad { height: 48px; }

/* ---- queue tab (carbon-copy change order) ------------------------------------------ */

#tabQueue, #tabMore { padding-top: 0; }
#queueView, #moreView { padding: 16px 14px; }
.queue-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.queue-head h2 { font-size: 26px; }
.queue-count {
  font-family: var(--font-mono); font-weight: 600; font-size: 14px;
  background: var(--rust); color: #FFF8F0;
  border-radius: 10px; padding: 1px 9px;
}
.queue-group {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.queue-proj {
  width: 100%; text-align: left;
  padding: 11px 12px;
  font-weight: 700; font-size: 14.5px;
  border-bottom: 1px dashed var(--line);
  background: linear-gradient(0deg, transparent, rgba(194, 138, 31, .06));
}
.queue-proj .card-num { margin-right: 6px; }
.queue-entry {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 9px 6px 9px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.queue-entry:last-child { border-bottom: 0; }
.q-body { flex: 1; font-size: 13.5px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.q-field { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); flex: 0 0 100%; }
.q-old { font-family: var(--font-mono); text-decoration: line-through; color: var(--ink-soft); }
.q-arrow { color: var(--rust); }
.q-new { font-family: var(--font-mono); font-weight: 600; color: var(--rust-deep); }
.q-text { flex: 1 1 100%; }
.q-del { flex: 0 0 36px; height: 32px; font-size: 19px; color: var(--ink-soft); }
.q-meta { flex: 1 1 100%; display: flex; gap: 8px; margin-top: 2px; }
.q-status {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-soft); border: 1px solid var(--ink-soft); border-radius: 9px; padding: 0 7px;
}
.q-status.applied { color: var(--green); border-color: var(--green); }
.q-status.rejected { color: var(--rust-deep); border-color: var(--rust); }
.q-sub { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); }
.queue-entry.foreign { opacity: .85; }
.queue-actions { display: flex; flex-direction: column; gap: 9px; margin-top: 18px; }

/* ---- more tab -------------------------------------------------------------------------- */

.more-section {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.more-section h2 { font-size: 19px; }
.more-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.more-row strong { font-family: var(--font-mono); font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.more-hint { font-size: 12.5px; color: var(--ink-soft); margin: 0; }
.more-warn { font-size: 12.5px; color: var(--rust-deep); background: var(--warn-bg); border-radius: 8px; padding: 8px 10px; margin: 0; }
.more-about { text-align: center; font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); padding: 8px 0 20px; }
.more-credit {
  display: block; text-align: center; margin-top: 14px;
  font-size: 11.5px; font-weight: 600; color: var(--ink-soft); opacity: .6;
  text-decoration: none;
}
.more-credit:active { opacity: .85; }

/* ---- map tab ------------------------------------------------------------------------------
 * Fixed, full-viewport column. The canvas fills everything between the info
 * bar and the bottom nav — no dvh math on the canvas itself, so there are no
 * grey dead bands when the mobile URL bar shows/hides.
 */
#tabMap {
  position: fixed;
  top: 0; left: 0; right: 0;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column;
  padding-bottom: 0;
}
.map-info {
  flex: 0 0 auto;
  padding: 8px 14px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}
/* Stage wraps the canvas so the floating toggle anchors below the info bar,
 * never overlapping it (the info text wraps to two lines on small screens). */
.map-stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; }
.map-canvas { flex: 1 1 auto; min-height: 0; background: #E8E4D8; }
.map-pop { font-family: var(--font-body); padding: 2px; }
.map-pop-num { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-soft); }
.map-pop-name { font-weight: 700; font-size: 14px; line-height: 1.2; margin: 1px 0 2px; }
.map-pop-loc { font-size: 12px; color: var(--ink-soft); }
.map-pop-fig { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink); margin: 4px 0 8px; }
.map-pop .btn { width: 100%; min-height: 38px; padding: 8px 10px; }

/* Theme Leaflet's popup chrome to match the notebook aesthetic. */
.leaflet-popup-content-wrapper {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.leaflet-popup-content { margin: 12px 14px; font-family: var(--font-body); }
.leaflet-popup-tip { background: var(--card); border: 1px solid var(--line); }
.leaflet-popup-close-button {
  width: 30px !important; height: 30px !important;
  font-size: 22px !important; padding: 2px 0 0 !important;
  color: var(--ink-soft) !important;
}
.leaflet-container { font-family: var(--font-body); background: #E8E4D8; }
.leaflet-bar a { color: var(--ink); }

/* ---- toast ----------------------------------------------------------------------------------- */

.toast {
  position: fixed; left: 14px; right: 14px;
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom));
  z-index: 2200;
  background: var(--ink); color: var(--paper);
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: 13.5px;
  box-shadow: 0 6px 22px rgba(43, 42, 38, .32);
  opacity: 0; transform: translateY(8px);
  transition: opacity .22s, transform .22s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

/* ---- wider screens ------------------------------------------------------------------------------- */

@media (min-width: 740px) {
  .project-list, .topbar, #queueView, #moreView { max-width: 720px; margin-left: auto; margin-right: auto; }
  .topbar { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .detail-scroll, .detail-head { padding-left: max(14px, calc((100vw - 720px) / 2)); padding-right: max(14px, calc((100vw - 720px) / 2)); }
}

/* ---- Companies ----------------------------------------------------------------------------------- */

/* Company cards reuse .project-card; the neutral spine reads as "not a
 * status-bearing project". Tint it teal so the two lists feel distinct. */
/* Company edge: blue when no linked projects, purple when one or more. */
.company-card .card-spine { background: var(--teal); }
.company-card.has-projects .card-spine { background: var(--purple); }
.company-head { border-bottom-color: var(--teal); }
.list-loading { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 40px 14px; color: var(--ink-soft); font-size: 14px; }

/* Blue link icon on the Customer Discos II row (the whole row is tappable). */
.drow-link {
  display: inline-block; margin-left: 6px;
  color: var(--teal); line-height: 0; vertical-align: -3px;
}
.drow-link-ico { width: 13px; height: 13px; display: block; }

/* Linked-projects rows on a company detail. */
.dgroup-count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); font-weight: 400; }
.linked-list { display: flex; flex-direction: column; gap: 6px; }
.linked-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 10px 12px; background: var(--card);
  border: 1px solid var(--line-soft); border-left: 4px solid var(--ink-soft); border-radius: var(--radius);
  text-align: left; cursor: pointer;
}
.linked-row.st-prebid { border-left-color: var(--amber); }
.linked-row.st-quote { border-left-color: var(--teal); }
.linked-row.st-order { border-left-color: var(--green); }
.linked-row:active { background: var(--paper); }
.linked-num { font-family: var(--font-mono); font-size: 12px; color: var(--ink-soft); flex: 0 0 auto; }
.linked-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

/* Map Projects/Companies toggle — floats over the canvas, just below the
 * info bar (anchored to .map-stage, so it never covers the info text). */
.map-toggle {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); z-index: 1000;
  display: flex; gap: 2px; padding: 3px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow);
}
.map-toggle-btn {
  padding: 6px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.map-toggle-btn.active { background: var(--ink); color: var(--paper); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
