/* Billia — main stylesheet. No frameworks, no build step. */
:root {
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #eef2f7;
  --bg: #f8fafc;
  --card: #ffffff;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --accent-soft: #eef2ff;
  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #d97706;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 2px 4px rgba(15, 23, 42, .06), 0 20px 44px -16px rgba(15, 23, 42, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 1200px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 18px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--ink); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800;
}
.nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.nav a { color: var(--ink-soft); font-weight: 600; font-size: 14.5px; padding: 8px 12px; border-radius: 8px; }
.nav a:hover { background: var(--line-soft); text-decoration: none; color: var(--ink); }
.nav .btn { margin-left: 8px; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 10px;
  font: 600 15px/1 var(--font); padding: 12px 20px; cursor: pointer;
  transition: transform .06s ease, box-shadow .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px -6px rgba(79, 70, 229, .5); }
.btn-primary:hover { background: var(--accent-dark); }
.btn-secondary { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn-ghost { background: transparent; color: var(--muted); padding: 8px 10px; font-size: 14px; }
.btn-ghost:hover { color: var(--red); background: var(--red-soft); }
.btn-sm { padding: 8px 14px; font-size: 13.5px; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea {
  font: 500 15px var(--font); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; background: #fff; width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { resize: vertical; min-height: 74px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ---------- hero ---------- */
.hero { padding: 72px 0 40px; text-align: center; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--green-soft); color: var(--green);
  font-weight: 700; font-size: 13.5px; padding: 7px 14px; border-radius: 999px;
  border: 1px solid #a7f3d0; margin-bottom: 20px;
}
.hero h1 { font-size: clamp(32px, 5vw, 52px); letter-spacing: -.03em; line-height: 1.12; margin: 0 0 16px; }
.hero h1 .free { color: var(--accent); }
.hero p.sub { font-size: 18px; color: var(--muted); max-width: 640px; margin: 0 auto 28px; }
.hero-ctas { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-trust { margin-top: 22px; color: var(--faint); font-size: 13.5px; display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.hero-trust span::before { content: "✓ "; color: var(--green); font-weight: 700; }

/* ---------- builder ---------- */
.builder { padding: 24px 0 72px; }
.builder-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.builder-head h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }

.seg { display: inline-flex; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  border: 0; background: transparent; border-radius: 8px; cursor: pointer;
  font: 700 13.5px var(--font); color: var(--muted); padding: 9px 16px;
  display: inline-flex; align-items: center; gap: 7px;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.seg .dot { width: 22px; height: 16px; border-radius: 4px; border: 1px solid var(--line); display: inline-block; }

.builder-grid { display: grid; grid-template-columns: 430px 1fr; gap: 22px; align-items: start; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-pad { padding: 22px; }
.panel h3 { margin: 0 0 4px; font-size: 16px; letter-spacing: -.01em; }
.panel .hint { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
.section-title { font-size: 12px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin: 22px 0 12px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.section-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-thumb { width: 52px; height: 52px; border-radius: 10px; border: 1.5px dashed var(--line); object-fit: contain; background: #fff; display: none; }
.logo-thumb.show { display: block; }

.items-head { display: grid; grid-template-columns: 1fr 64px 90px 26px; gap: 8px; font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); margin-bottom: 6px; padding: 0 2px; }
.item-row { display: grid; grid-template-columns: 1fr 64px 90px 26px; gap: 8px; margin-bottom: 8px; align-items: center; }
.item-row input { font: 500 14px var(--font); border: 1.5px solid var(--line); border-radius: 8px; padding: 9px 10px; width: 100%; }
.item-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.item-del { border: 0; background: transparent; color: var(--faint); font-size: 18px; cursor: pointer; border-radius: 6px; line-height: 1; padding: 4px; }
.item-del:hover { color: var(--red); background: var(--red-soft); }
.add-item { width: 100%; margin-top: 4px; border-style: dashed; }

/* ---------- preview ---------- */
.preview-col { position: sticky; top: 84px; }
.preview-toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.preview-shell { background: #e8edf3; border: 1px solid var(--line); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); }
.doc { background: #fff; border-radius: 6px; box-shadow: var(--shadow-lg); padding: 48px 52px; min-height: 640px; font-size: 14px; color: var(--ink); }
.doc table { width: 100%; border-collapse: collapse; }
.doc .meta-row { display: flex; justify-content: space-between; gap: 24px; }

/* template: minimal */
.tpl-minimal .doc-kind { font-size: 30px; font-weight: 800; letter-spacing: .14em; color: #cbd5e1; text-align: right; margin: 0; }
.tpl-minimal .biz-name { font-size: 19px; font-weight: 800; margin: 0 0 4px; }
.tpl-minimal .small { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.tpl-minimal .doc-meta { text-align: right; font-size: 13px; color: var(--ink-soft); line-height: 1.9; }
.tpl-minimal .doc-meta b { color: var(--ink); }
.tpl-minimal .billto { margin: 30px 0 6px; font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--faint); text-transform: uppercase; }
.tpl-minimal .billto-name { font-weight: 700; font-size: 15px; }
.tpl-minimal table.items { margin-top: 18px; }
.tpl-minimal table.items th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 10px 8px; border-bottom: 2px solid var(--ink); }
.tpl-minimal table.items td { padding: 12px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tpl-minimal .num { text-align: right; font-variant-numeric: tabular-nums; }
.tpl-minimal .totals { width: 260px; margin: 18px 0 0 auto; font-size: 13.5px; }
.tpl-minimal .totals td { padding: 5px 0; }
.tpl-minimal .totals .grand td { font-size: 17px; font-weight: 800; border-top: 2px solid var(--ink); padding-top: 10px; }
.tpl-minimal .notes { margin-top: 34px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line-soft); padding-top: 14px; white-space: pre-line; }

/* template: modern */
.tpl-modern .doc { padding: 0; overflow: hidden; }
.tpl-modern .band { background: linear-gradient(120deg, #4f46e5, #7c3aed); color: #fff; padding: 36px 52px; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.tpl-modern .doc-kind { font-size: 34px; font-weight: 800; letter-spacing: .1em; margin: 0; }
.tpl-modern .biz-name { font-size: 18px; font-weight: 800; margin: 0 0 4px; }
.tpl-modern .band .small { color: rgba(255,255,255,.82); font-size: 12.5px; line-height: 1.6; }
.tpl-modern .body { padding: 34px 52px 48px; }
.tpl-modern .doc-meta { display: flex; gap: 34px; font-size: 13px; margin-bottom: 8px; flex-wrap: wrap; }
.tpl-modern .doc-meta .k { font-size: 10.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); display: block; }
.tpl-modern .doc-meta .v { font-weight: 700; }
.tpl-modern .billto { margin: 22px 0 4px; font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--accent); text-transform: uppercase; }
.tpl-modern .billto-name { font-weight: 700; font-size: 15px; }
.tpl-modern .small { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.tpl-modern table.items { margin-top: 16px; border-radius: 8px; overflow: hidden; }
.tpl-modern table.items th { background: var(--ink); color: #fff; text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 11px 12px; }
.tpl-modern table.items td { padding: 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.tpl-modern table.items tr:nth-child(even) td { background: #f8fafc; }
.tpl-modern .num { text-align: right; font-variant-numeric: tabular-nums; }
.tpl-modern .totals { width: 260px; margin: 18px 0 0 auto; font-size: 13.5px; }
.tpl-modern .totals td { padding: 5px 0; }
.tpl-modern .totals .grand td { font-size: 17px; font-weight: 800; color: var(--accent-dark); border-top: 2px solid var(--accent); padding-top: 10px; }
.tpl-modern .notes { margin-top: 30px; font-size: 12.5px; color: var(--muted); background: var(--accent-soft); border-radius: 8px; padding: 14px 16px; white-space: pre-line; }

/* template: classic */
.tpl-classic .doc-head { text-align: center; border-bottom: 3px double var(--ink); padding-bottom: 18px; margin-bottom: 8px; }
.tpl-classic .biz-name { font-size: 24px; font-weight: 800; margin: 0 0 4px; font-family: Georgia, "Times New Roman", serif; }
.tpl-classic .small { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.tpl-classic .doc-kind { font-size: 22px; font-weight: 800; letter-spacing: .22em; margin: 22px 0 4px; font-family: Georgia, "Times New Roman", serif; }
.tpl-classic .doc-meta { font-size: 13px; color: var(--ink-soft); line-height: 1.9; }
.tpl-classic .billto { margin: 24px 0 4px; font-size: 11px; font-weight: 800; letter-spacing: .1em; color: var(--faint); text-transform: uppercase; }
.tpl-classic .billto-name { font-weight: 700; font-size: 15px; }
.tpl-classic table.items { margin-top: 16px; border: 1px solid var(--line); }
.tpl-classic table.items th { text-align: left; font-size: 12px; padding: 10px 12px; border: 1px solid var(--line); background: #f1f5f9; }
.tpl-classic table.items td { padding: 11px 12px; border: 1px solid var(--line); vertical-align: top; }
.tpl-classic .num { text-align: right; font-variant-numeric: tabular-nums; }
.tpl-classic .totals { width: 280px; margin: 0 0 0 auto; font-size: 13.5px; border: 1px solid var(--line); border-top: 0; }
.tpl-classic .totals td { padding: 7px 12px; border-bottom: 1px solid var(--line-soft); }
.tpl-classic .totals .grand td { font-size: 16px; font-weight: 800; background: #f1f5f9; }
.tpl-classic .notes { margin-top: 28px; font-size: 12.5px; color: var(--muted); white-space: pre-line; }
.tpl-classic .notes .k { font-weight: 800; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); display: block; margin-bottom: 4px; }

.doc-logo { max-height: 56px; max-width: 180px; object-fit: contain; margin-bottom: 10px; display: block; }
.empty-line { color: var(--faint); font-style: italic; }

/* ---------- saved invoices ---------- */
.saved { padding: 0 0 72px; }
.saved-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.saved-head h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
.saved-head p { margin: 0; color: var(--muted); font-size: 14px; }
.saved-list { display: grid; gap: 10px; }
.saved-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
}
.saved-row .n { font-weight: 800; }
.saved-row .t { color: var(--muted); font-size: 13.5px; }
.saved-row .amt { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; }
.saved-row .actions { display: flex; gap: 6px; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; font: 600 13px var(--font); color: var(--ink-soft); padding: 7px 11px; cursor: pointer; }
.icon-btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.icon-btn.danger:hover { color: var(--red); border-color: #fecaca; background: var(--red-soft); }
.saved-empty { text-align: center; color: var(--muted); padding: 34px; border: 1.5px dashed var(--line); border-radius: 12px; background: #fff; font-size: 14.5px; }

/* ---------- faq / footer ---------- */
.faq { padding: 0 0 72px; }
.faq h2 { font-size: 22px; letter-spacing: -.02em; margin: 0 0 16px; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 16px 18px; }
.faq summary { font-weight: 700; cursor: pointer; font-size: 15.5px; }
.faq summary::marker { color: var(--accent); }
.faq details p { color: var(--muted); margin: 10px 0 0; font-size: 14.5px; }

.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 36px 0; color: var(--muted); font-size: 14px; }
.site-footer .wrap { display: flex; gap: 24px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.site-footer nav { display: flex; gap: 18px; }

/* ---------- pricing page ---------- */
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 860px; margin: 36px auto 72px; }
.plan { background: #fff; border: 1.5px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); position: relative; }
.plan.pro { border-color: var(--accent); }
.plan .flag { position: absolute; top: -13px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; font: 700 12px var(--font); letter-spacing: .06em; text-transform: uppercase; padding: 5px 14px; border-radius: 999px; }
.plan h2 { margin: 0 0 4px; font-size: 20px; }
.plan .price { font-size: 40px; font-weight: 800; letter-spacing: -.03em; margin: 12px 0 4px; }
.plan .price small { font-size: 15px; color: var(--muted); font-weight: 600; }
.plan ul { list-style: none; padding: 0; margin: 20px 0 24px; }
.plan li { padding: 8px 0 8px 28px; position: relative; font-size: 14.5px; color: var(--ink-soft); border-bottom: 1px solid var(--line-soft); }
.plan li::before { content: "✓"; position: absolute; left: 4px; color: var(--green); font-weight: 800; }
.plan li.soon::before { content: "◷"; color: var(--amber); }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; font: 600 14px var(--font);
  padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .builder-grid { grid-template-columns: 1fr; }
  .preview-col { position: static; }
}
@media (max-width: 640px) {
  .hero { padding: 48px 0 28px; }
  .nav a:not(.btn) { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .preview-shell { padding: 12px; }
  .doc { padding: 28px 22px; min-height: 0; }
  .tpl-modern .band { padding: 26px; flex-direction: column; }
  .tpl-modern .body { padding: 24px 22px 32px; }
  .plans { grid-template-columns: 1fr; }
  .preview-toolbar .btn { flex: 1; }
  .doc .meta-row { flex-direction: column; }
  .tpl-minimal .doc-kind, .tpl-minimal .doc-meta { text-align: left; }
}

/* ---------- print: only the invoice ---------- */
@media print {
  .site-header, .hero, .builder-head, .form-col, .preview-toolbar,
  .saved, .faq, .site-footer, .toast { display: none !important; }
  body { background: #fff; }
  .builder, .builder-grid { display: block; padding: 0; }
  .preview-shell { border: 0; padding: 0; box-shadow: none; background: #fff; }
  .doc { box-shadow: none; border-radius: 0; }
  .wrap { max-width: none; padding: 0; }
}
