/* Bastion — no external dependencies */
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #1b2430;
  --muted: #6b7686;
  --line: #e2e6ec;
  --brand: #0f4c81;
  --brand-2: #1767ad;
  --accent: #19a974;
  --warn: #c77700;
  --bad: #c62828;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html { font-size: 14px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .25rem; font-weight: 650; }
h2 { font-size: 1.1rem; margin: 0 0 .9rem; font-weight: 650; display: flex; gap: .6rem; align-items: baseline; }
h3 { font-size: .95rem; margin: 1.2rem 0 .6rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; font-weight: normal; }
.center { text-align: center; }
.right { text-align: right; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .92em; }
.prewrap { white-space: pre-wrap; word-break: break-word; }
.bad-text { color: var(--bad); font-weight: 600; }
.warn-text { color: var(--warn); font-weight: 600; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; height: 56px;
  background: var(--brand); color: #fff; position: sticky; top: 0; z-index: 10;
}
.brand { color: #fff; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 400; opacity: .7; margin-left: .3rem; }
.logo { color: var(--logo-tint); }
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a { color: rgba(255,255,255,.82); padding: .45rem .6rem; border-radius: 6px; white-space: nowrap; }
.mainnav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.mainnav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.userbox { display: flex; gap: .9rem; align-items: center; white-space: nowrap; }
.userbox a { color: #fff; }
.userbox a.muted { color: rgba(255,255,255,.7); }
.quicksearch input {
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2); color: #fff;
  border-radius: 6px; padding: .4rem .7rem; width: 180px;
}
.quicksearch input::placeholder { color: rgba(255,255,255,.65); }
.menu-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; }

.container { max-width: 1400px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.footer { text-align: center; color: var(--muted); font-size: .85rem; padding: 1rem 0 2rem; }

/* Page heading */
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.crumbs { color: var(--muted); font-size: .9rem; margin-bottom: .2rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Buttons */
.btn {
  display: inline-block; padding: .5rem .9rem; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; line-height: 1.2;
}
.btn:hover { border-color: var(--line-2); text-decoration: none; background: var(--warm); }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { background: var(--brand); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.block { width: 100%; padding: .7rem; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand-2); cursor: pointer; font: inherit; }
.linkbtn.danger { color: var(--bad); }
form.inline { display: inline; }
form.inline.right { float: right; }

/* Cards & layout */
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.card.flush { padding: 0; overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid2 > .card { margin-bottom: 0; }
.grid2 + .card, .grid2 + section { margin-top: 1.25rem; }
.grid2.wide-left { grid-template-columns: 2fr 1fr; }
.grid2.wide-left > div > .card { margin-bottom: 1.25rem; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .9rem; margin-bottom: 1.5rem; }
.stat {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem;
  display: flex; flex-direction: column; color: var(--muted); border-left: 4px solid var(--brand-2);
}
a.stat:hover { text-decoration: none; box-shadow: 0 4px 12px rgba(16,24,40,.12); }
.stat .num { font-size: 1.55rem; font-weight: 700; color: var(--ink); }
.stat.warn { border-left-color: var(--warn); }
.stat.bad { border-left-color: var(--bad); }
.stats.small .stat { padding: .75rem 1rem; }
.stats.small .num { font-size: 1.25rem; }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--warm); }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--warm); }
.table .num, .table th.num { text-align: right; white-space: nowrap; }
.table tr.row-critical td:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.table tr.inactive td { opacity: .55; }
.table .totalrow td { font-weight: 700; font-size: 1.05rem; border-top: 2px solid var(--ink); }
.rowactions { white-space: nowrap; }
.rowactions > * + * { margin-left: .7rem; }
.tablewrap { overflow-x: auto; }
.items input, .items select { width: 100%; }
.items .qty, .items .price, .items .cost { max-width: 110px; }

/* Definition lists */
.dl { display: grid; grid-template-columns: 140px 1fr; gap: .45rem 1rem; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.dl.cols { grid-template-columns: 110px 1fr 110px 1fr; margin-bottom: 1rem; }

/* Badges */
.badge {
  display: inline-block; padding: .12rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600;
  background: var(--sunk); color: var(--ink-2); white-space: nowrap; vertical-align: middle;
}
.b-active, .b-won, .b-paid, .b-resolved { background: var(--ok-bg); color: var(--ok-ink); }
.b-prospect, .b-quote, .b-open, .b-normal { background: var(--soft); color: var(--brand-ink); }
.b-pending, .b-waiting, .b-in_repair, .b-high { background: var(--warn-bg); color: var(--warn-ink); }
.b-in_progress, .b-invoiced { background: var(--violet-bg); color: #5b34a8; }
.b-critical, .b-lost { background: var(--bad-bg); color: var(--bad-ink); }
.b-inactive, .b-retired, .b-closed, .b-low, .b-spare { background: var(--sunk); color: var(--muted); }
.b-primary { background: var(--soft); color: var(--brand-ink); }

/* Forms */
.form .field { margin-bottom: .9rem; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 1rem; }
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; color: #3b4555; }
label.check { display: flex; gap: .45rem; align-items: center; font-weight: 500; margin: .3rem 0 .9rem; }
label.inline-label { display: inline-flex; align-items: center; gap: .4rem; margin: 0; font-weight: 500; color: var(--muted); }
input, select, textarea {
  font: inherit; color: inherit; padding: .5rem .6rem; border: 1px solid var(--line-2); border-radius: 6px; background: var(--panel);
}
.field input, .field select, .field textarea { width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--brand-2); }
textarea { resize: vertical; }
.formactions { display: flex; gap: .5rem; margin-top: .5rem; }
.form.narrow { max-width: 520px; }
details summary { cursor: pointer; color: var(--brand-2); font-weight: 600; margin: 1rem 0 .8rem; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters input[type=search] { min-width: 260px; flex: 1 1 260px; max-width: 380px; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--brand-2); border-bottom-color: var(--brand-2); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }

.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; color: var(--muted); }

.flash { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; background: var(--ok-bg); color: var(--ok-ink); border: 1px solid var(--ok-line); }
.flash-error { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad-line); }

.note { border-left: 3px solid var(--line); padding: .25rem 0 .25rem .9rem; margin-bottom: 1rem; }
.note-head { display: flex; gap: .7rem; align-items: center; margin-bottom: .25rem; flex-wrap: wrap; }
.note-head form { margin-left: auto; }
.addnote { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }

.dangerzone { margin-top: 1.5rem; text-align: right; }

/* Login */
body.auth { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, #0f4c81, #0a2f52); }
.auth-card { background: var(--panel); padding: 2rem; border-radius: 12px; width: 100%; max-width: 380px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card .field { margin-bottom: 1rem; }
.auth-card .field input { width: 100%; }
.auth-brand { color: var(--brand); font-weight: 700; margin-bottom: .2rem; }
.auth-card h1 { margin-bottom: 1.25rem; }

/* Responsive */
@media (max-width: 1480px) {
  .brand small { display: none; }
  .quicksearch input { width: 150px; }
}
@media (max-width: 900px) {
  .grid2, .grid2.wide-left { grid-template-columns: 1fr; }
  .grid2 > .card { margin-bottom: 0; }
}
@media (max-width: 1260px) {
  .menu-toggle { display: block; margin-left: auto; }
  .topbar { flex-wrap: wrap; height: auto; padding: .7rem 1rem; gap: .6rem; }
  .mainnav, .userbox { display: none; width: 100%; flex: 0 0 100%; }
  body.nav-open .mainnav, body.nav-open .userbox { display: flex; flex-wrap: wrap; }
  .quicksearch, .quicksearch input { width: 100%; }
  .dl.cols { grid-template-columns: 110px 1fr; }
}

/* Print (sale quotes / invoices) */
@media print {
  .topbar, .footer, .actions, .noprint, .dangerzone, .filters, .pager { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; padding: 0; }
  .container { padding: 0; }
}

/* Tweaks */
input[type=checkbox] { width: auto !important; margin: 0; }
.dl + form { margin-top: 1rem; }
.items td { vertical-align: middle; }

/* Payments */
.b-partially_refunded { background: var(--warn-bg); color: var(--warn-ink); }
.b-refunded, .b-failed, .b-canceled { background: var(--bad-bg); color: var(--bad-ink); }
.b-expired { background: var(--sunk); color: var(--muted); }
.copyrow { display: flex; gap: .5rem; }
.copyrow input { flex: 1; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .85rem; }
.paycard { max-width: 440px; }
.paycard .payamount { font-size: 2.2rem; font-weight: 700; margin: 1rem 0; }
.paycard .paydl { grid-template-columns: 90px 1fr; margin-bottom: .5rem; }
.paycard .btn.block { margin-bottom: .75rem; }

/* Customer portal */
.note-customer { border-left-color: #f0b44c; }
.note-staff { border-left-color: var(--brand-2); }
.muted-light { color: rgba(255,255,255,.65); }
.userbox a.active { text-decoration: underline; }
.permform label.check { margin: 0 0 .2rem; font-size: .85rem; }
.invoice-head { display: flex; justify-content: space-between; gap: 2rem; margin-bottom: 1rem; flex-wrap: wrap; }
body.portal .topbar { background: #12395f; }

/* Logo */
.brand { display: inline-flex; align-items: center; gap: .55rem; }
.brand-logo { height: 30px; width: auto; display: block; }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: .5rem; margin-bottom: 1rem; font-size: 1.15rem; text-align: center; }
.auth-logo { width: 240px; max-width: 100%; height: auto; display: block; }
.auth-logo.auth-appicon { width: 132px; height: 132px; border-radius: 29px; box-shadow: 0 10px 30px rgba(10,40,90,.35); }
.auth-card h1 { text-align: center; }
@media print { .brand-logo { display: none; } }
.invoice-brand { display: flex; align-items: center; gap: .75rem; font-size: 1.2rem; }
.invoice-brand img { height: 72px; width: auto; }
.invoice-brand .doc-title { margin-left: auto; text-align: right; font-weight: 700; letter-spacing: .08em; font-size: 1.3rem; }
.invoice-brand .doc-title .muted { font-weight: 400; letter-spacing: 0; font-size: 1rem; }
.print-only { display: none; }
@media print { .print-only { display: flex !important; margin-bottom: 1.5rem; } .pagehead { display: none !important; } }

/* Products on sales */
.quickadd { display: flex; gap: .75rem; align-items: center; margin-bottom: .75rem; }
.quickadd input { flex: 1; max-width: 520px; }
.items select.product { min-width: 160px; }
.items select.type { min-width: 105px; }

/* Documents */
details.card > summary { margin: 0; }
details.card[open] > summary { margin-bottom: 1rem; }
.docupload input[type=file] { padding: .4rem; background: var(--warm); }
.flash-info { background: var(--soft); color: var(--brand-ink); border-color: var(--brand-line); }

/* Settings dropdown */
.navdrop { position: relative; }
.navdrop-toggle {
  background: none; border: 0; font: inherit; cursor: pointer; color: rgba(255,255,255,.82);
  padding: .45rem .6rem; border-radius: 6px; white-space: nowrap;
}
.navdrop-toggle:hover, .navdrop.open .navdrop-toggle { background: rgba(255,255,255,.1); color: #fff; }
.navdrop-toggle.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.navdrop-toggle .caret { font-size: .7em; opacity: .8; }
.navdrop-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; min-width: 190px; z-index: 50;
  background: var(--panel); border-radius: 8px; box-shadow: 0 10px 30px rgba(16,24,40,.18); padding: .35rem;
}
.navdrop.open .navdrop-menu { display: block; }
.mainnav .navdrop-menu a { display: block; color: var(--ink); padding: .5rem .75rem; border-radius: 6px; }
.mainnav .navdrop-menu a:hover { background: var(--sunk); color: var(--ink); }
.mainnav .navdrop-menu a.active { background: var(--soft); color: var(--brand); font-weight: 600; }
.navdrop-sep { height: 1px; background: var(--line); margin: .3rem .25rem; }
@media (max-width: 1260px) {
  /* In the collapsed menu, show Settings items inline */
  .navdrop { width: 100%; display: flex; flex-wrap: wrap; align-items: center; border-top: 1px solid rgba(255,255,255,.12); margin-top: .3rem; padding-top: .3rem; }
  .navdrop-toggle { pointer-events: none; padding-left: .6rem; color: rgba(255,255,255,.55); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
  .navdrop-toggle.active { background: none; color: rgba(255,255,255,.55); }
  .navdrop-toggle .caret, .navdrop-sep { display: none; }
  .navdrop-menu { display: flex; flex-wrap: wrap; position: static; background: none; box-shadow: none; padding: 0; min-width: 0; }
  .mainnav .navdrop-menu a { color: rgba(255,255,255,.82); padding: .45rem .6rem; }
  .mainnav .navdrop-menu a:hover { background: rgba(255,255,255,.1); color: #fff; }
  .mainnav .navdrop-menu a.active { background: rgba(255,255,255,.18); color: #fff; }
}

/* Settings overview */
.settings-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; margin-bottom: 1.25rem; }
.card.tile { display: flex; gap: 1rem; margin: 0; color: var(--ink); border: 1px solid transparent; }
.card.tile:hover { text-decoration: none; border-color: var(--brand-line); box-shadow: 0 4px 12px rgba(16,24,40,.1); }
.card.tile h2 { margin-bottom: .3rem; color: var(--brand-2); }
.card.tile p { margin: .2rem 0; }
.tile-icon { font-size: 1.8rem; line-height: 1; }
.statustable td { vertical-align: middle; }
.statustable .st { width: 36px; }
.statustable .lbl { width: 240px; font-weight: 600; }
.statustable .ok, .statustable .bad, .statustable .info { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: .8rem; font-weight: 700; }
.statustable .ok { background: var(--ok-bg); color: var(--ok-ink); }
.statustable .bad { background: var(--warn-bg); color: var(--warn-ink); }
.statustable .info { background: var(--sunk); color: var(--muted); font-style: italic; font-family: Georgia, serif; }
.narrow-card { max-width: 520px; }

/* ================================================================== */
/* iPhone / phone layout (≤ 760px)                                    */
/* ================================================================== */
.m-only { display: none !important; }

@media (max-width: 760px) {
  .m-only { display: revert !important; }
  html { font-size: 15px; -webkit-text-size-adjust: 100%; }
  body.staff { padding-bottom: calc(70px + env(safe-area-inset-bottom)); -webkit-tap-highlight-color: rgba(23,103,173,.15); }
  body.sheet-open { overflow: hidden; }

  /* Top bar: brand + search only (navigation moves to the tab bar) */
  body.staff .topbar {
    flex-wrap: nowrap; height: auto; gap: .5rem;
    padding: calc(.55rem + env(safe-area-inset-top)) calc(.9rem + env(safe-area-inset-right)) .55rem calc(.9rem + env(safe-area-inset-left));
  }
  body.staff .menu-toggle, body.staff .mainnav, body.staff .userbox,
  body.staff.nav-open .mainnav, body.staff.nav-open .userbox { display: none !important; }
  body.staff .brand { font-size: 1rem; }
  body.staff .brand-logo { height: 26px; }
  .m-topicon { margin-left: auto; color: #fff; font-size: 1.6rem; line-height: 1; padding: .1rem .4rem; text-decoration: none !important; }

  .container { padding: 1rem calc(.8rem + env(safe-area-inset-right)) 1.5rem calc(.8rem + env(safe-area-inset-left)); }
  .footer { display: none; }

  /* Page headings & actions */
  .pagehead { flex-direction: column; align-items: stretch; gap: .6rem; margin-bottom: 1rem; }
  h1 { font-size: 1.35rem; line-height: 1.25; }
  .pagehead .actions { gap: .4rem; }
  .pagehead .actions .btn, .pagehead .actions select { flex: 1 1 auto; text-align: center; }
  .pagehead .actions form.inline { display: flex; flex: 1 1 auto; }
  .pagehead .actions form.inline .btn, .pagehead .actions form.inline select { width: 100%; }

  /* Touch-friendly controls; 16px inputs stop iOS zooming in */
  input, select, textarea { font-size: 16px !important; min-height: 44px; }
  input[type=checkbox] { min-height: 0; width: 22px !important; height: 22px; }
  textarea { min-height: 90px; }
  .btn { min-height: 44px; padding: .65rem 1rem; display: inline-flex; align-items: center; justify-content: center; }
  label.check { font-size: 1rem; padding: .3rem 0; }
  .formgrid { grid-template-columns: 1fr; }
  .formactions { flex-wrap: wrap; }
  .formactions .btn { flex: 1 1 auto; }
  .form.narrow, .narrow-card { max-width: none; }

  /* Filters: full-width search, two selects per row */
  .filters { gap: .45rem; }
  .filters input[type=search] { flex: 1 1 100%; max-width: none; min-width: 0; }
  .filters select, .filters .inline-label { flex: 1 1 calc(50% - .45rem); min-width: 0; }
  .filters .inline-label input { flex: 1; min-width: 0; }
  .filters .btn { flex: 1 1 auto; }

  .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs a { white-space: nowrap; }

  /* Stats: two per row */
  .stats { grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1rem; }
  .stat { padding: .75rem .85rem; }
  .stat .num { font-size: 1.25rem; }

  .card { padding: 1rem; margin-bottom: 1rem; border-radius: 12px; }
  .grid2 { gap: 1rem; }
  .dl { grid-template-columns: 105px 1fr; }
  .dl.cols { grid-template-columns: 105px 1fr; }

  /* Tables become stacked cards: first cell is the title, others show "Label  value" */
  table.cardify, table.cardify tbody, table.cardify thead, table.cardify tfoot { display: block; width: 100%; }
  table.cardify tr.hdr { display: none; }
  table.cardify tr { display: block; padding: .75rem .2rem; border-bottom: 1px solid var(--line); }
  table.cardify tr:last-child { border-bottom: 0; }
  .card.flush table.cardify tr { padding: .8rem 1rem; }
  table.cardify td, table.cardify th { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
    padding: .18rem 0; border: 0; text-align: right; background: none !important; }
  table.cardify td::before { content: attr(data-label); color: var(--muted); font-size: .82rem; text-align: left; flex: 0 0 auto; max-width: 45%; }
  table.cardify td:not([data-label])::before, table.cardify td.span::before { content: none; }
  table.cardify td:first-child { display: block; text-align: left; font-size: 1.02rem; padding-bottom: .3rem; }
  table.cardify td:first-child::before { content: none; }
  table.cardify td:empty { display: none; }
  table.cardify td.num { text-align: right; }
  table.cardify td.span { justify-content: flex-end; }
  table.cardify td.rowactions { justify-content: flex-start; gap: 1.2rem; padding-top: .45rem; flex-wrap: wrap; }
  table.cardify td.rowactions::before { content: none; }
  table.cardify tr.totalrow td { font-size: 1.05rem; }
  table.cardify tr.row-critical { box-shadow: inset 4px 0 0 var(--bad); }
  table.cardify tr.row-critical td:first-child { box-shadow: none; }
  .card.flush { overflow: visible; }

  /* Sale line-item editor as cards */
  .items.cardify td { display: block; text-align: left; }
  .items.cardify td::before { display: block; margin-bottom: .2rem; }
  .items.cardify td input, .items.cardify td select { width: 100%; max-width: none !important; }
  .items.cardify td.linetotal { text-align: right; font-weight: 700; }
  .items.cardify tr.item td:last-child { text-align: right; }
  .quickadd { flex-wrap: wrap; }
  .quickadd input { max-width: none; flex: 1 1 100%; }

  .note-head { gap: .45rem; }
  .copyrow { flex-wrap: wrap; }
  .copyrow input { flex: 1 1 100%; }
  .dangerzone { text-align: center; }
  .dangerzone .btn { width: 100%; }
  .settings-tiles { grid-template-columns: 1fr; gap: .8rem; }
  .statustable .lbl { width: auto; }
  .invoice-head { gap: 1rem; }

  /* Bottom tab bar */
  .tabbar {
    display: flex !important; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--tabbar-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: .3rem env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    justify-content: space-around; align-items: center;
  }
  .tabbar a, .tabbar button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem; background: none; border: 0;
    font: inherit; font-size: .68rem; color: var(--faint); padding: .3rem 0 .35rem; text-decoration: none !important; cursor: pointer;
  }
  .tabbar .ti { font-size: 1.35rem; line-height: 1.1; }
  .tabbar .active { color: var(--brand-2); font-weight: 600; }
  .tabbar .tab-add { flex: 0 0 auto; }
  .tabbar .tab-add span {
    display: grid; place-items: center; width: 48px; height: 48px; margin-top: -18px; border-radius: 50%;
    background: var(--brand-2); color: #fff; font-size: 1.9rem; line-height: 1; box-shadow: 0 4px 12px rgba(23,103,173,.4);
  }

  /* Bottom sheets */
  .sheet-backdrop { position: fixed; inset: 0; background: rgba(10,20,35,.45); z-index: 60; }
  .sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; background: var(--panel); border-radius: 16px 16px 0 0;
    padding: .6rem calc(1rem + env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) calc(1rem + env(safe-area-inset-left));
    max-height: 85vh; overflow-y: auto; transform: translateY(100%); transition: transform .22s ease-out;
    box-shadow: 0 -8px 30px rgba(0,0,0,.15);
  }
  .sheet.open { transform: none; }
  .sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 0 auto .8rem; }
  .sheet h3 { margin: 0 0 .8rem; }
  .sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1rem; }
  .sheet-grid a {
    display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .9rem .3rem; border-radius: 12px;
    background: var(--sunk); color: var(--ink); font-size: .85rem; font-weight: 500; text-decoration: none !important;
  }
  .sheet-grid a span { font-size: 1.6rem; }
  .sheet-search { margin-bottom: .6rem; }
  .sheet-search input { width: 100%; }
  .sheet-list { display: flex; flex-direction: column; margin-bottom: .8rem; }
  .sheet-list a {
    display: flex; align-items: center; gap: .8rem; padding: .8rem .3rem; color: var(--ink); font-size: 1.02rem;
    border-bottom: 1px solid var(--line); text-decoration: none !important;
  }
  .sheet-list a span { width: 1.6rem; text-align: center; }
  .sheet-list a.danger { color: var(--bad); }

  /* Install hint */
  .install-hint {
    position: fixed; left: .7rem; right: .7rem; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 45;
    background: var(--ink); color: #fff; border-radius: 12px; padding: .8rem 2.4rem .8rem 1rem; font-size: .9rem;
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
  }
  .install-hint[hidden] { display: none; }
  .install-hint .linkbtn { position: absolute; right: .7rem; top: .6rem; color: #fff; font-size: 1.1rem; }
  .share-ico { display: inline-block; border: 1px solid rgba(255,255,255,.6); border-radius: 4px; padding: 0 .25rem; }

  /* Sign-in page on phones */
  body.auth { padding: env(safe-area-inset-top) .8rem env(safe-area-inset-bottom); align-items: start; padding-top: calc(2rem + env(safe-area-inset-top)); }
  .auth-card { padding: 1.5rem 1.25rem; }
}
.sheet[hidden], .sheet-backdrop[hidden] { display: none !important; }

/* Field quick actions (all screen sizes) */
.quickacts { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 0; }
.quickacts .btn { display: inline-flex; align-items: center; gap: .35rem; }
.timechips { display: flex; gap: .4rem; flex-wrap: wrap; margin: -.4rem 0 .8rem; }
.timechips button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: .35rem .8rem; font: inherit; font-size: .85rem; cursor: pointer; }
.timechips button:hover { border-color: var(--brand-2); color: var(--brand-2); }
.photo-btn { position: relative; overflow: hidden; }
.photo-btn input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0 !important; min-height: 0; }
@media (max-width: 760px) {
  .details-first > div:last-child { order: -1; }
  .quickacts .btn, .quickacts .photo-form { flex: 1 1 calc(50% - .5rem); }
  .quickacts .photo-form .btn { width: 100%; }
  .timechips button { padding: .5rem .9rem; font-size: .95rem; }
}
@media (max-width: 760px) {
  /* "#" column becomes a small ticket number above the title */
  table.cardify.idfirst td:first-child:not(.span) { display: inline-block; font-size: .8rem; color: var(--muted); padding: 0; }
  table.cardify.idfirst td:first-child a { color: var(--muted); }
  table.cardify.idfirst td:first-child:not(.span)::before { content: '#'; display: inline; }
  table.cardify.idfirst td:nth-child(2) { display: block; text-align: left; font-size: 1.02rem; padding: .1rem 0 .35rem; }
  table.cardify.idfirst td:nth-child(2)::before { content: none; }
  /* Ticket page: details & quick actions first, delete button last */
  .details-first > div:last-child { display: contents; }
  .details-first > div:last-child > section { order: -1; }
  .details-first > div:last-child > .dangerzone { order: 99; }
}
.emailbody { background: var(--warm); border: 1px solid var(--line); border-radius: 8px; padding: .9rem 1rem; max-height: 520px; overflow-y: auto; font-size: .95rem; }
.sheet-version { text-align: center; color: var(--muted); font-size: .8rem; margin: 0 0 .6rem; }

/* Maintenance mode */
.maint-banner { background: var(--warn-bg); color: var(--warn-ink); border-bottom: 1px solid var(--warn-line); padding: .6rem 1.25rem; font-size: .92rem; text-align: center; }
.maint-banner a { color: var(--warn-ink); font-weight: 700; text-decoration: underline; }
.maint-card { max-width: 480px; text-align: center; }
.maint-icon { font-size: 2.6rem; margin: .2rem 0 .4rem; }
.maint-msg { font-size: 1.05rem; line-height: 1.55; margin: .5rem 0 1rem; }
.maint-until { font-weight: 600; color: var(--brand); margin-bottom: 1rem; }
.maint-settings.is-on { border: 2px solid #f0b44c; }
.maint-grid { grid-template-columns: 2fr 1fr; }
.btn.danger-solid { background: #c77700; border-color: #c77700; color: #fff; }
.btn.danger-solid:hover { background: var(--warn-ink); }
@media (max-width: 760px) { .maint-grid { grid-template-columns: 1fr; } .maint-banner { padding: .55rem .9rem; } }

/* ================================================================== */
/* Schedule / appointments                                            */
/* ================================================================== */
.sched-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem 1.5rem; margin-bottom: 1rem; }
.sched-nav { display: flex; align-items: center; gap: .4rem; }
.sched-nav .btn { padding: .45rem .8rem; }
.sched-range { font-size: 1.1rem; margin-left: .5rem; }
.sched-tabs { margin: 0; border: 0; }
.sched-filter { display: flex; align-items: center; gap: .8rem; margin-left: auto; }
.sched-filter label.check { margin: 0; }

.weekgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.weekday { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: .5rem; min-height: 320px; display: flex; flex-direction: column; gap: .4rem; }
.weekday.weekend { background: var(--warm); }
.weekday.today { box-shadow: 0 0 0 2px var(--brand-2), var(--shadow); }
.wd-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .85rem; padding: .1rem .2rem .3rem; border-bottom: 1px solid var(--line); }
.wd-head strong { color: var(--ink); font-size: 1.05rem; margin-left: .15rem; }
.weekday.today .wd-head strong { color: #fff; background: var(--brand-2); border-radius: 999px; padding: 0 .45rem; }
.wd-add { font-size: 1.2rem; line-height: 1; padding: 0 .35rem; border-radius: 6px; color: var(--muted); }
.wd-add:hover { background: var(--sunk); text-decoration: none; color: var(--brand-2); }
.wd-empty { color: var(--faint); text-align: center; padding-top: .5rem; }

.appt-chip { display: flex; flex-direction: column; gap: .05rem; padding: .4rem .5rem .4rem .6rem; border-radius: 6px;
  background: color-mix(in srgb, var(--tc) 9%, var(--panel)); border-left: 4px solid var(--tc); color: var(--ink); font-size: .82rem; line-height: 1.3; }
.appt-chip:hover { text-decoration: none; background: color-mix(in srgb, var(--tc) 16%, var(--panel)); }
.appt-chip .t { font-weight: 700; color: var(--tc); font-size: .78rem; }
.appt-chip .c { font-weight: 600; }
.appt-chip .ti { color: var(--ink-2); }
.appt-chip .tech { color: var(--muted); font-size: .75rem; }
.appt-chip.st-completed { opacity: .7; }
.appt-chip.st-completed .t::after { content: ' ✓'; }
.appt-chip.st-canceled { opacity: .5; text-decoration: line-through; }
.appt-chip.st-no_show { opacity: .6; }
.appt-chip.st-no_show .t::after { content: ' · no-show'; font-weight: 400; }

.monthgrid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.mg-dow { background: var(--warm); padding: .45rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; text-align: center; }
.mg-day { background: var(--panel); min-height: 108px; padding: .3rem; display: flex; flex-direction: column; gap: .2rem; }
.mg-day.out { background: var(--warm); }
.mg-day.out .mg-num { color: var(--faint); }
.mg-num { font-size: .85rem; font-weight: 600; color: var(--ink); align-self: flex-start; padding: .05rem .35rem; border-radius: 999px; }
.mg-day.today .mg-num { background: var(--brand-2); color: #fff; }
.mg-day .appt-chip { flex-direction: row; display: block; padding: .15rem .35rem; font-size: .75rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left-width: 3px; }
.mg-more { font-size: .75rem; color: var(--muted); padding-left: .3rem; }
.mg-dots { display: none; }

.agenda-day h2 { font-size: 1rem; }
.agenda-day.today { border-left: 4px solid var(--brand-2); }
.agenda-day .appt-chip { display: grid; grid-template-columns: 170px 1fr auto; gap: .2rem 1rem; align-items: baseline; margin-bottom: .5rem; font-size: .92rem; }
.agenda-day .appt-chip .ti { grid-column: 2; }
.agenda-day .appt-chip .tech { grid-row: 1; grid-column: 3; }

.tech-legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; }
.techdot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }

/* Appointment detail */
.appt-when-card { display: flex; gap: 1.2rem; align-items: center; }
.appt-bigdate { flex: 0 0 auto; width: 74px; text-align: center; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 4px rgba(16,24,40,.12); background: var(--panel); }
.appt-bigdate .m { display: block; background: #d64545; color: #fff; font-size: .75rem; font-weight: 700; text-transform: uppercase; padding: .2rem 0; }
.appt-bigdate .d { display: block; font-size: 1.9rem; font-weight: 700; line-height: 1.15; padding-top: .15rem; }
.appt-bigdate .w { display: block; font-size: .75rem; color: var(--muted); padding-bottom: .3rem; }
.appt-time { font-size: 1.35rem; font-weight: 700; }
.appt-loc { margin-top: .35rem; }
.cancelbox { display: inline-block; }
.cancelbox > summary { list-style: none; margin: 0; color: var(--bad); }
.cancelbox > summary::-webkit-details-marker { display: none; }
.cancelbox[open] { display: block; width: 100%; margin-top: .8rem; }
.notifybox { border: 1px solid var(--line); border-radius: 8px; padding: .6rem 1rem .2rem; margin: 0 0 1rem; }
.when-grid { grid-template-columns: repeat(3, minmax(0, 200px)); }
.appt-mini { list-style: none; padding: 0; margin: 0; }
.appt-mini li { padding: .35rem 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; }
.appt-mini li:last-child { border-bottom: 0; }
.appt-mini li.st-canceled a { text-decoration: line-through; color: var(--muted); }

/* Portal: next appointment */
.next-appt { display: flex; gap: 1.2rem; align-items: center; border-left: 4px solid var(--brand-2); }
.next-appt h2 { margin: .15rem 0 .3rem; }
.next-appt-body { flex: 1; }
.portal-appt-note { margin: -.4rem 0 1.2rem; }

@media (max-width: 1100px) {
  .weekgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sched-bar { gap: .6rem; }
  .sched-nav { width: 100%; }
  .sched-range { margin-left: auto; font-size: 1rem; }
  .sched-filter { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .sched-filter select { flex: 1; }
  .weekgrid { grid-template-columns: 1fr; gap: .6rem; }
  .weekday { min-height: 0; }
  .weekday .wd-empty { display: none; }
  .weekday:not(:has(.appt-chip)) { padding: .35rem .5rem; }
  .weekday:not(:has(.appt-chip)) .wd-head { border-bottom: 0; padding-bottom: 0; }
  .mg-day { min-height: 54px; }
  .mg-day .appt-chip, .mg-more { display: none; }
  .mg-dots { display: block; color: var(--brand-2); font-size: 1.1rem; line-height: .6; text-align: center; letter-spacing: 1px; }
  .agenda-day .appt-chip { grid-template-columns: 1fr; }
  .agenda-day .appt-chip .ti, .agenda-day .appt-chip .tech { grid-column: 1; grid-row: auto; }
  .when-grid { grid-template-columns: 1fr 1fr; }
  .when-grid .field:first-child { grid-column: 1 / -1; }
  .next-appt { flex-wrap: wrap; }
  .next-appt-act { width: 100%; }
  .next-appt-act .btn { width: 100%; }
  .calfeeds { grid-template-columns: 1fr !important; }
}
.calfeeds { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.calfeeds h3 { margin-top: .5rem; }
.calfeeds p { margin: .6rem 0 0; }
@media (max-width: 1420px) and (min-width: 1261px) {
  .userbox > a[href="profile.php"] { display: none; }
  .quicksearch input { width: 130px; }
  .mainnav a, .navdrop-toggle { padding-left: .5rem; padding-right: .5rem; }
}

/* ================================================================== */
/* v1.3 theme: warm, rounded look + left sidebar                      */
/* ================================================================== */
/* v2.3 — theme variables (light is the default; dark follows the device or the user's choice) */
:root {
  color-scheme: light;
  --bg: #F7F5F2; --bg-glass: rgba(247,245,242,.88); --tabbar-bg: rgba(255,255,255,.97); --panel: #fff; --ink: #1E2430; --ink-2: #3D4554; --muted: #5D6575; --faint: #8A919C; --line: #ECE7E0;
  --line-2: #E2DCD3; --sunk: #F1EDE7;
  --brand: #174BA6; --brand-2: #1D5BC8; --brand-ink: #1659A0; --brand-line: #B9CDF2; --soft: #EAF1FD; --warm: #FAF8F5;
  --accent: #0B6B4A; --warn: #8A4B00; --bad: #A01818;
  --ok-bg: #E6F5EF; --ok-ink: #0B6B4A; --ok-line: #BFE9D6;
  --warn-bg: #FFF1DC; --warn-ink: #8A4B00; --warn-line: #F0D78A;
  --bad-bg: #FDECEC; --bad-ink: #A01818; --bad-line: #F0C4C4;
  --violet-bg: #F1ECFB; --violet-ink: #5B3BA8; --focus: #9CC9F5; --logo-tint: #7FD1FF;
  --radius: 20px; --shadow: 0 1px 3px rgba(30,36,48,.06); --shadow-lift: 0 8px 24px rgba(30,36,48,.10);
  --side-w: 248px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0F1319; --bg-glass: rgba(15,19,25,.86); --tabbar-bg: rgba(23,28,36,.96); --panel: #171C24; --ink: #E8ECF3; --ink-2: #C5CCD8; --muted: #9AA4B4; --faint: #7A8596; --line: #262D38;
  --line-2: #323A47; --sunk: #202732;
  --brand: #6C9BFF; --brand-2: #3F78E6; --brand-ink: #8DB2FF; --brand-line: #2F4673; --soft: #17233B; --warm: #1B212B;
  --accent: #3DC596; --warn: #E0A04A; --bad: #F07B7B;
  --ok-bg: #123226; --ok-ink: #5AD3A6; --ok-line: #1F5440;
  --warn-bg: #3A2A12; --warn-ink: #F0B65E; --warn-line: #5E4520;
  --bad-bg: #3A1A1D; --bad-ink: #FF9C9C; --bad-line: #6A2E33;
  --violet-bg: #261E3D; --violet-ink: #B8A2F5; --focus: #4F7FD6; --logo-tint: #7FD1FF;
  --shadow: 0 1px 3px rgba(0,0,0,.4); --shadow-lift: 0 8px 24px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg: #0F1319; --bg-glass: rgba(15,19,25,.86); --tabbar-bg: rgba(23,28,36,.96); --panel: #171C24; --ink: #E8ECF3; --ink-2: #C5CCD8; --muted: #9AA4B4; --faint: #7A8596; --line: #262D38;
  --line-2: #323A47; --sunk: #202732;
  --brand: #6C9BFF; --brand-2: #3F78E6; --brand-ink: #8DB2FF; --brand-line: #2F4673; --soft: #17233B; --warm: #1B212B;
  --accent: #3DC596; --warn: #E0A04A; --bad: #F07B7B;
  --ok-bg: #123226; --ok-ink: #5AD3A6; --ok-line: #1F5440;
  --warn-bg: #3A2A12; --warn-ink: #F0B65E; --warn-line: #5E4520;
  --bad-bg: #3A1A1D; --bad-ink: #FF9C9C; --bad-line: #6A2E33;
  --violet-bg: #261E3D; --violet-ink: #B8A2F5; --focus: #4F7FD6; --logo-tint: #7FD1FF;
  --shadow: 0 1px 3px rgba(0,0,0,.4); --shadow-lift: 0 8px 24px rgba(0,0,0,.5);
  }
}

body { font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; letter-spacing: -.003em; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; }
h2 { font-weight: 700; letter-spacing: -.01em; }
h3 { font-size: .78rem; font-weight: 700; letter-spacing: .07em; }
a { color: var(--brand-2); }

/* App shell */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main > .container { width: 100%; flex: 1; padding-top: 1.5rem; }
.sidebar {
  width: var(--side-w); flex: 0 0 var(--side-w); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 1.1rem .85rem .8rem;
  scrollbar-width: thin;
}
.side-brand { display: flex; align-items: center; gap: .7rem; padding: .2rem .55rem 1.1rem; color: var(--ink); }
.side-brand:hover { text-decoration: none; }
.side-brand img { width: 36px; height: 36px; object-fit: contain; flex: 0 0 auto; }
.side-brand .side-label { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.side-brand strong { font-size: .98rem; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-brand small { color: var(--muted); font-size: .78rem; font-weight: 500; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-item {
  display: flex; align-items: center; gap: .75rem; padding: .62rem .75rem; border-radius: 12px;
  color: var(--ink-2); font-weight: 600; font-size: .95rem; white-space: nowrap;
}
.side-item .ico { flex: 0 0 auto; color: var(--faint); }
.side-item:hover { background: var(--warm); text-decoration: none; color: var(--ink); }
.side-item.active { background: var(--soft); color: var(--brand-2); }
.side-item.active .ico { color: var(--brand-2); }
.side-label { min-width: 0; }
.side-count {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 .45rem; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--soft); color: var(--brand-2); font-size: .75rem; font-weight: 700;
}
.side-item.active .side-count { background: var(--panel); }
.side-count.amber { background: var(--warn-bg); color: var(--warn-ink); }
.side-section { margin: 1.1rem .75rem .35rem; font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.side-sub { display: flex; flex-direction: column; margin: 2px 0 4px 2.15rem; border-left: 2px solid var(--line); padding-left: .5rem; }
.side-sub a { padding: .4rem .7rem; border-radius: 10px; color: var(--muted); font-weight: 500; font-size: .9rem; }
.side-sub a:hover { background: var(--warm); text-decoration: none; color: var(--ink); }
.side-sub a.active { color: var(--brand-2); font-weight: 700; background: var(--soft); }
.side-user {
  display: flex; align-items: center; gap: .65rem; margin-top: 1rem; padding: .7rem .65rem; border-radius: 16px; background: var(--warm);
}
.side-avatar {
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--brand-2); color: #fff; font-weight: 700; font-size: .85rem;
}
.side-avatar:hover { text-decoration: none; }
.side-who { display: flex; flex-direction: column; line-height: 1.25; flex: 1; color: var(--ink); overflow: hidden; }
.side-who:hover { text-decoration: none; }
.side-who strong { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-who small { color: var(--muted); font-size: .76rem; }
.side-out { color: var(--muted); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; }
.side-out:hover { background: var(--panel); color: var(--bad); }
.side-version { text-align: center; color: var(--faint); font-size: .72rem; margin-top: .55rem; }

/* App bar */
.appbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1.75rem; background: var(--bg-glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.appsearch { position: relative; flex: 1; max-width: 520px; }
.appsearch .ico { position: absolute; left: .95rem; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.appsearch input { width: 100%; height: 44px; padding: 0 1rem 0 2.6rem; border-radius: 14px; border: 1px solid var(--line); background: var(--panel); }
.appbar-actions { margin-left: auto; display: flex; gap: .55rem; }
.appbar-brand { display: none; }
.btn .ico, .btn svg { vertical-align: -3px; }

/* Buttons, inputs */
.btn {
  border-radius: 14px; padding: .62rem 1.05rem; border: 1px solid var(--line); font-weight: 600; background: var(--panel);
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 42px;
}
.btn:hover { background: var(--warm); border-color: var(--line-2); }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); box-shadow: 0 2px 6px rgba(29,91,200,.22); }
.btn.primary:hover { background: var(--brand); border-color: var(--brand); }
.btn.danger { border-color: var(--bad-line); }
.btn.danger:hover { background: var(--bad-bg); }
.btn.block { border-radius: 14px; min-height: 48px; }
input, select, textarea { border-radius: 12px; border: 1px solid var(--line-2); padding: .6rem .8rem; background: var(--panel); }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select { min-height: 42px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(29,91,200,.18); border-color: var(--brand-2); }
label { color: var(--ink-2); font-weight: 600; }
details summary { color: var(--brand-2); }

/* Cards */
.card { border-radius: var(--radius); box-shadow: var(--shadow); border: 0; padding: 1.4rem 1.5rem; }
.card.flush { border-radius: var(--radius); }
.card h2 { font-size: 1.08rem; }
.grid2 { gap: 1.25rem; }
.pagehead { margin-bottom: 1.4rem; }
.crumbs { font-weight: 500; }

/* Stats */
.stat { border-left: 0; border-radius: 18px; padding: 1.05rem 1.15rem; gap: .1rem; font-weight: 500; font-size: .9rem; }
.stat .num { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
a.stat:hover { box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.stat.warn { background: var(--warn-bg); color: var(--warn-ink); }
.stat.warn .num { color: var(--warn-ink); }
.stat.bad { background: var(--bad-bg); color: var(--bad-ink); }
.stat.bad .num { color: var(--bad-ink); }
.stat { transition: box-shadow .15s, transform .15s; }

/* Tables */
.table th { background: transparent; color: var(--faint); font-size: .72rem; letter-spacing: .07em; font-weight: 700; border-bottom-color: var(--line); }
.table th, .table td { border-bottom-color: var(--sunk); padding: .72rem .85rem; }
.table tr:hover td { background: var(--warm); }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 1.4rem; }
.card.flush .table th:last-child, .card.flush .table td:last-child { padding-right: 1.4rem; }
.card.flush .table th { padding-top: 1rem; }
.table .totalrow td { border-top-color: var(--ink); }

/* Badges / chips */
.badge { padding: .2rem .6rem; font-weight: 700; font-size: .74rem; border-radius: 999px; }
.b-active, .b-won, .b-paid, .b-resolved { background: var(--ok-bg); color: var(--ok-ink); }
.b-prospect, .b-quote, .b-open, .b-normal, .b-primary { background: var(--soft); color: var(--brand-2); }
.b-pending, .b-waiting, .b-in_repair, .b-high, .b-partially_refunded { background: var(--warn-bg); color: var(--warn-ink); }
.b-in_progress, .b-invoiced { background: var(--violet-bg); color: var(--violet-ink); }
.b-critical, .b-lost, .b-refunded, .b-failed, .b-canceled { background: var(--bad-bg); color: var(--bad-ink); }
.b-inactive, .b-retired, .b-closed, .b-low, .b-spare, .b-expired { background: var(--sunk); color: var(--muted); }

/* Tabs as pills */
.tabs { border-bottom: 0; gap: .4rem; margin-bottom: 1.1rem; }
.tabs a { border: 0; margin: 0; padding: .5rem 1rem; border-radius: 999px; background: var(--panel); color: var(--muted); font-weight: 600; box-shadow: var(--shadow); }
.tabs a:hover { color: var(--ink); background: var(--panel); }
.tabs a.active { background: var(--ink); color: #fff; border: 0; }

/* Misc */
.flash { border-radius: 14px; border: 0; padding: .85rem 1.1rem; font-weight: 500; }
.note { border-left-width: 3px; background: var(--warm); border-radius: 0 14px 14px 0; padding: .7rem 1rem; }
.note-customer { border-left-color: #E9A23B; background: var(--warn-bg); }
.note-staff { border-left-color: var(--brand-2); }
.addnote { border-top-color: var(--line); }
.emailbody { background: var(--warm); border-color: var(--line); border-radius: 14px; }
.timechips button { border-color: var(--line); background: var(--panel); font-weight: 600; }
.card.tile { border: 1px solid transparent; }
.card.tile:hover { border-color: var(--brand-line); box-shadow: var(--shadow-lift); }
.statustable .ok { background: var(--ok-bg); color: var(--ok-ink); }
.statustable .bad { background: var(--warn-bg); color: var(--warn-ink); }
.maint-banner { background: var(--warn-bg); color: var(--warn-ink); border-bottom: 0; }
.maint-banner a { color: var(--warn-ink); }
.footer { color: var(--faint); font-size: .8rem; }

/* Dashboard */
.hello { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.3rem; }
.hello h1 { font-size: 2rem; margin: 0 0 .25rem; }
.hello p { margin: 0; }
.hello-date { color: var(--muted); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .3rem !important; }
.dash-top { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1.25rem; margin-bottom: 1.75rem; }
.upnext { display: flex; gap: 1.3rem; background: var(--soft); border-radius: 24px; padding: 1.5rem; align-items: flex-start; }
.upnext-date {
  flex: 0 0 76px; background: var(--panel); border-radius: 18px; text-align: center; padding: .6rem 0 .65rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column; line-height: 1.1;
}
.upnext-date span { color: var(--brand-2); font-weight: 800; text-transform: uppercase; font-size: .75rem; letter-spacing: .08em; }
.upnext-date strong { font-size: 2rem; font-weight: 800; letter-spacing: -.03em; margin: .1rem 0; }
.upnext-date small { color: var(--muted); font-weight: 600; }
.upnext-body { flex: 1; min-width: 0; }
.upnext-kicker { margin: 0 0 .3rem; color: var(--brand-2); font-weight: 700; font-size: .85rem; }
.upnext h2 { font-size: 1.35rem; margin: 0 0 .3rem; display: block; }
.upnext h2 a { color: var(--ink); }
.upnext-meta { margin: 0 0 1rem; color: var(--ink-2); }
.upnext-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.upnext-actions .btn:not(.primary) { border-color: transparent; }
.quicktiles { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.qtile {
  background: var(--panel); border-radius: 20px; padding: 1.05rem 1.1rem; box-shadow: var(--shadow); color: var(--ink);
  display: flex; flex-direction: column; gap: .15rem; transition: box-shadow .15s, transform .15s;
}
.qtile:hover { text-decoration: none; box-shadow: var(--shadow-lift); transform: translateY(-1px); }
.qtile .qi { margin-bottom: .55rem; }
.qtile strong { font-size: .98rem; }
.qtile small { color: var(--muted); }
.qi { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex: 0 0 auto; }
.qi-blue { background: var(--soft); color: var(--brand-2); }
.qi-green { background: var(--ok-bg); color: var(--ok-ink); }
.qi-amber { background: var(--warn-bg); color: var(--warn-ink); }
.qi-purple { background: var(--violet-bg); color: var(--violet-ink); }
.dash-h { font-size: 1.1rem; margin-bottom: .8rem; }

/* Auth pages (staff + portal sign-in, payment pages, maintenance) */
body.auth { background: var(--bg); }
.auth-card { border-radius: 24px; box-shadow: 0 1px 3px rgba(30,36,48,.06), 0 18px 40px rgba(30,36,48,.08); padding: 2.2rem 2rem; }
.auth-brand { color: var(--ink); }

/* Customer portal top bar (light) */
body.portal .topbar, .topbar {
  background: var(--panel); color: var(--ink); border-bottom: 1px solid var(--line); height: 64px;
}
.topbar .brand { color: var(--ink); }
.topbar .brand small { color: var(--muted); opacity: 1; }
.topbar .mainnav { gap: .3rem; }
.topbar .mainnav a { color: var(--muted); font-weight: 600; border-radius: 999px; padding: .5rem .95rem; }
.topbar .mainnav a:hover { background: var(--warm); color: var(--ink); }
.topbar .mainnav a.active { background: var(--soft); color: var(--brand-2); }
.topbar .userbox a { color: var(--ink); font-weight: 600; }
.topbar .userbox a.muted { color: var(--muted); }
.topbar .menu-toggle { color: var(--ink); }
.muted-light { color: var(--muted); }
body.portal .container { max-width: 1180px; }
.next-appt { border-radius: 20px; }

/* Settings dropdown (no longer used by staff, kept harmless) */
.navdrop-menu { border-radius: 14px; }

/* Responsive shell */
@media (max-width: 1260px) {
  :root { --side-w: 76px; }
  .sidebar { padding: 1rem .6rem; align-items: stretch; }
  .sidebar .side-label, .side-section, .side-sub, .side-count { display: none !important; }
  .side-brand { justify-content: center; padding: .2rem 0 1rem; }
  .side-item { justify-content: center; padding: .7rem 0; position: relative; }
  .side-item .ico { width: 22px; height: 22px; }
  .side-nav .side-item:nth-of-type(6) { margin-top: 1rem; }   /* gap before Billing group */
  .side-nav .side-item:nth-of-type(10) { margin-top: 1rem; }  /* gap before Workspace group */
  .side-user { flex-direction: column; background: none; padding: .4rem 0; gap: .4rem; }
  .side-version { display: none; }
  .appbar { padding: .75rem 1.25rem; }
  .appbar .btn { padding: .6rem .8rem; }
  .side-item:has(.side-count)::after {
    content: ''; position: absolute; top: 8px; right: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-2); border: 2px solid var(--panel);
  }
}
@media (max-width: 1100px) {
  .dash-top { grid-template-columns: 1fr; }
  .quicktiles { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
  .appbar-actions .btn:not(.primary) { display: none; }
  .quicktiles { grid-template-columns: 1fr 1fr; }
}

/* Phones */
@media (max-width: 760px) {
  .sidebar { display: none; }
  .appbar {
    padding: calc(.55rem + env(safe-area-inset-top)) calc(1rem + env(safe-area-inset-right)) .55rem calc(1rem + env(safe-area-inset-left));
    gap: .5rem; background: var(--bg-glass);
  }
  .appbar-brand { display: flex !important; align-items: center; gap: .55rem; font-weight: 800; color: var(--ink); font-size: 1.02rem; }
  .appbar-brand:hover { text-decoration: none; }
  .appbar-brand img { width: 30px; height: 30px; object-fit: contain; }
  .appsearch, .appbar-actions { display: none; }
  .m-topicon { margin-left: auto; color: var(--ink); width: 42px; height: 42px; display: grid !important; place-items: center; border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
  body.staff { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .main > .container { padding-top: .75rem; }
  .card { border-radius: 20px; padding: 1.1rem; }
  .btn { border-radius: 14px; min-height: 46px; }
  input, select, textarea { min-height: 46px; }
  h1 { font-size: 1.45rem; }

  .hello h1 { font-size: 1.5rem; }
  .dash-top { gap: .9rem; margin-bottom: 1.25rem; }
  .upnext { background: var(--brand-2); color: #fff; padding: 1.15rem; gap: 1rem; border-radius: 24px; }
  .upnext-date { flex-basis: 62px; border-radius: 16px; }
  .upnext-date strong { font-size: 1.6rem; }
  .upnext-kicker { color: rgba(255,255,255,.8); }
  .upnext h2 { font-size: 1.15rem; }
  .upnext h2 a, .upnext-meta { color: #fff; }
  .upnext-meta { opacity: .85; margin-bottom: .85rem; }
  .upnext .btn { flex: 1 1 auto; border-color: transparent; }
  .upnext .btn.primary { background: #fff; color: #1D5BC8; box-shadow: none; }
  .upnext .btn:not(.primary) { background: rgba(255,255,255,.16); color: #fff; }
  .quicktiles { grid-template-columns: repeat(4, 1fr); gap: .5rem; }
  .qtile { padding: .7rem .2rem .6rem; align-items: center; text-align: center; border-radius: 18px; }
  .qtile .qi { width: 44px; height: 44px; margin-bottom: .35rem; }
  .qtile strong { font-size: .74rem; font-weight: 700; line-height: 1.2; }
  .qtile small { display: none; }
  .stat { border-radius: 16px; }

  /* Floating rounded tab bar */
  .tabbar {
    left: calc(.75rem + env(safe-area-inset-left)); right: calc(.75rem + env(safe-area-inset-right));
    bottom: calc(.6rem + env(safe-area-inset-bottom)); border-radius: 24px; border: 1px solid var(--line);
    padding: .35rem .4rem; background: var(--tabbar-bg); box-shadow: 0 8px 28px rgba(30,36,48,.14);
  }
  .tabbar a, .tabbar button { color: var(--faint); font-size: .68rem; font-weight: 600; border-radius: 18px; padding: .4rem 0 .35rem; gap: .15rem; }
  .tabbar .ti { width: 22px; height: 22px; }
  .tabbar .active { color: var(--brand-2); background: var(--soft); }
  .tabbar .tab-add { background: none !important; flex: 0 0 auto; padding: 0 .35rem; }
  .tabbar .tab-add span { width: 50px; height: 50px; margin-top: 0; border-radius: 16px; background: var(--brand-2); box-shadow: 0 4px 12px rgba(29,91,200,.35); }
  .install-hint { bottom: calc(92px + env(safe-area-inset-bottom)); border-radius: 18px; }

  /* Sheets */
  .sheet { border-radius: 24px 24px 0 0; }
  .sheet-grid a { background: var(--warm); border-radius: 18px; font-weight: 600; }
  .sheet-grid a .qi { width: 44px; height: 44px; }
  .sheet-list a { gap: .85rem; font-weight: 500; border-bottom-color: var(--sunk); }
  .sheet-list a svg { color: var(--faint); flex: 0 0 auto; }
  .sheet-list a.danger svg { color: var(--bad); }
  .sheet-list .side-count { margin-left: auto; }

  /* Cardified tables: warm separators */
  table.cardify tr { border-bottom-color: var(--sunk); }
  .tabs a { box-shadow: none; }

  /* Portal header on phones */
  .topbar { height: auto; padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem; }
}

/* Print: no shell */
@media print {
  .sidebar, .appbar, .tabbar, .sheet, .sheet-backdrop, .maint-banner { display: none !important; }
  .app { display: block; }
  body { font-family: "Plus Jakarta Sans", -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
  .table th { color: var(--muted); }
}
.upnext-date strong { color: var(--ink); }
.app { background: linear-gradient(to right, var(--panel) calc(var(--side-w) - 1px), var(--line) calc(var(--side-w) - 1px), var(--line) var(--side-w), transparent var(--side-w)); }
.upnext-later { margin: 1.1rem 0 0; padding: .9rem 0 0; border-top: 1px solid rgba(29,91,200,.15); list-style: none; display: flex; flex-direction: column; gap: .45rem; }
.upnext-later li { display: flex; gap: .7rem; font-size: .9rem; color: var(--ink-2); }
.upnext-later li strong { color: var(--brand-2); min-width: 150px; font-weight: 700; }
.upnext-later a { color: inherit; }
@media (max-width: 760px) { .app { background: none; } .upnext-later { display: none; } }
/* Date tiles (appointment detail, portal) in the new style */
.appt-bigdate { border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); background: var(--panel); border: 0; }
.appt-bigdate .m { background: var(--soft) !important; color: var(--brand-2) !important; font-weight: 800; letter-spacing: .08em; }
.appt-bigdate .d { font-weight: 800; color: var(--ink); }
.next-appt { border-left: 0; background: var(--soft); }
.readonly-value { min-height: 42px; display: flex; align-items: center; padding: 0 .85rem; border-radius: 12px; background: var(--warm); font-weight: 700; letter-spacing: .02em; }

/* v1.4: payment method picker, checkbox lines */
.segmented { display: flex; gap: .5rem; flex-wrap: wrap; }
.segmented label {
  flex: 1 1 140px; display: flex; align-items: center; gap: .5rem; min-height: 48px; padding: 0 1rem; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel); font-weight: 700; color: var(--ink);
}
.segmented label:has(input:checked) { border-color: var(--brand-2); background: var(--soft); color: var(--brand-2); box-shadow: 0 0 0 1px var(--brand-2) inset; }
.segmented input { accent-color: var(--brand-2); width: 18px; height: 18px; min-height: 0 !important; }
.checkline { display: flex; align-items: center; gap: .55rem; font-weight: 500; color: var(--ink-2); margin: .2rem 0 .9rem; min-height: 42px; }
.checkline input { width: 18px; height: 18px; min-height: 0 !important; accent-color: var(--brand-2); }
.form.narrow .formgrid { grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .form.narrow .formgrid { grid-template-columns: 1fr; } }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.inline-form input[type=email] { flex: 1 1 260px; max-width: 380px; }

/* v1.5: USD inputs get a "$" prefix */
input.money {
  padding-left: 1.65rem !important; font-variant-numeric: tabular-nums;
  background: var(--panel) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='20'%3E%3Ctext x='1' y='15' font-family='Arial,sans-serif' font-size='15' font-weight='600' fill='%235D6575'%3E%24%3C/text%3E%3C/svg%3E") no-repeat .6rem 50%;
}
td input.money { padding-left: 1.4rem !important; background-position: .4rem 50%; }
.asset-id-chip { display: inline-block; margin: .35rem 0 0; padding: .2rem .65rem; border-radius: 999px; background: var(--soft); color: var(--brand-2);
  font: 700 .85rem ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; }
th.chk, td.chk { width: 36px; padding-right: 0 !important; }
td.chk input, th.chk input { width: 18px; height: 18px; min-height: 0 !important; accent-color: var(--brand-2); }
/* v1.5: attachments */
.attach-list { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .55rem; }
.attach-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .7rem; border-radius: 999px; background: var(--panel);
  border: 1px solid var(--line); font-size: .85rem; font-weight: 600; color: var(--ink); max-width: 100%; }
.attach-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.attach-chip small { color: var(--muted); font-weight: 500; }
.attach-chip:hover { text-decoration: none; border-color: var(--brand-line); background: var(--soft); }
.attach-rows { list-style: none; margin: 0; padding: 0; }
.attach-rows li { display: flex; flex-direction: column; gap: .15rem; padding: .65rem 0; border-bottom: 1px solid var(--sunk); }
.attach-rows li:last-child { border-bottom: 0; }
.attach-rows li > a { font-weight: 600; word-break: break-word; }
.attach-acts { display: flex; gap: .7rem; align-items: center; flex-wrap: wrap; font-size: .85rem; }
.attach-field input[type=file] { padding: .55rem; border: 1px dashed var(--line-2); border-radius: 12px; background: var(--warm); width: 100%; }
.attach-field label .ico { vertical-align: -3px; }

/* v1.5: reports */
.report-filters { align-items: center; }
.custom-dates { display: inline-flex; gap: .5rem; flex-wrap: wrap; }
.csvlink { float: right; font-weight: 600; font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; margin-top: .25rem; }
.card h2.padded { padding: 1.3rem 1.4rem .2rem; margin: 0; }
.stat small { font-size: .78rem; font-weight: 500; }
.rbars { display: flex; flex-direction: column; gap: .55rem; }
.rbar { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: .75rem; font-size: .9rem; }
.rbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-weight: 500; }
.rbar-label a { color: inherit; }
.rbar-track { height: 12px; background: var(--sunk); border-radius: 4px; overflow: hidden; }
.rbar-fill { display: block; height: 100%; background: var(--brand-2); border-radius: 0 4px 4px 0; }
.rbar-val { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); min-width: 4.5rem; text-align: right; font-size: .85rem; }
.rcols { margin: .5rem 0 0; }
.rcols-plot { display: flex; align-items: flex-end; gap: 3px; height: 190px; padding-top: 22px; border-bottom: 1px solid var(--line-2);
  background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), var(--sunk) calc(25% - 1px), var(--sunk) 25%); }
.rcol { flex: 1; height: 100%; position: relative; display: flex; align-items: flex-end; justify-content: center; outline: none; }
.rcol-bar { display: block; width: min(70%, 44px); background: var(--brand-2); border-radius: 4px 4px 0 0; }
.rcol:hover .rcol-bar, .rcol:focus .rcol-bar { background: var(--brand); }
.rcol-peak { position: absolute; left: 50%; transform: translate(-50%, -4px); font-size: .72rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.rcol-tip { display: none; position: absolute; bottom: calc(100% - 14px); left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: .35rem .6rem; border-radius: 10px; font-size: .75rem; white-space: nowrap; z-index: 3; text-align: center; line-height: 1.3; pointer-events: none; }
.rcol-tip strong { display: block; font-size: .85rem; }
.rcol:hover .rcol-tip, .rcol:focus .rcol-tip { display: block; }
.rcols-axis { display: flex; gap: 3px; margin-top: .35rem; }
.rcols-axis span { flex: 1; text-align: center; font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: visible; }
.rtable-toggle { margin-top: .6rem; }
.rtable-toggle summary { cursor: pointer; font-size: .85rem; font-weight: 600; }
@media (max-width: 760px) {
  .rbar { grid-template-columns: 1fr auto; }
  .rbar-track { grid-column: 1 / -1; order: 3; }
  .rcols-plot { height: 150px; }
  .csvlink { float: none; margin-left: .5rem; }
}
@media print { .report-filters, .tabs, .csvlink, .rtable-toggle { display: none !important; } .rbar-fill, .rcol-bar { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

/* v1.6: asset photos */
.cardhead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .9rem; }
.cardhead h2 { margin: 0; }
.small-btn { min-height: 38px; padding: .45rem .85rem; font-size: .9rem; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.photo { margin: 0; }
.photo-open { display: block; aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: var(--warm); box-shadow: var(--shadow); }
.photo-open img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.photo-open:hover img { transform: scale(1.04); }
.photo-fallback { display: grid; place-items: center; width: 100%; height: 100%; font-weight: 800; color: var(--muted); letter-spacing: .08em; }
.photo figcaption { display: flex; justify-content: space-between; align-items: center; font-size: .78rem; color: var(--muted); padding: .35rem .2rem 0; }
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(20,22,28,.92); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: calc(100vw - 140px); max-height: calc(100vh - 120px); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,.5); background: var(--panel); }
.lightbox button { position: absolute; background: rgba(255,255,255,.14); color: #fff; border: 0; width: 48px; height: 48px; border-radius: 50%;
  font-size: 1.6rem; line-height: 1; cursor: pointer; display: grid; place-items: center; }
.lightbox button:hover { background: rgba(255,255,255,.28); }
.lb-close { top: calc(16px + env(safe-area-inset-top)); right: 16px; font-size: 1.1rem !important; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-bar { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 0; right: 0; display: flex; justify-content: center; gap: 1.2rem; color: var(--line); font-size: .88rem; }
.lb-bar a { color: #fff; font-weight: 600; }
body.lb-open { overflow: hidden; }
@media (max-width: 760px) {
  .photo-grid { grid-template-columns: repeat(3, 1fr); gap: .45rem; }
  .photo-open { border-radius: 12px; }
  .photo figcaption span { display: none; }
  .photo figcaption { justify-content: flex-end; }
  .lightbox img { max-width: 100vw; max-height: calc(100vh - 160px); border-radius: 0; }
  .lb-prev, .lb-next { top: auto !important; bottom: calc(56px + env(safe-area-inset-bottom)); transform: none !important; }
  .cardhead { flex-wrap: wrap; }
}
@media print { .photo-form, .lightbox, .photo figcaption form { display: none !important; } .photo-grid { grid-template-columns: repeat(4, 1fr); } }

/* v1.7: mileage + billing */
.b-mileage { background: var(--ok-bg); color: var(--ok-ink); display: inline-flex; align-items: center; gap: .2rem; }
a.badge:hover { text-decoration: none; filter: brightness(.96); }
.billform .billrow { display: flex; align-items: center; gap: .5rem; justify-content: space-between; margin-bottom: .4rem; }
.billform .billrow .checkline { margin: 0; min-height: 0; flex: 1; }
.billform .billrow input[type=number] { width: 120px; flex: 0 0 120px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
th.thumbcol, td.thumbcol { width: 64px; padding-right: 0 !important; }
.docthumb { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 10px; overflow: hidden; background: var(--warm); }
.docthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.docthumb:hover { box-shadow: 0 0 0 2px var(--brand-line); }
@media (max-width: 760px) { td.thumbcol::before { display: none !important; } td.thumbcol { width: auto; } }
/* recurring plan line items */
#plan-items { table-layout: fixed; width: 100%; }
#plan-items th:nth-child(1) { width: 170px; } #plan-items th:nth-child(3) { width: 140px; }
#plan-items th:nth-child(4) { width: 80px; } #plan-items th:nth-child(5), #plan-items th:nth-child(6) { width: 120px; }
#plan-items th:nth-child(7) { width: 110px; } #plan-items th:nth-child(8) { width: 36px; }
#plan-items input, #plan-items select { width: 100%; min-width: 0; }
#plan-items td { padding-left: .35rem; padding-right: .35rem; }
@media (max-width: 760px) { #plan-items { table-layout: auto; } #plan-items th { width: auto !important; } }
@media print { .app { background: none !important; } }
/* balance hint on payment forms */
.balance-box { margin: -.2rem 0 1rem; padding: .7rem .95rem; border-radius: 12px; background: var(--warm); color: var(--ink-2); font-size: .92rem; }
.balance-box.due { background: var(--warn-bg); color: var(--warn-ink); }
.balance-box.ok { background: var(--ok-bg); color: var(--ok-ink); }

/* customer: current balance box */
.balance-card { border-left: 0; }
.balance-head { display: flex; justify-content: space-between; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
.balance-card h2 { margin: 0 0 .2rem; }
.balance-amount { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.balance-sub { margin: .2rem 0 .25rem; font-weight: 500; }
.balance-meta { margin: 0; }
.balance-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.balance-card.is-due { background: var(--warn-bg); } .balance-card.is-due .balance-amount { color: var(--warn-ink); }
.balance-card.is-overdue { background: var(--bad-bg); } .balance-card.is-overdue .balance-amount { color: var(--bad-ink); }
.balance-card.is-clear .balance-amount { color: var(--ok-ink); }
.balance-table { margin-top: 1rem; background: color-mix(in srgb, var(--panel) 70%, transparent); border-radius: 14px; }
@media (max-width: 760px) { .balance-amount { font-size: 1.9rem; } .balance-actions { width: 100%; } .balance-actions .btn { flex: 1 1 100%; } }

/* Customer page tabs */
.ctabs { display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none; margin: .4rem 0 1.25rem; padding: .35rem;
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); position: sticky; top: 74px; z-index: 20; }
.ctabs::-webkit-scrollbar { display: none; }
.ctab { flex: 0 0 auto; display: inline-flex; align-items: center; gap: .45rem; padding: .6rem 1rem; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: .93rem; white-space: nowrap; min-height: 44px; box-sizing: border-box; }
.ctab:hover { background: var(--warm); color: var(--ink); text-decoration: none; }
.ctab.active { background: var(--soft); color: var(--brand-2); }
.ctab:focus-visible { outline: 3px solid rgba(29,91,200,.35); outline-offset: 1px; }
.ctab-count { font-size: .75rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; background: var(--sunk); color: var(--muted); }
.ctab.active .ctab-count { background: var(--panel); color: var(--brand-2); }
.ctab-count.hot { background: var(--warn-bg); color: var(--warn-ink); }
.ctab-panel { scroll-margin-top: 140px; }
.ctab-panel > .card:first-child, .ctab-panel > .grid2:first-child { margin-top: 0; }
@media (max-width: 760px) {
  .ctabs { position: static; margin: .2rem -1rem 1rem; border-radius: 0; box-shadow: none; background: transparent; padding: 0 1rem .2rem; }
  .ctab { background: var(--panel); box-shadow: var(--shadow); }
  .ctab.active { background: var(--brand-2); color: #fff; }
  .ctab.active .ctab-count { background: rgba(255,255,255,.22); color: #fff; }
}
@media print { .ctabs { display: none; } .ctab-panel[hidden] { display: block !important; } }
.company-preview { background: var(--warm); border-radius: 14px; padding: .8rem 1rem; margin: .2rem 0 1rem; }
.company-preview #company-preview { color: var(--ink-2); font-size: .92rem; line-height: 1.55; margin-top: .2rem; }
.addlines { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.addlines .btn svg { vertical-align: -3px; }

/* v1.9 — Contracts */
.b-draft { background: var(--sunk); color: var(--muted); }
.b-declined { background: var(--bad-bg); color: var(--bad-ink); }
.flash-warn { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.flash-warn a { color: inherit; font-weight: 700; }
.tplpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.tplcard { display: flex; gap: .7rem; align-items: flex-start; padding: .9rem 1rem; border: 1.5px solid var(--line); border-radius: 16px; cursor: pointer; background: var(--panel); }
.tplcard:hover { border-color: var(--brand-line); }
.tplcard:has(input:checked) { border-color: var(--brand-2); background: var(--soft); box-shadow: 0 0 0 3px rgba(29,91,200,.12); }
.tplcard input { margin-top: .2rem; flex: none; }
.tplcard strong { display: block; }
.tplcard small { display: block; color: var(--muted); margin-top: .15rem; line-height: 1.4; }
textarea.contract-text { font: 13px/1.55 ui-monospace, "SF Mono", Menlo, Consolas, monospace; min-height: 420px; tab-size: 4; }
.ctr-editgrid { margin-top: .5rem; align-items: start; }
.ctr-editgrid .mergehelp { position: sticky; top: 1rem; }
.mergehelp h2 { margin-bottom: .25rem; }
.mergelist { display: flex; flex-direction: column; gap: .3rem; max-height: 430px; overflow: auto; margin: .6rem 0 1rem; }
.mergechip { display: flex; flex-direction: column; align-items: flex-start; gap: .05rem; text-align: left; font: inherit; background: var(--warm); border: 1px solid transparent; border-radius: 10px; padding: .4rem .6rem; cursor: pointer; }
.mergechip:hover { border-color: var(--brand-line); background: var(--soft); }
.mergechip code { font-size: .8rem; color: var(--brand-2); }
.mergechip span { font-size: .76rem; color: var(--muted); }
.fmt-help { padding-left: 1.1rem; margin: .3rem 0 0; }
.fmt-help li { margin: .2rem 0; }
.fmt-help code, .flash code { font-size: .8rem; background: rgba(0,0,0,.05); padding: 0 .25rem; border-radius: 4px; }
.ctr-preview { padding: 0; overflow: hidden; }
.ctr-preview .ctr { width: auto; padding: 36px 40px; }
.linkbox { border: 1.5px solid var(--brand-line); background: var(--soft); }
.copyrow { display: flex; gap: .5rem; margin-top: .5rem; }
.copyrow input { flex: 1; font: 13px ui-monospace, Menlo, monospace; }
.dangerzone .inline + .inline { margin-left: .4rem; }
@media (max-width: 760px) {
  .ctr-preview .ctr { padding: 20px 16px; }
  .ctr-editgrid .mergehelp { position: static; }
  .mergelist { max-height: 260px; }
}

/* v2.0 — branding & setup wizard */
.logo-row { display: flex; gap: 1rem; align-items: flex-start; }
.logo-row > span:last-child { display: flex; flex-direction: column; gap: .35rem; min-width: 0; }
.logo-prev { flex: none; display: grid; place-items: center; background: var(--warm); border: 1px solid var(--line); border-radius: 14px; }
.logo-prev-full { width: 180px; height: 72px; padding: 8px; }
.logo-prev-icon { width: 72px; height: 72px; padding: 8px; }
.logo-prev img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.formgrid.logos { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); margin-top: .5rem; }
.side-brand img, .appbar-brand img, .brand-logo { object-fit: contain; }
.wizard { max-width: 980px; }
.wiz-steps { list-style: none; display: flex; gap: .5rem; flex-wrap: wrap; padding: 0; margin: 0 0 1.25rem; }
.wiz-steps li { display: flex; align-items: center; gap: .5rem; padding: .45rem .9rem .45rem .45rem; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: .9rem; }
.wiz-steps li span { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); font-size: .8rem; }
.wiz-steps li.on { color: var(--brand-2); border-color: var(--brand-line); background: var(--soft); }
.wiz-steps li.on span { background: var(--brand-2); color: #fff; }
.wiz-steps li.done span { background: var(--ok-bg); color: var(--ok-ink); }
.wiz-skip { margin-top: .5rem; }
.wiz-next { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.wiz-next .card { display: flex; flex-direction: column; gap: .35rem; margin: 0; color: inherit; text-decoration: none; transition: border-color .15s, transform .15s; }
.wiz-next .card:hover { border-color: var(--brand-line); transform: translateY(-1px); }
.wiz-next .card svg { color: var(--brand-2); }
.wiz-next .card span { color: var(--muted); font-size: .9rem; }
@media (max-width: 760px) { .formgrid.logos { grid-template-columns: 1fr; } .logo-prev-full { width: 120px; } }

/* v2.0 — two-step sign-in */
.otp-input { font: 600 1.25rem ui-monospace, "SF Mono", Menlo, monospace !important; letter-spacing: .15em; text-align: center; }
.tf-steps { padding-left: 1.2rem; }
.tf-steps li { margin: .5rem 0; }
.tf-qr { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; margin: .6rem 0; }
.tf-qr svg { width: 180px; height: 180px; border: 1px solid var(--line); border-radius: 12px; padding: 4px; background: var(--panel); }
.tf-key { display: block; font-size: 1rem; letter-spacing: .06em; margin-top: .3rem; word-break: break-all; }
.tf-actions { display: flex; gap: .75rem 1.5rem; flex-wrap: wrap; align-items: center; }
.recovery { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 14px; padding: 1rem 1.2rem; margin-bottom: 1rem; }
.recovery .codes { columns: 2; padding-left: 1.4rem; margin: .5rem 0 .9rem; }
.recovery .codes code { font-size: 1rem; letter-spacing: .05em; }
.twofa-policy { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.twofa-policy p { margin: .2rem 0 0; }
@media print { body.staff .recovery { border: 0; } }

/* v2.0 — CSV import */
.mapgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .6rem 1rem; margin: 1rem 0 1.25rem; }
.maprow { display: flex; flex-direction: column; gap: .25rem; padding: .6rem .75rem; border-radius: 12px; background: var(--warm); border: 1px solid transparent; font-weight: 600; font-size: .88rem; }
.maprow.set { background: var(--soft); border-color: var(--brand-line); }
.maprow small { font-weight: 400; min-height: 1em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.importcheck { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .5rem; }
table.small td, table.small th { font-size: .82rem; }

/* v2.1 — customizable dashboard */
.dash-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1.25rem; align-items: stretch; }
.dblock { min-width: 0; display: flex; flex-direction: column; }
.dblock.s-2 { grid-column: span 2; } .dblock.s-3 { grid-column: span 3; } .dblock.s-4 { grid-column: span 4; } .dblock.s-6 { grid-column: span 6; }
.dblock.is-off { display: none; }
.dbody { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dbody > .card, .dbody > .upnext { margin: 0; flex: 1; }
.dbody > .quicktiles { flex: 1; }
.dbody > .stats { margin-bottom: 0; }
.dbody > .card .table { display: block; overflow-x: auto; }
.dblock.s-2 .upnext { flex-direction: column; }
.dblock .quicktiles { grid-template-columns: 1fr 1fr; }
.dblock.s-6 .quicktiles { grid-template-columns: repeat(4, 1fr); }
.dtools { display: none; }
.hello .dash-customize { flex: none; }
.hello .dash-customize[hidden] { display: none; }
.dash-editbar { position: sticky; top: .75rem; z-index: 20; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1.25rem;
                padding: .9rem 1.1rem; border-radius: 18px; background: var(--panel); border: 1.5px solid var(--brand-line); box-shadow: 0 10px 30px rgba(29,91,200,.12); }
.dash-editbar[hidden] { display: none; }
.dash-editbar .grow { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: .15rem; }
.dash-editbtns { display: flex; gap: .5rem; flex-wrap: wrap; }
.dhandle-demo { font-weight: 800; }
body.dash-edit .dblock { display: flex; border: 1.5px dashed var(--brand-line); border-radius: 22px; padding: .5rem; background: rgba(244,248,254,.6); }
body.dash-edit .dblock.is-off { opacity: .55; background: repeating-linear-gradient(135deg, var(--warm) 0 10px, var(--sunk) 10px 20px); border-color: var(--line-2); }
body.dash-edit .dtools { display: flex; gap: .35rem; align-items: center; padding: 0 .25rem .5rem; flex-wrap: wrap; }
body.dash-edit .dbody { pointer-events: none; }
body.dash-edit .dbody .dash-tiles, body.dash-edit .dbody .dash-tiles * { pointer-events: auto; }
.dname { flex: 1; font-size: .85rem; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dhandle { cursor: grab; font-size: 1.2rem; line-height: 1; padding: .3rem .45rem; border-radius: 8px; background: var(--panel); border: 1px solid var(--line); touch-action: none; user-select: none; }
.dbtn { font: 600 .8rem inherit; font-family: inherit; padding: .3rem .6rem; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; color: var(--ink); }
.dbtn:hover, .dhandle:hover { border-color: var(--brand-line); }
.d-size { font-size: .8rem; padding: .25rem .4rem; border-radius: 8px; width: auto; }
.doff { padding: 1.2rem; text-align: center; color: var(--muted); font-weight: 600; font-size: .9rem; }
.dblock.dragging, .dash-tiles .stat.dragging { opacity: .6; outline: 2px solid var(--brand-2); outline-offset: 2px; }
.dash-tiles .stat.is-off { display: none; }
body.dash-edit .dash-tiles .stat { cursor: pointer; touch-action: none; user-select: none; position: relative; }
body.dash-edit .dash-tiles .stat.is-off { display: flex; opacity: .45; background: repeating-linear-gradient(135deg, var(--panel) 0 8px, var(--warm) 8px 16px); }
body.dash-edit .dash-tiles .stat::after { content: "✓"; position: absolute; top: .45rem; right: .55rem; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
                                          font-size: .7rem; font-weight: 800; background: var(--brand-2); color: #fff; }
body.dash-edit .dash-tiles .stat.is-off::after { content: ""; background: var(--panel); border: 1.5px solid var(--line-2); }
@media (max-width: 1100px) { .dblock.s-2 { grid-column: span 3; } .dblock.s-4 { grid-column: span 6; } }
@media (max-width: 760px) {
  .dash-grid { grid-template-columns: 1fr; gap: 1rem; }
  .dblock.s-2, .dblock.s-3, .dblock.s-4, .dblock.s-6 { grid-column: 1 / -1; }
  .dblock .quicktiles, .dblock.s-6 .quicktiles { grid-template-columns: 1fr 1fr; }
  .hello { align-items: flex-start; }
  .hello .dash-customize { padding: .45rem .7rem; font-size: .85rem; }
  .d-size { display: none; }
  .dash-editbar { position: static; padding: .75rem .9rem; }
  .dash-editbar .grow .muted { display: none; }
  .dash-editbtns .btn { padding: .5rem .8rem; font-size: .88rem; }
}

/* v2.2 — scheduled task settings */
.cron-steps { padding-left: 1.2rem; }
.cron-steps > li { margin: .55rem 0; }
.cron-opt { background: var(--warm); border-radius: 14px; padding: .75rem 1rem; margin: .6rem 0; }
.cron-opt p { margin: .2rem 0 .5rem; }
.cron-out { background: var(--ink); color: var(--line); border-radius: 12px; padding: .8rem 1rem; font-size: .8rem; white-space: pre-wrap; margin: .5rem 0 .8rem; }

/* dark-mode touch-ups for things variables can't express */
:root[data-theme="dark"] img.brand-img, :root[data-theme="dark"] .auth-card img.logo-img { background: transparent; }
:root[data-theme="dark"] .btn.primary, :root[data-theme="dark"] .tabs a.active { color: #fff; }
:root[data-theme="dark"] .tabs a.active { background: var(--brand-2); }
:root[data-theme="dark"] .btn:hover { border-color: var(--line-2); }
:root[data-theme="dark"] ::placeholder { color: var(--faint); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.primary, :root:not([data-theme="light"]) .tabs a.active { color: #fff; }
  :root:not([data-theme="light"]) .tabs a.active { background: var(--brand-2); }
  :root:not([data-theme="light"]) .btn:hover { border-color: var(--line-2); }
  :root:not([data-theme="light"]) ::placeholder { color: var(--faint); }
}
/* theme switcher (profile page) */
.theme-pick { display: inline-flex; gap: .35rem; padding: .25rem; border-radius: 999px; background: var(--sunk); border: 1px solid var(--line); }
.theme-pick button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: .4rem .9rem; border-radius: 999px; cursor: pointer; }
.theme-pick button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
/* v2.4 — remote support */
.notice-box { background: var(--soft); border: 1px solid var(--brand-line); border-radius: 14px; padding: .75rem 1rem; margin-top: 1rem; }
.notice-box p { margin: .35rem 0; }
.remote-card form.inline { display: inline-block; margin: 0 .4rem .4rem 0; }
.inline-form { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; margin-top: .75rem; }
.inline-form .field { flex: 1 1 260px; margin: 0; }
td form.inline { margin: 0; }
@media (max-width: 700px) { .inline-form .btn { width: 100%; } }

/* printing always uses the light palette */
@media print {
  :root, :root[data-theme="dark"], :root[data-theme="light"] {
    color-scheme: light;
    --bg: #fff; --panel: #fff; --ink: #1E2430; --ink-2: #3D4554; --muted: #5D6575; --faint: #8A919C; --line: #ECE7E0; --line-2: #E2DCD3; --sunk: #F1EDE7; --warm: #FAF8F5; --soft: #EAF1FD;
    --brand: #174BA6; --brand-2: #1D5BC8; --brand-ink: #1659A0; --brand-line: #B9CDF2;
    --ok-bg: #E6F5EF; --ok-ink: #0B6B4A; --warn-bg: #FFF1DC; --warn-ink: #8A4B00; --bad-bg: #FDECEC; --bad-ink: #A01818;
  }
  body { background: #fff !important; color: #1E2430 !important; }
}
/* logos are usually dark-on-white artwork: give them a light plate on dark themes */
:root[data-theme="dark"] .auth-logo { background: #fff; padding: .6rem 1rem; border-radius: 14px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth-logo { background: #fff; padding: .6rem 1rem; border-radius: 14px; } }
/* keep wide status tables inside the screen on phones */
@media (max-width: 700px) { table.statustable { display: block; max-width: 100%; overflow-x: auto; } }

/* ---- v2.5: on-site assessments ---- */
.b-completed { background: var(--ok-bg); color: var(--ok-ink); }
.chipnav { display: flex; gap: .4rem; overflow-x: auto; padding: .2rem 0 .8rem; position: sticky; top: 0; z-index: 5; background: var(--bg); }
.chipnav a { white-space: nowrap; padding: .35rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: var(--ink-2); font-size: .85rem; text-decoration: none; }
.chipnav a:hover { border-color: var(--brand-2); color: var(--brand-2); }
.assess-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .8rem 1rem; }
.assess-grid .field.wide { grid-column: 1 / -1; }
.assess-grid .field { margin: 0; }
.assess-form .card { margin-bottom: 1rem; scroll-margin-top: 3.5rem; }
.assess-form .lbl { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .35rem; color: var(--ink-2); }
.checks { display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.chk { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; cursor: pointer; }
.chk input { width: 18px; height: 18px; min-height: 0 !important; accent-color: var(--brand-2); }
.eq-row { display: grid; grid-template-columns: 1.2fr 1.6fr 70px 80px 1.2fr 1.6fr 32px; gap: .4rem; margin-bottom: .4rem; align-items: center; }
.eq-row input, .eq-row select { min-width: 0; width: 100%; }
.stickybar { position: sticky; bottom: 0; z-index: 4; background: var(--bg-glass); backdrop-filter: blur(8px); padding: .7rem 0; border-top: 1px solid var(--line); margin-top: 0; }
.upload-form { margin-bottom: 1rem; }
.upload-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.upload-row .photo-btn { cursor: pointer; }
.upload-row input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.afiles { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.afile { display: flex; gap: .8rem; align-items: flex-start; padding: .6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
.afile-thumb { flex: 0 0 72px; width: 72px; height: 72px; display: flex; align-items: center; justify-content: center; background: var(--sunk); border-radius: 8px; overflow: hidden; }
.afile-thumb img { width: 100%; height: 100%; object-fit: cover; }
.afile-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .25rem; }
.afile-name { font-weight: 600; overflow-wrap: anywhere; }
.afile-note { color: var(--ink-2); overflow-wrap: anywhere; }
.notefm { display: flex; gap: .4rem; flex-wrap: wrap; }
.notefm input { flex: 1 1 200px; min-width: 0; }
.plainlist { list-style: none; margin: 0 0 .8rem; padding: 0; display: grid; gap: .4rem; }
@media (max-width: 900px) { .eq-row { grid-template-columns: 1fr 1fr; } .eq-row .eq-notes, .eq-row input:nth-of-type(1) { grid-column: 1 / -1; } .eq-row .eq-del { justify-self: end; } }
@media (max-width: 700px) { .afile { flex-wrap: wrap; } .afile-body { flex-basis: calc(100% - 90px); } .assess-grid { grid-template-columns: 1fr; } .stickybar { bottom: 64px; } }
@media print { .chipnav, .stickybar { display: none !important; } }

/* ---- v2.6: discounts ---- */
.discount-box { border: 1px solid var(--line); border-radius: 10px; padding: .6rem 1rem 1rem; margin: 1rem 0; background: var(--panel); }
.discount-box legend { font-weight: 600; padding: 0 .4rem; color: var(--ink-2); }
.discount-row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.discount-row .field { margin: 0; flex: 0 1 190px; } .discount-row .field.grow { flex: 1 1 260px; }

/* ---- v2.7: per-line discounts ---- */
.dcell { display: flex; gap: .2rem; min-width: 124px; }
.dcell select { flex: 0 0 52px; width: 52px !important; padding-left: .3rem; padding-right: .3rem; }
.dcell input { flex: 1 1 60px; min-width: 56px; }
.items .dcell input.dval { max-width: 96px; min-width: 64px; }
table.items { min-width: 0; }
.items select.product { min-width: 140px; } .items select.type { min-width: 104px; }
.items input.qty { min-width: 56px; } .items input.price { min-width: 84px; } .items input.cost { min-width: 76px; } .items input.desc { min-width: 130px; }


/* v2.8 ticket form: customer balance */
.balrow { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: -.2rem 0 1rem; font-size: .92rem; }
.balrow-label { color: var(--muted); font-weight: 600; }
.balchip { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-weight: 600; text-decoration: none;
  background: var(--ok-bg); color: var(--ok-ink); }
.balchip.is-due { background: var(--warn-bg); color: var(--warn-ink); }
.balchip.is-overdue { background: var(--bad-bg); color: var(--bad-ink); }

:root[data-theme="dark"] .auth-logo.auth-appicon { background: none; padding: 0; border-radius: 29px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth-logo.auth-appicon { background: none; padding: 0; border-radius: 29px; } }

/* One-click light/dark toggle */
.theme-toggle { border: 0; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; padding: 0; font: inherit; }
.theme-toggle:hover { background: var(--panel); color: var(--ink); }
.theme-toggle .ico { display: block; }
.theme-toggle .tt-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .tt-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .tt-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .tt-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .tt-moon { display: block; }
}
.theme-toggle.auth-theme { position: fixed; top: .9rem; right: .9rem; width: 42px; height: 42px; background: var(--panel); border: 1px solid var(--line); border-radius: 50%; box-shadow: var(--shadow); }
@media (max-width: 520px) { .theme-toggle.auth-theme { top: .25rem; right: .25rem; width: 36px; height: 36px; } }

/* Service agreements: hours-used bar */
.hbar { height: 10px; border-radius: 999px; background: var(--sunk); overflow: hidden; margin: .35rem 0; }
.hbar span { display: block; height: 100%; border-radius: 999px; background: var(--good, #2f9e6a); }
.hbar.warn span { background: var(--warn, #e0a030); }
.hbar.bad span { background: var(--bad, #d14b4b); }
.agr-stats { display: flex; flex-wrap: wrap; gap: 1.5rem; margin: .5rem 0 1rem; }
.agr-stats strong { display: block; font-size: 1.4rem; }
form.agr-form > .actions { margin-top: .85rem; }
form.agr-addall { margin-top: .6rem; display: inline-block; }

/* Ticket quick-action buttons: same height (the photo form's line box used to stretch its neighbours) */
.quickacts { align-items: flex-start; }
.quickacts .photo-form { display: flex; margin: 0; }
.quickacts .photo-form .btn { flex: 1; }
.quickacts .btn { line-height: 1.2; }
.quickacts .photo-form .btn { margin: 0; }

/* Documents: bulk selection */
.bulkbar{display:flex;align-items:center;flex-wrap:wrap;gap:10px;margin:0 0 10px}
.bulkbar .grow{flex:1}
.bulkbar .btn[disabled]{opacity:.45;cursor:not-allowed}
th.selcol,td.selcol{width:34px;text-align:center}

/* Portal: attachments as plain links, one per line */
.attach-list.attach-plain{display:flex;flex-direction:column;gap:.2rem;align-items:flex-start}
.attach-list.attach-plain a{word-break:break-all}

/* Portal overview: service agreement hours */
.agr-usage-head{display:flex;justify-content:space-between;flex-wrap:wrap;gap:.4rem .8rem;margin-bottom:.6rem}
