:root {
  --bg: #eef1f4; --surface: #fff; --surface2: #f6f8fa; --fg: #16202b; --muted: #5d6b7a; --line: #d3dae2;
  --accent: #1f5fbf; --accent-fg: #fff; --ok: #1d7a4a; --warn: #b26a00; --bad: #c62828;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f151c; --surface: #18212b; --surface2: #1e2935; --fg: #e4eaf0; --muted: #8c9aa8; --line: #2a3745;
    --accent: #5b9bf0; --accent-fg: #0b1320; --ok: #4cc28a; --warn: #f0b04c; --bad: #ef6b6b; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f151c; --surface: #18212b; --surface2: #1e2935; --fg: #e4eaf0; --muted: #8c9aa8; --line: #2a3745;
  --accent: #5b9bf0; --accent-fg: #0b1320; --ok: #4cc28a; --warn: #f0b04c; --bad: #ef6b6b; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.4 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.splash { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }

/* Top bar + tabs */
.top {
  position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: max(8px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.top-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.brand { font-weight: 700; font-size: 17px; }
.who { font-size: 12px; color: var(--muted); text-align: right; line-height: 1.2; }
.who button { border: 0; background: none; color: var(--accent); padding: 0; font-size: 12px; cursor: pointer; }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin-top: 6px; scrollbar-width: none; }
.tabs button {
  border: 0; background: none; padding: 10px 12px; border-bottom: 2px solid transparent; color: var(--muted);
  font-weight: 600; white-space: nowrap; cursor: pointer;
}
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

main.view { padding: 14px max(16px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.narrow { max-width: 640px; margin: 0 auto; }

.top-right { display: flex; align-items: center; gap: 10px; }
.theme-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface2);
  font-size: 17px; line-height: 1; cursor: pointer; display: grid; place-items: center; padding: 0;
}

/* Board — phone: status chips that wrap (no sideways scrolling) + one vertical list */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.board-wrap { display: flex; flex-direction: column; gap: 12px; }
.status-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 7px 11px; font-size: 14px; cursor: pointer; color: var(--fg); min-height: 36px;
}
.chip .n { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip.on .n { color: inherit; opacity: .85; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.chip.on .dot { box-shadow: 0 0 0 2px var(--accent-fg); }
.board-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.group h2 { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 4px 2px 8px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.group h2 .n { margin-left: auto; font-weight: 500; }
.card-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.card-grid .card { margin: 0; }

/* Board — computer: statuses as a sidebar, cards in a grid that fits the width */
@media (min-width: 900px) {
  .board-wrap { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; max-width: 1400px; margin: 0 auto; }
  .status-nav { flex-direction: column; flex-wrap: nowrap; position: sticky; top: 110px; }
  .chip { border-radius: 10px; width: 100%; justify-content: flex-start; padding: 9px 12px; }
  .chip .n { margin-left: auto; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}
.card {
  display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--line));
  border-radius: 10px; padding: 10px; margin-bottom: 8px; cursor: pointer;
}
.card .l1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.card .l2, .card .l3 { font-size: 14px; color: var(--muted); }
.flags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.flag { font-size: 11px; padding: 2px 6px; border-radius: 6px; background: var(--surface2); border: 1px solid var(--line); color: var(--muted); }
.flag.ok { color: var(--ok); border-color: currentColor; }
.flag.no { color: var(--warn); border-color: currentColor; }
.empty { color: var(--muted); font-size: 14px; padding: 8px; }

/* Forms */
label.lab { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 6px; }
input[type="text"], input[type="search"], input[type="email"], input[type="number"], input[type="date"], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 11px 12px; font-size: 16px;
}
textarea { font-family: var(--mono); min-height: 110px; resize: vertical; }
.toolbar input, .toolbar select { width: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 0; font-size: 16px; }
.check input { width: 22px; height: 22px; }
button.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 11px 16px; font-weight: 600; cursor: pointer; }
button.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.btn.danger { color: var(--bad); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.row .grow { flex: 1; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.panel h3 { margin: 0 0 6px; font-size: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
pre.card-text { white-space: pre-wrap; font-family: var(--mono); font-size: 14px; background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin: 8px 0 0; }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.okc { color: var(--ok); }

table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th, table.t td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
table.t td.num, table.t th.num { text-align: right; white-space: nowrap; }
.scroll-x { overflow-x: auto; }
.diff-from { color: var(--bad); text-decoration: line-through; }
.diff-to { color: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat .v { font-size: 22px; font-weight: 700; }
.stat .k { font-size: 12px; color: var(--muted); }

/* Order sheet */
dialog.sheet {
  border: 0; padding: 0; width: min(640px, 100vw); max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0 auto;
  background: var(--bg); color: var(--fg);
}
@media (min-width: 700px) { dialog.sheet { height: auto; max-height: 92vh; margin-top: 4vh; border-radius: 14px; } }
dialog.sheet::backdrop { background: rgba(0,0,0,.45); }
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
}
.sheet-head h2 { margin: 0; font-size: 18px; flex: 1; }
.sheet-body { padding: 14px 16px max(30px, env(safe-area-inset-bottom)); }
/* the card by role: folded sections, the tech's head / client / sticky bar, the dispatcher's two columns */
details.fold { margin: 10px 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
details.fold > summary { cursor: pointer; padding: 12px 14px; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::before { content: '▸'; color: var(--muted); transition: transform .15s; }
details.fold[open] > summary::before { transform: rotate(90deg); }
details.fold > .panel, details.fold > details.panel { border: 0; margin: 0; box-shadow: none; border-top: 1px solid var(--line); border-radius: 0 0 12px 12px; }
details.fold > .panel > h3:first-child { display: none; }
.view-switch { font-size: 12px; padding: 6px 10px; }
.tech-head { padding: 4px 2px 10px; border-left: 4px solid var(--c); padding-left: 10px; margin-bottom: 10px; }
.tech-head .th-l1 { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 17px; }
.tech-head .th-problem { margin-top: 4px; }
.tech-head .th-visit { margin-top: 4px; font-weight: 700; color: var(--accent); }
.tech-client .tc-name { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.tech-client .tc-row { gap: 6px; margin-top: 6px; }
.tech-client .btn { padding: 12px; font-size: 15px; text-align: left; text-decoration: none; }
.tech-client .tc-addr { overflow-wrap: anywhere; }
.sticky-bar { position: sticky; bottom: 0; z-index: 3; margin: 12px -16px calc(-1 * max(30px, env(safe-area-inset-bottom))); padding: 10px 16px max(12px, env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -6px 16px rgba(0,0,0,.12); }
.sticky-bar .row { gap: 8px; align-items: center; }
.sticky-bar .sb-small { margin-top: 6px; }
.btn.big { font-size: 18px; padding: 15px; font-weight: 700; }
.tech-view .tax-lab, .tech-view #ptax { display: none; }
.wiz-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.wiz-step { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 12px; margin: 10px 0; }
.wiz-step h3 { margin: 0 0 8px; }
.wiz-step > .panel { border: 0; padding: 0; margin: 0; background: none; box-shadow: none; }
.wiz-step > .panel > h3:first-child { display: none; }
.outcomes { display: grid; gap: 8px; }
.outcomes .btn { border-left: 6px solid var(--c); text-align: left; }
.meth-btns { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 8px; }
.meth-btns .btn.big { padding: 12px 4px; font-size: 15px; }
.wizard #pmeth { display: none; }
.wizard .show-more #pmeth { display: block; }
.wizard .money-banner.now .mb-v { font-size: 30px; }
.phone-row { margin-top: 8px; }
.phone-row .ph-num { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.phone-row .ph-num a { color: var(--fg); text-decoration: none; }
.phone-row .ph-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 4px; }
.ph-btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 40px; padding: 6px 8px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface2); color: var(--fg); font: inherit; font-size: 14px;
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.ph-btn:hover { border-color: var(--accent); }
@media (min-width: 700px) { .phone-row .ph-btns { display: flex; } .ph-btn { min-height: 34px; padding: 4px 12px; } }
.client-hint .btn.primary { font-weight: 700; }
@keyframes justFilled { from { background: color-mix(in srgb, var(--accent) 30%, var(--surface)); } to { background: var(--surface); } }
input.just-filled, textarea.just-filled { animation: justFilled 1.6s ease-out; }
.sms-dlg { width: min(520px, 96vw); }
.sms-body { padding: 12px 16px 16px; }
.sms-body textarea { width: 100%; min-height: 140px; }
.sms-body .row { gap: 8px; margin-top: 8px; }
.rc-send { margin-top: 10px; padding: 10px; border: 1px dashed var(--line); border-radius: 10px; }
.rc-send .row { gap: 6px; margin-top: 6px; }
.rc-send input { flex: 1; min-width: 0; }
@media (min-width: 1000px) {
  dialog.sheet.desk-view { width: min(1120px, 96vw); }
  .card-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
}
.pay-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-bottom: 6px; }
.pay-row button { padding: 0 12px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; text-align: center; }
.login .box { max-width: 360px; }
.login h1 { margin: 0 0 6px; }

#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s;
  max-width: calc(100vw - 32px); z-index: 100;
}
#toast.show { opacity: 1; }
.chip .lbl-long { display: none; }
@media (min-width: 900px) { .chip .lbl { display: none; } .chip .lbl-long { display: inline; text-align: left; } }

/* Order sheet: trip (safety) steps */
.trip-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 8px 0 10px; }
.trip-steps .step { border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; background: var(--surface2); }
.trip-steps .step .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.trip-steps .step .v { font-weight: 600; margin-top: 2px; }
.trip-steps .step.done { border-color: var(--ok); }
.trip-steps .step.done .k { color: var(--ok); }
.trip-btn { width: 100%; font-size: 17px; padding: 14px; }
.trip-row { gap: 8px; align-items: stretch; }
.trip-row .trip-btn { width: auto; }
.still-btn { font-size: 15px; padding: 12px 14px; border-color: var(--accent); color: var(--accent); }
.still-btn:disabled { opacity: .55; }
.flag.trip-onway, .trip-line.trip-onway { color: var(--warn); border-color: currentColor; }
.flag.trip-arrived, .trip-line.trip-arrived { color: var(--accent); border-color: currentColor; }
.flag.trip-left, .trip-line.trip-left { color: var(--ok); border-color: currentColor; }

/* Schedule */
.sched { max-width: 760px; margin: 0 auto; }
.day-bar { display: grid; grid-template-columns: 48px 1fr 48px; gap: 8px; align-items: center; margin-bottom: 10px; }
.day-arrow { font-size: 22px; padding: 6px 0; height: 48px; }
.day-mid { text-align: center; }
.day-mid input[type="date"] { width: auto; padding: 6px 10px; font-size: 15px; }
.day-name { font-weight: 700; font-size: 18px; margin-top: 4px; }
.day-name .muted { font-weight: 400; font-size: 14px; }
.sched-tools select { width: auto; padding: 8px 10px; }
.sched-sum { margin-left: auto; }
/* the app's calendar (day / week / month) */
.cal { max-width: 1100px; }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; padding: 8px 10px; }
.seg .btn:first-child { border-radius: 10px 0 0 10px; }
.seg .btn:last-child { border-radius: 0 10px 10px 0; }
.seg .btn + .btn { margin-left: -1px; }
.cal-grid { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.cal-head, .cal-untimed, .cal-body { display: grid; grid-template-columns: 44px repeat(var(--cols), minmax(0, 1fr)); }
.cal-head { border-bottom: 1px solid var(--line); background: var(--surface); }
.cal-scroll { max-height: max(360px, calc(100vh - 250px)); max-height: max(360px, calc(100dvh - 250px)); overflow-y: auto; overscroll-behavior: contain; }
.cal-body { padding-top: 6px; box-sizing: content-box; }
.cal-dh { background: none; border: 0; border-left: 1px solid var(--line); padding: 6px 2px; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; min-width: 0; }
.cal-dh b { color: var(--fg); font-size: 15px; }
.cal-dh.today b { color: var(--accent-fg); background: var(--accent); border-radius: 50%; padding: 1px 6px; }
.cal-untimed { border-bottom: 1px solid var(--line); }
.cal-untimed .cal-gutter { font-size: 10px; padding: 4px 2px; }
.cal-ucol { border-left: 1px solid var(--line); padding: 3px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-chip, .cal-mchip { display: block; border: 0; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 16%, var(--surface)); color: var(--fg);
  border-radius: 5px; padding: 2px 4px; font: inherit; font-size: 11px; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-body { position: relative; }
.cal-body > .cal-gutter { position: relative; }
.cal-hour { position: absolute; right: 4px; transform: translateY(-50%); font-size: 10px; color: var(--muted); white-space: nowrap; }
.cal-hour:first-child { transform: none; }
.cal-col { position: relative; border-left: 1px solid var(--line); min-width: 0; }
.cal-col.today { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.cal-line { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); opacity: .6; }
.cal-block { position: absolute; z-index: 1; overflow: hidden; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left;
  border: 0; border-left: 4px solid var(--c); border-radius: 6px; padding: 3px 5px; font: inherit; font-size: 12px; line-height: 1.2; cursor: pointer;
  background: color-mix(in srgb, var(--c) 22%, var(--surface)); color: var(--fg); box-shadow: 0 0 0 1px var(--surface); }
.cal-block .t, .cal-block .n { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cal-block .k { font-size: 10px; color: var(--muted); }
/* worked-out visits (Left / no access / canceled): greyed in their place; the one where the tech is now: highlighted */
.cal-block.ph-past, .cal-mchip.ph-past { opacity: .45; filter: grayscale(.8); }
.cal-block.ph-here { box-shadow: 0 0 0 2px var(--accent); font-weight: 600; }
.sched-item.ph-past { opacity: .55; filter: grayscale(.7); }
.sched-item.ph-here { box-shadow: 0 0 0 2px var(--accent); }
.flag.past-flag { background: var(--surface2); color: var(--muted); text-transform: uppercase; }
.flag.here-flag { color: var(--accent); border-color: var(--accent); font-weight: 700; }
.no-access-btn { border-color: var(--warn); color: var(--warn); }
.no-access-line { color: var(--warn); font-weight: 600; margin: 4px 0; }
.cal-week .cal-block { padding: 2px 3px; font-size: 10px; }
.cal-week .cal-block b { word-break: break-all; line-height: 1.1; }
.cal-dh span { display: block; }
.cal-month { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.cal-mhead, .cal-mrow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-mhead div { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0; border-bottom: 1px solid var(--line); }
.cal-mday { min-height: 84px; min-width: 0; border: 0; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); background: none; color: var(--fg);
  font: inherit; padding: 3px; display: flex; flex-direction: column; gap: 2px; align-items: stretch; text-align: left; cursor: pointer; }
.cal-mday:first-child { border-left: 0; }
.cal-mday .d { font-size: 12px; font-weight: 600; }
.cal-mday.other { color: var(--muted); background: var(--surface2); }
.cal-mday.today .d { color: var(--accent-fg); background: var(--accent); border-radius: 50%; align-self: flex-start; padding: 0 5px; }
.cal-mchip { font-size: 10px; padding: 1px 3px; }
@media (max-width: 520px) {
  .cal-mday { min-height: 64px; }
  .cal-mchip { font-size: 9px; padding: 1px 2px; text-overflow: clip; }
  .cal-mchip .tm { display: none; }
  .cal-head, .cal-untimed, .cal-body { grid-template-columns: 34px repeat(var(--cols), minmax(0, 1fr)); }
  .seg .btn { padding: 7px 8px; font-size: 13px; }
}
.sched-list { display: flex; flex-direction: column; gap: 10px; }
.sched-item {
  display: grid; grid-template-columns: 84px 1fr; gap: 10px; background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--c, var(--line)); border-radius: 12px; padding: 12px;
}
.sched-item.is-canceled { opacity: .55; }
.sched-time { font-weight: 700; font-size: 15px; line-height: 1.25; }
.sched-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }
.sched-body .l1 { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sched-body .flag { display: inline-flex; align-items: center; gap: 4px; }
.trip-line { font-size: 14px; font-weight: 600; }
.sched-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sched-actions select { width: auto; max-width: 100%; padding: 9px 10px; font-size: 15px; }
.sched-actions .btn { padding: 9px 12px; }
.swipe-hint { text-align: center; }
@media (min-width: 900px) { .swipe-hint { display: none; } }
@media (max-width: 420px) {
  .sched-item { grid-template-columns: 1fr; gap: 4px; }
  .sched-time { font-size: 16px; }
}

/* Order sheet: visits, notes, reports, client */
.banner { border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-weight: 600; border: 1px solid currentColor; }
.banner.warn { color: var(--warn); }
.banner.bad { color: var(--bad); }
.visits { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.visit { border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.visit.cur { border-color: var(--accent); }
.visit-h { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.visit-h b { margin-right: auto; }
.visit-h input[type="date"] { width: auto; padding: 6px 8px; font-size: 15px; }
.visit-h input[type="text"] { width: 110px; padding: 6px 8px; font-size: 15px; }
.visit-h .btn { padding: 6px 10px; }
.add-visit { margin-top: 10px; }
.add-visit summary, details.raw summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 4px 0; }
.panel-h { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.panel-h h3 { margin: 0; }
.panel-h .btn { padding: 6px 12px; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
textarea.plain { font-family: var(--font); min-height: 70px; }
.tech-panel { border-color: var(--warn); }
.tech-note { color: var(--warn); font-weight: 600; }
.suggest { margin-top: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.suggest .sug { display: block; width: 100%; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; color: var(--fg);
  font: inherit; font-size: 13px; padding: 9px 10px; cursor: pointer; overflow-wrap: anywhere; }
.suggest .sug:first-child { border-top: 0; }
.suggest .sug:hover, .suggest .sug:focus { background: var(--surface2); }
.client-hint { margin-top: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.client-hint .row { margin-top: 6px; gap: 6px; flex-wrap: wrap; }
#mHint .banner, #eHint .banner { margin-top: 8px; }
.small-btn { padding: 3px 8px; font-size: 12px; }
.client-orders { display: flex; flex-direction: column; gap: 4px; }
.linkrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; text-align: left; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface2); color: var(--fg); font: inherit; padding: 8px 10px; cursor: pointer; }
.linkrow .num { margin-left: auto; font-weight: 600; }
.linkrow .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.client-box { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: var(--surface2); border: 1px solid var(--line); }
.linkbtn { border: 0; background: none; color: var(--accent); padding: 0; font: inherit; cursor: pointer; text-decoration: underline; }
.reports { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.report { border-left: 3px solid var(--line); padding: 2px 0 2px 10px; }
.quote { margin-top: 6px; }
.flag.bad { color: var(--bad); border-color: currentColor; }
.flag.lead { font-weight: 700; background: color-mix(in srgb, var(--bad) 14%, transparent); }
@media (max-width: 420px) { .tabs button { padding: 10px 8px; font-size: 15px; } .tabs { gap: 0; } }

/* "View as…" preview */
.viewas-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  background: #f6c453; color: #1a1200; font-size: 14px; border-radius: 10px; padding: 6px 6px 6px 12px; margin-bottom: 6px;
}
.viewas-bar .btn { padding: 6px 12px; background: #fff; color: #1a1200; border-color: transparent; }
.viewas-btn {
  position: relative; display: inline-flex; align-items: center; height: 36px; padding: 0 12px; border-radius: 18px;
  border: 1px solid var(--accent); color: var(--accent); background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
}
.viewas-btn select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.viewas-btn .sm { display: none; }
@media (max-width: 480px) { .viewas-btn .lg { display: none; } .viewas-btn .sm { display: inline; } .viewas-btn { padding: 0 10px; } .who { font-size: 11px; } }
.brand { white-space: nowrap; }
@media (max-width: 480px) { .brand { font-size: 15px; } .top-right { gap: 6px; } }

/* Assignment */
.unassigned { color: var(--bad); font-weight: 600; }
.tech-pick { display: flex; flex-wrap: wrap; gap: 0 16px; }
.tech-pick .check { padding: 6px 0; }
table.people input[type="text"] { padding: 6px 8px; font-size: 15px; }
table.people .check { padding: 4px 0; }

/* Order timeline */
details.timeline summary { cursor: pointer; padding: 2px 0; }
ol.tl { list-style: none; margin: 10px 0 0; padding: 0; border-left: 2px solid var(--line); }
.tl-item { display: grid; grid-template-columns: 26px 1fr; gap: 6px; padding: 6px 0 6px 8px; position: relative; }
.tl-item::before { content: ''; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.tl-item.tl-imp::before { background: var(--muted); }
.tl-ico { font-size: 16px; line-height: 1.3; }
.tl-item.tl-loud { background: color-mix(in srgb, var(--c) 14%, transparent); border-left: 4px solid var(--c); border-radius: 0 8px 8px 0; margin: 2px 0; }
.tl-item.tl-loud::before { background: var(--c); }
.tl-item.tl-loud > div > div:last-child { color: var(--c); font-weight: 700; }
.tl-when { font-size: 12px; color: var(--muted); }
.lang-btn { font-size: 12px; font-weight: 700; letter-spacing: .03em; }

/* job status select: the status colour as a bar on the left */
.st-select { border-left: 8px solid var(--c, var(--line)); }

/* photos / video */
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.thumb { position: relative; width: 64px; height: 64px; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph { font-size: 26px; line-height: 62px; }
.thumb .play { position: absolute; inset: auto 4px 4px auto; background: rgba(0,0,0,.6); color: #fff; border-radius: 4px; font-size: 11px; padding: 1px 4px; }
.file-btn { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--surface); }
.upl-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 13px; }
.upl-row .upl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upl-row progress { width: 90px; }
.upl-row.bad { color: var(--bad); }
.viewer { width: min(calc(100vw - 16px), 1100px); max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); margin: auto; box-sizing: border-box; padding: 0; border: 0; border-radius: 12px; background: var(--surface); color: var(--fg); }
.viewer::backdrop { background: rgba(0,0,0,.75); }
.viewer-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.viewer-head .small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-body { display: flex; justify-content: center; align-items: center; min-height: 200px; padding: 0 8px 8px; }
.viewer-body img, .viewer-body video { max-width: 100%; max-height: calc(100dvh - 80px); border-radius: 8px; }

/* invoice */
.inv-dlg { width: min(calc(100vw - 16px), 1200px); }
.inv-body { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 12px; padding: 0 10px 10px; }
.inv-form input, .inv-form select, .inv-form textarea { width: 100%; box-sizing: border-box; }
.inv-lines { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 13px; }
.inv-lines th { text-align: left; font-weight: 600; color: var(--muted); padding: 2px; }
.inv-lines td { padding: 2px; }
.inv-lines td:nth-child(2) { width: 56px; } .inv-lines td:nth-child(3) { width: 90px; } .inv-lines td:nth-child(4) { width: 40px; }
.inv-preview { width: 100%; min-height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
@media (max-width: 760px) { .inv-body { grid-template-columns: 1fr; } .inv-preview { min-height: 60vh; } }

/* bill (Money lines like invoice-generator) */
.bill-ed { display: grid; gap: 8px; margin-bottom: 10px; }
.bill-line { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; padding: 8px; border: 1px solid var(--line, #ddd); border-radius: 8px; }
.bill-pick { display: grid; gap: 4px; min-width: 0; }
.bill-pick select, .bill-pick input { min-width: 0; width: 100%; }
.bill-nums { grid-column: 1 / -1; display: grid; grid-template-columns: 90px 1fr auto; gap: 6px; align-items: end; }
.bill-nums label { display: grid; gap: 2px; }
.bill-nums button { padding: 0 12px; height: 40px; }
.bill-lines td:first-child { word-break: break-word; }
.bill-tot { margin-top: 6px; }
@media (max-width: 520px) { .bill-line { grid-template-columns: 1fr; } .bill-nums { grid-template-columns: 70px 1fr auto; } }

/* order card: address + copy button; Money block (bill lines, payments, documents); payment methods in the settings */
.addr-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.copy-addr { padding: 4px 10px; font-size: 12px; font-weight: 600; }
.bill-line2 { display: grid; grid-template-columns: 1fr 110px 40px; gap: 6px; margin-bottom: 6px; }
.bill-line2 .line-desc { grid-column: 1 / -1; font-size: 13px; padding: 6px 10px; margin-top: -2px; }
.pay-add { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.pay-add #padd { grid-column: 2; }
.docs-row { gap: 8px; margin-top: 10px; }
.docs-row .btn[disabled] { opacity: .45; cursor: not-allowed; }
.meth-row { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.meth-row > input[type=text] { flex: 1 1 180px; min-width: 0; }
.meth-row > label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; margin: 0; }
.meth-row > .btn { flex: 0 0 auto; width: auto; }
.meth-row label input[type=number] { width: 70px; }
.inv-preview.doc-full { width: 100%; height: 75vh; border: 0; background: #fff; }
.money-panel .step { font-weight: 700; margin: 14px 0 6px; }
.money-panel .save-row { margin-top: 4px; }
.money-panel .rest-row { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.money-panel .pay-btn { font-weight: 600; }
.money-panel .pay-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 4px; }
.money-panel .pay-h { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.money-panel .pay-new { border: 1px dashed var(--accent); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.money-panel .bill-line2.paid { align-items: center; color: var(--muted); padding: 6px 0; }
.money-panel .bill-line2.paid .num { text-align: right; }
.money-panel .pay-new[hidden], .money-panel [hidden] { display: none; }
.money-panel .tax-modes { display: flex; flex-direction: column; gap: 2px; }
.money-panel .credit-row { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; border-top: 1px dashed var(--line); }

/* Money: big banners the technician reads to the client — what is still owed, what the client pays now */
.money-banner { border-radius: 12px; padding: 12px 14px; margin: 8px 0; border: 2px solid var(--line); background: var(--surface2); }
.money-banner .mb-k { font-weight: 700; font-size: 14px; }
.money-banner .mb-v { font-size: 26px; font-weight: 800; line-height: 1.2; margin-top: 2px; }
.money-banner .mb-sub { font-size: 14px; font-weight: 500; color: var(--muted); }
.money-banner .mb-alts, .money-banner .mb-after { margin-top: 4px; font-size: 15px; }
.money-banner .mb-f { margin-top: 4px; font-size: 14px; word-break: break-word; }
.money-banner.due { border-color: var(--warn); }
.money-banner.due .mb-v { color: var(--warn); }
.money-banner.ok { border-color: var(--ok); }
.money-banner.ok .mb-v { color: var(--ok); }
.money-banner.now { border-color: var(--accent); }
.money-banner .nowrap { white-space: nowrap; }

/* visit time: "from / to" pickers, quick "+ Finish / + Recall / + SC" */
.time-pick { display: inline-flex; align-items: center; gap: 4px; }
.time-pick select { width: auto; min-width: 92px; }
.add-visit .kind-btns { gap: 6px; flex-wrap: wrap; }
.visit.st-canceled { opacity: .55; }
.visit.st-canceled .visit-h b { text-decoration: line-through; }
.card .l1 .bad { color: var(--bad); font-weight: 700; }
.rc-go { margin-top: 8px; }
.app-ver { text-align: center; font-size: 11px; color: var(--muted); padding: 16px 8px calc(16px + env(safe-area-inset-bottom)); opacity: .7; user-select: all; }
/* Settings: tax counties (name | % | ZIPs) */
.zone-row { display: grid; grid-template-columns: 1fr 90px; gap: 6px; margin-bottom: 8px; }
.zone-row textarea { grid-column: 1 / -1; font-size: 12px; }
