/* Direction: Billcraft — crisp white-lavender canvas, rich indigo accent, lime highlight for paid moments, Plus Jakarta Sans throughout */
/* Completed by the platform from the short form: both modes, every
   palette token, each text-on-ground pair at its floor. To restyle, write the
   short form again (the decisions in one :root) and it is completed again. */

:root {
  --canvas: #f8f8fd;
  --surface: #ffffff;
  --surface-2: #ececf2;
  --border: #e2e1f1;
  --border-strong: #b1b1bb;
  --ink: #17162e;
  --muted: #5a5a78;
  --accent: #4f46e5;
  --accent-hover: #433cc3;
  --accent-ink: #ffffff;
  --accent-text: #4338ca;
  --accent-strong: #4f46e5;
  --accent-soft: #e0dffa;
  --accent-border: #aca8f2;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #ddeae6;
  --success-strong: #137638;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #f0e4e0;
  --warning-strong: #a64c08;
  --danger: #b91c1c;
  --danger-ink: #ffffff;
  --danger-soft: #f0dee2;
  --danger-strong: #b91c1c;
  --chart-1: #4f46e5;
  --chart-2: #ce31b1;
  --chart-3: #8c2906;
  --chart-4: #8e7a06;
  --chart-5: #015d36;
  --chart-6: #198ba4;

  --font-display: "Plus Jakarta Sans", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", system-ui, sans-serif;
  --display-weight: 800;
  --display-tracking: -0.03em;
  --radius-card: 16px;
  --radius-btn: 10px;
  --radius-input: 10px;
  --shadow-card: 0 1px 2px rgba(23, 22, 46, 0.05), 0 4px 16px rgba(79, 70, 229, 0.04);
  --x-lime: #c8f53c;
  --x-on-lime: #1c2d04;
  --x-lavender: #eeecfd;
  --x-dark: #14122e;
  --x-on-dark: #ffffff;
  --x-on-dark-muted: #b9b7d8;
  --x-paper: #ffffff;
  --x-paper-ink: #1b1a33;
  --x-paper-muted: #5f5e7c;
  --x-paper-line: #e2e1f1;
  --x-paper-tint: #f3f2fd;
  --x-paper-accent: #4f46e5;
  --font-mono: "JetBrains Mono Variable", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans: "Plus Jakarta Sans", system-ui, sans-serif;
  --eyebrow-tracking: 0.08em;
}

html[data-theme="dark"] {
  --canvas: #080817;
  --surface: #21212e;
  --surface-2: #141423;
  --border: #2b2b37;
  --border-strong: #52525d;
  --ink: #f8f8fd;
  --muted: #9898a1;
  --accent: #4f46e5;
  --accent-hover: #6962e9;
  --accent-ink: #ffffff;
  --accent-text: #817bed;
  --accent-strong: #817bed;
  --accent-soft: #181644;
  --accent-border: #282474;
  --success: #15803d;
  --success-ink: #ffffff;
  --success-soft: #0b221f;
  --success-strong: #499c68;
  --warning: #b45309;
  --warning-ink: #ffffff;
  --warning-soft: #2e1914;
  --warning-strong: #c57a40;
  --danger: #b91c1c;
  --danger-ink: #ffffff;
  --danger-soft: #2f0c18;
  --danger-strong: #d16969;
  --chart-1: #5954f3;
  --chart-2: #dc41bd;
  --chart-3: #db450e;
  --chart-4: #9c8600;
  --chart-5: #0f985d;
  --chart-6: #1799b4;
}

/* ==========================================================================
   Billcraft — app styles (loaded after the design layer, so these win)
   ========================================================================== */
html { scroll-behavior: smooth; }
html.reduced-motion { scroll-behavior: auto; }
svg.icon { width: 1.125rem; height: 1.125rem; stroke-width: 1.75; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 24%, transparent); }
a { text-underline-offset: 3px; }
.nw { white-space: nowrap; }
.pre { white-space: pre-line; }
.trunc { display: block; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trunc-cell { max-width: 16rem; }

/* App shell: ONE navigation at any width ---------------------------------- */
.app-shell { min-height: 100vh; }
.mbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .625rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.side { position: fixed; inset: 0 auto 0 0; z-index: 50; display: flex; flex-direction: column; width: 18rem; max-width: 86vw; padding: 1.25rem 1rem; overflow: hidden; background: var(--surface); border-right: 1px solid var(--border); transform: translateX(-100%); transition: transform .2s ease; }
.nav-open .side { transform: none; }
.nav-backdrop { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); }
.nav-open .nav-backdrop { display: block; }
html.reduced-motion .side { transition: none; }
@media (min-width: 1024px) {
  .app-shell { display: grid; grid-template-columns: 17rem minmax(0, 1fr); align-items: start; }
  .mbar, .side-close { display: none; }
  .side { position: sticky; top: 0; z-index: auto; width: auto; max-width: none; height: 100vh; height: 100dvh; transform: none; }
  body:has(.demo-bar) .side { height: calc(100dvh - 2.5rem); }
  .nav-backdrop, .nav-open .nav-backdrop { display: none; }
}
.side-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-bottom: 1rem; }
.side-link { display: flex; align-items: center; gap: .75rem; padding: .625rem .75rem; border-radius: var(--radius-btn); font-size: .875rem; font-weight: 500; color: var(--muted); transition: background .15s, color .15s; }
.side-link:hover { background: var(--surface-2); color: var(--ink); }
.side-link.is-active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.side-link.is-active:hover { background: var(--accent-hover); color: var(--accent-ink); }
.demo-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .25rem 1rem; padding: .5rem 1rem; background: var(--x-dark); color: var(--x-on-dark); font-size: .8125rem; font-weight: 500; text-align: center; }
.demo-bar a { color: var(--x-lime); }

/* Panels, headings, forms -------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 1.25rem; min-width: 0; }
@media (min-width: 640px) { .panel { padding: 1.5rem; } }
.panel-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; min-height: 2rem; }
.sec-title { font-family: var(--font-display); font-size: 1.125rem; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; }
.fld { display: flex; flex-direction: column; gap: .375rem; min-width: 0; }
.fld .label { font-size: .8125rem; font-weight: 600; margin: 0; }
.fld textarea { resize: vertical; min-height: 2.75rem; }
.fld .hint { margin: 0; font-size: .8125rem; }
.fld-err { margin: 0; font-size: .8125rem; color: var(--danger-strong); }
.fld [aria-invalid="true"] { border-color: var(--danger); }
dialog.modal { width: min(36rem, calc(100vw - 2rem)); max-width: 100%; }
.modal-in { width: 100%; }
.notice { display: flex; align-items: flex-start; gap: .75rem; padding: 1rem 1.25rem; border: 1px solid var(--accent-border); border-radius: var(--radius-card); background: var(--accent-soft); color: var(--accent-strong); font-size: .875rem; }
.notice .icon { margin-top: .125rem; }
.notice p { margin: 0; color: var(--ink); }
.or-rule { display: flex; align-items: center; gap: 1rem; margin: 1.5rem 0; color: var(--muted); font-size: .8125rem; }
.or-rule::before, .or-rule::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.drop { display: flex; align-items: center; gap: 1rem; padding: 1rem; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-card); background: var(--surface-2); transition: border-color .15s, background .15s; }
.drop.is-over, .drop:focus-within { border-color: var(--accent); background: var(--accent-soft); }
.drop-prev { display: grid; place-items: center; width: 3.5rem; height: 3.5rem; flex-shrink: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--muted); }
.drop-prev img { width: 100%; height: 100%; object-fit: contain; }
.drop-name { margin: .375rem 0 0; overflow: hidden; font-size: .8125rem; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }

.switch-row { display: flex; align-items: flex-start; gap: 1rem; cursor: pointer; }
.switch { position: relative; flex-shrink: 0; width: 2.75rem; height: 1.5rem; }
.switch input[type="checkbox"] { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch-ui { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background .15s; }
.switch-ui::after { content: ""; position: absolute; top: .1875rem; left: .1875rem; width: 1.125rem; height: 1.125rem; border-radius: 50%; background: var(--accent-ink); transition: transform .15s; }
.switch input:checked ~ .switch-ui { background: var(--accent); }
.switch input:checked ~ .switch-ui::after { transform: translateX(1.25rem); }
.switch input:focus-visible ~ .switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }

.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 1.25rem; min-width: 0; transition: transform .15s; }
.kpi:hover { transform: translateY(-2px); }
.kpi-l { font-size: .8125rem; font-weight: 600; color: var(--muted); }
.kpi-v { margin-top: .375rem; font-family: var(--font-display); font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; color: var(--accent-text); }
.kpi-s { margin-top: .25rem; font-size: .8125rem; color: var(--muted); }
.kpi.is-danger .kpi-v { color: var(--danger-strong); }
.kpi-ic { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex-shrink: 0; border-radius: 10px; background: var(--accent-soft); color: var(--accent-strong); }
.kpi-ic.is-lime { background: var(--x-lime); color: var(--x-on-lime); }
.kpi-ic.is-danger { background: var(--danger-soft); color: var(--danger-strong); }

.fchip { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .8rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: .8125rem; font-weight: 500; color: var(--muted); transition: background .15s, color .15s, border-color .15s; }
.fchip span { font-size: .75rem; opacity: .8; }
.fchip:hover { color: var(--ink); border-color: var(--border-strong); }
.fchip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.empty-box { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: 3rem 1.5rem; text-align: center; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-card); }
.empty-ic { display: grid; place-items: center; width: 3rem; height: 3rem; margin-bottom: .25rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); }
.empty-ic svg.icon { width: 1.375rem; height: 1.375rem; }

.plist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.plist li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--border); }
.plist li:first-child { padding-top: 0; }
.plist li:last-child { padding-bottom: 0; border-bottom: 0; }
.kv { margin: 0; display: flex; flex-direction: column; gap: .625rem; font-size: .875rem; }
.kv > div { display: flex; justify-content: space-between; gap: 1rem; }
.kv dt { color: var(--muted); flex-shrink: 0; }
.kv dd { margin: 0; text-align: right; font-weight: 500; min-width: 0; overflow-wrap: break-word; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1.25rem; }
.kv-grid > div { display: block; min-width: 0; }
.kv-grid dd { text-align: left; margin-top: .125rem; }

/* Dropdown menu ------------------------------------------------------------ */
.dd { position: relative; display: inline-block; }
.dd > summary { list-style: none; cursor: pointer; }
.dd > summary::-webkit-details-marker { display: none; }
.dd-menu { position: absolute; left: 0; top: calc(100% + .375rem); z-index: 30; min-width: 13rem; max-width: calc(100vw - 2rem); padding: .375rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px -8px rgba(20, 18, 46, .28); }
.dd-menu.is-right { left: auto; right: 0; }
.dd-menu form { margin: 0; }
.dd-item { display: flex; align-items: center; gap: .625rem; width: 100%; padding: .55rem .75rem; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; font-size: .875rem; font-weight: 500; text-align: left; cursor: pointer; }
.dd-item:hover { background: var(--surface-2); }
.dd-item.is-danger { color: var(--danger-strong); }

/* Tables ------------------------------------------------------------------- */
.tbl-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .875rem; }
.tbl th { padding: .75rem; text-align: left; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: .875rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th:first-child, .tbl td:first-child { padding-left: 1rem; }
.tbl th:last-child, .tbl td:last-child { padding-right: 1rem; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--accent-soft); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl .row-total td { font-weight: 700; background: var(--surface-2); }
.m-only { display: none; }
@media (min-width: 900px) and (max-width: 1279px) { .col-xl { display: none; } }
@media (min-width: 1100px) and (max-width: 1399px) { .tbl-doc .col-wide { display: none; } }

/* Dashboard "Needs attention": five columns, client takes the slack and is cut with an ellipsis */
@media (min-width: 900px) {
  .tbl-att { table-layout: auto; }
  .tbl-att th, .tbl-att td { padding-left: .5rem; padding-right: .5rem; }
  .tbl-att th:first-child, .tbl-att td:first-child { padding-left: 1rem; }
  .tbl-att th:last-child, .tbl-att td:last-child { padding-right: 1.25rem; }
  .tbl-att th.c-client, .tbl-att td.c-client { width: 100%; max-width: 0; }
}

/* Generic tables become cards on small screens */
@media (max-width: 899px) {
  .tbl:not(.tbl-doc) thead { display: none; }
  .tbl:not(.tbl-doc), .tbl:not(.tbl-doc) tbody, .tbl:not(.tbl-doc) tr, .tbl:not(.tbl-doc) td { display: block; width: 100%; }
  .tbl:not(.tbl-doc) tr { padding: .875rem 1rem; border-bottom: 1px solid var(--border); }
  .tbl:not(.tbl-doc) tbody tr:last-child { border-bottom: 0; }
  .tbl:not(.tbl-doc) td { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .25rem 0 !important; border: 0; text-align: right; }
  .tbl:not(.tbl-doc) td::before { content: attr(data-label); flex-shrink: 0; font-size: .75rem; font-weight: 600; color: var(--muted); text-align: left; }
  .tbl:not(.tbl-doc) td[data-label=""]::before { content: none; }
  .tbl:not(.tbl-doc) td.cell-main { display: block; padding-bottom: .5rem !important; text-align: left; font-size: 1rem; }
  .tbl:not(.tbl-doc) td.num { white-space: normal; }
  .tbl:not(.tbl-doc) .trunc-cell { max-width: none; }
}
/* Invoice/quote rows: two compact lines (number + client / amount + status + due) */
@media (max-width: 1099px) {
  .tbl-doc thead { display: none; }
  .tbl-doc, .tbl-doc tbody { display: block; width: 100%; }
  .tbl-doc tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .375rem .75rem; padding: .875rem 1rem; border-bottom: 1px solid var(--border); }
  .tbl-doc tbody tr:last-child { border-bottom: 0; }
  .tbl-doc td { display: block; min-width: 0; padding: 0 !important; border: 0; }
  .tbl-doc td::before { content: none; }
  .tbl-doc .c-iss, .tbl-doc .c-bal { display: none; }
  .tbl-doc .c-num { grid-row: 1; grid-column: 1; font-weight: 600; }
  .tbl-doc .c-client { grid-row: 1; grid-column: 2 / -1; overflow: hidden; text-align: right; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
  .tbl-doc .c-total { grid-row: 2; grid-column: 1; text-align: left; font-weight: 600; }
  .tbl-doc .c-status { grid-row: 2; grid-column: 2; justify-self: start; }
  .tbl-doc .c-due { grid-row: 2; grid-column: 3; text-align: right; font-size: .8125rem; color: var(--muted); }
  .tbl-doc .m-only { display: inline; }
}

/* Pagination --------------------------------------------------------------- */
.pager { display: flex; flex-direction: column; gap: .75rem; margin-top: 1rem; font-size: .875rem; }
@media (min-width: 640px) { .pager { flex-direction: row; align-items: center; justify-content: space-between; } }
.pager-info { margin: 0; color: var(--muted); }
.pager-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.25rem; }
.pager-per { display: flex; align-items: center; gap: .5rem; color: var(--muted); }
.pager-per .select { width: auto; min-width: 4.5rem; }
.pager-nav { display: flex; align-items: center; gap: .5rem; }
.pager-page { min-width: 6rem; text-align: center; color: var(--muted); }
.pg { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; border: 1px solid var(--border); border-radius: var(--radius-btn); background: var(--surface); color: var(--ink); transition: border-color .15s, color .15s; }
a.pg:hover { border-color: var(--accent); color: var(--accent-text); }
.pg.is-off { opacity: .4; }

/* Skeleton loaders (htmx adds .htmx-request while a request is in flight) --- */
.sk-wrap .sk { display: none; }
.sk-wrap.htmx-request .sk { display: block; }
.sk-wrap.htmx-request .sk-real { display: none; }
.sk-bar, .sk-bars i { display: block; height: .75rem; border-radius: 999px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: sk-shimmer 1.2s linear infinite; }
.sk-row { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1rem; border-bottom: 1px solid var(--border); }
.sk-row:last-child { border-bottom: 0; }
.sk-bars { display: grid; gap: .75rem; }
.sk-bars i:nth-child(odd) { width: 100%; }
.sk-bars i:nth-child(even) { width: 78%; }
.sk-bars i:nth-child(3n) { width: 55%; }
@keyframes sk-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
html.reduced-motion .sk-bar, html.reduced-motion .sk-bars i { animation: none; }
/* A panel whose action is in flight: its content is replaced by grey shapes */
.panel.htmx-request { position: relative; pointer-events: none; }
.panel.htmx-request > * { visibility: hidden; }
.panel.htmx-request::after { content: ""; position: absolute; inset: 1.5rem; border-radius: 8px;
  background:
    linear-gradient(var(--surface-2), var(--surface-2)) 0 0 / 42% 1.25rem no-repeat,
    linear-gradient(var(--surface-2), var(--surface-2)) 0 2.5rem / 100% .875rem no-repeat,
    linear-gradient(var(--surface-2), var(--surface-2)) 0 4.25rem / 82% .875rem no-repeat,
    linear-gradient(var(--surface-2), var(--surface-2)) 0 6rem / 64% .875rem no-repeat;
  animation: sk-pulse 1.1s ease-in-out infinite alternate; }
@keyframes sk-pulse { from { opacity: .55; } to { opacity: 1; } }
html.reduced-motion .panel.htmx-request::after { animation: none; }

/* Status badges ------------------------------------------------------------ */
.st { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .625rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: .75rem; font-weight: 600; line-height: 1.4; white-space: nowrap; }
.st::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--muted); }
.st-partial::before { background: var(--warning); }
.st-overdue::before, .st-declined::before { background: var(--danger); }
.st-sent { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-border); }
.st-sent::before { background: var(--accent); }
.st-paid, .st-accepted { background: var(--x-lime); color: var(--x-on-lime); border-color: transparent; }
.st-paid::before, .st-accepted::before { background: var(--x-on-lime); }

/* Chart -------------------------------------------------------------------- */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .75rem; align-items: stretch; height: 12.5rem; }
.bar { display: flex; flex-direction: column; align-items: center; gap: .375rem; min-width: 0; }
.bar b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .6875rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.bar span { font-size: .75rem; color: var(--muted); }
.bar-track { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar-track i { display: block; width: 100%; max-width: 3rem; background: var(--accent); border-radius: 6px 6px 0 0; transform-origin: bottom; animation: bar-grow .5s ease-out both; }
@keyframes bar-grow { from { transform: scaleY(.15); } to { transform: scaleY(1); } }
html.reduced-motion .bar-track i { animation: none; }

/* Reports toolbar ---------------------------------------------------------- */
.rp-bar { display: flex; flex-direction: column; align-items: stretch; gap: .75rem; margin-bottom: 1.5rem; }
.rp-form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.rp-form .input, .rp-form .select { width: auto; flex: 1 1 9.5rem; min-width: 0; }
.rp-form .rp-cur { flex: 0 1 6rem; }
.rp-form .btn { flex-shrink: 0; }
.rp-presets { display: flex; flex-wrap: wrap; gap: .5rem; }
.rp-presets .fchip { white-space: nowrap; }
@media (min-width: 768px) {
  .rp-form { flex-wrap: nowrap; }
  .rp-form .input { flex: 0 1 11rem; }
  .rp-form .rp-cur { flex: 0 0 6.5rem; }
}
.amt-s { display: none; font-style: normal; }
.amt-f { font-style: normal; }
@media (max-width: 767px) { .amt-f { display: none; } .amt-s { display: inline; } .bars { gap: .375rem; } }

/* Search field with the icon inside ----------------------------------------- */
.sf { position: relative; width: 100%; }
.sf > svg.icon { position: absolute; left: .875rem; top: 50%; transform: translateY(-50%); width: 1rem; height: 1rem; color: var(--muted); pointer-events: none; }
.sf .input { width: 100%; padding-left: 2.5rem; text-overflow: ellipsis; }
.rp-to { color: var(--muted); font-size: .875rem; }

/* Line-item editor --------------------------------------------------------- */
.li { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; padding: 1rem; margin-bottom: .75rem; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface-2); }
.li .c-name, .li .c-desc { grid-column: 1 / -1; }
.li .c-del { justify-self: end; align-self: end; }
.li-l { display: block; margin-bottom: .25rem; font-size: .75rem; font-weight: 600; color: var(--muted); }
.li textarea { min-height: 2.75rem; resize: vertical; }
.li-amt { display: block; padding: .625rem 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.li-head { display: none; }
@media (min-width: 1024px) {
  .li, .li-head { grid-template-columns: minmax(0, 2fr) minmax(0, 2.4fr) 4.5rem 6.5rem 4.5rem 9.5rem 6.5rem 2.5rem; gap: .75rem; }
  .li { align-items: start; margin: 0; padding: .75rem 0; border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: transparent; }
  .li-head { display: grid; padding: 0 0 .625rem; font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .li .c-name, .li .c-desc { grid-column: auto; }
  .li .c-del { align-self: start; justify-self: stretch; }
  .li-l { display: none; }
  .li-amt { text-align: right; }
}
.totals { display: flex; flex-direction: column; gap: .5rem; font-size: .875rem; }
#tot-taxes { display: contents; }
.trow { display: flex; justify-content: space-between; gap: 1rem; }
.trow b { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.trow.grand { margin-top: .25rem; padding-top: .75rem; border-top: 1px solid var(--border); font-size: 1.0625rem; font-weight: 700; }
.trow.grand b { font-weight: 800; }

/* Invoice / quote page layout ---------------------------------------------- */
.actionbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1.5rem; padding: .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.doc-grid { display: grid; gap: 1.5rem; }
.doc-main { min-width: 0; }
.doc-side { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); align-content: start; }
@media (min-width: 1536px) {
  .doc-grid { grid-template-columns: minmax(0, 1fr) 22rem; align-items: start; }
  .doc-side { grid-template-columns: 1fr; }
}

/* The document paper (always white, in both colour modes) ------------------ */
.paper-stage { max-width: 56rem; margin: 0 auto; width: 100%; }
.paper { background: var(--x-paper); color: var(--x-paper-ink); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: 1.5rem; font-family: var(--font-body); font-size: .875rem; line-height: 1.55; }
@media (min-width: 640px) { .paper { padding: 2.25rem; } }
.paper p, .paper h2, .paper dl, .paper dd { margin: 0; }
.paper-head { display: flex; flex-direction: column; gap: 1.5rem; padding-bottom: 1.5rem; border-bottom: 2px solid var(--x-paper-accent); }
.paper-biz { display: flex; align-items: flex-start; gap: 1rem; min-width: 0; }
.paper-logo { height: 3.5rem; max-width: 9rem; object-fit: contain; }
.paper-name { font-family: var(--font-display); font-size: 1.125rem; font-weight: 800; }
.paper-small { font-size: .8125rem; color: var(--x-paper-muted); }
.paper-title h2 { font-family: var(--font-display); font-size: 1.75rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--x-paper-accent); line-height: 1.2; }
.paper-num { margin-bottom: .5rem !important; font-weight: 600; }
.paper-meta { display: grid; gap: 1.5rem; padding: 1.5rem 0; }
.paper-k { margin-bottom: .25rem !important; font-size: .6875rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--x-paper-muted); }
.paper-strong { font-size: 1rem; font-weight: 700; }
.paper-dl { display: grid; gap: .375rem; align-content: start; min-width: 0; }
.paper-dl > div { display: flex; justify-content: space-between; gap: 1rem; }
.paper-dl dt { color: var(--x-paper-muted); }
.paper-dl dd { font-weight: 600; text-align: right; white-space: nowrap; }
.paper-due { margin-top: .25rem; padding: .625rem .75rem; border-radius: 8px; background: var(--x-paper-tint); }
.paper-due dd { font-size: 1.0625rem; font-weight: 800; }
.paper-table { width: 100%; border-collapse: collapse; }
.paper-table th { padding: .625rem .5rem; text-align: left; font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: var(--x-paper-muted); border-bottom: 1.5px solid var(--x-paper-ink); }
.paper-table td { padding: .75rem .5rem; vertical-align: top; border-bottom: 1px solid var(--x-paper-line); }
.paper-table th:first-child, .paper-table td:first-child { padding-left: 0; }
.paper-table th:last-child, .paper-table td:last-child { padding-right: 0; }
.paper-table .r { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.paper-table .p-qty { width: 3.25rem; }
.paper-table .p-price { width: 6.25rem; }
.paper-table .p-disc { width: 3.75rem; }
.paper-table .p-tax { width: 5.5rem; }
.paper-table .p-amt { width: 6.25rem; }
.paper-table .p-calc { display: none; }
.paper-totals { display: flex; flex-direction: column; gap: .5rem; width: 100%; max-width: 20rem; margin: 1.25rem 0 0 auto; }
.paper .trow.grand { border-top-color: var(--x-paper-ink); }
.paper-foot { display: grid; gap: 1.25rem; margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--x-paper-line); }
.paper .st { background: var(--x-paper-tint); color: var(--x-paper-ink); border-color: var(--x-paper-line); }
.paper .st-sent { color: var(--x-paper-accent); }
.paper .st-paid, .paper .st-accepted { background: var(--x-lime); color: var(--x-on-lime); border-color: transparent; }
@media (min-width: 640px) {
  .paper-head { flex-direction: row; justify-content: space-between; }
  .paper-title { text-align: right; }
  .paper-meta, .paper-foot { grid-template-columns: 1fr 1fr; gap: 2rem; }
}
/* Phones: each line becomes "Item / qty x price = amount" */
@media (max-width: 639px) {
  .paper-table thead { display: none; }
  .paper-table, .paper-table tbody { display: block; width: 100%; }
  .paper-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .25rem .75rem; padding: .75rem 0; border-bottom: 1px solid var(--x-paper-line); }
  .paper-table td { display: block; width: auto !important; padding: 0 !important; border: 0; }
  .paper-table .p-qty, .paper-table .p-price, .paper-table .p-disc, .paper-table .p-tax { display: none; }
  .paper-table .p-item { grid-column: 1 / -1; }
  .paper-table .p-calc { display: block; color: var(--x-paper-muted); font-variant-numeric: tabular-nums; }
  .paper-table .p-calc small { display: block; font-size: .75rem; }
  .paper-table .p-amt { align-self: start; font-weight: 700; }
}
.paper.pdf-mode { width: 820px; max-width: none; padding: 2.25rem; border: 0; box-shadow: none; border-radius: 0; }
.pdf-mode .paper-head { flex-direction: row; justify-content: space-between; }
.pdf-mode .paper-title { text-align: right; }
.pdf-mode .paper-meta, .pdf-mode .paper-foot { grid-template-columns: 1fr 1fr; }

.pub { min-height: 100vh; }
.pub-bar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }

/* Billcraft brand layer ---------------------------------------------------- */
.pill { display: inline-flex; align-items: center; gap: .5rem; padding: .45rem .9rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent-strong); font-size: .75rem; font-weight: 700; letter-spacing: .08em; line-height: 1; text-transform: uppercase; }
.pill-dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--accent); }
.pill.on-tint { background: var(--surface); }
.pill.on-dark { background: rgba(255, 255, 255, .1); color: var(--x-lime); }

.float-card { z-index: 2; padding: 1rem; border-radius: 16px; background: var(--x-paper); color: var(--x-paper-ink); border: 1px solid var(--x-paper-line); box-shadow: 0 18px 40px -14px rgba(20, 18, 46, .38), 0 2px 6px rgba(20, 18, 46, .08); animation: float-in .7s ease-out both; }
.float-card.has-bar { border-left: 5px solid var(--x-paper-accent); }
.fc-muted { color: var(--x-paper-muted); }
.fc-chip { display: grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 8px; background: var(--x-paper-tint); color: var(--x-paper-accent); }
.fc-lime { display: grid; place-items: center; width: 2.25rem; height: 2.25rem; flex-shrink: 0; border-radius: 50%; background: var(--x-lime); color: var(--x-on-lime); }
@keyframes float-in { from { transform: translateY(14px); } to { transform: none; } }
html.reduced-motion .float-card { animation: none; }

.feat { display: flex; flex-direction: column; padding: 1.25rem; border-radius: 1.5rem; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-card); transition: transform .2s, box-shadow .2s; }
.feat:hover { transform: translateY(-4px); box-shadow: 0 18px 36px -18px rgba(20, 18, 46, .28); }
html.reduced-motion .feat:hover, html.reduced-motion .kpi:hover { transform: none; }
.ill { min-height: 11.5rem; padding: 1.25rem; border-radius: 1rem; background: var(--surface-2); }
.shape { display: block; border-radius: 999px; }
.av { display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; border: 2px solid var(--surface-2); border-radius: 50%; font-size: .75rem; font-weight: 700; }
.av-sm { width: 1.75rem; height: 1.75rem; flex-shrink: 0; border: 0; font-size: .6875rem; }
.tag { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .6875rem; font-weight: 700; line-height: 1.3; }
.stat-big { margin: 0; font-family: var(--font-display); font-size: clamp(2.75rem, 6vw, 4rem); font-weight: 800; letter-spacing: -.04em; line-height: 1; color: var(--accent-text); }
.quote-card { position: relative; display: flex; flex-direction: column; justify-content: space-between; margin: 0; padding: 2rem 2rem 2rem 2.5rem; overflow: hidden; border: 1px solid var(--border); border-radius: 1.5rem; background: var(--surface); box-shadow: var(--shadow-card); }
.quote-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: .5rem; background: var(--accent); }
.quote-card svg.icon { width: 2rem; height: 2rem; }
.avatar-photo { width: 3.5rem; height: 3.5rem; flex-shrink: 0; border-radius: 50%; object-fit: cover; }

.cta-band { background: var(--x-dark); color: var(--x-on-dark); }
.cta-foot { border-top: 1px solid rgba(255, 255, 255, .12); }
.auth-art { align-items: center; justify-content: center; padding: 4rem; color: var(--x-on-dark); background-color: var(--x-dark); background-image: radial-gradient(circle at 20% 12%, color-mix(in srgb, var(--accent) 60%, transparent), transparent 55%); }
.auth-art .icon { color: var(--x-lime); }

/* Print -------------------------------------------------------------------- */
@media print {
  @page { margin: 12mm; }
  body { background: var(--x-paper) !important; }
  .no-print, .mbar, .side, .nav-backdrop, .demo-bar, .toasts, dialog, .actionbar { display: none !important; }
  .app-shell { display: block !important; }
  main { padding: 0 !important; }
  .paper-stage { max-width: none; }
  .paper { border: 0; box-shadow: none; border-radius: 0; padding: 0; }
  .paper-head { flex-direction: row; justify-content: space-between; }
  .paper-title { text-align: right; }
  .paper-meta, .paper-foot { grid-template-columns: 1fr 1fr; }
  .doc-grid { display: block; }
  tr, .paper-totals, .paper-foot { break-inside: avoid; }
}
