:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --border: #e1e4df;
  --text: #1c2321;
  --muted: #66706c;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e3f1ef;
  --ok: #15803d;
  --ok-soft: #e4f4e9;
  --warn: #b45309;
  --warn-soft: #fdf0dc;
  --danger: #b42318;
  --danger-soft: #fdeceb;
  --done: #4b5563;
  --done-soft: #eceef1;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 2px 8px rgba(16, 24, 20, .04);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.45; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.boot { padding: 4rem; text-align: center; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #0e2a27; color: #d6e5e2; padding: 1.1rem .75rem; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: #fff; padding: 0 .5rem 1.25rem; font-size: 1.05rem; }
.brand img { width: 28px; height: 28px; }
.brand small { display: block; font-weight: 400; color: #8fb3ad; font-size: .72rem; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: #c9dbd8; padding: .55rem .7rem; border-radius: 8px; display: flex; gap: .6rem; align-items: center; font-size: .93rem; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav a.active { background: rgba(255, 255, 255, .12); color: #fff; font-weight: 600; }
.nav .sep { margin: .75rem .7rem .3rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #7fa39d; }
.side-foot { margin-top: auto; padding: .5rem .7rem; font-size: .82rem; color: #8fb3ad; }
.side-foot button { background: none; border: 0; color: #c9dbd8; padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.main { padding: 1.5rem 2rem 4rem; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.topbar, .bottom-nav, .backdrop, .m-totalbar { display: none; }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); align-items: start; }
.sticky-preview { position: sticky; top: 1rem; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat .label { color: var(--muted); font-size: .82rem; }
.stat .value { font-size: 1.55rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .55rem .95rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { padding: .35rem .65rem; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: .85rem; margin-bottom: .85rem; }
label { display: block; font-size: .83rem; font-weight: 600; color: #3b4542; }
label .hint { font-weight: 400; color: var(--muted); }
input, select, textarea { width: 100%; margin-top: .3rem; padding: .55rem .65rem; border: 1px solid #cdd3cf; border-radius: 8px; font: inherit; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; font-size: .9rem; cursor: pointer; }
.check input { width: auto; margin: 0; }
.input-prefix { position: relative; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
fieldset { border: 0; padding: 0; margin: 0 0 1rem; min-width: 0; }
.grid > * { min-width: 0; }
legend { font-weight: 700; margin-bottom: .6rem; padding: 0; font-size: .98rem; }

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.list th { text-align: left; color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: .5rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.list td { padding: .65rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--surface-2); }

.badge { display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; text-transform: capitalize; white-space: nowrap; }
.badge.confirmed, .badge.accepted { background: var(--brand-soft); color: var(--brand); }
.badge.tentative, .badge.sent { background: var(--warn-soft); color: var(--warn); }
.badge.completed, .badge.converted { background: var(--ok-soft); color: var(--ok); }
.badge.cancelled, .badge.rejected { background: var(--danger-soft); color: var(--danger); }
.badge.draft, .badge.inactive { background: var(--done-soft); color: var(--done); }
.badge.available { background: var(--ok-soft); color: var(--ok); }
.badge.booked { background: var(--danger-soft); color: var(--danger); }
.badge.b2c { background: #e0f2fe; color: #0369a1; text-transform: none; }
.badge.b2b { background: #fae8ff; color: #a21caf; text-transform: none; }
.badge.admin { background: #ede9fe; color: #6d28d9; }

.tabs { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { white-space: nowrap; padding: .45rem .9rem; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .9rem; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .btn { margin-top: .75rem; }
.filter-bar { display: flex; gap: .5rem; flex-wrap: wrap; }
.filter-bar select { width: auto; margin: 0; }
.filter-bar input { width: 230px; margin: 0; }
.card-actions { display: flex; gap: .4rem; margin-top: .4rem; flex-wrap: wrap; }
.notice { padding: .65rem .85rem; border-radius: 8px; font-size: .9rem; margin: .5rem 0; }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.notice.info { background: var(--brand-soft); color: var(--brand); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: #1c2321; color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .2); font-size: .9rem; max-width: 360px; }
.toast.err { background: var(--danger); }

.rate-grid { display: grid; grid-template-columns: minmax(130px, 1.2fr) 1fr 1fr; gap: .45rem .75rem; align-items: center; }
.rate-grid input { margin: 0; }
.rate-grid .rh { font-size: .8rem; font-weight: 700; }
.rate-grid .rl { font-size: .83rem; font-weight: 600; color: #3b4542; }
.seg { display: flex; gap: .5rem; flex-wrap: wrap; }
.seg label { flex: 1; min-width: 180px; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label > span { display: block; padding: .65rem .8rem; border: 1px solid var(--border); border-radius: 8px; font-weight: 600; }
.seg input:checked + span { border-color: var(--brand); outline: 2px solid var(--brand); background: var(--brand-soft); }
.seg input:focus-visible + span { outline: 3px solid var(--brand); }

.permit-box { border: 1px solid var(--border); border-radius: 8px; padding: .75rem; margin-bottom: .85rem; background: var(--surface-2); }
.permit-rows { display: flex; flex-direction: column; gap: .4rem; }
.permit-row { display: grid; grid-template-columns: 1fr 110px auto; gap: .4rem; align-items: center; }
.permit-row select, .permit-row input { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--brand-soft); color: var(--brand); border-radius: 999px; padding: .25rem .35rem .25rem .7rem; font-size: .85rem; font-weight: 600; }
.chip small { font-weight: 400; color: var(--text); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip button { border: 0; background: rgba(0, 0, 0, .08); border-radius: 999px; width: 20px; height: 20px; cursor: pointer; font: inherit; line-height: 1; color: inherit; }
.chip-add { width: auto; min-width: 170px; margin: 0; padding: .35rem .5rem; font-size: .85rem; }

/* ---------- vehicles ---------- */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 1rem; }
.vcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: .35rem; color: inherit; }
.vcard:hover { text-decoration: none; border-color: var(--brand); }
.vcard.selectable { cursor: pointer; text-align: left; font: inherit; }
.vcard.selected { border-color: var(--brand); outline: 2px solid var(--brand); }
.vcard.unavailable { opacity: .65; }
.vcard .top { display: flex; justify-content: space-between; align-items: start; gap: .5rem; }
.vcard .name { font-weight: 700; }
.vcard .reg { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; background: var(--surface-2); padding: .1rem .4rem; border-radius: 4px; border: 1px solid var(--border); }
.vcard .meta { color: var(--muted); font-size: .85rem; }
.vcard .rates { font-size: .84rem; border-top: 1px dashed var(--border); padding-top: .45rem; margin-top: .25rem; }

/* ---------- monthly fleet calendar ---------- */
.cal-toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.cal-toolbar .month { font-weight: 700; min-width: 150px; text-align: center; font-size: 1.05rem; }
.legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; background: var(--c); }
.fleet-cal-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table.fleet-cal { border-collapse: separate; border-spacing: 0; font-size: .78rem; width: 100%; table-layout: fixed; }
.fleet-cal th, .fleet-cal td { border-bottom: 1px solid var(--border); border-right: 1px solid #eef0ed; padding: 0; height: 40px; }
.fleet-cal thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; font-weight: 600; color: var(--muted); text-align: center; line-height: 1.15; padding: .3rem 0; font-size: .72rem; }
.fleet-cal thead th.wkend { color: #9a3412; }
.fleet-cal thead th.today { background: var(--brand); color: #fff; }
.fleet-cal th.vh { position: sticky; left: 0; background: var(--surface); z-index: 3; text-align: left; width: 150px; padding: .3rem .7rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fleet-cal th.vh small { overflow: hidden; text-overflow: ellipsis; }
.fleet-cal th.vh small { display: block; color: var(--muted); font-weight: 400; }
.fleet-cal td.free { cursor: pointer; }
.fleet-cal td.free:hover { background: var(--brand-soft); }
.fleet-cal td.free:hover::after { content: "+"; display: block; text-align: center; color: var(--brand); font-weight: 700; }
.fleet-cal td.past { background: repeating-linear-gradient(45deg, #fafafa, #fafafa 4px, #f3f4f2 4px, #f3f4f2 8px); cursor: default; }
.fleet-cal td.past:hover::after { content: none; }
.fleet-cal td.bk { padding: 3px 2px; }
.fleet-cal .bar { display: block; height: 100%; border-radius: 6px; padding: .2rem .4rem; font-size: .74rem; color: #fff; background: var(--brand); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 600; line-height: 1.2; text-decoration: none; }
.fleet-cal .bar small { display: block; font-weight: 400; opacity: .85; overflow: hidden; text-overflow: ellipsis; }
.fleet-cal .bar.tentative { background: #d97706; }
.fleet-cal .bar.completed { background: #64748b; }
.fleet-cal .bar.cont-l { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.fleet-cal .bar.cont-r { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.fleet-cal tfoot th, .fleet-cal tfoot td { background: var(--surface-2); text-align: center; font-weight: 600; color: var(--muted); }
.fleet-cal tfoot td.full { color: var(--danger); }
.fleet-cal tfoot td.some { color: var(--ok); }

/* ---------- monthly view: phone timeline ---------- */
.cal-mob, .mob-only { display: none; }
.fstrip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0 .6rem .7rem; }
.fs-head, .fs-strip { display: grid; grid-template-columns: repeat(var(--dim), minmax(0, 1fr)); }
.fs-head { position: sticky; top: var(--topbar-h, 0); z-index: 3; background: var(--surface); padding: .5rem 0 .3rem; border-bottom: 1px solid var(--border); font-size: .6rem; font-weight: 600; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.fs-head span { position: relative; height: 1.35rem; border-radius: 4px; cursor: pointer; }
.fs-head span::before { content: ""; position: absolute; left: 50%; top: 50%; width: 1px; height: 5px; margin-top: -2px; background: #c9cfcb; }
.fs-head span.tick::before, .fs-head span.sel::before { content: attr(data-n); position: absolute; left: 50%; top: 50%; width: auto; height: auto; margin: 0; transform: translate(-50%, -50%); background: none; z-index: 1; }
.fs-head span.sel::before { background: var(--text); color: #fff; border-radius: 4px; padding: .1rem .25rem; }
.fs-head span.wk { color: #9a3412; }
.fs-head span.today { color: var(--brand); font-weight: 800; }
.fs-head span.full::after { content: ""; position: absolute; left: 50%; bottom: -3px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--danger); }
.fs-row { margin-top: .6rem; }
.fs-name { font-size: .8rem; font-weight: 600; margin-bottom: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fs-name small { font-weight: 400; color: var(--muted); font-size: .7rem; margin-left: .2rem; }
.fs-strip { grid-template-rows: 26px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.fs-cell { grid-row: 1; border-right: 1px solid var(--surface); cursor: pointer; }
.fs-cell.wk { background: #ebe7e2; }
.fs-cell.past { background: repeating-linear-gradient(45deg, #f6f6f5, #f6f6f5 3px, #ecedeb 3px, #ecedeb 6px); }
.fs-cell.today { box-shadow: inset 0 -3px 0 var(--brand); }
.fs-cell.sel { background: var(--brand-soft); box-shadow: inset 0 0 0 2px var(--brand); }
.fs-bar { grid-row: 1; z-index: 1; margin: 2px 1px; border-radius: 5px; background: var(--brand); color: #fff; font-size: .62rem; font-weight: 600; line-height: 22px; padding: 0 .3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none !important; }
.fs-bar.tentative { background: #d97706; }
.fs-bar.completed { background: #64748b; }
.fs-bar.cont-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.fs-bar.cont-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.day-panel { margin-top: .75rem; }
.dp-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; text-align: center; padding-bottom: .6rem; border-bottom: 1px solid var(--border); }
.dp-list { list-style: none; margin: 0; padding: 0; }
.dp-list li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.dp-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.dp-veh { font-weight: 600; font-size: .88rem; min-width: 0; }
.dp-veh small, .dp-bk small { display: block; font-weight: 400; color: var(--muted); font-size: .74rem; }
.dp-bk { text-align: right; font-size: .85rem; color: var(--text); border-right: 3px solid var(--brand); padding-right: .5rem; min-width: 0; }
.dp-bk.tentative { border-color: #d97706; }
.dp-bk.completed { border-color: #64748b; }

/* ---------- mini month picker ---------- */
.mini-cal { max-width: 380px; }
.mini-cal .head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .5rem; }
.mini-cal .grid7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.mini-cal .dow { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 600; padding: .2rem 0; }
.mini-cal button.d { aspect-ratio: 1; border: 1px solid transparent; background: var(--surface-2); border-radius: 7px; font: inherit; font-size: .88rem; cursor: pointer; color: var(--text); }
.mini-cal button.d:hover:not(:disabled) { border-color: var(--brand); }
.mini-cal button.d.booked { background: var(--danger-soft); color: var(--danger); text-decoration: line-through; cursor: not-allowed; }
.mini-cal button.d.past { opacity: .35; cursor: not-allowed; }
.mini-cal button.d.inrange { background: var(--brand-soft); color: var(--brand); }
.mini-cal button.d.sel { background: var(--brand); color: #fff; font-weight: 700; }
.mini-cal button.d.today { border-color: var(--text); }

/* ---------- quotation ---------- */
.quote-preview table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.quote-preview td { padding: .45rem 0; border-bottom: 1px dashed var(--border); vertical-align: top; }
.quote-preview td.amt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; padding-left: 1rem; }
.quote-preview tr.excluded td { color: var(--muted); font-style: italic; }
.quote-preview tr.total td { font-weight: 800; font-size: 1.15rem; border-bottom: 0; padding-top: .7rem; }
.quote-preview tr.sub td { border-bottom: 0; padding: .25rem 0; }
.quote-preview .detail { display: block; color: var(--muted); font-size: .8rem; }

.doc { max-width: 820px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem 2.2rem; box-shadow: var(--shadow); }
.doc-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid var(--text); padding-bottom: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.doc-head .biz { font-size: 1.3rem; font-weight: 800; }
.doc-head .qmeta { text-align: right; }
.doc-head .qmeta .title { font-size: 1.05rem; font-weight: 800; letter-spacing: .1em; color: var(--brand); }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem 2rem; margin-bottom: 1.25rem; font-size: .92rem; }
.doc-grid .k { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; }
.doc .terms { white-space: pre-wrap; font-size: .85rem; color: #3b4542; border-top: 1px solid var(--border); padding-top: .8rem; margin-top: 1rem; }

@media print {
  body { background: #fff; }
  .side, .no-print, #toasts, .page-head { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
}

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: linear-gradient(160deg, #0e2a27 0%, #134e48 60%, #0f766e 100%); }
.auth .card { width: 100%; max-width: 420px; padding: 2rem; }
.auth .brand { color: var(--text); padding: 0 0 1.25rem; font-size: 1.2rem; }
.auth .brand small { color: var(--muted); font-size: .8rem; }
.auth .switch { margin-top: 1rem; text-align: center; font-size: .9rem; }

/* =====================================================================
   Small screens
   - up to 860px: compact app shell (top bar, drawer, bottom tabs)
   - up to 640px: phone layout (tables as cards, tighter spacing)
   - touch devices only: bigger tap targets, 16px inputs (stops iOS zoom)
   ===================================================================== */
@media (max-width: 860px) {
  :root { --topbar-h: 50px; --bnav-h: 56px; }
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }

  /* top bar */
  .topbar { display: flex; align-items: center; gap: .4rem; position: sticky; top: 0; z-index: 30; height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) .6rem 0; background: #0e2a27; color: #fff; }
  .topbar .brand { padding: 0; font-size: .95rem; min-width: 0; gap: .45rem; }
  .topbar .brand img { width: 24px; height: 24px; }
  .topbar .brand > div { min-width: 0; line-height: 1.2; }
  .topbar .brand small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .7rem; }
  .icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 8px; background: none; color: #fff; cursor: pointer; flex: none; }
  .icon-btn:hover, .icon-btn:focus-visible { background: rgba(255, 255, 255, .1); }

  /* sidebar becomes a slide-in drawer */
  .side { position: fixed; top: 0; left: 0; bottom: 0; z-index: 60; width: min(260px, 82vw); height: 100%; overflow-y: auto; padding: calc(1rem + env(safe-area-inset-top)) .6rem calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-100%); transition: transform .2s ease; box-shadow: 4px 0 24px rgba(0, 0, 0, .25); visibility: hidden; }
  .shell.nav-open .side { transform: none; visibility: visible; }
  .side-foot { padding: 1rem .7rem 0; }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(8, 20, 18, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .shell.nav-open .backdrop { opacity: 1; pointer-events: auto; }

  /* bottom tab bar */
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; height: calc(var(--bnav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; color: var(--muted); font-size: .68rem; font-weight: 600; text-decoration: none; }
  .bottom-nav a .ic { font-size: 1.05rem; line-height: 1.2; }
  .bottom-nav a.active { color: var(--brand); }
  .bottom-nav a.fab .ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 1.1rem; }
  .bottom-nav a.fab.active .ic { box-shadow: 0 0 0 3px var(--brand-soft); }

  .main { padding: 1rem 1rem calc(var(--bnav-h) + env(safe-area-inset-bottom) + 1.25rem); }
  .main:has(.m-totalbar) { padding-bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom) + 4.5rem); }
  .page-head { margin-bottom: 1rem; gap: .6rem; }
  .page-head > form { flex: 1 1 220px; }
  .page-head > form input { width: 100%; }
  .filter-bar { flex: 1 1 260px; }
  .filter-bar select { flex: 1 1 130px; }
  .filter-bar input { flex: 2 1 180px; width: auto; }

  /* tabs scroll sideways instead of wrapping */
  .tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { flex: 0 0 auto; }

  .sticky-preview { position: static; }
  .fleet-cal th.vh { width: 118px; padding: .3rem .5rem; }

  /* quotation form: total bar above the tab bar */
  .m-totalbar { display: flex; align-items: center; gap: .75rem; position: fixed; left: 0; right: 0; bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom)); z-index: 35; padding: .45rem 1rem; background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 14px rgba(16, 24, 20, .06); }
  .m-total { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 0; font: inherit; color: var(--text); cursor: pointer; }
  .m-total small { display: block; color: var(--muted); font-size: .72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-total b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }

  #toasts { left: 1rem; right: 1rem; bottom: calc(var(--bnav-h) + env(safe-area-inset-bottom) + .75rem); align-items: center; }
  .toast { max-width: 100%; }
}

@media (max-width: 640px) {
  :root { font-size: 14px; }
  h1 { font-size: 1.2rem; }
  h2 { font-size: 1.02rem; }
  .main { padding-left: .75rem; padding-right: .75rem; padding-top: .85rem; }
  .card { padding: .85rem; }
  .card + .card { margin-top: .75rem; }
  .grid { gap: .75rem; }
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .stat { padding: .7rem .8rem; }
  .stat .label { font-size: .75rem; }
  .stat .value { font-size: 1.15rem; overflow-wrap: anywhere; }
  .vgrid { gap: .6rem; }
  .vcard { padding: .8rem; }
  form .row { gap: .65rem; margin-bottom: .65rem; }

  .tabs { margin-bottom: .75rem; }
  .tabs a { padding: .4rem .75rem; font-size: .85rem; }
  .tabs.split { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .tabs.split a { white-space: normal; text-align: center; padding: .45rem .4rem; line-height: 1.25; }

  /* tables become cards */
  table.mcards, table.mcards tbody { display: block; }
  table.mcards thead { display: none; }
  table.mcards tr { display: flex; flex-direction: column; gap: .15rem; position: relative; padding: .65rem 0; border-bottom: 1px solid var(--border); }
  table.mcards tr:first-child { padding-top: 0; }
  table.mcards tr:first-child td.m-status { top: 0; }
  table.mcards tr:last-child { border-bottom: 0; }
  table.mcards td { display: block; padding: 0; border: 0; text-align: right; white-space: normal; font-size: .88rem; }
  table.mcards td .small { font-size: .78rem; }
  table.mcards td::before { content: attr(data-label); float: left; margin-right: 1rem; color: var(--muted); font-size: .8rem; text-align: left; }
  table.mcards td.m-head { order: -2; text-align: left; font-size: .95rem; padding-right: 6rem; margin-bottom: .15rem; }
  table.mcards td.m-head::before, table.mcards td.m-status::before { content: none; }
  table.mcards td.m-status { position: absolute; top: .65rem; right: 0; }
  table.mcards td.empty { text-align: center; }
  table.mcards tr.click:hover td { background: none; }

  .rate-grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr); gap: .4rem .5rem; }
  .rate-grid .rh { font-size: .72rem; }
  .rate-grid .rl { font-size: .76rem; }
  .permit-row { grid-template-columns: 1fr 90px auto; }
  .chip-add { flex: 1 1 100%; }
  .seg label { min-width: 0; flex-basis: 100%; }

  .cal-toolbar .month { min-width: 0; flex: 1; }
  .cal-desk, .desk-only { display: none; }
  .cal-mob { display: block; }
  .mob-only { display: inline; }
  .mini-cal { max-width: 360px; }

  .doc { padding: 1rem; }
  .doc-head .biz { font-size: 1.1rem; }
  .quote-preview td.amt { padding-left: .6rem; }
  .auth .card { padding: 1.4rem 1.1rem; }
}

/* touch screens: comfortable tap targets */
@media (max-width: 860px) and (pointer: coarse) {
  .btn { min-height: 40px; }
  .btn.small { min-height: 34px; }
  .nav a { padding: .7rem .8rem; }
  .check input { width: 18px; height: 18px; }
  .chip button { width: 24px; height: 24px; }
}
/* iOS zooms into any field under 16px; only bump size there */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 860px) { input, select, textarea { font-size: 16px; } }
}

@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .side, .backdrop { transition: none; }
}

@media print {
  .topbar, .bottom-nav, .backdrop, .m-totalbar { display: none !important; }
}

/* Send trip details (driver & vehicle) to customer */
.share-opts { display: flex; flex-wrap: wrap; gap: .4rem 1rem; margin-bottom: .5rem; }
.share-preview { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: .65rem .8rem; font: inherit; font-size: .85rem; margin: .5rem 0; max-height: 16rem; overflow: auto; }
.share-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
