/* DriveQuote v2 — Hydro CRM
   Apple HIG materials + water-trade brand. Dark-first, light parity.
*/

:root {
  --bg: #f2f5f8;
  --bg-elevated: rgba(255, 255, 255, 0.72);
  --bg-solid: #ffffff;
  --bg-grouped: #eef2f6;
  --fill: rgba(120, 120, 128, 0.12);
  --fill-secondary: rgba(120, 120, 128, 0.08);
  --line: rgba(60, 60, 67, 0.12);
  --line-opaque: #c6c6c8;
  --label: #0b1220;
  --label-secondary: rgba(60, 60, 67, 0.62);
  --label-tertiary: rgba(60, 60, 67, 0.34);
  --blue: #007aff;
  --blue-press: #0066d6;
  --hydro: #0ea5e9;
  --hydro-deep: #0369a1;
  --hydro-glow: rgba(14, 165, 233, 0.35);
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --indigo: #5856d6;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow: 0 1px 3px rgba(8, 28, 48, 0.04), 0 10px 28px rgba(8, 28, 48, 0.07);
  --shadow-soft: 0 0.5px 0 rgba(0, 0, 0, 0.04);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  --dock-h: 64px;
  /* Motion — Apple HIG / Emil Kowalski */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --dur-press: 140ms;
  --dur-fast: 180ms;
  --dur-ui: 240ms;
  --dur-enter: 280ms;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070d16;
    --bg-elevated: rgba(14, 22, 36, 0.78);
    --bg-solid: #121a28;
    --bg-grouped: #070d16;
    --fill: rgba(120, 140, 170, 0.18);
    --fill-secondary: rgba(120, 140, 170, 0.12);
    --line: rgba(120, 150, 190, 0.18);
    --line-opaque: #243044;
    --label: #f4f7fb;
    --label-secondary: rgba(220, 230, 245, 0.58);
    --label-tertiary: rgba(220, 230, 245, 0.32);
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 36px rgba(0, 0, 0, 0.45);
    --hydro: #38bdf8;
    --hydro-deep: #0ea5e9;
    --hydro-glow: rgba(56, 189, 248, 0.28);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-grouped);
  color: var(--label);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.29;
  letter-spacing: -0.022em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
#app {
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--dock-h) + var(--safe-bottom));
}
@media (min-width: 900px) {
  #app { padding-bottom: 0; }
  .dock { display: none !important; }
}

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: calc(8px + var(--safe-top)) 16px 10px;
  background: var(--bg-elevated);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-bottom: 0.5px solid var(--line);
}
.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand .logo {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(145deg, #7dd3fc 0%, var(--hydro) 45%, #007aff 100%);
  box-shadow: 0 4px 14px var(--hydro-glow);
}
.brand strong {
  display: block;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.brand small {
  display: block;
  color: var(--label-secondary);
  font-size: 12px;
  font-weight: 400;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--fill);
  color: var(--blue);
  cursor: pointer;
  transition: transform var(--dur-press) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.icon-btn:active, .icon-btn.is-pressed { transform: scale(0.94); }

.tabs {
  display: flex;
  gap: 2px;
  padding: 2px;
  overflow-x: auto;
  background: var(--fill);
  border-radius: 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1 0 auto;
  border: 0;
  background: transparent;
  color: var(--label);
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  transition:
    background var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-press) var(--ease-out);
}
.tab.active {
  background: var(--bg-solid);
  box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.06);
  font-weight: 600;
}
.tab.is-pressed { transform: scale(0.97); }
@media (prefers-color-scheme: dark) {
  .tab.active { background: #2a3648; box-shadow: none; }
}

main {
  flex: 1;
  padding: 20px 16px 28px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}
.view { display: none; }
.view.active {
  display: block;
  animation: appleIn var(--dur-enter) var(--ease-out);
}
@keyframes appleIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Staggered list / tile enter (animation avoids fighting card transitions) */
.motion-enter {
  opacity: 0;
  transform: translateY(8px);
}
.motion-enter.is-in {
  opacity: 1;
  transform: translateY(0);
  animation: motionIn var(--dur-enter) var(--ease-out) backwards;
  animation-delay: calc(var(--i, 0) * 48ms);
}
@keyframes motionIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.hydro-hero.motion-enter.is-in {
  animation-name: motionInHero;
  animation-delay: 0ms;
}
@keyframes motionInHero {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Hero ──────────────────────────────────────────────── */
.hydro-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(14, 165, 233, 0.32), transparent 55%),
    radial-gradient(80% 70% at 0% 100%, rgba(0, 122, 255, 0.22), transparent 50%),
    var(--bg-solid);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.hero-copy { position: relative; z-index: 1; max-width: 38rem; }
.hero-media {
  position: absolute;
  right: -18px;
  top: -18px;
  bottom: -18px;
  width: 46%;
  max-width: 520px;
  border-radius: 18px;
  overflow: hidden;
  z-index: 0;
  mask-image: linear-gradient(to left, rgba(0,0,0,0.85) 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to left, rgba(0,0,0,0.85) 60%, transparent 100%);
  pointer-events: none;
  border: 0.5px solid var(--line);
  box-shadow: var(--shadow);
}
.hero-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 760px) {
  .hero-media { display: none; }
}
.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hydro-deep);
}
@media (prefers-color-scheme: dark) {
  .eyebrow { color: var(--hydro); }
}
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 750;
  letter-spacing: -0.035em;
  line-height: 1.08;
}
.hero-sub {
  margin: 0 0 18px;
  color: var(--label-secondary);
  font-size: 15px;
  line-height: 1.4;
  max-width: 34em;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dashboard-media {
  position: relative;
  margin-top: 18px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 0.5px solid var(--line);
  box-shadow: var(--shadow);
  height: 220px;
}
.dashboard-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 760px) {
  .dashboard-media { height: 160px; }
}
.hero-orb {
  position: absolute;
  right: -30px;
  top: -40px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(125, 211, 252, 0.55), transparent 65%);
  filter: blur(2px);
  pointer-events: none;
  z-index: 0;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 8px 0 12px;
}
.section-title.tight { margin-bottom: 4px; }
.muted {
  color: var(--label-secondary);
  font-size: 13px;
  line-height: 1.35;
  margin: 0 0 14px;
}
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.row-between.wrap { flex-wrap: wrap; align-items: flex-start; }
.filter-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── Stats ─────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}
.stat {
  background: var(--bg-solid);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 12px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
  transition:
    transform var(--dur-press) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out);
}
.stat.is-pressed { transform: scale(0.98); }
@media (hover: hover) and (pointer: fine) {
  .stat:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
  }
}
.stat::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 2px;
  background: linear-gradient(90deg, var(--hydro), var(--blue));
  opacity: 0.55;
}
.stat span {
  display: block;
  color: var(--label-secondary);
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 4px;
}
.stat strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}
.stat.alert strong { color: var(--orange); }

.dash-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 16px;
  margin-bottom: 18px;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-solid);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 4px 16px 12px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-soft);
}
.card h3 {
  margin: 12px 0 4px;
  font-size: 12px;
  font-weight: 650;
  color: var(--label-secondary);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.card-list { display: flex; flex-direction: column; gap: 10px; }

.quote-card, .person-card, .job-card {
  background: var(--bg-solid);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition:
    transform var(--dur-press) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    opacity var(--dur-enter) var(--ease-out);
}
.quote-card:active, .quote-card.is-pressed,
.person-card:active, .person-card.is-pressed,
.job-card:active, .job-card.is-pressed {
  transform: scale(0.98);
  background: var(--fill-secondary);
}
@media (hover: hover) and (pointer: fine) {
  .quote-card:hover, .person-card:hover, .job-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
  }
  .quote-card:hover:active, .quote-card:hover.is-pressed,
  .person-card:hover:active, .person-card:hover.is-pressed,
  .job-card:hover:active, .job-card:hover.is-pressed {
    transform: scale(0.98);
  }
}
.quote-card .top, .person-card .top, .job-card .top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.quote-card .top strong, .person-card .top strong {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.addr {
  color: var(--label-secondary);
  font-size: 13px;
  margin-top: 3px;
}
.money {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.badge {
  font-size: 11px;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(0, 122, 255, 0.12);
  color: var(--blue);
  text-transform: capitalize;
  letter-spacing: -0.01em;
}
.badge.won { background: rgba(52, 199, 89, 0.15); color: var(--green); }
.badge.lost { background: rgba(255, 59, 48, 0.14); color: var(--red); }
.badge.sent { background: rgba(255, 149, 0, 0.16); color: var(--orange); }
.badge.draft { background: var(--fill); color: var(--label-secondary); }
.badge.tag {
  background: rgba(14, 165, 233, 0.12);
  color: var(--hydro-deep);
  font-weight: 600;
  text-transform: none;
}
@media (prefers-color-scheme: dark) {
  .badge.tag { color: var(--hydro); }
}

.tag-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  border: 0;
  border-radius: 12px;
  padding: 11px 16px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  background: var(--fill);
  color: var(--label);
  transition:
    transform var(--dur-press) var(--ease-out),
    opacity var(--dur-press) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    filter var(--dur-press) var(--ease-out);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.btn:active, .btn.is-pressed { transform: scale(0.97); }
.btn.primary {
  background: linear-gradient(180deg, #1a8cff 0%, var(--blue) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.28);
}
.btn.primary:active, .btn.primary.is-pressed {
  background: var(--blue-press);
  filter: brightness(0.97);
}
.btn.secondary {
  background: rgba(52, 199, 89, 0.14);
  color: var(--green);
}
.btn.ghost {
  background: transparent;
  border: 0.5px solid var(--line);
  color: var(--blue);
  font-weight: 500;
}
.btn.glass {
  background: rgba(255, 255, 255, 0.45);
  border: 0.5px solid var(--line);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--label);
}
@media (prefers-color-scheme: dark) {
  .btn.glass { background: rgba(255, 255, 255, 0.06); }
}
.btn.text {
  background: transparent;
  color: var(--blue);
  font-weight: 600;
  font-size: 14px;
  padding: 6px 8px;
}
.btn.danger { color: var(--red); background: rgba(255, 59, 48, 0.1); }
.btn.block { width: 100%; margin-top: 8px; }
.btn.flex { flex: 1; }
.btn-row { display: flex; gap: 8px; margin-top: 8px; }
.btn:disabled { opacity: 0.4; pointer-events: none; }

/* ── Forms ─────────────────────────────────────────────── */
label {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--label-secondary);
  margin: 0;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--line);
}
label:last-child { border-bottom: 0; }
label input,
label select,
label textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  outline: none;
  font-size: 17px;
  color: var(--label);
  letter-spacing: -0.02em;
}
label input::placeholder,
label textarea::placeholder { color: var(--label-tertiary); }
label select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238e8e93' d='M1.4 0L6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 2px center;
  padding-right: 18px;
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--label);
  font-size: 17px;
  padding: 12px 0;
  border-bottom: 0.5px solid var(--line);
  margin: 0;
}
.check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--blue);
}
.search-field {
  background: var(--bg-solid);
  border: 0.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
  min-width: 180px;
  box-shadow: var(--shadow-soft);
  outline: none;
}
.search-field:focus { box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.22); }
.block-search { width: 100%; margin-bottom: 14px; min-width: 0; }
.file-label {
  display: block;
  padding: 12px 0;
  color: var(--blue);
  font-weight: 500;
  cursor: pointer;
}
.file-label input { margin-top: 8px; font-size: 14px; }

.metric {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 0.5px solid var(--line);
  font-size: 15px;
}
.metric span { color: var(--label-secondary); }
.metric strong {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.metric.total strong {
  color: var(--green);
  font-size: 22px;
  font-weight: 700;
}
.poly-list {
  margin-top: 4px;
  font-size: 13px;
  color: var(--label-secondary);
}
.poly-list div {
  padding: 8px 0;
  border-bottom: 0.5px solid var(--line);
}
.photo-strip {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 8px 0 4px;
}
.photo-strip img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 10px;
  border: 0.5px solid var(--line);
}
.pb-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
  margin-bottom: 12px;
}
.form-stack label { margin-bottom: 0; }
hr {
  border: 0;
  border-top: 0.5px solid var(--line);
  margin: 16px 0;
}
.foot-note { margin-top: 18px; text-align: center; }
.price-card .metric.total { border-bottom: 0.5px solid var(--line); }
.sticky-actions {
  position: sticky;
  bottom: calc(var(--dock-h) + var(--safe-bottom) + 8px);
  background: linear-gradient(180deg, transparent, var(--bg-grouped) 28%);
  padding-top: 12px;
  z-index: 5;
}
@media (min-width: 900px) {
  .sticky-actions { bottom: 8px; }
}

/* ── Activity ──────────────────────────────────────────── */
.activity-feed {
  padding: 8px 14px 12px;
  max-height: 320px;
  overflow: auto;
}
.act-item {
  display: grid;
  grid-template-columns: 8px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 0.5px solid var(--line);
  font-size: 14px;
}
.act-item:last-child { border-bottom: 0; }
.act-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  background: var(--hydro);
}
.act-dot.won { background: var(--green); }
.act-dot.sent { background: var(--orange); }
.act-dot.draft { background: var(--label-tertiary); }
.act-dot.system, .act-dot.info { background: var(--blue); }
.act-text { font-weight: 500; letter-spacing: -0.01em; }
.act-time {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--label-secondary);
  font-weight: 400;
}

/* ── Kanban ────────────────────────────────────────────── */
.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(200px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}
.kan-col {
  background: var(--fill-secondary);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 10px;
  min-height: 280px;
  min-width: 210px;
}
.kan-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 2px 4px;
}
.kan-head strong {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.kan-head span {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--label-secondary);
  font-weight: 600;
}
.kan-col .quote-card {
  margin-bottom: 8px;
  padding: 12px;
}
.kan-col .quote-card .top strong { font-size: 15px; }
.kan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}
.kan-actions .btn {
  padding: 6px 8px;
  font-size: 12px;
  border-radius: 8px;
}

/* ── Measure ───────────────────────────────────────────── */
.measure-layout {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
  min-height: calc(100dvh - 160px);
}
.map-pane { display: flex; flex-direction: column; min-height: 420px; gap: 8px; }
.map-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.map-toolbar input[type="search"] {
  flex: 1;
  min-width: 140px;
  background: var(--bg-solid);
  border: 0.5px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 16px;
  box-shadow: var(--shadow-soft);
}
.map-toolbar input[type="search"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.25);
}
.toolbar-select {
  background: var(--bg-solid);
  border: 0.5px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  max-width: 170px;
  font-size: 13px;
  font-weight: 500;
  color: var(--label);
  box-shadow: var(--shadow-soft);
}
#mapWrap {
  position: relative;
  flex: 1;
  min-height: 380px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 0.5px solid var(--line);
  box-shadow: var(--shadow);
  isolation: isolate;
  z-index: 0;
}
#mapWrap #map {
  position: absolute;
  inset: 0;
  min-height: 0;
  height: 100%;
  border-radius: 0;
  background: #1a2433;
}
.map-hint {
  color: var(--label-secondary);
  font-size: 12px;
  line-height: 1.4;
  margin: 0;
}
.side-pane {
  overflow: auto;
  max-height: calc(100dvh - 150px);
  padding-bottom: 8px;
}
.map-meta {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 20; /* stay inside map stack; never above app modals */
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}
.map-meta span {
  background: rgba(255, 255, 255, 0.9);
  color: #1c1c1e;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 8px;
  border-radius: 8px;
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}
@media (prefers-color-scheme: dark) {
  .map-meta span {
    background: rgba(18, 26, 40, 0.9);
    color: #f5f5f7;
    border-color: rgba(255, 255, 255, 0.08);
  }
}
.conf.high, .conf.good { color: var(--green) !important; }
.conf.fair { color: var(--orange) !important; }
.conf.low, .conf.poor { color: var(--red) !important; }

.crosshair { position: absolute; inset: 0; z-index: 15; pointer-events: none; }
.crosshair.hidden { display: none; }
.crosshair .ch-h, .crosshair .ch-v {
  position: absolute;
  background: rgba(14, 165, 233, 0.8);
}
.crosshair .ch-h { left: 0; right: 0; top: 50%; height: 1px; }
.crosshair .ch-v { top: 0; bottom: 0; left: 50%; width: 1px; }
.crosshair .ch-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border: 2px solid var(--hydro);
  border-radius: 50%;
  background: rgba(14, 165, 233, 0.18);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.leaflet-editing-icon.dq-vertex, .dq-vertex {
  width: 12px !important;
  height: 12px !important;
  margin-left: -6px !important;
  margin-top: -6px !important;
  border: 2px solid #0ea5e9 !important;
  background: #fff !important;
  border-radius: 50% !important;
}
.leaflet-bar {
  border: 0.5px solid var(--line) !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: var(--shadow) !important;
}
.leaflet-bar a {
  background: var(--bg-solid) !important;
  color: var(--label) !important;
  border-bottom: 0.5px solid var(--line) !important;
  width: 36px !important;
  height: 36px !important;
  line-height: 36px !important;
}
.leaflet-draw-toolbar a { background-color: var(--bg-solid) !important; }

.draw-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.draw-bar.hidden { display: none !important; }
.draw-bar .draw-main {
  flex: 1 1 180px;
  min-height: 48px;
  font-size: 17px;
  border-radius: 14px;
}
.draw-bar .btn.detecting {
  opacity: 0.72;
  pointer-events: none;
}
.draw-bar.tracing {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-solid);
  border: 0.5px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
}
.trace-status {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.trace-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.trace-actions .btn { flex: 1; min-height: 44px; }

.trace-coach {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 18;
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border-radius: 14px;
  padding: 12px 14px;
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  pointer-events: none;
}
.trace-coach.hidden { display: none; }
.trace-coach strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
  color: #1c1c1e;
}
.trace-coach span {
  font-size: 13px;
  color: rgba(60, 60, 67, 0.7);
  line-height: 1.35;
}
@media (prefers-color-scheme: dark) {
  .trace-coach {
    background: rgba(18, 26, 40, 0.92);
    border-color: rgba(255, 255, 255, 0.08);
  }
  .trace-coach strong { color: #f5f5f7; }
  .trace-coach span { color: rgba(235, 235, 245, 0.6); }
}
.leaflet-tooltip.trace-num {
  background: #0ea5e9;
  color: #fff;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 6px;
  box-shadow: 0 2px 6px rgba(14, 165, 233, 0.4);
}
.leaflet-tooltip.trace-num::before { display: none; }
.easy-draw-map .leaflet-draw-toolbar { opacity: 0.28; }
.easy-draw-map .leaflet-draw-toolbar:hover { opacity: 1; }

.drop-corner-fab {
  position: absolute;
  left: 50%;
  bottom: 56px;
  transform: translateX(-50%);
  z-index: 19;
  min-width: 160px;
  min-height: 48px;
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(14, 165, 233, 0.4);
}
.drop-corner-fab.hidden { display: none !important; }

/* ── Modal / proposal ────────────────────────────────────
   Leaflet panes/controls sit ~400–1000+. Keep sheets above the map. */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  isolation: isolate;
}
.modal.hidden { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(0, 0, 0, 0.4);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
}
.modal-sheet {
  position: relative;
  z-index: 1;
  width: min(740px, 100%);
  max-height: 92dvh;
  overflow: auto;
  background: var(--bg-grouped);
  color: var(--label);
  border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(20px + var(--safe-bottom));
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.22);
  will-change: transform;
  transform: translate3d(0, 100%, 0);
  /* Open/close driven by DriveFluid springs (drawer feel); no CSS fight */
  transition: none;
}
/* Confine Leaflet stacking so it never punches through the app chrome/modals */
#mapWrap,
#map,
#map .leaflet-container,
#map .leaflet-pane,
#map .leaflet-top,
#map .leaflet-bottom,
#map .leaflet-control {
  z-index: auto;
}
#map .leaflet-container {
  z-index: 0;
}
#map .leaflet-map-pane { z-index: 1; }
#map .leaflet-tile-pane { z-index: 2; }
#map .leaflet-overlay-pane { z-index: 3; }
#map .leaflet-shadow-pane { z-index: 4; }
#map .leaflet-marker-pane { z-index: 5; }
#map .leaflet-tooltip-pane { z-index: 6; }
#map .leaflet-popup-pane { z-index: 7; }
#map .leaflet-control { z-index: 8; }
body.modal-open {
  overflow: hidden;
}
body.modal-open #mapWrap,
body.modal-open .leaflet-container {
  pointer-events: none;
}
.sheet-form { margin-top: 4px; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  background: var(--bg-grouped);
  padding: 8px 0;
  z-index: 2;
}
.sheet-grab {
  display: flex;
  justify-content: center;
  padding: 8px 0 4px;
  cursor: grab;
  touch-action: none;
}
.sheet-grab:active { cursor: grabbing; }
.sheet-grab-pill {
  width: 36px;
  height: 5px;
  border-radius: 999px;
  background: rgba(60, 60, 67, 0.28);
}
@media (prefers-color-scheme: dark) {
  .sheet-grab-pill { background: rgba(235, 235, 245, 0.28); }
}

.proposal {
  background: #fff;
  color: #0f172a;
  border: 0.5px solid rgba(0, 0, 0, 0.06);
  border-radius: 18px;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.proposal-hero {
  padding: 28px 28px 22px;
  background:
    radial-gradient(90% 120% at 100% 0%, rgba(14, 165, 233, 0.2), transparent 55%),
    linear-gradient(180deg, #f8fafc 0%, #fff 100%);
  border-bottom: 0.5px solid rgba(15, 23, 42, 0.08);
}
.proposal-hero h1 {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.035em;
  color: #0b1220;
}
.proposal-body { padding: 22px 28px 28px; }
.proposal .sub {
  color: rgba(60, 60, 67, 0.62);
  margin-bottom: 0;
  font-size: 13px;
}
.proposal table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 15px;
}
.proposal th, .proposal td {
  text-align: left;
  padding: 11px 6px;
  border-bottom: 0.5px solid rgba(60, 60, 67, 0.12);
}
.proposal .total-row td {
  font-weight: 750;
  font-size: 18px;
  border-bottom: 0;
  padding-top: 14px;
}
.proposal-total-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(14, 165, 233, 0.1);
  color: #0369a1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.proposal-total-chip span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.8;
}
.proposal-total-chip strong { font-size: 22px; letter-spacing: -0.03em; }
.proposal-brand-mark {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 64px;
  height: 64px;
  border-radius: 14px;
  overflow: hidden;
  border: 0.5px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 3px rgba(8, 28, 48, 0.08);
  background: #fff;
}
.proposal-brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.proposal-hero { position: relative; }

/* ── Dock ──────────────────────────────────────────────── */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 6px 8px calc(6px + var(--safe-bottom));
  background: var(--bg-elevated);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border-top: 0.5px solid var(--line);
}
.dock-item {
  border: 0;
  background: transparent;
  color: var(--label-secondary);
  font-size: 10px;
  font-weight: 600;
  padding: 6px 4px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition:
    transform var(--dur-press) var(--ease-out),
    opacity var(--dur-fast) var(--ease-out),
    background var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out);
}
.dock-item .di { font-size: 16px; line-height: 1.1; }
.dock-item.is-pressed { transform: scale(0.94); }
.dock-item.active { color: var(--blue); background: rgba(0, 122, 255, 0.1); }
.dock-item.dock-main {
  color: #fff;
  background: linear-gradient(180deg, #1a8cff, var(--blue));
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.3);
  margin-top: -10px;
  padding-top: 10px;
  padding-bottom: 8px;
}
.dock-item.dock-main.active { color: #fff; }
.dock-item.dock-main.is-pressed { transform: scale(0.96); }

/* ── Toast ─────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--dock-h) + var(--safe-bottom) + 18px);
  transform: translateX(-50%) translateY(10px);
  z-index: 21000;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 220ms var(--ease-out),
    transform 220ms var(--ease-out);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  transition:
    opacity 220ms var(--ease-out),
    transform 220ms var(--ease-out);
}
.toast:not(.show) {
  transition:
    opacity 160ms var(--ease-out),
    transform 160ms var(--ease-out);
}
.toast.hidden { display: block; }
@media (min-width: 900px) {
  .toast { bottom: 28px; }
}
@media (prefers-color-scheme: light) {
  .toast { background: rgba(15, 23, 42, 0.94); }
}

/* ── Empty ─────────────────────────────────────────────── */
.empty {
  padding: 28px 18px;
  text-align: center;
  color: var(--label-secondary);
  font-size: 14px;
  border: 0.5px dashed var(--line);
  border-radius: var(--radius-lg);
  background: var(--fill-secondary);
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 900px) {
  .measure-layout { grid-template-columns: 1fr; }
  .side-pane { max-height: none; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dash-grid { grid-template-columns: 1fr; }
  .pb-grid { grid-template-columns: 1fr; }
  #mapWrap { height: 48vh; min-height: 300px; }
  main { padding: 16px 12px 20px; }
  .kanban { grid-template-columns: repeat(4, minmax(200px, 1fr)); }
}
@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat strong { font-size: 20px; }
  .tabs .tab[data-view="pricebook"],
  .tabs .tab[data-view="settings"] { /* still reachable on desktop tabs; mobile uses settings via home rarely */
  }
}

@media print {
  body * { visibility: hidden; }
  #proposalModal, #proposalModal * { visibility: visible; }
  #proposalModal { position: static; }
  .modal-backdrop, .modal-actions, .sheet-grab, .dock, .toast { display: none !important; }
  .modal-sheet {
    max-height: none;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    background: #fff;
    transform: none !important;
  }
  .proposal { box-shadow: none; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .view.active { animation: none !important; }
  .btn, .tab, .quote-card, .person-card, .job-card, .stat,
  .dock-item, .icon-btn, .modal-sheet, .toast {
    transition: none !important;
  }
  .motion-enter,
  .motion-enter.is-in,
  .hydro-hero.motion-enter,
  .hydro-hero.motion-enter.is-in {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
    transition: none !important;
    transition-delay: 0ms !important;
  }
  .btn.is-pressed, .btn:active,
  .tab.is-pressed,
  .quote-card.is-pressed, .quote-card:active,
  .person-card.is-pressed, .person-card:active,
  .job-card.is-pressed, .job-card:active,
  .stat.is-pressed,
  .dock-item.is-pressed,
  .icon-btn.is-pressed, .icon-btn:active {
    transform: none !important;
    opacity: 0.75;
  }
  @media (hover: hover) and (pointer: fine) {
    .quote-card:hover, .person-card:hover, .job-card:hover, .stat:hover {
      transform: none !important;
      box-shadow: var(--shadow-soft);
    }
  }
}
