/* Capitán CRM — office & field app. Hand-written, no framework.
   Identity: blueprint-navy rail + hi-vis yellow "you are here"/"today" marker; quiet white panels on concrete grey;
   blueprint blue (#1d4ed8, same as the customer pages) for actions. Barlow (OFL) with tabular figures for money. */

@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 400; font-display: swap; src: url('../vendor/fonts/barlow-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 600; font-display: swap; src: url('../vendor/fonts/barlow-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Barlow'; font-style: normal; font-weight: 700; font-display: swap; src: url('../vendor/fonts/barlow-latin-700-normal.woff2') format('woff2'); }

:root {
  --rail: #0f2347;
  --rail-2: #16305e;
  --rail-ink: #c3cee4;
  --rail-ink-strong: #ffffff;
  --rail-line: rgba(255, 255, 255, .1);
  --hivis: #f6b40e;
  --hivis-ink: #2e2100;
  --brand: #1d4ed8;
  --brand-strong: #173fb0;
  --brand-soft: #e8eefc;
  --btn-primary: #1d4ed8;
  --btn-primary-hover: #173fb0;
  --paper: #f2f4f7;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --ink: #172033;
  --ink-2: #364158;
  --muted: #5c677a;
  --line: #dde3eb;
  --line-strong: #c4cdd9;
  --ok: #047857; --ok-soft: #e4f4ec;
  --warn: #a15c07; --warn-soft: #fcf0dc;
  --danger: #b91c1c; --danger-soft: #fce9e9;
  --info: #1d4ed8; --info-soft: #e8eefc;
  --violet: #6d28d9; --violet-soft: #efe8fd;
  --neutral: #465063; --neutral-soft: #eceff4;
  --progress-ink: #5a4200; --progress-soft: #fdefc0;
  --focus: #1d4ed8;
  --radius: 10px;
  --radius-sm: 7px;
  --overlay: rgba(12, 22, 44, .5);
  --shadow-pop: 0 16px 44px rgba(12, 28, 60, .22), 0 2px 6px rgba(12, 28, 60, .08);
  --font: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --rail: #0a1730;
    --rail-2: #142952;
    --paper: #0d1420;
    --surface: #141c2b;
    --surface-2: #182233;
    --surface-3: #1d2839;
    --ink: #e5eaf2;
    --ink-2: #c4cddb;
    --muted: #97a3b6;
    --line: #253147;
    --line-strong: #34425a;
    --brand: #7ea2ff;
    --brand-strong: #a3bdff;
    --brand-soft: #1b2a4c;
    --btn-primary: #3a68e8;
    --btn-primary-hover: #4a77f0;
    --ok: #4ade9b; --ok-soft: #10302a;
    --warn: #f5b84a; --warn-soft: #382a10;
    --danger: #f88a8a; --danger-soft: #3a1818;
    --info: #8eb0ff; --info-soft: #1b2a4c;
    --violet: #c0a8ff; --violet-soft: #2a2148;
    --neutral: #b2bccb; --neutral-soft: #222c3d;
    --progress-ink: #fbd56b; --progress-soft: #3a300d;
    --focus: #8eb0ff;
    --overlay: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

/* ---- base ---------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 400 16px/1.45 var(--font); font-feature-settings: 'kern'; -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -.005em; }
p { margin: 0 0 .6em; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
a, button, label, select, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.mono-ish { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.mr-auto { margin-right: auto; }
.nowrap { white-space: nowrap; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--hivis); color: var(--hivis-ink); padding: 10px 14px; border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 8px; }
.boot { min-height: 100dvh; display: grid; place-items: center; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; } }

/* ---- shell --------------------------------------------------------------------------- */
.shell { min-height: 100dvh; }
.shell-main { min-width: 0; }
.main { outline: none; padding-bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom)); }
.content { max-width: 1240px; margin: 0 auto; padding: 14px 14px 28px; }
.content.wide { max-width: none; }

.wordmark { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 700; }
.wordmark:hover { text-decoration: none; }
.wordmark-mark {
  width: 30px; height: 30px; border-radius: 7px; background: var(--hivis); color: var(--rail);
  display: grid; place-items: center; font-size: 19px; font-weight: 700; line-height: 1; flex: none;
}
.wordmark-text { font-size: 19px; letter-spacing: -.01em; display: inline-flex; align-items: baseline; gap: 5px; }
.wordmark-sub { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.wordmark.on-dark { color: #fff; }
.wordmark.on-dark .wordmark-sub { color: var(--rail-ink); }
.wordmark-lg .wordmark-mark { width: 44px; height: 44px; font-size: 27px; border-radius: 10px; }
.wordmark-lg .wordmark-text { font-size: 30px; }
.wordmark-lg .wordmark-sub { font-size: 15px; }

.rail { display: none; }
.topbar { display: none; }

.mobile-top {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 56px; padding: 0 10px 0 14px; padding-top: env(safe-area-inset-top);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.mobile-top-actions { display: flex; align-items: center; gap: 6px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--rail); border-top: 1px solid var(--rail-line);
}
.tabbar a, .tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; position: relative;
  color: var(--rail-ink); font-size: 12.5px; font-weight: 600; background: none; border: 0; text-decoration: none; cursor: pointer; min-width: 0;
}
.tabbar a span, .tabbar button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; padding: 0 2px; }
.tabbar .is-active { color: #fff; }
.tabbar .is-active::before { content: ''; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; background: var(--hivis); border-radius: 0 0 3px 3px; }
.tabbar :focus-visible { outline-color: var(--hivis); outline-offset: -4px; }

.lang-toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px; background: var(--surface); }
.lang-toggle button { border: 0; background: none; padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--muted); cursor: pointer; min-height: 30px; }
.lang-toggle button.is-on { background: var(--rail); color: #fff; }
.lang-toggle.on-dark { background: transparent; border-color: var(--rail-line); }
.lang-toggle.on-dark button { color: var(--rail-ink); }
.lang-toggle.on-dark button.is-on { background: var(--hivis); color: var(--hivis-ink); }

@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); background: linear-gradient(to right, var(--rail) 232px, transparent 232px); }
  .mobile-top, .tabbar { display: none; }
  .main { padding-bottom: 32px; }
  .content { padding: 22px 32px 40px; }
  body { font-size: 15px; }
  .rail {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    background: var(--rail); color: var(--rail-ink); padding: 18px 12px 14px;
  }
  .rail-top { padding: 0 8px 4px; }
  .rail-tenant { padding: 2px 8px 16px 47px; font-size: 13px; color: var(--rail-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-bottom: 1px solid var(--rail-line); margin-bottom: 10px; }
  .rail-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
  .rail-nav a {
    position: relative; display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 8px;
    color: var(--rail-ink); font-weight: 600; text-decoration: none;
  }
  .rail-nav a:hover { background: var(--rail-2); color: #fff; }
  .rail-nav a.is-active { background: var(--rail-2); color: #fff; }
  .rail-nav a.is-active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--hivis); }
  .rail-nav a:focus-visible, .rail button:focus-visible { outline-color: var(--hivis); }
  .rail-bottom { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--rail-line); display: flex; flex-direction: column; gap: 12px; }
  .rail-bottom .lang-toggle { align-self: flex-start; margin-left: 4px; }
  .rail-user { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
  .rail-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--rail-2); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
  .rail-user-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
  .rail-user-name { color: #fff; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rail-user-role { font-size: 12.5px; }
  .topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px;
    height: 60px; padding: 0 32px; background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .topbar .gsearch { width: min(440px, 50vw); }
  .topbar-right { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

/* ---- global search ------------------------------------------------------------------------ */
.gsearch { position: relative; }
.gsearch-box { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.gsearch-box:focus-within { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }
.gsearch-box input { flex: 1; border: 0; background: transparent; outline: none; min-width: 0; height: 100%; color: var(--ink); font-size: 16px; }
.gsearch-list, .combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; list-style: none; margin: 0; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-pop); max-height: 360px; overflow-y: auto;
}
.gsearch-list li, .combo-list li { display: flex; flex-direction: column; padding: 9px 10px; border-radius: 7px; cursor: pointer; }
.gsearch-list li.is-active, .combo-list li.is-active, .gsearch-list li:hover, .combo-list li:hover { background: var(--brand-soft); }
.gsearch-name { font-weight: 600; }
.gsearch-meta { font-size: 13.5px; color: var(--muted); }
.gsearch-empty, .combo-empty { color: var(--muted); cursor: default !important; background: none !important; }
.modal .gsearch-list { position: static; box-shadow: none; border: 0; padding: 4px 0 0; max-height: none; }

/* ---- page header & panels ------------------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin: 4px 0 16px; }
.page-head-main { min-width: 0; flex: 1 1 260px; }
.page-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; overflow-wrap: anywhere; }
.page-sub { margin-top: 4px; color: var(--muted); font-size: 15px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--muted); }
@media (min-width: 1024px) { .page-head h1 { font-size: 27px; } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.panel + .panel { margin-top: 14px; }
.grid-2 > .panel + .panel, .stack > .panel + .panel, .dash-col > .panel + .panel, .settings-body > .panel + .panel { margin-top: 0; }
.stat-row + .panel { margin-top: 0; }
.stack > * + .panel { margin-top: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); min-height: 52px; }
.panel-head h2 { font-size: 17px; font-weight: 700; }
.panel-sub { font-size: 13.5px; color: var(--muted); margin-top: 1px; }
.panel-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.panel-body { padding: 14px 16px; }
.panel-body.flush { padding: 0; }
.panel-link { font-size: 14px; font-weight: 600; white-space: nowrap; }

.grid-2 { display: grid; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
@media (min-width: 1024px) { .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

/* ---- buttons ------------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 600 15px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; user-select: none;
  transition: background-color .12s, border-color .12s;
}
@media (hover: hover) { .btn:hover { text-decoration: none; background: var(--surface-3); } }
.btn:active:not(:disabled), .icon-btn:active:not(:disabled), .chip:active, .sheet-btn:active:not(:disabled) { filter: brightness(.94); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--btn-primary); border-color: var(--btn-primary); color: #fff; }
@media (hover: hover) { .btn-primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); } }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
@media (hover: hover) { .btn-danger:hover { background: #991b1b; } }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brand); }
@media (hover: hover) { .btn-ghost:hover { background: var(--brand-soft); } }
.btn-ghost-danger { background: transparent; border-color: transparent; color: var(--danger); }
@media (hover: hover) { .btn-ghost-danger:hover { background: var(--danger-soft); } }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: 14px; }
.btn-lg { min-height: 50px; font-size: 16.5px; padding: 0 20px; }
.btn-icon { padding: 0; width: 42px; }
.btn-sm.btn-icon { width: 34px; }
.btn-block { width: 100%; }
.btn.is-busy { cursor: progress; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; flex: none;
}
@media (hover: hover) { .icon-btn:hover { background: var(--surface-3); color: var(--ink); } }
.icon-btn.on-dark { color: var(--rail-ink); }
@media (hover: hover) { .icon-btn.on-dark:hover { background: var(--rail-2); color: #fff; } }
.icon-btn-sm { width: 30px; height: 30px; }
.link-btn { border: 0; background: none; padding: 0; color: var(--brand); font-weight: 600; cursor: pointer; text-align: left; }
@media (hover: hover) { .link-btn:hover { text-decoration: underline; } }
@media (max-width: 1023.98px) { .btn { min-height: 44px; } .btn-sm { min-height: 38px; } .btn-icon { width: 44px; } }

.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .7s linear infinite; flex: none; }
.spin-lg { width: 28px; height: 28px; border-width: 3px; color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- badges, chips, tabs, segmented ------------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; line-height: 21px; white-space: nowrap; }
.badge-neutral { background: var(--neutral-soft); color: var(--neutral); }
.badge-muted { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line-strong); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-progress { background: var(--progress-soft); color: var(--progress-ink); box-shadow: inset 3px 0 0 var(--hivis); }

.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: thin; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink-2); font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; flex: none;
}
@media (hover: hover) { .chip:hover { border-color: var(--brand); color: var(--brand); } }
.chip.is-on { background: var(--rail); border-color: var(--rail); color: #fff; }
.chip-count { font-size: 12.5px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); line-height: 18px; }
.chip.is-on .chip-count { background: rgba(255, 255, 255, .18); color: #fff; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; margin-bottom: 16px; scrollbar-width: none; }
.tabs button {
  border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; position: relative; min-height: 44px; display: inline-flex; align-items: center; gap: 6px;
}
@media (hover: hover) { .tabs button:hover { color: var(--ink); } }
.tabs button.is-on { color: var(--ink); }
.tabs button.is-on::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--brand); }

.segmented { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--surface-3); gap: 2px; }
.segmented button { border: 0; background: none; padding: 7px 12px; border-radius: 7px; font-weight: 600; color: var(--muted); cursor: pointer; min-height: 34px; }
.segmented button.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 35, 71, .12); }
.segmented-sm button { padding: 4px 10px; min-height: 30px; font-size: 14px; }

/* ---- forms --------------------------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; position: relative; }
.field > label, .field-label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.req { color: var(--danger); }
.field input, .field select, .field textarea, .qty-input, .inline-input {
  width: 100%; min-height: 44px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 16px; line-height: 1.3;
}
.field textarea { min-height: 80px; resize: vertical; line-height: 1.45; }
.field select { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.unit-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.unit-pick select { flex: 1 1 110px; min-width: 0; }
.unit-pick .unit-custom { flex: 1 1 110px; min-width: 0; }
.field input:focus, .field select:focus, .field textarea:focus, .qty-input:focus, .inline-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field input:disabled, .field select:disabled, .field textarea:disabled, fieldset:disabled input, fieldset:disabled select, fieldset:disabled textarea { background: var(--surface-2); color: var(--muted); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 13.5px; font-weight: 600; }
.field-hint { color: var(--muted); font-size: 13.5px; }
.affix { display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.affix:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field .affix input { border: 0; box-shadow: none !important; min-width: 0; flex: 1; background: transparent; }
.affix-pre, .affix-suf { display: flex; align-items: center; padding: 0 10px; color: var(--muted); font-weight: 600; }
.affix-pre { padding-right: 0; }
.field.has-error .affix { border-color: var(--danger); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 6px 0; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.check-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.check label { font-weight: 600; font-size: 15px; cursor: pointer; }
.check .field-hint { font-weight: 400; margin: 0; }
.check-inline { align-self: end; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px 14px; }
.form-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) {
  .form-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: 1 / -1; }
}
.form-section-title { font-size: 15px; font-weight: 700; margin: 10px 0 2px; grid-column: 1 / -1; color: var(--ink-2); }
.form-alert { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--danger-soft); color: var(--danger); font-weight: 600; margin-bottom: 12px; }
.form-note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--surface-3); color: var(--ink-2); font-size: 14.5px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }

.combo { position: relative; }
.picked { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); min-height: 52px; }
.picked-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.picked-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.picked-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picked-text .muted { font-size: 13.5px; }

/* ---- tables & lists ------------------------------------------------------------------------------------------ */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.tbl td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl tr.row-link { cursor: pointer; }
@media (hover: hover) { .tbl tr.row-link:hover td { background: var(--surface-2); } }
.tbl .cell-title { font-weight: 600; color: var(--ink); }
@media (hover: hover) { .tbl a.cell-title:hover { color: var(--brand); } }
.tbl .cell-sub { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); border-bottom: 0; background: var(--surface-2); }
.tbl .badge { vertical-align: middle; }
.show-sm { display: none; }
@media (max-width: 759.98px) {
  .hide-sm { display: none !important; }
  .show-sm { display: block; }
  .tbl td, .tbl th { padding-left: 12px; padding-right: 10px; }
}
@media (min-width: 760px) and (max-width: 1023.98px) { .hide-md { display: none !important; } }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li + li { border-top: 1px solid var(--line); }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; color: inherit; text-decoration: none; }
@media (hover: hover) { .mini-row:hover { background: var(--surface-2); text-decoration: none; } }
.mini-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.mini-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-sub { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.mini-side .num { font-weight: 600; }

.dl { margin: 0; display: grid; gap: 0; }
.dl-row { display: grid; grid-template-columns: minmax(110px, 38%) minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dl-row:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); font-size: 14px; }
.dl dd { margin: 0; overflow-wrap: anywhere; }

.crew-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--crew, var(--line-strong)); margin: 0 4px 0 2px; vertical-align: middle; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.toolbar .field { flex: 1 1 200px; max-width: 360px; }
.toolbar .chips { flex: 1 1 100%; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.load-more { display: flex; justify-content: center; padding: 12px; }

/* ---- bars & progress --------------------------------------------------------------------------------------------- */
.bar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; min-width: 40px; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.bar-ok { background: var(--ok); } .bar-warn { background: #d98a10; } .bar-danger { background: var(--danger); } .bar-muted { background: var(--line-strong); }
.bar-hivis { background: var(--hivis); }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-top: 4px; max-width: 220px; }
.progress span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }

/* ---- empty / loading / error ------------------------------------------------------------------------------------------ */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 30px 18px; color: var(--muted); }
.empty-compact { padding: 18px 14px; }
.empty-ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); margin-bottom: 4px; }
.empty-compact .empty-ico { width: 36px; height: 36px; }
.empty-title { font-weight: 600; color: var(--ink-2); margin: 0; }
.empty-body { margin: 0; max-width: 46ch; font-size: 14.5px; }
.empty .btn { margin-top: 8px; }
.loading { display: flex; flex-direction: column; gap: 12px; padding: 18px 4px; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s ease-in-out infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.error-box { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); align-items: flex-start; }
.error-box p { margin: 0 0 8px; font-weight: 600; }

/* ---- modal / drawer / sheet ------------------------------------------------------------------------------------------- */
.overlay { position: fixed; inset: 0; z-index: 60; background: var(--overlay); display: flex; align-items: flex-end; justify-content: center; animation: fade .14s ease-out; }
.modal {
  background: var(--surface); width: 100%; max-height: calc(100dvh - 24px); display: flex; flex-direction: column; outline: none;
  border-radius: 16px 16px 0 0; box-shadow: var(--shadow-pop); animation: rise .18s ease-out;
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 19px; padding-top: 6px; }
.modal-sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.modal-form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-body { padding: 16px 18px; overflow-y: auto; flex: 1; min-height: 0; overscroll-behavior: contain; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); border-radius: 0 0 16px 16px; }
.confirm-body { color: var(--ink-2); }
@media (max-width: 639.98px) {
  /* Large pickers and drawers take the whole screen; shorter forms rise only as far as their content. */
  .overlay-center .modal-lg, .overlay-drawer .modal { height: calc(100dvh - 12px); max-height: none; }
  .modal-foot .btn { flex: 1 1 auto; }
  .modal-foot .mr-auto { flex: 0 0 auto; }
}
@media (min-width: 640px) {
  .overlay-center { align-items: center; padding: 20px; }
  .overlay-center .modal { border-radius: 14px; max-height: calc(100dvh - 40px); }
  .overlay-center .modal-foot { border-radius: 0 0 14px 14px; }
  .modal-sm { max-width: 440px; }
  .modal-md { max-width: 640px; }
  .modal-lg { max-width: 920px; }
  .overlay-drawer { justify-content: flex-end; align-items: stretch; }
  .overlay-drawer .modal { max-width: 600px; height: 100dvh; max-height: none; border-radius: 0; animation: slide .2s ease-out; }
  .overlay-drawer .modal-foot { border-radius: 0; }
  .overlay-sheet { align-items: center; padding: 20px; }
  .overlay-sheet .modal { border-radius: 14px; max-width: 440px; }
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(16px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes drop { from { transform: translateY(-12px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes slide { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }

.sheet-nav { list-style: none; margin: 0 -8px; padding: 0; }
.sheet-nav a { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 10px; border-radius: 9px; color: var(--ink); font-weight: 600; text-decoration: none; }
.sheet-nav a:hover, .sheet-nav a.is-active { background: var(--surface-3); }
.sheet-nav a.is-active { box-shadow: inset 4px 0 0 var(--hivis); }
.sheet-chev { margin-left: auto; color: var(--muted); }
.sheet-user { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--line); }

/* ---- toasts ------------------------------------------------------------------------------------------------------------ */
/* Placement keeps primary buttons clear: phones get toasts at the top (sheet footers and the tab bar live at the
   bottom); desktop gets them bottom-left of the content (drawers open on the right, modal buttons sit bottom-right). */
.toasts {
  position: fixed; z-index: 80; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 12px; right: 12px;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; border-radius: 10px;
  background: var(--rail); color: #fff; box-shadow: var(--shadow-pop); font-weight: 600; animation: drop .18s ease-out;
}
.toast .icon-btn { color: rgba(255, 255, 255, .75); }
@media (hover: hover) { .toast .icon-btn:hover { background: rgba(255, 255, 255, .12); color: #fff; } }
.toast-msg { flex: 1; }
.toast-ok .ico { color: #6ee7b7; }
.toast-warn .ico { color: var(--hivis); }
.toast-error { background: #8f1414; }
@media (max-width: 1023.98px) { .toast:nth-last-child(n+3) { display: none; } }
@media (min-width: 1024px) {
  .toasts { top: auto; right: auto; bottom: 24px; left: 24px; width: 400px; }
  body:has(.rail) .toasts { left: 256px; }
  .toast { animation-name: rise; }
}

/* ---- public link ----------------------------------------------------------------------------------------------------------- */
.public-link-label { font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.public-link-row { display: flex; gap: 6px; flex-wrap: wrap; }
.public-link-btns { display: flex; gap: 6px; flex: 0 0 auto; }
.public-link-row input { flex: 1 1 220px; min-width: 0; min-height: 42px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-2); font-size: 14px; }

/* ---- login -------------------------------------------------------------------------------------------------------------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; background: var(--surface); }
.login-brand { background: var(--rail); color: var(--rail-ink); padding: 28px 20px 24px; position: relative; overflow: hidden; }
.login-brand::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(rgba(255, 255, 255, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .05) 1px, transparent 1px);
  background-size: 28px 28px;
}
.login-brand-inner { position: relative; z-index: 1; max-width: 420px; }
.login-tagline { color: #fff; font-size: 21px; font-weight: 600; line-height: 1.3; margin: 18px 0 0; max-width: 24ch; }
.login-steps { display: none; list-style: none; margin: 26px 0 0; padding: 0; }
.login-steps li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--rail-line); font-weight: 600; }
.login-steps li:last-child { border-bottom: 1px solid var(--rail-line); }
.login-steps .ico { color: var(--hivis); }
.login-form-wrap { flex: 1; display: flex; flex-direction: column; padding: 18px 20px 32px; }
.login-lang { align-self: flex-end; display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--surface-3); }
.login-lang button { border: 0; background: none; padding: 6px 12px; border-radius: 999px; font-weight: 600; color: var(--muted); cursor: pointer; }
.login-lang button.is-on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 35, 71, .14); }
.login-form { width: 100%; max-width: 400px; margin: 18px auto 0; display: flex; flex-direction: column; gap: 14px; }
.login-form h1 { font-size: 28px; }
.login-form > .muted { margin: -6px 0 4px; }
.login-help { color: var(--muted); font-size: 14px; text-align: center; margin: 4px 0 0; }
@media (min-width: 900px) {
  .login { flex-direction: row; }
  .login-brand { flex: 0 0 44%; display: flex; align-items: center; padding: 48px 56px; }
  .login-tagline { font-size: 30px; }
  .login-steps { display: block; }
  .login-form-wrap { justify-content: center; padding: 28px 48px; position: relative; }
  .login-lang { position: absolute; top: 24px; right: 32px; }
  .login-form { margin-top: 0; }
}

/* ---- dashboard -------------------------------------------------------------------------------------------------------------- */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px 13px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); min-width: 0; }
.kpi:nth-child(odd) { border-right: 1px solid var(--line); }
@media (hover: hover) { .kpi:hover { background: var(--surface-2); text-decoration: none; } }
.kpi-label { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.kpi-value { font-size: 23px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-sub { font-size: 13px; color: var(--muted); line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kpi-danger .kpi-sub { color: var(--danger); font-weight: 600; }
.kpis .kpi:nth-last-child(-n+2) { border-bottom: 0; }
@media (min-width: 1100px) {
  .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kpi { border-bottom: 0; border-right: 1px solid var(--line); padding: 14px 16px 15px; }
  .kpi:last-child { border-right: 0; }
  .kpi-value { font-size: 25px; }
}
.dash-grid { display: grid; gap: 14px; }
.dash-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.dash-col .panel + .panel { margin-top: 0; }
@media (min-width: 1024px) { .dash-grid { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; } }

.stage-bars ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.stage-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'label value' 'bar bar'; gap: 4px 10px; align-items: center; }
.stage-bar-label { grid-area: label; display: flex; gap: 8px; color: var(--ink); font-weight: 600; font-size: 14.5px; min-width: 0; }
.stage-bar-label span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-bar .bar { grid-area: bar; }
.stage-bar-value { grid-area: value; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 14.5px; }
.stage-bars-foot { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.stage-bars-foot span { display: inline-flex; align-items: center; gap: 6px; }
@media (min-width: 640px) {
  .stage-bar { grid-template-columns: 190px minmax(0, 1fr) 110px; grid-template-areas: 'label bar value'; }
  .stage-bar-value { text-align: right; }
}

.agenda { display: flex; flex-direction: column; gap: 14px; }
.agenda-day-label { font-size: 14px; font-weight: 700; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.agenda-day.is-today .agenda-day-label { color: var(--ink); }
.agenda-day.is-today .agenda-day-label::before { content: ''; width: 10px; height: 10px; border-radius: 3px; background: var(--hivis); }
.agenda ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.agenda-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 9px 10px; border-radius: 8px; background: var(--surface-2); border-left: 4px solid var(--crew, var(--line-strong)); }
.agenda-time { font-size: 14px; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.agenda-title { font-weight: 600; color: var(--ink); display: block; }
.agenda-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.kind-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); flex: none; }
.agenda-meta .kind-dot { margin-right: -6px; }
.kind-site_visit { background: #7c3aed; } .kind-work { background: var(--brand); } .kind-inspection { background: #d97706; }
.kind-delivery { background: #0f766e; } .kind-meeting { background: #64748b; } .kind-other { background: #94a3b8; }

.field-jobs { list-style: none; margin: 0; padding: 0; }
.field-job { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.field-job:last-child { border-bottom: 0; }
.field-job-main { display: flex; flex-direction: column; gap: 2px; color: inherit; text-decoration: none; }
.field-job-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---- activity feed ---------------------------------------------------------------------------------------------------- */
.feed { list-style: none; margin: 0; padding: 0; }
.feed-item { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; padding: 9px 0; position: relative; }
.feed-item + .feed-item { border-top: 1px solid var(--line); }
.feed-ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--ink-2); }
.feed-call .feed-ico, .feed-sms .feed-ico, .feed-whatsapp .feed-ico, .feed-email .feed-ico { background: var(--info-soft); color: var(--info); }
.feed-estimate_approved .feed-ico, .feed-payment .feed-ico { background: var(--ok-soft); color: var(--ok); }
.feed-estimate_declined .feed-ico { background: var(--danger-soft); color: var(--danger); }
.feed-note .feed-ico { background: var(--progress-soft); color: var(--progress-ink); }
.feed-main { min-width: 0; }
.feed-title { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.feed-kind { font-weight: 600; color: var(--ink-2); }
.feed-title time { color: var(--muted); white-space: nowrap; }
.feed-text { margin-top: 1px; overflow-wrap: anywhere; }
.feed-detail { color: var(--ink-2); font-size: 14.5px; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 2px; }
.feed-meta { display: flex; gap: 12px; font-size: 13px; color: var(--muted); margin-top: 2px; }
.feed-compact .feed-item { padding: 8px 0; }
.composer { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.composer-kinds { display: flex; gap: 6px; flex-wrap: wrap; }
.composer-kinds .chip { min-height: 34px; }
.composer-foot { display: flex; justify-content: flex-end; }

/* ---- pipeline ------------------------------------------------------------------------------------------------------------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 14px; scroll-snap-type: x proximity; align-items: flex-start; }
.lane { flex: 0 0 84vw; max-width: 320px; background: var(--surface-3); border-radius: var(--radius); display: flex; flex-direction: column; scroll-snap-align: start; border: 1px solid transparent; }
.lane.is-over { border-color: var(--brand); background: var(--brand-soft); }
.lane-head { padding: 11px 12px 9px; border-top: 4px solid var(--line-strong); border-radius: var(--radius) var(--radius) 0 0; }
.lane-won .lane-head { border-top-color: var(--ok); }
.lane-lost .lane-head { border-top-color: var(--danger); }
.lane-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 700; }
.lane-title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-count { font-size: 13px; font-weight: 700; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 0 8px; line-height: 21px; }
.lane-total { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }
.lane-body { padding: 4px 8px 10px; display: flex; flex-direction: column; gap: 8px; min-height: 70px; }
.lane-empty { border: 1px dashed var(--line-strong); border-radius: 8px; padding: 16px 10px; text-align: center; color: var(--muted); font-size: 14px; }
@media (min-width: 760px) { .lane { flex-basis: 288px; } }
.opp-card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 10px 10px 12px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.opp-card[draggable="true"] { cursor: grab; }
.opp-card.is-dragging { opacity: .45; }
@media (hover: hover) { .opp-card:hover { border-color: var(--line-strong); } }
.opp-card-top { display: flex; align-items: flex-start; gap: 6px; }
.opp-card-title { font-weight: 600; color: var(--ink); flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
@media (hover: hover) { .opp-card-title:hover { color: var(--brand); text-decoration: none; } }
.opp-card-contact { font-size: 14px; color: var(--ink-2); }
.opp-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.opp-card-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.opp-card-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.opp-age.is-stale { color: var(--warn); font-weight: 600; }
.opp-card .icon-btn { width: 32px; height: 32px; margin: -4px -4px 0 0; }
.move-menu { position: absolute; right: 6px; top: 36px; z-index: 25; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-pop); padding: 4px; min-width: 210px; list-style: none; margin: 0; }
.move-menu li button { width: 100%; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; font-weight: 600; color: var(--ink); }
.move-menu li button:hover, .move-menu li button:focus-visible { background: var(--brand-soft); }
.move-menu li button[aria-current="true"] { color: var(--muted); }
.move-menu-title { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 6px 10px 4px; }

.drawer-section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.drawer-section:first-child { padding-top: 0; }
.drawer-section:last-child { border-bottom: 0; }
.drawer-section h3 { font-size: 15px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.opp-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.opp-value-big { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.linked-to { display: flex; align-items: center; gap: 8px; font-weight: 600; }

/* ---- contacts ------------------------------------------------------------------------------------------------------------- */
.contact-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 6px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag { display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px 1px 10px; border-radius: 999px; background: var(--surface-3); font-size: 14px; font-weight: 600; color: var(--ink-2); }
.tag a { color: inherit; }
.tag .icon-btn { width: 26px; height: 26px; }
.tag-add { display: flex; gap: 6px; }
.tag-add input { min-height: 36px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); font-size: 15px; width: 150px; }
.prop-list { list-style: none; margin: 0; padding: 0; }
.prop-list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.prop-list li:last-child { border-bottom: 0; }
.prop-main { flex: 1; min-width: 0; }
.prop-main strong { display: block; }
.dnc-banner { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger); font-weight: 600; margin-bottom: 14px; }

/* ---- estimate builder ---------------------------------------------------------------------------------------------------- */
.builder { display: grid; gap: 14px; }
@media (min-width: 1100px) { .builder { grid-template-columns: minmax(0, 1fr) 304px; align-items: start; } .builder-side { position: sticky; top: 76px; } }
.builder-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.builder-main .panel + .panel { margin-top: 0; }
.frozen-banner { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: var(--info-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--info) 25%, transparent); }
.frozen-banner.is-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.frozen-banner.is-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.frozen-banner > div { flex: 1 1 260px; }
.frozen-banner strong { display: block; }
.save-state { font-size: 13.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.section-card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.section-card.is-optional { border-style: dashed; border-color: var(--line-strong); }
.section-card.is-off .item-row { opacity: .55; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--line); }
.section-title { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.section-title strong { font-size: 16px; overflow-wrap: anywhere; }
.section-title .muted { font-size: 13.5px; }
.section-flags { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.section-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.section-tools { display: flex; gap: 2px; }
.section-foot { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line); }
.items { list-style: none; margin: 0; padding: 0; }
.item-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'desc tools' 'nums nums'; gap: 6px 8px; padding: 10px 12px 10px 14px; border-bottom: 1px solid var(--line); align-items: center; }
.item-row:last-child { border-bottom: 0; }
.item-desc { grid-area: desc; min-width: 0; }
.item-desc strong { font-weight: 400; color: var(--ink); overflow-wrap: anywhere; }
.item-desc .muted { display: block; font-size: 13px; }
.item-nums { grid-area: nums; display: grid; grid-template-columns: 78px auto minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.item-price { display: flex; align-items: center; gap: 8px; min-width: 0; }
.item-price .inline-input { max-width: 116px; }
.item-qty { display: block; text-align: right; }
.times { color: var(--muted); font-weight: 600; }
.item-tools { grid-area: tools; display: flex; gap: 0; }
.item-total { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.item-unit { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-input { min-height: 38px; padding: 6px 8px; font-size: 15px; font-variant-numeric: tabular-nums; text-align: right; }
.item-price-static { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.items-head { display: none; }
.builder-main { container-type: inline-size; container-name: est; }
@container est (min-width: 720px) {
  .item-row { grid-template-columns: minmax(0, 1fr) 76px 70px 108px 112px 66px; grid-template-areas: 'desc qty unit price total tools'; }
  .item-nums { display: contents; }
  .item-nums > :nth-child(1) { grid-area: qty; } .item-nums > :nth-child(2) { grid-area: unit; }
  .item-nums > :nth-child(3) { grid-area: price; } .item-nums > :nth-child(4) { grid-area: total; }
  .item-price { justify-content: flex-end; } .item-price .inline-input { max-width: none; } .times { display: none; }
  .items-head { display: grid; grid-template-columns: minmax(0, 1fr) 76px 70px 108px 112px 66px; gap: 8px; padding: 6px 12px 6px 14px; font-size: 12.5px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); background: var(--surface-2); }
  .items-head span:nth-child(n+2) { text-align: right; }
  .items-head span:nth-child(3) { text-align: left; }
}
.item-row.is-saving { opacity: .6; }
.totals { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.totals td { padding: 5px 0; }
.totals td:last-child { text-align: right; font-weight: 600; }
.totals .grand td { font-size: 20px; font-weight: 700; padding-top: 10px; border-top: 2px solid var(--ink); }
.totals .sub td { color: var(--muted); font-size: 14px; }
.totals .internal td { color: var(--ink-2); font-size: 14.5px; }
.margin-note { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.side-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.side-actions .btn { width: 100%; }
.mobile-sumbar { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 15; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; margin: 0 -14px -28px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 18px rgba(15, 35, 71, .08); }
.mobile-sumbar strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.mobile-sumbar .muted { font-size: 13px; display: block; }
@media (min-width: 1100px) { .mobile-sumbar { display: none; } }
.picker-filters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; margin-bottom: 12px; }
@media (min-width: 640px) { .picker-filters { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); } }
.pb-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); }
.pb-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'main main' 'price add'; gap: 6px 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: center; }
.pb-row:last-child { border-bottom: 0; }
.pb-main { grid-area: main; min-width: 0; }
.pb-name { font-weight: 600; }
.pb-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--muted); }
.pb-price { grid-area: price; }
.pb-price-main { font-weight: 700; font-variant-numeric: tabular-nums; }
.pb-price-sub { font-size: 13px; color: var(--muted); }
.pb-add { grid-area: add; display: flex; gap: 6px; align-items: center; }
.qty-input { width: 72px; min-height: 38px; text-align: right; padding: 6px 8px; }
@media (min-width: 760px) { .pb-row { grid-template-columns: minmax(0, 1fr) 200px auto; grid-template-areas: 'main price add'; } }
.item-preview { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); font-variant-numeric: tabular-nums; }
.version-links { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; }
.option-pick { display: flex; flex-direction: column; gap: 6px; }
.option-pick label { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.option-pick input { width: 18px; height: 18px; accent-color: var(--brand); }
.option-pick .num { margin-left: auto; }
.result-links { display: flex; flex-direction: column; gap: 12px; }

/* ---- jobs ------------------------------------------------------------------------------------------------------------- */
.job-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 14px; }
.job-summary > div { padding: 11px 14px; border-bottom: 1px solid var(--line); min-width: 0; }
.job-summary > div:nth-child(odd) { border-right: 1px solid var(--line); }
.job-summary .lbl { font-size: 13px; color: var(--muted); font-weight: 600; display: block; }
.job-summary .val { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
@media (min-width: 1024px) {
  .job-summary { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .job-summary > div { border-bottom: 0; border-right: 1px solid var(--line); }
  .job-summary > div:last-child { border-right: 0; }
}
.status-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist label { display: flex; gap: 12px; align-items: flex-start; padding: 11px 2px; cursor: pointer; min-height: 48px; }
.checklist input { width: 22px; height: 22px; margin: 0; accent-color: var(--ok); flex: none; }
.checklist .done-text { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.checklist .done-at { display: block; font-size: 12.5px; color: var(--muted); text-decoration: none; }
.checklist-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.checklist-head .progress { flex: 1; max-width: none; margin: 0; height: 8px; }
.costing-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.costing-row:last-child { border-bottom: 0; }
.costing-row .bar { grid-column: 1 / -1; height: 8px; }
.costing-nums { font-variant-numeric: tabular-nums; font-size: 14.5px; text-align: right; }
.costing-total { display: flex; flex-wrap: wrap; gap: 10px 22px; padding-top: 12px; margin-top: 4px; border-top: 2px solid var(--line-strong); }
.costing-total div { display: flex; flex-direction: column; }
.costing-total .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.costing-total .val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.job-summary .sub, .costing-total .sub { font-size: 12px; color: var(--muted); display: block; }
.job-summary .val.muted, .costing-total .val.muted { color: var(--muted); }
.labor-calc { font-variant-numeric: tabular-nums; color: var(--ink-2); padding: 8px 10px; background: var(--surface-2); border-radius: 8px; }
.pct-shortcuts { display: flex; flex-wrap: wrap; gap: 6px; }
.docs { display: flex; flex-direction: column; gap: 14px; }
.docs-upload { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.docs-buttons { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.docs-buttons label.btn { cursor: pointer; }
.docs-busy { display: inline-flex; align-items: center; gap: 6px; }
.thumbs { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.thumb { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.thumb-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; aspect-ratio: 4 / 3; }
.thumb-img, .thumb-fallback { width: 100%; height: 100%; object-fit: cover; display: grid; place-items: center; color: var(--muted); }
.thumb-cap { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 4px 4px 4px 8px; font-size: 13px; color: var(--ink-2); }
.thumb-cap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.file-list li:last-child { border-bottom: 0; }
.file-list .icon-btn { margin-left: auto; }

/* ---- schedule ---------------------------------------------------------------------------------------------------------- */
.week-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.week-label { font-weight: 700; font-size: 17px; min-width: 150px; text-align: center; }
.week { display: none; }
@media (min-width: 1024px) {
  .week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
  .agenda-mobile { display: none; }
}
.week-day { border-right: 1px solid var(--line); min-height: 420px; display: flex; flex-direction: column; min-width: 0; }
.week-day:last-child { border-right: 0; }
.week-day-head { padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); display: flex; align-items: baseline; justify-content: space-between; gap: 6px; }
.week-day-name { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: capitalize; }
.week-day-num { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.week-day.is-today .week-day-head { background: var(--progress-soft); box-shadow: inset 0 3px 0 var(--hivis); }
.week-day.is-today .week-day-name { color: var(--progress-ink); }
.week-day-body { padding: 6px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.week-day.is-weekend .week-day-body { background: repeating-linear-gradient(135deg, transparent 0 10px, var(--surface-2) 10px 11px); }
.week-add { opacity: 0; border: 1px dashed var(--line-strong); background: none; border-radius: 7px; color: var(--muted); padding: 6px; cursor: pointer; font-weight: 600; font-size: 13px; margin-top: auto; }
.week-day:hover .week-add, .week-add:focus-visible { opacity: 1; }
.ev { display: block; width: 100%; text-align: left; border: 0; border-left: 4px solid var(--crew, var(--line-strong)); background: var(--surface-3); border-radius: 6px; padding: 6px 8px; cursor: pointer; color: var(--ink); font-size: 13.5px; }
@media (hover: hover) { .ev:hover { background: var(--brand-soft); } }
.ev-time { font-weight: 700; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; display: flex; gap: 6px; align-items: center; }
.ev-title { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; display: block; margin-top: 1px; }
.ev-sub { color: var(--muted); font-size: 12.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.is-cancelled { opacity: .55; text-decoration: line-through; }
.ev.is-done { opacity: .75; }
.agenda-mobile .agenda-row { cursor: pointer; border-top: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; font: inherit; color: inherit; }
@media (hover: hover) { .agenda-mobile .agenda-row:hover { background: var(--brand-soft); } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; color: var(--muted); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .kind-dot { margin-right: 0; }

/* ---- invoices / reports ------------------------------------------------------------------------------------------------------ */
.aging { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
.aging-cell { padding: 10px 14px; border-bottom: 1px solid var(--line); min-width: 0; }
.aging-cell:nth-child(odd) { border-right: 1px solid var(--line); }
.aging-cell .lbl { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.aging-cell .val { display: block; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.aging-cell .cnt { font-size: 13px; color: var(--muted); }
.aging-cell.is-bad .val { color: var(--danger); }
.aging-total { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; background: var(--surface-2); }
.aging-total .val { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.aging-strip { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-3); margin: 0 14px 12px; }
.aging-strip span { display: block; height: 100%; }
@media (min-width: 900px) {
  .aging { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .aging-cell { border-bottom: 0; border-right: 1px solid var(--line); }
  .aging-cell:nth-child(5) { border-right: 0; }
}
.inv-totals { max-width: 360px; margin-left: auto; }
.report-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.report-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.report-bar .bar { grid-column: 1 / -1; }
.report-bar-label { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report-bar-value { font-variant-numeric: tabular-nums; font-size: 14.5px; text-align: right; }
.dual-bar { display: flex; flex-direction: column; gap: 3px; grid-column: 1 / -1; }
.dual-bar .bar { height: 8px; }
.stat-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); margin-bottom: 14px; }
.stat-row > div { padding: 11px 14px; border-bottom: 1px solid var(--line); }
.stat-row > div:nth-child(odd) { border-right: 1px solid var(--line); }
.stat-row .lbl { display: block; font-size: 13px; color: var(--muted); font-weight: 600; }
.stat-row .val { display: block; font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (min-width: 900px) {
  .stat-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-row > div { border-bottom: 0; border-right: 1px solid var(--line); }
  .stat-row > div:last-child { border-right: 0; }
}
.key-legend { display: flex; gap: 14px; font-size: 13.5px; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.key-legend span { display: inline-flex; align-items: center; gap: 6px; }
.key-legend i { width: 12px; height: 8px; border-radius: 3px; display: inline-block; }

/* ---- settings ------------------------------------------------------------------------------------------------------------- */
.settings { display: grid; gap: 14px; }

.settings-nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 600; white-space: nowrap; text-decoration: none; min-height: 42px; }
@media (hover: hover) { .settings-nav a:hover { background: var(--surface-3); } }
.settings-nav { border-bottom: 1px solid var(--line); padding-bottom: 0; gap: 2px; }
.settings-nav a { border-radius: 8px 8px 0 0; position: relative; }
.settings-nav a.is-active { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.settings-nav a.is-active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--hivis); }

.swatch { width: 18px; height: 18px; border-radius: 5px; display: inline-block; vertical-align: middle; border: 1px solid rgba(0, 0, 0, .12); }
.secret-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 10px; background: var(--progress-soft); color: var(--progress-ink); }
.secret-box code { font-size: 14px; word-break: break-all; background: var(--surface); color: var(--ink); padding: 8px 10px; border-radius: 7px; border: 1px solid var(--line); }
.tpl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
@media (min-width: 900px) { .tpl-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tpl { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); }
.tpl-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.tpl-head strong { font-size: 16px; }
.tpl p { margin: 0; color: var(--ink-2); font-size: 14.5px; }
.tpl-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.stage-edit { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); padding: 12px 0; border-bottom: 1px solid var(--line); }
.stage-edit:last-child { border-bottom: 0; }
@media (min-width: 900px) { .stage-edit { grid-template-columns: 40px minmax(0, 1.2fr) minmax(0, 1.2fr) 120px 100px 90px auto; align-items: end; } }
.order-btns { display: flex; gap: 2px; }
@media (min-width: 900px) { .order-btns { flex-direction: column; } .order-btns .icon-btn { height: 22px; } }
.pb-table input.inline-input { width: 96px; }
.pb-table td { vertical-align: middle; }
.map-grid { display: grid; gap: 10px; }
@media (min-width: 760px) { .map-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.log-list .tbl td { font-size: 14px; }

/* ---- print (rarely used: customer documents print from their public page) ---------------------------- */
@media print {
  .rail, .topbar, .tabbar, .mobile-top, .page-actions, .toasts, .mobile-sumbar, .side-actions { display: none !important; }
  body { background: #fff; }
  .panel { break-inside: avoid; }
}

/* ---- detail layouts & small shared bits ------------------------------------------------------------- */
.detail-grid { display: grid; gap: 14px; align-items: start; }
.detail-grid > .stack { min-width: 0; }
.detail-grid .panel + .panel { margin-top: 0; }
@media (min-width: 1024px) { .detail-grid { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); } }
.tab-actions { display: flex; justify-content: flex-end; padding: 0 12px; }
.tab-actions:empty { display: none; }
.tab-actions + .mini-list, .tab-actions + .empty { margin-top: 6px; border-top: 1px solid var(--line); }
.tag-filter { display: flex; align-items: center; gap: 8px; align-self: center; }
.toolbar-hint { margin: 0 0 10px; font-size: 14px; align-self: flex-end; }
.sheet-btn { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 50px; padding: 0 10px; border: 0; border-radius: 9px; background: none; color: var(--ink); font-weight: 600; cursor: pointer; text-align: left; }
@media (hover: hover) { .sheet-btn:hover:not(:disabled) { background: var(--surface-3); } }
.sheet-btn:disabled { cursor: default; color: var(--muted); }
.stage-swatch { width: 12px; height: 12px; border-radius: 4px; background: var(--brand); flex: none; }
.stage-swatch.stage-won { background: var(--ok); }
.stage-swatch.stage-lost { background: var(--danger); }
.mini-list.bordered { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mini-list.bordered .mini-row { padding: 10px 12px; }

/* ---- estimate builder extras ------------------------------------------------------------------------- */
.narrow-panel { max-width: 760px; }
.panel-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.inline-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer; min-height: 32px; }
.inline-check input { width: 18px; height: 18px; accent-color: var(--brand); margin: 0; }
.section-empty { margin: 0; padding: 14px; font-size: 14.5px; }
.add-section { border-style: dashed; background: transparent; }
.add-section-row { display: grid; gap: 10px; align-items: end; }
@media (min-width: 760px) { .add-section-row { grid-template-columns: minmax(0, 1fr) auto auto; } .add-section-row .check { padding-bottom: 0; } }
.side-link { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.side-link .public-link-row input { flex-basis: 100%; }
.approve-group { border: 0; padding: 0; margin: 0 0 12px; }
.approve-group legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.signature-field input { font-family: 'Segoe Script', 'Brush Script MT', cursive; font-size: 21px; }
.inline-input.is-bad { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.item-row .inline-input { width: 100%; }

/* ---- jobs & schedule extras ------------------------------------------------------------------------------- */
.content.wide-ish { max-width: 1440px; }
.sched-toolbar { align-items: flex-end; justify-content: space-between; }
.sched-toolbar .field { max-width: 280px; }
.link-row { width: 100%; border: 0; background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.co-total { text-align: right; font-weight: 700; margin: 8px 0 0; font-variant-numeric: tabular-nums; }
.job-summary .val.text-warn { color: var(--warn); }

/* ---- invoices editor & reports extras ------------------------------------------------------------------- */
.wide-form { max-width: 980px; }
.inv-items { display: flex; flex-direction: column; gap: 10px; }
.inv-item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.inv-item.has-error { border-color: var(--danger); }
.inv-item .inv-desc { grid-column: 1 / -1; }
.inv-item .field input { min-height: 40px; }
.inv-item-end { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.inv-item-end .num { margin-left: auto; }
.inv-item-error { grid-column: 1 / -1; }
.inv-items-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-variant-numeric: tabular-nums; font-weight: 600; }
@media (min-width: 900px) {
  .inv-item { grid-template-columns: minmax(0, 1fr) 80px 90px 130px auto; align-items: end; background: transparent; }
  .inv-item .inv-desc { grid-column: auto; }
  .inv-item-end { grid-column: auto; min-height: 40px; }
}
.report-bar-meta { grid-column: 1 / -1; font-size: 13px; }
.stat-row .val small { font-size: 14px; font-weight: 600; }

/* ---- settings extras ------------------------------------------------------------------------------------------ */
.settings-body { min-width: 0; }
.sticky-actions { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 10; padding: 12px 0; margin-top: 0; background: linear-gradient(to top, var(--paper) 70%, transparent); }
@media (min-width: 1024px) { .sticky-actions { bottom: 0; } }
.pb-toolbar { margin: 0; border-bottom: 1px solid var(--line); }
.pb-toolbar .check { align-self: flex-end; }
.affix-sm { min-width: 104px; }
.affix-sm input.inline-input { border: 0; box-shadow: none; min-height: 36px; padding: 4px 8px 4px 2px; background: transparent; }
.affix-sm .affix-pre, .affix-sm .affix-suf { padding: 0 6px; }
tr.is-inactive td, .stage-edit.is-inactive { opacity: .6; }
.stage-actions { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.stage-key { font-size: 12.5px; }
.member-pick { display: flex; flex-direction: column; gap: 4px; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.member-pick legend { font-weight: 600; font-size: 14px; padding: 0 4px; color: var(--ink-2); }
.color-input { padding: 4px !important; height: 44px; width: 100%; max-width: 120px; cursor: pointer; }
@media (min-width: 900px) { .stage-edit { grid-template-columns: 40px minmax(0, 1.2fr) minmax(0, 1.2fr) 130px 110px 100px 190px; } }

.tbl th.center, .tbl td.center { text-align: center; }
.cell-check { width: 20px; height: 20px; accent-color: var(--brand); margin: 6px 0 0; }
.pb-table .affix-sm { min-width: 0; width: 112px; margin-left: auto; }
.pb-name-cell { min-width: 220px; }

/* ---- dispatch (module A: board, technician app, timesheets) ---------------------------------------------- */
.dispatch .toolbar { align-items: flex-end; }
.disp-toolbar .field { max-width: 260px; margin: 0; }
.disp-date { min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; }
.disp-alerts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 14px; }
.chip-danger.is-on { background: var(--danger); border-color: var(--danger); }
.chip-warn.is-on { background: var(--warn); border-color: var(--warn); }
.chip-info.is-on { background: var(--info); border-color: var(--info); }
.is-dim { opacity: .32; }

/* status dots (visit states) */
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--neutral); flex: none; }
.status-dot.st-confirmed { background: var(--info); }
.status-dot.st-en_route { background: var(--violet); }
.status-dot.st-in_progress { background: var(--hivis); }
.status-dot.st-done { background: var(--ok); }
.status-dot.st-cancelled { background: var(--danger); }
.status-dot.st-no_show { background: var(--warn); }

/* technician initials */
.tchips { display: inline-flex; align-items: center; gap: 2px; }
.tchip { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 4px; border-radius: 999px; background: var(--tc, var(--neutral)); color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; box-shadow: 0 0 0 1.5px var(--surface); }
.tchip.is-working { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--hivis); }
.tchip.is-done { opacity: .55; }
.tchip.is-paused { box-shadow: 0 0 0 1.5px var(--surface), 0 0 0 3px var(--warn); }
.tchip-more { background: var(--surface-3); color: var(--muted); }
.inline-check .tchip { margin-right: 2px; }

/* day board */
.dboard-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding-bottom: 4px; }
.dboard { display: grid; grid-template-columns: 62px repeat(var(--lanes), minmax(200px, 1fr)); min-width: 100%; }
.dboard-corner { position: sticky; left: 0; z-index: 3; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.dboard-strip-label { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 8px 6px; display: flex; align-items: flex-start; }
.dlane-head { padding: 9px 10px 8px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); border-top: 4px solid var(--crew, var(--line-strong)); background: var(--surface-2); min-width: 0; position: sticky; top: 0; z-index: 2; }
.dlane-head.is-unassigned { border-top-style: dashed; }
.dlane-name { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlane-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.dlane-strip { min-height: 38px; padding: 4px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; background: repeating-linear-gradient(135deg, transparent 0 8px, var(--surface-2) 8px 9px); }
.dlane-strip.is-over, .dlane.is-over { background-color: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.dboard-times { position: relative; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; background: var(--surface-2); position: sticky; left: 0; z-index: 1; }
.dboard-hour { position: absolute; right: 6px; transform: translateY(-50%); background: var(--surface-2); padding: 0 2px; }
.dboard-hour:first-child { transform: none; }
.dlane { position: relative; border-left: 1px solid var(--line); background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px calc(var(--slot) * 2)); background-size: 100% calc(var(--slot) * 2); }
.dboard-now { position: absolute; left: 0; right: 0; height: 0; border-top: 2px solid var(--danger); z-index: 1; pointer-events: none; }
.dboard-now::before { content: ''; position: absolute; left: -4px; top: -5px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }

/* visit cards */
.vcard { position: absolute; display: flex; flex-direction: column; gap: 1px; text-align: left; border: 1px solid var(--line-strong); border-left: 4px solid var(--neutral); border-radius: 6px; background: var(--surface); color: var(--ink); padding: 4px 6px; font-size: 12.5px; line-height: 1.25; overflow: hidden; cursor: pointer; z-index: 1; box-shadow: 0 1px 2px rgba(15, 35, 71, .08); font-family: inherit; }
.vcard[draggable="true"] { cursor: grab; }
.vcard:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; z-index: 2; }
@media (hover: hover) { .vcard:hover { border-color: var(--brand); z-index: 2; box-shadow: var(--shadow-pop); } }
.vcard.is-compact { position: static; width: 100%; }
.vcard.st-confirmed { border-left-color: var(--info); }
.vcard.st-en_route { border-left-color: var(--violet); background: var(--violet-soft); }
.vcard.st-in_progress { border-left-color: var(--hivis); background: var(--progress-soft); }
.vcard.st-done { border-left-color: var(--ok); opacity: .7; }
.vcard.st-cancelled { border-left-color: var(--danger); opacity: .55; text-decoration: line-through; }
.vcard.st-no_show { border-left-color: var(--warn); opacity: .7; }
.vcard-top { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.vcard-time { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard-warn { color: var(--warn); flex: none; }
.vcard-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard-title { color: var(--ink-2); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard-addr { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: auto; }
.vcard-job { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* list rows (mobile board, technician's day) */
.vrows { list-style: none; margin: 0; padding: 0; }
.vrows li + li { border-top: 1px solid var(--line); }
.vrow { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px; width: 100%; padding: 11px 14px; text-align: left; border: 0; border-left: 4px solid var(--neutral); background: var(--surface); color: inherit; text-decoration: none; font: inherit; cursor: pointer; }
.vrow.st-confirmed { border-left-color: var(--info); }
.vrow.st-en_route { border-left-color: var(--violet); }
.vrow.st-in_progress { border-left-color: var(--hivis); }
.vrow.st-done { border-left-color: var(--ok); }
.vrow.st-cancelled, .vrow.st-no_show { border-left-color: var(--danger); opacity: .6; }
@media (hover: hover) { .vrow:hover { background: var(--surface-2); text-decoration: none; } }
.vrow-time { display: flex; flex-direction: column; gap: 2px; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.vrow-time .muted { font-weight: 500; font-size: 12.5px; }
.vrow-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.vrow-name { font-weight: 600; }
.vrow-sub { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vrow-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.disp-list { display: flex; flex-direction: column; gap: 14px; }
.disp-lane-list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.disp-lane-title { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 14px; font-size: 15px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-top: 4px solid var(--crew, var(--line-strong)); }
.disp-lane-title .muted { font-weight: 500; font-size: 13px; margin-left: auto; }
.disp-lane-list > .muted { margin: 0; padding: 12px 14px; }
.disp-table tr.row-link { cursor: pointer; }

/* week */
.dweek { display: grid; gap: 8px; }
@media (min-width: 1024px) { .dweek { grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; gap: 0; } }
.dweek-day { min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); }
@media (min-width: 1024px) { .dweek-day { border-radius: 0; min-height: 380px; } .dweek-day:last-child { border-right: 0; } }
.dweek-day.is-today .week-day-head { background: var(--progress-soft); box-shadow: inset 0 3px 0 var(--hivis); }
.dweek-body { padding: 6px; display: flex; flex-direction: column; gap: 8px; }
.dweek-lane { display: flex; flex-direction: column; gap: 4px; }
.dweek-lane-name { font-size: 12px; font-weight: 700; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.dweek-empty { margin: 4px 2px; font-size: 13px; }

/* menus */
.vmenu-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; font-size: 14px; }
.vmenu-addr { margin: 0 0 8px; font-size: 14px; }
.sheet-btn.is-danger { color: var(--danger); }
.unsched-row { align-items: center; }
.unsched-row .mini-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* technician app */
.timer-bar { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin: 0 0 14px; border-radius: var(--radius); background: var(--rail); color: var(--rail-ink-strong); box-shadow: 0 2px 8px rgba(15, 35, 71, .18); }
.timer-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--hivis); box-shadow: 0 0 0 4px rgba(246, 180, 14, .25); animation: timer-pulse 1.6s ease-in-out infinite; flex: none; }
@keyframes timer-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
.timer-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.timer-clock { font-size: 20px; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.timer-what { font-size: 13.5px; color: var(--rail-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timer-what .muted { color: var(--rail-ink); }
.field-daynav { margin-bottom: 12px; }
.visit-when { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 12px; font-size: 15px; }
.visit-when strong { text-transform: capitalize; }
.visit-contact { margin: 0 0 10px; }
.visit-addr { display: flex; align-items: center; gap: 6px; margin: 0 0 14px; color: var(--ink-2); }
.visit-actions { display: grid; gap: 10px; padding: 12px 14px; margin: 0 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.visit-actions .btn { width: 100%; justify-content: center; }
@media (min-width: 760px) { .visit-actions { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); } .visit-actions .btn { width: auto; } }
@media (max-width: 759.98px) { .visit-actions { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px); z-index: 12; box-shadow: var(--shadow-pop); } }
.visit-timer-note { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.visit-closed { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); margin-bottom: 14px; background: var(--neutral-soft); color: var(--ink); }
.visit-closed.st-done { background: var(--ok-soft); color: var(--ok); }
.visit-closed.st-cancelled, .visit-closed.st-no_show { background: var(--danger-soft); color: var(--danger); }
.visit-closed .muted, .visit-closed div > div { color: var(--ink-2); }
.visit-notes { white-space: pre-wrap; margin: 0 0 10px; }
.assign-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.assign-list li { display: flex; align-items: center; gap: 8px; }
.ok-note { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--ok-soft); color: var(--ok); margin-bottom: 14px; }
.ok-note .muted { color: var(--ink-2); }
.ok-note .public-link { margin-top: 8px; }
.eta-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 10px; }
.eta-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 64px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); color: var(--ink); font: inherit; font-size: 24px; font-weight: 700; cursor: pointer; }
.eta-btn span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.eta-btn.is-default { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
@media (hover: hover) { .eta-btn:hover { background: var(--brand-soft); } }
.sigpad { border: 1px dashed var(--line-strong); border-radius: var(--radius); background: #fff; }
.sigpad-canvas { display: block; width: 100%; height: 160px; touch-action: none; border-radius: var(--radius) var(--radius) 0 0; }
.sigpad-foot { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 4px 12px; border-top: 1px solid var(--line); font-size: 13px; }
.visit-mini { align-items: flex-start; }
.visit-mini .mini-main.link-row { padding: 0; }
.visit-mini .mini-side { flex-direction: row; align-items: center; gap: 6px; }
.visit-mini-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
@media (prefers-color-scheme: dark) { .sigpad { background: #f3f4f6; } }
/* ---- payments (module C) ---- */
.pay-chips { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.pay-reqs { margin: 0 0 6px; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.pay-reqs li { margin: 2px 0; }
.pay-stats { margin-bottom: 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.pay-block { padding: 12px 0; border-top: 1px solid var(--line); }
.pay-block:first-of-type { border-top: 0; padding-top: 0; }
.pay-block .form-section-title { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; }
.pay-row { align-items: end; }
.pay-qr { display: flex; justify-content: center; padding: 12px; margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.pay-qr svg { width: min(260px, 70vw); height: auto; }
.pay-dispute { margin-top: 0; }
.pay-methods .mini-side { gap: 4px; }
@media (min-width: 640px) {
  .pay-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .pay-stats > div { border-bottom: 0; }
  .pay-stats > div:not(:last-child) { border-right: 1px solid var(--line); }
}
/* ---- portal & booking (module B) ---- */
.hours-grid { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.hours-row { display: grid; grid-template-columns: minmax(110px, 150px) minmax(0, 1fr); gap: 8px 12px; align-items: start; padding: 4px 0; border-bottom: 1px solid var(--line); }
.hours-row:last-child { border-bottom: 0; }
.hours-row.is-off .hours-wins { color: var(--muted); }
.hours-day { text-transform: capitalize; min-height: 40px; }
.hours-wins { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; min-height: 40px; }
.hours-win { display: inline-flex; align-items: center; gap: 6px; }
.hours-win input[type=time] { min-height: 40px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; font-size: 15px; background: var(--surface); color: var(--ink); }
.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }
.booking-page-modal .member-pick { max-height: 220px; overflow: auto; }
.hub-panel .dl { margin-bottom: 4px; }
.hub-panel .contact-actions { margin-top: 8px; }
.hub-requests .mini-row { padding: 9px 0; }
@media (max-width: 639.98px) {
  .hours-row { grid-template-columns: 1fr; gap: 2px; }
  .row-actions { flex-direction: column; align-items: stretch; }
}

/* ---- recurring, memberships, equipment, inventory (module D) ---- */
.rec-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.rec-meta { font-size: 14px; margin-top: 2px; }
.rec-next .mini-row { padding: 8px 2px; }
.rec-actions { margin-top: 12px; }
.rec-badges { display: inline-flex; gap: 4px; align-items: center; }
.rec-badges .badge .ico { vertical-align: -2px; margin-right: 2px; }
.rec-weekdays { padding: 2px 0 0; }
.rec-weekdays .chip { min-width: 44px; justify-content: center; }
.rec-preview { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; }
.rec-scope { padding-top: 4px; border-top: 1px solid var(--line); }
.plain-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.plain-list li + li { margin-top: 2px; }
.inv-item.mem-service { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mem-active .link-btn strong { font-size: 15px; }
.mem-sheet .mini-row, .eq-sheet .mini-row { padding: 9px 2px; }
.eq-group + .eq-group { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.eq-group-title { display: flex; align-items: center; gap: 4px; font-size: 13px; margin: 2px 0; }
.eq-serviced { margin: 12px 0 8px; }
.eq-due .mini-row { padding: 9px 14px; }
.stock-stats { margin-bottom: 12px; }
.stock-stats .val small { font-size: 13px; font-weight: 600; color: var(--muted); }
.count-table { font-size: 14.5px; }
.count-table td { padding: 8px 6px; }
.count-input { width: 96px; text-align: right; min-height: 38px; }
.tbl tr.is-low td { background: var(--warn-soft); }
.inv-item.po-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (min-width: 640px) {
  .stock-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stock-stats > div { border-bottom: 0; }
  .stock-stats > div:not(:last-child) { border-right: 1px solid var(--line); }
  .inv-item.mem-service { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inv-item.mem-service .inv-item-end { grid-column: 1 / -1; }
}

/* ---- AI assistant (module E: launcher, drawer, chat, settings) ---- */
.ai-fab { position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom, 0px)); z-index: 50; display: inline-flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 16px 0 14px; border: 0; border-radius: 999px; background: var(--rail); color: #fff; font: inherit; font-weight: 600; box-shadow: var(--shadow-pop); cursor: pointer; }
.ai-fab:hover { background: var(--rail-2); }
.shell:has(.ai-fab) .main { padding-bottom: calc(var(--tabbar-h) + 84px + env(safe-area-inset-bottom, 0px)); }
/* Modals, drawers and sheets (.overlay, z 60) sit above the launcher, and it steps aside while one is open so it never covers their footers. */
body:has(.overlay) .ai-fab { visibility: hidden; }
.ai-drawer { z-index: 49; }
.ai-fab:focus-visible { outline: 3px solid var(--hivis); outline-offset: 2px; }
.ai-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; }
.ai-drawer.is-sheet { left: 0; width: auto; border-left: 0; bottom: 0; }
.ai-drawer.is-sheet .ai-chat { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px)); }
.ai-chat { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--surface); }
.ai-page .ai-page-body { height: calc(100vh - 150px); min-height: 420px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.ai-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line); }
.ai-head-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.ai-head-text .muted { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-head-actions { display: flex; gap: 2px; }
.ai-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--rail); color: var(--hivis); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.ai-usage { height: 4px; background: var(--surface-3); }
.ai-usage span { display: block; height: 100%; background: var(--brand); transition: width .3s; }
.ai-usage span.is-near { background: var(--warn); }
.ai-usage span.is-over { background: var(--danger); }
.ai-list { border-bottom: 1px solid var(--line); max-height: 40%; overflow-y: auto; padding: 6px; background: var(--surface-2); }
.ai-list-item { display: flex; align-items: center; gap: 4px; border-radius: 8px; }
.ai-list-item.is-on { background: var(--brand-soft); }
.ai-list-item > button:first-child { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 10px; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; color: var(--ink); border-radius: 8px; }
.ai-list-item > button:first-child:hover { background: var(--surface-3); }
.ai-list-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.ai-list-item .muted { font-size: 12.5px; }
.ai-thread { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 14px 6px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.ai-msg { display: flex; gap: 8px; align-items: flex-end; }
.ai-msg.is-user { justify-content: flex-end; }
.ai-msg.is-tool { padding-left: 40px; }
.ai-bubble { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: 15px; line-height: 1.45; word-wrap: break-word; overflow-wrap: anywhere; }
.ai-msg.is-user .ai-bubble { background: var(--brand); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.ai-msg.is-assistant .ai-bubble { background: var(--surface-3); color: var(--ink); border-bottom-left-radius: 4px; }
.ai-md p { margin: 0 0 6px; }
.ai-md > div:last-child p:last-child { margin-bottom: 0; }
.ai-md ul, .ai-md ol { margin: 0 0 6px; padding-left: 20px; }
.ai-md li { margin: 2px 0; }
.ai-md code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: rgba(0, 0, 0, .06); padding: 1px 5px; border-radius: 4px; }
.ai-md pre { margin: 4px 0 8px; padding: 10px; background: var(--rail); color: #e6edf7; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.ai-md pre code { background: none; color: inherit; padding: 0; }
.ai-md .ai-h { font-weight: 700; }
.ai-md a { color: var(--brand); }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12.5px; background: var(--surface-3); color: var(--ink-2); border: 1px solid var(--line); }
.ai-chip.is-executed { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.ai-chip.is-error, .ai-chip.is-rejected, .ai-chip.is-refused, .ai-chip.is-unknown_tool { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.ai-chip.is-expired, .ai-chip.is-pending { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.ai-chip.is-running { color: var(--brand); }
.ai-chip .spin-sm { width: 12px; height: 12px; border-width: 2px; }
.ai-confirm { margin-left: 40px; border: 1px solid var(--warn); border-radius: 12px; background: var(--warn-soft); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.ai-confirm-head { display: flex; align-items: center; gap: 8px; color: var(--warn); }
.ai-confirm-head .muted { margin-left: auto; font-size: 12.5px; }
.ai-confirm-tool { font-weight: 600; display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.ai-confirm-tool code { font-size: 12px; color: var(--muted); font-weight: 400; }
.ai-confirm-args { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
.ai-confirm-actions { display: flex; gap: 8px; }
.ai-error { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 14px; margin-left: 40px; }
.ai-disabled { text-align: center; padding: 30px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.ai-intro { padding: 8px 2px; color: var(--ink-2); font-size: 15px; }
.ai-suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ai-input { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px 6px; border-top: 1px solid var(--line); }
.ai-input textarea { flex: 1; resize: none; min-height: 44px; max-height: 140px; padding: 11px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; line-height: 1.35; }
.ai-input textarea:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.ai-foot { margin: 0; padding: 0 14px 10px; font-size: 12px; text-align: center; }
.ai-tools { display: grid; grid-template-columns: 1fr; gap: 4px 16px; }
.ai-tools code { font-size: 12px; color: var(--muted); margin-left: 6px; }
.ai-automations { display: flex; flex-direction: column; gap: 14px; }
.ai-auto { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.ai-auto-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; }
.ai-recipients { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip-check { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 14px; cursor: pointer; background: var(--surface); }
.ai-runs-title { font-size: 15px; margin: 18px 0 8px; }
.ai-run-output { font-size: 13.5px; color: var(--ink-2); max-width: 520px; white-space: pre-wrap; }
.ai-bars { display: flex; flex-direction: column; gap: 8px; }
.ai-bar-row { display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.ai-bar { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.ai-bar span { display: block; height: 100%; background: var(--brand); }
.ai-bar-val { color: var(--muted); font-size: 13px; white-space: nowrap; }
.form-note.is-danger { background: var(--danger-soft); color: var(--danger); }
@media (min-width: 1024px) {
  /* Desktop: the launcher lives in the top bar (right side), where it never covers drag targets or form footers. */
  .ai-fab { top: 10px; right: 24px; bottom: auto; min-height: 36px; padding: 0 14px 0 12px; font-size: 14px; box-shadow: none; }
  .ai-fab:hover { box-shadow: var(--shadow-pop); }
  .shell:has(.ai-fab) .topbar-tenant { padding-right: 150px; }
  .shell:has(.ai-fab) .main { padding-bottom: 32px; }
  .ai-tools { grid-template-columns: 1fr 1fr; }
  .ai-page .ai-page-body { height: calc(100vh - 170px); }
}
@media (prefers-color-scheme: dark) {
  .ai-md code { background: rgba(255, 255, 255, .1); }
}
