:root {
  --bg: #f3f5fa;
  --card: #ffffff;
  --text: #101828;
  --muted: #667085;
  --line: #e6eaf2;
  --navy: #101a30;
  --navy-2: #1a2744;
  --gold: #c9a24a;
  --blue: #2f5fef;
  --blue-soft: #e8eeff;
  --danger: #d92d20;
  --radius: 20px;
  --shadow: 0 12px 40px rgba(16, 26, 48, 0.08);
  --font: "Vazirmatn", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  padding-bottom: 92px;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }

.appbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--navy), var(--navy-2));
  color: #eef3ff;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: #93a4c4; font-size: 11px; }
.seal {
  width: 40px; height: 40px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--gold); color: #1b1406; font-weight: 800;
}
.seal.xl { width: 64px; height: 64px; font-size: 28px; border-radius: 20px; }
.desk-nav { display: none; margin-inline-start: auto; gap: 4px; flex-wrap: wrap; max-width: 72%; }
.desk-nav a { color: #c9d4ea; padding: 6px 10px; border-radius: 12px; font-size: 13px; }
.desk-nav a.active { background: #22304e; color: #fff; }
.logout { margin-inline-start: auto; }
.logout button {
  border: 0; background: transparent; color: #c9d4ea; padding: 8px 10px;
}

.shell { width: min(980px, calc(100% - 24px)); margin: 16px auto 0; }
.shell-login { width: min(520px, calc(100% - 24px)); }

.page-head { display: flex; justify-content: space-between; align-items: end; gap: 12px; margin-bottom: 14px; }
.page-head h1, .hero h1, .auth h1, .block h2 { margin: 0; }
.eyebrow { margin: 0; color: var(--gold); font-size: 12px; font-weight: 700; }
.muted { color: var(--muted); }

.hero {
  background: linear-gradient(160deg, #16254a, #0b1224);
  color: #f7f9ff; border-radius: 24px; padding: 22px;
  display: grid; gap: 16px; margin-bottom: 14px;
}
.hero p { color: #b7c4df; margin: 8px 0 0; }
.fab {
  display: inline-flex; justify-content: center;
  background: var(--gold); color: #1b1406; font-weight: 800;
  border-radius: 14px; padding: 12px 16px;
}

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.kpis.compact { grid-template-columns: 1fr 1.4fr 1fr; }
.kpi {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 14px; box-shadow: var(--shadow);
}
.kpi.gold { background: linear-gradient(180deg, #fff8e8, #fff); }
.kpi small { color: var(--muted); }
.kpi strong { display: block; margin: 6px 0 4px; font-size: 18px; line-height: 1.3; }
.kpi span { color: #98a2b3; font-size: 12px; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.quick a {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; box-shadow: var(--shadow);
}
.quick small { display: block; color: var(--muted); margin-top: 4px; }

.block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.block-head a { color: var(--blue); font-weight: 700; }

.order-cards { display: grid; gap: 10px; }
.order-card {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.order-card a { min-width: 0; }
.order-card small { display: block; color: var(--muted); margin-top: 4px; }
.order-card em { font-style: normal; font-weight: 800; color: var(--navy); white-space: nowrap; }
.order-side { display: grid; justify-items: end; gap: 6px; }
.danger-link { border: 0; background: transparent; color: var(--danger); cursor: pointer; font-weight: 700; }
.empty-card {
  background: var(--card); border: 1px dashed var(--line); border-radius: 18px;
  padding: 28px 16px; text-align: center; color: var(--muted);
}

.searchbar { display: flex; gap: 8px; margin-bottom: 12px; }
.searchbar input, .card input, .card textarea, .card select, #product-filter {
  width: 100%; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; background: #fff;
}
.searchbar button, .primary, .chip, .step {
  border: 0; border-radius: 14px; padding: 12px 16px; cursor: pointer;
}
.searchbar button { background: var(--blue-soft); color: var(--blue); font-weight: 700; }
.primary { background: var(--blue); color: #fff; font-weight: 800; }
.wide { width: 100%; }
.banner { background: #eff8ff; color: #026aa2; padding: 12px 14px; border-radius: 14px; margin-bottom: 12px; }
.banner.danger { background: #fee4e2; color: var(--danger); }

body.page-login {
  padding: 0;
  min-height: 100vh;
  background: #f3f5fa;
}
.login-shell { min-height: 100vh; display: grid; }
.login-brand {
  background: linear-gradient(165deg, #16254a 0%, #0b1224 70%);
  color: #eef3ff;
  padding: 36px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-mark {
  width: 52px; height: 52px; border-radius: 15px;
  background: var(--gold); color: #1b1406;
  display: grid; place-items: center;
  font-size: 26px; font-weight: 800;
}
.login-brand h1 { margin: 10px 0 0; font-size: 28px; line-height: 1.35; }
.gold-rule {
  display: block; width: 64px; height: 3px;
  background: var(--gold); border-radius: 99px; margin: 4px 0 2px;
}
.login-caption { margin: 0; color: #c9a24a; font-weight: 700; }
.login-brand ul { list-style: none; padding: 12px 0 0; margin: 0; display: grid; gap: 10px; }
.login-brand li {
  position: relative; padding-right: 22px; color: #b7c4df; font-size: 14px; line-height: 1.6;
}
.login-brand li::before {
  content: "✓"; position: absolute; right: 0; color: var(--gold); font-weight: 800;
}
.login-brand small { margin-top: auto; color: #93a4c4; padding-top: 24px; }
.login-form-wrap {
  display: grid; place-items: center;
  padding: 28px 18px;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 30px 26px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}
.login-card h2 { margin: 0; font-size: 24px; }
.login-card > p { margin: 0; color: var(--muted); }
.field { display: grid; gap: 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.field input, .field select {
  width: 100%; border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 14px; background: #fff; color: var(--text); font-weight: 500;
}
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.hint { color: var(--muted); text-align: center; line-height: 1.6; }

.dev-hero {
  background: linear-gradient(160deg, #16254a, #0b1224);
  color: #f7f9ff; border-radius: 24px; padding: 22px;
  display: flex; justify-content: space-between; gap: 16px; align-items: center;
  margin-bottom: 14px;
}
.dev-hero p { color: #b7c4df; margin: 8px 0 0; }
.dev-badge {
  background: var(--gold); color: #1b1406; font-weight: 800;
  border-radius: 999px; padding: 8px 14px; font-size: 12px;
}
.dev-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 4px 0 14px; }
.dev-pane { display: none; }
.dev-pane.show { display: grid; gap: 12px; }
.dev-grid { display: grid; gap: 12px; }
.stack { display: grid; gap: 12px; }
.kv { display: grid; gap: 0; margin: 0; }
.kv div {
  display: grid; grid-template-columns: 140px 1fr;
  gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line);
}
.kv dt { color: var(--muted); font-size: 13px; }
.kv dd { margin: 0; font-weight: 700; }
.plain { width: 100%; border-collapse: collapse; font-size: 13px; }
.plain th, .plain td { text-align: right; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.plain th { color: var(--muted); font-weight: 700; }
.empty-card {
  background: #fff; border: 1px dashed var(--line); border-radius: 16px;
  padding: 22px; text-align: center; color: var(--muted);
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 16px; display: grid; gap: 12px; }
.steps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.step { background: #fff; color: var(--muted); border: 1px solid var(--line); }
.step.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.panel { display: none; }
.panel.show { display: block; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin: 8px 0; }
.chip { background: #fff; border: 1px solid var(--line); color: var(--text); white-space: nowrap; }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.cat-pane { display: none; }
.cat-pane.show { display: grid; gap: 8px; }
.item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px;
}
.item small { color: var(--muted); }
.stepper { display: flex; align-items: center; background: #f4f6fb; border-radius: 999px; padding: 4px; }
.stepper button {
  width: 36px; height: 36px; border: 0; border-radius: 50%; background: #fff; color: var(--navy); font-size: 20px;
}
.stepper input { width: 42px; border: 0; background: transparent; text-align: center; padding: 0; }
.cartbar {
  position: sticky; bottom: 76px; z-index: 8;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--navy); color: #fff; border-radius: 18px; padding: 12px 14px; margin-top: 14px;
}
.cartbar small { color: #b7c4df; display: block; }

body.page-invoice {
  background: #cfcfcf;
  padding: 20px 0 32px;
  color: #111;
}
body.page-invoice .shell { width: min(210mm, calc(100% - 24px)); margin: 0 auto; }
.invoice-sheet {
  background: #fff;
  color: #111;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
}
.inv-frame {
  position: relative;
  margin: 8px;
  padding: 14px 16px 10px;
  border: 1.5px solid #111;
  outline: 0.4px solid #111;
  outline-offset: 3px;
}
.inv-corner {
  position: absolute; width: 16px; height: 16px;
  border: 1.6px solid #111; pointer-events: none;
}
.inv-corner.tr { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.inv-corner.tl { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.inv-corner.br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.inv-corner.bl { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.inv-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.inv-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.inv-seal {
  width: 51px; height: 51px; border-radius: 6px;
  background: #111; color: #fff;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 800; flex: 0 0 auto;
}
.inv-brand h1 { margin: 0; font-size: 22px; font-weight: 800; color: #111; }
.inv-brand p { margin: 4px 0 0; font-size: 12px; color: #444; }
.inv-plate {
  width: 242px; flex: 0 0 242px;
  border: 1.4px solid #111; text-align: center;
}
.inv-plate strong {
  display: block; background: #111; color: #fff;
  padding: 6px 8px; font-size: 14px;
}
.inv-plate b { display: block; padding: 8px 8px 2px; font-size: 13px; }
.inv-plate small { display: block; padding: 0 8px 8px; color: #444; font-size: 11px; }
.inv-double-rule {
  height: 3px; margin: 12px 0 14px;
  border-top: 1.6px solid #111;
  border-bottom: 0.4px solid #111;
}
.inv-meta { width: 100%; border-collapse: collapse; table-layout: fixed; }
.inv-meta td {
  border: 0.7px solid #111;
  padding: 0;
  vertical-align: middle;
}
.inv-meta .pair {
  display: grid;
  grid-template-columns: 38% 1fr;
  min-height: 42px;
}
.inv-meta .pair span,
.inv-meta .pair b {
  display: flex; align-items: center;
  padding: 8px 10px;
}
.inv-meta .pair span {
  background: #ececec;
  color: #444;
  font-size: 11px;
  border-inline-start: 0.4px solid #111;
}
.inv-meta .pair b { font-size: 13px; color: #111; font-weight: 700; }
.inv-section {
  margin: 16px 0 6px;
  font-size: 13px;
  font-weight: 800;
  text-align: right;
}
.inv-items { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.inv-items th {
  background: #111; color: #fff; font-weight: 700;
  padding: 8px 6px; text-align: center;
}
.inv-items td {
  border: 0.4px solid #111;
  padding: 7px 6px;
  text-align: center;
  color: #111;
}
.inv-items td.name { text-align: right; }
.inv-items tbody tr:nth-child(even) { background: #e8e8e8; }
.inv-items tfoot td {
  background: #ececec;
  font-weight: 800;
  border-top: 1.2px solid #111;
}
.inv-items tfoot td:first-child { text-align: right; }
.inv-words { width: 100%; border-collapse: collapse; margin-top: 16px; }
.inv-words th, .inv-words td { border: 0.8px solid #111; padding: 10px 12px; }
.inv-words th {
  width: 22%; background: #ececec; color: #444;
  font-size: 12px; font-weight: 700; text-align: right;
}
.inv-words td { font-weight: 800; font-size: 13px; }
.inv-pay {
  margin-top: 10px;
  background: #111; color: #fff;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px;
}
.inv-pay span { font-weight: 800; font-size: 13px; }
.inv-pay strong { font-size: 18px; font-weight: 800; }
.inv-note { margin: 12px 0 14px; color: #444; font-size: 12px; text-align: right; }
.inv-signs { width: 100%; border-collapse: collapse; }
.inv-signs td {
  width: 50%; border: 0.8px solid #111; padding: 0;
  vertical-align: top; text-align: center;
}
.inv-signs strong {
  display: block; background: #ececec; padding: 8px;
  font-size: 12px; border-bottom: 0.5px solid #111;
}
.inv-signs i {
  display: block; height: 58px;
  border-bottom: 0.8px solid #111;
  margin: 28px 28px 10px;
}
.inv-foot { margin-top: 14px; }
.inv-foot-rule {
  height: 3px; margin-bottom: 8px;
  border-top: 0.4px solid #111;
  border-bottom: 1.6px solid #111;
}
.inv-foot-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.inv-store { margin: 6px 0 0; color: #444; font-size: 11px; }
.inv-foot small { display: block; text-align: center; color: #444; margin-top: 8px; font-size: 11px; }
.invoice-actions { display: grid; gap: 8px; margin-top: 14px; }
.invoice-actions .secondary {
  display: block; text-align: center;
  border: 1px solid #111; border-radius: 14px;
  padding: 12px 16px; background: #fff; color: #111; font-weight: 700;
}

.form-grid { display: grid; gap: 12px; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ghost {
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: var(--navy); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 16px; font-weight: 700;
}
.ghost.compact { padding: 8px 12px; font-size: 13px; }
.table-wrap {
  overflow-x: auto; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 8px; box-shadow: var(--shadow);
}
.table-wrap.bare { border: 0; box-shadow: none; padding: 0; }
.plain input[type="text"], .plain input[type="number"] {
  width: min(160px, 100%); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
}
.searchbar.wrap { flex-wrap: wrap; }
.searchbar.wrap input { min-width: 140px; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-grid a {
  background: var(--card); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; box-shadow: var(--shadow);
}
.menu-grid small { display: block; color: var(--muted); margin-top: 4px; }

.tabbar {
  position: fixed; left: 12px; right: 12px; bottom: 10px; z-index: 30;
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr;
  background: #fff; border: 1px solid var(--line); border-radius: 22px;
  box-shadow: var(--shadow); padding: 8px;
}
.tabbar a {
  display: grid; place-items: center; gap: 2px; color: var(--muted);
  border-radius: 16px; padding: 8px 0; font-size: 12px;
}
.tabbar a.active { color: var(--navy); background: #f4f6fb; font-weight: 800; }
.tabbar .plus { background: var(--blue); color: #fff; }
.tabbar .plus b { font-size: 20px; line-height: 1; }
.tabbar.wide { grid-template-columns: 1fr 1fr 1fr 1fr; }

@media (min-width: 860px) {
  .desk-nav { display: flex; }
  .logout { margin-inline-start: 0; }
  .tabbar, .page-head .primary { display: none; }
  .kpis { grid-template-columns: repeat(4, 1fr); }
  .kpis.compact { grid-template-columns: repeat(3, 1fr); }
  .form-grid.two { grid-template-columns: 1fr 1fr; }
  .menu-grid { grid-template-columns: repeat(3, 1fr); }
  .quick { grid-template-columns: repeat(4, 1fr); }
  .inv-head { align-items: flex-start; }
  .hero { grid-template-columns: 1fr auto; align-items: center; }
  .cartbar { bottom: 16px; }
  .login-shell { grid-template-columns: minmax(320px, 0.9fr) 1.2fr; }
  .login-brand { padding: 44px 40px 40px; }
  .dev-grid { grid-template-columns: 1fr 1fr; }
  .dev-hero { align-items: center; }
}

@media print {
  @page { size: A4; margin: 8mm; }
  html, body { background: #fff !important; padding: 0 !important; }
  body.page-invoice .shell { width: 100%; margin: 0; }
  .appbar, .tabbar, .no-print, .invoice-actions { display: none !important; }
  .invoice-sheet { box-shadow: none; }
  .inv-frame { margin: 0; }
}
