@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #efebe3;
  --bg-elevated: #f7f4ee;
  --bg-sunken: #e6e0d6;
  --bg-sidebar: #152824;
  --fg-sidebar: #e4eee8;
  --fg-sidebar-muted: #9bb0a8;
  --fg: #1c1915;
  --fg-muted: #6a645c;
  --fg-subtle: #8a837a;
  --accent: #1f4a44;
  --accent-2: #2c6a62;
  --accent-fg: #f4f1eb;
  --border: color-mix(in srgb, #1c1915 12%, transparent);
  --border-strong: color-mix(in srgb, #1c1915 22%, transparent);
  --danger: #8f3a32;
  --danger-bg: #f4e4e1;
  --warn: #8a5a24;
  --warn-bg: #f3ead8;
  --ok: #2c5e45;
  --ok-bg: #dceadf;
  --shadow: 0 1px 2px color-mix(in srgb, #1c1915 6%, transparent), 0 12px 32px color-mix(in srgb, #1c1915 6%, transparent);
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 28px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --font: "Vazirmatn", Tahoma, sans-serif;
  --text-xs: 0.78rem;
  --text-sm: 0.88rem;
  --text-base: 1rem;
  --text-lg: 1.15rem;
  --text-xl: 1.45rem;
  --text-2xl: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem);
  --leading: 1.6;
  --motion-quick: 150ms;
  --motion-fast: 250ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sidebar: 248px;
  --topbar: 64px;
  --bottom: 0px;
}

*, *::before, *::after { box-sizing: border-box; }
html { direction: rtl; }
html, body { height: 100%; overflow-x: hidden; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: var(--leading);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
button:not(:disabled), [role="button"]:not(:disabled), a { cursor: pointer; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 1rem; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }
h1, h2, h3 { text-wrap: balance; margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.25; }
p { text-wrap: pretty; }
.ltr { direction: ltr; text-align: left; unicode-bidi: plaintext; }
.tabular { font-variant-numeric: tabular-nums; }

#app {
  min-height: 100%;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
}
.sidebar {
  background: var(--bg-sidebar);
  color: var(--fg-sidebar);
  display: flex;
  flex-direction: column;
  padding: 22px 16px 18px;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 8px 22px;
}
.brand .logo { color: #d7ece4; }
.brand strong { display: block; font-size: 1.05rem; }
.brand small { color: var(--fg-sidebar-muted); font-size: var(--text-xs); }
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--fg-sidebar-muted);
  min-height: 44px;
  transition: background var(--motion-quick) var(--ease), color var(--motion-quick) var(--ease);
}
.nav-link svg { width: 20px; height: 20px; flex: 0 0 auto; }
.nav-link:hover { color: var(--fg-sidebar); background: color-mix(in srgb, #fff 6%, transparent); }
.nav-link.is-active {
  background: color-mix(in srgb, #fff 10%, transparent);
  color: #fff;
}
.side-foot {
  padding: 12px 12px 4px;
  color: var(--fg-sidebar-muted);
  font-size: var(--text-xs);
  border-top: 1px solid color-mix(in srgb, #fff 8%, transparent);
  margin-top: 12px;
}

.main { min-width: 0; display: flex; flex-direction: column; min-height: 100dvh; }
.topbar {
  height: var(--topbar);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.15rem; font-weight: 600; flex: 1; }
.menu-btn { display: none; }
.view { padding: 24px; padding-bottom: 48px; flex: 1; min-width: 0; overflow-x: hidden; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--bg-sunken);
  color: var(--fg);
  font-weight: 500;
  font-size: var(--text-sm);
  transition: transform var(--motion-quick) var(--ease), background var(--motion-quick) var(--ease), opacity var(--motion-quick) var(--ease);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-2); }
.btn-ghost { background: transparent; border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { min-height: 36px; padding: 0 12px; border-radius: var(--radius-xs); }
.icon-btn {
  width: 44px; height: 44px; border: 0; background: transparent; color: inherit;
  border-radius: var(--radius-sm); display: grid; place-items: center;
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:hover { background: var(--bg-sunken); }

.grid-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 18px 16px;
  min-height: 108px;
}
.stat .k { color: var(--fg-muted); font-size: var(--text-xs); font-weight: 500; }
.stat .v { font-size: 1.35rem; font-weight: 600; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat .s { color: var(--fg-subtle); font-size: var(--text-xs); margin-top: 6px; }
.stat.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 22%, transparent); }
.stat.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 22%, transparent); }

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel + .panel { margin-top: 16px; }
.panel h2 { font-size: 1.05rem; margin-bottom: 14px; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px;
}
.panel-head h2 { margin: 0; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 16px;
}
.split > * { min-width: 0; }

.table-wrap { overflow-x: auto; max-width: 100%; border-radius: var(--radius-md); border: 1px solid var(--border); }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: var(--bg-elevated);
}
table.data th, table.data td {
  padding: 12px 14px;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data th {
  font-weight: 500;
  color: var(--fg-muted);
  background: var(--bg-sunken);
  font-size: var(--text-xs);
}
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: color-mix(in srgb, var(--accent) 4%, transparent); }
table.data .num { font-variant-numeric: tabular-nums; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 500;
  background: var(--bg-sunken); color: var(--fg-muted);
}
.badge.low { background: var(--warn-bg); color: var(--warn); }
.badge.out { background: var(--danger-bg); color: var(--danger); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.svc { background: color-mix(in srgb, var(--accent) 12%, white); color: var(--accent); }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.grow { flex: 1 1 200px; min-width: 0; }
label.grow { position: relative; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }
@media (max-width: 760px) {
  .row-2 { grid-template-columns: 1fr; }
}

label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: var(--text-sm); font-weight: 500; color: var(--fg-muted);
}
label.check { flex-direction: row; align-items: center; font-weight: 400; color: var(--fg); }
input[type="text"], input[type="password"], input[type="tel"], input[type="number"], input[type="search"], textarea, select {
  min-height: 44px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--fg);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  outline: none;
  width: 100%;
  transition: border-color var(--motion-quick) var(--ease), box-shadow var(--motion-quick) var(--ease);
}
textarea { padding: 10px 12px; min-height: 88px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.date-field { position: relative; }
.date-field input { padding-inline-end: 42px; }
.date-field .cal-btn {
  position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; background: transparent; color: var(--fg-muted);
  display: grid; place-items: center; border-radius: var(--radius-xs);
}
.date-field .cal-btn svg { width: 18px; height: 18px; }

.cal-pop {
  position: absolute; z-index: 50; inset-inline-start: 0; top: calc(100% + 6px);
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); padding: 12px; box-shadow: var(--shadow);
  width: min(320px, calc(100vw - 48px));
  max-width: 100%;
  direction: rtl;
  animation: pop var(--motion-fast) var(--ease);
}
.cal-pop header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.cal-pop header select {
  min-height: 36px; flex: 1;
}
.cal-pop table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-pop th {
  font-size: 0.72rem; color: var(--fg-subtle); font-weight: 500; padding: 6px 0;
}
.cal-pop td { padding: 2px; }
.cal-pop td button {
  width: 100%; aspect-ratio: 1; border: 0; background: transparent;
  border-radius: var(--radius-sm); color: var(--fg); font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.cal-pop td button:hover { background: var(--bg-sunken); }
.cal-pop td button.is-today { box-shadow: inset 0 0 0 1px var(--accent); }
.cal-pop td button.is-sel { background: var(--accent); color: var(--accent-fg); }
.cal-pop td button.mute { color: var(--fg-subtle); opacity: .45; }
.cal-pop footer { margin-top: 8px; display: flex; justify-content: space-between; }

.plate {
  display: flex; direction: ltr; align-items: stretch;
  flex-wrap: nowrap;
  border: 2px solid #1c1915; border-radius: 6px; overflow: hidden;
  background: #fff; height: 54px; width: 100%; max-width: 100%;
  font-weight: 700; letter-spacing: 0.02em;
  box-sizing: border-box;
}
.plate-block { width: 100%; }
.plate-block > label { width: 100%; display: flex; flex-direction: column; }
.plate .ir {
  background: #1d4e89; color: #fff; width: 44px; flex: 0 0 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 0.55rem; font-weight: 600; letter-spacing: 0; line-height: 1.1;
}
.plate input, .plate select {
  border: 0; border-radius: 0; min-height: 0; height: 100%;
  text-align: center; font-weight: 700; box-shadow: none !important;
  background: #fff; width: 0; flex: 1 1 0; min-width: 0; padding: 0 1px;
  max-width: none;
}
.plate .p2 { flex: 1.1 1 0; }
.plate .plet { flex: 1 1 0; font-size: 1.05rem; }
.plate .p3 { flex: 1.6 1 0; }
.plate .iran { flex: 1.1 1 0; border-inline-start: 1px solid #1c1915; font-size: 0.95rem; }

.item-row {
  display: grid;
  grid-template-columns: 1.6fr 90px 140px 140px 44px;
  gap: 8px; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.totals {
  margin-top: 16px;
  display: grid; gap: 8px;
  background: var(--bg-sunken);
  border-radius: var(--radius-md);
  padding: 16px;
}
.totals div { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 1.15rem; font-weight: 600; padding-top: 8px; border-top: 1px solid var(--border); }
.totals .profit { color: var(--ok); font-weight: 600; }

.search-list {
  position: absolute; z-index: 40; inset-inline: 0; top: 100%;
  background: #fff; border: 1px solid var(--border-strong);
  border-radius: var(--radius-md); max-height: 240px; overflow: auto;
  box-shadow: var(--shadow);
}
.search-list button {
  display: block; width: 100%; text-align: right; border: 0; background: transparent;
  padding: 10px 12px; font-family: inherit; color: var(--fg);
}
.search-list button:hover, .search-list button.active { background: var(--bg-sunken); }
.search-list small { color: var(--fg-muted); display: block; font-size: var(--text-xs); }

.pkg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}
.pkg-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: var(--bg-elevated);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: right;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  width: 100%;
}
.pkg-card:hover, .pkg-card.is-on {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.pkg-card b { font-size: 0.95rem; }
.pkg-card .pkg-price { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.pkg-card ul { margin: 0; padding: 0 16px 0 0; font-size: var(--text-xs); color: var(--fg-muted); }
.cust-search { position: relative; width: 100%; }

.empty {
  text-align: center; color: var(--fg-muted); padding: 36px 12px;
}
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border);
  background: transparent; color: var(--fg-muted); font-family: inherit; font-size: var(--text-sm);
}
.tab.is-on { background: var(--accent); color: var(--accent-fg); border-color: transparent; }

.bar-row { display: grid; grid-template-columns: 88px 1fr 120px; gap: 10px; align-items: center; margin: 8px 0; font-size: var(--text-sm); }
.bar { height: 10px; background: var(--bg-sunken); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.toasts {
  position: fixed; inset-inline-end: 16px; bottom: 16px; z-index: 80;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--fg); color: var(--bg); padding: 12px 16px;
  border-radius: var(--radius-md); min-width: 220px; box-shadow: var(--shadow);
  animation: pop var(--motion-fast) var(--ease);
}
.toast.err { background: var(--danger); color: #fff; }

.modal-root:empty { display: none; }
.modal-root {
  position: fixed; inset: 0; z-index: 70;
  background: color-mix(in srgb, #152824 46%, transparent);
  display: grid; place-items: center; padding: 16px;
}
.modal {
  background: var(--bg-elevated); color: var(--fg);
  border-radius: var(--radius-xl); padding: 24px;
  width: min(560px, 100%);
  max-height: min(88dvh, 720px); overflow: auto;
  animation: pop var(--motion-fast) var(--ease);
}
.modal h3 { margin-bottom: 16px; }

.lock-screen {
  position: fixed; inset: 0; z-index: 90;
  background: var(--bg-sidebar); color: var(--fg-sidebar);
  display: none;
  place-items: center;
}
.lock-screen:not([hidden]) { display: grid; }
.lock-card {
  width: min(360px, 92vw); background: color-mix(in srgb, #fff 8%, transparent);
  border: 1px solid color-mix(in srgb, #fff 12%, transparent);
  border-radius: var(--radius-xl); padding: 28px; display: flex; flex-direction: column; gap: 12px;
}
.lock-card input { background: #fff; }

.bottom-nav { display: none; }
.form-error { color: var(--danger); font-size: var(--text-sm); }
.muted { color: var(--fg-muted); }
.tiny { font-size: var(--text-xs); color: var(--fg-subtle); }
#sms-preview { white-space: pre-wrap; line-height: 1.7; }

.install-body { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.install-card {
  width: min(480px, 100%); background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: 28px; box-shadow: var(--shadow);
}
.install-card h1 { margin: 12px 0 4px; }
.lede { color: var(--fg-muted); margin: 0 0 18px; }
.banner {
  background: var(--warn-bg); color: var(--warn); padding: 10px 12px;
  border-radius: var(--radius-sm); margin-bottom: 12px; font-size: var(--text-sm);
}
.banner.success { background: var(--ok-bg); color: var(--ok); }
.banner.danger { background: var(--danger-bg); color: var(--danger); }
.seg { border: 0; padding: 0; display: flex; gap: 8px; }
.chip {
  flex-direction: row; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 999px; padding: 8px 12px; color: var(--fg);
}

.print-head, .print-cust { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.print-head h1 { font-size: 1.4rem; }
.print-meta { text-align: left; display: flex; flex-direction: column; gap: 4px; }
.print-cust div { display: flex; flex-direction: column; gap: 2px; }
.print-cust span { color: var(--fg-muted); font-size: var(--text-xs); }
.print-table { width: 100%; border-collapse: collapse; margin: 12px 0 20px; }
.print-table th, .print-table td { border-bottom: 1px solid var(--border); padding: 8px; text-align: right; }
.print-foot { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.print-foot .grand { font-size: 1.2rem; }
.print-actions { display: flex; gap: 8px; margin-bottom: 16px; }
.thanks { color: var(--fg-muted); margin-top: 24px; }

.more-list a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 4px; border-bottom: 1px solid var(--border); min-height: 48px;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.96) translateY(6px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media (max-width: 980px) {
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  :root { --bottom: 64px; }
  #app { display: block; }
  .sidebar {
    display: none;
    position: fixed;
    inset: 0 0 0 auto;
    transform: none;
    z-index: 60;
    width: min(280px, 86vw);
    height: 100dvh;
  }
  .sidebar.open { display: flex; }
  .sidebar-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: color-mix(in srgb, #152824 40%, transparent);
  }
  .menu-btn { display: grid; }
  .top-cta { display: none; }
  .view { padding: 16px; padding-bottom: calc(var(--bottom) + 24px); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
    background: var(--bg-elevated); border-top: 1px solid var(--border);
    height: var(--bottom); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; font-size: 0.68rem; color: var(--fg-muted);
  }
  .bottom-nav a svg { width: 20px; height: 20px; }
  .bottom-nav a.is-active { color: var(--accent); }
  table.data th, table.data td { white-space: normal; }
  .grid-stats { grid-template-columns: 1fr; }
  .plate { max-width: 100%; height: 50px; }
  .plate .ir { width: 36px; flex: 0 0 36px; font-size: 0.46rem; }
  .pkg-grid { grid-template-columns: 1fr; }
}
