/* JGR Invoice Builder — Colorado palette: dark blue, white, silver, medium-dark grey */
:root {
  --bar: #2A6496;
  --navy: #0F2A4A;
  --navy-2: #1A3D66;
  --navy-3: #24507F;
  --white: #FFFFFF;
  --silver: #C5CBD3;
  --silver-2: #E4E8EC;
  --steel: #5D6875;
  --ink: #1B2430;
  --green: #1E5B3A;
  --truck: #1F64B0;
  --danger: #A33A2E;
  --radius-s: 4px;
  --radius-m: 8px;
  --ui: 'Barlow', 'Segoe UI', Roboto, Arial, sans-serif;
  --ui-cond: 'Barlow Condensed', 'Arial Narrow', 'Barlow', sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { overflow: hidden; }
body {
  margin: 0; font-family: var(--ui); font-size: 15px; color: var(--ink);
  background: var(--silver-2);
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--navy-3); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: relative; background: var(--bar); color: var(--white);
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 14px 24px 30px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 40px; height: 40px; border-radius: 10px; background: #fff; padding: 2px; }
.auth-gate { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(173, 216, 230, 0.02); /* light blue at 2% */
  -webkit-backdrop-filter: blur(18px) saturate(1.5); backdrop-filter: blur(18px) saturate(1.5); /* glass */ }
.auth-card { background: rgba(255, 255, 255, 0.72); border: 1px solid rgba(255, 255, 255, 0.65);
  -webkit-backdrop-filter: blur(22px) saturate(1.6); backdrop-filter: blur(22px) saturate(1.6);
  border-radius: 16px; max-width: 420px; width: 100%; padding: 28px; text-align: center; box-shadow: 0 20px 60px rgba(15,42,74,.28); }
.auth-card h2 { margin: 12px 0 8px; }
.auth-card form { text-align: left; margin-top: 12px; }
.auth-card .btn { width: 100%; margin-top: 10px; padding: 12px; font-size: 16px; }
/* ---------- grouped nav menus (New / Existing / Setup) ---------- */
.navmenu { position: relative; }
.navmenu summary { list-style: none; cursor: pointer; user-select: none; }
.navmenu summary::-webkit-details-marker { display: none; }
.navmenu summary::marker { content: ''; }
.navmenu .menu { position: absolute; top: calc(100% + 8px); left: 0; z-index: 150; min-width: 240px;
  background: var(--bar); border-radius: 10px; padding: 6px; box-shadow: 0 14px 40px rgba(15,42,74,.30);
  border: 1px solid rgba(255,255,255,.25); }
.navmenu .menu-item { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left;
  background: transparent; border: 0; border-radius: 7px; padding: 10px 12px; font-weight: 600; cursor: pointer; color: #fff; }
.navmenu .menu-item:hover, .navmenu .menu-item:focus-visible { background: rgba(255,255,255,.16); }
.fuelbox { border: 1px dashed var(--steel); border-radius: var(--radius-m); padding: 10px 14px; margin: 14px 0; background: #fff; }
.fuel-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.fuel-inputs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-weight: 600; }
.fuel-inputs input { width: 90px; padding: 6px 8px; border: 1px solid var(--silver); border-radius: var(--radius-s); }
.fuel-inputs select { padding: 6px 8px; border: 1px solid var(--silver); border-radius: var(--radius-s); font-weight: 600; }
#fuel-pct { width: 70px; }
.fuel-inputs input:focus-visible { outline-offset: 0; }
.paybox { border: 2px dotted #E67E22; background: #FEF5E7; border-radius: var(--radius-m); padding: 10px 14px; margin: 0 0 14px; }
.pay-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.pay-inputs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-weight: 600; }
.pay-inputs input { width: 80px; padding: 6px 8px; border: 1px solid var(--silver); border-radius: var(--radius-s); }
.pay-due { color: var(--steel); font-size: 13px; }
.inv-reminder { border: 2px solid #111; border-radius: 6px; padding: 8px 12px; margin-top: 10px; font-size: 13.5px; }
/* ---------- rotate-to-landscape hint (portrait phones, review modal) ---------- */
.rotate-hint { position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(173, 216, 230, 0.12);
  -webkit-backdrop-filter: blur(14px) saturate(1.4); backdrop-filter: blur(14px) saturate(1.4); }
.rotate-card { background: rgba(255,255,255,.9); border: 1px solid rgba(255,255,255,.7); border-radius: 18px;
  max-width: 320px; width: 100%; padding: 26px 24px; text-align: center; box-shadow: 0 20px 60px rgba(15,42,74,.3); }
.rotate-card h2 { margin: 6px 0 4px; color: var(--navy); }
.rotate-card .btn { width: 100%; margin-top: 10px; }
.phone-spin { width: 110px; height: 110px; }
.phone-spin .handset { fill: var(--bar); transform-origin: 65px 60px; animation: phoneFlip 2.6s ease-in-out infinite; }
.phone-spin .handset .screen { fill: #fff; }
.phone-spin .handset circle { fill: #fff; }
.phone-spin .spin-arrow { stroke: var(--bar); }
@keyframes phoneFlip {
  0%, 18% { transform: rotate(0deg); }
  48%, 78% { transform: rotate(90deg); }
  100% { transform: rotate(90deg); }
}
.signed-in { color: var(--silver-2); font-size: 13px; font-weight: 600; }
.signed-in:empty { display: none; }
.calc.error { color: var(--danger); font-weight: 600; }
.inv-sub { display: flex; justify-content: flex-end; gap: 24px; font-weight: 600; padding: 2px 8px; }
.inv-sub span:last-child { min-width: 140px; text-align: right; }
/* Invoice barcode: under the invoice number, aligned to the right margin */
.inv-bar-top { margin: 6px 0 0 auto; max-width: 220px; }
.inv-bar-top svg { display: block; margin-left: auto; max-width: 100%; height: auto; }
.inv-scan { position: absolute; right: 60px; bottom: 56px; display: flex; gap: 18px; align-items: flex-end;
  max-width: 250px; max-height: 250px; margin: 0; }
.inv-scan-cell { text-align: center; }
.inv-scan-cap { font-size: 9.5px; letter-spacing: .08em; color: #5D6875; margin-top: 4px; font-weight: 700; white-space: nowrap; }
.inv-scan-na { width: 110px; height: 110px; display: grid; place-items: center; border: 1px dashed #b9c3cf;
  color: #5D6875; font-size: 10px; text-align: center; }
.inv-scan-bar svg { max-width: 128px; height: auto; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%; background: var(--silver);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 34'%3E%3Cpath d='M2 26 L12 10 L17 17 L22 8 L32 26 Z'/%3E%3C/svg%3E") center/80% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 34 34'%3E%3Cpath d='M2 26 L12 10 L17 17 L22 8 L32 26 Z'/%3E%3C/svg%3E") center/80% no-repeat;
}
.brand-name { font-family: var(--ui-cond); font-weight: 700; font-size: 22px; letter-spacing: .02em; line-height: 1; }
.brand-sub { color: var(--silver); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.divider { width: 1px; height: 26px; background: var(--steel); margin: 0 4px; }
.ridge { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 22px; fill: var(--silver-2); }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid transparent; border-radius: var(--radius-s); padding: 8px 14px;
  font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--white); color: var(--navy); }
.editor .btn-primary, .modal .btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--silver); }
.editor .btn-primary:hover:not(:disabled), .modal .btn-primary:hover:not(:disabled) { background: var(--navy-3); }
.btn-ghost { background: transparent; color: var(--white); border-color: var(--steel); }
.btn-ghost:hover { border-color: var(--silver); background: var(--navy-2); }
.btn-silver { background: var(--silver-2); color: var(--ink); border-color: var(--silver); }
.btn-silver:hover { background: var(--silver); }
.btn-small { padding: 4px 10px; font-size: 13px; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; width: 32px; height: 32px; border-radius: var(--radius-s);
  color: var(--steel); font-size: 16px;
}
.icon-btn:hover { background: var(--silver-2); color: var(--ink); }

/* ---------- split layout ---------- */
.view-switch { display: none; }
.split { flex: 1; display: grid; grid-template-columns: minmax(380px, 44%) 1fr; grid-template-rows: minmax(0, 1fr); min-height: 0; }
.editor {
  background: var(--white); border-right: 1px solid var(--silver);
  overflow-y: auto; padding: 0 24px; min-height: 0;
}
.preview {
  overflow: auto; padding: 28px; min-height: 0;
  background:
    linear-gradient(var(--silver-2), var(--silver-2)) padding-box;
}
.preview-scaler { transform-origin: top left; width: 794px; }

/* ---------- total bar ---------- */
.totalbar {
  position: sticky; top: 0; z-index: 3; margin: 0 -24px 18px; padding: 16px 24px;
  background: var(--navy-2); color: var(--white);
  display: flex; justify-content: space-between; align-items: flex-end; gap: 16px;
}
.totalbar-label { color: var(--silver); font-size: 13px; }
.totalbar-amount { font-family: var(--ui-cond); font-size: 38px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.totalbar-meta { text-align: right; }
.totalbar-number { font-family: var(--ui-cond); font-size: 20px; font-weight: 600; letter-spacing: .03em; }

/* ---------- form fields ---------- */
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; min-width: 0; }
.field.grow { flex: 1 1 220px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--steel); }
.field input, .field select {
  height: 40px; padding: 0 10px; border: 1px solid var(--silver); border-radius: var(--radius-s);
  background: var(--white); min-width: 0; width: 100%;
}
.field input:focus, .field select:focus { border-color: var(--navy-3); outline: none; box-shadow: 0 0 0 3px rgba(36,80,127,.18); }
.date-input { cursor: pointer; background-image: linear-gradient(transparent, transparent); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--steel); margin-top: 8px; }

.billto { border-left: 4px solid var(--navy); background: var(--silver-2); padding: 10px 14px; margin-bottom: 18px; border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.billto-label { font-size: 12px; color: var(--steel); font-weight: 600; }
.billto-name { font-family: var(--ui-cond); font-size: 20px; font-weight: 700; color: var(--navy); }
.billto-addr { font-size: 14px; color: var(--ink); }

/* ---------- load lines ---------- */
.lines { display: flex; flex-direction: column; gap: 14px; }
.line {
  border: 1px solid var(--silver); border-radius: var(--radius-m); background: var(--white);
  border-top: 4px solid var(--navy);
}
.line-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px 8px 14px; background: var(--silver-2); }
.line-toggle span { display: inline-block; font-size: 15px; }
.line.collapsed .line-body { display: none; }
.line.collapsed .line-head { border-radius: var(--radius-m); }
.line-title { font-family: var(--ui-cond); font-weight: 700; font-size: 17px; color: var(--navy); }
.line-amount { font-family: var(--ui-cond); font-weight: 700; font-size: 18px; margin-left: auto; margin-right: 8px; font-variant-numeric: tabular-nums; }
.line-body { padding: 12px 14px 4px; }
.line-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.line-grid .span-2 { grid-column: span 2; }

.addr-wrap { position: relative; display: flex; gap: 6px; }
.addr-wrap input { flex: 1; }
.addr-toggle {
  width: 40px; height: 40px; flex: none; border: 0; border-radius: var(--radius-s); cursor: pointer;
  background: var(--green); color: var(--white); display: grid; place-items: center;
}
.addr-toggle:hover { background: #164a2e; }
.addr-toggle svg { width: 16px; height: 16px; transition: transform .15s; }
.addr-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.addr-menu {
  position: absolute; z-index: 5; top: 44px; left: 0; right: 0; background: var(--white);
  border: 1px solid var(--green); border-radius: var(--radius-s); box-shadow: 0 8px 24px rgba(15,42,74,.18);
  max-height: 240px; overflow: auto; padding: 4px;
}
.addr-menu button {
  display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px;
  border-radius: var(--radius-s); cursor: pointer;
}
.addr-menu button:hover, .addr-menu button:focus { background: #E3EFE7; }
.addr-menu small { color: var(--steel); display: block; }

.stepper { display: flex; height: 40px; border: 1px solid var(--silver); border-radius: var(--radius-s); overflow: hidden; }
.stepper button { width: 40px; border: 0; background: var(--navy); color: var(--white); cursor: pointer; font-size: 14px; }
.stepper button:hover { background: var(--navy-3); }
.stepper input { flex: 1; border: 0 !important; text-align: center; font-weight: 700; font-size: 17px; height: 38px !important; border-radius: 0 !important; }

.segmented { display: flex; height: 40px; border: 1px solid var(--silver); border-radius: var(--radius-s); overflow: hidden; }
.segmented label { position: relative; flex: 1; display: grid; place-items: center; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--steel); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--navy); color: var(--white); }
.segmented label:has(input:focus-visible) { outline: 3px solid var(--navy-3); outline-offset: -3px; }

.calc { font-size: 13px; color: var(--steel); padding: 0 0 10px; }
.calc strong { color: var(--ink); }

/* ---------- add load ---------- */
.add-load {
  margin-top: 16px; width: 100%; display: flex; align-items: center; gap: 16px; padding: 12px 16px;
  border: 2px dashed var(--truck); border-radius: var(--radius-m); background: #F2F6FB; cursor: pointer; text-align: left;
  color: var(--truck);
}
.add-load:hover:not(:disabled) { background: #E5EEF8; }
.add-load:disabled { border-color: var(--silver); color: var(--steel); cursor: not-allowed; background: var(--white); }
.add-load strong { display: block; font-family: var(--ui-cond); font-size: 20px; color: var(--navy); }
.add-load small { color: var(--steel); }
.truck-icon { width: 104px; flex: none; color: var(--truck); }
.add-load:disabled .truck-icon { color: var(--steel); }
.truck-icon svg { display: block; width: 100%; height: auto; }

.footer-actions {
  position: sticky; bottom: 0; z-index: 3; display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin: 22px -24px 0; padding: 14px 24px 16px; background: var(--white); border-top: 2px solid var(--navy);
}
.footer-actions .btn { padding: 8px 12px; }
.footer-actions .btn-quiet { padding: 8px 2px; }
.btn-quiet { background: none; color: var(--steel); border-color: transparent; margin-left: auto; text-decoration: underline; text-underline-offset: 3px; }
.btn-quiet:hover { color: var(--danger); }
.footer-actions.busy .btn { pointer-events: none; opacity: .6; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15,42,74,.6); }
.modal-card {
  position: relative; background: var(--white); border-radius: var(--radius-m); width: min(720px, 100%);
  max-height: calc(100vh - 32px); display: flex; flex-direction: column; border-top: 6px solid var(--navy);
}
.modal-card.wide { width: min(980px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px 8px; }
.modal-head h2 { margin: 0; font-family: var(--ui-cond); font-size: 24px; color: var(--navy); }
.modal-body { padding: 8px 20px 20px; overflow: auto; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.form-error { color: var(--danger); font-weight: 600; min-height: 1.2em; margin: 4px 0; }
.contact-grid { display: grid; grid-template-columns: 28px 1fr 1fr; gap: 8px 10px; align-items: center; margin-bottom: 14px; }
.contact-grid .n { font-family: var(--ui-cond); font-weight: 700; color: var(--steel); text-align: center; }
.contact-grid input { height: 40px; padding: 0 10px; border: 1px solid var(--silver); border-radius: var(--radius-s); min-width: 0; width: 100%; }
.contact-grid input:focus { border-color: var(--navy-3); outline: none; box-shadow: 0 0 0 3px rgba(36,80,127,.18); }
.contact-grid .head { font-size: 13px; font-weight: 600; color: var(--steel); }
.setup-section { font-family: var(--ui-cond); font-size: 18px; color: var(--navy); margin: 6px 0 8px; border-bottom: 1px solid var(--silver); padding-bottom: 4px; }
.btn-setup { border-color: var(--silver); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.chip { background: var(--silver-2); border: 1px solid var(--silver); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.chip.taken { background: var(--navy); color: var(--white); border-color: var(--navy); }
.list-scroll { max-height: 180px; overflow: auto; border: 1px solid var(--silver); border-radius: var(--radius-s); padding: 6px 10px; margin-bottom: 14px; font-size: 14px; columns: 2; }
.photo-drop { display: flex; gap: 12px; align-items: center; }
.photo-drop img { width: 120px; height: 80px; object-fit: cover; border-radius: var(--radius-s); border: 1px solid var(--silver); background: var(--silver-2); }

/* review */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--silver); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--steel); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs button[aria-selected="true"] { color: var(--navy); border-bottom-color: var(--navy); }
.typeahead { position: relative; }
.typeahead-list { position: absolute; z-index: 6; top: 100%; left: 0; right: 0; background: var(--white); border: 1px solid var(--silver); border-radius: var(--radius-s); box-shadow: 0 8px 24px rgba(15,42,74,.15); max-height: 220px; overflow: auto; }
.typeahead-list button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; cursor: pointer; }
.typeahead-list button:hover, .typeahead-list button.active { background: var(--silver-2); }
.typeahead-list mark { background: none; color: var(--navy); font-weight: 700; }
.prefix-input { display: flex; }
.prefix-input select { width: auto !important; border-radius: var(--radius-s) 0 0 var(--radius-s) !important; background: var(--navy) !important; color: var(--white); font-weight: 700; border-color: var(--navy) !important; }
.prefix-input input { border-radius: 0 var(--radius-s) var(--radius-s) 0 !important; border-left: 0 !important; }
.results { width: 100%; border-collapse: collapse; font-size: 14px; }
.results th { text-align: left; font-size: 12px; color: var(--steel); padding: 6px 8px; border-bottom: 2px solid var(--silver); }
.results td { padding: 8px; border-bottom: 1px solid var(--silver-2); }
.results tr[data-id] { cursor: pointer; }
.results tr[data-id]:hover td { background: var(--silver-2); }
.results .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.empty { color: var(--steel); padding: 18px 0; text-align: center; }

/* toast */
.toast {
  visibility: hidden;
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 140%); z-index: 60;
  background: var(--navy); color: var(--white); padding: 10px 18px; border-radius: var(--radius-s);
  border-left: 4px solid var(--silver); transition: transform .25s; max-width: 90vw;
}
.toast.show { transform: translate(-50%, 0); visibility: visible; }
.toast.error { border-left-color: #E07B6E; }

/* flatpickr in the Colorado palette */
.flatpickr-calendar { font-family: var(--ui); border-top: 4px solid var(--navy); }
.flatpickr-months .flatpickr-month, .flatpickr-current-month .flatpickr-monthDropdown-months { color: var(--navy); fill: var(--navy); font-weight: 700; }
.flatpickr-day.selected, .flatpickr-day.selected:hover { background: var(--navy); border-color: var(--navy); }
.flatpickr-day.today { border-color: var(--steel); }

/* ======================================================================
   A4 INVOICE (210 × 297 mm at 96 dpi = 794 × 1123 px)
   ====================================================================== */
.invoice-page {
  position: relative;
  width: 794px; min-height: 1123px; background: #fff; color: #111;
  padding: 96px 82px 70px 70px; box-shadow: 0 2px 18px rgba(15,42,74,.18);
  font-family: 'Gill Sans', 'Gill Sans MT', 'Lato', Calibri, sans-serif; font-size: 15.5px; line-height: 1.32;
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
}
.invoice-page.exporting { box-shadow: none; min-height: 1120px; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; }
.inv-company { font-family: Cambria, 'Times New Roman', Georgia, serif; font-weight: 700; font-size: 25px; color: #1a2238; margin-bottom: 4px; letter-spacing: .01em; }
.inv-title-block { text-align: right; }
.inv-title { font-family: 'Lato', Verdana, sans-serif; font-weight: 900; font-size: 38px; color: #2D5F8A; letter-spacing: .03em; line-height: 1.1; }
.inv-date { font-family: Cambria, Georgia, serif; font-weight: 700; color: #3A4E73; margin-top: 74px; font-size: 15px; letter-spacing: .02em; }
.inv-number { font-family: Cambria, Georgia, serif; font-weight: 700; color: #3A4E73; font-size: 13px; margin-top: 4px; letter-spacing: .02em; }
.inv-to { margin-top: 52px; font-family: Cambria, Georgia, serif; font-weight: 700; font-size: 15px; color: #1a2238; min-height: 150px; }
.inv-to-label { margin-right: 6px; }
.inv-to-addr { font-family: 'Gill Sans', 'Lato', sans-serif; font-weight: 400; margin: 4px 0 0 34px; }
.inv-placeholder { color: #9aa3ad; font-weight: 400; font-style: italic; }

.inv-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.inv-table th {
  font-family: Cambria, Georgia, serif; font-weight: 700; font-size: 15px; color: #1a2238;
  text-align: left; padding: 6px 8px 8px; border-bottom: 1.5px solid #8b98a8; letter-spacing: .02em;
}
.inv-table th.left { padding-left: 2px; }
.inv-table th:nth-child(2), .inv-table th:nth-child(3) { text-align: center; }
.inv-table th:nth-child(4) { text-align: center; color: #2D5F8A; }
.inv-table td { border-bottom: 1px solid #b9c3cf; vertical-align: middle; padding: 3px 10px; }
.inv-table td + td { border-left: 1px solid #b9c3cf; }
.inv-table td.inv-desc { padding-left: 2px; }
.inv-table td:nth-child(2) { white-space: nowrap; padding: 3px 8px; }
.inv-table .blank td { height: 34px; }
.inv-total { display: flex; justify-content: flex-end; align-items: center; margin-top: 8px; }
.inv-total-label { font-family: 'Lato', Verdana, sans-serif; font-weight: 900; font-size: 16px; width: 16%; text-align: center; }
.inv-total-amount { font-weight: 700; font-size: 16.5px; width: 22%; padding-left: 10px; border-left: 1px solid #b9c3cf; padding-top: 6px; padding-bottom: 6px; }
.inv-payable { margin-top: 36px; font-size: 15px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .view-switch { display: flex; background: var(--navy); padding: 0 16px 10px; gap: 6px; }
  .view-switch button { flex: 1; border: 1px solid var(--steel); background: transparent; color: var(--white); padding: 8px; border-radius: var(--radius-s); font-weight: 600; }
  .view-switch button[aria-selected="true"] { background: var(--white); color: var(--navy); }
  html { overflow: auto; }
  body { height: auto; overflow: visible; }
  .split { grid-template-columns: 1fr; grid-template-rows: auto; }
  .split[data-view="edit"] .preview, .split[data-view="preview"] .editor { display: none; }
  .editor, .preview { height: auto; }
  .preview { padding: 16px; }
  .actions { margin-left: 0; }
  .divider { display: none; }
}
/* ---------- mobile drawer nav (slide in from left) ---------- */
.nav-toggle { display: none; background: transparent; border: 1px solid var(--steel); color: var(--white);
  border-radius: var(--radius-s); font-size: 22px; line-height: 1; padding: 6px 12px; cursor: pointer; }
.nav-scrim { position: fixed; inset: 0; z-index: 290; background: rgba(173, 216, 230, 0.25);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .topbar { gap: 12px; }
  .actions { position: fixed; top: 0; left: 0; bottom: 0; z-index: 300; width: min(300px, 84vw);
    flex-direction: column; align-items: stretch; gap: 10px; margin: 0; padding: 18px 14px;
    background: var(--bar); box-shadow: 8px 0 40px rgba(0,0,0,.35);
    transform: translateX(-105%); transition: transform .25s ease; overflow-y: auto; }
  body.nav-open .actions { transform: translateX(0); }
  .navmenu summary { width: 100%; justify-content: space-between; }
  .navmenu .menu { position: static; box-shadow: none; margin-top: 6px; }
  .signed-in { margin-top: auto; padding-top: 10px; }
}
/* ---------- tablet (portrait iPad and small laptops) ---------- */
@media (min-width: 761px) and (max-width: 1024px) {
  .topbar { padding: 12px 18px 26px; }
  .actions { gap: 10px; }
  .btn, .navmenu summary { min-height: 44px; display: inline-flex; align-items: center; }
  .navmenu .menu-item { min-height: 44px; font-size: 15px; }
  .editor { padding: 0 20px; }
  .preview { padding: 20px; }
  .modal-card { width: min(680px, 94vw); }
  .totalbar-amount { font-size: 32px; }
  input, select, textarea { font-size: 16px; } /* stops iOS auto-zoom */
}
/* ---------- phone ---------- */
@media (max-width: 760px) {
  .line-grid { grid-template-columns: 1fr; }
  .line-grid .span-2 { grid-column: auto; }
  input, select, textarea { font-size: 16px; } /* stops iOS auto-zoom */
  .modal-card { width: calc(100vw - 24px); margin: 12px; }
  .footer-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .footer-actions .btn { min-height: 44px; }
  .totalbar-amount { font-size: 30px; }
  .field-row { flex-wrap: wrap; }
}
/* ---------- full desktop ---------- */
@media (min-width: 1025px) {
  .topbar { padding: 14px 32px 30px; }
  .editor { padding: 0 32px; }
  .preview { padding: 36px; }
  .modal-card { width: min(560px, 94vw); }
}
@media (max-width: 560px) {
  .list-scroll { columns: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- print: only the A4 invoice ---------- */
@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; display: block; }
  body > *:not(main), .editor, .view-switch { display: none !important; }
  .split, .preview { display: block !important; padding: 0 !important; height: auto !important; overflow: visible !important; }
  .preview-scaler { transform: none !important; width: auto !important; height: auto !important; }
  .invoice-page { box-shadow: none; width: 210mm; min-height: 297mm; }
}
