/* ==========================================================================
   CRM app styles -- the "app" look (Figtree, dark or brand-colored header,
   bottom tab bar on phones, white cards on a warm off-white page).

   Brand color: --primary is the company's color from Settings -> Appearance
   (Company::themeStyleTag() writes it, plus the header colors, into every
   page's <head>). Everything below reads those variables.
   ========================================================================== */

:root {
    color-scheme: light;
    --bg: #fbfaf7;
    --card-bg: #ffffff;
    --text: #141413;
    --text-2: #3d3c37;
    --muted: #5f5e58;
    --border: #e6e4dd;
    --border-strong: #d5d3cc;
    --fill: #f1f0ec;
    --fill-2: #ecebe6;

    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-contrast: #fff;
    --brand-text: #1d4ed8;
    --primary-soft: #e8edfb;

    /* Header + nav -- "dark" style by default; the "brand" style overrides
       these from Company::themeStyleTag(). */
    --hdr-bg: #1c1c1a;
    --hdr-fg: #ffffff;
    --hdr-muted: #b8b7b0;
    --hdr-line: var(--primary);
    --nav-bg: #1c1c1a;
    --nav-fg: #b8b7b0;
    --nav-line: #1c1c1a;
    --nav-active: #ffffff;

    --error-bg: #f7dedc;
    --error-text: #8f1d17;
    --success-bg: #dcefe1;
    --success-text: #1d6b3a;
    --warn-bg: #fdebd3;
    --warn-text: #8a4b0f;
    --info-bg: #dde8f7;
    --info-text: #1f4e8c;
    --danger: #8f1d17;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow-fab: 0 6px 16px rgba(20, 20, 19, .25);
    --bottom-nav-h: 0px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: 'Figtree', system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.45;
    background: var(--bg);
    color: var(--text);
}

a { color: var(--brand-text); }
a:hover { color: var(--primary-hover); }

button, input, select, textarea { font-family: inherit; }

h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 8px; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 32px 0 12px; }
h3 { font-size: 1rem; font-weight: 700; }

.icon { flex-shrink: 0; display: block; }

.muted { color: var(--muted); }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Auth page ---------- */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--hdr-bg);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    border-radius: 18px;
    padding: 32px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .25);
}

.auth-card h1 { font-size: 1.35rem; margin: 0 0 20px; text-align: center; }

.auth-card form label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.auth-card form input:not([type="checkbox"]) {
    width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); font-size: 1rem; background: #fff;
}
.auth-card form button {
    width: 100%; min-height: 50px; margin-top: 20px; padding: 0 12px; background: var(--primary);
    color: var(--primary-contrast); border: none; border-radius: var(--radius); font-size: 1.05rem;
    font-weight: 700; cursor: pointer;
}
.auth-card form button:hover { background: var(--primary-hover); }

/* ---------- Alerts ---------- */

.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 0.92rem; margin: 0 0 16px; font-weight: 500; }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-warn { background: var(--warn-bg); color: var(--warn-text); }

/* ==========================================================================
   App bar (top) + title band + bottom tab bar
   ========================================================================== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px;
    min-height: 60px;
    background: var(--hdr-bg);
    color: var(--hdr-fg);
}

.topbar-left { display: flex; align-items: center; gap: 24px; flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 6px; }

.topbar-brand {
    display: flex; align-items: center; gap: 10px; color: var(--hdr-fg);
    text-decoration: none; min-width: 0;
}
.topbar-brand:hover { color: var(--hdr-fg); }
.topbar-company { font-weight: 800; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Always constrained to a small header logo regardless of the uploaded
   image's own dimensions. White tile behind it so a dark logo still shows
   on the dark header. */
.topbar-logo {
    height: 34px; width: auto; max-width: 120px; max-height: 34px; object-fit: contain; flex-shrink: 0;
    background: #fff; border-radius: 8px; padding: 3px 5px;
}
.topbar-monogram {
    width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: var(--primary-contrast);
    display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; flex-shrink: 0;
}

.topnav { display: flex; gap: 2px; align-items: stretch; align-self: stretch; }
.topnav a {
    display: flex; align-items: center; color: var(--hdr-muted); text-decoration: none;
    font-size: .95rem; font-weight: 700; padding: 0 12px; border-bottom: 4px solid transparent;
    border-top: 4px solid transparent;
}
.topnav a:hover { color: var(--hdr-fg); }
.topnav a.active { color: var(--hdr-fg); border-bottom-color: var(--hdr-line); }

.topbar-icon-btn, .topnav-settings {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; min-width: 44px; padding: 0 10px; border-radius: 22px; border: 0;
    background: transparent; color: var(--hdr-muted); text-decoration: none; font-weight: 700;
    font-size: .92rem; cursor: pointer;
}
.topbar-icon-btn:hover, .topnav-settings:hover, .topnav-settings.active { color: var(--hdr-fg); background: rgba(255, 255, 255, .08); }
.topbar-right form { margin: 0; }

.link-button {
    background: none;
    border: none;
    color: var(--brand-text);
    cursor: pointer;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 0;
}
.link-button.danger { color: var(--danger); }

/* Title band: the big page title in the header color, right under the app
   bar -- set $titleBar before including partials/header.php. */
.title-band { background: var(--hdr-bg); color: var(--hdr-fg); }
.title-band-inner {
    max-width: 1000px; margin: 0 auto; padding: 14px 24px 18px;
    display: flex; align-items: center; gap: 6px;
}
.title-band h1 { margin: 0; font-size: 1.75rem; font-weight: 700; flex: 1; min-width: 0; color: var(--hdr-fg); }
.title-band .title-sub { display: block; font-size: .9rem; font-weight: 500; color: var(--hdr-muted); margin-top: 2px; }
.title-band .band-btn {
    width: 44px; height: 44px; border: 0; padding: 0; background: transparent; color: var(--hdr-fg);
    display: inline-flex; align-items: center; justify-content: center; border-radius: 22px; cursor: pointer;
    text-decoration: none; flex-shrink: 0;
}
.title-band .band-btn:hover { background: rgba(255, 255, 255, .1); color: var(--hdr-fg); }
.title-band .band-action {
    display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
    border-radius: 20px; background: var(--primary); color: var(--primary-contrast); font-weight: 700;
    text-decoration: none; font-size: .92rem; border: 0; cursor: pointer;
}
.title-band .band-action:hover { background: var(--primary-hover); color: var(--primary-contrast); }
.title-tabs { max-width: 1000px; margin: 0 auto; padding: 0 12px; display: flex; overflow-x: auto; scrollbar-width: none; }
.title-tabs::-webkit-scrollbar { display: none; }
.title-tabs a {
    flex: 1 0 auto; min-height: 48px; display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 0 12px; color: var(--hdr-muted); text-decoration: none; font-weight: 700; font-size: .95rem;
    border-bottom: 4px solid transparent; white-space: nowrap;
}
.title-tabs a:hover { color: var(--hdr-fg); }
.title-tabs a.active { color: var(--hdr-fg); border-bottom-color: var(--hdr-line); }
.title-tabs .tab-count { font-size: .78rem; font-weight: 700; opacity: .8; }

/* Bottom tab bar -- phones only (see the media query at the end). */
.bottom-nav { display: none; }
.more-sheet { display: none; }

/* ---------- Layout ---------- */

.page {
    max-width: 1000px;
    margin: 28px auto;
    padding: 0 24px 96px;
}
.page.page-tight { margin-top: 16px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.breadcrumb { font-size: .92rem; margin: 0 0 12px; }
.breadcrumb a { text-decoration: none; font-weight: 600; }

/* ---------- Cards + list rows (the app design's building blocks) ---------- */

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
}
.card + .card { margin-top: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }

.list-group { margin: 0 0 8px; }
.list-group-title {
    font-size: 1.05rem; font-weight: 800; padding: 20px 0 8px; margin: 0;
    border-bottom: 2px solid var(--text);
}
.list-group-title.letter { font-size: .95rem; }

.list-row {
    display: flex; align-items: center; gap: 12px; width: 100%;
    min-height: 68px; padding: 12px 0; border: 0; border-bottom: 1px solid var(--border);
    background: transparent; color: var(--text); text-decoration: none; text-align: left;
}
a.list-row:hover { color: var(--text); background: linear-gradient(90deg, transparent, var(--fill) 20%, var(--fill) 80%, transparent); }
.list-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.list-row-title { font-size: 1.08rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.list-row-sub { font-size: .9rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.list-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.list-row-amount { font-size: 1.05rem; font-weight: 600; white-space: nowrap; }
.list-empty { padding: 40px 12px; text-align: center; color: var(--muted); }

/* Status chips (square-ish, uppercase -- matches the app mockups) */
.chip {
    display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    padding: 4px 10px; border-radius: 6px; background: var(--fill-2); color: #4a4943; white-space: nowrap;
}
.chip-draft { background: var(--fill-2); color: #4a4943; }
.chip-sent, .chip-due, .chip-unpaid, .chip-scheduled { background: var(--info-bg); color: var(--info-text); }
.chip-viewed, .chip-partial, .chip-quoted, .chip-in_progress { background: var(--warn-bg); color: var(--warn-text); }
.chip-accepted, .chip-paid, .chip-completed, .chip-approved { background: var(--success-bg); color: var(--success-text); }
.chip-declined, .chip-overdue, .chip-cancelled { background: var(--error-bg); color: var(--error-text); }
.chip-void, .chip-lost { background: var(--fill-2); color: var(--muted); }
.chip-lead { background: #e9e4f5; color: #4d3a80; }

/* Floating action button */
.fab {
    position: fixed; right: max(20px, calc((100vw - 1000px) / 2 - 84px)); bottom: calc(24px + var(--bottom-nav-h));
    z-index: 15; width: 60px; height: 60px; border-radius: 30px; border: 0; background: var(--primary);
    color: var(--primary-contrast); display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-fab); cursor: pointer; text-decoration: none;
}
.fab:hover { background: var(--primary-hover); color: var(--primary-contrast); }

/* Round icon actions (Call / Text / Email / Directions) */
.action-circles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.action-circle {
    display: flex; flex-direction: column; align-items: center; gap: 6px; border: 0; background: transparent;
    padding: 0; font-size: .82rem; font-weight: 600; color: var(--text); text-decoration: none; cursor: pointer;
    text-align: center; line-height: 1.25;
}
.action-circle:hover { color: var(--text); }
.action-circle .circle {
    width: 52px; height: 52px; border-radius: 26px; background: var(--primary); color: var(--primary-contrast);
    display: flex; align-items: center; justify-content: center;
}
.action-circle:hover .circle { background: var(--primary-hover); }
.action-circle.neutral .circle { background: var(--fill); color: var(--text); }
.action-circle.neutral:hover .circle { background: var(--fill-2); }
.action-circle.is-disabled { opacity: .4; pointer-events: none; }

/* Label/value card (Phone / Email / Address) */
.kv-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px; }
.kv-row { padding: 12px 0; border-bottom: 1px solid var(--border); }
.kv-row:last-child { border-bottom: 0; }
.kv-label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.kv-value { font-size: 1.05rem; padding-top: 2px; overflow-wrap: anywhere; }
.kv-value a { text-decoration: none; }

/* Snapshot tiles */
.snapshot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.snapshot-tile { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.snapshot-value { font-size: 1.35rem; font-weight: 700; }
.snapshot-label { font-size: .82rem; color: var(--muted); padding-top: 2px; }

/* Menu rows inside a card (Estimates > / Invoices > / Jobs >) */
.menu-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.menu-row {
    display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 0 16px; border-bottom: 1px solid var(--border);
    color: var(--text); text-decoration: none; font-size: 1.05rem;
}
.menu-row:last-child { border-bottom: 0; }
.menu-row:hover { background: var(--fill); color: var(--text); }
.menu-row-label { flex: 1; }
.menu-row-count { font-size: .9rem; color: var(--muted); }
.menu-row .icon { color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 20px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* Big full-width button */
.btn-block {
    display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
    min-height: 54px; border: 0; border-radius: var(--radius); background: var(--primary);
    color: var(--primary-contrast); font-size: 1.05rem; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn-block:hover { background: var(--primary-hover); color: var(--primary-contrast); }
.btn-block.secondary { background: #fff; color: var(--text); border: 1px solid var(--border-strong); }
.btn-block.secondary:hover { background: var(--fill); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
    padding: 0 16px; border-radius: var(--radius-sm); border: 0; background: var(--primary);
    color: var(--primary-contrast); font-weight: 700; font-size: .95rem; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--primary-hover); color: var(--primary-contrast); }
.btn-outline { background: #fff; color: var(--brand-text); border: 2px solid var(--brand-text); }
.btn-outline:hover { background: var(--primary-soft); color: var(--brand-text); }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: var(--fill); color: var(--text); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #e8b9b5; }
.btn-danger:hover { background: var(--error-bg); color: var(--danger); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .88rem; border-radius: 9px; }

/* Status banner under the title band (Viewed / Signed / Cancelled) */
.status-banner {
    display: flex; align-items: center; gap: 8px; padding: 10px 24px; font-size: .92rem; font-weight: 600;
    background: var(--warn-bg); color: var(--warn-text);
}
.status-banner .grow { flex: 1; }
.status-banner strong { font-weight: 800; letter-spacing: .02em; }
.status-banner.good { background: var(--success-bg); color: var(--success-text); }
.status-banner.bad { background: var(--error-bg); color: var(--error-text); }
.status-banner.info { background: var(--info-bg); color: var(--info-text); }
.status-banner.neutral { background: var(--fill-2); color: var(--text-2); }
.status-banner-inner { max-width: 1000px; margin: 0 auto; width: 100%; display: flex; align-items: center; gap: 8px; }

/* Bottom sheet (estimate actions, "More" menu) */
.sheet-backdrop {
    position: fixed; inset: 0; z-index: 40; background: rgba(20, 20, 19, .5);
    display: none; flex-direction: column; justify-content: flex-end; align-items: center;
}
.sheet-backdrop.open { display: flex; }
.sheet {
    width: 100%; max-width: 560px; background: #fff; border-radius: 22px 22px 0 0;
    padding: 12px 20px calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 18px;
}
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); align-self: center; }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.sheet-head h2 { margin: 0; font-size: 1.15rem; flex: 1; }
.sheet-close {
    width: 44px; height: 44px; border: 0; padding: 0; background: var(--fill); border-radius: 22px;
    display: flex; align-items: center; justify-content: center; color: var(--text); cursor: pointer;
}
.sheet-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 8px; }
.sheet-grid form { margin: 0; display: contents; }
.sheet-grid .action-circle { font-size: .88rem; }
.sheet-grid .action-circle .circle { width: 58px; height: 58px; border-radius: 29px; }
.sheet-list { display: flex; flex-direction: column; }
.sheet-list a, .sheet-list button {
    display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 0 4px; border: 0; background: none;
    border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 1.05rem;
    font-weight: 600; text-align: left; width: 100%; cursor: pointer;
}
.sheet-list form { margin: 0; }
.sheet-list a:last-child, .sheet-list form:last-child button { border-bottom: 0; }

/* Segmented control (Text message | Email, Dark | Brand color) */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); background: var(--fill-2); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented a, .segmented button, .segmented label {
    min-height: 44px; border: 0; border-radius: 9px; font-size: 1rem; font-weight: 700; background: transparent;
    color: var(--text-2); display: flex; align-items: center; justify-content: center; text-decoration: none; cursor: pointer;
    margin: 0 !important;
}
.segmented .active, .segmented input:checked + span { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.segmented label { padding: 0; }
.segmented label input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label span { width: 100%; height: 100%; min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 9px; }

/* Signature pad (customer signing + in-person signing) */
.signature-box {
    height: 170px; background: #fff; border: 2px dashed #c9c7bf; border-radius: var(--radius); position: relative; touch-action: none;
}
.signature-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.signature-box .sig-line { position: absolute; left: 20px; right: 20px; bottom: 34px; border-top: 1px solid #c9c7bf; pointer-events: none; }
.signature-box .sig-hint { position: absolute; left: 20px; bottom: 10px; font-size: .82rem; color: var(--muted); pointer-events: none; }

/* ---------- Forms (data entry pages) ---------- */

.stacked-form { display: flex; flex-direction: column; max-width: 560px; }
.stacked-form label { font-size: 0.88rem; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }
.stacked-form input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
.stacked-form select,
.stacked-form textarea {
    min-height: 48px;
    padding: 10px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: inherit;
    width: 100%;
    background: #fff;
    color: var(--text);
}
.stacked-form textarea { resize: vertical; line-height: 1.45; }
.stacked-form input:focus, .stacked-form select:focus, .stacked-form textarea:focus,
.inline-form input:focus, .inline-form select:focus, .search-form input:focus {
    outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary);
}
.stacked-form input[type="checkbox"], .stacked-form input[type="radio"] { width: 20px; height: 20px; accent-color: var(--primary); }
.checkbox-label {
    display: flex !important; align-items: flex-start; gap: 12px; font-size: 0.95rem !important; margin: 14px 0 !important;
    font-weight: 500 !important; color: var(--text-2) !important; line-height: 1.45;
}
.checkbox-label input { margin: 1px 0 0; flex-shrink: 0; }
.field-help { margin: 4px 0 0; font-size: .84rem; color: var(--muted); }

/* ---------- Theme color swatches (Settings -> Appearance) ---------- */
.theme-swatches { display: flex; flex-wrap: wrap; gap: 14px; margin: 10px 0; align-items: center; }
.theme-swatch {
    width: 44px; height: 44px; border-radius: 50%; border: 0;
    cursor: pointer; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}
.theme-swatch:hover { transform: scale(1.06); }
.theme-swatch.active { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--text); }

.stacked-form button:not(.theme-swatch):not(.link-button):not(.contract-toggle-btn):not(.secondary-button):not(.remove-row) {
    margin-top: 18px;
    align-self: flex-start;
    min-height: 48px;
    padding: 0 22px;
    background: var(--primary);
    color: var(--primary-contrast);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
}
.stacked-form button:not(.theme-swatch):not(.link-button):not(.contract-toggle-btn):not(.secondary-button):not(.remove-row):hover { background: var(--primary-hover); }

.form-row { display: flex; gap: 12px; }
.form-row > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.form-row-3 > div { flex: 1; }

.inline-form { display: inline-flex; align-items: center; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.inline-form label { font-weight: 600; color: var(--muted); font-size: .9rem; }
.inline-form select, .inline-form input:not([type="checkbox"]):not([type="hidden"]):not([type="file"]) {
    min-height: 42px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 9px; font-size: .95rem; background: #fff;
}
.inline-form button:not(.link-button) {
    min-height: 42px; padding: 0 16px; background: var(--primary); color: var(--primary-contrast); border: none;
    border-radius: 9px; font-size: 0.92rem; font-weight: 700; cursor: pointer;
}
.inline-form button:not(.link-button):hover { background: var(--primary-hover); }

.search-form { display: flex; gap: 8px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.search-form input {
    flex: 1; min-height: 46px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: 12px;
    min-width: 200px; font-size: 1rem; background: #fff;
}
.search-form button {
    min-height: 46px; padding: 0 16px; border: 1px solid var(--border-strong); background: #fff;
    border-radius: 12px; cursor: pointer; font-weight: 700; color: var(--text);
}

.add-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 16px 0;
}
.add-panel summary { cursor: pointer; font-weight: 700; font-size: 1rem; color: var(--brand-text); min-height: 28px; }
.add-panel[open] summary { margin-bottom: 8px; }

/* ---------- Tables ---------- */

.data-table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.95rem; vertical-align: middle; }
.data-table th { background: var(--bg); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; }
.data-table tr:last-child td { border-bottom: none; }
.data-table a { color: var(--brand-text); text-decoration: none; font-weight: 600; }
.data-table a:hover { text-decoration: underline; }

/* ---------- Detail grid (client/job read-only fields) ---------- */

.detail-grid {
    display: grid; grid-template-columns: 170px 1fr; gap: 0; max-width: 680px; margin: 0 0 16px;
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px;
}
.detail-grid dt, .detail-grid dd { padding: 11px 0; border-bottom: 1px solid var(--border); }
.detail-grid dt { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.detail-grid dd { margin: 0; font-size: 1rem; }
.detail-grid dt:nth-last-of-type(1), .detail-grid dd:last-of-type { border-bottom: 0; }

/* ---------- Status badges (older pages -- same palette as .chip) ---------- */

.badge { display: inline-block; padding: 4px 10px; border-radius: 6px; font-size: 0.72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; vertical-align: middle; }
.badge-lead        { background: #e9e4f5; color: #4d3a80; }
.badge-quoted      { background: var(--warn-bg); color: var(--warn-text); }
.badge-scheduled   { background: var(--info-bg); color: var(--info-text); }
.badge-in_progress { background: var(--warn-bg); color: var(--warn-text); }
.badge-completed   { background: var(--success-bg); color: var(--success-text); }
.badge-lost        { background: var(--fill-2); color: var(--muted); }

.badge-photo-before { background: var(--fill-2); color: var(--text-2); }
.badge-photo-after  { background: var(--success-bg); color: var(--success-text); }
.badge-photo-other  { background: var(--info-bg); color: var(--info-text); }

.badge-est-draft     { background: var(--fill-2); color: #4a4943; }
.badge-est-sent      { background: var(--info-bg); color: var(--info-text); }
.badge-est-viewed    { background: var(--warn-bg); color: var(--warn-text); }
.badge-est-accepted  { background: var(--success-bg); color: var(--success-text); }
.badge-est-declined  { background: var(--error-bg); color: var(--error-text); }
.badge-est-cancelled { background: var(--error-bg); color: var(--error-text); }

.badge-inv-unpaid  { background: var(--error-bg); color: var(--error-text); }
.badge-inv-partial { background: var(--warn-bg); color: var(--warn-text); }
.badge-inv-paid    { background: var(--success-bg); color: var(--success-text); }
.badge-inv-void    { background: var(--fill-2); color: var(--muted); }

.badge-pay-pending   { background: var(--warn-bg); color: var(--warn-text); }
.badge-pay-succeeded { background: var(--success-bg); color: var(--success-text); }
.badge-pay-failed    { background: var(--error-bg); color: var(--error-text); }

.badge-rr-sent   { background: var(--success-bg); color: var(--success-text); }
.badge-rr-failed { background: var(--error-bg); color: var(--error-text); }

.badge-import-new       { background: var(--success-bg); color: var(--success-text); }
.badge-import-duplicate { background: var(--fill-2); color: var(--muted); }
.badge-import-error     { background: var(--error-bg); color: var(--error-text); }

.map-link { color: var(--brand-text); text-decoration: none; }
.map-link:hover { text-decoration: underline; }
.map-link::after { content: " \2197"; font-size: 0.8em; }

.tel-link { color: var(--brand-text); text-decoration: none; }
.tel-link:hover { text-decoration: underline; }

/* ---------- Estimates ---------- */

.button-link {
    display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 16px; background: var(--primary);
    color: var(--primary-contrast); border-radius: var(--radius-sm); text-decoration: none; font-size: 0.92rem; font-weight: 700;
}
.button-link:hover { background: var(--primary-hover); color: var(--primary-contrast); }

.secondary-button {
    margin-top: 10px; min-height: 42px; padding: 0 14px; background: #fff; border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm); font-size: 0.9rem; font-weight: 700; cursor: pointer; color: var(--text);
}
.secondary-button:hover { border-color: var(--brand-text); color: var(--brand-text); }

.share-link-row { display: flex; gap: 8px; align-items: center; max-width: 680px; margin-bottom: 16px; flex-wrap: wrap; }
.share-link-row input {
    flex: 1; min-width: 200px; min-height: 44px; padding: 0 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 0.88rem; background: var(--bg); color: var(--muted);
}

#items-table input { width: 100%; min-height: 42px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; font-size: 0.95rem; }
#items-table td { vertical-align: middle; }
.line-total { font-weight: 700; white-space: nowrap; }

.totals-box { max-width: 420px; margin-top: 16px; }
.totals-summary { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; max-width: 300px; margin: 16px 0 0; }
.totals-summary dt { color: var(--muted); font-size: 0.95rem; }
.totals-summary dd { margin: 0; text-align: right; font-size: 1rem; }
.totals-summary .totals-grand { font-size: 1.25rem; font-weight: 800; color: var(--text); }

.contract-section { max-width: 680px; margin-top: 24px; }
.contract-toggle { display: inline-flex; background: var(--fill-2); border-radius: 12px; padding: 4px; gap: 4px; margin-top: 4px; }
.contract-toggle-btn {
    min-height: 40px; padding: 0 18px; background: transparent; border: none; border-radius: 9px;
    font-size: 0.92rem; font-weight: 700; cursor: pointer; color: var(--muted);
}
.contract-toggle-btn:hover { color: var(--text); }
.contract-toggle-btn.active { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
fieldset:disabled { opacity: 0.65; }
fieldset:disabled .contract-toggle-btn, fieldset:disabled input, fieldset:disabled textarea, fieldset:disabled select { cursor: not-allowed; }
.contract-preview {
    margin-top: 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--bg); font-size: 0.88rem; white-space: pre-wrap; max-height: 220px; overflow-y: auto;
}

/* Estimate "paper" preview (estimate page, signed copy) */
.doc-preview-wrap { background: #efeee9; border-radius: var(--radius); padding: 16px; }
.doc-paper {
    background: #fff; border-radius: 10px; padding: 22px 20px; box-shadow: 0 1px 3px rgba(20,20,19,.12);
    display: flex; flex-direction: column; gap: 16px; max-width: 760px; margin: 0 auto;
}
.doc-paper-head { display: flex; gap: 12px; align-items: center; }
.doc-paper-logo { width: 48px; height: 48px; border-radius: 10px; object-fit: contain; background: #fff; border: 1px solid var(--border); }
.doc-paper-mono { width: 48px; height: 48px; border-radius: 10px; background: var(--primary); color: var(--primary-contrast); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.05rem; }
.doc-paper-company { flex: 1; display: flex; flex-direction: column; }
.doc-paper-company strong { font-size: .98rem; }
.doc-paper-company span { font-size: .8rem; color: var(--muted); }
.doc-paper-kind { font-size: .78rem; font-weight: 700; letter-spacing: .1em; color: var(--brand-text); }
.doc-paper-parties { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; font-size: .88rem; line-height: 1.45; }
.doc-paper-lines { border-top: 2px solid var(--text); }
.doc-paper-line { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.doc-paper-line-main { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.doc-paper-line-main strong { font-size: .95rem; font-weight: 600; }
.doc-paper-line-main span { font-size: .8rem; color: var(--muted); }
.doc-paper-line-price { font-size: .95rem; font-weight: 600; white-space: nowrap; }
.doc-paper-total { display: flex; justify-content: flex-end; gap: 24px; font-size: 1.05rem; font-weight: 800; }
.approval-box { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.approval-box .eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.approval-box img { max-width: 240px; max-height: 80px; }
.approval-box .who { border-top: 1px solid #c9c7bf; padding-top: 8px; font-size: .88rem; line-height: 1.5; }

/* Backlog ("To schedule") */
.backlog-summary {
    margin-top: 18px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; display: flex; flex-direction: column; gap: 4px;
}
.backlog-summary .eyebrow { font-size: .8rem; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.backlog-summary .big { font-size: 2rem; font-weight: 800; letter-spacing: -.01em; }
.backlog-summary .sub { font-size: .9rem; color: var(--text-2); }
.wait { font-size: .82rem; font-weight: 700; color: var(--muted); }
.wait-warn { color: var(--warn-text); }
.wait-late { color: var(--error-text); }
.backlog-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.backlog-actions form { margin: 0; }

/* ---------- Dashboard pipeline stat tiles ---------- */

.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; margin: 16px 0 24px; }
.stat-tile {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; text-decoration: none; color: var(--text);
}
.stat-tile:hover { border-color: var(--brand-text); color: var(--text); }
.stat-count { font-size: 1.6rem; font-weight: 800; }
.stat-label { font-size: 0.85rem; color: var(--muted); font-weight: 600; }

/* ---------- Status tabs (jobs list etc.) ---------- */

.status-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.status-tabs a {
    min-height: 38px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 19px; font-size: 0.9rem;
    text-decoration: none; font-weight: 700; color: var(--text-2); background: var(--card-bg); border: 1px solid var(--border);
}
.status-tabs a:hover { border-color: var(--text-2); }
.status-tabs a.active { background: var(--text); color: #fff; border-color: var(--text); }

/* ---------- Invoices / payments ---------- */

.balance-due { font-weight: 800; }
.balance-due.paid-up { color: var(--success-text); }

.pay-box {
    max-width: 440px; margin: 20px 0; padding: 18px 20px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--card-bg);
}
.pay-box .totals-summary { margin-top: 0; }
.pay-box .amount-input-row { display: flex; align-items: center; gap: 6px; margin: 12px 0; }
.pay-box .amount-input-row input { width: 150px; min-height: 44px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 1rem; }

/* ---------- Photos ---------- */

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 12px 0 24px; }
.photo-card { margin: 0; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.photo-card img { width: 100%; height: 150px; object-fit: cover; display: block; }
.photo-card figcaption { padding: 8px 10px; font-size: 0.85rem; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }

/* ---------- Notes ---------- */

.note-list { list-style: none; padding: 0; margin: 16px 0; max-width: 680px; }
.note-list li { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; }
.note-list li.note-system { background: transparent; border-style: dashed; }
.note-list p { margin: 4px 0 0; font-size: 0.95rem; }
.note-meta { font-size: 0.78rem; color: var(--muted); font-weight: 700; }

/* ---------- Schedule (office) ---------- */

.schedule-date-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.schedule-date-nav input[type="date"] { min-height: 42px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 9px; }

.schedule-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; margin-top: 16px; }

.schedule-crew-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.schedule-crew-card.schedule-crew-inactive { opacity: 0.6; }
.schedule-crew-card h2 { margin: 0 0 10px; font-size: 1.05rem; display: flex; align-items: center; gap: 8px; }

.schedule-job-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.schedule-job-list li { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.schedule-job-list li.schedule-job-done { background: var(--bg); }
.schedule-job-list li.schedule-job-done .schedule-job-main a { text-decoration: line-through; color: var(--muted); }
.schedule-job-main { display: flex; flex-direction: column; gap: 4px; font-size: 0.95rem; }
.schedule-job-main a { color: var(--text); text-decoration: none; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.schedule-job-note { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }
.schedule-job-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.schedule-job-actions .link-button { font-size: 0.88rem; }
.schedule-job-actions button[disabled] { opacity: 0.3; cursor: default; }

/* ---------- Crew "My Jobs" (crew view + office preview) ---------- */

.crew-job-list { list-style: none; margin: 16px 0; padding: 0; display: flex; flex-direction: column; gap: 12px; max-width: 680px; }
.crew-job-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.crew-job-card.crew-job-done { background: var(--bg); }
.crew-job-card.crew-job-done .crew-job-client { text-decoration: line-through; color: var(--muted); }
.crew-job-main { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 200px; }
.crew-job-client { color: var(--text); text-decoration: none; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.crew-job-desc { margin: 2px 0 0; font-size: 0.9rem; color: var(--text-2); }
.crew-job-actions { margin: 0; }
.crew-job-actions button { min-height: 48px; padding: 0 18px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--card-bg); font-weight: 700; cursor: pointer; }
.crew-job-actions button.crew-job-done-btn { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }
.crew-job-actions button.crew-job-done-btn:hover { background: var(--primary-hover); }

/* ---------- Team permissions ---------- */

.perm-list { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 0; }
.perm-list .checkbox-label { margin: 8px 0 !important; }
.perm-list .perm-help { display: block; font-size: .82rem; color: var(--muted); font-weight: 400; }
.perm-default { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-left: 6px; }

/* ---------- Settings sections ---------- */

.settings-section { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 20px 20px; margin: 0 0 20px; }
.settings-section > h2:first-child { margin-top: 16px; }
.settings-section .stacked-form { max-width: 100%; }

/* ==========================================================================
   Phones and small tablets
   ========================================================================== */

@media (max-width: 860px) {
    :root { --bottom-nav-h: 76px; }

    body { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }

    .topbar { min-height: 56px; padding: 0 12px 0 16px; }
    /* On phones the big title band IS the header (like the app mockups);
       the bottom tabs + "More" cover navigation and signing out. */
    .has-title-band .topbar { display: none; }
    .title-band-inner { padding-top: calc(14px + env(safe-area-inset-top)); }
    .title-band .hide-phone { display: none; }
    .topnav, .topbar-right .topnav-settings, .topbar-right .signout-form { display: none; }

    .title-band-inner { padding: 12px 12px 14px 20px; }
    .title-band h1 { font-size: 1.6rem; }
    .title-band .band-btn:first-child { margin-left: -12px; }

    .bottom-nav {
        display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--nav-bg); border-top: 1px solid var(--nav-line);
    }
    .bottom-nav a, .bottom-nav button {
        border: 0; background: transparent; padding: 8px 0 10px; display: flex; flex-direction: column;
        align-items: center; justify-content: center; gap: 4px; font-size: .75rem; font-weight: 700;
        color: var(--nav-fg); text-decoration: none; cursor: pointer;
    }
    .bottom-nav .pill { width: 56px; height: 32px; border-radius: 16px; display: flex; align-items: center; justify-content: center; }
    .bottom-nav .active { color: var(--nav-active); }
    .bottom-nav .active .pill { background: var(--primary); color: var(--primary-contrast); }

    .page { padding: 0 16px 110px; margin: 18px auto; }

    .page-head { flex-direction: column; align-items: flex-start; gap: 10px; }
    .page-head > div { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; }

    .two-col { grid-template-columns: 1fr; }

    .form-row, .form-row-3 { flex-direction: column; gap: 0; }

    .data-table { display: block; overflow-x: auto; white-space: nowrap; }
    .data-table th, .data-table td { padding: 10px 12px; }

    .detail-grid { grid-template-columns: 1fr; padding: 4px 16px; }
    .detail-grid dt { padding: 12px 0 0; border-bottom: 0; }
    .detail-grid dd { padding: 2px 0 12px; }

    .stacked-form, .totals-box, .share-link-row, .pay-box { max-width: 100%; }
    .stacked-form button:not(.theme-swatch):not(.link-button):not(.contract-toggle-btn):not(.secondary-button):not(.remove-row) { align-self: stretch; min-height: 52px; }

    .auth-card { padding: 26px 20px; }

    .schedule-board { grid-template-columns: 1fr; }
    .schedule-date-nav { gap: 8px; }
    .crew-job-card { flex-direction: column; align-items: stretch; }
    .crew-job-actions button { width: 100%; }

    .status-banner { padding: 10px 16px; }
    .settings-section { padding: 2px 16px 16px; }

    .more-sheet.open { display: flex; }
}

@media (min-width: 861px) {
    .only-phone { display: none !important; }
}

@media print {
    .topbar, .bottom-nav, .fab, .title-band .band-btn, .no-print { display: none !important; }
    body { background: #fff; padding: 0; }
}
.list-row > .icon { color: var(--muted); }
.inline-date summary { list-style: none; }
.inline-date summary::-webkit-details-marker { display: none; }
.inline-date[open] summary { background: var(--fill); }
button[disabled], .btn-block[disabled] { opacity: .5; cursor: not-allowed; }

/* Add panels opened from a floating + button stay out of the way until then. */
.fab-panel:not([open]) { display: none; }
.title-band h1 { overflow-wrap: anywhere; }
.backlog-row { flex-wrap: wrap; }
@media (max-width: 560px) {
    .backlog-row .list-row-main { flex-basis: 100%; }
    .backlog-row .list-row-side { flex-basis: 100%; flex-direction: row; justify-content: space-between; align-items: center; }
}

/* ==========================================================================
   Estimate visits: route planner, route list, estimator's day
   ========================================================================== */

.route-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.route-map-col { position: sticky; top: 76px; }
.route-map {
    width: 100%; height: calc(100vh - 230px); min-height: 360px; border-radius: var(--radius);
    border: 1px solid var(--border); background: #e9e7e0; overflow: hidden;
}
.route-map-empty { display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--muted); font-size: .95rem; }
.map-info { font-family: 'Figtree', system-ui, sans-serif; font-size: 13px; line-height: 1.4; max-width: 220px; }

.planner-settings { padding: 14px 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.form-grid label, .block-label { display: flex; flex-direction: column; gap: 5px; font-size: .84rem; font-weight: 600; color: var(--muted); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid label[hidden] { display: none; }
.form-grid input, .form-grid select, .block-label input {
    min-height: 44px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 9px; font-size: .98rem;
    background: #fff; color: var(--text); width: 100%;
}
.block-label { margin-top: 10px; }

.pick-head { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0 4px; }
.pick-head h2 { margin: 0; font-size: 1.05rem; }
.pick-list { border-top: 2px solid var(--text); }
.pick-row { border-bottom: 1px solid var(--border); padding: 10px 0; }
.pick-row.is-picked { background: linear-gradient(90deg, var(--primary-soft), transparent 70%); }
.pick-row.is-blocked .pick-main { opacity: .6; }
.pick-main { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.pick-main input[type="checkbox"] { width: 22px; height: 22px; margin: 3px 0 0 4px; accent-color: var(--primary); flex-shrink: 0; }
.pick-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.pick-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.pick-meta .chip { text-transform: none; letter-spacing: 0; font-size: .76rem; font-weight: 600; }
.pick-warn { font-size: .84rem; font-weight: 700; color: var(--warn-text); }
.pick-note { font-size: .86rem; color: var(--text-2); background: var(--fill); border-radius: 8px; padding: 6px 10px; }
.pick-edit { margin: 8px 0 0 38px; }
.pick-edit > summary, .sendback > summary { list-style: none; display: inline-flex; }
.pick-edit > summary::-webkit-details-marker, .sendback > summary::-webkit-details-marker { display: none; }
.restrictions { margin-top: 10px; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.day-picks { border: 0; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.day-picks legend { font-size: .84rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; padding: 0; }
.day-picks label { position: relative; }
.day-picks input { position: absolute; opacity: 0; }
.day-picks label span {
    display: inline-flex; align-items: center; justify-content: center; min-width: 48px; min-height: 40px; padding: 0 10px;
    border: 1px solid var(--border-strong); border-radius: 20px; font-weight: 700; font-size: .9rem; cursor: pointer; background: #fff;
}
.day-picks label input:checked + span { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }
.day-picks label input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.restrictions-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.sticky-bar {
    position: sticky; bottom: 12px; z-index: 12; margin-top: 16px; display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 10px 10px 10px 18px; background: var(--hdr-bg); color: var(--hdr-fg); border-radius: 16px;
    box-shadow: 0 8px 24px rgba(20,20,19,.25); font-weight: 700;
}
.sticky-bar .btn { min-height: 48px; }

.route-summary .eyebrow { font-size: .78rem; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.route-summary-main { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.route-summary-main div { display: flex; flex-direction: column; }
.route-summary-main strong { font-size: 1.2rem; font-weight: 800; }
.route-summary-main span { font-size: .8rem; color: var(--muted); }

.route-stops { list-style: none; margin: 12px 0 0; padding: 0; position: relative; }
.route-stop { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--border); position: relative; }
.route-stop:last-child { border-bottom: 0; }
.route-num {
    width: 30px; height: 30px; border-radius: 15px; background: var(--primary); color: var(--primary-contrast); font-weight: 800;
    font-size: .88rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.route-end .route-num { background: var(--text); color: #fff; }
.route-stop-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.route-stop-main > span { font-size: .88rem; color: var(--muted); }
.route-stop-main a { color: var(--text); text-decoration: none; }
.route-time { font-weight: 800; white-space: nowrap; text-align: right; display: flex; flex-direction: column; }
.route-time small { font-weight: 500; color: var(--muted); font-size: .8rem; }
.route-stop.is-out { opacity: .55; }
.route-stop.is-out .route-num { background: var(--fill-2); color: var(--muted); }
.route-stop.is-done .route-num { background: var(--success-text); }
.draft-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.route-card + .route-card { margin-top: 16px; }
.route-card-head h2 { margin: 0; font-size: 1.1rem; }
.route-card-head .muted { font-size: .88rem; }
.route-card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.sendback { margin-top: 4px; }
.sendback .inline-form { margin: 6px 0 0; }

.visit-card + .visit-card { margin-top: 14px; }
.visit-card.is-done { opacity: .75; }
.visit-head { display: flex; gap: 12px; align-items: flex-start; }
.visit-title { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.visit-title strong { font-size: 1.1rem; }
.visit-title .muted { font-size: .9rem; }
.visit-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; align-items: flex-start; }
.visit-actions form { margin: 0; }

@media (max-width: 860px) {
    .route-layout { grid-template-columns: 1fr; }
    .route-map-col { position: static; }
    .route-map { height: 46vh; min-height: 280px; }
    .sticky-bar { bottom: calc(var(--bottom-nav-h) + 10px + env(safe-area-inset-bottom)); }
    .pick-edit { margin-left: 0; }
    .route-summary-main { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Type-to-search customer picker (New estimate) */
.client-picker { position: relative; }
.client-picker .picker-input {
    width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-size: 1rem; background: #fff;
}
.client-picker.is-chosen .picker-input { border-color: var(--success-text); background: var(--success-bg); font-weight: 600; }
.picker-results {
    position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; list-style: none; margin: 0; padding: 4px;
    background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    box-shadow: 0 10px 24px rgba(20,20,19,.15); max-height: 320px; overflow-y: auto;
}
.picker-results li { padding: 10px 12px; border-radius: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.picker-results li span { font-size: .85rem; color: var(--muted); }
.picker-results li.active, .picker-results li:hover { background: var(--primary-soft); }
.picker-results li.picker-empty { cursor: default; color: var(--muted); }
.client-filter-count { font-size: .88rem; color: var(--muted); margin: -6px 0 8px; }
[hidden] { display: none !important; }
.client-row .list-row-main { text-decoration: none; color: var(--text); }
.client-row .list-row-main:hover .list-row-title { color: var(--brand-text); }
.client-row .list-row-side { flex-direction: row; align-items: center; gap: 10px; }
.row-chevron { color: var(--muted); display: flex; min-width: 24px; min-height: 44px; align-items: center; }
@media (max-width: 560px) { .client-row .list-row-side .muted { display: none; } }
