/* ──────────────────────────────────────────────────────────────────────────
 * books.css — the neuralbooks app (invoices.html / quotes.html / customers.html).
 *
 * Lifted verbatim from the inline <style> blocks that were duplicated across
 * invoices.html and quotes.html (the invoices block is a superset), plus the
 * shared neuralbooks app bar and the customers view. Palette mirrors the
 * shell's --nds-* dark tokens.
 *
 * NOTE: pre-token debt, MOVED not created — these rules predate the token
 * system and are excluded from the stylelint drift gate (see .stylelintrc.json
 * ignoreFiles), exactly as they were while inline. Tokenizing this file is
 * part of the CSS-drift burn-down, not the neuralbooks extraction.
 * ────────────────────────────────────────────────────────────────────────── */
:root {
  --inv-bg: #0e0f12; --inv-surface: #15171c; --inv-card: #1b1e25; --inv-card-hover: #23272f;
  --inv-text: #f2f4f8; --inv-text-2: #aeb6c4; --inv-muted: #727b8b;
  --inv-border: #2c313b; --inv-border-2: #3a404c;
  --inv-input-bg: #15171c; --inv-accent: #33b1ff; --inv-accent-h: #1493e6;
  --inv-link: #33b1ff; --inv-link-h: #66c6ff; --inv-danger: #ff5c5c;
  --inv-card-shadow: 0 2px 12px rgba(0,0,0,.35);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--inv-bg); font-family: 'Sora', system-ui, -apple-system, sans-serif; color: var(--inv-text); }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 28px; background: var(--inv-surface); border-bottom: 1px solid var(--inv-border); }
.topbar h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.topbar a { color: var(--inv-text-2); text-decoration: none; font-size: 14px; }
.wrap { max-width: 920px; margin: 26px auto 80px; padding: 0 16px; }
.muted { color: var(--inv-muted); }
.btn-primary { background: var(--inv-accent); color: #fff; border: 0; padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; box-shadow: 0 2px 10px rgba(51,177,255,.30); transition: background .15s ease; }
.btn-primary:hover { background: var(--inv-accent-h); }
.btn-ghost { background: var(--inv-card-hover); color: var(--inv-text); border: 0; padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; display: inline-block; transition: background .15s ease; }
.btn-ghost:hover { background: #2d374e; }
.btn-danger-ghost { background: rgba(239,68,68,.12); color: var(--inv-danger); border: 0; padding: 10px 18px; border-radius: 8px; font-weight: 600; font-size: 14px; cursor: pointer; transition: background .15s ease; }
.btn-danger-ghost:hover { background: rgba(239,68,68,.22); }
.link { background: none; border: 0; color: var(--inv-link); font-weight: 600; cursor: pointer; font-size: 14px; padding: 0; }
.link:hover { color: var(--inv-link-h); }
.badge { padding: 3px 10px; border-radius: 14px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.sb { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; }
.sb-ok { background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.30); color: #4ade80; }
.sb-warn { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.30); color: #fbbf24; }
/* Brand-tinted "connect" invite banners — the initial CTA wears the vendor's
   colour (indigo/blue) with a 3px brand accent bar. "Needs attention" states
   stay amber (.sb-warn) and success stays green (.sb-ok) so those signals read. */
.sb-stripe { background: rgba(99,91,255,.10); border: 1px solid rgba(99,91,255,.28); border-left: 3px solid #635bff; color: #b6b1fb; }
.sb-xero { background: rgba(19,181,234,.10); border: 1px solid rgba(19,181,234,.26); border-left: 3px solid #13b5ea; color: #86d4f1; }
.sb-stripe strong, .sb-xero strong { color: #fff; }
/* Leading brand badge — a white "app-icon" chip carrying the vendor logo,
   so every Stripe/Xero banner is identifiable at a glance. */
.sb-lead { display: flex; align-items: center; gap: 12px; min-width: 0; }
.sb-badge { flex: none; display: inline-flex; align-items: center; justify-content: center; background: #fff; border-radius: 7px; padding: 6px 8px; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.sb-badge svg { display: block; }
.sb .btn-primary, .sb .btn-brand { white-space: nowrap; }

/* ── Integration banner row ─────────────────────────────────────
   Full-size banners (connect CTAs / "needs attention" states) span
   the whole row; "all set up" success states collapse to compact
   pills that sit side-by-side, each expanding a full-width detail
   panel below the row on click. */
.int-banners { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-start; }
.int-banners:has(> div:not(:empty)) { margin-bottom: 14px; }
.int-banners > div:empty { display: none; }
.int-banners > div { flex: 1 1 100%; }        /* full banner → own row */
.int-banners .sb { margin-bottom: 0; }
/* In pill mode the container & wrap dissolve so the pill button and its
   detail panel become direct flex items of the row: pills flow together
   on one line, an opened panel wraps onto its own full-width line below. */
.int-banners > div.is-chip, .int-banners .sb-chip-wrap { display: contents; }

/* Collapsed success pill. The brand badge already carries the vendor
   wordmark, so the pill is just badge + tick + chevron. */
.sb-chip { order: 0; flex: 0 1 auto; box-sizing: border-box; min-height: 32px; display: inline-flex; align-items: center; gap: 8px; font-family: inherit; font-size: 13px; font-weight: 600; color: #4ade80; background: rgba(34,197,94,.12); border: 1px solid rgba(34,197,94,.30); border-radius: 999px; padding: 5px 12px 5px 6px; cursor: pointer; transition: background .15s ease, border-color .15s ease; }
.sb-chip:hover { background: rgba(34,197,94,.20); border-color: rgba(34,197,94,.45); }
/* Normalise the two vendor badges to one height so the pills match. */
.sb-chip .sb-badge { padding: 3px 6px; border-radius: 5px; }
.sb-chip .sb-badge svg { height: 13px; width: auto; }
.sb-chip-tick { font-size: 14px; line-height: 1; }
.sb-chip-chev { margin-left: 1px; opacity: .7; transition: transform .25s ease; }
.sb-chip-wrap.open .sb-chip-chev { transform: rotate(180deg); }
/* Detail panel: collapsed → zero-width, invisible item riding the pill row;
   open → full-width flex item that wraps to its own line below the pills.
   grid 0fr→1fr animates the height without measuring content. Border/bg
   live on the open state only so nothing shows while collapsed. */
.sb-chip-body { order: 1; flex: 0 0 0; width: 0; display: grid; grid-template-rows: 0fr; opacity: 0; visibility: hidden; overflow: hidden; transition: grid-template-rows .25s ease, opacity .2s ease; }
.sb-chip-wrap.open .sb-chip-body { flex: 1 1 100%; width: auto; grid-template-rows: 1fr; opacity: 1; visibility: visible; }
.sb-chip-body-inner { overflow: hidden; display: flex; align-items: center; gap: 14px; font-size: 13px; color: #4ade80; border-radius: 10px; }
.sb-chip-wrap.open .sb-chip-body-inner { padding: 10px 14px; background: rgba(34,197,94,.08); border: 1px solid rgba(34,197,94,.22); }
.sb-chip-body-inner .btn-ghost { white-space: nowrap; flex: none; }

/* ── Integration brand buttons (Stripe / Xero) ──────────────────
   Brand-coloured CTAs so each integration is instantly recognisable
   instead of a generic blue button. Colours are the vendors' brand
   values: Stripe #635bff, Xero #13b5ea. */
.btn-brand { display: inline-flex; align-items: center; gap: 9px; border: 0; padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: 14px; line-height: 1; color: #fff; cursor: pointer; transition: background .15s ease, box-shadow .15s ease, transform .06s ease; }
.btn-brand:hover { transform: translateY(-1px); }
.btn-brand:active { transform: translateY(0); }
.btn-brand:disabled { opacity: .7; cursor: default; transform: none; }
.btn-brand svg { display: block; }
.brand-logo { height: 15px; width: auto; }
.btn-stripe { background: #635bff; box-shadow: 0 2px 10px rgba(99,91,255,.35); }
.btn-stripe:hover { background: #554df0; }
.btn-xero { background: #13b5ea; box-shadow: 0 2px 10px rgba(19,181,234,.32); }
.btn-xero:hover { background: #0f9fce; }
/* Xero controls in already-connected / per-invoice contexts (dark bg). */
.btn-xero-ghost { display: inline-flex; align-items: center; gap: 7px; background: rgba(19,181,234,.12); color: #5ccbef; border: 1px solid rgba(19,181,234,.30); padding: 9px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; line-height: 1; cursor: pointer; transition: background .15s ease; }
.btn-xero-ghost:hover { background: rgba(19,181,234,.20); }
.xero-synced { display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 8px; font-weight: 600; font-size: 14px; line-height: 1; color: #4ade80; background: rgba(34,197,94,.10); border: 1px solid rgba(34,197,94,.25); cursor: default; }

/* list */
.inv-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.inv-summary:empty { display: none; }
.stat { background: var(--inv-card); border-radius: 12px; box-shadow: var(--inv-card-shadow); padding: 16px 18px; text-align: left; font-family: inherit; color: var(--inv-text); border: 1px solid transparent; cursor: pointer; transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.stat:hover { background: var(--inv-card-hover); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.stat:active { transform: translateY(0); }
.stat-active { border-color: var(--inv-accent); background: var(--inv-card-hover); }
.stat-val { font-size: 22px; font-weight: 700; letter-spacing: -.01em; transition: color .15s ease; }
.stat-lbl { font-size: 12px; color: var(--inv-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }
.stat-danger .stat-val { color: var(--inv-danger); }
.stat-ok .stat-val { color: #4ade80; }
@media (max-width: 640px) { .inv-summary { grid-template-columns: repeat(2, 1fr); } }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.list-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inv-search { width: 220px; padding: 9px 12px; border: 1px solid var(--inv-border-2); border-radius: 8px; background: var(--inv-input-bg); color: var(--inv-text); font-size: 14px; }
.inv-search::placeholder { color: var(--inv-muted); }
.inv-settings { margin-bottom: 18px; }
.settings-card { background: var(--inv-card); border-radius: 12px; box-shadow: var(--inv-card-shadow); padding: 22px; }
.settings-head { display: flex; justify-content: space-between; align-items: center; }
.settings-head h3 { margin: 0; font-size: 16px; }
.settings-note { font-size: 12px; color: var(--inv-muted); margin: 6px 0 14px; }
.settings-note a { color: var(--inv-link); }
.settings-sec { font-size: 12px; font-weight: 600; color: var(--inv-text-2); text-transform: uppercase; letter-spacing: .04em; margin: 16px 0 8px; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.settings-grid .lbl { margin-top: 0; }
.settings-actions { margin-top: 18px; }
@media (max-width: 640px) { .settings-grid { grid-template-columns: 1fr; } }
.list-head h2 { margin: 0; font-size: 22px; }
.card { background: var(--inv-card); border-radius: 12px; box-shadow: var(--inv-card-shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--inv-border); cursor: pointer; transition: background .15s ease; }
.row:hover { background: var(--inv-card-hover); }
.row-num { font-weight: 600; }
.row-cust { font-size: 13px; color: var(--inv-text-2); }
.row-meta { display: flex; align-items: center; gap: 16px; margin-left: auto; }
.row-total { font-weight: 600; }
.row-date { font-size: 12px; color: var(--inv-muted); min-width: 90px; text-align: right; }
.row-check { display: inline-flex; align-items: center; flex: none; padding: 2px; }
.row-check input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--inv-accent); }

/* Bulk-action bar — floats while rows are selected. */
.bulk-bar { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 10px 8px 16px; background: var(--inv-surface); border: 1px solid var(--inv-border-2); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 60; animation: inv-fade-up .2s ease both; }
.bulk-n { font-size: 13px; font-weight: 600; color: var(--inv-text); margin-right: 4px; white-space: nowrap; }
.bulk-bar .btn-ghost { padding: 7px 12px; font-size: 13px; }
@media (max-width: 560px) { .bulk-bar { left: 12px; right: 12px; transform: none; flex-wrap: wrap; justify-content: center; } }

/* List loading skeleton (shimmer rows) — replaces the plain "Loading…" text. */
.sk-row { display: flex; align-items: center; justify-content: space-between; padding: 17px 20px; border-bottom: 1px solid var(--inv-border); }
.sk-bar { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--inv-input-bg) 25%, var(--inv-card-hover) 37%, var(--inv-input-bg) 63%); background-size: 400% 100%; animation: sk-shimmer 1.4s ease infinite; }
@keyframes sk-shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* editor */
.ed-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.ed-status { display: flex; align-items: center; gap: 8px; }
.warn { background: rgba(245,158,11,.12); border: 1px solid rgba(245,158,11,.30); color: #fbbf24; padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.ed-dates { font-size: 13px; color: var(--inv-muted); font-weight: 400; }
.ed-from { background: var(--inv-card); padding: 16px 18px; border-radius: 12px; box-shadow: var(--inv-card-shadow); margin-bottom: 16px; }
.ed-from .lbl { margin: 0 0 4px; }
.ed-from .from-name { font-weight: 600; color: var(--inv-text); }
.ed-from .from-line { font-size: 13px; color: var(--inv-text-2); margin-top: 2px; }
.ed-payments { margin: 0 0 4px auto; width: 340px; }
.ed-payments .lbl { margin: 0 0 6px; }
.ed-payments .pay-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 5px 0; font-size: 13px; color: var(--inv-text-2); border-top: 1px solid var(--inv-border); }
.ed-payments .pay-when { color: var(--inv-muted); white-space: nowrap; }
.ed-payments .pay-method { flex: 1; }
.ed-payments .pay-amt { font-weight: 600; color: var(--inv-text); white-space: nowrap; }
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; background: var(--inv-card); padding: 22px; border-radius: 12px; box-shadow: var(--inv-card-shadow); }
.ed-col { display: flex; flex-direction: column; }
.lbl { font-size: 12px; font-weight: 600; color: var(--inv-text-2); margin: 12px 0 4px; }
.ed-col .lbl:first-child { margin-top: 0; }
.hint { font-weight: 400; color: var(--inv-muted); }
input, textarea, select { font-family: inherit; font-size: 14px; padding: 9px 11px; border: 1px solid var(--inv-border-2); border-radius: 7px; width: 100%; background: var(--inv-input-bg); color: var(--inv-text); }
input::placeholder, textarea::placeholder { color: var(--inv-muted); }
input:disabled, textarea:disabled { background: var(--inv-bg); color: var(--inv-muted); }
.items-head { display: flex; justify-content: space-between; align-items: center; margin: 26px 0 8px; }
.items-head h3 { margin: 0; font-size: 16px; }
table.ed-items { width: 100%; border-collapse: collapse; background: var(--inv-card); border-radius: 12px; overflow: hidden; box-shadow: var(--inv-card-shadow); }
table.ed-items th { text-align: left; font-size: 12px; color: var(--inv-text-2); padding: 10px; border-bottom: 2px solid var(--inv-border); }
table.ed-items td { padding: 6px 10px; border-bottom: 1px solid var(--inv-border); vertical-align: middle; }
table.ed-items .num { text-align: right; white-space: nowrap; }
.w-qty { width: 70px; } .w-unit { width: 60px; } .w-price { width: 100px; }
.gst-cell { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.gst-cell input { width: auto; }
.x { background: none; border: 0; color: var(--inv-muted); font-size: 20px; cursor: pointer; line-height: 1; }
.x:hover { color: var(--inv-danger); }
.ed-totals { margin: 18px 0 18px auto; width: 280px; }
.ed-totals > div { display: flex; justify-content: space-between; padding: 4px 0; font-size: 14px; color: var(--inv-text-2); }
.ed-totals span { color: var(--inv-muted); }
.ed-totals .grand { border-top: 1px solid var(--inv-border); margin-top: 4px; padding-top: 8px; font-size: 17px; font-weight: 700; color: var(--inv-text); }
.ed-totals .grand span { color: var(--inv-text); }
.ed-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }

#flash { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #0b0f17; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; border: 1px solid var(--inv-border-2); }
#busy { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.55); align-items: center; justify-content: center; color: #fff; font-weight: 600; z-index: 50; animation: inv-fade-in .15s ease; }

/* ── neuralbooks app bar ─────────────────────────────────────── */
.books-bar { justify-content: flex-start; gap: 22px; }
.books-back { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 8px; color: var(--inv-text-2); text-decoration: none; font-size: 18px; margin-right: -8px; transition: background .15s ease, color .15s ease; }
.books-back:hover { background: var(--inv-card-hover); color: var(--inv-text); }
.books-brand { display: inline-flex; align-items: center; gap: 9px; font-size: 17px; letter-spacing: -.02em; color: var(--inv-text); white-space: nowrap; }
.books-brand b { font-weight: 800; }
.books-brand img { display: block; border-radius: 6px; }
.books-tabs { display: flex; align-items: center; gap: 4px; }
.books-tab { color: var(--inv-text-2); text-decoration: none; font-size: 14px; font-weight: 600; padding: 7px 14px; border-radius: 8px; border: 1px solid transparent; transition: background .15s ease, color .15s ease; }
.books-tab:hover { background: var(--inv-card-hover); color: var(--inv-text); }
.books-tab.is-active { background: var(--inv-card); color: var(--inv-text); border-color: var(--inv-border-2); }
@media (max-width: 560px) {
  /* App-style mobile chrome. The top bar is a single row (brand + search + bell +
     theme); the tabs move to a fixed BOTTOM NAV (see the block after the bell
     section). Content is padded so it clears the bottom nav. */
  .books-bar { padding: 9px 12px; gap: 8px; flex-wrap: wrap; align-items: center; }
  .books-back { display: none; }                 /* PWA: reclaim the space */
  .books-brand { order: 1; }
  .books-brand span { display: none; }
  .books-search { order: 2; flex: 1 1 auto; min-width: 0; margin-left: 0; }
  .books-search input, .books-search input:focus { width: 100%; padding-right: 12px; }
  .books-install { order: 3; }
  .books-bell-wrap { order: 4; }
  .books-theme { order: 5; margin-left: 0; }
  .books-signout { order: 6; margin-left: 0; }
  .books-kbd { display: none; }
  /* NB: the bottom-nav, bell-panel and search-results mobile overrides live AFTER
     their base rules (below the bell section) so source order lets them win. */
}
/* Tab icons only appear in the mobile bottom nav. */
.books-tab i.ti { display: none; }

/* Tab badges (unpaid invoices / quotes needing attention). */
.books-badge { display: inline-block; margin-left: 7px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--inv-accent); color: #fff; vertical-align: 1px; }

/* Global search (injected by books-bar.js; sits at the right of the bar). */
.books-search { position: relative; margin-left: auto; display: flex; align-items: center; }
.books-search input { width: 200px; padding: 8px 54px 8px 12px; border: 1px solid var(--inv-border-2); border-radius: 8px; background: var(--inv-input-bg); color: var(--inv-text); font-size: 13px; transition: width .15s ease; }
.books-search input:focus { width: 280px; outline: none; border-color: var(--inv-accent); }
.books-search input::placeholder { color: var(--inv-muted); }
.books-kbd { position: absolute; right: 10px; font-family: inherit; font-size: 10px; color: var(--inv-muted); border: 1px solid var(--inv-border-2); border-radius: 4px; padding: 1px 5px; pointer-events: none; }
.books-search-results { position: absolute; top: calc(100% + 6px); right: 0; width: 340px; max-height: 420px; overflow-y: auto; background: var(--inv-surface); border: 1px solid var(--inv-border-2); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.45); z-index: 70; padding: 6px; }
.bsr-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--inv-muted); padding: 8px 10px 4px; }
.bsr-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px; text-decoration: none; color: var(--inv-text); font-size: 13px; }
.bsr-row:hover { background: var(--inv-card-hover); }
.bsr-row i { color: var(--inv-muted); font-size: 15px; }
.bsr-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bsr-row em { font-style: normal; color: var(--inv-muted); font-size: 12px; white-space: nowrap; }
.bsr-empty { padding: 14px; font-size: 13px; color: var(--inv-muted); text-align: center; }

/* Theme toggle button. */
.books-theme { flex: none; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 1px solid transparent; border-radius: 8px; color: var(--inv-text-2); font-size: 17px; cursor: pointer; transition: background .15s ease, color .15s ease; }
.books-theme:hover { background: var(--inv-card-hover); color: var(--inv-text); }

/* Sign-out button (injected by books-bar.js; sits at the far right of the bar). */
.books-signout { flex: none; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center; background: none; border: 1px solid transparent; border-radius: 8px; color: var(--inv-text-2); font-size: 17px; cursor: pointer; transition: background .15s ease, color .15s ease; }
.books-signout:hover { background: rgba(239,68,68,0.12); color: #ef4444; }

/* ── Install button (PWA; shown only when installable) ─────────── */
.books-install { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 34px; padding: 0 12px; border-radius: 8px;
  background: var(--inv-card-hover); color: var(--inv-text); border: 1px solid var(--inv-border-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s ease; }
.books-install:hover { background: var(--inv-accent); color: #fff; border-color: transparent; }
.books-install i { font-size: 15px; }

/* ── Notification bell + activity panel ────────────────────────── */
.books-bell-wrap { position: relative; flex: none; }
.books-bell { position: relative; width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 1px solid transparent; border-radius: 8px; color: var(--inv-text-2); font-size: 17px; cursor: pointer; transition: background .15s ease, color .15s ease; }
.books-bell:hover { background: var(--inv-card-hover); color: var(--inv-text); }
.books-bell-dot { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; padding: 0 4px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; background: var(--inv-danger, #dc2626); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1; border-radius: 999px; border: 2px solid var(--inv-bg); }
.books-bell-panel { position: absolute; top: 42px; right: 0; width: 320px; max-width: 86vw; max-height: 60vh; overflow-y: auto; z-index: 200;
  background: var(--inv-card); border: 1px solid var(--inv-border-2); border-radius: 12px; box-shadow: 0 16px 44px rgba(0,0,0,.4); padding: 6px; animation: bfx-pop .16s ease both; }
.bell-row { display: grid; grid-template-columns: 20px 1fr auto; align-items: start; gap: 9px; padding: 9px 10px; border-radius: 9px;
  text-decoration: none; color: var(--inv-text); font-size: 13px; line-height: 1.4; }
.bell-row:hover { background: var(--inv-card-hover); }
.bell-row i { font-size: 16px; margin-top: 1px; color: var(--inv-muted); }
.bell-row.warn i { color: #f59e0b; } .bell-row.good i { color: #22c55e; } .bell-row.info i { color: #1493e6; }
.bell-row em { font-style: normal; color: var(--inv-muted); font-size: 11px; white-space: nowrap; }
.bell-empty { display: flex; align-items: center; gap: 7px; padding: 18px 12px; color: var(--inv-muted); font-size: 13px; justify-content: center; }
.bell-empty i { color: #22c55e; font-size: 16px; }
.bell-notif { display: flex; align-items: center; gap: 8px; padding: 9px 10px; margin-bottom: 4px; border-radius: 9px;
  background: var(--inv-input-bg); font-size: 12.5px; color: var(--inv-text-2); }
.bell-notif > span { flex: 1; display: inline-flex; align-items: center; gap: 6px; }
.bell-notif i { color: #6366f1; font-size: 15px; }
.bell-notif-btn { flex: none; font: inherit; font-size: 12px; font-weight: 600; border-radius: 7px; padding: 5px 10px; cursor: pointer;
  background: transparent; color: var(--inv-text-2); border: 1px solid var(--inv-border-2); }
.bell-notif-btn.primary { background: var(--inv-accent); color: #fff; border-color: transparent; }
.bell-notif-btn:disabled { opacity: .6; cursor: default; }
@media (max-width: 560px) { .books-install span, .books-install { font-size: 0; gap: 0; padding: 0 10px; } .books-install i { font-size: 17px; } }

/* Mobile: keep the search results on-screen and turn the activity panel into a
   bottom sheet. Placed AFTER the base .books-search-results / .books-bell-panel
   rules so these win on source order (equal specificity). */
@media (max-width: 560px) {
  .books-search-results { width: min(360px, calc(100vw - 20px)); }
  .books-bell-panel { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none;
    max-height: 72vh; border-radius: 16px 16px 0 0; padding: 8px 10px calc(10px + env(safe-area-inset-bottom));
    box-shadow: 0 -14px 40px rgba(0, 0, 0, .5); animation: bell-sheet-up .22s ease both; }
  .books-bell-panel::before { content: ''; display: block; width: 36px; height: 4px; border-radius: 999px;
    background: var(--inv-border-2); margin: 2px auto 8px; }
}
@keyframes bell-sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .books-bell-panel { animation: none; } }

/* Mobile bottom navigation — the tabs become a fixed, icon+label bottom bar
   (native-app feel). Placed after the base .books-tabs/.books-tab rules so these
   win on source order. Bottom-anchored UI (editor action bar, bulk bar, flash)
   is lifted to clear the ~58px nav, and the page gains matching bottom padding. */
:root { --books-navh: 58px; }
@media (max-width: 560px) {
  body { padding-bottom: calc(var(--books-navh) + env(safe-area-inset-bottom)); }
  .books-tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
    display: flex; justify-content: space-around; align-items: stretch; gap: 0;
    background: var(--inv-surface); border-top: 1px solid var(--inv-border);
    padding: 6px 4px calc(4px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 20px rgba(0, 0, 0, .28); }
  .books-tab { position: relative; flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 4px 2px; font-size: 11px; font-weight: 600; line-height: 1.1; border: 0; border-radius: 10px;
    color: var(--inv-text-2); background: none; text-align: center; }
  .books-tab i.ti { display: block; font-size: 21px; }
  .books-tab.is-active { color: var(--inv-accent); background: none; border-color: transparent; }
  .books-tab:hover { background: none; }
  /* Badge as a dot on the icon corner rather than an inline pill. */
  .books-badge { position: absolute; top: 0; left: 58%; margin: 0; min-width: 16px; padding: 1px 5px;
    box-shadow: 0 0 0 2px var(--inv-surface); }
  /* Lift bottom-anchored chrome above the nav. */
  .ed-actions { bottom: calc(var(--books-navh) + env(safe-area-inset-bottom)); }
  .bulk-bar { bottom: calc(var(--books-navh) + 14px + env(safe-area-inset-bottom)); }
  #flash { bottom: calc(var(--books-navh) + 16px + env(safe-area-inset-bottom)); }
  /* The activity sheet sits above the nav (its own scrim covers it). */
  .books-bell-panel { z-index: 210; }
}

/* ── Light theme (books-bar toggle; pre-paint script sets the attr) ── */
:root[data-books-theme="light"] {
  --inv-bg: #f4f6fa; --inv-surface: #ffffff; --inv-card: #ffffff; --inv-card-hover: #eef2f7;
  --inv-text: #131722; --inv-text-2: #4a5568; --inv-muted: #8a94a4;
  --inv-border: #e4e9f1; --inv-border-2: #d5dce8;
  --inv-input-bg: #e9edf3; --inv-accent: #1493e6; --inv-accent-h: #0f76bf;
  --inv-link: #1493e6; --inv-link-h: #0f76bf; --inv-danger: #e23b3b;
  --inv-card-shadow: 0 2px 10px rgba(15,23,42,.07);
}
:root[data-books-theme="light"] .btn-ghost { background: #e2e8f0; }
:root[data-books-theme="light"] .btn-ghost:hover { background: #cbd5e1; }
:root[data-books-theme="light"] #flash { background: #0f172a; }
:root[data-books-theme="light"] .stat-ok .stat-val { color: #15803d; }
:root[data-books-theme="light"] .books-search-results { box-shadow: 0 10px 30px rgba(15,23,42,.18); }
/* The tinted banners carry dark-theme pastels — deepen them for light bg. */
:root[data-books-theme="light"] .sb-stripe { color: #4338ca; }
:root[data-books-theme="light"] .sb-xero { color: #0e7490; }
:root[data-books-theme="light"] .sb-stripe strong, :root[data-books-theme="light"] .sb-xero strong { color: #0f172a; }
:root[data-books-theme="light"] .sb-warn { color: #92400e; }
:root[data-books-theme="light"] .sb-ok, :root[data-books-theme="light"] .sb-chip,
:root[data-books-theme="light"] .sb-chip-body-inner { color: #15803d; }
:root[data-books-theme="light"] .warn { color: #92400e; }

/* ── Invoice status timeline (editor) ───────────────────────── */
.tl { display: flex; align-items: flex-start; margin: 0 0 16px; }
.tl-step { flex: 1; position: relative; text-align: center; font-size: 12px; }
.tl-step::before { content: ''; position: absolute; top: 6px; left: -50%; width: 100%; height: 2px; background: var(--inv-border-2); }
.tl-step:first-child::before { display: none; }
.tl-dot { position: relative; display: inline-block; width: 13px; height: 13px; border-radius: 50%; background: var(--inv-card); border: 2px solid var(--inv-border-2); z-index: 1; }
.tl-step.done .tl-dot { background: #22c55e; border-color: #22c55e; }
.tl-step.warn .tl-dot { background: #ef4444; border-color: #ef4444; }
.tl-step.done::before { background: #22c55e; }
.tl-step.warn::before { background: #ef4444; }
.tl-label { display: block; margin-top: 5px; font-weight: 600; color: var(--inv-text-2); }
.tl-step.done .tl-label { color: var(--inv-text); }
.tl-step.warn .tl-label { color: var(--inv-danger); }
.tl-date { display: block; color: var(--inv-muted); font-size: 11px; margin-top: 1px; }

/* ── Line-item drag reorder ─────────────────────────────────── */
.dragcell { width: 22px; }
.draghandle { cursor: grab; color: var(--inv-muted); font-size: 13px; letter-spacing: -1px; user-select: none; }
.draghandle:hover { color: var(--inv-text-2); }
tr.drag-over td { border-top: 2px solid var(--inv-accent); }

/* ── List toolbar extras (sort + date range) ────────────────── */
.list-actions select.inv-search, .list-actions input[type="date"].inv-search { width: auto; }

/* ── First-run checklist (Overview) ─────────────────────────── */
.ck-list { display: flex; flex-direction: column; gap: 8px; }
.ck-item { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--inv-text-2); }
.ck-item i { font-size: 16px; }
.ck-item.done { color: var(--inv-muted); text-decoration: line-through; }
.ck-item.done i { color: #22c55e; }
.ck-item a { color: var(--inv-link); text-decoration: none; font-weight: 600; }
.ck-item a:hover { color: var(--inv-link-h); }

/* Clickable Overview rows (aging buckets / top customers). */
a.ov-row { text-decoration: none; color: inherit; border-radius: 6px; }
a.ov-row:hover { background: var(--inv-card-hover); }

/* ── Overview tab ────────────────────────────────────────────── */
.ov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.ov-card { background: var(--inv-card); border-radius: 12px; box-shadow: var(--inv-card-shadow); padding: 18px 20px; animation: inv-fade-up .5s ease both; }
.ov-wide { grid-column: 1 / -1; }
.ov-title { font-size: 12px; font-weight: 600; color: var(--inv-text-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 12px; }
.ov-big { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 10px; }
.ov-sub { font-size: 13px; font-weight: 500; color: var(--inv-muted); }
.ov-line { font-size: 13px; color: var(--inv-text-2); margin-top: 4px; }
.ov-empty { font-size: 13px; color: var(--inv-muted); padding: 8px 0; }
.ov-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.ov-row-label { flex: 0 0 116px; color: var(--inv-text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-bar { flex: 1; height: 8px; background: var(--inv-input-bg); border-radius: 4px; overflow: hidden; }
.ov-bar-fill { display: block; height: 100%; border-radius: 4px; }
.ov-row-val { flex: 0 0 auto; min-width: 62px; text-align: right; font-weight: 600; color: var(--inv-text); }
.ov-table { width: 100%; border-collapse: collapse; }
.ov-table th { text-align: left; font-size: 12px; color: var(--inv-muted); font-weight: 600; padding: 4px 12px 6px 0; border-bottom: 1px solid var(--inv-border); }
.ov-table td { font-size: 13px; color: var(--inv-text-2); padding: 6px 12px 6px 0; border-bottom: 1px solid var(--inv-border); }
.ov-table tr:last-child td { border-bottom: 0; }
/* Accrual/Cash basis toggle on the GST summary card. */
.ov-seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--inv-input-bg); border-radius: 8px; }
.ov-seg-btn { font-size: 12px; font-weight: 600; color: var(--inv-text-2); background: transparent; border: 0; border-radius: 6px; padding: 4px 12px; cursor: pointer; }
.ov-seg-btn.is-on { background: var(--inv-card); color: var(--inv-text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ── AI insights card ────────────────────────────────────────── */
.ov-ai { position: relative; overflow: hidden; }
.ov-ai::before { content: ''; position: absolute; inset: 0; padding: 1px; border-radius: 12px; pointer-events: none;
  background: linear-gradient(120deg, #6366f1, #06b6d4 55%, #22c55e);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: .45; }
.ov-ai .ov-title { display: flex; align-items: center; gap: 6px; }
.ov-ai .ov-title i.ti-sparkles { color: #6366f1; font-size: 14px; text-transform: none; }
.ov-ai-refresh { margin-left: auto; background: transparent; border: 0; color: var(--inv-muted); cursor: pointer; padding: 2px 6px; border-radius: 6px; line-height: 1; }
.ov-ai-refresh:hover { color: var(--inv-text); background: var(--inv-input-bg); }
.ov-ai-body { display: flex; flex-direction: column; gap: 8px; }
.ov-ai-item { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; line-height: 1.45; color: var(--inv-text); }
.ov-ai-item i { flex: 0 0 auto; margin-top: 2px; font-size: 15px; color: var(--inv-muted); }
.ov-ai-item.good i { color: #22c55e; }
.ov-ai-item.warn i { color: #f59e0b; }
.ov-ai-item.info i { color: #1493e6; }
.ov-ai-loading { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--inv-muted); }
.ov-ai-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .35; animation: ov-ai-bounce 1.1s infinite ease-in-out; }
.ov-ai-dot:nth-child(2) { animation-delay: .16s; } .ov-ai-dot:nth-child(3) { animation-delay: .32s; }
@keyframes ov-ai-bounce { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: .9; transform: translateY(-3px); } }
.ov-ai-err { font-size: 13px; color: var(--inv-text-2); display: flex; align-items: center; gap: 6px; }
.ov-linklike { background: none; border: 0; color: var(--inv-link); cursor: pointer; padding: 0; font: inherit; text-decoration: underline; }
@media (prefers-reduced-motion: reduce) { .ov-ai-dot { animation: none; } }

/* ── AI modal (books-fx promptBox / resultBox) ───────────────── */
.bfx-back { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); animation: bfx-fade .18s ease both; }
.bfx-modal { width: 100%; max-width: 520px; background: var(--inv-card); color: var(--inv-text); border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35); padding: 20px; animation: bfx-pop .2s cubic-bezier(.2, .9, .3, 1.2) both;
  border: 1px solid var(--inv-border); }
.bfx-title { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; margin-bottom: 6px; }
.bfx-title i.ti-sparkles { color: #6366f1; }
.bfx-hint { font-size: 13px; color: var(--inv-muted); margin-bottom: 12px; line-height: 1.45; }
.bfx-ta { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; font-size: 14px; line-height: 1.5;
  background: var(--inv-input-bg); color: var(--inv-text); border: 1px solid var(--inv-border); border-radius: 9px; padding: 10px 12px; }
.bfx-ta:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, .18); }
.bfx-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.bfx-ghost, .bfx-primary { font: inherit; font-size: 14px; font-weight: 600; border-radius: 9px; padding: 9px 16px; cursor: pointer; border: 1px solid transparent; display: inline-flex; align-items: center; gap: 6px; }
.bfx-ghost { background: transparent; color: var(--inv-text-2); border-color: var(--inv-border); }
.bfx-ghost:hover { background: var(--inv-input-bg); }
.bfx-primary { background: linear-gradient(120deg, #6366f1, #4f46e5); color: #fff; }
.bfx-primary:hover { filter: brightness(1.06); }
.bfx-primary:disabled, .bfx-ghost:disabled { opacity: .6; cursor: default; }
@keyframes bfx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bfx-pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .bfx-back, .bfx-modal { animation: none; } }
/* Sparkle accent on AI affordances */
.ai-link, .ai-btn { display: inline-flex; align-items: center; gap: 5px; }
.ai-link i.ti-sparkles, .ai-btn i.ti-sparkles { color: #6366f1; }

/* ── Customers view ──────────────────────────────────────────── */
.cust-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.cust-card { background: var(--inv-card); border-radius: 12px; box-shadow: var(--inv-card-shadow); padding: 16px 18px; animation: inv-fade-up .5s ease both; }
.cust-head { display: flex; align-items: flex-start; gap: 8px; }
.cust-head > div { flex: 1; min-width: 0; }
.cust-name { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.cust-meta { font-size: 12px; color: var(--inv-muted); margin-top: 3px; overflow-wrap: anywhere; }
.cust-meta i { font-size: 11px; margin-right: 3px; }
.cust-notes { font-style: italic; }
.cust-empty { grid-column: 1 / -1; text-align: center; padding: 40px 16px; color: var(--inv-muted); font-size: 13px; }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 7px; }

/* Whole-card click opens the activity/edit modal. */
.cust-card.is-click { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease; border: 1px solid transparent; }
.cust-card.is-click:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.32); border-color: var(--inv-border-2); }
.cust-card.is-click:focus-visible { outline: 2px solid var(--inv-accent); outline-offset: 2px; }
.cust-unsaved { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--inv-muted); background: var(--inv-input-bg); border: 1px solid var(--inv-border-2); border-radius: 999px; padding: 1px 7px; vertical-align: 2px; margin-left: 4px; }

/* Money line — outstanding balance leads (the reason to open this page). */
.cust-money { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; }
.cust-owing { font-weight: 700; font-size: 15px; color: #fbbf24; }
.cust-clear { font-weight: 600; color: #4ade80; }
.cust-none { color: var(--inv-muted); }
.cust-last { color: var(--inv-muted); font-size: 12px; }

/* Fixed metric chip strip — same four on every card so heights match. */
.cust-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cchip { font-size: 12px; color: var(--inv-text-2); background: var(--inv-input-bg); border: 1px solid var(--inv-border); border-radius: 7px; padding: 3px 8px; white-space: nowrap; }
.cchip em { font-style: normal; color: #4ade80; }
.cchip.is-zero { color: var(--inv-muted); opacity: .5; }

/* ── Price catalog (catalog.html) ───────────────────────────── */
.cat-intro { color: var(--inv-muted); font-size: 13px; margin: -4px 0 14px; max-width: 620px; }
.cat-cats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.cat-chip { background: var(--inv-card); color: var(--inv-text-2); border: 1px solid var(--inv-border); border-radius: 999px; padding: 6px 13px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .12s ease, border-color .12s ease, color .12s ease; }
.cat-chip:hover { border-color: var(--inv-border-2); }
.cat-chip.is-active { background: var(--inv-accent); border-color: var(--inv-accent); color: #fff; }
.cat-chip-n { opacity: .6; font-weight: 500; margin-left: 3px; }
.cat-chip.is-active .cat-chip-n { opacity: .85; }
.cat-card .cat-price { text-align: right; font-weight: 700; font-size: 15px; white-space: nowrap; }
.cat-card .cat-unit { display: block; font-size: 11px; font-weight: 500; color: var(--inv-muted); }
.cat-shared { color: var(--inv-accent); }
.cat-shared i { font-size: 11px; }
.cat-share { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; cursor: pointer; }
.cat-share input { margin-top: 2px; }
.cat-share .hint { display: block; }

/* Catalog picker overlay (quote editor → "From catalog") */
.cat-picker { max-width: 520px; display: flex; flex-direction: column; }
.cat-picker .cat-cats { margin: 12px 0; }
.cat-picker-list { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 46vh; margin: 0 -4px; padding: 0 4px; }
.cat-pick-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; text-align: left; background: var(--inv-card); border: 1px solid var(--inv-border); border-radius: 9px; padding: 11px 13px; cursor: pointer; color: var(--inv-text); transition: background .12s ease, border-color .12s ease; }
.cat-pick-row:hover, .cat-pick-row:focus-visible { background: var(--inv-card-hover); border-color: var(--inv-border-2); outline: none; }
.cat-pick-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.cat-pick-name { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.cat-pick-meta { font-size: 11px; color: var(--inv-muted); overflow-wrap: anywhere; }
.cat-pick-price { font-weight: 700; font-size: 14px; white-space: nowrap; text-align: right; }
.cat-pick-price .cat-unit { display: block; font-size: 11px; font-weight: 500; color: var(--inv-muted); }

/* Per-line "save to catalog" action in the quote editor */
.it-actions { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.it-save { background: none; border: 0; color: var(--inv-muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 4px; border-radius: 6px; transition: color .12s ease, background .12s ease; }
.it-save:hover { color: var(--inv-accent); background: var(--inv-card-hover); }

/* Site / scope photos (on-site quoting) */
.scope-photos { margin-top: 8px; }
.scope-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.scope-thumb { position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; border: 1px solid var(--inv-border); }
.scope-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scope-del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border: 0; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.scope-del:hover { background: #dc2626; }
.scope-add { width: 96px; height: 96px; border: 1.5px dashed var(--inv-border-2); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; color: var(--inv-muted); font-size: 12px; transition: border-color .12s ease, color .12s ease; }
.scope-add:hover { border-color: var(--inv-accent); color: var(--inv-accent); }
.scope-add i { font-size: 22px; }

/* Customer modal (add/edit + equipment + job history) */
.bk-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 16px; animation: inv-fade-in .15s ease; }
.bk-modal { background: var(--inv-surface); border: 1px solid var(--inv-border-2); border-radius: 14px; padding: 22px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; }
.bk-modal h3 { margin: 0 0 14px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.bk-modal h3 i { color: var(--inv-accent); }
.bk-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bk-span2 { grid-column: 1 / -1; }
.bk-modal .lbl { margin: 0 0 4px; display: block; }
.bk-sec { border-top: 1px solid var(--inv-border); margin-top: 16px; padding-top: 12px; }
.bk-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.bk-sec-head .lbl { margin: 0; }
.bk-items { display: flex; flex-direction: column; gap: 6px; }
.bk-item { display: flex; align-items: flex-start; gap: 6px; border: 1px solid var(--inv-border); border-radius: 8px; padding: 8px 10px; }
.bk-item > div { flex: 1; min-width: 0; }
.bk-item-title { font-size: 13px; font-weight: 600; }
.bk-item-meta { font-size: 11px; color: var(--inv-muted); margin-top: 2px; }
.equip-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.equip-thumb { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 1px solid var(--inv-border); display: block; cursor: zoom-in; }
.bk-subform { display: none; margin-top: 10px; border: 1px solid var(--inv-border); border-radius: 8px; padding: 10px; }
.bk-subform-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bk-subform-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.bk-modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 18px; }
.bk-modal-actions .bk-right { display: flex; gap: 8px; margin-left: auto; }

/* ── Motion ─────────────────────────────────────────────────── */
@keyframes inv-fade-up { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes inv-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Summary stat cards stagger in on load/filter. */
.inv-summary .stat { animation: inv-fade-up .6s ease both; }
.inv-summary .stat:nth-child(2) { animation-delay: .1s; }
.inv-summary .stat:nth-child(3) { animation-delay: .2s; }
.inv-summary .stat:nth-child(4) { animation-delay: .3s; }

/* Settings panel + the editor's blocks ease in when rendered. */
.settings-card { animation: inv-fade-up .5s ease both; }
.ed-from       { animation: inv-fade-up .5s ease both; }
.ed-grid       { animation: inv-fade-up .55s ease both; animation-delay: .1s; }
table.ed-items { animation: inv-fade-up .6s ease both;  animation-delay: .2s; }
.ed-totals     { animation: inv-fade-up .65s ease both; animation-delay: .3s; }

/* Flash toast lifts as it fades in. */
#flash { transition: opacity .3s ease, transform .3s ease; }
#flash.show { transform: translateX(-50%) translateY(-6px); }

/* ── Mobile editor (≤560px) — field use on a phone ────────────────
   The line-items table overflows a phone (6 cols + inputs). Below this
   breakpoint each row becomes a stacked card, the customer/dates grid goes
   single-column, and the action bar sticks to the bottom so Finalize/Save is
   always one tap away instead of buried under the items. */
@media (max-width: 560px) {
  .ed-grid { grid-template-columns: 1fr; gap: 12px; padding: 16px; }

  /* Table → card list: hide the header, block-ify, one card per row. */
  table.ed-items { display: block; background: transparent; box-shadow: none; border-radius: 0; }
  table.ed-items thead { display: none; }
  table.ed-items tbody { display: block; }
  table.ed-items tr { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    background: var(--inv-card); border: 1px solid var(--inv-border); border-radius: 10px;
    padding: 12px; margin-bottom: 10px; box-shadow: var(--inv-card-shadow); }
  table.ed-items td { display: flex; align-items: center; gap: 6px; padding: 0; border: 0; font-size: 13px; }
  table.ed-items td.dragcell { display: none; }         /* reorder is a desktop affordance */
  table.ed-items td.it-desc { flex: 1 1 100%; }
  table.ed-items td.it-desc input { width: 100%; }
  table.ed-items td[data-label]::before { content: attr(data-label); color: var(--inv-muted); font-size: 11px; white-space: nowrap; }
  table.ed-items input.w-qty, table.ed-items input.w-unit { width: 64px; }
  table.ed-items input.w-price { width: 96px; }
  /* Comfortable touch targets for on-site quoting. */
  table.ed-items input { min-height: 42px; font-size: 16px; }  /* 16px avoids iOS zoom-on-focus */
  table.ed-items td.num { margin-left: auto; font-weight: 700; font-size: 15px; }
  table.ed-items td.it-actions { margin-left: 4px; gap: 2px; }
  table.ed-items td.it-actions .x { font-size: 26px; padding: 4px 6px; }
  table.ed-items td.it-actions .it-save { font-size: 20px; padding: 6px; }

  /* Line-item action row — make "From catalog" the obvious on-site path. */
  .items-head span { gap: 10px 14px; }
  .items-head .link { padding: 8px 4px; font-size: 14px; }

  /* Sticky action bar — full-bleed footer, primary action always reachable. */
  .ed-actions { position: sticky; bottom: 0; margin: 20px -16px 0; padding: 12px 16px;
    background: var(--inv-bg); border-top: 1px solid var(--inv-border); box-shadow: 0 -4px 16px rgba(0,0,0,.28); z-index: 20; }
  .ed-actions .btn-primary, .ed-actions .btn-ghost, .ed-actions .btn-danger-ghost { flex: 1 1 auto; text-align: center; }
  .ed-payments { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
