/* Payo — UI stylesheet */

:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --border: #e3e6ec;
  --border-strong: #cfd4dd;
  --border-hover: #b9c0cc;
  --hover-bg: #f6f8fb;
  --input-bg: #ffffff;
  --text: #101828;
  --text-secondary: #344054;
  --label: #475467;
  --muted: #667085;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --accent-soft-border: #d5e2fb;
  --danger: #dc2626;
  --ok: #15803d;
  --ok-soft: rgba(21, 128, 61, 0.12);
  --ok-border: rgba(21, 128, 61, 0.4);
  --warn: #b45309;
  --warn-soft: rgba(217, 119, 6, 0.1);
  --warn-border: rgba(217, 119, 6, 0.45);
  --ring: rgba(37, 99, 235, 0.22);
  --bar-bg: rgba(255, 255, 255, 0.92);
  --toast-bg: #101828;
  --toast-text: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  color-scheme: light;
}

/* Dark palette — applied by the toggle (data-theme) or the OS preference. */
:root[data-theme="dark"] {
  --bg: #0e1320;
  --card: #161c2a;
  --border: #232c3d;
  --border-strong: #39455c;
  --border-hover: #4a5872;
  --hover-bg: #1e2637;
  --input-bg: #111827;
  --text: #e7ecf5;
  --text-secondary: #c7d1e0;
  --label: #a9b4c8;
  --muted: #8d97ac;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: #1a2540;
  --accent-soft-border: #2e416b;
  --danger: #f87171;
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.14);
  --ok-border: rgba(74, 222, 128, 0.4);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --warn-border: rgba(251, 191, 36, 0.4);
  --ring: rgba(96, 165, 250, 0.3);
  --bar-bg: rgba(15, 20, 32, 0.92);
  --toast-bg: #e9eef7;
  --toast-text: #111827;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1320;
    --card: #161c2a;
    --border: #232c3d;
    --border-strong: #39455c;
    --border-hover: #4a5872;
    --hover-bg: #1e2637;
    --input-bg: #111827;
    --text: #e7ecf5;
    --text-secondary: #c7d1e0;
    --label: #a9b4c8;
    --muted: #8d97ac;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-soft: #1a2540;
    --accent-soft-border: #2e416b;
    --danger: #f87171;
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, 0.14);
    --ok-border: rgba(74, 222, 128, 0.4);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.12);
    --warn-border: rgba(251, 191, 36, 0.4);
    --ring: rgba(96, 165, 250, 0.3);
    --bar-bg: rgba(15, 20, 32, 0.92);
    --toast-bg: #e9eef7;
    --toast-text: #111827;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

/* author display rules must never resurrect [hidden] elements */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.45;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

a.brand:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
  border-radius: 8px;
}

.brand-mark {
  width: 26px;
  height: 26px;
  color: var(--accent);
  flex: none;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  color: var(--muted);
  font-size: 12.5px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  white-space: nowrap;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* the editor's own toolbar row (top of the invoice page on desktop,
   fixed bottom bar on phones via the mobile rules further down) */
.editor-actions { justify-content: flex-end; }

/* ---------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}

.btn:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--card);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { background: var(--hover-bg); border-color: var(--border-hover); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { color: var(--text); background: var(--hover-bg); }

/* anchors dressed as buttons (e.g. the Call tel: link) sit like buttons */
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, background-color .15s, border-color .15s, box-shadow .15s;
}
.btn-icon:hover { color: var(--text); background: var(--hover-bg); }
.btn-icon:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.btn-icon svg { width: 18px; height: 18px; }

/* the UA's [hidden] rule is HTML-namespace only — cover SVG icons too */
.btn-icon svg[hidden] { display: none; }

/* the hamburger + its labelled menu exist only on phones */
.btn-menu { display: none; }

.mobile-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 25;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
  padding: 6px 10px 10px;
  display: grid;
  gap: 2px;
}

.mobile-menu button {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 12px;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 15.5px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.mobile-menu button:hover,
.mobile-menu button:active { background: var(--hover-bg); }

.mobile-menu svg { width: 20px; height: 20px; color: var(--muted); flex: none; }

@media (min-width: 761px) {
  .mobile-menu { display: none !important; }
}

/* ------------------------------------------------------------------ cards */

.page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 22px 20px 12px;
  display: grid;
  gap: 16px;
}

main.page[hidden] { display: none; }

.page-foot {
  max-width: 1000px;
  margin: 0 auto;
  padding: 8px 20px 48px;
}

/* The top bar is pure navigation and never changes between screens — the
   invoice actions live on the editor page itself (.editor-actions). */

/* ---------------------------------------------------------- landing page */

.page-landing { max-width: 1080px; padding-top: max(5vh, 24px); padding-bottom: 40px; }

/* hero: the illustrated banner with copy laid over its empty left half */
.land-hero-banner {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 18px 44px rgba(15, 30, 70, 0.12);
  margin-bottom: 44px;
  background: #fffdf8; /* matches the banner artwork */
}

.land-hero-bg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 460px;          /* keep the hero comfortably inside a laptop fold */
  object-fit: cover;
  object-position: center right; /* the artwork lives on the right; the left is copy space */
}

.land-hero-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 4.5%;
  max-width: 46%; /* the artwork's empty copy space is the left ~45% */
}
.land-hero-overlay .land-title { font-size: 33px; }
.land-hero-overlay .land-sub { font-size: 14.5px; }

/* the banner artwork is always light, so the overlay text is fixed-dark */
.land-hero-overlay .land-title { color: #16233b; }
.land-hero-overlay .land-sub { color: #45536e; }
.land-hero-overlay .land-trust { color: #5b6880; }

.land-pill {
  display: inline-block;
  background: var(--ok-soft, #e8f6ee);
  color: var(--ok, #177245);
  border: 1px solid var(--ok-border, #bfe5cf);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 6px 14px;
  margin-bottom: 14px;
}

.land-title {
  margin: 0 0 12px;
  font-size: 38px;
  line-height: 1.12;
  letter-spacing: -0.025em;
}

.land-sub {
  margin: 0 0 20px;
  color: var(--text-secondary);
  font-size: 16px;
  line-height: 1.55;
  max-width: 460px;
}

.landing-ctas {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.landing-ctas .btn { min-width: 170px; min-height: 44px; }
.btn-large { font-size: 15.5px; padding: 12px 22px; }

.land-trust {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.land-shot img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 18px 44px rgba(15, 30, 70, 0.14);
}
.land-shot { margin: 0; }

/* stacked page sections */
.land-section { margin: 0 0 44px; }

.land-h2 {
  margin: 0 0 18px;
  font-size: 25px;
  letter-spacing: -0.02em;
  text-align: center;
}

.land-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.land-grid li {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.land-grid strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 4px;
}

/* image-beside-copy sections (PDF showcase, illustration stories) */
.land-split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 36px;
  align-items: center;
}
.land-split-rev { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.land-split-rev .land-shot-art { order: 2; }
.land-split-rev .land-split-copy { order: 1; }
.land-shot-pdf { max-width: 340px; justify-self: center; }
.land-shot-art { max-width: 400px; justify-self: center; width: 100%; }
.land-shot-app { max-width: 480px; justify-self: center; width: 100%; }
.land-shot-art img { box-shadow: none; border: none; border-radius: 14px; }
.land-split-copy .land-h2 { text-align: left; }
.land-split-copy p { color: var(--text-secondary); font-size: 15px; line-height: 1.6; }
.land-split-copy strong { color: var(--text); }

/* honesty section: cafe illustration beside the checklist */
.land-honest-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
  gap: 28px;
  align-items: center;
}
.land-honest-grid .land-ticks { margin: 0; max-width: none; }
.land-honest-grid .land-honest-lead { text-align: left; margin: 0 0 14px; max-width: none; }

/* the honesty block: what it is (and isn't) */
.land-honest {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 28px;
}
.land-honest-lead {
  margin: 0 auto 16px;
  max-width: 720px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
}
.land-honest-lead strong { color: var(--text); }
.land-ticks {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  max-width: 640px;
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}
.land-ticks li { padding-left: 26px; position: relative; }
.land-ticks li::before {
  content: "✓";
  position: absolute;
  left: 4px;
  color: var(--ok, #177245);
  font-weight: 800;
}

/* final call to action */
.land-cta-band {
  text-align: center;
  padding: 30px 20px 6px;
  border-top: 1px solid var(--border);
}
.land-cta-band .landing-ctas { justify-content: center; }
.land-fineprint {
  margin: 14px auto 0;
  max-width: 640px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

@media (max-width: 1000px) {
  .land-hero-overlay { max-width: 50%; }
  .land-hero-overlay .land-title { font-size: 26px; }
  .land-hero-overlay .land-sub { font-size: 13px; margin-bottom: 12px; }
  .land-hero-overlay .land-trust { display: none; }
}

@media (max-width: 860px) {
  /* small screens: the banner art becomes a picture under the copy */
  .land-hero-banner {
    border: none;
    box-shadow: none;
    background: none;
    overflow: visible;
    display: flex;
    flex-direction: column-reverse;
  }
  .land-hero-overlay { position: static; max-width: none; padding: 0; }
  .land-hero-bg {
    margin: 20px auto 0;
    border-radius: 14px;
    border: 1px solid var(--border);
    max-width: 420px;
    max-height: none;
    object-fit: fill;
  }
  .land-title { font-size: 29px; }
  .land-hero-overlay .land-title { color: var(--text); }
  .land-hero-overlay .land-sub { color: var(--text-secondary); }
  .land-hero-overlay .land-trust { color: var(--text-secondary); }
  .land-grid { grid-template-columns: 1fr 1fr; }
  .land-split, .land-split-rev, .land-honest-grid { grid-template-columns: 1fr; }
  .land-split-rev .land-shot-art { order: 1; }
  .land-split-rev .land-split-copy { order: 2; }
  .land-shot-pdf { max-width: 320px; }
  .land-split-copy .land-h2 { text-align: center; }
  .land-honest-grid .land-honest-lead { text-align: center; }
}

@media (max-width: 560px) {
  .land-grid { grid-template-columns: 1fr; }
  .landing-ctas .btn { flex: 1; }
  .land-section { margin-bottom: 34px; }
  .land-h2 { font-size: 21px; }
  .land-shot-art, .land-shot-app { max-width: 330px; }
  .land-shot-pdf { max-width: 290px; }
}

.landing-closed { margin-top: 8px; }

.steps-123 {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  max-width: 980px;
}
@media (max-width: 720px) {
  .steps-123 { grid-template-columns: 1fr; gap: 13px; }
}

.steps-123 li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.step-num {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.step-body {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.step-body strong {
  display: block;
  color: var(--text);
  font-size: 14.5px;
  margin-bottom: 1px;
}

/* ------------------------------------------------- saved items & services */

.add-item-row {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* the add-service form: the description deserves most of the row */
.svc-grid { grid-template-columns: 3fr 1fr; }

@media (max-width: 760px) {
  .svc-grid { grid-template-columns: 1fr; }
}

.saved-menu-wrap { position: relative; display: inline-flex; }

.saved-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 50;
  min-width: 300px;
  max-width: min(420px, 88vw);
  max-height: 300px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  padding: 6px;
}

.saved-menu-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13.5px;
  color: var(--text);
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
}

.saved-menu-item:hover { background: var(--accent-soft); }

.saved-menu-empty {
  padding: 10px 10px 4px;
  color: var(--muted);
  font-size: 13px;
}

.saved-menu .btn-link { padding: 6px 10px 10px; }

.service-price {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.service-info { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.service-info strong { overflow-wrap: anywhere; }

.row-save {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s, background-color .15s;
}
.row-save:hover { color: var(--accent); background: var(--accent-soft); }

.settings-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.settings-head h2 { margin: 0; }

.field-check .check-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

.field-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.btn-icon[aria-pressed="true"] {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ------------------------------------------------------------ auth screen */

/* signed-out screens show just the brand — sign in to reach any controls */
.auth-open .topbar-right .btn-icon { display: none; }
.auth-open #btn-new { display: none; }

.page-auth {
  max-width: 430px;
  padding-top: max(7vh, 30px);
}

.auth-card { padding: 26px 24px 24px; }

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-bottom: 18px;
}

.auth-brand .brand-mark { width: 30px; height: 30px; }
.auth-brand .brand-name { font-size: 20px; }

.auth-title {
  margin: 0 0 14px !important;
  font-size: 15px !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--text) !important;
}

.auth-error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 10px 0 2px;
}

.auth-ok {
  color: var(--accent);
  font-size: 13px;
  margin: 10px 0 2px;
}

.btn-block { width: 100%; margin-top: 4px; }

.auth-alt {
  text-align: center;
  margin: 14px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.btn-link {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn-link:hover { text-decoration: underline; }

.code-input {
  font-size: 22px !important;
  letter-spacing: 0.35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.code-actions {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
}

/* --------------------------------------------------------- invoice list */

table.invlist {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  margin-bottom: 14px;
}

table.invlist th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 10px 8px;
  border-bottom: 2px solid var(--border-strong);
}

table.invlist th.num, table.invlist td.num { text-align: right; font-variant-numeric: tabular-nums; }

table.invlist td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.invlist .badge { margin-left: 8px; }

td.inv-client {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

td.inv-actions {
  text-align: right;
  white-space: nowrap;
}

td.inv-actions .btn { margin-left: 6px; }

/* -------------------------------------------- admin context (view/edit) */

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  color: var(--text-secondary);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13.5px;
}

/* admin screen: limits editor */
.limits-group {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px 14px 12px;
  margin: 0 0 14px;
  min-width: 0;
}
.limits-group legend {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-secondary);
  padding: 0 6px;
}
.limits-group .field { margin: 8px 0 0; }

/* admin screen: activity log */
.audit-list { max-height: 420px; overflow-y: auto; }
.audit-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.audit-row:last-child { border-bottom: none; }
.audit-time {
  color: var(--text-secondary);
  white-space: nowrap;
  flex: none;
  min-width: 108px;
}
.audit-user { font-weight: 600; overflow-wrap: anywhere; }
.audit-action { color: var(--text-secondary); overflow-wrap: anywhere; }

/* admin screen: the public sign-up switch under the user list */
.reg-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 14px 0 6px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
}
.reg-check input { margin-top: 2px; }
.reg-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 4px 0 6px;
}
.reg-actions .hint { margin: 0; }

/* email trouble: amber warning shown to admins on the dashboard */
.banner-warn {
  background: var(--warn-soft);
  border-color: var(--warn-border);
  color: var(--text);
}
.banner-warn::before { content: "⚠️"; flex: none; }

/* sent-invoice lock: the whole banner is one big "unlock" button */
.banner-lock {
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  background: var(--warn-soft);
  border-color: var(--warn-border);
  transition: border-color .15s, box-shadow .15s;
}
.banner-lock:hover { border-color: var(--warn); }
.banner-lock:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.banner-lock-icon { font-size: 16px; flex: none; }
.banner-lock-text { flex: 1; min-width: 220px; }
.banner-lock-cta { pointer-events: none; flex: none; }

/* while locked the editor cards read as untouchable */
.inv-locked #page-invoice .card { opacity: 0.72; }

/* invoice date that isn't today — the re-issue nudge */
input.date-stale {
  border-color: var(--warn);
  color: var(--warn);
  font-weight: 600;
}

.hint.field-note-warn, .field-note-warn { color: var(--warn); }

.list-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* filter/sort toolbar above the invoice list */
.list-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 12px;
}

/* free-text search sitting alongside the filter dropdowns */
.list-search { flex: 1 1 200px; min-width: 0; max-width: 300px; }

.inv-ref {
  color: var(--muted);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* the invoice number doubles as an open-this-invoice link */
.inv-num-link {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
}
.inv-num-link:hover { color: var(--accent); text-decoration: underline; }
.inv-num-link:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.user-select {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  padding: 8px 10px;
  max-width: 220px;
}

/* ------------------------------------------------------------ save state */

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.save-status {
  font-size: 12px;
  color: var(--muted);
}

.save-status-error { color: var(--danger); font-weight: 600; }

.email-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.email-row input { flex: 1; min-width: 220px; }

/* ------------------------------------------------------- account & users */

.account-line { margin: 0 0 14px; }

.account-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  vertical-align: middle;
}

.users-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}

.user-you { color: var(--muted); font-size: 12.5px; margin-left: 8px; }

.user-info { min-width: 0; }

.user-biz { font-size: 13px; margin-top: 2px; }

.user-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* the whole row is a button that opens that user's invoice list */
.user-row-click { cursor: pointer; }
.user-row-click:hover,
.user-row-click:focus-visible { border-color: var(--accent); }

.badge-paid {
  background: var(--ok-soft);
  border-color: var(--ok-border);
  color: var(--ok);
}

.badge-overdue {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.4);
  color: var(--danger);
}

.badge-emailed {
  background: var(--accent-soft);
  border-color: var(--accent-soft-border);
  color: var(--accent);
}

.badge-exported {
  background: var(--hover-bg);
  border-color: var(--accent-soft-border);
  color: var(--text-secondary);
}

.badge-draft {
  background: var(--hover-bg);
  border-color: var(--border-strong);
  color: var(--muted);
}

tr.inv-row-paid td { opacity: 0.72; }
tr.inv-row-paid td.inv-paid-cell,
tr.inv-row-paid td.inv-actions { opacity: 1; }

td.inv-paid-cell { text-align: center; }

.paid-toggle { display: inline-flex; padding: 4px; cursor: pointer; }

.paid-toggle input {
  width: 19px;
  height: 19px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--ok);
}

/* --------------------------------------------------------------- dashboard */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  /* clear air under the Dashboard header / New invoice button */
  margin-top: 14px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--card);
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.stat-danger .stat-value { color: var(--danger); }

.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }

.dash-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 700px) {
  .dash-cols { grid-template-columns: 1fr; }
}

.top-row { margin-bottom: 12px; }

.top-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  margin-bottom: 4px;
}

.top-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.top-total { font-weight: 700; font-variant-numeric: tabular-nums; }

.top-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--accent-soft);
  overflow: hidden;
}

.top-bar-fill {
  position: relative;
  height: 100%;
  border-radius: 3px;
  background: var(--accent);
  overflow: hidden;
}

/* the paid share of the customer's bar, growing from the left */
.top-bar-paid {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: var(--ok);
  border-radius: 3px 0 0 3px;
}

.top-pct { color: var(--muted); font-weight: 600; }
.top-pct-full { color: var(--ok); }

.attention-worst { border-color: var(--danger); }

.badge-locked {
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(220, 38, 38, 0.4);
  color: var(--danger);
}

.user-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* --------------------------------------------- customer picker (Bill to) */

.cust-picker-wrap { display: block; position: relative; }

.cust-menu {
  bottom: auto;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: 300px;
  overflow: auto;
}

/* ------------------------------------------------ email-with-preview modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 12, 22, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  width: 100%;
  max-width: 660px;
  max-height: 94vh;
  overflow: auto;
  padding: 18px 20px;
}

.pdf-preview {
  display: block;
  width: 100%;
  height: 48vh;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  margin: 12px 0 14px;
  background: #525659; /* the PDF viewer's own chrome tone */
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- first-login setup wizard ---- */
.wizard { max-width: 580px; }

.wizard-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

.wizard-count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.wizard-sub { margin: 4px 0 2px; font-size: 17px; }

.wizard-intro { margin: 6px 0 12px; }

.wizard-tour {
  list-style: none;
  padding: 0;
  margin: 10px 0 12px;
}

.wizard-tour li {
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.wizard-tour li:last-child { border-bottom: none; }

/* the action row stays in reach while a long step scrolls */
.wizard-actions {
  position: sticky;
  bottom: 0;
  margin-top: 14px;
  padding: 12px 0 2px;
  background: var(--card);
  box-shadow: 0 -10px 14px -12px rgba(0, 0, 0, 0.35);
}

.wizard-actions-spacer { flex: 1; }

/* phones: the wizard becomes a full-height sheet with a stacked action bar */
@media (max-width: 600px) {
  .modal-overlay:has(.wizard) { padding: 0; align-items: stretch; }
  .modal.wizard {
    max-width: none;
    max-height: none;
    height: 100%;
    border-radius: 0;
    border: 0;
    display: flex;
    flex-direction: column;
  }
  /* short steps: the action bar drops to the bottom of the sheet */
  .modal.wizard .wizard-actions { margin-top: auto; }
  .wizard-actions { flex-wrap: wrap; }
  .wizard-actions .btn-primary {
    flex: 1 1 100%;
    order: 4;
    padding: 12px 14px;
    font-size: 15px;
  }
}

.field-note { margin-top: 6px; }
.hint.field-note-ok, .field-note-ok { color: var(--ok); }
.hint.field-note-bad, .field-note-bad { color: var(--danger); }

.smtp-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  margin: 0 0 14px;
  font-size: 13px;
}

.smtp-details dt { color: var(--muted); font-weight: 600; }

.smtp-details dd { margin: 0; overflow-wrap: anywhere; }

.btn-small { padding: 5px 10px; font-size: 12.5px; }

.btn-danger:hover { color: var(--danger); background: rgba(220, 38, 38, 0.12); }

#form-new-user .btn { margin-top: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px 20px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ----------------------------------------------------------------- fields */

.field { display: block; }

.field + .field { margin-top: 12px; }

/* grid cells align at the top — the sibling spacing is for stacked fields only */
.grid .field + .field { margin-top: 0; }

/* a full-width field straight after a grid (e.g. ABN with its info icon)
   needs the same breathing room as field-to-field stacking — and so do
   stacked grid rows (the customers form mixes fields and grid rows) */
.grid + .field,
.field + .grid,
.grid + .grid { margin-top: 14px; }

.field-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--label);
  margin-bottom: 5px;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="password"],
input[type="email"],
input[type="tel"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

textarea {
  resize: vertical;
  min-height: 38px;
  line-height: 1.5;
}

.hint {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.logo-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.input-caps { text-transform: uppercase; }

.logo-white-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

.logo-white-line input {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}

.logo-preview {
  max-height: 56px;
  max-width: 180px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff; /* stays white in dark mode — the PDF page is white */
  object-fit: contain;
}

/* ------------------------------------------------------------- line items */

.items-scroll { overflow-x: auto; }

table.items {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

table.items th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 8px 8px;
  border-bottom: 2px solid var(--border-strong);
}

table.items th.col-qty,
table.items th.col-price,
table.items th.col-amount { text-align: right; }

table.items td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.items .col-drag { width: 30px; padding-left: 0; padding-right: 0; }
table.items .col-desc { width: 49%; }
table.items .col-qty,
table.items .col-price { width: 14%; }
table.items .col-amount { width: 17%; }
table.items .col-del { width: 62px; padding-right: 0; white-space: nowrap; }

table.items td.col-desc textarea {
  overflow: hidden;
  resize: none;
  min-height: 36px;
}

table.items td.col-qty input,
table.items td.col-price input { text-align: right; }

/* hide number-input spinners so the table stays clean */
table.items input[type="number"]::-webkit-outer-spin-button,
table.items input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
table.items input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

td.col-amount {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
}

.row-del {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  transition: color .15s, background-color .15s;
}
.row-del:hover { color: var(--danger); background: rgba(220, 38, 38, 0.12); }

/* drag-to-reorder handle */
.row-drag {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  line-height: 1;
  width: 26px;
  height: 28px;
  border-radius: 6px;
  cursor: grab;
  touch-action: none; /* the handle drags rows, it never scrolls the page */
}
.row-drag:hover { color: var(--text); background: var(--hover-bg); }
.row-drag:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.row-drag:active { cursor: grabbing; }

tr.row-dragging { opacity: 0.6; }
tr.row-dragging td { background: var(--hover-bg); }

.btn-add { margin-top: 12px; }

/* ----------------------------------------------------------------- totals */

.totals-wrap {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  flex-wrap: wrap;
}

.gst-side {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gst-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}

/* ---------------------------------------------------- info tip (ⓘ) ----- */

.tip {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.tip-btn {
  appearance: none;
  width: 19px;
  height: 19px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  flex: none;
  transition: color .15s, border-color .15s, background-color .15s;
}

.tip:hover .tip-btn,
.tip.tip-open .tip-btn,
.tip-btn:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tip-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.tip-bubble {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  padding-bottom: 9px;              /* hover bridge between button and card */
  width: min(320px, 86vw);
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
}

.tip:hover .tip-bubble,
.tip:focus-within .tip-bubble,
.tip.tip-open .tip-bubble {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.tip-inner {
  display: block;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  padding: 12px 14px;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text-secondary);
  text-align: left;
  white-space: normal;
  cursor: auto;
}

.tip-inner strong { color: var(--text); }

.tip-inner strong:first-child {
  display: block;
  margin-bottom: 4px;
}

.tip-inner a {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.tip-inner a:hover { text-decoration: underline; }

.tip-inner em {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11.5px;
}

.check-line-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.gst-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.totals {
  min-width: 300px;
  max-width: 360px;
  flex: 1;
  font-variant-numeric: tabular-nums;
}

.trow {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 7px 2px;
  border-top: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-secondary);
}

.trow:first-child { border-top: 0; }

.trow .num { font-weight: 600; }

.trow-muted { color: var(--muted); }
.trow-muted .num { font-weight: 500; }

.trow-total {
  border-top: 2px solid var(--text);
  font-size: 16.5px;
  font-weight: 700;
  color: var(--text);
  padding-top: 10px;
}
.trow-total .num { font-weight: 700; }

/* ------------------------------------------------------------------- misc */

.foot-note {
  margin: 4px 2px 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.app-meta {
  margin: 2px 2px 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.meta-sep { margin: 0 6px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  background: var(--toast-bg);
  color: var(--toast-text);
  font-size: 13.5px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  max-width: min(92vw, 560px);
}

.toast-show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-error { background: #b42318; color: #fff; }

/* ------------------------------------------------------------- responsive */

/* Respect notch / Dynamic Island insets in landscape */
.topbar-inner {
  padding-left: calc(20px + env(safe-area-inset-left));
  padding-right: calc(20px + env(safe-area-inset-right));
}

@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .brand-sub { display: none; }

  /* phones: brand + New invoice + hamburger — the icon row lives in the menu */
  .topbar-right { gap: 8px; }
  .topbar-right .btn-icon:not(.btn-menu) { display: none; }
  .btn-menu { display: inline-flex; }
  .btn-new-top { white-space: nowrap; padding: 8px 12px; }
  .card { padding: 16px 14px; }
  .totals { min-width: 0; width: 100%; }

  .topbar-inner {
    padding: 10px calc(14px + env(safe-area-inset-right)) 10px calc(14px + env(safe-area-inset-left));
  }

  .page {
    padding: 16px calc(12px + env(safe-area-inset-right)) 8px calc(12px + env(safe-area-inset-left));
  }

  .page-foot {
    padding: 8px calc(12px + env(safe-area-inset-right)) calc(40px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  }

  /* the editor's fixed bottom bar needs clearance + the home indicator */
  .editor-open .page-foot {
    padding-bottom: calc(150px + env(safe-area-inset-bottom));
  }

  /* 16px inputs stop iOS Safari from auto-zooming on focus */
  input[type="text"],
  input[type="date"],
  input[type="number"],
  input[type="password"],
  input[type="email"],
  input[type="tel"],
  select,
  textarea { font-size: 16px; }

  /* comfortable touch targets */
  .btn { min-height: 44px; }
  .row-del { width: 38px; height: 38px; font-size: 22px; }

  /* --- actions become a fixed, thumb-reachable bottom bar --------------- */
  .actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
    gap: 8px;
    padding: 10px calc(14px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
    background: var(--bar-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
  }

  .actions .btn { width: 100%; padding-left: 6px; padding-right: 6px; white-space: nowrap; }
  .actions .btn-ghost { background: var(--card); border-color: var(--border-strong); color: var(--text); }
  #btn-pdf, #btn-email { grid-column: 1 / -1; }

  .toast { bottom: calc(128px + env(safe-area-inset-bottom)); }

  /* --- line items: table becomes stacked cards -------------------------- */
  .items-scroll { overflow-x: visible; }

  table.items { min-width: 0; }
  table.items thead { display: none; }
  table.items, table.items tbody { display: block; }

  table.items tbody tr {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "desc  desc"
      "qty   price"
      "amount amount";
    gap: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--card);
    box-shadow: var(--shadow);
  }

  table.items td { display: block; padding: 0; border-bottom: 0; }

  /* beat the base percentage column widths (table.items .col-*) */
  table.items td.col-desc,
  table.items td.col-qty,
  table.items td.col-price,
  table.items td.col-amount,
  table.items td.col-del { width: auto; }

  table.items td.col-desc { grid-area: desc; padding-right: 34px; }
  table.items td.col-qty { grid-area: qty; }
  table.items td.col-price { grid-area: price; }

  table.items td.col-qty::before,
  table.items td.col-price::before {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 4px;
  }
  table.items td.col-qty::before { content: "Quantity"; }
  table.items td.col-price::before { content: "Unit Price"; }

  table.items td.col-amount {
    grid-area: amount;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px dashed var(--border-strong);
    padding-top: 9px;
    font-size: 15px;
  }
  table.items td.col-amount::before {
    content: var(--amount-label, "Amount AUD");
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
  }

  table.items td.col-del {
    position: absolute;
    top: 8px;
    right: 8px;
  }

  .totals-wrap { flex-direction: column; align-items: stretch; }
  .gst-side { justify-content: center; }
  .gst-toggle { justify-content: center; flex: 1; }

  /* --- saved-invoice list becomes stacked cards ------------------------- */
  .list-tools { width: 100%; }
  .list-tools .user-select { flex: 1; min-width: 0; max-width: none; font-size: 16px; }
  .list-tools .btn { flex: 1; }
  .list-filters .list-search { max-width: none; font-size: 16px; }

  table.invlist { min-width: 0; margin-bottom: 4px; }
  table.invlist thead { display: none; }
  table.invlist, table.invlist tbody { display: block; }

  table.invlist tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "number total"
      "date   paid"
      "client client"
      "actions actions";
    gap: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--card);
    box-shadow: var(--shadow);
  }

  table.invlist td { display: block; border: 0; padding: 0; }
  table.invlist td:nth-child(1) { grid-area: number; }
  table.invlist td:nth-child(2) { grid-area: date; color: var(--muted); font-size: 12.5px; align-self: center; }
  table.invlist td:nth-child(3) { grid-area: client; }
  table.invlist td:nth-child(4) { grid-area: total; font-weight: 700; }
  table.invlist td:nth-child(5) { grid-area: paid; justify-self: end; }
  table.invlist td:nth-child(6) {
    grid-area: actions;
    text-align: left;
    white-space: normal;
    border-top: 1px dashed var(--border-strong);
    padding-top: 9px;
    margin-top: 5px;
  }
  td.inv-client { white-space: normal; max-width: none; }
  td.inv-actions .btn { margin: 0 6px 6px 0; min-height: 38px; }
}

/* phones: the reorder handle sits beside the delete button on each card */
@media (max-width: 760px) {
  table.items td.col-drag {
    position: absolute;
    top: 8px;
    right: 74px;
    width: auto;
    padding: 0;
  }
  .row-drag { width: 38px; height: 38px; font-size: 18px; }
  table.items td.col-desc { padding-right: 118px; }
}
