:root {
  --bg: #eef3f0;
  --ink: #10211e;
  --muted: #5d6d68;
  --paper: #fffdf9;
  --line: #e4ebe6;
  --teal: #0b3d3a;
  --teal-2: #14615c;
  --gold: #c89612;
  --gold-soft: #f6e7bc;
  --mint: #e7f4ef;
  --danger: #9b2c2c;
  --shadow: 0 20px 50px rgba(11, 61, 58, 0.08);
  --radius: 22px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Vazirmatn, Tahoma, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background: var(--bg);
}
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 420px at 100% -10%, rgba(200, 150, 18, 0.16), transparent 55%),
    radial-gradient(700px 380px at -10% 20%, rgba(11, 61, 58, 0.1), transparent 50%),
    linear-gradient(180deg, #dceae4 0%, var(--bg) 280px);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(16px);
  background: rgba(255, 253, 249, 0.86);
  border-bottom: 1px solid rgba(11, 61, 58, 0.08);
}
.topbar-inner, .hero-inner, main, .steps {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 68px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: var(--gold);
  font-weight: 800;
  font-size: 20px;
}
.brand small { display: block; color: var(--muted); font-size: 12px; }
.formula-pill {
  margin: 0 auto 0 0;
  background: var(--mint);
  color: var(--teal);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
}
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.hero { padding: 36px 0 18px; }
.eyebrow {
  margin: 0 0 10px;
  color: var(--teal-2);
  font-size: 13px;
  font-weight: 700;
}
.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(30px, 4.6vw, 52px);
  line-height: 1.25;
  letter-spacing: -0.03em;
}
.lede { max-width: 680px; line-height: 1.95; color: var(--muted); margin: 0; }
.stats { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 22px; }
.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  box-shadow: 0 8px 20px rgba(16, 33, 30, 0.04);
}
.stat b { color: var(--teal); }

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 8px auto 16px;
  padding: 0;
  list-style: none;
}
.step {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,253,249,0.7);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--muted);
  font-weight: 700;
}
.step span {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #e7ece9;
}
.step.is-current, .step.is-done {
  background: var(--paper);
  color: var(--ink);
  border-color: #cfe0d8;
}
.step.is-current span { background: var(--teal); color: #fff; }
.step.is-done span { background: var(--gold); color: #1b1404; }

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 18px;
}
.panel h2 { margin: 0 0 6px; font-size: 20px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  flex-wrap: wrap;
}
.panel-head.tight { align-items: center; }
.panel-head p, .hint, .empty-card p, footer { color: var(--muted); line-height: 1.8; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip, .examples button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 700;
  color: var(--teal);
}
.chip.is-on, .examples button:hover, .chip:hover {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.search-shell { margin-top: 16px; position: relative; }
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 8px 8px 16px;
  border: 1.5px solid #cfdcd6;
  border-radius: 18px;
  background: #fff;
  box-shadow: inset 0 1px 0 #fff, 0 10px 30px rgba(11, 61, 58, 0.05);
}
.search-box:focus-within { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(11, 61, 58, 0.12); }
.search-box svg { color: var(--muted); flex: 0 0 auto; }
.search-box input {
  flex: 1;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 16px;
  background: transparent;
  min-width: 0;
}
.examples { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; font-size: 13px; color: var(--muted); }

.btn {
  font-family: inherit;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-2); }
.btn.ghost { background: #f4f8f6; color: var(--teal); border: 1px solid var(--line); }
.btn.wide { width: 100%; margin-top: 6px; }
.btn.sm { padding: 8px 12px; font-size: 12px; border-radius: 10px; }
.btn.tiny { padding: 6px 10px; font-size: 12px; }

.hidden { display: none !important; }
.suggest-box {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 16px 36px rgba(11, 61, 58, 0.12);
  z-index: 20;
}
.suggest-meta { padding: 10px 14px; font-size: 13px; color: var(--muted); background: #f7faf8; border-bottom: 1px solid var(--line); }
.suggest-item {
  display: grid;
  grid-template-columns: 108px 1fr auto auto;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
  cursor: pointer;
  background: #fff;
  font: inherit;
  text-align: right;
  color: inherit;
}
.suggest-item:hover, .suggest-item.active, .suggest-item.is-kbd { background: #f3f8f5; }
.code { font-weight: 800; color: var(--teal); font-variant-numeric: tabular-nums; }
.mark { background: var(--gold-soft); border-radius: 4px; padding: 0 2px; }
.muted { color: var(--muted); font-size: 13px; }
.badge {
  background: var(--gold-soft);
  color: #6d5410;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.badge.service { background: #e6eefc; color: #27407a; }
.badge.commerce { background: var(--gold-soft); color: #6d5410; }
.badge.production { background: #e4f3ea; color: #1e5b38; }
.more-btn { width: 100%; border-radius: 0; }

.workspace { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 18px; }
.empty-card {
  margin-top: 8px;
  border: 1.5px dashed #d5e0db;
  border-radius: 16px;
  padding: 28px 18px;
  text-align: center;
  background: #fbfcfb;
}
.selected-card { display: grid; gap: 2px; }
.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.kv strong { text-align: left; }
.notes {
  margin: 10px 0 0;
  background: #f7f4ea;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.8;
  color: #5a5240;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 13px; color: var(--muted); }
#turnover, .table-filters input {
  font-family: inherit;
  font-size: 18px;
  padding: 12px 14px;
  border: 1px solid #d8d0be;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
#turnover { font-weight: 800; letter-spacing: 0.02em; }
#turnover:focus, .table-filters input:focus { outline: 2px solid rgba(11, 61, 58, 0.2); border-color: var(--teal); }
.unit-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.unit input { display: none; }
.unit span {
  display: block;
  text-align: center;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-weight: 800;
  cursor: pointer;
}
.unit input:checked + span { background: var(--teal); color: #fff; border-color: var(--teal); }

.receipt {
  margin-top: 14px;
  background: linear-gradient(180deg, #f7fff9, #eef7f2);
  border: 1px solid #cfe3dc;
  border-radius: 16px;
  padding: 16px;
}
.receipt .tax {
  font-size: 30px;
  font-weight: 800;
  color: var(--teal);
  margin: 10px 0 0;
  font-variant-numeric: tabular-nums;
}
.formula { font-size: 13px; color: var(--muted); }
.receipt.warn { background: #fff6f4; border-color: #f0d2cc; color: var(--danger); }

.downloads { display: flex; gap: 8px; flex-wrap: wrap; }
.table-filters input { font-size: 14px; font-weight: 500; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; max-height: 640px; }
table { width: 100%; border-collapse: collapse; min-width: 920px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: right; font-size: 13px; }
th {
  background: var(--teal);
  color: #fff;
  cursor: pointer;
  position: sticky;
  top: 0;
  white-space: nowrap;
  user-select: none;
}
th::after { content: " ↕"; opacity: 0.4; font-size: 11px; }
th.sort-asc::after { content: " ↑"; opacity: 1; }
th.sort-desc::after { content: " ↓"; opacity: 1; }
tbody tr:hover { background: #f6faf7; }
tbody tr.is-selected { background: #eef6e8; }
td.title-cell { max-width: 340px; }
.table-footer { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; align-items: center; flex-wrap: wrap; }

.dock {
  position: sticky;
  bottom: 16px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 16px;
  background: var(--teal);
  color: #fff;
  border-radius: 18px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 18px 40px rgba(11, 61, 58, 0.28);
  z-index: 30;
}
.dock small { display: block; opacity: 0.75; font-size: 11px; }
.dock-tax { margin-inline-start: auto; font-size: 20px; font-weight: 800; color: var(--gold-soft); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  z-index: 80;
  font-size: 14px;
}
@media (display-mode: standalone), (display-mode: fullscreen) {
  .install-btn, #installBtn { display: none !important; }
}
.skeleton { opacity: 0.7; }
footer { text-align: center; padding: 8px 20px 40px; font-size: 13px; }

@media (max-width: 900px) {
  .formula-pill { display: none; }
  .top-actions { display: none; }
  .steps, .workspace, .table-filters, .suggest-item { grid-template-columns: 1fr; }
  .search-box { flex-wrap: wrap; }
  .search-box .btn { width: 100%; }
  .dock { flex-wrap: wrap; }
  .dock-tax { margin: 0; }
  .table-head .downloads { display: flex; }
}
@media print {
  .topbar, .steps, .search-panel, .table-panel, .dock, footer, .btn { display: none !important; }
  .workspace { display: block; }
  body { background: #fff; }
}
