/* Tallyline — styles.css
   Light and dark follow the system setting. No external assets. */

:root {
  color-scheme: light dark;
  --bg: #f6f4f0;
  --surface: #fffefb;
  --surface-2: #f0ebe4;
  --text: #1a1815;
  --muted: #5d574e;
  --border: #e0d9cf;
  --border-strong: #c3baad;
  --accent: #14506e;
  --accent-hover: #0e3d56;
  --accent-soft: #e5eef4;
  --on-accent: #ffffff;
  --income: #14603b;
  --expense: #9a3327;
  --chart-expense: #b6ada0;
  --focus: #14506e;
  --radius: 8px;
  --radius-sm: 6px;
  --maxw: 1080px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141311;
    --surface: #1c1a17;
    --surface-2: #25221e;
    --text: #ece7df;
    --muted: #a9a196;
    --border: #33302a;
    --border-strong: #4b463e;
    --accent: #8ec3df;
    --accent-hover: #abd5ea;
    --accent-soft: #1a2a33;
    --on-accent: #0a2330;
    --income: #83cfa5;
    --expense: #f09b8c;
    --chart-expense: #5a544a;
    --focus: #8ec3df;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  margin: 0 0 12px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

p { margin: 0 0 16px; }
ul, ol { margin: 0 0 16px; padding-left: 22px; }
li { margin: 0 0 8px; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }
svg { display: block; }
hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 24px; } }

.muted { color: var(--muted); }
.small { font-size: 0.86rem; line-height: 1.5; }
.hint { color: var(--muted); font-weight: 400; }
.money, .num, .metric-value, .sample-balance, .invoice-paper { font-variant-numeric: tabular-nums; }
.income { color: var(--income); }
.expense { color: var(--expense); }
[hidden] { display: none !important; }

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

.skip-link {
  position: absolute;
  left: 16px; top: -60px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--text); }
.brand-mark { width: 26px; height: 26px; flex: none; }

.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a:not(.btn) {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 0.94rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.site-nav a:not(.btn):hover { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current="page"]:not(.btn) { color: var(--text); font-weight: 600; }

@media (max-width: 719px) {
  .site-nav a.nav-secondary { display: none; }
  .site-nav { gap: 2px; }
  .site-nav a:not(.btn) { padding: 0 6px; }
  .header-inner { min-height: 60px; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover { border-color: var(--text); color: var(--text); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-danger { background: transparent; border-color: var(--expense); color: var(--expense); }
.btn-danger:hover { background: var(--expense); border-color: var(--expense); color: #fff; }
.btn-block { width: 100%; }
.btn-xs { min-height: 44px; padding: 0 10px; font-size: 0.86rem; }
.btn:disabled, .btn-disabled {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}
.btn-sm { min-height: 44px; padding: 0 14px; font-size: 0.9rem; }

/* ---------- Landing ---------- */

.hero { padding: 40px 0 32px; }
@media (min-width: 860px) { .hero { padding: 64px 0 48px; } }

.hero-grid { display: grid; gap: 32px; align-items: start; }
@media (min-width: 900px) {
  .hero-grid { grid-template-columns: 1.05fr 0.95fr; gap: 56px; align-items: center; }
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero h1 {
  margin: 0 0 20px;
  font-size: clamp(2.15rem, 5.4vw, 3.4rem);
  line-height: 1.03;
  letter-spacing: -0.03em;
}

.lede {
  max-width: 34em;
  margin: 0 0 26px;
  color: var(--muted);
  font-size: clamp(1rem, 1.7vw, 1.1rem);
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-note { margin: 16px 0 0; color: var(--muted); font-size: 0.86rem; }

.sample {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sample-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.sample-balance { margin: 0; font-size: 1.5rem; font-weight: 650; letter-spacing: -0.02em; }
.sample-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.sample-row:last-of-type { border-bottom: 0; }
.sample-row span:first-child { color: var(--text); }
.sample-row span:last-child { white-space: nowrap; font-weight: 600; }
.sample .small { margin: 12px 0 0; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.section { padding: 48px 0; border-top: 1px solid var(--border); }
@media (min-width: 720px) { .section { padding: 64px 0; } }
.section h2 { font-size: clamp(1.4rem, 3vw, 1.85rem); }
.section-intro { max-width: 46em; margin-bottom: 28px; color: var(--muted); }

.steps { display: grid; gap: 24px; margin: 0; padding: 0; list-style: none; }
@media (min-width: 780px) { .steps { grid-template-columns: repeat(3, 1fr); gap: 32px; } }
.steps li { display: flex; gap: 14px; margin: 0; }
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 30px; height: 30px;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
}
.steps h3 { margin: 2px 0 6px; font-size: 1rem; }
.steps p { margin: 0; color: var(--muted); font-size: 0.94rem; }

.cards { display: grid; gap: 16px; }
@media (min-width: 700px) { .cards { grid-template-columns: 1fr 1fr; gap: 20px; } }
.card {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
@media (min-width: 720px) { .card { padding: 24px; } }
.card h3 { margin: 0 0 8px; font-size: 1.02rem; }
.card p:last-child { margin-bottom: 0; }
.card p { color: var(--muted); font-size: 0.94rem; }
.card-icon { margin-bottom: 14px; color: var(--accent); }
.card-icon svg { width: 24px; height: 24px; }

.faq { border-top: 1px solid var(--border); }
details.faq { border-bottom: 1px solid var(--border); }
details.faq summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 44px;
  padding: 14px 0;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}
details.faq summary::-webkit-details-marker { display: none; }
details.faq summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 1.1rem; }
details.faq[open] summary::after { content: "\2013"; }
details.faq p { max-width: 62em; margin: 0 0 16px; color: var(--muted); font-size: 0.94rem; }

.about { max-width: 66em; }
.about p { max-width: 62em; }
.product-line { font-size: 1.02rem; }

/* ---------- Pricing / legal ---------- */

.page { padding: 40px 0 56px; }
@media (min-width: 720px) { .page { padding: 56px 0 72px; } }
.page h1 { font-size: clamp(1.9rem, 4vw, 2.6rem); }
.page-head { max-width: 46em; margin-bottom: 32px; }
.page-head p { color: var(--muted); }

.prose { max-width: 68ch; }
.prose h2 { margin-top: 32px; font-size: 1.2rem; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose li { color: var(--text); }
.prose .muted { color: var(--muted); }
.updated { color: var(--muted); font-size: 0.84rem; }

.compare-wrap { margin: 8px 0 24px; }
.compare {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.compare th, .compare td { padding: 12px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.compare thead th { font-size: 0.76rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.compare thead th:nth-child(2), .compare thead th:nth-child(3),
.compare td:nth-child(2), .compare td:nth-child(3) { text-align: center; width: 24%; }
.compare tbody tr:last-child td { border-bottom: 0; }
.compare td:first-child { font-weight: 500; }
.compare .pro-col { background: var(--accent-soft); }
.compare th.pro-col { color: var(--accent); }
@media (max-width: 420px) {
  .compare { font-size: 0.88rem; }
  .compare th, .compare td { padding: 10px 6px; }
}

.price-card {
  max-width: 560px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.price { margin: 0 0 4px; font-size: 1.6rem; font-weight: 650; letter-spacing: -0.02em; }
.price .cur { margin-left: 6px; color: var(--muted); font-size: 0.9rem; font-weight: 500; letter-spacing: 0; }
.price-terms { margin: 0 0 20px; color: var(--muted); font-size: 0.9rem; }
.checkout-note { margin: 12px 0 0; color: var(--muted); }
.checkout-note a { color: var(--accent); }

.policy-list { padding-left: 20px; }
.policy-list li { margin-bottom: 10px; }

.contact-block {
  max-width: 40em;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
}
.contact-block .email { font-size: 1.1rem; font-weight: 650; }

/* ---------- Footer ---------- */

.site-footer { margin-top: 40px; padding: 32px 0 40px; border-top: 1px solid var(--border); }
.footer-inner { display: grid; gap: 20px; }
@media (min-width: 700px) { .footer-inner { grid-template-columns: 1fr auto; align-items: start; } }
.footer-brand { margin: 0 0 4px; font-weight: 650; }
.footer-inner p { margin: 0 0 4px; }
.footer-nav { display: flex; flex-wrap: wrap; gap: 0 16px; }
.footer-nav a { display: inline-flex; align-items: center; min-height: 44px; color: var(--muted); font-size: 0.9rem; text-decoration: none; }
.footer-nav a:hover { color: var(--text); text-decoration: underline; }
.footer-bottom { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.footer-bottom p { margin: 0; color: var(--muted); font-size: 0.82rem; }

/* ---------- App shell ---------- */

.app-main { padding: 0 0 56px; }

.tabs {
  display: flex;
  gap: 2px;
  margin: 0 0 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
@media (min-width: 720px) { .tabs { margin: 0 0 24px; } }

.tab {
  appearance: none;
  flex: none;
  min-height: 48px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

.panel:focus { outline: none; }
.panel-head { margin-bottom: 16px; }
.panel-head h2 { margin: 0 0 4px; font-size: 1.35rem; }
.panel-head p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.notice {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-left-width: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 0.92rem;
}
.notice a { margin-left: 4px; }
.notice-warn { border-left-color: var(--expense); }

/* Summary */

.summary {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
@media (min-width: 820px) {
  .summary { grid-template-columns: 1.3fr 1fr 1fr 1fr 150px; align-items: center; gap: 24px; }
}
.metric-label {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.metric-value { margin: 0; font-size: 1.18rem; font-weight: 650; letter-spacing: -0.01em; }
.metric-value.balance { font-size: 1.55rem; }
.balance-live { border-radius: 4px; }

/* Forms */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
label, legend, .label {
  display: block;
  margin: 0 0 6px;
  color: var(--text);
  font-size: 0.83rem;
  font-weight: 600;
}
legend { padding: 0; }
input[type="text"], input[type="email"], input[type="date"], input[type="month"],
input[type="number"], input[type="password"], select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
}
textarea { min-height: 72px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: var(--accent);
}
::placeholder { color: var(--muted); opacity: 0.8; }

.form-row { display: grid; gap: 0 12px; }
@media (min-width: 480px) { .form-row { grid-template-columns: 1fr 1fr; } }
.form-row .field { min-width: 0; }

fieldset.field { border: 0; padding: 0; margin: 0 0 14px; }

.segmented {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}
.segmented label { flex: 1; margin: 0; cursor: pointer; }
.segmented label span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}
.segmented input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segmented input:checked + span { background: var(--accent-soft); color: var(--accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -2px; }

.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.form-error {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--expense);
  border-radius: var(--radius-sm);
  color: var(--expense);
  background: var(--surface);
  font-size: 0.9rem;
}
.form-subhead {
  margin: 22px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.form-subhead:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.upgrade {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  font-size: 0.9rem;
}
.upgrade p { margin: 0; }
.upgrade strong { font-weight: 650; }

/* Tables */

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-bottom: 12px;
}
.card-head h2, .card-title { margin: 0; font-size: 1.02rem; }

.table-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}
.table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 0; }
.table th:last-child, .table td:last-child { padding-right: 0; }
.table .num { text-align: right; white-space: nowrap; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 2px; }
.entry-cat { display: block; font-weight: 550; }
.entry-meta { display: block; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }

@media (max-width: 700px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    margin-bottom: 10px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
  }
  .table tr:last-child { margin-bottom: 0; }
  .table td, .table td:first-child, .table td:last-child {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 0;
    border: 0;
    text-align: right;
  }
  .table td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    text-align: left;
  }
  .table td.row-actions { justify-content: flex-end; }
  .table td.row-actions::before { content: attr(data-label); }
  .entry-cat, .entry-meta { text-align: right; }
}

.empty { padding: 28px 8px; text-align: center; color: var(--muted); font-size: 0.92rem; }
.empty strong { display: block; margin-bottom: 4px; color: var(--text); font-size: 0.98rem; }

/* Ledger layout */

.ledger-grid { display: grid; gap: 16px; margin-bottom: 16px; }
@media (min-width: 900px) { .ledger-grid { grid-template-columns: 360px minmax(0, 1fr); align-items: start; } }

.chart-card { margin-top: 0; }
.chart-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 20px; margin-bottom: 8px; }
.chart-head h2 { margin: 0; font-size: 1.02rem; }
.chart-summary { margin: 0; color: var(--muted); font-size: 0.88rem; }
.chart { width: 100%; height: auto; display: block; margin-top: 8px; }
.chart-empty { padding: 24px 0 8px; color: var(--muted); font-size: 0.9rem; }
.grid-line { stroke: var(--border); stroke-width: 1; }
.chart-axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.bar-income { fill: var(--accent); }
.bar-expense { fill: var(--chart-expense); }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; color: var(--muted); font-size: 0.82rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.swatch-income { background: var(--accent); }
.swatch-expense { background: var(--chart-expense); }

/* Invoice form */

.item-row {
  display: grid;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: 0; padding-bottom: 0; }
.item-desc-wrap { min-width: 0; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.item-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.item-inline input {
  width: 68px;
  min-height: 44px;
  padding: 6px 8px;
  font-size: 0.9rem;
}
.item-inline input.item-unit { width: 100px; }
.item-line-total { margin-left: auto; color: var(--text); font-size: 0.88rem; }
.item-remove { flex: none; padding: 0 10px; }
@media (max-width: 619px) {
  .item-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; align-items: end; }
  .item-inline { flex-direction: column; align-items: stretch; gap: 4px; }
  .item-inline input, .item-inline input.item-unit { width: 100%; }
  .item-line-total { margin-left: 0; align-self: center; }
  .item-remove { margin-left: auto; }
}

.invoice-layout { display: grid; gap: 16px; margin-bottom: 16px; }
@media (min-width: 1000px) {
  .invoice-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 20px; }
  .invoice-preview-wrap { position: sticky; top: 84px; }
}

/* Invoice paper */

.invoice-paper {
  padding: 22px;
  background: #ffffff;
  color: #1b1a18;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.84rem;
  line-height: 1.45;
}
@media (min-width: 620px) { .invoice-paper { padding: 28px; } }
.invoice-paper h1, .invoice-paper h2, .invoice-paper h3 { letter-spacing: 0; }
.invoice-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px; }
.invoice-brand { min-width: 0; }
.invoice-brand-name { margin: 0 0 4px; font-size: 1.05rem; font-weight: 700; }
.invoice-brand-lines { margin: 0; color: #4b463f; font-size: 0.8rem; white-space: pre-line; }
.invoice-logo { display: block; max-width: 150px; max-height: 60px; margin-bottom: 10px; }
.invoice-meta { min-width: 150px; text-align: right; }
.invoice-meta h2 {
  margin: 0 0 4px;
  color: #6b655c;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.invoice-number { margin: 0; font-size: 1rem; font-weight: 700; }
.invoice-dates { margin: 8px 0 0; color: #4b463f; font-size: 0.78rem; }
.invoice-dates div { margin-bottom: 2px; }
.invoice-parties { display: grid; gap: 16px; margin: 22px 0; }
@media (min-width: 560px) { .invoice-parties { grid-template-columns: 1fr 1fr; } }
.invoice-label {
  margin: 0 0 4px;
  color: #6b655c;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.invoice-party { margin: 0; white-space: pre-line; color: #292623; }
.invoice-items { width: 100%; border-collapse: collapse; margin-top: 6px; }
.invoice-items th {
  padding: 6px 4px;
  border-bottom: 1px solid #d6cfc4;
  color: #6b655c;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}
.invoice-items td { padding: 8px 4px; border-bottom: 1px solid #e9e3d9; vertical-align: top; }
.invoice-items th:first-child, .invoice-items td:first-child { padding-left: 0; }
.invoice-items th:last-child, .invoice-items td:last-child { padding-right: 0; }
.invoice-items .num { text-align: right; white-space: nowrap; }
.invoice-empty { padding: 14px 0; color: #6b655c; }
.invoice-totals { width: 100%; max-width: 260px; margin: 14px 0 0 auto; }
.invoice-totals div { display: flex; justify-content: space-between; gap: 16px; padding: 5px 0; }
.invoice-totals .label { margin: 0; color: #4b463f; font-size: 0.82rem; font-weight: 400; }
.invoice-totals .total { margin-top: 4px; padding-top: 8px; border-top: 1px solid #d6cfc4; font-size: 0.95rem; font-weight: 700; }
.invoice-notes { margin: 22px 0 0; color: #3d3831; font-size: 0.8rem; white-space: pre-line; }
.invoice-made-with { margin-top: 24px; padding-top: 10px; border-top: 1px solid #e9e3d9; color: #6b655c; font-size: 0.72rem; }
.preview-hint { margin: 0 0 10px; color: var(--muted); font-size: 0.82rem; }

.status-select {
  min-height: 44px;
  padding: 6px 8px;
  font-size: 0.86rem;
}
.invoice-number-cell { font-weight: 600; }

/* Settings */

.settings-grid { display: grid; gap: 16px; }
@media (min-width: 860px) { .settings-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.settings-grid .card h2 { margin: 0 0 4px; font-size: 1.02rem; }
.settings-grid .card > p { margin: 0 0 16px; color: var(--muted); font-size: 0.88rem; }
.settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.logo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.logo-preview {
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
  flex: none;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.license-state { margin: 12px 0 0; font-size: 0.9rem; font-weight: 600; color: var(--muted); }
.license-state.is-pro { color: var(--accent); }
.license-row { display: flex; flex-wrap: wrap; gap: 8px; }
.license-row input { flex: 1 1 170px; min-width: 0; }
.license-row .btn { flex: 0 0 auto; }

.note { color: var(--muted); font-size: 0.82rem; margin: 8px 0 0; }

/* Utilities */

.stack-16 > * + * { margin-top: 16px; }
.nowrap { white-space: nowrap; }

/* ---------- Print: invoice only ---------- */

@media print {
  @page { margin: 14mm; }
  html, body { background: #fff !important; color: #000 !important; }
  .site-header, .site-footer, .tabs, .no-print, .notice,
  #panel-ledger, #panel-settings, .preview-hint { display: none !important; }
  #panel-invoices { display: block !important; }
  .app-main, .wrap { max-width: none; padding: 0; margin: 0; }
  .invoice-layout { display: block; margin: 0; }
  .invoice-preview-wrap { position: static; padding: 0; border: 0; background: none; }
  .invoice-paper {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #fff;
    color: #000;
    font-size: 10pt;
    max-width: none;
  }
  .invoice-paper a { color: #000; text-decoration: none; }
  .invoice-items tr { page-break-inside: avoid; }
  .invoice-totals { page-break-inside: avoid; }
  .invoice-made-with { border-top-color: #ccc; color: #444; }
}

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