:root {
  --ink: #2c1810;
  --muted: #8a5a3a;
  --line: #f0d2b4;
  --paper: #fff4e8;
  --card: #fffaf4;
  --accent: #e86f12;
  --accent-dark: #b84a08;
  --header: #4a220c;
  --leaf: #3f7a3a;
  --copper: #c4530a;
  --warn-bg: #fff1d6;
  --ok-bg: #e8f6df;
  --err-bg: #fde8e0;
  --shadow: 0 18px 50px rgba(120, 48, 8, 0.08);
  color: var(--ink);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
a { color: var(--accent-dark); }
h1, h2, .logo, .sheet h1 { font-family: Fraunces, Georgia, serif; font-weight: 650; letter-spacing: -0.03em; }
h1 { font-size: 40px; line-height: 1.1; margin: 0 0 10px; }
h2 { font-size: 26px; margin: 28px 0 12px; }
p { margin: 0 0 12px; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }

.utility { background: #ffe4c4; color: var(--accent-dark); text-align: center; padding: 7px 16px; font-size: 14px; }
.site-header { display: flex; gap: 18px; align-items: center; padding: 14px 22px; background: var(--header); color: #f7f3ec; }
.site-header a { color: inherit; text-decoration: none; }
.logo { display: flex; align-items: center; gap: 10px; font-size: 26px; }
.logo span { width: 36px; height: 36px; display: grid; place-items: center; background: var(--accent); color: white; border-radius: 50%; font-size: 16px; }
.search { flex: 1; display: flex; gap: 8px; }
.search input { flex: 1; border: 0; border-radius: 999px; padding: 10px 14px; background: #6b3418; color: white; }
.search input::placeholder { color: #f3d2b8; }
.search button, .main-nav .nav-cta { background: var(--accent); color: white; border: 0; border-radius: 999px; padding: 10px 14px; cursor: pointer; text-decoration: none; }
.main-nav { display: flex; gap: 14px; align-items: center; }
.main-nav b { background: #ffe4c4; color: var(--header); border-radius: 999px; padding: 0 6px; font-size: 13px; }
.linkish { background: none; border: 0; color: inherit; cursor: pointer; padding: 0; }
.subnav { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 22px; background: #fffaf4; border-bottom: 1px solid var(--line); }
.subnav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 999px; }
.subnav a.active, .subnav a:hover { background: #ffe8d0; color: var(--accent-dark); }

main { width: min(1180px, calc(100% - 32px)); margin: 24px auto 40px; }
.site-footer { display: flex; justify-content: space-between; gap: 20px; width: min(1180px, calc(100% - 32px)); margin: 0 auto 28px; color: var(--muted); font-size: 15px; }
.site-footer a { display: block; }

.hero, .panel, .auth-card, .empty, .product-page { background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.hero { display: grid; grid-template-columns: 1.4fr .8fr; gap: 24px; padding: 28px; margin-bottom: 16px; }
.panel, .empty { padding: 28px; }
.auth-card { width: min(460px, 100%); margin: 0 auto; padding: 28px; }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; color: var(--copper); margin-bottom: 6px; }
.lede { font-size: 18px; color: #5c3a28; max-width: 68ch; }
.hero-stats { display: grid; gap: 10px; align-content: end; }
.hero-stats div, .stats a, .stats div { background: #fff1e4; border-radius: 16px; padding: 14px 16px; }
.hero-stats dt, .stats span { color: var(--muted); font-size: 14px; }
.hero-stats dd, .stats b { display: block; margin: 0; font-family: Fraunces, Georgia, serif; font-size: 28px; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stats.compact { grid-template-columns: repeat(4, 1fr); margin: 12px 0; }
.stats a { text-decoration: none; color: inherit; }

.banner { background: var(--ok-bg); border-radius: 14px; padding: 12px 14px; }
.banner.warn, .flash-error { background: var(--err-bg); }
.flash { border-radius: 14px; padding: 12px 14px; margin: 0 0 12px; }
.flash-ok { background: var(--ok-bg); }
.flashes { margin-bottom: 8px; }
.hint, small { color: var(--muted); display: block; }
.chips { display: flex; gap: 8px; overflow: auto; padding: 4px 0 14px; }
.chips a { white-space: nowrap; text-decoration: none; background: white; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; color: var(--ink); }
.chips a.active { background: var(--header); color: white; border-color: var(--header); }
.chips em { font-style: normal; color: var(--muted); }
.chips a.active em { color: #ffe0c2; }
.chips.sub { padding-top: 0; }
.chips.sub a { background: #fff1e4; color: var(--ink); }
.chips.sub a.active { background: #ffd7b0; color: var(--ink); border-color: #e8b888; }
.chips.sub a.active em { color: #6b4a32; }

.table-wrap { overflow-x: auto; margin: 8px 0 16px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.group td { background: #fff1e4; font-family: Fraunces, Georgia, serif; font-size: 18px; }
.product-cell { display: flex; gap: 10px; align-items: center; }
.product-cell a { font-weight: 650; text-decoration: none; }
.product-cell small, td small { color: var(--muted); }
.thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: #ffe8d2; }
.placeholder, .visual-fallback { display: grid; place-items: center; background: #ffe8d2; color: var(--accent-dark); font-family: Fraunces, Georgia, serif; }
.placeholder { width: 46px; height: 46px; border-radius: 10px; }
.locked { color: var(--muted); }
tr.muted { opacity: .55; }
.add-form, .inline-note, .row-actions, .actions, .split { display: flex; gap: 8px; align-items: center; }
.split, .actions { justify-content: space-between; flex-wrap: wrap; }
.add-form input, td input[name^="qty_"] { width: 76px; }
.totals { font-size: 18px; }

.btn, .add-form button, .inline-note button { background: var(--accent); color: white; border: 0; border-radius: 999px; padding: 10px 16px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.btn.ghost, a.btn.ghost { background: transparent; color: var(--accent-dark); border: 1px solid var(--line); }
.btn.danger { background: var(--copper); }
.danger-zone { margin-top: 18px; }
.pager { display: flex; gap: 6px; }
.pager a { text-decoration: none; padding: 6px 10px; border-radius: 8px; background: white; }
.pager a.active { background: var(--header); color: white; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide, .wide, .check.wide { grid-column: 1 / -1; }
.field span i { color: var(--copper); font-style: normal; }
.field input, .field select, .field textarea, .filters input, .filters select, .search input { border: 1px solid var(--line); background: white; border-radius: 12px; padding: 10px 12px; color: var(--ink); }
.search input::placeholder { color: #8a6a55; }
.stack { display: grid; gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; }
.check input { width: auto; }
.filters { display: flex; gap: 8px; margin: 12px 0 18px; }
.filters input { min-width: min(320px, 100%); }
.company-card, .category-row { border-top: 1px solid var(--line); padding: 16px 0; }
.company-card header { display: flex; justify-content: space-between; gap: 12px; }
.company-card h2 { margin: 0 0 4px; font-size: 22px; }
.badge { display: inline-flex; border-radius: 999px; padding: 3px 8px; background: #ffe8d2; font-size: 13px; }
.status-approved, .status-paid, .status-shipped { background: var(--ok-bg); }
.status-pending, .status-invoiced { background: var(--warn-bg); }
.status-rejected, .status-cancelled { background: var(--err-bg); }
.category-result { list-style: none; padding: 0; }
.category-result li { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 8px 0; }
.errors { color: var(--copper); }

.product-page { display: grid; grid-template-columns: .9fr 1.1fr; gap: 28px; padding: 22px; }
.product-visual img, .visual-fallback { width: 100%; border-radius: 18px; min-height: 280px; object-fit: cover; }
.visual-fallback { display: grid; align-content: center; justify-items: center; gap: 8px; }
.visual-fallback span { font-size: 72px; }
.price-lg { font-family: Fraunces, Georgia, serif; font-size: 36px; margin: 8px 0 0; }
.price-lg small, .price-sub { color: var(--muted); }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.facts div { background: #fff1e4; border-radius: 12px; padding: 10px 12px; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; font-size: 18px; }
.add-form.large input { width: 110px; padding: 10px; border-radius: 12px; border: 1px solid var(--line); }
.checkout { margin-top: 16px; display: grid; gap: 12px; }

.invoice-page main { width: min(920px, calc(100% - 24px)); }
.sheet { position: relative; background: white; border: 1px solid var(--line); border-radius: 18px; padding: 28px; overflow: hidden; }
.sheet h1 { font-size: 28px; }
.sheet-kicker { color: var(--muted); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.requisites th { width: 140px; text-transform: none; letter-spacing: 0; font-size: 15px; color: var(--ink); }
.lines td span { color: var(--muted); }
.sheet-total { text-align: right; }
.words { font-family: Fraunces, Georgia, serif; font-size: 18px; }
.signs { display: grid; gap: 18px; margin-top: 28px; }
.watermark { position: absolute; left: 8%; right: 8%; top: 38%; text-align: center; font-size: 92px; color: rgba(232, 111, 18, .16); transform: rotate(-14deg); pointer-events: none; font-family: Fraunces, Georgia, serif; }
.sheet-tools { display: flex; gap: 8px; margin-bottom: 12px; }

@media (max-width: 900px) {
  .hero, .product-page, .form-grid, .stats, .stats.compact { grid-template-columns: 1fr; }
  .site-header { flex-wrap: wrap; }
  .search { order: 3; flex-basis: 100%; }
  h1 { font-size: 32px; }
  .site-footer { flex-direction: column; }
}

@media print {
  .no-print { display: none !important; }
  body, .sheet { background: white; box-shadow: none; }
  main { width: auto; margin: 0; }
  .sheet { border: 0; }
}
