/* Captain Chip Stock: clean, flat, mobile first */

:root {
  --bg: #faf9f5;
  --panel: #f3f2ec;
  --surface: #ffffff;
  --hover: #ecebe4;
  --active: #e4e2da;
  --seg-active: #ffffff;
  --border: #e5e3da;
  --text: #1f1e1b;
  --muted: #6f6d66;
  --faint: #a09e95;
  --primary: #1f1e1b;
  --primary-text: #faf9f5;
  --accent: #2f6fde;
  --warn-bg: #fbe6df;
  --warn-text: #a8391f;
  --ok-bg: #e2f0e6;
  --ok-text: #2b7449;
  --info-bg: #e5ecfa;
  --info-text: #2d5bb5;
  --danger: #c2412d;
  --skel: #eceae3;
  --skel-hi: #f7f6f2;
  --backdrop: rgba(20, 20, 18, 0.35);
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tabbar-h: 64px;
  --bar-offset: 0px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #262624;
    --panel: #1f1f1e;
    --surface: #2c2c2a;
    --hover: #333331;
    --active: #3a3a38;
    --seg-active: #454543;
    --border: #363634;
    --text: #ecebe6;
    --muted: #a3a19a;
    --faint: #75736d;
    --primary: #ecebe6;
    --primary-text: #1f1f1e;
    --accent: #4b8bf5;
    --warn-bg: #4a2b23;
    --warn-text: #f2a591;
    --ok-bg: #233a2b;
    --ok-text: #86d1a1;
    --info-bg: #26324a;
    --info-text: #9fbcf2;
    --danger: #ec7a64;
    --skel: #2f2f2d;
    --skel-hi: #3b3b38;
    --backdrop: rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #262624;
  --panel: #1f1f1e;
  --surface: #2c2c2a;
  --hover: #333331;
  --active: #3a3a38;
  --seg-active: #454543;
  --border: #363634;
  --text: #ecebe6;
  --muted: #a3a19a;
  --faint: #75736d;
  --primary: #ecebe6;
  --primary-text: #1f1f1e;
  --accent: #4b8bf5;
  --warn-bg: #4a2b23;
  --warn-text: #f2a591;
  --ok-bg: #233a2b;
  --ok-text: #86d1a1;
  --info-bg: #26324a;
  --info-text: #9fbcf2;
  --danger: #ec7a64;
  --skel: #2f2f2d;
  --skel-hi: #3b3b38;
  --backdrop: rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.ic { flex-shrink: 0; display: block; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, 'Cascadia Mono', Menlo, Consolas, monospace; font-size: 12.5px; }
[hidden] { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 14px;
  border: none; border-radius: var(--radius);
  background: var(--hover); color: var(--text);
  font-size: 14px; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--active); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary); opacity: 0.9; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--warn-bg); }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: var(--danger); opacity: 0.9; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; }
.btn-block { width: 100%; height: 46px; font-size: 15px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  border: none; border-radius: var(--radius);
  background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }
.icon-btn-sm { width: 32px; height: 32px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Form fields */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--muted); }
.field input, .field select {
  height: 46px; width: 100%; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 16px; outline: none;
}
.field input:focus { border-color: var(--faint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.field input::placeholder { color: var(--faint); }
.form-error { color: var(--danger); font-size: 14px; }

/* Switch */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch-text { display: grid; gap: 2px; }
.switch {
  appearance: none; -webkit-appearance: none; flex-shrink: 0;
  position: relative; width: 40px; height: 24px; margin: 0;
  border-radius: 12px; background: var(--active); cursor: pointer;
  transition: background 0.15s;
}
.switch::before {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform 0.15s;
}
.switch:checked { background: var(--accent); }
.switch:checked::before { transform: translateX(16px); }

/* Segmented control */
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--hover); border-radius: var(--radius); max-width: 100%; overflow-x: auto; }
.seg { position: relative; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg-btn { position: relative; z-index: 1; border: none; background: transparent; padding: 6px 12px; border-radius: 6px; font-size: 13.5px; font-weight: 500; color: var(--muted); white-space: nowrap; transition: color 0.2s; }
.seg-btn.is-active { background: var(--seg-active); color: var(--text); }
.seg.has-thumb .seg-btn.is-active { background: transparent; }
.seg-thumb {
  position: absolute; top: 0; left: 0; width: 0; opacity: 0;
  border-radius: 6px; background: var(--seg-active);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  transition: transform 0.28s cubic-bezier(0.3, 0.7, 0.2, 1), width 0.28s cubic-bezier(0.3, 0.7, 0.2, 1);
}
.seg-thumb.no-anim { transition: none; }
@media (prefers-reduced-motion: reduce) { .seg-thumb { transition: none; } }

/* Items table in Settings: card-like rows on phones, a proper table on desktop */
.it-table { position: relative; margin-top: 8px; border-top: 1px solid var(--border); }
.it-head { display: none; }
.it-row {
  position: relative; background: var(--bg);
  display: grid; gap: 8px 10px; align-items: end;
  grid-template-columns: 28px 1fr 1fr auto;
  grid-template-areas: "grip name name actions" "grip unit reorder halves";
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.it-grip {
  grid-area: grip; align-self: stretch;
  display: grid; place-items: center; width: 28px; padding: 0;
  border: none; border-radius: 6px; background: transparent; color: var(--faint);
  cursor: grab; touch-action: none;
}
.it-grip:hover { background: var(--hover); color: var(--text); }
.it-row.is-dragging {
  z-index: 5; border-radius: var(--radius); border-bottom-color: transparent;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16), 0 0 0 1px var(--border);
}
.it-row.is-dragging .it-grip { cursor: grabbing; color: var(--text); }
.it-table.is-sorting { user-select: none; -webkit-user-select: none; cursor: grabbing; }
.it-name { grid-area: name; font-weight: 500; }
.it-unit { grid-area: unit; }
.it-reorder { grid-area: reorder; }
.it-halves { grid-area: halves; justify-items: center; }
.it-actions { grid-area: actions; display: flex; gap: 2px; justify-content: flex-end; align-self: center; }
.it-cell { display: grid; gap: 4px; min-width: 0; }
.it-mlabel { font-size: 12px; color: var(--muted); }
.it-halves .switch { margin: 7px 0; }
.cell-input {
  width: 100%; min-width: 0; height: 40px; padding: 0 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 16px; outline: none; transition: background 0.15s, border-color 0.15s;
}
.cell-input:focus { border-color: var(--faint); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.cell-num { font-variant-numeric: tabular-nums; }
@media (min-width: 900px) {
  .it-table { border-top: none; }
  .it-head, .it-row { grid-template-columns: 28px minmax(150px, 2fr) minmax(120px, 1.4fr) 110px 72px 40px; align-items: center; }
  .it-grip { height: 32px; align-self: center; }
  .it-head { display: grid; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; font-weight: 500; color: var(--muted); }
  .it-head span:nth-child(2) { padding-left: 10px; }
  .it-row { grid-template-areas: "grip name unit reorder halves actions"; gap: 10px; padding: 6px 0; }
  .it-mlabel { display: none; }
  .it-halves { justify-items: start; }
  .it-halves .switch { margin: 0 0 0 4px; }
  .cell-input { height: 36px; font-size: 14.5px; background: transparent; border-color: transparent; }
  .cell-input:hover { background: var(--hover); }
}

/* Shimmer while loading */
.skel {
  background: linear-gradient(90deg, var(--skel) 0%, var(--skel-hi) 50%, var(--skel) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: 6px;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
.boot { min-height: 100dvh; display: grid; place-items: center; }

/* Brand */
.brand-mark {
  display: block; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 8px;
  background: #fff; object-fit: cover;
  box-shadow: inset 0 0 0 1px var(--border);
}

/* Full logo, swapped for light / dark mode */
.logo { display: inline-flex; flex-shrink: 0; }
.logo img { display: block; height: 40px; width: auto; }
.logo-sm img { height: 30px; }
.logo-md img { height: 42px; }
.logo-lg img { height: 72px; }
.logo-dark { display: none !important; }
:root[data-theme="dark"] .logo-light { display: none !important; }
:root[data-theme="dark"] .logo-dark { display: block !important; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none !important; }
  :root:not([data-theme="light"]) .logo-dark { display: block !important; }
}

/* Sign in */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 360px; display: grid; gap: 16px; }
.auth-card h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin-top: 8px; }
.auth-card .muted { margin-top: -10px; }

/* App shell: mobile */
.shell { min-height: 100dvh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 56px; padding: 0 8px 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
/* Not positioned, so the menu lines up with the whole top bar and always stays on screen */
.site-switch { margin-left: auto; min-width: 0; }
.site-switch-btn {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  padding: 7px 8px 7px 12px; border: none; border-radius: var(--radius);
  background: var(--hover); font-size: 15px; font-weight: 600;
}
.site-switch-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-switch-btn .ic { color: var(--muted); transition: transform 0.2s ease; }
.site-switch-btn[aria-expanded="true"] .ic { transform: rotate(180deg); }
.site-menu {
  position: absolute; right: 8px; top: calc(100% + 6px); z-index: 40;
  width: min(280px, calc(100vw - 16px)); max-height: calc(100dvh - 140px); overflow-y: auto; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  transform-origin: top right; animation: menu-in 0.14s ease-out;
}
.site-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 10px; border: none; border-radius: var(--radius);
  background: transparent; font-size: 15px; text-align: left; color: var(--text);
}
.site-menu-item .ic { color: var(--muted); }
.site-menu-item:hover, .site-menu-item:focus-visible { background: var(--hover); outline: none; }
.site-menu-item.is-current { font-weight: 600; }
.site-menu-item.is-current .ic { color: var(--text); }
.site-menu-check { margin-left: auto; display: grid; color: var(--accent); }
.site-menu-check .ic { color: var(--accent); }
.site-menu-send, .site-menu-send .ic { color: var(--accent); }
.site-menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }
@keyframes menu-in { from { opacity: 0; transform: scale(0.97) translateY(-4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .site-menu { animation: none; } }
.demo-banner { padding: 8px 16px; background: var(--info-bg); color: var(--info-text); font-size: 13px; }
.view { padding: 20px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); outline: none; --bar-offset: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(6, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--panel); border-top: 1px solid var(--border);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 500; color: var(--muted); }
.tab.is-active { color: var(--text); }
.tab.is-active .ic { stroke-width: 2.1; }

/* App shell: desktop */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 252px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 2px;
    position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    padding: 14px 10px; background: var(--panel); border-right: 1px solid var(--border);
  }
  .topbar, .tabbar { display: none; }
  .view { max-width: 860px; padding: 36px 48px 64px; --bar-offset: 0px; }
  .hide-desktop { display: none !important; }
}
@media (max-width: 899px) { .hide-mobile { display: none !important; } }

.brand { display: flex; align-items: center; padding: 6px 8px 12px; }
.side-label { padding: 14px 10px 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.side-group { display: grid; gap: 1px; }
.side-link {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 7px 10px; border: none; border-radius: var(--radius);
  background: transparent; font-size: 14px; text-align: left; color: var(--text);
}
.side-link .ic { color: var(--muted); }
.side-link:hover { background: var(--hover); }
.side-link.is-active { background: var(--active); font-weight: 500; }
.side-link.is-active .ic { color: var(--text); }
.side-empty { padding: 6px 10px; font-size: 13px; color: var(--muted); }

/* Sites in the sidebar open like folders to show their pages */
.side-site-head .side-chev { margin-left: auto; display: grid; color: var(--faint); transform: rotate(-90deg); transition: transform 0.2s ease; }
.side-site.is-open .side-chev { transform: none; }
.side-site.is-current > .side-site-head { font-weight: 600; }
.side-site.is-current > .side-site-head > .ic { color: var(--text); }
.side-sub { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.22s ease; }
.side-site.is-open .side-sub { grid-template-rows: 1fr; }
.side-sub-inner {
  overflow: hidden; min-height: 0; display: grid; gap: 1px;
  margin-left: 19px; padding-left: 8px; border-left: 1px solid var(--border);
}
.side-site.is-open .side-sub-inner { padding-top: 2px; padding-bottom: 6px; }
.side-sublink { padding: 6px 10px; font-size: 13.5px; }
.side-send { color: var(--accent); }
.side-send .ic { color: var(--accent); }
.side-add { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.set-site-tabs { margin-bottom: 24px; }
@media (prefers-reduced-motion: reduce) { .side-sub, .side-chev { transition: none; } }

/* Send-link dialog */
.share-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.share-grid .btn { height: 44px; }
.share-wide { grid-column: 1 / -1; }
.side-foot { margin-top: auto; padding-top: 12px; display: grid; gap: 1px; }

/* Page */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.25; }
.page-sub { color: var(--muted); margin-top: 2px; min-height: 1.5em; }
.empty { padding: 40px 8px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.empty h2 { font-size: 17px; font-weight: 600; }
.empty .btn { margin-top: 8px; }
.empty-text { color: var(--muted); padding: 14px 0; }
.error-box { padding: 16px; border-radius: var(--radius-lg); background: var(--warn-bg); color: var(--warn-text); display: grid; gap: 10px; justify-items: start; }

/* Notice */
.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 16px; margin-bottom: 20px;
  background: var(--panel); border-radius: var(--radius-lg);
}
.notice > div { flex: 1 1 220px; }
.notice strong { font-weight: 600; }
.notice p { font-size: 14px; }

/* Lists with dividers */
.list { border-top: 1px solid var(--border); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 2px; border-bottom: 1px solid var(--border); }
.row-main { min-width: 0; flex: 1; }
.row-title { font-weight: 500; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-sub { font-size: 13px; color: var(--muted); }
.stock-num { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.stock-num .num { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stock-num .unit { font-size: 12px; color: var(--muted); }
.stock-row.is-low .num { color: var(--warn-text); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }

/* Wizard (step-by-step on mobile, one page on desktop) */
.wizard-progress { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.step { display: none; }
.step.is-active { display: block; }
.step-title { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.step-hint { color: var(--muted); font-size: 14px; margin-top: 2px; }
.step-body { margin-top: 16px; display: grid; gap: 16px; }
.wizard-bar {
  position: sticky; bottom: var(--bar-offset); z-index: 10;
  display: flex; gap: 8px; margin-top: 20px; padding: 12px 0;
  background: var(--bg);
}
.wizard-bar .btn { flex: 1; height: 48px; font-size: 15px; }
.wizard-bar .is-hidden { display: none; }
.as-who { font-size: 14px; color: var(--muted); }
.link-btn { border: none; background: none; padding: 0; color: var(--accent); font-weight: 500; }
@media (min-width: 900px) {
  .wizard-progress { display: none; }
  .step { display: block; margin-bottom: 36px; }
  .wizard-bar { position: static; justify-content: flex-end; padding: 0; margin-top: 0; }
  .wizard-bar .btn { flex: 0 0 auto; height: 42px; padding: 0 20px; }
  .wizard-bar [data-wiz="back"], .wizard-bar [data-wiz="next"] { display: none !important; }
  .wizard-bar [data-wiz="save"] { display: inline-flex !important; }
  .as-who { display: none; }
}

/* Quantity rows */
.qty-list { border-top: 1px solid var(--border); }
.qty-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.qty-label { min-width: 0; }
.qty-name { font-weight: 500; }
.qty-sub { font-size: 13px; color: var(--muted); }
.qty-row.is-set .qty-name { font-weight: 600; }
.stepper { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.step-btn {
  display: grid; place-items: center; width: 44px; height: 44px;
  border: none; border-radius: var(--radius); background: var(--hover); color: var(--text);
}
.step-btn:active { background: var(--active); }
.step-input {
  width: 58px; height: 44px; padding: 0; text-align: center;
  border: none; border-radius: var(--radius); background: transparent;
  font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--faint); outline: none;
}
.step-input:focus { background: var(--surface); box-shadow: inset 0 0 0 1px var(--border); }
.qty-row.is-set .step-input { color: var(--text); }

/* Summary */
.summary { border-top: 1px solid var(--border); }
.sum-row { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.sum-val { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* History */
.hist-filters { margin-bottom: 8px; }
.day-label { margin: 22px 0 2px; font-size: 13px; font-weight: 600; color: var(--muted); }
.hist-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.hist-head { display: flex; align-items: center; gap: 8px; }
.hist-who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-time { color: var(--muted); font-size: 13px; margin-right: auto; }
.hist-lines { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 4px; font-size: 14px; color: var(--muted); }
.hist-lines b { color: var(--text); font-weight: 600; }
.hist-note { margin-top: 4px; font-size: 13px; color: var(--muted); font-style: italic; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; }
.chip-fill { background: var(--hover); color: var(--text); }
.chip-delivery { background: var(--ok-bg); color: var(--ok-text); }
.chip-count { background: var(--info-bg); color: var(--info-text); }
.load-more-wrap { display: flex; justify-content: center; margin-top: 16px; }

/* Settings */
.set-section { margin-bottom: 36px; }
.set-section h2 { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.set-intro { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.set-list { border-top: 1px solid var(--border); margin-top: 8px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.set-text { min-width: 0; flex: 1; display: grid; gap: 2px; }
.set-label { font-weight: 500; }
.set-desc { font-size: 13px; color: var(--muted); }
.set-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.set-foot { margin-top: 12px; }
.link-box { margin-top: 6px; padding: 8px 10px; background: var(--panel); border-radius: 6px; word-break: break-all; color: var(--text); }
@media (max-width: 899px) {
  .set-row-stack { flex-direction: column; align-items: stretch; }
  .set-row-stack .set-actions .btn { flex: 1; }
}

/* Dialog */
dialog {
  border: none; padding: 0; margin: auto;
  width: min(440px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  background: var(--surface); color: var(--text); border-radius: var(--radius-lg);
}
dialog::backdrop {
  background: var(--backdrop);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.dialog-form { display: grid; gap: 16px; padding: 22px 20px 20px; }
.dialog-form h2 { font-size: 18px; font-weight: 600; }
.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.dialog-actions .spacer { flex: 1; }
@media (max-width: 899px) {
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 16px 16px 0 0; }
  .dialog-form { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 8px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: var(--radius);
  background: var(--primary); color: var(--primary-text); font-size: 14px; font-weight: 500;
  transition: opacity 0.15s, transform 0.15s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); color: #fff; }
.fill-page .toast, .no-tabbar .toast { bottom: calc(88px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* Sales */
.head-actions { display: flex; gap: 8px; flex-shrink: 0; }
.sales-section { margin-bottom: 32px; }
.sales-section > h2 { font-size: 16px; font-weight: 600; margin-bottom: 8px; }
.sales-tools { display: grid; gap: 10px; margin-bottom: 4px; }
.search {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--muted);
}
.search:focus-within { border-color: var(--faint); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search input { flex: 1; min-width: 0; height: 100%; border: none; background: transparent; outline: none; font-size: 16px; color: var(--text); }
/* Extra filters under the status bar */
.filter-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filter-bar .dd-btn { height: 38px; font-size: 14px; }
.filter-sort { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.filter-sort .dd { flex: 1; }
@media (min-width: 900px) {
  .filter-bar { display: flex; flex-wrap: wrap; align-items: center; }
  .filter-bar > .dd { width: 170px; }
  .filter-bar .dd-btn { background: var(--surface); border-color: var(--border); }
  .filter-sort { margin-left: auto; }
  .filter-sort .dd { width: 180px; flex: none; }
}

/* Status filter: one row; shares the full width on a computer, scrolls sideways on a phone */
.stage-filter { display: flex; flex-wrap: nowrap; overflow-x: auto; width: 100%; margin-bottom: 8px; }
.stage-filter .seg-btn { flex-shrink: 0; }
@media (min-width: 900px) {
  .stage-filter .seg-btn { flex: 1 1 auto; padding: 7px 8px; font-size: 13.5px; }
}
.seg-count { color: var(--faint); font-weight: 500; margin-left: 2px; font-variant-numeric: tabular-nums; }
.lead-row:hover { background: var(--hover); }
.lead-row { margin: 0 -8px; padding-left: 10px; padding-right: 10px; border-radius: var(--radius); }
.lead-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.due { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.due-over, .due-over strong { color: var(--warn-text); }
.stage-chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.stage-to_call { background: var(--hover); color: var(--text); }
.stage-no_answer { background: var(--hover); color: var(--muted); }
.stage-call_back { background: var(--info-bg); color: var(--info-text); }
.stage-awaiting { background: #dff1ef; color: #1f6f6a; }
:root[data-theme="dark"] .stage-awaiting { background: #1f3a38; color: #8fd6cf; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .stage-awaiting { background: #1f3a38; color: #8fd6cf; } }

/* AI-added leads */
.ai-badge {
  display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 5px; vertical-align: 2px;
  background: #ece4fb; color: #5f3aa6; font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em; line-height: 16px;
}
:root[data-theme="dark"] .ai-badge { background: #352a4a; color: #c9b2f2; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ai-badge { background: #352a4a; color: #c9b2f2; } }
.page-head h1 .ai-badge { font-size: 12px; line-height: 20px; vertical-align: 4px; }
.ai-note .ai-badge { margin-left: 0; margin-right: 4px; }
.source-link { display: inline-flex; align-items: center; gap: 3px; color: var(--accent); }

/* Import leads from AI */
.import-step { font-weight: 600; margin: 4px 0 8px; }
.ai-instructions {
  margin: 0; max-height: 34dvh; overflow-y: auto; padding: 12px 14px;
  background: var(--panel); border-radius: var(--radius); white-space: pre-wrap;
  font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.5; color: var(--text);
}
.ai-copy { display: inline-flex; align-items: center; gap: 5px; margin: 6px 0 14px; font-size: 13px; }
.ai-answer { margin-bottom: 4px; }
.import-opts { display: grid; gap: 10px; margin-bottom: 12px; }
@media (min-width: 900px) { .import-opts { grid-template-columns: 1.4fr 1.4fr 0.6fr; } }
.import-dialog [data-copy-prompt] { margin-bottom: 8px; }
.import-dialog textarea { min-height: 140px; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.import-list { max-height: 50dvh; overflow-y: auto; border-top: 1px solid var(--border); }
.import-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px 2px; border-bottom: 1px solid var(--border); cursor: pointer; }
.import-row input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.import-row.is-dup { opacity: 0.6; }
.import-main { display: grid; gap: 1px; min-width: 0; }
.import-name { font-weight: 500; }
.import-sub { font-size: 13px; color: var(--muted); }
.dup-tag { font-size: 11.5px; font-weight: 500; color: var(--warn-text); background: var(--warn-bg); padding: 0 6px; border-radius: 5px; margin-left: 4px; }

/* Sales dashboard: summary tiles */
.dash-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 20px; }
.dash-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-width: 0;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); text-align: left; color: var(--text);
}
.dash-tile:hover { background: var(--hover); }
.dash-n { font-size: 26px; font-weight: 600; line-height: 1.15; font-variant-numeric: tabular-nums; }
.dash-label { font-size: 13.5px; font-weight: 500; }
.dash-sub { font-size: 12.5px; color: var(--muted); }
.dash-tile.is-warn .dash-n, .dash-tile.is-warn .dash-sub { color: var(--warn-text); }
@media (min-width: 900px) { .dash-tiles { grid-template-columns: repeat(5, 1fr); } }
@media (max-width: 899px) {
  /* Phone: header buttons go under the title in a neat grid instead of running off screen */
  .page-head { flex-wrap: wrap; }
  .page-head .head-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .page-head .head-actions .btn { width: 100%; }
  .lead-page .page-head .head-actions { grid-template-columns: repeat(3, 1fr); }
  /* Phone: Due + Follow up big on top, the other three in one row */
  .dash-tiles { grid-template-columns: repeat(6, 1fr); }
  .dash-tile { grid-column: span 2; }
  .dash-tile:nth-child(-n+2) { grid-column: span 3; }
  /* Soft fade on the right shows the status filters scroll sideways */
  .stage-filter { -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
}

/* Sales dashboard: Follow up (folds open) */
.follow-panel { margin-bottom: 20px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); }
.follow-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 16px 18px; border: none; border-radius: 16px; background: transparent; text-align: left; color: var(--text);
}
.follow-toggle:hover { background: var(--hover); }
.follow-toggle > .ic { color: var(--muted); flex-shrink: 0; transition: transform 0.2s ease; }
.follow-panel.is-open .follow-toggle > .ic { transform: rotate(180deg); }
.follow-title { display: block; font-size: 17px; font-weight: 600; }
.follow-desc { display: block; font-size: 13.5px; color: var(--muted); }
.follow-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.25s ease; }
.follow-panel.is-open .follow-body { grid-template-rows: 1fr; }
.follow-inner { overflow: hidden; min-height: 0; }
.fu-list { margin: 0 18px 12px; border-top: 1px solid var(--border); }
.fu-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main actions" "since stage";
  gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.fu-row:last-child { border-bottom: none; }
.fu-main { grid-area: main; display: grid; min-width: 0; color: var(--text); }
.fu-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fu-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fu-since { grid-area: since; font-size: 13px; color: var(--muted); }
.fu-stage { grid-area: stage; justify-self: end; }
.fu-actions { grid-area: actions; display: flex; align-items: center; gap: 4px; justify-self: end; }
@media (min-width: 900px) {
  .fu-row { grid-template-columns: minmax(0, 1fr) 170px 120px auto; grid-template-areas: "main since stage actions"; }
  .fu-stage { justify-self: start; }
}
@media (prefers-reduced-motion: reduce) { .follow-body, .follow-toggle > .ic { transition: none; } }
.all-leads-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; color: var(--accent); }
.all-leads-link .ic { transform: rotate(-90deg); }

/* Sales: Call today panel */
.today-panel { margin-bottom: 32px; padding: 18px; background: var(--panel); border-radius: 16px; }
.today-head { margin-bottom: 14px; }
.today-head h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.today-empty { color: var(--muted); font-size: 14px; }
.today-sub { display: flex; align-items: center; gap: 4px; margin: 16px 0 10px; font-size: 14px; font-weight: 600; }
.today-head + .today-sub { margin-top: 0; }
.today-sub .h-count { margin-left: 4px; }
.today-sub-note { margin-left: 8px; font-size: 13px; font-weight: 400; color: var(--muted); }
.today-more { margin-top: 12px; font-size: 14px; }
.today-grid { display: grid; gap: 10px; }
.today-card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 12px;
  padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
}
.today-card:hover { border-color: var(--faint); }
.today-main { display: grid; gap: 3px; min-width: 0; color: var(--text); }
.today-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.today-top .due { font-size: 12.5px; font-weight: 600; }
.today-name { font-size: 15.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.today-note { font-size: 14px; }
.today-who { font-size: 13px; color: var(--muted); }
.today-emailed, .emailed-row span, .waiting-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.today-emailed { color: var(--muted); margin-top: 2px; }
.emailed-mark { display: inline-flex; vertical-align: -2px; margin-left: 6px; color: var(--muted); }
.lead-page .page-head { flex-wrap: wrap; }
@media (max-width: 899px) { .lead-page .head-actions { width: 100%; } .lead-page .head-actions .btn { flex: 1; } }
.email-dialog { width: min(640px, calc(100vw - 32px)); }
dialog:has(.email-dialog) { width: min(640px, calc(100vw - 32px)); }
.email-dialog textarea { min-height: 240px; }
.form-hint { font-size: 13px; color: var(--muted); margin-top: -6px; }
.form-hint .ic { display: inline-block; vertical-align: -2px; margin-right: 6px; }
.email-actions { flex-wrap: wrap; }
@media (max-width: 899px) { dialog:has(.email-dialog) { width: 100%; } .email-actions .btn { flex: 1 1 auto; } .email-actions .spacer { display: none; } }
.emailed-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; font-size: 13px; }
.emailed-row .link-btn { font-size: 13px; }
.waiting-tag { margin-bottom: 6px; padding: 2px 8px; border-radius: 6px; background: #dff1ef; color: #1f6f6a; font-weight: 500; }
:root[data-theme="dark"] .waiting-tag { background: #1f3a38; color: #8fd6cf; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .waiting-tag { background: #1f3a38; color: #8fd6cf; } }
.today-actions { display: flex; gap: 8px; }
.today-actions .btn { flex: 1; height: 38px; }
@media (min-width: 900px) {
  .today-panel { padding: 20px 22px; }
  .today-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

/* Sales list: status tiles + lead table */
.pipe { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 28px; }
.pipe-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); text-align: left; color: var(--text);
}
.pipe-tile:hover { background: var(--hover); }
.pipe-tile.is-active { border-color: var(--dot); box-shadow: inset 0 0 0 1px var(--dot); }
.pipe-count { font-size: 20px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.pipe-label { display: flex; align-items: center; gap: 6px; max-width: 100%; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pipe-tile .status-dot { width: 8px; height: 8px; }
.h-count { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 10px; background: var(--hover); color: var(--muted); font-size: 13px; font-weight: 500; vertical-align: 2px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.list-head h2 { font-size: 16px; font-weight: 600; margin: 0; }
.list-head .link-btn { margin-left: 8px; font-size: 13.5px; }
.list-head .search { flex: 1 1 260px; max-width: 360px; height: 40px; }

.lead-table { border-top: 1px solid var(--border); }
.lt-head { display: none; }
.lt-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main stage" "main next";
  gap: 2px 12px; align-items: center; padding: 12px 8px; border-bottom: 1px solid var(--border); color: var(--text);
}
.lt-row:hover { background: var(--hover); }
.lt-main { grid-area: main; min-width: 0; }
.lt-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-town, .lt-contact, .lt-phone { display: none; }
.lt-stage { grid-area: stage; justify-self: end; }
.lt-next { grid-area: next; justify-self: end; }
.lt-none { color: var(--faint); }

/* Lead page */
.side-card { padding: 16px; background: var(--panel); border-radius: var(--radius-lg); }
.side-card > h2 { font-size: 16px; font-weight: 600; }
.side-card-sub { font-size: 13px; color: var(--muted); }
.lead-contact .contact-stack { margin-top: 12px; }
/* minmax(0, 1fr) + min-width: 0 let long addresses shrink with "…" instead of spilling out of the card */
.contact-stack { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); }
.contact-stack .contact-group { display: flex; min-width: 0; }
.contact-copy { overflow: hidden; }
.contact-value { min-width: 0; }
.contact-stack .contact-group > .btn:first-child { flex-shrink: 0; width: 88px; justify-content: flex-start; }
.contact-stack .contact-copy { flex: 1; justify-content: space-between; }
.contact-stack .btn { height: 42px; background: var(--surface); }
.contact-stack .btn:hover { background: var(--hover); }
.lead-details .lead-fields { margin-top: 12px; grid-template-columns: 1fr; }
.lead-details .cell-input { background: var(--surface); }
.lead-delete { margin-top: 16px; }
.lead-layout { display: grid; gap: 20px; grid-template-areas: "contact" "main" "details"; }
.lead-contact { grid-area: contact; }
.lead-main { grid-area: main; min-width: 0; }
.lead-details { grid-area: details; }
.lead-main .set-section { margin-bottom: 28px; }
.next-card { margin-bottom: 24px; }

/* App-style dropdown */
.dd { position: relative; }
.dd-btn { display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; }
.dd-btn .ic { color: var(--muted); transition: transform 0.2s ease; flex-shrink: 0; }
.dd-btn[aria-expanded="true"] .ic { transform: rotate(180deg); }
.dd-placeholder { color: var(--faint); }
.dd-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16); animation: menu-in 0.14s ease-out; transform-origin: top;
  max-height: 280px; overflow-y: auto;
}
.dd-opt {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px; border: none;
  border-radius: var(--radius); background: transparent; font-size: 15px; text-align: left; color: var(--text);
}
.dd-opt:hover, .dd-opt:focus-visible { background: var(--hover); outline: none; }
.dd-opt.is-current { font-weight: 600; }
.dd-check { margin-left: auto; display: grid; color: var(--accent); }
.dd-check .ic { color: var(--accent); }

/* Status buttons on a lead: clear, tappable, colour-coded */
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-btn {
  display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  font-size: 14.5px; font-weight: 500; text-align: left; color: var(--text);
}
.status-btn:hover { background: var(--hover); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; background: var(--dot, var(--faint)); }
.status-btn.is-current { border-color: var(--dot); box-shadow: inset 0 0 0 1px var(--dot); font-weight: 600; }
.status-to_call { --dot: #9a988f; }
.status-no_answer { --dot: #b8b5ab; }
.status-call_back { --dot: #2f6fde; }
.status-awaiting { --dot: #1f8a83; }
.status-interested { --dot: #d49a00; }
.status-meeting { --dot: #7a4fd0; }
.status-won { --dot: #2b8a52; color: var(--ok-text); }
.status-lost { --dot: #c2412d; color: var(--danger); }
@media (min-width: 900px) {
  .status-grid { grid-template-columns: repeat(4, 1fr); }
  .view:has(.page-wide) { max-width: 1240px; }
  .pipe { grid-template-columns: repeat(8, 1fr); }
  .lead-table { border-top: none; }
  .lt-head, .lt-row {
    grid-template-columns: minmax(200px, 2.2fr) minmax(90px, 1fr) minmax(110px, 1.2fr) minmax(120px, 1.1fr) 130px 118px;
    grid-template-areas: none; gap: 0 16px;
  }
  .lt-head { display: grid; padding: 8px; border-bottom: 1px solid var(--border); font-size: 12.5px; font-weight: 500; color: var(--muted); }
  .lt-main, .lt-stage, .lt-next { grid-area: auto; }
  .lt-town, .lt-contact, .lt-phone { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lt-phone { font-variant-numeric: tabular-nums; }
  .lt-next, .lt-stage { justify-self: start; }
  .lead-main .status-grid { grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); }
  .status-btn { white-space: nowrap; }
  .lead-layout { grid-template-columns: minmax(0, 1fr) 340px; grid-template-areas: "main contact" "main details"; align-items: start; column-gap: 32px; }
  .lead-layout > .side-card { position: relative; }
}
.stage-interested { background: #fcefc9; color: #8a5a00; }
.stage-meeting { background: #ece4fb; color: #5f3aa6; }
.stage-won { background: var(--ok-bg); color: var(--ok-text); }
.stage-lost { background: var(--hover); color: var(--faint); }
:root[data-theme="dark"] .stage-interested { background: #4a3b17; color: #f2cf7a; }
:root[data-theme="dark"] .stage-meeting { background: #352a4a; color: #c9b2f2; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .stage-interested { background: #4a3b17; color: #f2cf7a; }
  :root:not([data-theme="light"]) .stage-meeting { background: #352a4a; color: #c9b2f2; }
}
.back-link { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; color: var(--muted); font-size: 14px; font-weight: 500; }
.back-link:hover { color: var(--text); }
.lead-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }
.lead-actions .btn { height: 44px; }
.contact-group { display: inline-flex; max-width: 100%; }
.contact-group > .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.contact-copy {
  border-radius: 0 var(--radius) var(--radius) 0; margin-left: 1px; min-width: 0;
  font-variant-numeric: tabular-nums; color: var(--text);
}
.contact-copy .ic { color: var(--muted); }
.contact-copy:hover .ic { color: var(--text); }
.contact-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: all; }
@media (max-width: 899px) {
  .lead-actions { display: grid; }
  .contact-group { display: flex; }
  .contact-group > .btn:first-child { flex-shrink: 0; }
  .contact-copy { flex: 1; justify-content: space-between; }
}
.next-when { display: flex; align-items: center; gap: 8px; }
.next-note { margin-top: 4px; font-size: 14px; color: var(--muted); }
.lead-fields { display: grid; gap: 12px; }
.lf { display: grid; gap: 4px; min-width: 0; }
.lf > span { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.lead-notes, .dialog-form textarea.cell-input { height: auto; padding: 10px; line-height: 1.5; resize: vertical; font-family: inherit; }
.call-log { border-top: 1px solid var(--border); }
.call-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.call-note { margin-top: 4px; font-size: 14px; white-space: pre-wrap; }
.last-called { font-size: 13px; margin-top: 10px; }
.chip-call-no_answer, .chip-call-note, .chip-call-call_back { background: var(--hover); color: var(--text); }
.chip-call-sent_email { background: var(--info-bg); color: var(--info-text); }
.chip-call-interested, .chip-call-meeting { background: #fcefc9; color: #8a5a00; }
.chip-call-won { background: var(--ok-bg); color: var(--ok-text); }
.chip-call-not_interested { background: var(--warn-bg); color: var(--warn-text); }
.dialog-sub { margin-top: -10px; }
.outcome-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.outcome {
  height: 42px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); font-size: 14px; font-weight: 500; text-align: left;
}
.outcome:hover { background: var(--hover); }
.outcome[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.quick-dates { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip-btn { height: 32px; padding: 0 10px; border: none; border-radius: 16px; background: var(--hover); font-size: 13px; font-weight: 500; }
.chip-btn:hover { background: var(--active); }
.script-text { white-space: pre-wrap; line-height: 1.6; padding: 14px; background: var(--panel); border-radius: var(--radius); max-height: 50dvh; overflow-y: auto; }
.script-edit { min-height: 220px; }
.script-text mark.fill { background: #fcefc9; color: #8a5a00; padding: 0 3px; border-radius: 4px; font-weight: 600; }
:root[data-theme="dark"] .script-text mark.fill { background: #4a3b17; color: #f2cf7a; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .script-text mark.fill { background: #4a3b17; color: #f2cf7a; } }
@media (min-width: 900px) {
  .search { max-width: 420px; }
  .lead-fields { grid-template-columns: 1fr 1fr; gap: 14px 20px; }
}
/* Loading screen: cup of chips */
.loader {
  display: grid; justify-items: center; gap: 14px; padding: 72px 16px;
  animation: loader-in 0.3s ease-out both;
}
.loader-cup { width: 96px; height: 96px; overflow: visible; }
.loader-cup .fry { fill: #f7b928; stroke: var(--text); stroke-width: 2.2; }
.loader-cup .cup { fill: var(--surface); stroke: var(--text); stroke-width: 2.5; stroke-linejoin: round; }
.loader-cup .cup-band { stroke: var(--text); stroke-width: 2.2; stroke-linecap: round; opacity: 0.35; }
.loader-text { color: var(--muted); font-size: 14px; }
.fry { animation: fry-pop 1.8s cubic-bezier(0.3, 0.7, 0.2, 1) infinite; }
.fry-2 { animation-delay: 0.09s; }
.fry-3 { animation-delay: 0.18s; }
.fry-4 { animation-delay: 0.27s; }
.fry-5 { animation-delay: 0.36s; }
@keyframes fry-pop {
  0% { translate: 0 40px; }
  32%, 72% { translate: 0 0; }
  100% { translate: 0 40px; }
}
@keyframes loader-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fry, .loader { animation: none; } }

/* Fill-up page */
.fill-wrap { max-width: 560px; margin: 0 auto; padding: 0 16px 24px; }
.fill-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 18px; }
.fill-title { margin-bottom: 20px; }
.fill-site { font-size: 22px; font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
.fill-sub { font-size: 13px; color: var(--muted); }
.done { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 48px 8px; }
.done-ic { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--ok-bg); color: var(--ok-text); margin-bottom: 8px; }
.done h1 { font-size: 22px; font-weight: 600; }
.done .btn { margin-top: 20px; max-width: 320px; }

.tpl-tabs { align-self: start; }
.tpl-pick { display: flex; gap: 8px; align-items: center; }
.tpl-pick [data-picker] { flex: 1; min-width: 0; }
.tpl-pick .btn { height: 40px; flex-shrink: 0; }
