/* ──────────────────────────────────────────────────────────────────────────
   Harvest CRM — semantic palette
   Light = cream + matte black accents
   Dark  = matte black + cream accents
   ────────────────────────────────────────────────────────────────────────── */

:root {
  /* Light theme: cream paper with matte black ink */
  --bg:        245 241 232;   /* cream #f5f1e8 */
  --surface:   252 250 246;   /* near-white #fcfaf6 */
  --surface-2: 238 233 222;   /* darker cream #eee9de */
  --fg:         18  18  18;   /* matte black */
  --muted:    115 110 100;
  --line:     220 213 198;
  --accent:    18  18  18;   /* matte black accent in light mode */
  --accent-fg: 245 241 232;  /* cream */
  --hover:    232 226 213;
  --warn:     180  85  25;
  /* Blue feature accent — punchy, unmissable. Used everywhere a number,
     CTA, or status should pop: progress bars, buttons, brand mark, metric
     values, active nav, focus rings, status chips. */
  --blue:        37 99 235;    /* #2563eb — Tailwind blue-600, deeper for contrast on cream */
  --blue-fg:    255 255 255;
  --blue-soft:  219 234 254;
  --blue-light:  96 165 250;   /* #60a5fa for soft accents */
}

.dark {
  /* Dark theme: matte black with cream highlights */
  --bg:         13  13  13;   /* deep matte #0d0d0d */
  --surface:    20  20  20;
  --surface-2:  28  28  28;
  --fg:        237 230 213;   /* cream #ede6d5 */
  --muted:    138 132 118;
  --line:      45  43  37;
  --accent:   237 230 213;   /* cream accent in dark mode */
  --accent-fg: 13  13  13;
  --hover:     30  30  30;
  --warn:     220 140  60;
  /* Blue in dark mode — bright and saturated against matte black */
  --blue:        59 130 246;   /* #3b82f6 — Tailwind blue-500 stays vivid on dark */
  --blue-fg:    255 255 255;
  --blue-soft:   30  58  138;
  --blue-light: 147 197 253;
}

html { background: rgb(var(--bg)); }
body { background-color: rgb(var(--bg)); }   /* color separately from grid background-image */

/* Blueprint grid — gradient style with MAJOR + MINOR lines.
   Major lines (heavier) every 4 cells, minor (lighter) every cell.
   Uses rgb(R G B / alpha) — the modern CSS syntax that actually
   works with space-separated CSS variable values. */
body {
  background-image:
    /* Major lines — visible-but-quiet */
    linear-gradient(to right,  rgb(var(--fg) / 0.16) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(var(--fg) / 0.16) 1px, transparent 1px),
    /* Minor lines — barely-there texture */
    linear-gradient(to right,  rgb(var(--fg) / 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(var(--fg) / 0.06) 1px, transparent 1px);
  background-size:
    192px 192px,
    192px 192px,
    48px 48px,
    48px 48px;
  background-position: 0 0;
}

.dark body {
  background-image:
    linear-gradient(to right,  rgb(var(--fg) / 0.13) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(var(--fg) / 0.13) 1px, transparent 1px),
    linear-gradient(to right,  rgb(var(--fg) / 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(var(--fg) / 0.05) 1px, transparent 1px);
  background-size: 192px 192px, 192px 192px, 48px 48px, 48px 48px;
}

/* Typography */
body {
  font-feature-settings: "ss01", "cv11";
  letter-spacing: -0.005em;
}

/* ──────────────────────────────────────────────────────────────────────────
   Animation system — spring easing throughout, subtle but felt.
   Same easing curve as the goal bar (cubic-bezier(0.34, 1.56, 0.64, 1))
   gives that gentle overshoot at the end of the motion.
   ────────────────────────────────────────────────────────────────────────── */

:root {
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-glide: cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes rise-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(-28px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slide-in-left {
  from { opacity: 0; transform: translateX(28px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}

/* Auto-animate every panel on page entry — the main visual building block */
.panel {
  animation: rise-in 520ms var(--ease-spring) both;
}

/* Hero metric tiles get a gentle scale-in with a stagger by position */
.metric {
  animation: scale-in 540ms var(--ease-spring) both;
}
.grid > .metric:nth-child(1) { animation-delay: 0ms; }
.grid > .metric:nth-child(2) { animation-delay: 70ms; }
.grid > .metric:nth-child(3) { animation-delay: 140ms; }
.grid > .metric:nth-child(4) { animation-delay: 210ms; }

/* Kanban columns slide in from the right, staggered left → right */
.kanban-col { animation: slide-in-left 600ms var(--ease-spring) both; }
.kanban-col:nth-child(1) { animation-delay: 0ms; }
.kanban-col:nth-child(2) { animation-delay: 50ms; }
.kanban-col:nth-child(3) { animation-delay: 100ms; }
.kanban-col:nth-child(4) { animation-delay: 150ms; }
.kanban-col:nth-child(5) { animation-delay: 200ms; }
.kanban-col:nth-child(6) { animation-delay: 250ms; }
.kanban-col:nth-child(7) { animation-delay: 300ms; }
.kanban-col:nth-child(8) { animation-delay: 350ms; }

/* Cards inside columns get a soft fade-in (no transform so they don't fight column slide) */
.deal-card { animation: fade-in 600ms var(--ease-glide) both; }

/* Page headings + section h1/h2 — subtle fade so they don't feel jarring */
h1, h2 { animation: fade-in 400ms var(--ease-glide) both; }

/* Task rows + inbox items rise gently */
.task-row, .ev-row { animation: rise-in 480ms var(--ease-spring) both; }

/* Stage selector buttons slide in from left, staggered */
.stage-btn { animation: slide-in-right 500ms var(--ease-spring) both; }
.stage-btn:nth-of-type(1) { animation-delay: 0ms; }
.stage-btn:nth-of-type(2) { animation-delay: 50ms; }
.stage-btn:nth-of-type(3) { animation-delay: 100ms; }
.stage-btn:nth-of-type(4) { animation-delay: 150ms; }
.stage-btn:nth-of-type(5) { animation-delay: 200ms; }
.stage-btn:nth-of-type(6) { animation-delay: 250ms; }
.stage-btn:nth-of-type(7) { animation-delay: 300ms; }

/* Hover transitions on interactive elements — keep snappy (~120ms) */
.btn-primary, .btn-secondary, .chip, .deal-card, .task-row, .stage-btn, .ev-row {
  transition: transform 160ms var(--ease-glide),
              border-color 160ms var(--ease-glide),
              background-color 160ms var(--ease-glide),
              filter 160ms var(--ease-glide),
              box-shadow 160ms var(--ease-glide);
}
.btn-primary:hover, .btn-secondary:hover { transform: translateY(-1px); }
.chip:hover { transform: translateY(-1px); }

/* Respect prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
h1, h2, h3 { letter-spacing: -0.02em; }
.tabular-nums { font-variant-numeric: tabular-nums; }
.uppercase-spread { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.7rem; }
/* Add `.text-blue` to any element you want stamped blue */
.text-blue { color: rgb(var(--blue)) !important; }

/* Bold blue accent under main page titles — wider + thicker so it's obvious */
main h1.text-3xl::after {
  content: '';
  display: block;
  width: 80px;
  height: 4px;
  background: rgb(var(--blue));
  border-radius: 2px;
  margin-top: 12px;
  box-shadow: 0 2px 6px rgba(var(--blue), 0.35);
}
/* Top nav links: blue on hover */
nav a:hover { color: rgb(var(--blue)) !important; }
/* Mobile bottom tab inactive icons hint blue on press */
.mobile-tab:active { color: rgb(var(--blue)); }

/* ── Kanban ── */
.kanban-col {
  min-width: 280px;
  max-width: 320px;
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--line));
  display: flex;
  flex-direction: column;
}
.kanban-col-header {
  padding: 14px 16px;
  border-bottom: 1px solid rgb(var(--line));
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Commission thought bubble (per pipeline column) ─────────────────────
   Floats above each column header. Pure CSS cloud + two dots that trail
   down to the column. Gently bobs + glows. Animation phase staggered per
   column via inline animation-delay so they don't all move in lockstep. */
.commission-bubble {
  position: absolute;
  top: -64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  width: 200px;
  pointer-events: none;
  animation: commission-bubble-bob 3.2s ease-in-out infinite alternate;
}
.commission-bubble-cloud {
  position: relative;
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--blue));
  border-radius: 18px;
  padding: 6px 10px 7px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(var(--blue), 0.18),
              inset 0 0 0 1px rgba(var(--blue), 0.06);
  animation: commission-bubble-glow 2.8s ease-in-out infinite alternate;
}
.commission-bubble-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgb(var(--muted));
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.commission-bubble-value {
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: rgb(var(--blue));
  line-height: 1.2;
  margin-top: 1px;
}
/* The two trailing thought-dots leading down from the cloud.
   Filled SOLID blue with a strong outer glow so they pop against the
   page background (not just rely on outline contrast). */
.commission-bubble-dot {
  position: absolute;
  left: 50%;
  border-radius: 50%;
  background: rgb(var(--blue));
  border: 2px solid rgb(var(--surface));
  box-shadow:
    0 0 0 1px rgb(var(--blue)),               /* outer ring */
    0 0 12px rgba(var(--blue), 0.55),          /* halo glow */
    0 2px 6px rgba(0,0,0,0.20);                /* drop shadow */
}
.commission-bubble-dot-1 {
  width: 14px; height: 14px;
  bottom: -12px;
  transform: translateX(-50%);
}
.commission-bubble-dot-2 {
  width: 9px; height: 9px;
  bottom: -28px;
  transform: translateX(-50%);
}
@keyframes commission-bubble-bob {
  from { transform: translateX(-50%) translateY(0); }
  to   { transform: translateX(-50%) translateY(-6px); }
}
@keyframes commission-bubble-glow {
  from { box-shadow: 0 2px 8px  rgba(var(--blue), 0.12),
                     inset 0 0 0 1px rgba(var(--blue), 0.04); }
  to   { box-shadow: 0 4px 18px rgba(var(--blue), 0.32),
                     inset 0 0 0 1px rgba(var(--blue), 0.10); }
}

/* On mobile, shrink the bubbles so they don't push the cards too far down */
@media (max-width: 768px) {
  .commission-bubble { top: -56px; width: 150px; }
  .commission-bubble-label { font-size: 0.5rem; }
  .commission-bubble-value { font-size: 0.75rem; }
}
.deal-card {
  background: rgb(var(--bg));
  border: 1px solid rgb(var(--line));
  padding: 12px;
  cursor: grab;
  transition: border-color 120ms ease, transform 120ms ease;
}
.deal-card:hover {
  border-color: rgb(var(--fg));
  transform: translateX(2px);
}
.deal-card:active { cursor: grabbing; }
.deal-card.dragging { opacity: 0.35; }
.kanban-col.drop-target {
  background: rgba(var(--blue), 0.08);
  border-color: rgb(var(--blue));
  box-shadow: 0 0 0 2px rgba(var(--blue), 0.3);
}

/* ── Inline editing ── */
.cell-edit {
  background: transparent;
  border: 1px solid transparent;
  padding: 5px 7px;
  width: 100%;
  color: inherit;
  font: inherit;
  border-radius: 0;
}
.cell-edit:hover {
  background: rgb(var(--hover));
  border-color: rgb(var(--line));
}
.cell-edit:focus {
  outline: none;
  background: rgb(var(--surface));
  border-color: rgb(var(--accent));
}

/* ── Tags / chips ── */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid rgb(var(--line));
  background: rgb(var(--surface-2));
  color: rgb(var(--fg));
}
/* Blue chip variant — use for emphasis (deal matches on emails, active stage) */
.chip-blue {
  border-color: rgb(var(--blue));
  background: rgba(var(--blue), 0.12);
  color: rgb(var(--blue));
}

/* ── Pipeline card commission box ── */
/* Prominent inline number editor on each deal card. Different border colors
   distinguish "auto" (matrix-computed) from "manual" (user-overridden) values. */
.card-commission-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid rgb(var(--blue));
  background: rgba(var(--blue), 0.08);
  transition: border-color 150ms ease, background 150ms ease;
}
.card-commission-wrap:focus-within {
  background: rgba(var(--blue), 0.14);
}
/* legacy aliases retained for safety — both classes resolve to the same box */
.card-commission-manual, .card-commission-matrix { /* no extra styles */ }
.card-commission-prefix {
  font-size: 0.7rem;
  color: rgb(var(--muted));
  font-weight: 500;
}
.card-commission {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: rgb(var(--fg));
  padding: 0;
  outline: none;
}
.card-commission::placeholder { color: rgb(var(--muted)); font-weight: 400; }

/* ── Tables ── */
table.data-table { width: 100%; font-size: 0.875rem; }
table.data-table thead { background: rgb(var(--surface-2)); }
table.data-table th {
  text-align: left;
  padding: 10px 16px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.7rem;
  font-weight: 500;
  color: rgb(var(--muted));
}
table.data-table td {
  padding: 10px 16px;
  border-top: 1px solid rgb(var(--line));
}
table.data-table tbody tr:hover { background: rgb(var(--hover)); }

/* ── Buttons ── */
.btn-primary {
  background: rgb(var(--blue));
  color: rgb(var(--blue-fg));
  border: 1px solid rgb(var(--blue));
  padding: 8px 16px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 500;
  transition: filter 120ms, transform 120ms;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: rgb(var(--fg));
  border: 1px solid rgb(var(--line));
  padding: 8px 16px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: border-color 120ms;
}
.btn-secondary:hover { border-color: rgb(var(--fg)); }

/* ── Inputs ── */
input[type="text"], input[type="number"], input[type="date"], input[type="email"],
input[type="tel"], input[type="search"], input[type="password"], select, textarea {
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--line));
  color: rgb(var(--fg));
  padding: 7px 10px;
  font-size: 0.875rem;
  border-radius: 0;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgb(var(--blue));
  box-shadow: 0 0 0 2px rgba(var(--blue), 0.18);
}

/* Card / panel surface */
.panel {
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--line));
  padding: 24px;
  position: relative;
}

/* Email-style composer for Notes & Recent Updates — focused state gets a
   blue ring to mirror Gmail/Outlook compose UX. */
.composer-focused {
  border-color: rgb(var(--blue)) !important;
  box-shadow: 0 0 0 3px rgba(var(--blue), 0.10);
  transition: box-shadow 150ms ease, border-color 150ms ease;
}

/* Top accent stripe on every panel — subtle but always visible */
.panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, rgb(var(--blue)) 0%, transparent 50%);
  pointer-events: none;
}

/* Subtle scanline texture for futurism (very subtle, only dark) */
.dark body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,0.012) 1px, transparent 1px);
  background-size: 100% 3px;
  z-index: 1;
  opacity: 0.6;
}

/* ──────────────────────────────────────────────────────────────────────────
   ONYX theme — matte black with a smooth gradient to grey. NO gridlines.
   Applied as a VARIANT of dark: <html class="dark onyx">, so every Tailwind
   `dark:` utility and `.dark` rule still resolves, while these later-in-source
   rules override the palette + the blueprint-grid background. Same specificity
   as `.dark` (one class) → source order wins, so onyx must stay BELOW dark.
   ────────────────────────────────────────────────────────────────────────── */
.onyx {
  --bg:         13  13  15;   /* matte black base #0d0d0f */
  --surface:    23  23  27;   /* floating panel */
  --surface-2:  32  32  37;
  --fg:        228 228 233;   /* cool near-white */
  --muted:    140 140 150;
  --line:      42  42  49;
  --accent:   228 228 233;
  --accent-fg: 13  13  15;
  --hover:     34  34  40;
  --warn:     220 140  60;
  --blue:        59 130 246;
  --blue-fg:    255 255 255;
  --blue-soft:   30  58  138;
  --blue-light: 147 197 253;
}

/* Smooth matte-black → grey gradient, fixed to the viewport, NO grid lines. */
.onyx body {
  background-image: none;
  background-color: #1a1a1e;
  background: linear-gradient(165deg, #1a1a1e 0%, #2e2e35 48%, #4a4a55 100%)
              fixed no-repeat;
  background-size: cover;
}
/* Onyx is intentionally smooth — kill the dark scanline + any grid texture. */
.onyx body::before { display: none !important; }


/* Number tile */
.metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.65rem;
  color: rgb(var(--muted));
}
.metric-value {
  font-size: 2rem;
  font-weight: 300;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
/* Blue-themed metric: opt-in for hero numbers */
.metric-blue .metric-value { color: rgb(var(--blue)); }
.metric-sub {
  font-size: 0.7rem;
  color: rgb(var(--muted));
}

/* Calendar event checkbox — minimal, theme-aware */
.ev-check {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1px solid rgb(var(--line));
  background: transparent;
  cursor: pointer;
  display: inline-block;
  position: relative;
  flex-shrink: 0;
  margin-top: 4px;
  transition: border-color 120ms;
}
.ev-check:hover { border-color: rgb(var(--fg)); }
.ev-check:checked {
  background: rgb(var(--fg));
  border-color: rgb(var(--fg));
}
.ev-check:checked::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgb(var(--bg));
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.ev-struck { text-decoration: line-through; opacity: 0.55; }
.ev-row:hover .ev-check { border-color: rgb(var(--fg)); }

/* Line clamps for previews */
.line-clamp-4 { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.line-clamp-8 { display: -webkit-box; -webkit-line-clamp: 8; -webkit-box-orient: vertical; overflow: hidden; max-height: 16rem; }

/* Progress bar */
.progress-bar { height: 4px; background: rgb(var(--surface-2)); }
.progress-bar > span { display: block; height: 100%; background: rgb(var(--fg)); }

/* ──────────────────────────────────────────────────────────────────────────
   Mobile bottom tab bar (hidden on desktop, shown ≤768px via media query below)
   ────────────────────────────────────────────────────────────────────────── */
.mobile-tabbar { display: none; }

@media (max-width: 768px) {
  .mobile-tabbar {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgb(var(--bg));
    border-top: 1px solid rgb(var(--line));
    z-index: 50;
    /* Safe-area inset for iPhones with home indicator */
    padding-bottom: env(safe-area-inset-bottom, 0);
    backdrop-filter: blur(12px);
    background: rgba(var(--bg), 0.95);
  }
  .mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 4px 8px;
    color: rgb(var(--muted));
    text-decoration: none;
    transition: color 120ms;
    position: relative;
  }
  .mobile-tab:active { background: rgb(var(--hover)); }
  .mobile-tab-active { color: rgb(var(--blue)); }
  .mobile-tab-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 30%;
    right: 30%;
    height: 2px;
    background: rgb(var(--blue));
  }
}

/* ──────────────────────────────────────────────────────────────────────────
   Mobile / phone responsive layer
   Triggers at ≤768px (typical phones in portrait, narrow split-screen iPad)
   ────────────────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Top nav: stays visible on mobile but scrolls horizontally so all 10 tabs
     (including Settings, Marketing, Referrals, LOI Gen) are still reachable
     via swipe. The bottom tab bar covers the 6 highest-frequency destinations. */
  nav > .max-w-screen-2xl {
    padding-left: 12px;
    padding-right: 12px;
    height: 48px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;            /* Firefox */
    gap: 0;
  }
  nav > .max-w-screen-2xl::-webkit-scrollbar { display: none; }  /* Safari/Chrome */
  /* Tighten tab padding so more fit per scroll window */
  nav > .max-w-screen-2xl > a:not(:first-child):not(:last-of-type) {
    padding-left: 10px;
    padding-right: 10px;
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.78rem;
  }
  /* Brand logo: don't shrink */
  nav > .max-w-screen-2xl > a:first-child { flex-shrink: 0; margin-right: 12px; }
  /* Hide the spacer + "New Deal" + theme toggle on mobile (FAB + chatbot cover those) */
  nav .flex-1, nav > .max-w-screen-2xl > a:last-of-type,
  nav > .max-w-screen-2xl > button { display: none; }

  /* Body baseline font scaled down so the page doesn't feel zoomed in */
  body { font-size: 14px; }

  /* Main container: tighter padding on phones, bottom padding for tab bar */
  main.max-w-screen-2xl {
    padding: 12px 12px;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0));
  }
  .panel { padding: 14px; }
  .panel + .panel,
  .panel + section,
  section + .panel,
  section + section { margin-top: 12px; }

  /* Stack ANY tailwind grid-cols-* / col-span-* — phone gets one column */
  .grid.grid-cols-2,
  .grid.grid-cols-3,
  .grid.grid-cols-4,
  .grid.grid-cols-5,
  .grid.grid-cols-6,
  .grid.grid-cols-7,
  .grid.grid-cols-12 {
    grid-template-columns: 1fr !important;
  }
  .col-span-1, .col-span-2, .col-span-3, .col-span-4, .col-span-5,
  .col-span-6, .col-span-7, .col-span-8, .col-span-9, .col-span-10,
  .col-span-11, .col-span-12 {
    grid-column: span 1 / span 1 !important;
  }

  /* Kanban: ONE column per phone screen, swipe horizontally between them.
     CSS scroll-snap makes the swipe feel native. */
  #board {
    gap: 12px;
    scroll-snap-type: x mandatory;
    scroll-padding: 14px;
    padding-bottom: 8px;
  }
  .kanban-col {
    min-width: 88vw;
    max-width: 88vw;
    scroll-snap-align: start;
    max-height: calc(100vh - 220px);
  }
  /* Cards inside the kanban: bigger touch target */
  .deal-card { padding: 14px; }
  .deal-card .text-sm { font-size: 0.95rem; }

  /* Scaled-down typography for phones */
  .metric-value { font-size: 1.4rem; }
  .metric-label { font-size: 0.6rem; }
  .metric-sub { font-size: 0.65rem; }
  h1.text-3xl { font-size: 1.4rem !important; line-height: 1.2; }
  h1 { font-size: 1.4rem !important; }
  h2.text-xl { font-size: 1rem !important; }
  h2 { font-size: 1rem !important; }
  h3 { font-size: 0.9rem !important; }
  .text-sm { font-size: 0.8rem; }
  .text-xs { font-size: 0.7rem; }

  /* Page title accent — smaller on phone */
  main h1.text-3xl::after { width: 50px; height: 3px; margin-top: 6px; }

  /* Tighter top nav on mobile */
  nav > .max-w-screen-2xl > a:first-child { font-size: 0.95rem; }

  /* Tables → card list. Each row stacks its cells vertically with the column
     header showing as a label above each value. Way more readable than
     horizontal scroll on a phone. */
  .data-table { display: block; width: 100%; }
  .data-table thead { display: none; }
  .data-table tbody, .data-table tr { display: block; width: 100%; }
  .data-table tr {
    padding: 12px 14px;
    border-top: 1px solid rgb(var(--line));
    background: rgb(var(--surface));
  }
  .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-top: none;
    text-align: right;
    gap: 12px;
  }
  .data-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.65rem;
    color: rgb(var(--muted));
    font-weight: 500;
  }
  /* First cell of each row is the "title" — show on its own line, full width */
  .data-table td:first-child {
    display: block;
    text-align: left;
    font-size: 1rem;
    font-weight: 500;
    padding-bottom: 6px;
    border-bottom: 1px solid rgb(var(--line));
    margin-bottom: 4px;
  }
  .data-table td:first-child::before { display: none; }

  /* Floating action button — "+ New Deal" on phone */
  .fab-new-deal {
    position: fixed;
    bottom: calc(72px + env(safe-area-inset-bottom, 0) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgb(var(--blue));
    color: rgb(var(--blue-fg));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 300;
    line-height: 1;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    z-index: 40;
    text-decoration: none;
    transition: transform 120ms;
  }
  .fab-new-deal:active { transform: scale(0.94); }

  /* Forms — full width inputs, larger touch targets */
  input[type="text"], input[type="number"], input[type="date"],
  input[type="email"], input[type="tel"], select, textarea {
    padding: 10px 12px;
    min-height: 44px;
  }
  .btn-primary, .btn-secondary { padding: 12px 18px; min-height: 44px; }

  /* Deal detail: ensure right sidebar (contacts / tasks / meetings / docs)
     appears AFTER main content, not before — the grid stack defaults to source
     order which is correct, but make sure spacing is generous */
  .panel { margin-bottom: 12px; }

  /* Calendar / inbox max-heights too big for phone — reduce */
  .max-h-\[480px\], .max-h-\[560px\], .max-h-\[640px\] {
    max-height: 400px !important;
  }
}
.fab-new-deal { display: none; }
@media (max-width: 768px) { .fab-new-deal { display: flex; } }

/* ──────────────────────────────────────────────────────────────────────────
   Cam's OS Chatbot — floating widget, available on every page
   ────────────────────────────────────────────────────────────────────────── */
.cam-chat-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 80;
}
.cam-chat-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgb(var(--blue));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(var(--blue), 0.4);
  transition: transform 160ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cam-chat-fab:hover { transform: scale(1.06); }
.cam-chat-fab:active { transform: scale(0.96); }
.cam-chat-fab-open { background: rgb(var(--fg)); }

.cam-chat-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--line));
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.18), 0 0 0 4px rgba(var(--blue), 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: chat-rise 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes chat-rise {
  from { opacity: 0; transform: translateY(20px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.cam-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid rgb(var(--line));
  background: linear-gradient(180deg, rgba(var(--blue), 0.06), transparent);
}
.cam-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cam-chat-msg { display: flex; }
.cam-chat-msg-user { justify-content: flex-end; }
.cam-chat-msg-assistant { justify-content: flex-start; }
.cam-chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.cam-chat-msg-user .cam-chat-bubble {
  background: rgb(var(--blue));
  color: white;
  border-bottom-right-radius: 4px;
}
.cam-chat-msg-assistant .cam-chat-bubble {
  background: rgb(var(--hover));
  color: rgb(var(--fg));
  border: 1px solid rgb(var(--line));
  border-bottom-left-radius: 4px;
}
.cam-chat-empty {
  margin: auto 0;
  padding: 0 8px;
}
.cam-chat-suggestion {
  font-size: 0.7rem;
  padding: 6px 10px;
  border: 1px solid rgb(var(--line));
  border-radius: 14px;
  background: transparent;
  color: rgb(var(--blue));
  cursor: pointer;
  transition: background 120ms;
}
.cam-chat-suggestion:hover { background: rgba(var(--blue), 0.08); }
.cam-chat-typing { display: flex; gap: 4px; align-items: center; min-height: 24px; }
.cam-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgb(var(--muted));
  animation: chat-typing 1.4s infinite ease-in-out;
}
.cam-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.cam-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chat-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}
.cam-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgb(var(--line));
  background: rgb(var(--bg));
}
.cam-chat-input {
  flex: 1;
  border: 1px solid rgb(var(--line));
  background: rgb(var(--surface));
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: rgb(var(--fg));
}
.cam-chat-input:focus { outline: none; border-color: rgb(var(--blue)); box-shadow: 0 0 0 2px rgba(var(--blue), 0.18); }
.cam-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgb(var(--blue));
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: filter 120ms;
}
.cam-chat-send:hover:not(:disabled) { filter: brightness(1.1); }
.cam-chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Mobile: lift the FAB above the bottom tab bar */
@media (max-width: 768px) {
  .cam-chat-root {
    bottom: calc(80px + env(safe-area-inset-bottom, 0));
    right: 16px;
  }
  .cam-chat-panel {
    width: calc(100vw - 24px);
    height: calc(100vh - 160px);
    bottom: 68px;
    right: -8px;
  }
}

  /* Deal detail: hide the noisy in-page "← Pipeline" + ID chip text */
  /* keep layout but tighten */
  .uppercase-spread { font-size: 0.6rem; }

  /* Make all inline-edit name input scale to viewport */
  .cell-edit { font-size: 1.1rem !important; }

  /* Tasks chalkboard: tighten padding on phones */
  .chalkboard { padding: 18px 16px; margin: -16px -12px; }
  .chalk-h1 { font-size: 2.2rem !important; }
  .chalkboard .grid.grid-cols-12 > div { grid-column: span 1 / span 1; }
}

/* Touch-friendly: ensure clickable rows have enough vertical hit area on phones */
@media (max-width: 768px) and (pointer: coarse) {
  button, a.deal-card, .stage-btn, .chalk-task { min-height: 40px; }
  input[type="text"], input[type="number"], input[type="date"], select, textarea {
    font-size: 16px;  /* prevents iOS Safari from auto-zooming on focus */
  }
}

/* ────────────────────────────────────────────────────────────────────
   Borrower Portal card — top-of-page CTA on every deal-detail page
   ──────────────────────────────────────────────────────────────────── */
.borrower-portal-card {
  position: relative;
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--line));
  border-left: 4px solid rgb(var(--blue));   /* prominent left accent */
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06),
              0 0 0 1px rgba(var(--blue), 0.08);
}

.bp-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.bp-headline { flex: 1; min-width: 0; }
.bp-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.bp-icon { font-size: 1.3rem; line-height: 1; }
.bp-title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.bp-pct {
  margin-left: auto;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border: 1px solid rgb(var(--blue));
  color: rgb(var(--blue));
  background: rgba(var(--blue), 0.08);
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
}
.bp-subtitle {
  font-size: 0.82rem;
  color: rgb(var(--muted));
  line-height: 1.5;
}

.bp-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  align-items: stretch;
}
.bp-cta {
  background: rgb(var(--blue));
  color: rgb(var(--blue-fg));
  border: 1px solid rgb(var(--blue));
  padding: 10px 18px;
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
}
.bp-cta:hover:not(:disabled) {
  background: rgb(var(--blue-light));
  box-shadow: 0 2px 8px rgba(var(--blue), 0.35);
}
.bp-cta:disabled { opacity: 0.4; cursor: not-allowed; }

.bp-secondary {
  border: 1px solid rgb(var(--fg));
  color: rgb(var(--fg));
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-decoration: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  transition: all 150ms ease;
}
.bp-secondary:hover {
  background: rgb(var(--fg));
  color: rgb(var(--bg));
}

/* Progress row — count + stats above the bar */
.bp-progress-row { margin: 8px 0 14px; }
.bp-progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.78rem;
  color: rgb(var(--muted));
  margin-bottom: 6px;
  gap: 12px;
  flex-wrap: wrap;
}
.bp-progress-meta strong {
  color: rgb(var(--fg));
  font-weight: 600;
}
.bp-stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-variant-numeric: tabular-nums;
}
.bp-progress-bar {
  height: 8px;
  background: rgb(var(--surface-2));
  border-radius: 4px;
  overflow: hidden;
}
.bp-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, rgb(var(--blue)) 0%, rgb(var(--blue-light)) 100%);
  transition: width 600ms cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 0 8px rgba(var(--blue), 0.4);
}

/* URL drawer */
.bp-url-details { margin-bottom: 8px; }
.bp-url-summary {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgb(var(--muted));
  cursor: pointer;
  padding: 4px 0;
}
.bp-url-summary:hover { color: rgb(var(--fg)); }
.bp-url-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.bp-url-input {
  flex: 1;
  min-width: 200px;
  background: rgb(var(--surface-2));
  color: rgb(var(--blue));
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 0.75rem;
  padding: 8px 10px;
  border: 1px solid rgb(var(--line));
}
.bp-url-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.bp-text-btn {
  background: transparent;
  border: none;
  color: rgb(var(--muted));
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  padding: 4px 8px;
}
.bp-text-btn:hover { color: rgb(var(--fg)); }
.bp-warn-btn:hover { color: rgb(var(--warn)); }

/* Checklist drawer */
.bp-checklist-details { margin-top: 4px; }
.bp-checklist-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgb(var(--muted));
  cursor: pointer;
  padding: 4px 0;
}
.bp-checklist-summary:hover { color: rgb(var(--fg)); }
.bp-checklist-count {
  color: rgb(var(--blue));
  font-variant-numeric: tabular-nums;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 600;
  font-size: 0.78rem;
}
.bp-checklist-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.bp-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 3px;
}
.bp-checklist-item:hover { background: rgb(var(--hover)); }
.bp-checklist-done .bp-check {
  color: rgb(var(--blue));
  font-weight: 700;
}
.bp-check {
  color: rgb(var(--muted));
  width: 14px;
  flex-shrink: 0;
  font-weight: 600;
  font-size: 0.9rem;
}
.bp-check-body { flex: 1; min-width: 0; }
.bp-check-label { font-size: 0.85rem; line-height: 1.4; }
.bp-checklist-done .bp-check-label { color: rgb(var(--fg)); }
.bp-check-note {
  font-size: 0.72rem;
  color: rgb(var(--muted));
  font-style: italic;
  margin-top: 2px;
  line-height: 1.4;
}

/* Mobile: stack the top strip + make the CTA full-width */
@media (max-width: 768px) {
  .borrower-portal-card { padding: 14px 14px; margin: -8px -4px 16px; }
  .bp-top { gap: 12px; }
  .bp-actions { width: 100%; }
  .bp-cta { flex: 1; padding: 12px 14px; font-size: 0.85rem; }
  .bp-secondary { padding: 12px 14px; min-height: 44px; }
  .bp-title { font-size: 1.05rem; }
  .bp-subtitle { font-size: 0.78rem; }
  .bp-url-row { flex-direction: column; }
  .bp-url-actions { justify-content: flex-end; }
}

/* ────────────────────────────────────────────────────────────────────────
   Mobile PWA fine-tuning — kicks in at ≤640px (real phone widths,
   not iPad portrait). Tightens typography + padding + components so the
   app feels purpose-built for a phone instead of a webapp squeezed onto one.
   ──────────────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* ── Typography: scale heading sizes down 15% ── */
  h1.text-3xl { font-size: 1.15rem !important; line-height: 1.25; }
  h1          { font-size: 1.15rem !important; }
  h2.text-xl  { font-size: 0.92rem !important; }
  h2          { font-size: 0.92rem !important; }
  h3          { font-size: 0.82rem !important; }
  body        { font-size: 13.5px; }
  .uppercase-spread { font-size: 0.58rem; letter-spacing: 0.09em; }

  /* Page header underline accent — narrower */
  main h1.text-3xl::after { width: 36px; height: 2px; margin-top: 4px; }

  /* ── Container: tighter outer padding so cards have more room ── */
  main.max-w-screen-2xl {
    padding: 8px 10px;
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0));
  }

  /* ── Panels: less internal padding, less spacing between ── */
  .panel { padding: 11px 12px; margin-bottom: 8px; }
  .panel + .panel,
  .panel + section,
  section + .panel,
  section + section { margin-top: 8px; }

  /* Page-header block (the .mb-6 / .mb-8 wrapper above each page) tightens */
  main > div.mb-6, main > div.mb-8 { margin-bottom: 12px !important; }
  main > div.mb-6 p, main > div.mb-8 p { font-size: 0.72rem; margin-top: 2px; }

  /* ── Metric tiles: smaller numbers, tighter padding ── */
  .metric { padding: 10px 12px; }
  .metric-value { font-size: 1.15rem; }
  .metric-label { font-size: 0.55rem; }
  .metric-sub   { font-size: 0.6rem; }

  /* ── Buttons: keep 44px min-height (accessibility) but tighter inner padding ── */
  .btn-primary, .btn-secondary {
    padding: 10px 14px;
    font-size: 0.78rem;
    min-height: 42px;
  }

  /* ── Form inputs: 16px keeps iOS from auto-zooming on focus,
        but tighten height + padding ── */
  input[type="text"], input[type="number"], input[type="date"],
  input[type="email"], input[type="tel"], input[type="password"],
  select, textarea {
    padding: 9px 11px;
    min-height: 40px;
  }

  /* ── Borrower portal card: tighter strip + smaller CTA ── */
  .borrower-portal-card { padding: 11px 12px; }
  .bp-icon  { font-size: 1.1rem; }
  .bp-title { font-size: 0.95rem; }
  .bp-subtitle { font-size: 0.72rem; }
  .bp-pct { font-size: 0.65rem; padding: 1px 6px; }
  .bp-cta {
    padding: 11px 14px;
    font-size: 0.74rem;
    letter-spacing: 0.06em;
    min-height: 42px;
  }
  .bp-secondary {
    padding: 11px 12px;
    font-size: 0.68rem;
    min-height: 42px;
  }
  .bp-progress-meta { font-size: 0.7rem; }
  .bp-progress-bar  { height: 6px; }
  .bp-url-summary, .bp-checklist-summary { font-size: 0.62rem; }
  .bp-check-label { font-size: 0.78rem; }
  .bp-check-note  { font-size: 0.65rem; }

  /* ── Floating action button — slightly smaller ── */
  .fab-new-deal {
    width: 50px; height: 50px;
    font-size: 24px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0) + 12px);
    right: 12px;
  }

  /* ── Chatbot widget: don't cover the whole screen ── */
  .cam-chat-fab {
    width: 46px; height: 46px;
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    right: 12px;
  }
  .cam-chat-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 200px);
    bottom: 64px;
    right: -4px;
    max-height: 70vh;
  }
  .cam-chat-msg-bubble { font-size: 0.82rem; }

  /* ── Mobile bottom tabbar: tighter ── */
  .mobile-tabbar { padding-top: 0; }
  .mobile-tab { padding: 8px 4px 6px; }
  .mobile-tab span { font-size: 9px; }
  .mobile-tab svg { width: 16px; height: 16px; }

  /* ── Top nav: shrink the brand to free more swipe room ── */
  nav > .max-w-screen-2xl { height: 42px; }
  nav > .max-w-screen-2xl > a:first-child { font-size: 0.85rem; }
  nav > .max-w-screen-2xl > a:not(:first-child):not(:last-of-type) {
    padding-left: 9px;
    padding-right: 9px;
    font-size: 0.72rem;
  }

  /* ── Kanban: narrower columns so adjacent column peeks visibly ── */
  .kanban-col {
    min-width: 82vw;
    max-width: 82vw;
    max-height: calc(100vh - 200px);
  }
  .deal-card { padding: 11px; }
  .deal-card .text-sm { font-size: 0.88rem; }

  /* ── Annual goal bar (the Lambo + finish line): scale down vertical footprint ── */
  .goal-bar { height: 28px; margin-top: 32px; }
  .goal-runner { width: 44px; height: 18px; transform: translateX(-22px); }
  .goal-finish { width: 22px; height: calc(100% + 26px); }
  .goal-fill-label, .goal-target-label { font-size: 0.7rem; }

  /* ── Composer textareas (deal-detail notes, etc.) — shorter min-height ── */
  textarea {
    min-height: 64px !important;
    line-height: 1.45;
  }

  /* ── Stage-selector buttons (pipeline stage picker on deal detail) ── */
  .stage-btn { padding: 6px 10px !important; font-size: 0.66rem !important; }

  /* ── Chips (the colored tags) ── */
  .chip { padding: 1px 6px; font-size: 0.6rem; }

  /* ── Hide bulky email-Triage / dashboard subtitles on mobile to save space ── */
  main > div.mb-6 p.max-w-2xl,
  main > div.mb-8 p.max-w-2xl { display: none; }

  /* ── Tighten Tasks chalkboard ── */
  .chalkboard { padding: 14px 12px; margin: -10px -8px 12px; }
  .chalk-h1 { font-size: 1.8rem !important; }
}

/* Extra-narrow (smaller phones in portrait, ≤380px) — tighten one more notch */
@media (max-width: 380px) {
  body { font-size: 13px; }
  h1.text-3xl, h1 { font-size: 1.05rem !important; }
  .panel { padding: 10px 11px; }
  .bp-cta { padding: 10px 12px; font-size: 0.7rem; }
  .kanban-col { min-width: 86vw; max-width: 86vw; }
  .metric-value { font-size: 1.05rem; }
}

/* ────────────────────────────────────────────────────────────────────
   Borrower Portal — mobile share UX additions
   ──────────────────────────────────────────────────────────────────── */

/* Show "📋 Copy Portal Link" on desktop, "📤 Send to Borrower" on mobile —
   mobile gets the native share sheet so the label needs to reflect that. */
.bp-cta-mobile  { display: none; }
.bp-cta-desktop { display: inline; }
@media (max-width: 640px) {
  .bp-cta-mobile  { display: inline; }
  .bp-cta-desktop { display: none; }
}

/* The visible URL block (replaces the old <details> drawer) */
.bp-url-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgb(var(--line));
}
.bp-url-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.bp-url-input {
  flex: 1;
  min-width: 0;
  background: rgb(var(--surface-2));
  color: rgb(var(--blue));
  font-family: 'SF Mono', Consolas, monospace;
  font-size: 0.78rem;
  padding: 8px 10px;
  border: 1px solid rgb(var(--line));
  cursor: pointer;
}
.bp-url-input:focus { outline: 2px solid rgb(var(--blue)); outline-offset: 1px; }
.bp-url-help {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.bp-mobile-only { display: none; }
.bp-url-mgmt {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

/* Mobile: show the long-press hint + stack URL row vertically if cramped */
@media (max-width: 640px) {
  .bp-mobile-only {
    display: inline;
    font-size: 0.7rem;
    color: rgb(var(--muted));
    font-style: italic;
    line-height: 1.4;
  }
  .bp-url-help { flex-direction: column; align-items: flex-start; gap: 8px; }
  .bp-url-mgmt { margin-left: 0; }
  .bp-url-input { font-size: 0.72rem; padding: 10px 12px; }
  /* Text button gets a more prominent green-ish tint on mobile since SMS is
     often the fastest delivery channel for borrowers */
  .bp-sms-btn {
    background: rgba(var(--blue), 0.08);
    border-color: rgb(var(--blue));
    color: rgb(var(--blue));
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   MODERN SKIN 2.0 (2026-07-19) — softer, rounder, easier to digest.
   Appended LAST so source order wins over the sharp-cornered rules above.
   Palette / themes (cream, dark, onyx) are untouched — this layer only
   changes shape (radius), depth (shadows) and the body typeface (Inter).
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
}

/* Body typeface → Inter (headings keep Poppins via base.html).
   .font-sans matches tw.css specificity; later source order wins. */
body, .font-sans {
  font-family: 'Inter', 'Space Grotesk', system-ui, -apple-system, sans-serif;
  letter-spacing: 0.005em;
}

/* ── Kanban board ── */
.kanban-col {
  border-radius: var(--radius-lg);
  background: rgb(var(--surface) / 0.75);
}
.kanban-col-header { padding: 14px 16px 12px; }

/* Deal cards — rounded squares, soft elevation, lift on hover. */
.deal-card {
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--line));
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 3px 10px rgb(0 0 0 / 0.04);
}
.deal-card:hover {
  border-color: rgb(var(--blue) / 0.55);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.10);
}
.deal-card .text-sm.font-medium { font-size: 0.9rem; line-height: 1.35; }
.dark .deal-card, .onyx .deal-card {
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 14px rgb(0 0 0 / 0.28);
}

/* ── Chips → pills ── */
.chip, .chip-blue { border-radius: 999px; padding: 3px 10px; }

/* ── Buttons ── */
.btn-primary, .btn-secondary, .login-submit, .stage-btn {
  border-radius: 10px;
}

/* ── Inputs / selects / textareas ── */
input[type="text"], input[type="number"], input[type="date"],
input[type="email"], input[type="tel"], input[type="search"],
input[type="password"], select, textarea {
  border-radius: 10px;
}
.cell-edit { border-radius: var(--radius-sm); }
.card-commission-wrap { border-radius: var(--radius-sm); }
.card-vis-seg { border-radius: var(--radius-sm); }
.card-vis-btn:first-child { border-top-left-radius: 7px; border-bottom-left-radius: 7px; }
.card-vis-btn:last-child  { border-top-right-radius: 7px; border-bottom-right-radius: 7px; }

/* ── Tiles, rows, tables, panels ── */
.metric { border-radius: var(--radius-lg); }
.task-row, .ev-row { border-radius: var(--radius); }
table.data-table { border-radius: var(--radius); overflow: hidden; }
.commission-bubble-cloud { border-radius: var(--radius-lg); }

/* Any bordered section/panel used on deal pages picks up the radius. */
.partner-tracker-card, .closing-items-card, section.card, .panel {
  border-radius: var(--radius-lg);
}

/* Generic: bordered boxes built with Tailwind `border border-line` utility
   pairs frequently used as panels — give them a soft default radius when
   they don't already carry a rounded-* class. Scoped to top-level blocks
   inside <main> to avoid rounding table cells / dividers. */
main .border.border-line:not([class*="rounded"]) { border-radius: var(--radius); }

/* Softer default borders overall (hairlines read lighter with radius). */
.deal-card, .kanban-col, .metric, .task-row, .ev-row {
  border-color: rgb(var(--line) / 0.9);
}

/* ── Breathing room (Cam 2026-07-21: boxes felt overcrowded) ──────────────
   More air between kanban columns, cards, and inside cards/panels. */
#board { gap: 20px !important; }
.kanban-col { min-width: 300px; max-width: 340px; }
.kanban-col-header { padding: 16px 18px 14px; }
.kanban-col [data-dropzone] { padding: 12px !important; gap: 12px !important; }
.deal-card { padding: 16px; }
.deal-card .chip { margin-left: 8px; }
.metric { padding: 18px 20px; }
main section, .partner-tracker-card { margin-bottom: 28px; }
main { padding-top: 8px; }
@media (min-width: 768px) {
  .deal-card { padding: 18px; }
}
