:root {
  --background: #e7e1d6;
  --foreground: #1e1a16;
  --card: #f7f3eb;
  --primary: #1e4a40;
  --primary-foreground: #f6f1e7;
  --muted: #efe8dc;
  --muted-foreground: #6b645c;
  --border: #d5cdbf;
  --destructive: #8e3b2e;
  --sidebar: #ddd6c8;
  --paper: #fbf8f3;
  --sample: #6b4520;
  --radius: 0.35rem;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { font-size: 18px; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: "Public Sans", "Segoe UI", sans-serif;
  line-height: 1.5;
}
a { color: inherit; }
h1, h2, .wordmark, .font-heading {
  font-family: Fraunces, Georgia, serif;
  font-weight: 560;
  letter-spacing: -0.02em;
}
h1 { font-size: 2.25rem; line-height: 1.15; margin: 0; }
h2 { font-size: 1.875rem; line-height: 1.2; margin: 0; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.shell { min-height: 100vh; }
.sidebar {
  display: none;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  flex-direction: column;
}
.wordmark { color: var(--primary); text-decoration: none; font-size: 36px; line-height: 40px; }
.company-name { margin-top: 0.5rem; color: var(--muted-foreground); font-size: 0.875rem; }
.nav-group { margin-top: 1.25rem; }
.kicker, .eyebrow {
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.nav-link {
  display: block;
  border-left: 2px solid transparent;
  padding: 0.35rem 0.75rem;
  text-decoration: none;
  font-size: 0.875rem;
  color: rgba(30, 26, 22, 0.8);
}
.nav-link.active { border-left-color: var(--primary); color: var(--primary); }
.sidebar-foot { margin-top: auto; padding-top: 2rem; }
.quiet { color: var(--muted-foreground); font-size: 0.875rem; text-decoration: none; }
.inline-form { display: inline; }
.linkish {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
}
.wordmark-sm { font-size: 24px; line-height: 32px; color: var(--primary); text-decoration: none; }
.menu-toggle { background: none; border: 0; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.875rem; }
.mobile-nav {
  display: none;
  position: absolute;
  right: 1rem;
  z-index: 20;
  width: 14rem;
  margin-top: 0.5rem;
  border: 1px solid var(--border);
  background: var(--card);
  padding: 0.75rem;
  box-shadow: 0 12px 30px rgba(60, 40, 20, 0.08);
}
.mobile-nav.open { display: block; }
.search-bar { border-bottom: 1px solid var(--border); padding: 0.75rem 1rem; }
.search-bar input, .field input, .field select, .field textarea {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  min-height: 2.5rem;
  padding: 0.4rem 0.75rem;
}
.field textarea { min-height: 7rem; border-radius: var(--radius); }
.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.9rem; }
.field label { font-size: 0.875rem; }
main { padding: 2rem 1rem 3rem; }
.wrap { max-width: 64rem; margin: 0 auto; }
.wrap-narrow { max-width: 40rem; margin: 0 auto; }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.lede { margin-top: 0.5rem; max-width: 40rem; color: var(--muted-foreground); font-size: 0.875rem; }
.stat { margin-top: 0.5rem; font-family: Fraunces, Georgia, serif; font-size: 3rem; letter-spacing: -0.03em; line-height: 1; }
.btn, a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
  text-decoration: none;
  font-size: 0.875rem;
}
.btn.outline, a.btn.outline { background: var(--card); color: var(--foreground); border-color: var(--border); }
.btn.small { min-height: 2rem; padding: 0 0.75rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.section { margin-top: 3rem; }
.notice { margin: 1rem 0; font-size: 0.875rem; color: var(--muted-foreground); }
.error {
  margin: 1rem 0;
  border: 1px solid rgba(142, 59, 46, 0.3);
  background: #f6e4df;
  color: var(--destructive);
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
}
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 0.4rem; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 0.95rem; }
th { font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-foreground); font-weight: 500; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge {
  display: inline-flex;
  border-radius: 0.15rem;
  padding: 0.1rem 0.45rem;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--muted);
}
.badge.sent, .badge.viewed { background: #e4ede9; color: var(--primary); }
.badge.partially_paid { background: #f3e6d4; color: var(--sample); }
.badge.paid, .badge.accepted { background: var(--primary); color: var(--primary-foreground); }
.badge.overdue, .badge.declined, .badge.failed { background: #f6e4df; color: var(--destructive); }
.badge.cancelled { color: var(--muted-foreground); text-decoration: line-through; }
.sample { margin-left: 0.4rem; color: var(--sample); font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--border); }
.list li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem; padding: 0.9rem 0; border-bottom: 1px solid var(--border); }
.card { border: 1px solid var(--border); background: var(--card); padding: 1rem; margin-top: 1rem; }
.grid-2 { display: grid; gap: 1rem; }
.empty {
  border: 1px dashed var(--border);
  padding: 2.5rem 1.5rem;
}
.auth { min-height: 100vh; padding: 3rem 1rem; }
.auth-inner { max-width: 28rem; margin: 0 auto; }
.auth h1 { margin-top: 2.5rem; }
.invoice-paper {
  background: var(--paper);
  box-shadow: 0 18px 50px rgba(60, 40, 20, 0.08);
  padding: 1.75rem;
  margin-top: 1.5rem;
}
.invoice-paper .kicker { font-size: 11px; }
.paper-head, .paper-row { display: flex; justify-content: space-between; gap: 1rem; }
.paper-brand { font-family: Fraunces, Georgia, serif; font-size: 1.6rem; color: var(--primary); margin: 0; }
.paper-number { font-family: Fraunces, Georgia, serif; font-size: 1.4rem; margin: 0.2rem 0; }
.paper-meta { color: var(--muted-foreground); font-size: 0.875rem; }
.logo { max-height: 48px; margin-bottom: 0.5rem; }
.paper-lines { margin-top: 1.25rem; }
.paper-totals { margin-top: 0.75rem; margin-left: auto; width: min(16rem, 100%); }
.paper-totals td { border: 0; padding: 0.15rem 0; }
.paper-note { margin-top: 1rem; font-size: 0.875rem; color: var(--muted-foreground); }
.lines .line-row { display: grid; grid-template-columns: 1.6fr 0.6fr 0.7fr; gap: 0.5rem; margin-bottom: 0.5rem; }
.check { display: flex; gap: 0.5rem; align-items: flex-start; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (min-width: 800px) {
  .shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); }
  .sidebar { display: flex; min-height: 100vh; }
  .topbar { display: none; }
  .search-bar, main { padding-left: 2.5rem; padding-right: 2.5rem; }
  main { padding-top: 3rem; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .stat { font-size: 3.75rem; }
}
@media print {
  .sidebar, .topbar, .search-bar, .no-print { display: none !important; }
  body { background: white; }
  .shell { display: block; }
  main { padding: 0; }
  .invoice-paper { box-shadow: none; }
}
