/* Office UI (Appliance Relay). Light, quiet surfaces; the logo's blue for actions
   and "you are here", its orange-red for the main call to action, navy for text;
   status is carried by soft tinted labels. */

:root {
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --line: #E3E7EC;
  --line-strong: #CDD4DC;
  --text: #142536;
  --muted: #5F6B7A;
  --faint: #8A95A3;
  --accent: #2160A0;
  --accent-hover: #183C60;
  --accent-soft: #E8F0F9;
  --brand-cta: #D94A30;
  --brand-cta-hover: #BF3D25;
  --brand-cta-text: #FFFFFF;
  --brand-navy: #183C60;
  --accent-text: #FFFFFF;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --ok: #157347;
  --focus: rgba(33, 96, 160, .28);
  --row-hover: #F5F8FC;
  --shadow-pop: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);

  /* status tints: background / text */
  --st-open-bg: #EEF1F4;       --st-open: #46505C;
  --st-assigned-bg: #E6F0FB;   --st-assigned: #1D5FA8;
  --st-progress-bg: #FFF4E0;   --st-progress: #93570B;
  --st-suspended-bg: #F3ECFB;  --st-suspended: #6B3FA0;
  --st-finished-bg: #E5F5EC;   --st-finished: #16703F;
  --st-completed-bg: #DDF0F3;  --st-completed: #0D5C66;
  --st-cancelled-bg: #FBEAEA;  --st-cancelled: #A1302A;

  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs: 14px; --fs-md: 16px; --fs-lg: 20px; --fs-xl: 26px;
  --r-sm: 6px; --r: 8px; --r-lg: 12px;
  --side-w: 236px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1419; --surface: #161C23; --surface-2: #1B222A; --line: #26303A; --line-strong: #34404C;
    --text: #E6EBF0; --muted: #9AA6B2; --faint: #6F7B88; --accent: #6EA4E6; --accent-hover: #8BB8EE;
    --accent-soft: #16273B; --accent-text: #0B1419; --brand-cta: #F07A62; --brand-cta-hover: #F4927E; --brand-cta-text: #1A0B07; --brand-navy: #8BB8EE; --danger: #F0796F; --danger-soft: #3A1D1B; --ok: #5CC58C;
    --row-hover: #1B232B; --focus: rgba(110, 164, 230, .35);
    --st-open-bg: #232B33; --st-open: #B5C0CB; --st-assigned-bg: #16304A; --st-assigned: #8CC0F2;
    --st-progress-bg: #3A2A10; --st-progress: #F2C277; --st-suspended-bg: #2E2240; --st-suspended: #C8A6F0;
    --st-finished-bg: #14352A; --st-finished: #7FD6A5; --st-completed-bg: #123339; --st-completed: #7CCFD8;
    --st-cancelled-bg: #3A1D1B; --st-cancelled: #F09A93;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 var(--fs)/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 50; background: var(--surface); padding: 8px; }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px 20px; font-weight: 700; font-size: var(--fs-md); letter-spacing: -0.015em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); position: relative; flex: none; }
.brand-mark::after { content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-text); right: 5px; top: 5px; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 0 12px; flex: 1; overflow-y: auto; }
.nav-group { margin: 16px 0 6px 10px; font-size: var(--fs-xs); color: var(--faint); font-weight: 600; }
.nav a, .nav .nav-soon { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r); color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .nav-soon { color: var(--faint); cursor: default; }
.nav .nav-soon small { margin-left: auto; font-size: 11px; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm); flex: none; }
.whoami { min-width: 0; flex: 1; font-size: var(--fs-sm); line-height: 1.3; }
.whoami div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { background: none; border: 0; padding: 6px; border-radius: var(--r-sm); color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 32px; background: var(--bg); position: sticky; top: 0; z-index: 10; }
.search { flex: 1; max-width: 520px; position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { width: 100%; height: 38px; padding: 0 12px 0 38px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; position: relative; }
.menu-btn { display: none; }
.main { padding: 8px 32px 64px; outline: none; max-width: 1400px; width: 100%; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 12px 0 20px; }
.page-head h1 { font-size: var(--fs-xl); font-weight: 700; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .sub { margin: 4px 0 0; color: var(--muted); }
.crumb { font-size: var(--fs-sm); margin-bottom: 6px; color: var(--muted); }
.crumb a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: var(--fs-xs); }
.btn-block { width: 100%; height: 40px; }
.btn[disabled] { opacity: .55; cursor: progress; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 600; font-size: inherit; }

/* dropdown menu */
.menu { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); padding: 6px; min-width: 200px; z-index: 30; }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); border: 0; background: none;
  color: var(--text); cursor: pointer; text-align: left; font-weight: 500; }
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- cards / panels ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: var(--fs-md); font-weight: 650; }
.card-body { padding: 16px 18px; }
.card + .card, .stack > .card + .card { margin-top: 16px; }
.split { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; gap: 16px; align-items: start; }
.split > div > .card + .card { margin-top: 16px; }
.split > *, .cols-2 > * { min-width: 0; }
.split.side-right { grid-template-columns: 1fr minmax(280px, 360px); }
.split.form-split { grid-template-columns: minmax(320px, 420px) 1fr; }
.scroll-x { overflow-x: auto; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

dl.facts { display: grid; grid-template-columns: 120px 1fr; gap: 10px 14px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: var(--fs-sm); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.pre { white-space: pre-wrap; }

/* ---------- toolbar / table ---------- */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: var(--fs-sm); }
.input, .toolbar input, .toolbar select { height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); }
.toolbar input[type=search] { min-width: 260px; }
.input:focus, .toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r); padding: 2px; }
.segmented button { border: 0; background: none; padding: 0 12px; height: 30px; border-radius: 6px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: var(--fs-sm); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.grid th { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); background: var(--surface-2); }
.grid th button { all: unset; cursor: pointer; }
.grid th button:focus-visible { outline: 2px solid var(--accent); }
.grid th[aria-sort="ascending"] button::after { content: " ↑"; }
.grid th[aria-sort="descending"] button::after { content: " ↓"; }
.grid tbody tr.clickable { cursor: pointer; }
.grid tbody tr.clickable:hover { background: var(--row-hover); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid td.wrap { white-space: normal; min-width: 220px; }
.grid .right, .grid th.right { text-align: right; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: var(--fs-xs); color: var(--muted); }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty h2 { font-size: var(--fs-md); color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }
.pager { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; align-items: center; font-size: var(--fs-sm); color: var(--muted); }

/* ---------- tags ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600;
  background: var(--st-open-bg); color: var(--st-open); white-space: nowrap; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.plain::before { display: none; }
.tag-Open { background: var(--st-open-bg); color: var(--st-open); }
.tag-Assigned { background: var(--st-assigned-bg); color: var(--st-assigned); }
.tag-InProgress { background: var(--st-progress-bg); color: var(--st-progress); }
.tag-Suspended { background: var(--st-suspended-bg); color: var(--st-suspended); }
.tag-Finished { background: var(--st-finished-bg); color: var(--st-finished); }
.tag-Completed { background: var(--st-completed-bg); color: var(--st-completed); }
.tag-Cancelled { background: var(--st-cancelled-bg); color: var(--st-cancelled); }
.tag-Todo { background: var(--st-open-bg); color: var(--st-open); }
.tag-Done { background: var(--st-finished-bg); color: var(--st-finished); }
.tag-active { background: var(--st-finished-bg); color: var(--st-finished); }
.tag-inactive { background: var(--st-open-bg); color: var(--st-open); }
.tag-accent { background: var(--accent-soft); color: var(--accent); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }

/* ---------- dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px 18px; color: var(--text); }
a.stat:hover { border-color: var(--line-strong); text-decoration: none; }
.stat strong { display: block; font-size: var(--fs-xl); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; }
.stat span { color: var(--muted); font-size: var(--fs-sm); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 84px 1fr auto; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.timeline li:last-child { border-bottom: 0; }
.timeline .time { font-weight: 600; font-size: var(--fs-sm); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list > li > :first-child { min-width: 0; }
.list > li > .actions { flex-wrap: nowrap; flex: none; }

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: var(--fs-sm); font-weight: 600; }
.field input, .field select, .field textarea {
  height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); width: 100%; }
.field textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.field select[multiple] { height: auto; min-height: 110px; padding: 6px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.field .error { font-size: var(--fs-xs); color: var(--danger); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
fieldset.group { border: 0; padding: 0; margin: 8px 0 0; grid-column: 1 / -1; }
fieldset.group legend { font-weight: 700; padding: 0; font-size: var(--fs-md); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 14px 0; border-top: 1px solid var(--line); margin-top: 16px; z-index: 5; }
.alert { padding: 10px 14px; border-radius: var(--r); margin: 0 0 14px; font-size: var(--fs-sm); }
.alert-error { background: var(--danger-soft); color: var(--danger); }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--line); padding: 12px; border-radius: var(--r); overflow-wrap: anywhere; user-select: all; }

/* autocomplete */
.picker { position: relative; }
.picker-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-pop); max-height: 280px; overflow-y: auto; z-index: 40; padding: 4px; }
.picker-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
.picker-list button:hover, .picker-list button.hi { background: var(--accent-soft); }
.picker-list .cell-sub { display: block; }
.picked { display: flex; align-items: center; justify-content: space-between; gap: 10px; height: 38px; padding: 0 6px 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface-2); font-weight: 600; }

/* line items editor */
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.lines td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lines input[type=text], .lines input[type=number] { width: 100%; height: 34px; padding: 0 8px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }
.lines input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.lines .qty { width: 84px; } .lines .price { width: 110px; } .lines .tot { width: 110px; text-align: right; padding-top: 14px; font-weight: 600; }
.lines .tx { width: 64px; text-align: center; padding-top: 14px; }
.lines .rm { width: 36px; }
.totals { margin-left: auto; width: 280px; margin-top: 12px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: var(--fs-md); }

/* visits */
.visit { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; background: var(--surface-2); }
.visit + .visit { margin-top: 10px; }
.visit-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-weight: 600; }
.visit-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.visit-row:last-child { border-bottom: 0; }
.people { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px 2px 2px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: var(--fs-xs); font-weight: 600; }
.chip .avatar { width: 20px; height: 20px; font-size: 10px; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* history */
.history { list-style: none; margin: 0; padding: 0; }
.history li { padding: 10px 18px; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.history li:last-child { border-bottom: 0; }

/* ---------- modal + toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 60; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 620px; padding: 22px 24px; box-shadow: var(--shadow-pop); }
.modal.wide { max-width: 820px; }
.modal h2 { margin: 0 0 16px; font-size: var(--fs-lg); font-weight: 700; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 16px); opacity: 0; background: var(--text); color: var(--surface);
  padding: 10px 16px; border-radius: 10px; transition: opacity .16s, transform .16s; pointer-events: none; z-index: 80; font-weight: 500; box-shadow: var(--shadow-pop); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }

/* ---------- login / error pages ---------- */
.login-page, .plain-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--bg); }
.login, .plain-card { background: var(--surface); width: 100%; max-width: 400px; padding: 32px; border-radius: 16px; border: 1px solid var(--line); }
.login .brand { padding: 0 0 24px; }
.login h1 { font-size: var(--fs-lg); font-weight: 700; margin-bottom: 4px; }
.login p.sub { color: var(--muted); margin: 0 0 22px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 960px) { .split, .split.side-right, .split.form-split, .cols-2 { grid-template-columns: 1fr; } }
@media (max-width: 780px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-pop); }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .topbar, .main { padding-left: 16px; padding-right: 16px; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .toolbar input[type=search] { min-width: 0; flex: 1; }
  .page-head h1 { font-size: var(--fs-lg); }
  .stats { grid-template-columns: 1fr 1fr; }
  .timeline li { grid-template-columns: 64px 1fr; }
  .timeline li > :last-child { grid-column: 2; }
  .totals { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- work order record (long, sectioned page) ---------- */
.record-head { position: sticky; top: 62px; z-index: 8; background: var(--bg); padding: 4px 0 10px; margin-bottom: 6px; }
.section-nav { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0; scrollbar-width: none; }
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; }
.section-nav a:hover { color: var(--text); border-color: var(--line-strong); text-decoration: none; }
.section-nav a .count { color: var(--faint); font-weight: 500; margin-left: 4px; }

.section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 16px; scroll-margin-top: 130px; }
.section-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.section.collapsed .section-head { border-bottom: 0; }
.section-toggle { all: unset; display: flex; align-items: center; gap: 10px; cursor: pointer; flex: 1; min-width: 0; }
.section-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }
.section-toggle h2 { font-size: var(--fs-md); font-weight: 650; }
.section-toggle .chev { width: 16px; height: 16px; color: var(--faint); transition: transform .15s; flex: none; }
.section.collapsed .section-toggle .chev { transform: rotate(-90deg); }
.section-toggle .meta { color: var(--muted); font-size: var(--fs-sm); font-weight: 500; }
.section-body { padding: 18px; }
.section.collapsed .section-body { display: none; }
.section-body.flush { padding: 0; }

.info-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.info-cols h3 { font-size: var(--fs-sm); font-weight: 650; color: var(--muted); margin: 0 0 10px; }
.info-cols dl.facts { grid-template-columns: 110px 1fr; }

/* notes: the reading surface of the page */
.notes-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.notes-grid .stack-col { display: flex; flex-direction: column; gap: 16px; }
.note-box { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); display: flex; flex-direction: column; min-width: 0; }
.note-box > header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.note-box > header h3 { font-size: var(--fs-sm); font-weight: 650; margin: 0; }
.note-box > header span { font-size: var(--fs-xs); color: var(--faint); }
.note-text { padding: 14px 16px; font-size: 15px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 120px; }
.note-box.main .note-text { min-height: 260px; }
.note-text.empty-note { color: var(--faint); font-style: italic; }
.note-box textarea { border: 0; border-radius: 0 0 var(--r) var(--r); background: var(--surface); padding: 14px 16px; font-size: 15px; line-height: 1.65;
  min-height: 160px; resize: vertical; width: 100%; font-family: inherit; color: var(--text); }
.note-box.main textarea { min-height: 300px; }
.note-box textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); }
.field textarea.big { min-height: 220px; font-size: 15px; line-height: 1.6; }
.field textarea.medium { min-height: 130px; font-size: 15px; line-height: 1.6; }

/* activity notes */
.composer { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.composer textarea { width: 100%; min-height: 96px; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: var(--r); font-size: 15px;
  line-height: 1.6; resize: vertical; background: var(--surface); }
.composer textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.composer-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); }
.activity .who { font-size: var(--fs-sm); color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.activity .who strong { color: var(--text); font-weight: 600; }
.activity .body { font-size: 15px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 4px; }
.activity li.flagged .body { border-left: 3px solid var(--st-progress); padding-left: 10px; }
.activity .row-actions { margin-left: auto; display: flex; gap: 4px; }

/* custom fields */
.cf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 24px; }
.cf-grid .cf label, .cf-grid .cf .label { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.cf-grid .cf .val { font-size: 15px; overflow-wrap: anywhere; white-space: pre-wrap; }
.cf-grid .cf .val.none { color: var(--faint); }
.cf-grid .cf.wide { grid-column: 1 / -1; }
.cf-group + .cf-group { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.cf-group h3 { font-size: var(--fs-sm); font-weight: 650; margin: 0 0 12px; }

/* photos */
.photo-group + .photo-group { margin-top: 22px; }
.photo-group h3 { font-size: var(--fs-sm); font-weight: 650; margin: 0 0 10px; display: flex; gap: 8px; align-items: center; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.photo { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface-2); display: flex; flex-direction: column; }
.photo a.img { display: block; aspect-ratio: 4 / 3; background: var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .cap { padding: 8px 10px; font-size: var(--fs-xs); color: var(--muted); display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 40px; }
.photo .cap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--r); padding: 18px; text-align: center; color: var(--muted); background: var(--surface-2); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

@media (max-width: 1100px) { .info-cols { grid-template-columns: 1fr 1fr; } }
@media (max-width: 960px) { .notes-grid { grid-template-columns: 1fr; } }
@media (max-width: 780px) {
  .info-cols { grid-template-columns: 1fr; }
  .record-head { top: 56px; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- work order: summary + tabbed workspace ---------- */
.wo-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 16px; }
.wo-summary > div { padding: 16px 18px; border-right: 1px solid var(--line); min-width: 0; }
.wo-summary > div:last-child { border-right: 0; }
.wo-summary h3 { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); margin: 0 0 6px; }
.wo-summary .big { font-size: var(--fs-md); font-weight: 650; overflow-wrap: anywhere; }
.wo-summary .cell-sub a { color: inherit; text-decoration: underline; }

.workspace-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.tablist { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; position: sticky; top: 62px; background: var(--surface); z-index: 6; border-radius: var(--r-lg) var(--r-lg) 0 0; }
.tablist::-webkit-scrollbar { display: none; }
.tablist [role=tab] { all: unset; cursor: pointer; padding: 14px 14px 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; transition: color .15s, border-color .15s; }
.tablist [role=tab]:hover { color: var(--text); }
.tablist [role=tab][aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }
.tablist [role=tab]:focus-visible { outline: 2px solid var(--accent); outline-offset: -4px; border-radius: 6px; }
.tablist .badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  font-size: 11px; display: inline-grid; place-items: center; color: var(--muted); }
.tablist [aria-selected=true] .badge { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.tab-panel { padding: 20px 22px 24px; }
.tab-panel:focus { outline: none; }
.tab-panel.entering { animation: tabIn .18s ease-out; }
@keyframes tabIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.panel-toolbar p { margin: 0; color: var(--muted); }

/* job notes: full-width reading cards */
.note-card { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.note-card + .note-card { margin-top: 14px; }
.note-card > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); border-radius: var(--r) var(--r) 0 0; }
.note-card > header h3 { margin: 0; font-size: var(--fs); font-weight: 650; }
.note-card > header .hint { color: var(--faint); font-size: var(--fs-xs); font-weight: 500; margin-left: 8px; }
.note-card .note-text { padding: 16px 18px; font-size: 15.5px; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; min-height: 0; }
.note-card.primary .note-text { min-height: 120px; }
.note-card .note-text.empty-note { color: var(--faint); font-style: normal; }
.note-card .note-text.empty-note button { margin-left: 4px; }

/* activity feed */
.feed { list-style: none; margin: 0; padding: 0; }
.feed > li { display: grid; grid-template-columns: 40px 1fr; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); }
.feed > li:first-child { border-top: 0; padding-top: 4px; }
.feed .avatar { width: 40px; height: 40px; }
.feed .meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); }
.feed .meta strong { color: var(--text); }
.feed .meta .row-actions { margin-left: auto; display: flex; gap: 2px; opacity: .65; transition: opacity .15s; }
.feed > li:hover .row-actions, .feed .row-actions:focus-within { opacity: 1; }
.feed .text { margin-top: 6px; font-size: 15.5px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.feed > li.flagged .text { background: var(--st-progress-bg); border-radius: var(--r); padding: 10px 12px; }
.editor-area { width: 100%; min-height: 300px; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: var(--r); font: inherit;
  font-size: 15.5px; line-height: 1.7; resize: vertical; background: var(--surface); color: var(--text); }
.editor-area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.modal.xl { max-width: 960px; }

/* photos: bigger grid + viewer */
.photo-grid.lg { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.photo-grid.lg .photo a.img, .photo-grid.lg .photo button.img { aspect-ratio: 4 / 3; }
.photo button.img { all: unset; display: block; cursor: zoom-in; width: 100%; background: var(--line); }
.photo button.img:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.photo button.img img { transition: transform .25s ease; }
.photo button.img:hover img { transform: scale(1.03); }
.photo { overflow: hidden; }
.viewer { position: fixed; inset: 0; background: rgba(10, 14, 18, .92); z-index: 90; display: grid; grid-template-rows: auto 1fr auto; color: #fff; }
.viewer header, .viewer footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; }
.viewer .stage { display: grid; place-items: center; min-height: 0; padding: 0 64px; position: relative; }
.viewer img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); border: 0; color: #fff; width: 44px; height: 44px;
  border-radius: 50%; cursor: pointer; font-size: 22px; display: grid; place-items: center; }
.viewer .nav:hover { background: rgba(255,255,255,.22); }
.viewer .nav.prev { left: 12px; } .viewer .nav.next { right: 12px; }
.viewer a, .viewer button.plain { color: #fff; }
.viewer .icon-btn { color: #fff; }
.viewer .icon-btn:hover { background: rgba(255,255,255,.15); color: #fff; }

@media (max-width: 1000px) { .wo-summary { grid-template-columns: 1fr 1fr; } .wo-summary > div:nth-child(2) { border-right: 0; } .wo-summary > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); } }
@media (max-width: 780px) {
  .wo-summary { grid-template-columns: 1fr; } .wo-summary > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .tablist { top: 56px; padding: 0 4px; } .tab-panel { padding: 16px 14px 20px; }
  .viewer .stage { padding: 0 8px; } .viewer .nav { display: none; }
  .photo-grid.lg { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .tab-panel.entering { animation: none; } .photo button.img img { transition: none; } }

.view { display: contents; }

/* ---------- shared bits ---------- */
.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; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; }
.label-sm { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); margin: 0 0 8px; text-transform: none; }
.jt-chip { display: inline-flex; align-items: center; padding: 3px 11px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 700;
  color: var(--jt-text, #fff); background: var(--jt); white-space: nowrap; line-height: 1.5; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.avatar.photo { background-size: cover; background-position: center; color: transparent; }

/* ---------- intake wizard ---------- */
.wz-steps { list-style: none; margin: 0 0 16px; padding: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.wz-steps::-webkit-scrollbar { display: none; }
.wz-steps li { flex: 1 0 auto; }
.wz-steps button { all: unset; box-sizing: border-box; width: 100%; display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 8px; border-radius: 999px;
  color: var(--faint); font-weight: 600; font-size: var(--fs-sm); cursor: pointer; white-space: nowrap; }
.wz-steps button[disabled] { cursor: default; }
.wz-steps .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; border: 1.5px solid var(--line-strong); background: var(--surface); flex: none; }
.wz-steps li.done button { color: var(--text); }
.wz-steps li.done .n { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.wz-steps li.on button { color: var(--accent); background: var(--accent-soft); }
.wz-steps li.on .n { border-color: var(--accent); color: var(--accent); }
.wz-steps button:not([disabled]):hover { background: var(--surface); }
.wz-steps button:focus-visible { outline: 2px solid var(--accent); }

.wz-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.wz-aside { position: sticky; top: 72px; }
.wz-panel { padding: 0; overflow: visible; }
.wz-head { padding: 22px 26px 0; }
.wz-count { font-size: var(--fs-xs); font-weight: 600; color: var(--faint); margin-bottom: 4px; }
.wz-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.wz-hint { color: var(--muted); margin: 6px 0 0; }
.wz-panel > .alert { margin: 16px 26px 0; }
.wz-body { padding: 20px 26px 8px; min-height: 260px; }
.wz-body.entering { animation: wzIn .2s ease-out; }
@keyframes wzIn { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: none; } }
.wz-foot { display: flex; align-items: center; gap: 10px; padding: 16px 26px; border-top: 1px solid var(--line); position: sticky; bottom: 0;
  background: var(--surface); border-radius: 0 0 var(--r-lg) var(--r-lg); z-index: 4; }
.wz-foot .wz-next { margin-left: auto; min-width: 150px; height: 42px; font-size: var(--fs); }
.wz-foot .btn { height: 42px; }
.wz-keys { font-size: var(--fs-xs); margin-left: auto; }
.wz-keys + .wz-next { margin-left: 12px; }
.wz-section { margin-top: 22px; }
.wz-section.flush-top { margin: 0 0 18px; }
.wz-section .field select, .wz-section .field input { height: 42px; }
.wz-facts { display: grid; grid-template-columns: 64px 1fr; gap: 12px 12px; margin: 0; padding: 16px 18px; font-size: var(--fs-sm); }
.wz-facts dt { color: var(--faint); font-weight: 600; font-size: var(--fs-xs); padding-top: 2px; }
.wz-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }

/* selectable cards */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.choice-list { display: grid; gap: 10px; }
.choice-list.compact .choice { padding: 12px 14px; }
.choice { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 14px; padding: 16px 18px; border: 1.5px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s, box-shadow .12s; min-width: 0; }
.choice:hover { border-color: var(--line-strong); }
.choice:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.choice.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 5%, var(--surface)); }
.choice .mark { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong); flex: none; position: relative; background: var(--surface); }
.choice .mark.box { border-radius: 5px; }
.choice.on .mark { border-color: var(--accent); background: var(--accent); }
.choice.on .mark::after { content: ""; position: absolute; inset: 4px; border-radius: 50%; background: var(--accent-text); }
.choice.on .mark.box::after { inset: auto; left: 5px; top: 1px; width: 5px; height: 10px; border: solid var(--accent-text); border-width: 0 2px 2px 0; transform: rotate(45deg); border-radius: 0; background: none; }
.choice-body { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.choice-grid .choice-body { flex-direction: column; align-items: flex-start; gap: 4px; }
.choice-body strong { font-size: var(--fs-md); font-weight: 650; }
.choice-body .grow { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.choice-body .grow strong { font-size: var(--fs); }
.choice .dot { width: 10px; height: 10px; border-radius: 50%; }
.avatar.add { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line-strong); }
.appl-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; flex: none; }

.wz-known { margin-top: 18px; }
.wz-known .cell-sub { display: flex; align-items: center; gap: 6px; }
.wz-known .cell-sub .icon { width: 15px; height: 15px; }
.known-card { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-radius: var(--r); background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.known-card span { color: var(--text); font-size: var(--fs-sm); }
.quick-picks { display: flex; flex-wrap: wrap; gap: 8px; }
.quick { all: unset; box-sizing: border-box; display: inline-flex; flex-direction: column; gap: 2px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--surface); cursor: pointer; font-size: var(--fs-sm); font-weight: 600; max-width: 100%; }
.quick:has(.icon) { flex-direction: row; align-items: center; gap: 8px; }
.quick:hover { border-color: var(--accent); background: var(--accent-soft); }
.quick:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
.wz-dupes { margin-top: 16px; }
.wz-dupes:empty { display: none; }

.appl-form { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; background: var(--surface-2); margin-top: 14px; }
.appl-form-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.wz-add { margin-top: 14px; }

.problem-block + .problem-block { margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); }
.problem-block h3 { font-size: var(--fs-md); margin-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip-toggle { all: unset; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line-strong); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; background: var(--surface); }
.chip-toggle:hover { border-color: var(--accent); }
.chip-toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip-toggle:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
textarea.wz-problem { width: 100%; min-height: 130px; padding: 14px 16px; font-size: 15px; line-height: 1.6; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); resize: vertical; }
textarea.wz-problem:focus, .wz-section textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }

.dropzone.big { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 38px 20px; cursor: pointer; border-radius: var(--r-lg); }
.dropzone.big .icon { width: 28px; height: 28px; color: var(--accent); }
.dropzone.big strong { color: var(--text); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 16px; }
.thumbs.small { grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; margin-top: 0; }
.thumb { margin: 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--surface-2); }
.thumb img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.thumb > .cell-sub { display: grid; place-items: center; aspect-ratio: 4 / 3; }
.thumb figcaption { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 4px 4px 4px 8px; font-size: var(--fs-xs); color: var(--muted); }
.thumb figcaption span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.review-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.review-block { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; min-width: 0; }
.review-block header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.review-block h3 { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

@media (max-width: 1100px) {
  .wz-layout { grid-template-columns: 1fr; }
  .wz-aside { display: none; }
}
@media (max-width: 780px) {
  .wz-steps .t { display: none; }
  .wz-steps li.on .t { display: inline; }
  .wz-steps li { flex: 0 0 auto; }
  .wz-head { padding: 18px 16px 0; }
  .wz-title { font-size: 19px; }
  .wz-body { padding: 16px 16px 4px; }
  .wz-panel > .alert { margin: 14px 16px 0; }
  .wz-foot { padding: 12px 16px; }
  .wz-keys { display: none; }
  .wz-foot .wz-next { flex: 1; }
  .choice-grid { grid-template-columns: 1fr 1fr; }
  .review-grid { grid-template-columns: 1fr; }
  .appl-form .form-grid.three { grid-template-columns: 1fr 1fr; }
  .wz-section.form-grid { grid-template-columns: 1fr; }
}
input.mono { text-transform: uppercase; } input.mono::placeholder { text-transform: none; }

/* ---------- work order: who / where / what / why ---------- */
.w4-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.w4 { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px 16px; min-width: 0; display: flex; flex-direction: column; }
.w4 > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.w4-label { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.w4-label .icon { width: 14px; height: 14px; }
.w4-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.w4-title { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; overflow-wrap: anywhere; line-height: 1.3; }
a.w4-title:hover { color: var(--accent); }
.w4-line { font-size: var(--fs-sm); color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; overflow-wrap: anywhere; }
.w4-line a { font-weight: 600; }
.w4-line .sep { color: var(--line-strong); }
.w4-line .mini { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--accent-soft); }
.w4-tags { margin-top: 8px; }
.warranty-box { display: flex; flex-direction: column; gap: 1px; padding: 9px 11px; border-radius: var(--r); font-size: var(--fs-sm);
  background: color-mix(in srgb, #7A4FB5 9%, var(--surface)); border: 1px solid color-mix(in srgb, #7A4FB5 22%, transparent); }
.warranty-box span { color: var(--muted); font-size: var(--fs-xs); }
.access-note { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; padding: 7px 10px; border-radius: var(--r); background: var(--st-progress-bg); color: var(--st-progress); font-size: var(--fs-sm); font-weight: 500; }
.access-note .icon { width: 14px; height: 14px; margin-top: 3px; }
.appl-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.appl-list li + li { border-top: 1px solid var(--line); padding-top: 12px; }
.appl-row { display: flex; align-items: center; gap: 8px; }
.appl-row strong { font-size: var(--fs-md); }
.appl-row .icon-btn { margin-left: auto; }
.icon-btn.sm { padding: 4px; } .icon-btn.sm .icon { width: 15px; height: 15px; }
.appl-ids { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 6px 0 4px; }
.appl-ids > span, .why-item .k, .sched-strip .k { display: flex; flex-direction: column; }
.k { font-size: 11px; font-weight: 600; color: var(--faint); }
.appl-ids .mono { font-size: var(--fs-sm); font-weight: 600; overflow-wrap: anywhere; }
.why-list { display: grid; gap: 12px; }
.why-item + .why-item { border-top: 1px solid var(--line); padding-top: 12px; }
.why-text { margin: 2px 0 4px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5; }
.link-btn.sm { font-size: var(--fs-xs); }
.link-btn.danger { color: var(--danger); }

.sched-strip { display: grid; grid-template-columns: 1.2fr 1.2fr 1.4fr .8fr; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin-bottom: 16px; }
.sched-strip > div { padding: 12px 16px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; align-items: flex-start; min-width: 0; }
.sched-strip > div:last-child { border-right: 0; }
.sched-strip .right { align-items: flex-end; text-align: right; }
.sched-strip strong { font-size: var(--fs-md); }
.sched-strip .btn { margin-top: 4px; }
.people-row { display: flex; margin-top: 2px; }
.people-row .avatar { width: 24px; height: 24px; font-size: 10px; border: 2px solid var(--surface); margin-right: -6px; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.xl { width: 88px; height: 88px; font-size: 28px; }
.pp { display: flex; gap: 20px; align-items: center; }
.sidebar-foot #avatar, .sidebar-foot .whoami { cursor: pointer; }

.sub-head { font-size: var(--fs-sm); font-weight: 700; margin: 22px 0 10px; }
.panel-toolbar + .sub-head { margin-top: 4px; }
.appl-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.appl-card { all: unset; box-sizing: border-box; display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-lg); cursor: pointer; min-width: 0; }
.appl-card > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.appl-card:hover { border-color: var(--line-strong); background: var(--surface-2); }
.appl-card:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
.appl-card.gone { opacity: .6; }
.grid tr.current td { background: var(--accent-soft); }
.cell-sub.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.detail-cards { display: grid; gap: 14px; }
.detail-facts { margin-top: 20px; grid-template-columns: 140px 1fr; }

/* ---------- notes as a conversation ---------- */
.tab-panel.chat-panel { padding: 0; display: flex; flex-direction: column; }
.chat-thread { padding: 18px 22px 8px; max-height: min(64vh, 720px); min-height: 220px; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.chat-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 54px 20px; color: var(--muted); text-align: center; }
.chat-empty strong { color: var(--text); font-size: var(--fs-md); }
.chat-day { display: flex; align-items: center; gap: 12px; margin: 14px 0 10px; color: var(--faint); font-size: var(--fs-xs); font-weight: 600; }
.chat-day::before, .chat-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; max-width: 760px; }
.msg.cont { margin-top: 4px; }
.msg .avatar, .msg .avatar-gap { width: 34px; height: 34px; flex: none; }
.msg-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; align-items: flex-start; }
.msg-meta { display: flex; gap: 8px; align-items: baseline; font-size: var(--fs-sm); }
.msg-meta span { color: var(--faint); font-size: var(--fs-xs); }
.bubble { background: var(--surface-2); border: 1px solid var(--line); padding: 9px 13px; border-radius: 4px 14px 14px 14px; max-width: 100%; }
.msg.cont .bubble { border-radius: 14px; }
.bubble-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; line-height: 1.5; }
.msg-time { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--faint); min-height: 16px; }
.msg-actions { display: inline-flex; gap: 10px; margin-left: 6px; opacity: 0; transition: opacity .12s; }
.msg-actions .link-btn { font-size: 11px; }
.msg:hover .msg-actions, .msg:focus-within .msg-actions, .msg.editing .msg-actions { opacity: 1; }
.msg.mine { margin-left: auto; flex-direction: row-reverse; }
.msg.mine .msg-main { align-items: flex-end; }
.msg.mine .msg-meta { flex-direction: row-reverse; }
.msg.mine .bubble { background: var(--accent); border-color: var(--accent); color: var(--accent-text); border-radius: 14px 4px 14px 14px; }
.msg.mine.cont .bubble { border-radius: 14px; }
.msg.mine .msg-time { flex-direction: row-reverse; }
.msg.mine .msg-actions { margin: 0 6px 0 0; }
.msg.flagged .bubble { box-shadow: inset 3px 0 0 #D97706; }
.msg.mine.flagged .bubble { box-shadow: inset -3px 0 0 #FBBF24; }
.flag-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; color: #B45309; margin-bottom: 2px; }
.msg.mine .flag-tag { color: #FDE68A; }
.flag-tag .icon { width: 12px; height: 12px; }
.msg.editing .bubble { outline: 2px dashed var(--accent); outline-offset: 2px; }
.chat-compose { display: flex; gap: 10px; align-items: flex-end; padding: 12px 22px 6px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-box { flex: 1; display: flex; align-items: flex-end; border: 1px solid var(--line-strong); border-radius: 22px; background: var(--surface); padding: 4px 6px 4px 16px; min-width: 0; }
.chat-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.chat-input { flex: 1; border: 0; outline: 0; resize: none; background: transparent; padding: 7px 0; min-height: 22px; max-height: 220px; font-size: 15px; line-height: 1.45; }
.flag-btn { margin-bottom: 1px; }
.flag-btn[aria-pressed="true"] { color: #D97706; background: #FEF3C7; }
.send-btn { height: 42px; border-radius: 21px; padding: 0 20px; }
.chat-help { font-size: 11px; margin: 0; padding: 0 22px 12px 38px; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .flag-btn[aria-pressed="true"] { background: #3A2A10; }
}
@media (max-width: 1100px) {
  .w4-grid { grid-template-columns: 1fr 1fr; }
  .sched-strip { grid-template-columns: 1fr 1fr; }
  .sched-strip > div:nth-child(2) { border-right: 0; }
  .sched-strip > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 780px) {
  .w4-grid { grid-template-columns: 1fr; }
  .chat-thread { padding: 14px 14px 6px; max-height: 60vh; }
  .chat-compose { padding: 10px 12px 6px; }
  .chat-help { display: none; }
  .msg { max-width: 92%; }
  .msg.mine { max-width: 86%; }
  .msg-actions { opacity: 1; }
  .detail-facts { grid-template-columns: 110px 1fr; }
}

/* ---------- settings: pick-lists ---------- */
.card.catalog + .card.catalog { margin-top: 16px; }
.catalog-blurb { margin: 0; padding: 12px 18px 4px; font-size: var(--fs-sm); }
.catalog-list li.off .cell-main { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.order-btns { display: flex; flex-direction: column; }
.order-btns .icon-btn { padding: 0 6px; line-height: 1.2; font-size: 13px; }
.order-btns .icon-btn[disabled] { opacity: .25; cursor: default; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); cursor: pointer; min-width: 52px; }
.switch input { appearance: none; -webkit-appearance: none; width: 32px; height: 18px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 18px 18px; }
.cloud-item { all: unset; padding: 5px 12px; border: 1px solid var(--line-strong); border-radius: 999px; font-size: var(--fs-sm); cursor: pointer; }
.cloud-item:hover { border-color: var(--accent); color: var(--accent); }
.cloud-item:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
.cloud-item.off { color: var(--faint); border-style: dashed; }
.field input[type=color] { padding: 3px; width: 72px; }
@media (max-width: 780px) {
  .catalog-list > li { flex-wrap: wrap; }
  .catalog .card-head { flex-wrap: wrap; }
}

/* job type cards: the selected one fills with the type's colors */
.choice.jt-card { padding: 18px 20px; border-left: 5px solid var(--jt); }
.choice.jt-card:hover { border-color: var(--jt); }
.choice.jt-card.on { background: var(--jt); border-color: var(--jt); color: var(--jt-text);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--jt) 30%, transparent); }
.choice.jt-card.on .cell-sub { color: var(--jt-text); opacity: .88; }
.choice.jt-card.on .mark { background: var(--jt-text); border-color: var(--jt-text); }
.choice.jt-card.on .mark::after { inset: auto; left: 6px; top: 2px; width: 4px; height: 9px; border-radius: 0; background: none;
  border: solid var(--jt); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.choice.jt-card.on:focus-visible { box-shadow: 0 0 0 3px var(--focus), 0 8px 20px color-mix(in srgb, var(--jt) 30%, transparent); }

/* ---------- searchable select (select2-style) ---------- */
.combo { position: relative; min-width: 0; }
.combo-btn { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; height: 42px; padding: 0 12px 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); cursor: pointer; font-weight: 500; }
.combo-btn:hover { border-color: var(--faint); }
.combo-btn:focus-visible, .combo.open .combo-btn { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.combo-value { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-value.placeholder { color: var(--faint); font-weight: 400; }
.combo-caret { width: 8px; height: 8px; border: solid var(--muted); border-width: 0 1.7px 1.7px 0; transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s; flex: none; }
.combo.open .combo-caret { transform: rotate(225deg) translate(-2px, -2px); }
.combo-pop { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); z-index: 45; overflow: hidden; animation: comboIn .12s ease-out; min-width: 240px; }
@keyframes comboIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.combo-search-wrap { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-bottom: 1px solid var(--line); color: var(--faint); }
.combo-search-wrap .icon { width: 16px; height: 16px; }
.combo-search { flex: 1; border: 0; outline: 0; height: 42px; background: transparent; min-width: 0; }
.combo-list { max-height: 300px; overflow-y: auto; padding: 6px; overscroll-behavior: contain; }
.combo-opt { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; }
.combo-opt > span:not(.combo-check) { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.combo-opt.hi { background: var(--accent-soft); }
.combo-opt.on .combo-label { font-weight: 700; color: var(--accent); }
.combo-check { color: var(--accent); font-weight: 700; }
.combo-opt.add { color: var(--accent); font-weight: 600; border-top: 1px solid var(--line); border-radius: 0 0 var(--r-sm) var(--r-sm); margin-top: 4px; }
.combo-opt.add .icon { width: 16px; height: 16px; }
.combo-empty { padding: 14px 10px; color: var(--muted); font-size: var(--fs-sm); }
.field .combo-search, .combo-search, .field .combo-search:focus { border: 0; box-shadow: none; height: 42px; padding: 0; background: transparent; border-radius: 0; outline: 0; }

/* customer step: search first */
.search-box { display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--faint); }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.search-box input { flex: 1; border: 0; outline: 0; background: transparent; height: 100%; font-size: 15px; min-width: 0; }
.cust-results { margin-top: 10px; }
.cust-results:empty { display: none; }
.no-results { margin: 4px 2px; }
label.label-sm { display: block; }
.other-cust { font-size: var(--fs-sm); }
.billing-box { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.billing-fields { margin-top: 14px; }
.related-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: -4px 0 12px; font-size: var(--fs-sm); color: var(--muted); }
.related-bar > .icon { width: 16px; height: 16px; }
.related-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 12px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); color: var(--text); }
.related-chip:hover { border-color: var(--accent); text-decoration: none; }
select.photo-for { width: calc(100% - 8px); margin: 4px 4px 0; height: 30px; font-size: var(--fs-xs); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }

/* labeled lines (Customer, Service Address, Serviceable Item(s)) */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; font-size: var(--fs-sm); }
dl.kv dt { color: var(--faint); font-weight: 600; font-size: var(--fs-xs); padding-top: 2px; white-space: nowrap; }
dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; color: var(--text); }
dl.kv dd a.strong, dl.kv dd strong { font-weight: 700; font-size: var(--fs); }
.w4 dl.kv + .w4-links { margin-top: 10px; }
.access-text { display: inline-block; padding: 2px 8px; border-radius: var(--r-sm); background: var(--st-progress-bg); color: var(--st-progress); font-weight: 600; }
.appl-list li > dl.kv { margin-top: 6px; }
.review-block dl.kv { margin-top: 8px; }
.plain-list.items > li + li { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.wz-facts { grid-template-columns: 96px 1fr; }
.job-line { display: inline-flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; }
.k-inline { color: var(--faint); font-weight: 600; font-size: var(--fs-xs); }

/* billing address with a "same as service" tag */
.addr-block { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 5px; }
.same-tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; }
.same-tag .icon { width: 12px; height: 12px; }

/* Google Maps link */
.map-link { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.map-link .icon { width: 15px; height: 15px; }
.review-link { margin-top: 10px; font-size: var(--fs-sm); }

/* full-screen loader */
body.is-busy { overflow: hidden; }
.busy-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: busyIn .15s ease-out; }
@keyframes busyIn { from { opacity: 0; } to { opacity: 1; } }
.busy-box { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 40px; border-radius: 16px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-pop); text-align: center; min-width: 260px; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; margin-bottom: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy-text { margin: 0; font-size: var(--fs-md); font-weight: 700; }
.busy-sub { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* schedule step */
.day-chips .chip-toggle.day { display: inline-flex; flex-direction: column; align-items: center; gap: 0; padding: 8px 14px; border-radius: 12px; min-width: 76px; line-height: 1.25; }
.day-chips .chip-toggle.day strong { font-size: var(--fs-sm); }
.day-chips .chip-toggle.day span { font-size: var(--fs-xs); opacity: .8; }
.date-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--muted); }
.date-row input, .date-row select { height: 40px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); color: var(--text); }
.date-row input:focus, .date-row select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.chip-toggle.team { display: inline-flex; align-items: center; gap: 6px; }
.chip-toggle.team .swatch { margin: 0; }
.team-load { font-size: 11px; opacity: .75; padding-left: 4px; border-left: 1px solid currentColor; margin-left: 2px; }
.field .date-row input, .field .date-row select { width: auto; min-width: 150px; height: 40px; }
.date-row label { font-weight: 500; }
.field .date-row { margin-top: 10px; }

/* ---------- Schedule card: one panel per visit (ServiceBridge layout) ---------- */
.sched-card { margin-bottom: 16px; }
.sched-card .card-head .actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sched-card .total-chip { white-space: nowrap; }
.sched-card .card-body { display: flex; flex-direction: column; gap: 12px; }
.visit-panel { border: 1px solid var(--line); border-radius: var(--r-md, 10px); padding: 12px 16px 14px; background: var(--surface); }
.visit-panel > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.visit-panel h3 { margin: 0; font-size: var(--fs-md, 1rem); display: flex; align-items: center; gap: 8px; }
.visit-panel h4 { margin: 12px 0 6px; font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.visit-panel .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.visit-panel .unscheduled { display: flex; align-items: center; gap: 8px; color: var(--muted); margin: 0 0 6px; }
.visit-panel .unscheduled .icon { width: 16px; height: 16px; }
dl.sched-rows { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.sched-rows dt { font-weight: 600; color: var(--text); }
dl.sched-rows dd { margin: 0; min-width: 0; }
.sched-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; border-top: 1px solid var(--line); margin-top: 12px; }
.sched-rows .under { color: #198754; font-weight: 600; }
.sched-rows .over { color: #c0392b; font-weight: 600; }
.member-names { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; }
.member-names .member { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-sm); color: var(--muted); }
.avatar.sm { width: 20px; height: 20px; font-size: 9px; }
#modal .date-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
#modal .date-row label { font-weight: 500; color: var(--muted); }
#modal .chips { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 720px) {
  .sched-cols { grid-template-columns: 1fr; }
  dl.sched-rows { grid-template-columns: 1fr; gap: 0; }
  dl.sched-rows dt { margin-top: 6px; font-size: var(--fs-sm); color: var(--muted); }
}

/* ---------- Work order header: job strip, then Schedule visit / Status / Category ---------- */
.wo-head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; gap: 12px 28px; margin-bottom: 14px; }
.wo-head h1 { margin: 0; white-space: nowrap; font-size: var(--fs-xl); font-weight: 700; }
@media (max-width: 720px) { .wo-head h1 { font-size: var(--fs-lg); } }
.wo-head .crumb { margin-bottom: 4px; }
.job-bar { display: flex; align-items: stretch; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); margin: 0 0 16px; }
.jb-cells { display: grid; grid-template-columns: 180px minmax(0, 1fr) minmax(0, 1fr); flex: 1; min-width: 0; }
.jb-cell { padding: 12px 18px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.jb-cell:last-child { border-right: 0; }
.jb-label { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.jb-value { font-size: 16px; min-height: 26px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.jb-value strong { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jb-value .jt-chip { align-self: flex-start; font-size: var(--fs-sm); padding: 4px 14px; }
.jb-sub { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.jb-dispatch { display: inline-flex; align-items: center; gap: 6px; }
.jb-dispatch .mono { font-size: 19px; font-weight: 700; letter-spacing: .02em; }
.jb-missing { color: #b54708; font-weight: 600; }
.jb-edit { align-self: center; margin: 0 10px; flex: none; }
.wo-actions { display: grid; grid-template-columns: 190px 240px minmax(0, 1fr); gap: 10px; align-items: stretch; }
.btn-schedule { height: 44px; padding: 0 18px; font-size: var(--fs-md, 15px); font-weight: 700; justify-content: center; box-shadow: 0 2px 8px rgba(217, 74, 48, .3); }
.btn-schedule .icon { width: 18px; height: 18px; }
.wo-actions .combo { width: 100%; }
.wo-actions .combo-btn { width: 100%; height: 44px; gap: 8px; }
.combo-prefix { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  padding-right: 9px; margin-right: 1px; border-right: 1px solid var(--line-strong); line-height: 18px; flex: none; }
.cat-combo .combo-value { font-weight: 600; }
.combo.colored .combo-btn { background: var(--jt); color: var(--jt-text, #fff); border-color: var(--jt); font-weight: 700; }
.combo.colored .combo-btn:hover { filter: brightness(.95); }
.combo.colored .combo-prefix { color: var(--jt-text, #fff); opacity: .8; border-right-color: currentColor; }
.combo.colored .combo-caret { border-color: var(--jt-text, #fff); }
.status-combo .combo-pop, .cat-combo .combo-pop { min-width: 300px; }
@media (max-width: 1100px) {
  .wo-head { grid-template-columns: minmax(0, 1fr); }
  .wo-actions { grid-template-columns: 190px minmax(0, 240px) minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .jb-cells { grid-template-columns: minmax(0, 1fr); }
  .jb-cell { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 14px; }
  .jb-cell:last-child { border-bottom: 0; }
  .jb-cell:empty { display: none; }
  .jb-edit { align-self: flex-start; margin: 10px 8px 0 0; }
  .wo-actions { grid-template-columns: minmax(0, 1fr); }
  .cat-combo .combo-value { white-space: normal; line-height: 1.3; }
  .wo-actions .cat-combo .combo-btn { height: auto; min-height: 44px; padding-top: 7px; padding-bottom: 7px; }
}

/* ---------- Address book picker (service + billing addresses) ---------- */
.addr-book { display: flex; flex-direction: column; gap: 8px; }
.addr-opt { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: var(--r); padding: 10px 10px 10px 12px; background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.addr-opt:hover { border-color: var(--faint); }
.addr-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.addr-opt > label { display: flex; align-items: flex-start; gap: 12px; flex: 1; min-width: 0; cursor: pointer; margin: 0; }
.addr-opt input[type=radio] { margin-top: 3px; accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.addr-txt { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.addr-line { font-weight: 600; }
.addr-sub { color: var(--muted); font-size: var(--fs-sm); }
.addr-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.addr-tag { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.addr-add { all: unset; box-sizing: border-box; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; border: 1px dashed var(--line-strong);
  border-radius: var(--r); color: var(--accent); font-weight: 600; cursor: pointer; }
.addr-add:hover, .addr-add:focus-visible { border-color: var(--accent); background: var(--accent-soft); }
.addr-add .icon { width: 16px; height: 16px; }
.addr-form { border: 1px solid var(--accent); border-radius: var(--r); padding: 12px 14px; background: var(--surface); box-shadow: 0 0 0 3px var(--focus); }
.addr-form-title { font-weight: 700; margin-bottom: 8px; }
.addr-form .form-actions { margin-top: 10px; }
.danger-text { color: #b42318; }
.danger-text:hover { background: #fef3f2; color: #912018; }
.sched-empty { display: flex; gap: 14px; align-items: flex-start; padding: 6px 4px; color: var(--muted); }
.sched-empty > .icon { width: 28px; height: 28px; flex: none; color: var(--faint); }
.sched-empty strong { color: var(--text); display: block; margin-bottom: 2px; }
.sched-empty p { margin: 0; }
.default-preview { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 14px; background: var(--bg, #f6f7f9); border-radius: var(--r); }

/* ---------- Visits: summary on the work order, the visit page, per-visit notes/photos ---------- */
.visit-summary { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin: 0 0 10px; padding: 8px 12px;
  background: var(--bg, #f6f7f9); border-radius: var(--r); font-size: var(--fs-sm); }
.visit-instr { color: var(--text); min-width: 0; flex: 1 1 300px; }
.visit-counts { display: inline-flex; gap: 14px; color: var(--muted); font-weight: 600; margin-left: auto; }
.visit-counts span { display: inline-flex; align-items: center; gap: 5px; }
.visit-counts .icon { width: 15px; height: 15px; }
.visit-counts:hover { color: var(--accent); }
.visit-chip { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); text-decoration: none; white-space: nowrap; }
.visit-chip:hover { background: var(--accent); color: var(--accent-text, #fff); }
.note-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip-toggle.sm { padding: 4px 11px; font-size: var(--fs-xs); }
.note-about-wrap { display: flex; flex-direction: column; gap: 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.note-about { height: 40px; border: 1px solid var(--line-strong); border-radius: var(--r); padding: 0 8px; background: var(--surface); font-size: var(--fs-sm); max-width: 220px; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--text); }
.photo-type { display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-right: 6px; }
.photo-group h3 a { color: inherit; }
.visit-page-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; align-self: end; }
.visit-job-cells { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)) !important; }
.visit-job .jb-value { font-size: 15px; }
.visit-job .clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clock-rows { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.instr-card { margin-bottom: 16px; }
.instr-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.visit-media { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.visit-media .chat-thread { max-height: 460px; }
.visit-instr-list ul { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 10px; }
.visit-instr-list li { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
@media (max-width: 900px) {
  .instr-cols, .visit-media { grid-template-columns: minmax(0, 1fr); }
  .visit-page-actions { justify-content: flex-start; }
}
.instr-cols .note-card + .note-card { margin-top: 0; }
.visit-media > .card { margin: 0; }
.chat-compose { flex-wrap: wrap; }
.chat-compose .chat-box { flex: 1 1 260px; min-width: 0; }
@media (max-width: 720px) {
  .note-about-wrap { flex: 1 0 100%; flex-direction: row; align-items: center; gap: 8px; }
  .note-about { max-width: none; flex: 1; }
}

/* ---------- Change log table ---------- */
.log-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 180px 200px 140px; gap: 8px; margin-bottom: 12px; }
.log-table td { vertical-align: top; }
.log-table .nowrap { white-space: nowrap; }
.log-who { display: inline-flex; align-items: center; gap: 6px; }
.log-val { max-width: 280px; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.log-from { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(0,0,0,.25); }
.log-to { color: var(--text); font-weight: 600; }
.th-sort { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; font: inherit; }
.th-sort:hover, .th-sort:focus-visible { color: var(--accent); }
@media (max-width: 720px) { .log-toolbar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .log-toolbar input { grid-column: 1 / -1; } }
.log-table { table-layout: fixed; min-width: 760px; }
.log-table th:nth-child(1) { width: 120px; } .log-table th:nth-child(2) { width: 170px; } .log-table th:nth-child(3) { width: 190px; }
.log-table td { overflow-wrap: anywhere; }
.log-val { max-width: none; }

/* ---------- Service address map ---------- */
.map-thumb { all: unset; box-sizing: border-box; position: relative; display: block; width: 100%; height: 150px; margin: 10px 0 8px; border-radius: var(--r);
  overflow: hidden; border: 1px solid var(--line); cursor: zoom-in; background: var(--surface-2, #eef0f3); }
.map-thumb iframe { width: 100%; height: 100%; border: 0; pointer-events: none; display: block; }
.map-thumb .map-hint { position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 5px; padding: 4px 9px; border-radius: 999px;
  background: rgba(17, 24, 39, .78); color: #fff; font-size: 12px; font-weight: 600; opacity: 0; transition: opacity .15s; }
.map-thumb .map-hint .icon { width: 13px; height: 13px; }
.map-thumb:hover .map-hint, .map-thumb:focus-visible .map-hint { opacity: 1; }
.map-thumb:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
.map-full { height: min(70vh, 720px); border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); }
.map-full iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (hover: none) { .map-thumb .map-hint { opacity: 1; } }

/* ---------- Service address footer: history badge + Google Maps ---------- */
.addr-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.addr-badge { all: unset; box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--accent); background: var(--accent-soft); cursor: pointer; white-space: nowrap; transition: background .12s, color .12s; }
.addr-badge .icon { width: 15px; height: 15px; }
.addr-badge strong { font-weight: 800; }
.addr-badge .arrow { transition: transform .12s; }
.addr-badge:hover, .addr-badge:focus-visible { background: var(--accent); color: var(--accent-text, #fff); }
.addr-badge:hover .arrow { transform: translateX(2px); }
.addr-badge:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
.addr-badge.new { color: #157347; background: #e8f5ee; }
.addr-badge.new:hover, .addr-badge.new:focus-visible { background: #157347; color: #fff; }
.addr-badge.loading { color: var(--faint); background: var(--surface-2, #eef0f3); cursor: default; }
.maps-btn { display: inline-flex; align-items: center; gap: 6px; height: 30px; }
.maps-btn .icon { width: 15px; height: 15px; }
.maps-btn .icon:last-child { width: 13px; height: 13px; opacity: .6; }
.maps-logo { width: 16px; height: 16px; object-fit: contain; flex: none; display: block; }
.btn-primary .maps-logo { background: #fff; border-radius: 4px; padding: 1px; width: 18px; height: 18px; }

/* ---------- Sign up ---------- */
.login-alt { text-align: center; margin: 18px 0 0; color: var(--muted); font-size: var(--fs-sm); }
.login-alt a { font-weight: 600; }
.login.signup { max-width: 460px; }
.signup-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field.has-error input { border-color: #d92d20; }
.field-error { color: #b42318; font-size: var(--fs-xs); font-weight: 600; }

/* ---------- Profile pages ---------- */
.profile-head { display: flex; gap: 22px; align-items: center; margin: 4px 0 20px; flex-wrap: wrap; }
.profile-photo { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.profile-photo .avatar.xl { width: 96px; height: 96px; font-size: 32px; }
.profile-head h1 { margin: 2px 0 0; font-size: var(--fs-xl); }
.profile-head .sub { margin: 2px 0 0; color: var(--muted); }
.profile-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.badge-owner { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 700;
  background: #fff4e5; color: #9a5b00; }
.badge-owner .icon { width: 14px; height: 14px; }
.profile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.profile-card { margin: 0; }
.profile-card .card-head h2 { display: flex; align-items: center; gap: 8px; }
.profile-card .card-head h2 .icon { width: 18px; height: 18px; color: var(--muted); }
.profile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.color-pill { display: inline-flex; align-items: center; gap: 8px; }
.profile-note { margin-top: 12px; }
.perm-table th.center, .perm-table td.center { text-align: center; }
.perm-table td.center input { width: 18px; height: 18px; accent-color: var(--accent); }
.perm-help { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 16px 0 0; font-size: var(--fs-sm); }
.perm-help dt { font-weight: 700; }
.perm-help dd { margin: 0; color: var(--muted); }
@media (max-width: 900px) { .profile-grid { grid-template-columns: minmax(0, 1fr); } .perm-help { grid-template-columns: 1fr; } }
.person-cell { display: flex; align-items: center; gap: 10px; }
.person-cell a.cell-main { color: inherit; text-decoration: none; }
.person-cell a.cell-main:hover { color: var(--accent); text-decoration: underline; }
.badge-owner.sm { padding: 1px 8px; font-size: 11px; }
.profile-grid > .profile-card { margin: 0 !important; }
.perm-table th.center { white-space: normal; min-width: 84px; line-height: 1.25; vertical-align: bottom; }
.perm-table td:first-child { min-width: 220px; }

/* ---------- Custom fields (same card style as the other lists) ---------- */
.cf-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 0 18px 0 0; }
.cf-toolbar .catalog-blurb { flex: 1 1 320px; }
.cf-section + .cf-section { border-top: 1px solid var(--line); }
.cf-section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 18px 4px; }
.cf-section-head h3 { margin: 0; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.cf-empty { padding: 4px 18px 14px; margin: 0; }
@media (max-width: 720px) { .cf-toolbar { padding: 0 14px 10px 0; } .cf-toolbar .segmented { margin-left: 14px; } }

/* ---------- Settings: grouped accordion menu + content ---------- */
.settings-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-menu { position: sticky; top: 76px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px; }
.sm-section + .sm-section { border-top: 1px solid var(--line); }
.sm-group { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 10px; border-radius: var(--r);
  cursor: pointer; font-weight: 700; font-size: var(--fs-sm); color: var(--text); }
.sm-group:hover { background: var(--surface-2, #f3f4f6); }
.sm-group:focus-visible { box-shadow: 0 0 0 3px var(--focus); }
.sm-group .icon { width: 17px; height: 17px; color: var(--muted); flex: none; }
.sm-group > span:nth-of-type(1) { flex: 1; }
.sm-count { font-size: 11px; font-weight: 700; color: var(--faint); background: var(--surface-2, #f3f4f6); border-radius: 999px; padding: 1px 7px; }
.sm-caret { width: 7px; height: 7px; border: solid var(--muted); border-width: 0 1.7px 1.7px 0; transform: rotate(45deg) translate(-2px, -2px); transition: transform .15s; flex: none; margin-left: 2px; }
.sm-group[aria-expanded="true"] .sm-caret { transform: rotate(225deg) translate(-2px, -2px); }
.sm-section.current .sm-group .icon { color: var(--accent); }
.sm-items { display: flex; flex-direction: column; padding: 0 0 8px 37px; gap: 1px; }
.sm-items a { display: block; padding: 7px 10px; border-radius: var(--r); color: var(--muted); font-size: var(--fs-sm); font-weight: 500; text-decoration: none; }
.sm-items a:hover { background: var(--surface-2, #f3f4f6); color: var(--text); }
.sm-items a.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.settings-body { min-width: 0; }
.settings-body > .card:first-child, .settings-body > .card.catalog:first-child { margin-top: 0; }
@media (max-width: 900px) {
  .settings-layout { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .settings-menu { position: static; }
}

/* ---------- Brand (Appliance Relay) ---------- */
.brand-logo { display: block; max-height: 84px; max-width: 196px; width: auto; height: auto; object-fit: contain; }
.brand-fallback { display: inline-flex; align-items: center; gap: 10px; }
.brand-fallback[hidden] { display: none; }
.login .brand-logo { max-height: 120px; max-width: 280px; margin: 0 auto; }
.login .brand { justify-content: center; }
.sidebar .brand { padding: 14px 20px 12px; }
/* The main call to action (Schedule visit, + New) in the logo's orange-red. */
.btn-schedule, .btn-primary.btn-schedule, #newBtn { background: var(--brand-cta); border-color: var(--brand-cta); color: var(--brand-cta-text); }
.btn-schedule:hover, #newBtn:hover { background: var(--brand-cta-hover); border-color: var(--brand-cta-hover); color: var(--brand-cta-text); }
h1, h2, .page-head h1, .wo-head h1 { color: var(--brand-navy); }

/* The logo has a white background: in dark mode show it on a rounded white tile. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-logo { background: #fff; border-radius: 12px; padding: 6px 10px; }
}

/* Signed in: the wide wordmark across the top of the sidebar. */
.brand-wordmark { max-height: 60px; max-width: 100%; }
.sidebar .brand { padding: 16px 18px 14px; }

/* =====================================================================
   Brand theme: more color and clearer structure.
   Navy top bar, blue-grey workspace, white cards that lift off it,
   tinted card headers, and a color per work order box.
   ===================================================================== */
:root {
  --bg: #E9EEF5;
  --line: #DCE3EC;
  --card-head: #F4F7FB;
  --shadow-card: 0 1px 2px rgba(16, 38, 64, .06), 0 2px 8px rgba(16, 38, 64, .05);
  --topbar-bg: linear-gradient(90deg, #183C60 0%, #1E4E80 100%);
  --sidebar-bg: #F7F9FC;
  --c-who: #2160A0; --c-where: #D94A30; --c-what: #183C60; --c-why: #C27C0E;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E141B; --card-head: #1A222C; --shadow-card: 0 1px 2px rgba(0,0,0,.4);
    --topbar-bg: linear-gradient(90deg, #102338 0%, #15304F 100%); --sidebar-bg: #121A23;
    --c-who: #6EA4E6; --c-where: #F07A62; --c-what: #8BB8EE; --c-why: #F2C277;
  }
}

/* Top bar */
.topbar { background: var(--topbar-bg); padding: 12px 32px; box-shadow: 0 2px 10px rgba(16, 38, 64, .18); }
.topbar .search .icon { color: #8FA6BF; }
.topbar .search input { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .18); color: #fff; }
.topbar .search input::placeholder { color: rgba(255, 255, 255, .7); }
.topbar .search input:focus { background: #fff; color: var(--text); border-color: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .25); }
.topbar .search:focus-within .icon { color: var(--faint); }
.topbar .menu-btn { color: #fff; }
.topbar .menu-btn:hover { background: rgba(255, 255, 255, .12); }
#newBtn { box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.main { padding-top: 18px; }

/* Sidebar */
.sidebar { background: var(--sidebar-bg); border-right-color: var(--line); }
.sidebar .brand { background: var(--surface); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.nav-group { color: var(--brand-navy); opacity: .7; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; font-weight: 700; }
.nav a { color: #3E4C5C; }
.nav a .icon { color: #6B7D91; }
.nav a:hover { background: #E6EEF8; color: var(--brand-navy); }
.nav a.active { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(33, 96, 160, .3); }
.nav a.active .icon { color: #fff; }
.sidebar-foot { background: var(--surface); }

/* Cards lift off the workspace */
.card, .w4, .job-bar, .table-wrap, .settings-menu, .visit-panel { box-shadow: var(--shadow-card); border-color: var(--line); }
.card-head { background: var(--card-head); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.card-head h2 { color: var(--brand-navy); }
table.grid thead th { background: var(--card-head); color: var(--brand-navy); }

/* Work order: one color per box (who / where / what / why) */
.w4 { border-top: 3px solid var(--w4c, var(--accent)); }
.w4.who { --w4c: var(--c-who); } .w4.where { --w4c: var(--c-where); } .w4.what { --w4c: var(--c-what); } .w4.why { --w4c: var(--c-why); }
.w4 .w4-label { color: var(--w4c); }
.w4 .w4-label .icon { color: var(--w4c); }
.job-bar { border-left: 4px solid var(--brand-cta); }
.jb-label { color: var(--brand-navy); opacity: .75; }
.visit-panel { border-left: 3px solid var(--accent); }

/* Tabs: a clearer "you are here" */
.tabs a.active { color: var(--accent); border-bottom-width: 3px; }
[role=tablist] [aria-selected="true"] { color: var(--accent); }

@media (max-width: 900px) {
  .topbar { padding: 10px 14px; }
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .nav a { color: #C3CEDA; }
  :root:not([data-theme="light"]) .nav a .icon { color: #8FA2B6; }
  :root:not([data-theme="light"]) .nav a:hover { background: #1B2836; color: #fff; }
  :root:not([data-theme="light"]) .nav a.active, :root:not([data-theme="light"]) .nav a.active .icon { color: #0B1419; }
  :root:not([data-theme="light"]) .nav-group { color: #8BB8EE; }
}

/* ---------- Search dropdown (results as you type) ---------- */
.search { position: relative; max-width: 640px; }
.gs-panel { position: absolute; top: calc(100% + 8px); left: 0; width: min(760px, calc(100vw - 32px)); max-height: min(72vh, 640px); overflow-y: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: 0 18px 48px rgba(16, 38, 64, .28);
  z-index: 60; padding: 6px; overscroll-behavior: contain; animation: comboIn .12s ease-out; }
.gs-section + .gs-section { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.gs-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 4px; }
.gs-head > span { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--brand-navy); }
.gs-head .icon { width: 14px; height: 14px; color: var(--accent); }
.gs-all { font-size: var(--fs-xs); font-weight: 700; color: var(--accent); text-decoration: none; }
.gs-all:hover { text-decoration: underline; }
.gs-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r);
  color: var(--text); text-decoration: none; cursor: pointer; }
.gs-item.hi { background: var(--accent-soft); }
.gs-item:hover { text-decoration: none; }
.gs-ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--card-head, #F4F7FB); color: var(--accent); }
.gs-item.hi .gs-ico { background: var(--accent); color: #fff; }
.gs-ico .icon { width: 16px; height: 16px; }
.gs-text { display: flex; flex-direction: column; min-width: 0; }
.gs-main { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-num { color: var(--brand-navy); }
.gs-sub { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-match { color: var(--brand-cta); font-weight: 600; }
.gs-right { display: inline-flex; gap: 6px; align-items: center; }
.gs-count { font-size: var(--fs-xs); color: var(--faint); font-weight: 600; white-space: nowrap; }
.gs-panel mark { background: #FFE8A3; color: inherit; border-radius: 3px; padding: 0 1px; }
.gs-empty { padding: 18px 14px; color: var(--muted); text-align: center; }
.search.searching .icon { animation: gsPulse .8s ease-in-out infinite alternate; }
@keyframes gsPulse { from { opacity: 1; } to { opacity: .35; } }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .gs-panel mark { background: #5C4A12; } }
@media (max-width: 720px) {
  .gs-panel { position: fixed; top: 58px; left: 8px; right: 8px; width: auto; max-height: calc(100vh - 72px); }
  .gs-right .jt-chip:first-child { display: none; }
}
.gs-panel .icon { position: static; transform: none; color: inherit; left: auto; top: auto; }
.gs-head .icon { color: var(--accent); }

/* Radio choices shown as cards */
.radios { display: grid; gap: 8px; }
.radio-card { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line, #d8dee6); border-radius: 8px; cursor: pointer; font-weight: 500; background: #fff; }
.radio-card:hover { border-color: var(--accent); }
.radio-card:has(input:checked) { border-color: var(--accent); background: #EEF4FB; box-shadow: inset 3px 0 0 var(--accent); }
.radio-card input { margin: 0; accent-color: var(--accent); }
.field[hidden] { display: none !important; }

/* Visit assignment: team or technician */
.seg { display: inline-flex; border: 1px solid var(--line, #d8dee6); border-radius: 8px; overflow: hidden; margin-bottom: 10px; }
.seg-opt { display: flex; align-items: center; cursor: pointer; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span { padding: 7px 16px; font-weight: 600; font-size: 14px; color: var(--muted, #556); }
.seg-opt + .seg-opt span { border-left: 1px solid var(--line, #d8dee6); }
.seg-opt input:checked + span { background: var(--accent); color: #fff; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -3px; }
.assign-box { background: #F6F9FC; border: 1px solid var(--line, #e3e8ef); border-radius: 10px; padding: 12px 14px; }
.assign-team { display: grid; gap: 10px; }
.assign-team[hidden], .assign-tech[hidden] { display: none !important; }
.assign-box select { max-width: 340px; }
.assign-kind { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; background: #E3EDF8; color: var(--brand-navy, #183C60); }
.wz-who { display: grid; grid-template-columns: 140px 1fr; gap: 10px; align-items: start; margin-top: 10px; }
.wz-who-label { font-size: 13px; font-weight: 600; color: var(--muted, #556); padding-top: 8px; }
@media (max-width: 640px) { .wz-who { grid-template-columns: 1fr; } }
.pool-tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: #FFF4E5; color: #9A5B00; border: 1px solid #F5D9A8; white-space: nowrap; }
.assign-cell { display: inline-flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.also-send summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); margin: 2px 0 6px; }
.wz-who-sub { display: block; font-weight: 400; font-size: 12px; color: var(--muted, #667); margin-top: 2px; }
.radio-card input[type=radio] { width: 18px; height: 18px; min-height: 0; flex: none; padding: 0; border: 0; box-shadow: none; background: none; }
.radio-card span { flex: 1; }
.seg { align-self: flex-start; width: max-content; max-width: 100%; }
.ac-off { display: flex; align-items: center; gap: 4px; color: #9A5B00; } .ac-off .icon { width: 13px; height: 13px; }
