/* ==========================================================================
   InvoiceBolt — styles.css
   Concept: a precision financial instrument (cool porcelain control surface)
   beside a warm floating paper document. Money & metadata are set in a
   monospaced tabular face; prose in a clean humanist sans. Signature devices:
   the amber bolt mark and a perforated tear-line divider on the invoice.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Neutrals — cool porcelain, not cream */
  --bg:        #EDEFF3;
  --bg-grid:   #E4E7EE;
  --surface:   #FFFFFF;
  --surface-2: #F6F7F9;
  --ink:       #191B22;
  --ink-soft:  #565D6E;
  --ink-faint: #878E9F;
  --line:      #E4E7EC;
  --line-soft: #EEF0F4;

  /* Brand */
  --accent:      #3B2FE0;  /* electric indigo */
  --accent-ink:  #2A20B8;  /* darker for hover/active */
  --accent-wash: #ECEBFC;  /* tint */
  --spark:       #FFB627;  /* amber bolt */
  --spark-ink:   #B4780A;

  --good:   #12A150;
  --danger: #E4484D;
  --danger-wash: #FCECED;

  /* Invoice accent — overridden per-invoice by app.js on .paper */
  --inv-accent: #3B2FE0;

  /* Type */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", "Segoe UI Mono", "Roboto Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Radius / shadow / spacing */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 40, .06), 0 1px 1px rgba(20, 24, 40, .04);
  --shadow:    0 4px 14px rgba(23, 27, 48, .08), 0 1px 3px rgba(23, 27, 48, .06);
  --shadow-lg: 0 24px 60px -18px rgba(23, 27, 48, .30), 0 8px 20px -12px rgba(23, 27, 48, .22);
  --shadow-paper: 0 30px 60px -24px rgba(23, 27, 48, .28), 0 2px 8px rgba(23, 27, 48, .08);

  --maxw: 1320px;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 26px 26px;
  background-position: -1px -1px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-size: 15px;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; }
p { margin: 0; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; }
input, select, textarea, button { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
svg { fill: none; }

.ico { width: 18px; height: 18px; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.is-hidden { display: none !important; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--ink-faint); }
.ta-r { text-align: right; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1, "zero" 1; }

/* ---------- Focus ---------- */
:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 200;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-sm);
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; text-decoration: none; }

/* ---------- Eyebrow ---------- */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--ink);
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 14px; font-weight: 600; letter-spacing: -0.01em;
  cursor: pointer; white-space: nowrap;
  transition: background .14s ease, border-color .14s ease, transform .06s ease, box-shadow .14s ease;
}
.btn:hover { border-color: #d3d8e0; }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 17px; height: 17px; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }

.btn-soft { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.btn-soft:hover { background: #eef0f4; }

.btn-dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-dark:hover { background: #000; border-color: #000; }

.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 10px -2px rgba(59,47,224,.5); }
.btn-accent:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-accent .ico { stroke-width: 2; }

.btn-upgrade {
  background: linear-gradient(180deg, #24262E, #16171C);
  border-color: #16171C; color: #fff;
}
.btn-upgrade .ico { color: var(--spark); }
.btn-upgrade:hover { background: #000; }

.btn-block { display: flex; justify-content: center; width: 100%; }
.btn-label-short { display: none; }
.btn[disabled], .btn.is-disabled { opacity: .55; cursor: not-allowed; }
.btn[disabled]:active { transform: none; }

.link-btn {
  background: none; border: none; padding: 0; margin: 0;
  color: var(--accent); font-weight: 600; font-size: inherit; cursor: pointer;
}
.link-btn:hover { text-decoration: underline; }

/* Pro tag chip */
.pro-tag {
  display: inline-block; font-family: var(--font-mono);
  font-size: 9.5px; font-weight: 700; letter-spacing: .08em;
  padding: 1px 5px; border-radius: 5px; vertical-align: middle;
  background: var(--spark); color: #3a2600; text-transform: uppercase;
  margin-left: 4px;
}
body.is-pro .pro-tag { display: none; }

/* ==========================================================================
   Header
   ========================================================================== */
.app-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(237,239,243,.82);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-header-inner {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 11px 20px;
}
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; filter: drop-shadow(0 2px 4px rgba(23,27,48,.18)); }
.brand-mark svg { display: block; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name { font-weight: 800; font-size: 18px; letter-spacing: -0.03em; }
.brand-tag { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .04em; color: var(--ink-faint); }

.app-actions { display: flex; align-items: center; gap: 6px; }

.pro-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: .06em;
  padding: 5px 11px; border-radius: 20px;
  background: #ECFBF2; color: #0B7A3D; border: 1px solid #BDECD0;
}
.pro-pill-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(18,161,80,.18); }

/* ==========================================================================
   Mobile view toggle
   ========================================================================== */
.view-toggle {
  display: none;
  position: sticky; top: 57px; z-index: 40;
  gap: 4px; padding: 8px 12px;
  background: rgba(237,239,243,.9);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.view-toggle-btn {
  flex: 1; padding: 9px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-soft); font-weight: 600; cursor: pointer;
}
.view-toggle-btn.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ==========================================================================
   Workspace
   ========================================================================== */
.workspace {
  max-width: var(--maxw); margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 26px; padding: 26px 20px 60px;
  align-items: start;
}

/* ---- Editor ---- */
.editor { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.editor-hint {
  display: flex; gap: 10px; align-items: baseline;
  font-size: 13px; color: var(--ink-soft);
  background: var(--accent-wash); border: 1px solid #DAD7F8;
  padding: 11px 14px; border-radius: var(--r);
}
.editor-hint strong { color: var(--accent-ink); font-weight: 700; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 10px; letter-spacing: -0.01em; }
.card-num {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 22px; padding: 0 7px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: .02em;
  color: var(--accent); background: var(--accent-wash);
  border-radius: 6px; text-transform: uppercase;
}
.card-tools { display: flex; gap: 14px; font-size: 12.5px; }

/* Form grid */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field label, .field-label-row label { font-size: 12px; font-weight: 600; color: var(--ink-soft); letter-spacing: .01em; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; }

input[type=text], input[type=email], input[type=tel], input[type=number],
input[type=date], select, textarea {
  width: 100%; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink);
  font-size: 14px; transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
input::placeholder, textarea::placeholder { color: #b6bcc9; }
input:hover, select:hover, textarea:hover { border-color: #d2d7df; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,47,224,.14); background: var(--surface);
}
textarea { resize: vertical; min-height: 44px; line-height: 1.5; }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23565D6E' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 32px;
}
/* Money inputs use tabular figures */
input[type=number] { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Logo uploader */
.field-logo { gap: 7px; }
.logo-drop {
  position: relative; border: 1.5px dashed var(--line); border-radius: var(--r);
  background: var(--surface-2); min-height: 88px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: border-color .14s ease, background .14s ease;
  overflow: hidden;
}
.logo-drop:hover { border-color: var(--accent); background: #fff; }
.logo-drop.is-drag { border-color: var(--accent); background: var(--accent-wash); }
.logo-empty { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-faint); text-align: center; padding: 12px; }
.logo-empty .ico { width: 24px; height: 24px; stroke: var(--ink-faint); margin-bottom: 2px; }
.logo-empty span { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.logo-empty small { font-size: 11px; }
.logo-preview { max-height: 74px; max-width: 82%; object-fit: contain; padding: 8px; }

/* ==========================================================================
   Line items editor
   ========================================================================== */
.items { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.items-head, .li-row {
  display: grid;
  grid-template-columns: minmax(0,1fr) 62px 88px 96px 30px;
  gap: 8px; align-items: center;
}
.items-head {
  padding: 8px 12px; background: var(--surface-2);
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint);
  border-bottom: 1px solid var(--line);
}
.items-body .li-row { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); }
.items-body .li-row:last-child { border-bottom: none; }
.li-row input { padding: 7px 9px; min-width: 0; }
.li-row .li-qty, .li-row .li-rate { text-align: right; font-family: var(--font-mono); }
.li-amt {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  text-align: right; font-size: 13.5px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.li-del {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--ink-faint);
  border-radius: 7px; cursor: pointer; font-size: 18px; line-height: 1;
  transition: background .12s, color .12s;
}
.li-del:hover { background: var(--danger-wash); color: var(--danger); }
.li-del:disabled { opacity: .3; cursor: not-allowed; }
.li-del:disabled:hover { background: transparent; color: var(--ink-faint); }

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

/* ==========================================================================
   Swatches
   ========================================================================== */
.swatches { display: flex; flex-wrap: wrap; gap: 9px; }
.swatch {
  position: relative; width: 34px; height: 34px; border-radius: 9px;
  border: 2px solid transparent; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 2px #fff, 0 1px 3px rgba(0,0,0,.14);
  transition: transform .1s ease;
}
.swatch:hover { transform: translateY(-2px); }
.swatch.is-active { border-color: var(--ink); }
.swatch.is-locked::after {
  content: ""; position: absolute; right: -3px; bottom: -3px;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--spark) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9' viewBox='0 0 24 24' fill='none' stroke='%233a2600' stroke-width='3' stroke-linecap='round'%3E%3Crect x='5' y='11' width='14' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E") center/9px no-repeat;
  border: 1.5px solid #fff;
}
body.is-pro .swatch.is-locked::after { display: none; }
.accent-note { margin-top: 12px; font-size: 12.5px; color: var(--ink-faint); }

/* ==========================================================================
   Preview / paper
   ========================================================================== */
.preview { position: sticky; top: 80px; min-width: 0; }
.preview-stage {
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(59,47,224,.05), transparent 70%);
  padding: 6px; border-radius: var(--r-lg);
}
.preview-foot { text-align: center; font-size: 12px; margin-top: 12px; font-family: var(--font-mono); letter-spacing: .03em; }

.paper {
  background: var(--surface); border-radius: 14px;
  box-shadow: var(--shadow-paper);
  overflow: hidden;
  /* A4 aspect ratio feel; height grows with content */
  max-width: 620px; margin: 0 auto;
  print-color-adjust: exact; -webkit-print-color-adjust: exact;
}

/* Invoice document */
.inv { color: #14161c; font-size: 13px; }
.inv-band { height: 9px; background: var(--inv-accent); print-color-adjust: exact; -webkit-print-color-adjust: exact; }
.inv-inner { padding: 34px 38px 40px; }

.inv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.inv-brand { min-width: 0; }
.inv-logo { max-height: 60px; max-width: 220px; object-fit: contain; margin-bottom: 8px; }
.inv-bizname { font-size: 20px; font-weight: 800; letter-spacing: -0.03em; color: #14161c; word-break: break-word; }
.inv-bizmeta { margin-top: 6px; font-size: 12px; color: #565d6e; white-space: pre-line; line-height: 1.5; word-break: break-word; }

.inv-title { text-align: right; flex-shrink: 0; }
.inv-word {
  font-family: var(--font-mono); font-size: 26px; font-weight: 700;
  letter-spacing: .22em; text-transform: uppercase; color: var(--inv-accent);
  print-color-adjust: exact; -webkit-print-color-adjust: exact;
}
.inv-number { font-family: var(--font-mono); font-size: 13px; color: #565d6e; margin-top: 4px; }
.inv-status { margin-top: 8px; }

/* Perforated divider — the signature */
.inv-perf {
  height: 1px; margin: 22px 0;
  background-image: radial-gradient(circle, #c4c9d4 1.1px, transparent 1.3px);
  background-size: 9px 2px; background-repeat: repeat-x; background-position: left center;
  print-color-adjust: exact; -webkit-print-color-adjust: exact;
}

.inv-parties { display: grid; grid-template-columns: 1.2fr 1fr; gap: 22px; }
.inv-block-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase; color: #9298a6; margin-bottom: 5px;
}
.inv-party-name { font-weight: 700; font-size: 14px; color: #14161c; word-break: break-word; }
.inv-party-meta { font-size: 12px; color: #565d6e; white-space: pre-line; line-height: 1.5; margin-top: 3px; word-break: break-word; }

.inv-meta-grid { display: grid; grid-template-columns: auto auto; gap: 6px 14px; justify-content: end; align-content: start; }
.inv-meta-k { font-size: 11.5px; color: #9298a6; text-align: right; }
.inv-meta-v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12.5px; color: #14161c; text-align: right; font-weight: 600; }

/* Items table */
.inv-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.inv-table thead th {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: #9298a6;
  text-align: left; padding: 9px 0; border-bottom: 1.5px solid #14161c;
}
.inv-table th.c-qty, .inv-table th.c-rate, .inv-table th.c-amt,
.inv-table td.c-qty, .inv-table td.c-rate, .inv-table td.c-amt { text-align: right; }
.inv-table tbody td { padding: 10px 0; border-bottom: 1px solid #eceef2; vertical-align: top; font-size: 12.5px; }
.inv-table td.c-desc { color: #14161c; padding-right: 14px; word-break: break-word; }
.inv-desc-name { font-weight: 600; }
.inv-table td.c-qty, .inv-table td.c-rate, .inv-table td.c-amt {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: #14161c; white-space: nowrap; padding-left: 10px;
}
.inv-table td.c-amt { font-weight: 600; }
.inv-table td.c-qty, .inv-table td.c-rate { color: #565d6e; }

/* Totals */
.inv-totals { display: flex; justify-content: flex-end; margin-top: 16px; }
.inv-totals-box { width: min(280px, 100%); }
.inv-trow { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; font-size: 12.5px; }
.inv-trow .t-k { color: #565d6e; }
.inv-trow .t-v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: #14161c; font-weight: 600; }
.inv-trow.is-discount .t-v { color: #12A150; }
.inv-total-final {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 8px; padding: 12px 14px; border-radius: 10px;
  background: var(--inv-accent); color: #fff;
  print-color-adjust: exact; -webkit-print-color-adjust: exact;
}
.inv-total-final .t-k { font-size: 12px; font-weight: 600; letter-spacing: .02em; opacity: .92; text-transform: uppercase; font-family: var(--font-mono); }
.inv-total-final .t-v { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 19px; font-weight: 700; }

/* Notes */
.inv-notes { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 24px; }
.inv-note-block { font-size: 12px; }
.inv-note-block .inv-block-label { margin-bottom: 6px; }
.inv-note-body { color: #3f4552; white-space: pre-line; line-height: 1.55; word-break: break-word; }
.inv-note-block.full { grid-column: 1 / -1; }

.inv-thanks {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid #eceef2;
  text-align: center; font-size: 12.5px; color: #565d6e; white-space: pre-line; word-break: break-word;
}

/* Watermark (free tier) */
.inv-wm {
  margin-top: 20px; text-align: center;
  font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em; color: #aeb4c0;
}
body.is-pro .inv-wm { display: none; }

/* Empty-state placeholders inside preview */
.inv .is-empty { color: #b8bdc9; font-style: italic; }

/* ==========================================================================
   Lander / benefits
   ========================================================================== */
.lander { border-top: 1px solid var(--line); background: var(--surface); }
.lander-inner { max-width: var(--maxw); margin: 0 auto; padding: 64px 20px; }
.lander-title { font-size: clamp(24px, 3.4vw, 36px); font-weight: 800; max-width: 20ch; letter-spacing: -0.03em; }
.benefits { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-top: 40px; }
.benefit {
  padding: 22px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface-2);
}
.benefit-ico {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 11px; margin-bottom: 14px;
  background: var(--ink); color: var(--spark);
}
.benefit-ico svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.benefit h3 { font-size: 16px; margin-bottom: 7px; letter-spacing: -0.02em; }
.benefit p { font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; }

/* ==========================================================================
   FAQ
   ========================================================================== */
.faq { border-top: 1px solid var(--line); }
.faq-inner { max-width: 820px; margin: 0 auto; padding: 64px 20px; }
.faq-list { margin-top: 34px; display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 4px 18px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.faq-item[open] { border-color: #d6dae2; box-shadow: var(--shadow-sm); }
.faq-item summary {
  cursor: pointer; list-style: none; padding: 15px 0;
  font-weight: 700; font-size: 15px; letter-spacing: -0.01em;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+"; font-family: var(--font-mono); font-size: 20px; font-weight: 400;
  color: var(--accent); transition: transform .18s ease; flex-shrink: 0;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item p { padding: 0 0 16px; color: var(--ink-soft); font-size: 14px; line-height: 1.6; max-width: 68ch; }

/* ==========================================================================
   Site footer
   ========================================================================== */
.site-foot { border-top: 1px solid var(--line); background: var(--surface); }
.site-foot-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 32px 20px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.site-foot-brand { display: flex; align-items: center; gap: 11px; font-size: 14px; color: var(--ink-soft); font-weight: 500; }
.site-foot-links { display: flex; align-items: center; gap: 22px; font-size: 14px; font-weight: 600; }
.site-foot-links a, .site-foot-links .link-btn { color: var(--ink-soft); }
.site-foot-links a:hover, .site-foot-links .link-btn:hover { color: var(--ink); }
.site-foot-fine { max-width: var(--maxw); margin: 0 auto; padding: 0 20px 32px; font-size: 12px; font-family: var(--font-mono); letter-spacing: .02em; }

/* ==========================================================================
   Modals
   ========================================================================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 17, 26, .55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  position: relative; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 620px; max-height: 90vh; overflow: auto;
  animation: pop .2s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-x {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  width: 34px; height: 34px; border-radius: 9px; border: none;
  background: var(--surface-2); color: var(--ink-soft); font-size: 22px; line-height: 1; cursor: pointer;
}
.modal-x:hover { background: var(--line); color: var(--ink); }
.modal-body { padding: 30px; }
.modal-title { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 6px; max-width: 22ch; }
.modal-sub { font-size: 13.5px; margin-bottom: 18px; }

.pro-list { list-style: none; padding: 0; margin: 18px 0 24px; display: grid; gap: 9px; }
.pro-list li { position: relative; padding-left: 28px; font-size: 14.5px; font-weight: 500; }
.pro-list li::before {
  content: ""; position: absolute; left: 0; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--good) 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='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center/12px no-repeat;
}

.upgrade-cols { display: grid; grid-template-columns: 1fr auto 1fr; gap: 18px; align-items: center; }
.upgrade-or { color: var(--ink-faint); font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; text-align: center; }
.upgrade-buy, .upgrade-verify { display: flex; flex-direction: column; gap: 8px; }
.upgrade-verify label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.upgrade-fine { font-size: 11.5px; text-align: center; }
.verify-row { display: flex; gap: 8px; }
.verify-row input { flex: 1; font-family: var(--font-mono); font-size: 12.5px; }
.verify-msg { font-size: 12.5px; min-height: 18px; margin-top: 2px; }
.verify-msg.is-error { color: var(--danger); }
.verify-msg.is-ok { color: var(--good); }
.verify-msg.is-busy { color: var(--ink-faint); }

/* Lists (clients / history) */
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2);
}
.list-item-main { min-width: 0; }
.list-item-title { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item-sub { font-size: 12px; color: var(--ink-faint); font-family: var(--font-mono); margin-top: 2px; }
.list-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.list-item-actions .btn { padding: 6px 10px; font-size: 12.5px; }
.icon-btn {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--surface); border-radius: 8px; cursor: pointer; color: var(--ink-soft);
}
.icon-btn:hover { border-color: #d3d8e0; color: var(--ink); }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-wash); }
.empty { text-align: center; color: var(--ink-faint); font-size: 13.5px; padding: 26px 10px; }

.history-actions { margin-bottom: 14px; }
.backup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.backup-card { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.backup-card h3 { font-size: 15px; }
.backup-card p { font-size: 12.5px; line-height: 1.5; flex: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 150; background: var(--ink); color: #fff;
  padding: 11px 18px; border-radius: 11px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow-lg); animation: toastin .22s ease;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.is-error { background: var(--danger); }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 12px); } }

/* ==========================================================================
   Legal pages
   ========================================================================== */
.legal-body { background-image: none; background: var(--bg); }
.legal-top {
  max-width: 820px; margin: 0 auto; padding: 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.legal-back { font-size: 13.5px; font-weight: 600; color: var(--ink-soft); }
.legal-wrap { max-width: 760px; margin: 0 auto; padding: 10px 20px 80px; }
.legal {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 44px 48px; box-shadow: var(--shadow-sm);
}
.legal h1 { font-size: clamp(28px, 5vw, 40px); font-weight: 800; letter-spacing: -0.03em; }
.legal-lede { font-size: 17px; color: var(--ink-soft); margin-top: 12px; line-height: 1.5; }
.legal-updated { font-family: var(--font-mono); font-size: 12px; color: var(--ink-faint); margin-top: 8px; }
.legal h2 { font-size: 17px; margin-top: 30px; margin-bottom: 6px; }
.legal p { color: var(--ink-soft); font-size: 14.5px; line-height: 1.65; margin-top: 6px; }
.legal code { font-family: var(--font-mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 5px; color: var(--ink); }
.legal-foot { margin-top: 26px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13.5px; color: var(--ink-soft); }
.legal-foot a { font-weight: 600; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1080px) {
  .workspace { grid-template-columns: 1fr; }
  .preview { position: static; }
  .paper { max-width: 640px; }
  .benefits { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  .btn .btn-label { display: none; }
  .btn .btn-label-short { display: inline; }
  .btn { padding: 9px; }
  .btn-accent, .btn-upgrade { padding: 9px 12px; }
  .app-header-inner { padding: 10px 14px; }
  .brand-tag { display: none; }

  /* Mobile: toggle between edit and preview */
  .view-toggle { display: flex; }
  .workspace { padding-top: 14px; }
  .workspace.show-preview .editor { display: none; }
  .workspace.show-edit .preview { display: none; }
  .preview { position: static; }

  .upgrade-cols { grid-template-columns: 1fr; }
  .upgrade-or { padding: 4px 0; }
  .backup-grid { grid-template-columns: 1fr; }
  .modal-body { padding: 24px 20px; }
  .inv-inner { padding: 24px 22px 30px; }
}

@media (max-width: 560px) {
  .brand-text { display: none; }
  .app-actions { gap: 4px; }
  .app-actions .btn { padding: 8px; }
  .app-actions .ico { width: 16px; height: 16px; }
  .btn-accent { padding: 8px 11px; }
  .btn-upgrade { padding: 8px; }
  .btn-upgrade .btn-label-short { display: none; } /* Upgrade → icon-only on phones */
  .benefits { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .inv-parties { grid-template-columns: 1fr; gap: 16px; }
  .inv-notes { grid-template-columns: 1fr; }
  .inv-head { flex-direction: column; }
  .inv-title { text-align: left; }
  .inv-meta-grid { justify-content: start; }
  .inv-meta-k, .inv-meta-v { text-align: left; }
  .items-head { display: none; }
  .li-row { grid-template-columns: 1fr 1fr; gap: 6px 8px; position: relative; padding-right: 34px; }
  .li-row .li-desc { grid-column: 1 / -1; }
  .li-amt { grid-column: 1 / -1; text-align: left; padding-top: 2px; }
  .li-del { position: absolute; right: 4px; top: 8px; }
  .legal { padding: 28px 22px; }
}

@media (max-width: 380px) {
  .app-actions { gap: 3px; }
  .btn { padding: 8px; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ==========================================================================
   PRINT — only the invoice paper, black on white, no app chrome
   ========================================================================== */
@media print {
  @page { margin: 12mm; }

  html, body {
    background: #fff !important;
    background-image: none !important;
    font-size: 12px;
  }

  /* Hide everything that isn't the invoice */
  .app-header, .view-toggle, .editor, .preview-foot,
  .lander, .faq, .site-foot, .toast, .skip-link,
  .modal-backdrop { display: none !important; }

  .workspace { display: block !important; max-width: none; padding: 0 !important; margin: 0; }
  .workspace.show-edit .preview, .workspace.show-preview .editor { display: block !important; }
  .preview { position: static !important; display: block !important; }
  .preview-stage { padding: 0 !important; background: none !important; border-radius: 0 !important; }

  .paper {
    max-width: none !important; width: 100% !important; margin: 0 !important;
    box-shadow: none !important; border-radius: 0 !important; overflow: visible !important;
  }

  .inv { font-size: 11.5px; }
  .inv-inner { padding: 0 !important; padding-top: 14px !important; }
  .inv-band { height: 7px !important; }

  /* Keep table rows from splitting awkwardly */
  .inv-table tbody tr { page-break-inside: avoid; }
  .inv-totals, .inv-total-final { page-break-inside: avoid; }

  /* Force accent/ink backgrounds to print */
  .inv-band, .inv-total-final, .inv-word { print-color-adjust: exact !important; -webkit-print-color-adjust: exact !important; }
}
