/* Bilufoiy — app chrome. Tokens mirror the OfficeLab Portal (sky brand,
   slate neutrals, Inter, rounded-2xl cards), with auto dark mode. */

:root {
  --brand: 21 128 61;         /* green-700 — primary actions */
  --brand-fg: 255 255 255;
  --brand-600: 22 101 52;     /* green-800 — links */
  --brand-700: 20 83 45;      /* green-900 — hover */
  --hero-from: #1e5638;       /* featured stat card gradient */
  --hero-mid: #123d26;
  --hero-to: #0a2617;
  --bg: 244 245 243;          /* flat neutral page, cards float on it */
  --surface: 255 255 255;
  --border: 229 231 228;
  --text: 23 26 24;
  --muted: 122 128 122;
  /* Card border width: 1px is the thinnest a standard display can draw, so the
     hairline is opt-in for high-DPI screens, where 0.5px renders cleanly. */
  --hairline: 1px;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E");
  --radius-card: 20px;
  --radius-field: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: 10 12 10;
    --surface: 24 26 24;
    --border: 43 46 43;
    --text: 233 236 232;
    --muted: 154 160 154;
  }
}

@media (min-resolution: 2dppx) {
  :root { --hairline: 0.5px; }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  color: rgb(var(--text));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  font-size: 14px;
  background: rgb(var(--bg));
}

a { color: rgb(var(--brand-600)); text-decoration: none; }
/* Buttons carry their own colour; the link rules must not reach them. */
a:not([class*="btn"]):not([class*="cta"]):hover { color: rgb(var(--brand-700)); }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { letter-spacing: -0.01em; }

/* ── Primitives ────────────────────────────────────────────── */

.card {
  background: rgb(var(--surface) / 0.92);
  border: var(--hairline) solid rgb(var(--border));
  border-radius: var(--radius-card);
  box-shadow: 0 1px 2px rgb(2 6 23 / 0.05);
}
.card-pad { padding: 18px; }
.card h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }

.input {
  width: 100%;
  border: 1px solid rgb(var(--border));
  background: rgb(var(--surface));
  border-radius: var(--radius-field);
  padding: 8px 12px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input::placeholder { color: rgb(var(--muted)); }
.input:hover { border-color: rgb(var(--muted) / 0.45); }
.input:focus { border-color: rgb(var(--brand)); box-shadow: 0 0 0 3px rgb(var(--brand) / 0.25); }
.input:disabled { opacity: 0.55; }
textarea.input { resize: vertical; line-height: 1.45; }
select.input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}
.input-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 10px; }
select.input-sm { padding-right: 26px; }

.label { display: block; font-size: 11.5px; font-weight: 500; color: rgb(var(--muted)); margin-bottom: 4px; }
.field { min-width: 0; }
.field-note { margin: 5px 0 0; font-size: 11.5px; color: rgb(var(--muted)); line-height: 1.5; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.check input { accent-color: rgb(var(--brand)); width: 15px; height: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  white-space: nowrap; border-radius: var(--radius-field);
  padding: 8px 16px; font-size: 13.5px; font-weight: 500;
  border: 1px solid transparent; text-decoration: none !important;
  transition: transform 0.15s ease-out, box-shadow 0.15s, background-color 0.15s, border-color 0.15s;
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary { background: rgb(var(--brand)); color: rgb(var(--brand-fg)); box-shadow: 0 1px 2px rgb(2 6 23 / 0.08); }
.btn-primary:hover { background: rgb(var(--brand-700)); transform: translateY(-2px); box-shadow: 0 10px 22px -8px rgb(var(--brand) / 0.55); }
.btn-ghost { border-color: rgb(var(--border)); background: rgb(var(--surface)); color: rgb(var(--text)); }
.btn-ghost:hover { background: rgb(var(--bg)); border-color: rgb(var(--brand) / 0.4); transform: translateY(-2px); }
.btn-danger { border-color: #fca5a5; color: #dc2626; background: rgb(var(--surface)); }
.btn-danger:hover { background: #fef2f2; transform: translateY(-2px); }
@media (prefers-color-scheme: dark) {
  .btn-danger { border-color: #7f1d1d; color: #f87171; }
  .btn-danger:hover { background: rgb(69 10 10 / 0.4); }
}
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 10px; }
.btn-icon { padding: 7px; border-radius: 10px; }
.link-btn { border: none; background: none; color: rgb(var(--muted)); font-size: 12px; padding: 0; }
.link-btn:hover { color: rgb(var(--brand-600)); }

.muted { color: rgb(var(--muted)); }
.small { font-size: 12px; }
.strong { font-weight: 600; color: rgb(var(--text)); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.upper { text-transform: uppercase; }
.nowrap { white-space: nowrap; }
.r { text-align: right; }
/* Single-button forms sit in flex rows beside plain buttons; inline-flex keeps
   the button inside them the same height as its neighbours. */
.inline { display: inline-flex; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; }
.btn-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > h2 { margin-bottom: 0; }
.stack-h { display: flex; gap: 10px; }
.stack-h .btn { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.narrow { max-width: 760px; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: 999px; padding: 3px 10px; font-size: 11.5px; font-weight: 500;
  text-decoration: none !important;
}
.badge .dot { width: 6px; height: 6px; border-radius: 999px; }
.st-draft { background: #f8fafc; color: #475569; box-shadow: inset 0 0 0 1px rgb(100 116 139 / 0.2); }
.st-draft .dot { background: #94a3b8; }
.st-sent, .st-viewed, .st-partial { background: #f0f9ff; color: #0369a1; box-shadow: inset 0 0 0 1px rgb(14 165 233 / 0.25); }
.st-sent .dot, .st-viewed .dot, .st-partial .dot { background: #0ea5e9; }
.st-unpaid, .st-pending { background: #fffbeb; color: #b45309; box-shadow: inset 0 0 0 1px rgb(245 158 11 / 0.25); }
.st-unpaid .dot, .st-pending .dot { background: #f59e0b; }
.st-paid, .st-accepted, .st-approved, .st-active { background: #ecfdf5; color: #047857; box-shadow: inset 0 0 0 1px rgb(16 185 129 / 0.25); }
.st-paid .dot, .st-accepted .dot, .st-approved .dot, .st-active .dot { background: #10b981; }
.st-overdue, .st-cancelled, .st-rejected, .st-expired { background: #fff1f2; color: #be123c; box-shadow: inset 0 0 0 1px rgb(244 63 94 / 0.25); }
.st-overdue .dot, .st-cancelled .dot, .st-rejected .dot, .st-expired .dot { background: #f43f5e; }
@media (prefers-color-scheme: dark) {
  .st-draft { background: rgb(148 163 184 / 0.1); color: #cbd5e1; }
  .st-sent, .st-viewed, .st-partial { background: rgb(56 189 248 / 0.1); color: #7dd3fc; }
  .st-unpaid, .st-pending { background: rgb(251 191 36 / 0.1); color: #fcd34d; }
  .st-paid, .st-accepted, .st-approved, .st-active { background: rgb(52 211 153 / 0.1); color: #6ee7b7; }
  .st-overdue, .st-cancelled, .st-rejected, .st-expired { background: rgb(251 113 133 / 0.1); color: #fda4af; }
}

.kind-chip {
  display: inline-flex; align-items: center; border-radius: 7px; padding: 2px 7px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.04em;
}
.kind-quotation { background: rgb(var(--brand) / 0.12); color: rgb(var(--brand-600)); }
.kind-invoice { background: rgb(16 185 129 / 0.12); color: #047857; }
@media (prefers-color-scheme: dark) {
  .kind-quotation { color: #7dd3fc; }
  .kind-invoice { color: #6ee7b7; }
}

/* ── Layout ────────────────────────────────────────────────── */

.app { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100vh; }

/* The scrim exists only to dim the page behind the off-canvas sidebar on narrow
   screens, so it must stay out of the flow here. Left as a plain grid child it
   claims the main column, pushing the content into a second row beneath the
   full-height sidebar and off the bottom of the screen. */
.scrim { display: none; }

.sidebar {
  display: flex; flex-direction: column;
  background: transparent;
  height: 100vh; position: sticky; top: 0; overflow-y: auto;
}
@media (prefers-color-scheme: dark) {
  .sidebar { background: transparent; }
}
.sidebar-head { padding: 16px 14px 10px; display: flex; flex-direction: column; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 14.5px; color: rgb(var(--text)) !important; text-decoration: none !important; }
.brand small { display: block; font-weight: 500; font-size: 10.5px; color: rgb(var(--muted)); max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The mark is the app's own artwork, so it needs no tile behind it. */
.brand-mark {
  width: 32px; height: 32px; flex-shrink: 0;
  display: block;
  object-fit: contain;
}
.brand-mark-lg { width: 48px; height: 48px; }
.new-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.nav { flex: 1; padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 11px;
  font-size: 13.5px; font-weight: 500; color: rgb(var(--text)) !important;
  text-decoration: none !important; transition: background 0.15s;
}
.nav-link:hover { background: rgb(var(--bg)); }
.nav-link.active {
  background: rgb(var(--brand) / 0.11);
  color: rgb(var(--brand-700)) !important;
  font-weight: 600;
}
.dark-safe {}
.nav-link.active svg { opacity: 1; color: rgb(var(--brand-600)); }
.nav-group-label {
  padding: 14px 12px 6px;
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: rgb(var(--muted));
}
.nav-link svg { flex-shrink: 0; opacity: 0.75; }
.nav-count {
  margin-left: auto; background: rgb(var(--brand)); color: #fff;
  border-radius: 999px; font-size: 10.5px; font-weight: 700; padding: 1px 7px;
}
.sidebar-foot { border-top: 1px solid rgb(var(--border)); padding: 10px; }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px 2px; }
.user-name { font-size: 12px; color: rgb(var(--muted)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 22px; position: sticky; top: 0; z-index: 20;
  background: rgb(var(--bg) / 0.75);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgb(var(--border) / 0.7);
}
.topbar-spacer { flex: 1; }
.menu-btn { display: none; }
.bell-btn { position: relative; }
.bell-dot { position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 999px; background: #f43f5e; }

.content { padding: 22px; flex: 1; max-width: 1120px; width: 100%; margin: 0 auto; }
.content-wide { max-width: 1440px; }

.flash {
  margin: 12px 22px 0; padding: 10px 16px;
  background: rgb(var(--brand) / 0.1); border: 1px solid rgb(var(--brand) / 0.3);
  color: rgb(var(--brand-700)); border-radius: 12px; font-size: 13px; font-weight: 500;
  word-break: break-word;
}
@media (prefers-color-scheme: dark) { .flash { color: #7dd3fc; } }
.flash-inline { margin: 0 0 12px; }
.notice {
  margin: 0 0 14px; padding: 9px 14px; font-size: 12.5px;
  background: rgb(var(--brand) / 0.07); border: 1px solid rgb(var(--brand) / 0.25);
  border-radius: 12px;
}
.notice-warn { background: rgb(245 158 11 / 0.08); border-color: rgb(245 158 11 / 0.35); }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin: 0 0 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { margin: 0; font-size: 12.5px; color: rgb(var(--muted)); }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.empty { padding: 40px 20px; text-align: center; }
.empty-title { margin: 0 0 4px; font-weight: 600; }
.empty-hint { margin: 0 0 14px; font-size: 12.5px; color: rgb(var(--muted)); }

/* ── Tables & lists ────────────────────────────────────────── */

.table-card { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: rgb(var(--muted)); padding: 12px 14px; border-bottom: 1px solid rgb(var(--border));
}
.table th.r { text-align: right; }
.table td { padding: 11px 14px; border-bottom: 1px solid rgb(var(--border) / 0.6); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .rowlink { cursor: pointer; transition: background 0.12s; }
.table .rowlink:hover { background: rgb(var(--brand) / 0.05); }
.table .totals-row td { border-top: 2px solid rgb(var(--border)); }
.small-table td { padding: 7px 4px; font-size: 12.5px; border-bottom-color: rgb(var(--border) / 0.4); }

.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar .input { max-width: 220px; }
.filter-bar input[type="date"].input { max-width: 150px; }

.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.mini-list li { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid rgb(var(--border) / 0.5); }
.mini-list li:last-child { border-bottom: none; }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; color: rgb(var(--text)) !important; text-decoration: none !important; }
.doc-row:hover { background: rgb(var(--bg)); }
.doc-num { font-weight: 600; font-size: 12.5px; }
.doc-total { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 12.5px; }

.dl { display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; font-size: 13px; margin: 0 0 14px; }
.dl dt { color: rgb(var(--muted)); }
.dl dd { margin: 0; }

/* ── Dashboard ─────────────────────────────────────────────── */

.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; color: rgb(var(--text)) !important; text-decoration: none !important; transition: transform 0.15s, box-shadow 0.15s; }
.stat:hover { transform: translateY(-2px); box-shadow: 0 10px 22px -14px rgb(var(--brand) / 0.5); }
.stat-label { font-size: 11.5px; color: rgb(var(--muted)); font-weight: 500; }
.stat-value {
  font-size: 19px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  letter-spacing: -0.01em;
}
/* Compound values carry more words, so they take a smaller, calmer size. */
.stat-value.is-phrase { font-size: 14px; font-weight: 600; letter-spacing: 0; }
.stat-warn .stat-value { color: #b45309; }

/* The first stat is the headline figure: filled, so the eye lands there. */
.stat-hero {
  background: linear-gradient(150deg, var(--hero-from) 0%, var(--hero-mid) 55%, var(--hero-to) 100%);
  border-color: transparent;
  position: relative;
  padding-right: 52px;
}
.stat-hero .stat-label { color: rgb(255 255 255 / 0.7); }
.stat-hero .stat-value, .stat-hero .stat-foot { color: #fff; }
.stat-hero .stat-foot { opacity: 0.72; }
.stat-hero:hover { box-shadow: 0 14px 30px -14px rgb(10 38 23 / 0.65); }
.stat-arrow {
  position: absolute; top: 14px; right: 14px;
  width: 28px; height: 28px; border-radius: 999px;
  background: rgb(255 255 255 / 0.14);
  display: grid; place-items: center; color: #fff;
}
.stat-foot { font-size: 11px; color: rgb(var(--muted)); }
.stat-bad .stat-value { color: #be123c; }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 8px; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.chart-bar {
  width: 100%; max-width: 34px; min-height: 3px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--hero-from), var(--hero-to));
}
/* A month with nothing received reads as an empty slot, not a short bar. */
.chart-bar.is-empty {
  background: repeating-linear-gradient(
    -45deg, rgb(var(--border)) 0 4px, transparent 4px 8px);
  border: var(--hairline) solid rgb(var(--border));
}
.chart-label { font-size: 9.5px; color: rgb(var(--muted)); }

/* ── Editor ────────────────────────────────────────────────── */

.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
@media (max-width: 1080px) { .editor-grid { grid-template-columns: 1fr; } }
.editor-side { position: sticky; top: 74px; }
@media (max-width: 1080px) { .editor-side { position: static; } }

.items-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.items-toolbar h2 { margin: 0; }
.items-tools { display: flex; gap: 8px; align-items: center; }
.items-tools .input-sm { max-width: 260px; }

.item-card { border: 1px solid rgb(var(--border)); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.item-grid { display: grid; grid-template-columns: minmax(0, 2fr) 70px 90px 110px 110px 90px 34px; gap: 8px; align-items: start; }
@media (max-width: 900px) { .item-grid { grid-template-columns: 1fr 1fr; } .item-grid .item-name-cell { grid-column: 1 / -1; } }
/* Two-column detail layout: a narrow panel (details, or an add/edit form)
   beside the main content. Used by the customer detail and catalog pages. */
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 900px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }

/* Numeric inputs read right-aligned, so figures line up down a column. */
.input.num { text-align: right; }

/* "Load more" pagination control, centred under a list. */
.more-row { display: flex; justify-content: center; padding: 14px 0 4px; }

/* Discount is a type/value pair stacked inside one 110px column — too narrow
   to sit side by side once the currency label is in the select. */
.disc-pair { display: grid; gap: 6px; }

.item-grid .rm { border: none; background: none; color: #e11d48; border-radius: 8px; padding: 6px 4px; margin-top: 20px; }
.item-grid .rm:hover { background: #fff1f2; }
@media (prefers-color-scheme: dark) { .item-grid .rm:hover { background: rgb(76 5 25 / 0.4); } }
.item-desc-row { margin-top: 8px; }
.item-amount { font-size: 12px; color: rgb(var(--muted)); text-align: right; margin-top: 6px; font-variant-numeric: tabular-nums; }

.totals { border-top: 1px solid rgb(var(--border)); padding-top: 12px; display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; }
.totals .row { display: flex; justify-content: space-between; gap: 10px; }
.totals .row span:last-child { font-variant-numeric: tabular-nums; }
.totals .grand { font-weight: 700; font-size: 15.5px; padding-top: 3px; }

/* ── Doc view ──────────────────────────────────────────────── */

.view-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 1150px) { .view-grid { grid-template-columns: 1fr; } }
.side-pane { min-width: 0; }
.sheet-pane { min-width: 0; }
.sheet-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.sheet-scaler-wrap { overflow: hidden; border-radius: 8px; }
.sheet-scaler { transform-origin: top left; width: 210mm; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row .input { flex: 1; font-size: 11.5px; }

/* ── Settings ──────────────────────────────────────────────── */

.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .settings-layout { grid-template-columns: 1fr; } }
.settings-tabs { display: flex; flex-direction: column; padding: 8px; position: sticky; top: 74px; }
@media (max-width: 900px) { .settings-tabs { position: static; flex-direction: row; overflow-x: auto; } }
.settings-tabs a {
  padding: 9px 12px; border-radius: 10px; font-size: 13px; font-weight: 500;
  color: rgb(var(--text)) !important; text-decoration: none !important; white-space: nowrap;
}
.settings-tabs a:hover { background: rgb(var(--bg)); }
.settings-tabs a.active { background: rgb(var(--brand) / 0.1); color: rgb(var(--brand-600)) !important; }
.settings-body { min-width: 0; }

.logo-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.logo-thumb {
  width: 110px; height: 54px; border: 1px dashed rgb(var(--border)); border-radius: 10px;
  display: grid; place-items: center; overflow: hidden; background: rgb(var(--surface)); flex-shrink: 0;
}
.logo-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-thumb span { font-size: 10px; color: rgb(var(--muted)); }

.perm-checks { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.danger-zone { border-color: rgb(244 63 94 / 0.35); }
.danger-zone h2 { color: #be123c; }
@media (prefers-color-scheme: dark) { .danger-zone h2 { color: #fda4af; } }

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.plan { padding: 14px; display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.plan-active { border-color: rgb(var(--brand)); box-shadow: 0 0 0 2px rgb(var(--brand) / 0.25); }
.plan-name { font-size: 12px; font-weight: 600; color: rgb(var(--muted)); text-transform: uppercase; letter-spacing: 0.05em; }
.plan-price { font-size: 18px; font-weight: 800; }

/* ── Notifications ─────────────────────────────────────────── */

.notif-list { list-style: none; margin: 0; padding: 6px; }
.notif-list li a {
  display: flex; flex-direction: column; gap: 2px; padding: 11px 14px; border-radius: 12px;
  color: rgb(var(--text)) !important; text-decoration: none !important;
}
.notif-list li a:hover { background: rgb(var(--bg)); }
.notif-list li.unread a { background: rgb(var(--brand) / 0.06); }
.notif-list li.unread .notif-title::before { content: "●  "; color: rgb(var(--brand)); font-size: 9px; vertical-align: 2px; }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-body { font-size: 12.5px; color: rgb(var(--muted)); }
.notif-time { font-size: 11px; color: rgb(var(--muted)); }

/* ── Auth & portal (bare pages) ────────────────────────────── */

body.bare { display: block; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; padding: 28px; }
.auth-card-wide { max-width: 560px; }
.auth-card h1 { margin: 0 0 6px; font-size: 20px; }
.auth-sub { margin: 0 0 18px; font-size: 13px; color: rgb(var(--muted)); }
.auth-brand { margin-bottom: 14px; }
.auth-alt { margin: 16px 0 0; font-size: 12.5px; color: rgb(var(--muted)); }

.portal { max-width: 900px; margin: 0 auto; padding: 18px; }
.portal-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; margin-bottom: 12px; flex-wrap: wrap;
  background: rgb(var(--surface) / 0.92); border: 1px solid rgb(var(--border)); border-radius: 14px;
}
.portal-brand { display: flex; align-items: center; gap: 10px; }
.portal-brand img { max-height: 34px; max-width: 120px; object-fit: contain; }
.portal-brand div { display: flex; flex-direction: column; }
.portal-actions { display: flex; align-items: center; gap: 8px; }
.portal-status {
  padding: 10px 16px; margin-bottom: 12px; font-size: 13px;
  background: rgb(var(--brand) / 0.07); border: 1px solid rgb(var(--brand) / 0.25); border-radius: 12px;
}
.portal-decide { padding: 16px; margin-bottom: 12px; }
.portal-decide h2 { margin: 0 0 4px; font-size: 15px; }
.portal-foot { text-align: center; font-size: 11px; color: rgb(var(--muted)); margin: 16px 0; }
.portal-sheet .sheet-scaler-wrap { border-radius: 8px; }

/* ── Responsive sidebar ────────────────────────────────────── */

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 60;
    transform: translateX(-102%); transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 20px 60px rgb(2 6 23 / 0.3); background: rgb(var(--surface));
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgb(2 6 23 / 0.45); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
  body.sidebar-open .scrim { opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-flex; }
  .content { padding: 14px; }
}

/* ── Print: hide everything except the sheet / printable ───── */

@page { size: A4; margin: 15mm 0 20mm; }
@media print {
  body { background: #fff !important; }
  .sidebar, .scrim, .topbar, .flash, .notice, .no-print, .side-pane, .page-head,
  .filter-bar, .settings-tabs, .portal-bar, .portal-status, .portal-decide, .portal-foot { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .view-grid, .editor-grid { display: block; }
  .sheet-scaler-wrap { overflow: visible; border-radius: 0; }
  .sheet-scaler { transform: none !important; width: auto; }
  /* Vertical padding is now the page margin's job — keeping it here would
     indent only the first page and leave every later page flush to the edge. */
  .sheet {
    padding: 0 50pt 12mm !important;
    width: auto !important;
    min-height: calc(297mm - 35mm) !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
  .portal { max-width: none; padding: 0; }
  /* Reports print as plain tables */
  .printable { border: none; box-shadow: none; }
}


/* ── Modal ─────────────────────────────────────────────────────
   Native <dialog>: Esc to dismiss and focus trapping are built in. */

.modal {
  border: var(--hairline) solid rgb(var(--border));
  border-radius: var(--radius-card);
  background: rgb(var(--surface));
  color: rgb(var(--text));
  padding: 0;
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  box-shadow: 0 24px 60px -12px rgb(2 6 23 / 0.35);
}
.modal::backdrop { background: rgb(2 6 23 / 0.45); }
.modal[open] { animation: modal-in 0.16s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .modal[open] { animation: none; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: var(--hairline) solid rgb(var(--border));
}
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-close {
  border: none; background: none; color: rgb(var(--muted));
  border-radius: 8px; padding: 5px; line-height: 0;
}
.modal-close:hover { background: rgb(var(--bg)); color: rgb(var(--text)); }
.modal-body { padding: 18px; overflow-y: auto; max-height: calc(100vh - 210px); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 18px; border-top: var(--hairline) solid rgb(var(--border));
}
.modal-error {
  margin: 0 0 12px; padding: 9px 13px; font-size: 12.5px; border-radius: 10px;
  background: rgb(244 63 94 / 0.08); border: var(--hairline) solid rgb(244 63 94 / 0.3); color: #be123c;
}
@media (prefers-color-scheme: dark) { .modal-error { color: #fda4af; } }

/* A link-styled button, for actions that open a modal rather than navigate. */
.link-action {
  border: none; background: none; padding: 0;
  color: rgb(var(--brand-600)); font-size: inherit; font-weight: 500;
}
.link-action:hover { color: rgb(var(--brand-700)); }

/* Field reference inside the import modal. */
.field-table { font-size: 12.5px; margin: 4px 0 2px; }
.field-table th { padding: 6px 8px; }
.field-table td { padding: 7px 8px; vertical-align: top; }
.field-table .mono { font-size: 12px; }
.req { color: #b45309; font-weight: 600; font-size: 11.5px; }
@media (prefers-color-scheme: dark) { .req { color: #fcd34d; } }

@media print { .modal { display: none !important; } }


/* Signed-in identity, shown as a chip in the topbar. */
.profile-chip {
  display: flex; align-items: center; gap: 9px;
  background: rgb(var(--surface));
  border: var(--hairline) solid rgb(var(--border));
  border-radius: 999px;
  padding: 5px 14px 5px 6px;
}
.profile-avatar {
  width: 28px; height: 28px; border-radius: 999px; flex-shrink: 0;
  background: linear-gradient(150deg, var(--hero-from), var(--hero-to));
  color: #fff; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700;
}
.profile-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.profile-name { font-size: 12.5px; font-weight: 600; }
.profile-mail { font-size: 10.5px; color: rgb(var(--muted)); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 170px; }
@media (max-width: 700px) { .profile-meta { display: none; } .profile-chip { padding: 5px; } }

/* ── Dropzone ──────────────────────────────────────────────────
   A <label> wrapping a hidden file input, so a click opens the file
   manager natively and drag-and-drop is layered on top by client.js. */

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center;
  padding: 26px 18px;
  border: 1.5px dashed rgb(var(--border));
  border-radius: 14px;
  background: rgb(var(--bg));
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover { border-color: rgb(var(--brand) / 0.55); }
.dropzone.is-over {
  border-color: rgb(var(--brand));
  background: rgb(var(--brand) / 0.06);
}
.dropzone.has-file { border-style: solid; border-color: rgb(var(--brand) / 0.5); }
.dz-icon { color: rgb(var(--muted)); }
.dropzone.is-over .dz-icon, .dropzone.has-file .dz-icon { color: rgb(var(--brand-600)); }
.dz-main { font-size: 13.5px; font-weight: 500; }
.dz-link { color: rgb(var(--brand-600)); text-decoration: underline; }
.dz-hint { font-size: 11.5px; color: rgb(var(--muted)); }

/* ── App footer ────────────────────────────────────────────── */

.app-foot {
  padding: 18px 22px 24px;
  text-align: center;
  font-size: 11.5px;
  color: rgb(var(--muted));
}
.app-foot a { color: rgb(var(--muted)); }
.app-foot a:hover { color: rgb(var(--text)); }
@media print { .app-foot { display: none !important; } }

/* ── Trial pill ────────────────────────────────────────────────
   Narrow and a touch taller than a badge; the label scrolls so a long
   message still reads in full without widening the topbar. */

.trial-pill {
  display: flex; align-items: center;
  width: 168px; height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  overflow: hidden;
  font-size: 12px; font-weight: 500;
  background: rgb(var(--brand) / 0.09);
  color: rgb(var(--brand-600)) !important;
  border: var(--hairline) solid rgb(var(--brand) / 0.28);
}
.trial-pill-warn {
  background: rgb(244 63 94 / 0.09);
  color: #be123c !important;
  border-color: rgb(244 63 94 / 0.3);
}
@media (prefers-color-scheme: dark) { .trial-pill-warn { color: #fda4af !important; } }

.marquee { display: block; width: 100%; overflow: hidden; }
.marquee-track {
  display: inline-flex; gap: 36px;
  white-space: nowrap;
  will-change: transform;
  animation: marquee-scroll 9s linear infinite;
}
/* The track holds the label twice, so -50% lands exactly on the copy. */
@keyframes marquee-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(calc(-50% - 18px)); }
}
.trial-pill:hover .marquee-track { animation-play-state: paused; }
@media (prefers-reduced-motion: reduce) {
  .marquee-track { animation: none; }
}

/* ── Disclosure ────────────────────────────────────────────────
   Replaces the default browser triangle on <details> with a chevron that
   turns to point down when the section opens. Masked, so it takes the
   summary's own colour in both themes. */

summary.disclosure {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  user-select: none;
  font-weight: 500;
  transition: color 0.15s;
}
summary.disclosure::-webkit-details-marker { display: none; }
summary.disclosure:hover { color: rgb(var(--brand-600)); }
summary.disclosure::before {
  content: "";
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: var(--chevron) center / contain no-repeat;
  mask: var(--chevron) center / contain no-repeat;
  transition: transform 0.18s ease;
}
details[open] > summary.disclosure::before { transform: rotate(90deg); }
summary.disclosure:focus-visible {
  outline: 2px solid rgb(var(--brand) / 0.5);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Confirm dialog ────────────────────────────────────────────
   Replaces window.confirm(), which renders as an unstyled browser bar
   labelled with the hostname. Injected once by client.js. */

.modal-confirm { width: min(430px, calc(100vw - 32px)); }
.confirm-body { display: flex; gap: 14px; padding: 22px 22px 6px; }
.confirm-icon {
  width: 38px; height: 38px; border-radius: 999px; flex-shrink: 0;
  display: grid; place-items: center;
  background: rgb(var(--brand) / 0.12);
  color: rgb(var(--brand-600));
}
.modal-confirm.is-danger .confirm-icon { background: rgb(244 63 94 / 0.12); color: #e11d48; }
.confirm-text { min-width: 0; padding-top: 1px; }
.confirm-title { margin: 0 0 4px; font-size: 15px; font-weight: 650; }
.confirm-message { margin: 0; font-size: 13.5px; color: rgb(var(--muted)); line-height: 1.5; }
.modal-confirm .modal-foot { border-top: none; padding: 16px 22px 18px; }


/* ── Narrow screens: use the width ─────────────────────────────
   The filter bar's desktop max-widths leave one control per row on a
   phone; a two-column grid fits them without horizontal scrolling. */

@media (max-width: 700px) {
  .filter-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .filter-bar > * { max-width: none !important; width: 100%; }
  .filter-bar > input[type="search"] { grid-column: 1 / -1; }
  .filter-bar > .btn { grid-column: 1 / -1; }

  /* Two stat tiles per row rather than one tall column. */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 12px 13px; }
  .stat-value { font-size: 17px; }
  .stat-value.is-phrase { font-size: 13px; }
  .stat-hero { padding-right: 13px; }
  .stat-arrow { display: none; }

  /* Page actions get a full row so the title is not squeezed. */
  .page-head { gap: 10px; }
  .page-head h1 { font-size: 22px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }

  .card-pad { padding: 14px; }
  .content { padding: 12px; }
}

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

/* ── Row actions ───────────────────────────────────────────────
   Compact controls inside a table row. The rowlink handler ignores clicks
   on buttons and forms, so these never trigger navigation. */

.row-actions { display: inline-flex; align-items: center; gap: 2px; justify-content: flex-end; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px;
  border: none; background: none; border-radius: 8px;
  color: rgb(var(--muted));
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: rgb(var(--bg)); color: rgb(var(--brand-600)); }
.icon-btn-danger:hover { background: rgb(244 63 94 / 0.1); color: #e11d48; }
tr:hover .icon-btn { color: rgb(var(--text)); }
tr:hover .icon-btn:hover { color: rgb(var(--brand-600)); }
tr:hover .icon-btn-danger:hover { color: #e11d48; }

/* Separates the status chips from the actions on a document header. */
.head-divider {
  width: 1px; height: 20px; margin: 0 2px;
  background: rgb(var(--border));
}

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

/* ── Landing page ──────────────────────────────────────────────
   Public marketing page. Uses the app's own tokens so the product a
   visitor signs into looks like the page that sold it to them. */

.lp { max-width: 1120px; margin: 0 auto; padding: 0 20px 60px; }

.lp-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 20px 0; flex-wrap: wrap;
}
.lp-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; color: rgb(var(--text)); }
.lp-nav-links { display: flex; align-items: center; gap: 18px; }
.lp-nav-links > a:not(.btn) { font-size: 13.5px; font-weight: 500; color: rgb(var(--muted)); }
.lp-nav-links > a:not(.btn):hover { color: rgb(var(--text)); }
@media (max-width: 620px) {
  .lp-nav-links > a:not(.btn) { display: none; }
}

.lp-hero { text-align: center; padding: 44px 0 10px; }
.lp-eyebrow {
  display: inline-block; margin-bottom: 16px;
  padding: 5px 14px; border-radius: 999px;
  background: rgb(var(--brand) / 0.1); color: rgb(var(--brand-700));
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
}
.lp-hero h1 {
  margin: 0 0 16px; font-size: clamp(30px, 5.4vw, 52px); line-height: 1.08;
  font-weight: 800; letter-spacing: -0.03em;
}
.lp-sub {
  max-width: 620px; margin: 0 auto 26px;
  font-size: clamp(14.5px, 1.7vw, 17px); line-height: 1.6; color: rgb(var(--muted));
}
.lp-cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.lp-cta .btn { padding: 11px 22px; font-size: 14.5px; }
.lp-fineprint { margin: 16px 0 0; font-size: 12px; color: rgb(var(--muted)); }

/* Abstract product shot — CSS only, so there is no screenshot to keep current. */
.lp-shot {
  margin: 44px auto 0; max-width: 940px;
  border: var(--hairline) solid rgb(var(--border));
  border-radius: 16px; overflow: hidden; background: rgb(var(--surface));
  box-shadow: 0 30px 60px -30px rgb(10 38 23 / 0.35);
}
.lp-shot-bar {
  display: flex; gap: 6px; padding: 11px 14px;
  border-bottom: var(--hairline) solid rgb(var(--border)); background: rgb(var(--bg));
}
.lp-shot-bar span { width: 9px; height: 9px; border-radius: 999px; background: rgb(var(--border)); }
.lp-shot-body { display: grid; grid-template-columns: 168px minmax(0, 1fr); min-height: 260px; }
.lp-shot-side {
  border-right: var(--hairline) solid rgb(var(--border));
  padding: 16px 12px; display: flex; flex-direction: column; gap: 9px; background: rgb(var(--bg));
}
.lp-shot-label { font-size: 9.5px; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: rgb(var(--muted)); }
.lp-shot-item { height: 11px; border-radius: 999px; background: rgb(var(--border)); }
.lp-shot-item.is-on { background: rgb(var(--brand) / 0.35); }
.lp-shot-main { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.lp-shot-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.lp-shot-stat {
  border: var(--hairline) solid rgb(var(--border)); border-radius: 12px; padding: 12px;
  display: flex; flex-direction: column; gap: 3px; text-align: left;
}
.lp-shot-stat b { font-size: 15px; }
.lp-shot-stat span { font-size: 10.5px; color: rgb(var(--muted)); }
.lp-shot-stat.is-hero {
  background: linear-gradient(150deg, var(--hero-from), var(--hero-to));
  border-color: transparent; color: #fff;
}
.lp-shot-stat.is-hero span { color: rgb(255 255 255 / 0.72); }
.lp-shot-rows { display: flex; flex-direction: column; gap: 8px; }
.lp-shot-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  border: var(--hairline) solid rgb(var(--border)); border-radius: 10px; padding: 10px 12px;
  font-size: 11.5px;
}
.lp-shot-row em { font-style: normal; font-size: 10px; font-weight: 600; padding: 2px 9px; border-radius: 999px; }
.lp-shot-row .is-paid { background: rgb(16 185 129 / 0.14); color: #047857; }
.lp-shot-row .is-due { background: rgb(244 63 94 / 0.12); color: #be123c; }
.lp-shot-row .is-sent { background: rgb(var(--brand) / 0.14); color: rgb(var(--brand-700)); }
@media (max-width: 720px) {
  .lp-shot-body { grid-template-columns: minmax(0, 1fr); }
  .lp-shot-side { display: none; }
  .lp-shot-stats { grid-template-columns: 1fr; }
}

.lp-section { padding: 64px 0 8px; }
.lp-h2 {
  margin: 0 0 10px; text-align: center;
  font-size: clamp(22px, 3vw, 30px); font-weight: 700; letter-spacing: -0.02em;
}
.lp-section-sub {
  max-width: 560px; margin: 0 auto 30px; text-align: center;
  font-size: 14px; line-height: 1.6; color: rgb(var(--muted));
}
/* Three tracks scrolling in alternating directions at different speeds.
   Each track holds its items twice, so translating by -50% lands exactly on
   the duplicate and the loop has no seam. */
.lp-marquees {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 30px 0 0;
  /* Bleed past the page gutter so items enter and leave off-screen. */
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.lp-marquee { overflow: hidden; }
.lp-marquee-track {
  display: flex;
  gap: 10px;
  width: max-content;
  animation: lp-scroll 52s linear infinite;
  will-change: transform;
}
.lp-marquee[data-row="1"] .lp-marquee-track { animation-duration: 38s; }
.lp-marquee[data-row="2"] .lp-marquee-track { animation-duration: 64s; }
/* Middle row travels the other way. */
.lp-marquee.is-reverse .lp-marquee-track { animation-direction: reverse; }

@keyframes lp-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.lp-marquees:hover .lp-marquee-track { animation-play-state: paused; }

.lp-feature {
  flex: 0 0 auto;
  width: 208px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 15px 13px;
  border-radius: 14px;
  background: rgb(var(--surface));
  border: var(--hairline) solid rgb(var(--border));
  transition: border-color 0.15s;
}
.lp-feature:hover { border-color: rgb(var(--brand) / 0.45); }

.lp-feature-icon {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: rgb(var(--brand) / 0.11);
  color: rgb(var(--brand-700));
  flex-shrink: 0;
}
.lp-feature-title { font-size: 12.5px; font-weight: 500; line-height: 1.35; }

@media (prefers-reduced-motion: reduce) {
  .lp-marquee-track { animation: none; }
  .lp-marquee { overflow-x: auto; }
}

.lp-band {
  background: rgb(var(--surface));
  border: var(--hairline) solid rgb(var(--border));
  border-radius: 22px; padding: 44px 34px; margin-top: 60px;
}
.lp-points { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 26px; margin-top: 26px; }
.lp-points b { display: block; margin-bottom: 6px; font-size: 14px; }
.lp-points p { margin: 0; font-size: 13px; line-height: 1.6; color: rgb(var(--muted)); }

.lp-pricing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(272px, 1fr));
  gap: 18px;
  align-items: start;
  max-width: 1000px;
  margin: 0 auto;
}

.lp-plan {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 28px 26px;
  border-radius: 20px;
  background: rgb(var(--surface));
  border: var(--hairline) solid rgb(var(--border));
  box-shadow: 0 1px 2px rgb(2 6 23 / 0.04);
}
/* The featured plan is filled, so it reads first in the row. */
.lp-plan.is-featured {
  background: linear-gradient(155deg, var(--hero-from), var(--hero-mid) 60%, var(--hero-to));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 22px 44px -24px rgb(10 38 23 / 0.6);
}
@media (min-width: 900px) {
  /* Lifted slightly above the others, as in a classic pricing row. */
  .lp-plan.is-featured { margin-top: -14px; padding-top: 42px; padding-bottom: 34px; }
}

.lp-plan-tag {
  position: absolute; top: 16px; right: 18px;
  background: rgb(255 255 255 / 0.16);
  color: #fff;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em;
  padding: 4px 11px; border-radius: 999px;
}

.lp-plan-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.lp-plan-head h3 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.01em; }
.lp-plan-icon {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: rgb(var(--brand) / 0.12);
  color: rgb(var(--brand-700));
  flex-shrink: 0;
}
.lp-plan.is-featured .lp-plan-icon { background: rgb(255 255 255 / 0.16); color: #fff; }

.lp-plan-price {
  margin: 0 0 10px;
  font-size: 34px; font-weight: 800; letter-spacing: -0.03em;
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.lp-plan-price .cur { font-size: 15px; font-weight: 700; color: rgb(var(--muted)); }
.lp-plan-price .per { font-size: 14px; font-weight: 500; color: rgb(var(--muted)); }
.lp-plan.is-featured .lp-plan-price .cur,
.lp-plan.is-featured .lp-plan-price .per { color: rgb(255 255 255 / 0.72); }

.lp-plan-blurb { margin: 0; font-size: 13px; line-height: 1.55; color: rgb(var(--muted)); }
.lp-plan.is-featured .lp-plan-blurb { color: rgb(255 255 255 / 0.78); }

.lp-plan-rule {
  border: none; height: 1px; margin: 22px 0;
  background: rgb(var(--border));
}
.lp-plan.is-featured .lp-plan-rule { background: rgb(255 255 255 / 0.22); }

.lp-plan-features {
  list-style: none; margin: 0 0 24px; padding: 0;
  display: flex; flex-direction: column; gap: 11px;
  font-size: 13px;
}
.lp-plan-features li { display: flex; align-items: center; gap: 10px; }
.lp-tick {
  display: grid; place-items: center;
  width: 19px; height: 19px; border-radius: 6px; flex-shrink: 0;
  background: rgb(var(--brand)); color: #fff;
}
.lp-plan.is-featured .lp-tick { background: rgb(255 255 255 / 0.22); }

/* Pushed to the bottom so buttons line up across cards of unequal height. */
.lp-plan-cta {
  margin-top: auto;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: 999px;
  background: rgb(var(--brand)); color: #fff;
  font-size: 14px; font-weight: 600;
  transition: background 0.15s, transform 0.15s;
}
.lp-plan-cta:hover { background: rgb(var(--brand-700)); transform: translateY(-1px); }
.lp-plan.is-featured .lp-plan-cta { background: #fff; color: var(--hero-to); }
.lp-plan.is-featured .lp-plan-cta:hover { background: #eef2ee; }

.lp-plan-fine {
  margin-top: 12px; text-align: center;
  font-size: 11.5px; color: rgb(var(--muted));
}
.lp-plan.is-featured .lp-plan-fine { color: rgb(255 255 255 / 0.66); }

.lp-final {
  margin-top: 64px; text-align: center;
  background: linear-gradient(150deg, var(--hero-from), var(--hero-mid) 55%, var(--hero-to));
  border-radius: 22px; padding: 52px 26px; color: #fff;
}
.lp-final h2 { margin: 0 0 8px; font-size: clamp(22px, 3vw, 30px); font-weight: 700; letter-spacing: -0.02em; }
.lp-final p { margin: 0 0 22px; font-size: 14px; color: rgb(255 255 255 / 0.78); }
.lp-final .btn-primary { background: #fff; color: var(--hero-to); }
.lp-final .btn-primary:hover { background: #f1f5f2; color: var(--hero-to); }

.lp-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-top: 40px; padding-top: 22px;
  border-top: var(--hairline) solid rgb(var(--border));
  font-size: 12.5px; color: rgb(var(--muted));
}
.lp-foot-links { display: flex; gap: 16px; }

/* "+ Add line" sits at the end of the item list, where a new row appears. */
.items-foot { display: flex; justify-content: flex-end; margin-top: 10px; }

/* ── Upload progress ───────────────────────────────────────────
   Any form marked [data-upload] is sent by XHR so real progress can be
   reported. Without JS the form still posts normally. */

.dropzone-sm { padding: 14px 12px; gap: 3px; }
.dropzone-sm .dz-main { font-size: 12.5px; }
.brand-upload { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand-upload .dropzone { flex: 1; min-width: 190px; }

.upload-progress {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 10px;
  border: var(--hairline) solid rgb(var(--border));
  border-radius: 12px;
  padding: 11px 13px;
  background: rgb(var(--surface));
}
.up-head { display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.up-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-meta { color: rgb(var(--muted)); font-size: 11.5px; margin-left: auto; white-space: nowrap; }
.up-bar { height: 6px; border-radius: 999px; background: rgb(var(--border)); overflow: hidden; }
.up-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, rgb(var(--brand)), var(--hero-from));
  transition: width 0.18s ease;
}
.upload-progress.is-done .up-fill { background: #10b981; }
.upload-progress.is-error .up-fill { background: #e11d48; }
.upload-progress.is-done .up-meta { color: #047857; }
.upload-progress.is-error .up-meta { color: #e11d48; }
.up-spin {
  width: 13px; height: 13px; flex-shrink: 0;
  border: 2px solid rgb(var(--border)); border-top-color: rgb(var(--brand));
  border-radius: 999px; animation: up-spin 0.7s linear infinite;
}
@keyframes up-spin { to { transform: rotate(360deg); } }
.upload-progress.is-done .up-spin,
.upload-progress.is-error .up-spin { display: none; }
@media (prefers-reduced-motion: reduce) {
  .up-spin { animation: none; }
  .up-fill { transition: none; }
}

/* ── Item entry ────────────────────────────────────────────────
   Items are added one at a time through a modal and listed read-only
   below, rather than edited as a grid of inputs. */

.items-empty {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  text-align: center;
  padding: 34px 18px;
  border: 1.5px dashed rgb(var(--border));
  border-radius: 14px;
  background: rgb(var(--bg));
}
.items-empty-title { margin: 0; font-size: 14px; font-weight: 600; }
.items-empty-hint { margin: 0 0 12px; font-size: 12.5px; color: rgb(var(--muted)); }

.items-table-wrap { overflow-x: auto; }
.items-table { margin: 0; }
.items-table td { vertical-align: top; }
.it-name { min-width: 190px; }
.it-desc {
  display: block; margin-top: 2px;
  font-size: 12px; color: rgb(var(--muted)); line-height: 1.45;
  white-space: pre-line;
}
.items-foot { display: flex; justify-content: flex-end; margin-top: 12px; }

/* Step rail in the add-item modal */
.modal-steps-dlg { width: min(560px, calc(100vw - 32px)); }
.step-rail {
  display: flex; gap: 8px; align-items: center;
  margin: 0; padding: 12px 18px 0;
  list-style: none;
}
.step-rail li {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 500; color: rgb(var(--muted));
}
.step-rail li + li::before {
  content: ""; width: 22px; height: 1px; background: rgb(var(--border)); margin-right: 7px;
}
.step-rail li span {
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 999px;
  background: rgb(var(--border)); color: rgb(var(--muted));
  font-size: 11px; font-weight: 700;
}
.step-rail li.is-on { color: rgb(var(--text)); }
.step-rail li.is-on span { background: rgb(var(--brand)); color: #fff; }

.im-preview {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-top: 14px; padding: 12px 14px;
  border-radius: 12px; background: rgb(var(--bg));
  border: var(--hairline) solid rgb(var(--border));
  font-size: 13px;
}
.im-preview strong { font-size: 16px; font-variant-numeric: tabular-nums; }

.modal-foot .foot-spacer { flex: 1; }

/* The hidden attribute is a UA-stylesheet rule, so any author rule that sets
   display (.btn is inline-flex, step panels are flex) silently defeats it.
   This restores hidden as the last word, wherever it is used. */
[hidden] { display: none !important; }

/* Add-item modal: one field per row with consistent breathing room. */
[data-step] { display: flex; flex-direction: column; gap: 14px; }
[data-step] .grid-2 { gap: 12px; }
[data-step] .field-note { margin-top: 5px; }

/* Inline discount control in the item table. */
.it-disc { display: flex; gap: 5px; align-items: center; min-width: 150px; }
.it-disc .input-sm { padding: 4px 8px; font-size: 12px; }
.it-disc select { max-width: 68px; }
.it-disc input { max-width: 78px; }

/* ── Navigation loading ────────────────────────────────────────
   Shown while the next page is being fetched. The overlay lives on the
   outgoing page and dies with it when the new document renders. */

.nav-loading {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: rgb(var(--bg) / 0.55);
  backdrop-filter: blur(1.5px);
  -webkit-backdrop-filter: blur(1.5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
/* Held back briefly: a fast page would otherwise flash the spinner. */
.nav-loading.is-on { opacity: 1; pointer-events: auto; }

.nav-loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 26px 34px;
  border-radius: 16px;
  background: rgb(var(--surface));
  border: var(--hairline) solid rgb(var(--border));
  box-shadow: 0 18px 44px -20px rgb(2 6 23 / 0.35);
}
.nav-spinner {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 3px solid rgb(var(--border));
  border-top-color: rgb(var(--text));
  animation: nav-spin 0.7s linear infinite;
}
@keyframes nav-spin { to { transform: rotate(360deg); } }
.nav-loading-label { font-size: 14px; font-weight: 500; }

@media (prefers-reduced-motion: reduce) {
  .nav-spinner { animation-duration: 2s; }
  .nav-loading { transition: none; }
}
@media print { .nav-loading { display: none !important; } }

/* One-time code entry: wide tracking so six digits read as separate figures. */
.otp-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 12px;
  text-align: center;
  padding: 12px;
}

/* ── Admin ─────────────────────────────────────────────────── */

.admin-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
  margin: 0 0 18px;
  border-bottom: var(--hairline) solid rgb(var(--border));
}
.admin-tabs a {
  padding: 9px 14px;
  font-size: 13.5px; font-weight: 500;
  color: rgb(var(--muted));
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.admin-tabs a:hover { color: rgb(var(--text)); }
.admin-tabs a.active {
  color: rgb(var(--brand-700));
  border-bottom-color: rgb(var(--brand));
}

/* Platform notices, by tone. */
.notice-info { }
.notice-warning {
  background: rgb(245 158 11 / 0.09);
  border-color: rgb(245 158 11 / 0.3);
  color: #92400e;
}
.notice-critical {
  background: rgb(244 63 94 / 0.09);
  border-color: rgb(244 63 94 / 0.3);
  color: #9f1239;
}
@media (prefers-color-scheme: dark) {
  .notice-warning { color: #fcd34d; }
  .notice-critical { color: #fda4af; }
}

/* Stack trace in the admin error log. */
.error-stack {
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgb(var(--bg));
  border: var(--hairline) solid rgb(var(--border));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.55;
  color: rgb(var(--muted));
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 260px;
}
