@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-Regular.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-Medium.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-Bold.woff2) format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(fonts/Vazirmatn-Black.woff2) format("woff2"); font-weight: 900; font-display: swap; }

:root {
  --bg: #f4f6f9; --surface: #ffffff; --surface-2: #f8fafc; --border: #e4e8ee; --text: #131a26; --muted: #667085;
  --primary: #0d8f7c; --primary-ink: #ffffff; --primary-soft: #e3f5f1;
  --warn: #b7791f; --warn-soft: #fdf3e1; --danger: #c2413b; --danger-soft: #fdecea;
  --info: #3b6fd6; --info-soft: #e8effd; --ok: #1f8a4c; --ok-soft: #e4f4ea; --violet: #7a4fd6; --violet-soft: #efe9fc;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
  --radius: 14px; --side: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1218; --surface: #161b23; --surface-2: #1b212b; --border: #262e3a; --text: #e8ecf2; --muted: #97a1b2;
    --primary: #2cc3a9; --primary-ink: #04221d; --primary-soft: #12302b;
    --warn: #e3a948; --warn-soft: #33270f; --danger: #ef6b64; --danger-soft: #3a1918;
    --info: #79a2f2; --info-soft: #172442; --ok: #4cc785; --ok-soft: #13301f; --violet: #a98af0; --violet-soft: #251c3b;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1218; --surface: #161b23; --surface-2: #1b212b; --border: #262e3a; --text: #e8ecf2; --muted: #97a1b2;
  --primary: #2cc3a9; --primary-ink: #04221d; --primary-soft: #12302b;
  --warn: #e3a948; --warn-soft: #33270f; --danger: #ef6b64; --danger-soft: #3a1918;
  --info: #79a2f2; --info-soft: #172442; --ok: #4cc785; --ok-soft: #13301f; --violet: #a98af0; --violet-soft: #251c3b;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.7 Vazirmatn, Tahoma, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--primary); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--surface); border-inline-start: 0; border-inline-end: 1px solid var(--border); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .logo { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, var(--primary), #3fb7a3); color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 18px; }
.brand b { display: block; font-size: 16px; line-height: 1.3; }
.brand span { font-size: 12px; color: var(--muted); }
.nav button { all: unset; display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; cursor: pointer; color: var(--muted); font-weight: 500; width: 100%; box-sizing: border-box; }
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.on { background: var(--primary-soft); color: var(--primary); }
.nav svg { width: 19px; height: 19px; flex: none; }
.nav .count { margin-inline-start: auto; background: var(--warn); color: #fff; border-radius: 99px; font-size: 12px; padding: 0 8px; line-height: 20px; }
.side .foot { margin-top: auto; display: flex; gap: 6px; }
.main { padding: 26px 30px 60px; min-width: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { font-size: 22px; margin: 0; font-weight: 800; }
.head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border); background: var(--surface); padding: 8px 15px; border-radius: 10px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }
.input, textarea.input, select.input { width: 100%; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 9px 12px; outline: none; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { resize: vertical; min-height: 90px; }
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
label.f small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 42px; height: 24px; border-radius: 99px; background: var(--border); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { inset-inline-start: 21px; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px 20px; }
.card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 700; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two { grid-template-columns: 1.6fr 1fr; }
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.kpi .val { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -.3px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* chips / badges */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 5px 13px; cursor: pointer; font-size: 13px; font-weight: 500; display: inline-flex; gap: 6px; align-items: center; }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { opacity: .7; }
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 1px 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.s-pending { background: var(--warn-soft); color: var(--warn); }
.s-approved { background: var(--info-soft); color: var(--info); }
.s-shipped { background: var(--ok-soft); color: var(--ok); }
.s-rejected, .s-cancelled { background: var(--danger-soft); color: var(--danger); }
.s-awaiting_payment, .s-draft { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.p-telegram { background: #e5f2fd; color: #1f7ac7; } .p-bale { background: #e3f6ef; color: #148a63; } .p-rubika { background: #f4e9fb; color: #8c3bbf; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .p-telegram { background: #12283b; color: #6db6f2; } :root:not([data-theme="light"]) .p-bale { background: #102c22; color: #4fd1a2; } :root:not([data-theme="light"]) .p-rubika { background: #2a1838; color: #c98af0; } }
:root[data-theme="dark"] .p-telegram { background: #12283b; color: #6db6f2; } :root[data-theme="dark"] .p-bale { background: #102c22; color: #4fd1a2; } :root[data-theme="dark"] .p-rubika { background: #2a1838; color: #c98af0; }

/* tables / lists */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.scroll-x { overflow-x: auto; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; opacity: .5; display: block; margin: 0 auto 10px; }
.amount { font-weight: 800; font-variant-numeric: tabular-nums; }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 170px; padding-top: 10px; }
.bars .b { flex: 1; background: var(--primary-soft); border-radius: 6px 6px 2px 2px; position: relative; min-height: 3px; transition: background .15s; }
.bars .b.has { background: var(--primary); }
.bars .b:hover::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 3px 9px; border-radius: 7px; font-size: 12px; white-space: nowrap; z-index: 2; }
.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 6px; }
.funnel .step { display: grid; grid-template-columns: 120px 1fr 70px; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.funnel .track { background: var(--surface-2); border-radius: 7px; height: 22px; overflow: hidden; border: 1px solid var(--border); }
.funnel .fill { height: 100%; background: linear-gradient(90deg, var(--primary), #3fb7a3); border-radius: 6px; }
[dir="rtl"] .funnel .fill { background: linear-gradient(270deg, var(--primary), #3fb7a3); }
.funnel .num { text-align: end; font-variant-numeric: tabular-nums; }

/* products */
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.pcard { overflow: hidden; display: flex; flex-direction: column; cursor: pointer; transition: transform .12s, box-shadow .12s; }
.pcard:hover { transform: translateY(-2px); }
.pcard .cover { aspect-ratio: 4/3; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); position: relative; }
.pcard .cover img { width: 100%; height: 100%; object-fit: cover; }
.pcard .cover .n { position: absolute; bottom: 8px; inset-inline-start: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; border-radius: 99px; padding: 0 9px; }
.pcard .off { position: absolute; top: 8px; inset-inline-end: 8px; }
.pcard .body { padding: 13px 15px 15px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.pcard .t { font-weight: 700; line-height: 1.5; }
.pcard .price { font-weight: 800; color: var(--primary); }
.pcard .id { font-size: 12px; color: var(--muted); }
.pcard.add { border: 2px dashed var(--border); box-shadow: none; background: transparent; align-items: center; justify-content: center; min-height: 260px; color: var(--muted); font-weight: 600; }
.pcard.add:hover { border-color: var(--primary); color: var(--primary); }

/* drawer */
#drawer-backdrop { position: fixed; inset: 0; background: rgba(10,14,20,.45); z-index: 40; }
#drawer { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(760px, 100vw); background: var(--bg); z-index: 41; box-shadow: 0 0 40px rgba(0,0,0,.2); display: flex; flex-direction: column; }
.dhead { display: flex; align-items: center; gap: 10px; padding: 16px 22px; border-bottom: 1px solid var(--border); background: var(--surface); }
.dhead h2 { margin: 0; font-size: 18px; flex: 1; }
.dbody { flex: 1; overflow-y: auto; padding: 20px 22px; }
.dfoot { padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.receipt { width: 100%; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); min-height: 160px; display: grid; place-items: center; overflow: hidden; cursor: zoom-in; }
.receipt img { width: 100%; max-height: 520px; object-fit: contain; display: block; }
.paybox { background: var(--warn-soft); border-radius: 12px; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 14px 0; }
.paybox .amount { font-size: 22px; color: var(--warn); }
.copy { all: unset; cursor: pointer; color: var(--muted); padding: 2px 4px; border-radius: 6px; }
.copy:hover { color: var(--primary); background: var(--primary-soft); }
.copy svg { width: 15px; height: 15px; vertical-align: -3px; }

/* product editor */
.editor { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.ph { position: relative; aspect-ratio: 1; border-radius: 11px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); cursor: grab; }
.ph img { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.ph .cov { position: absolute; top: 6px; inset-inline-start: 6px; background: var(--primary); color: var(--primary-ink); font-size: 11px; border-radius: 99px; padding: 0 8px; font-weight: 700; }
.ph .tools { position: absolute; bottom: 5px; inset-inline-end: 5px; display: flex; gap: 4px; }
.ph .tools button { all: unset; background: rgba(0,0,0,.6); color: #fff; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; cursor: pointer; }
.ph .tools svg { width: 14px; height: 14px; }
.ph.drag { opacity: .4; }
.ph.over { outline: 2px solid var(--primary); outline-offset: 2px; }
.drop { aspect-ratio: 1; border: 2px dashed var(--border); border-radius: 11px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 12px; cursor: pointer; padding: 6px; }
.drop:hover, .drop.over { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.drop svg { width: 24px; height: 24px; display: block; margin: 0 auto 4px; }
.feat { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.feat .input { padding: 7px 10px; }
.tg { background: #dfe9e4; border-radius: 14px; padding: 14px; position: sticky; top: 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tg { background: #0f1a17; } }
:root[data-theme="dark"] .tg { background: #0f1a17; }
.tg .bubble { background: var(--surface); border-radius: 14px 14px 14px 4px; overflow: hidden; box-shadow: 0 1px 1px rgba(0,0,0,.1); }
.tg .bubble img { width: 100%; display: block; aspect-ratio: 4/3; object-fit: cover; }
.tg .cap { padding: 9px 12px 10px; font-size: 13px; white-space: pre-wrap; line-height: 1.7; }
.tg .tgbtn { margin-top: 5px; background: rgba(255,255,255,.55); border-radius: 10px; text-align: center; padding: 8px; font-size: 13px; font-weight: 600; color: #2a7a5f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tg .tgbtn { background: rgba(255,255,255,.08); color: #6fd3b0; } }
:root[data-theme="dark"] .tg .tgbtn { background: rgba(255,255,255,.08); color: #6fd3b0; }
.tg .lbl { font-size: 12px; color: #5b6b64; margin-bottom: 8px; font-weight: 600; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 80% -10%, var(--primary-soft), transparent), var(--bg); }
.login .card { width: min(400px, 100%); padding: 30px 28px; }
.login h1 { margin: 14px 0 4px; font-size: 22px; }
.login .err { color: var(--danger); font-size: 13px; min-height: 22px; }

/* misc */
#toasts { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 11px; box-shadow: var(--shadow); font-size: 14px; max-width: 360px; animation: up .2s ease-out; }
.toast.err { background: var(--danger); color: #fff; }
@keyframes up { from { transform: translateY(8px); opacity: 0; } }
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 70; display: grid; place-items: center; cursor: zoom-out; padding: 20px; }
#lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }
.linkbox { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.linkbox code { flex: 1; direction: ltr; text-align: left; font-size: 13px; word-break: break-all; }
.note { background: var(--info-soft); color: var(--info); border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress > div { height: 100%; background: var(--primary); }
.spin { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; padding: 40px; }
.mobile-nav { display: none; }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .two { grid-template-columns: 1fr; } .editor { grid-template-columns: 1fr; } .tg { position: static; } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 16px 90px; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border); z-index: 30; overflow-x: auto; }
  .mobile-nav button { all: unset; flex: 1; min-width: 64px; padding: 8px 4px 10px; text-align: center; font-size: 11px; color: var(--muted); }
  .mobile-nav button.on { color: var(--primary); }
  .mobile-nav svg { width: 21px; height: 21px; display: block; margin: 0 auto 2px; }
  .kv { grid-template-columns: 90px 1fr; }
  .head h1 { font-size: 19px; }
  .funnel .step { grid-template-columns: 96px 1fr 54px; }
  .hide-m { display: none; }
}

/* subscription banner (page panel) */
.subbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.subbar.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.subbar.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* super-admin */
.adm { max-width: 1180px; margin: 0 auto; padding: 24px 20px 70px; }
.adm-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.adm-top h1 { margin: 0; font-size: 22px; flex: 1; }
.pg-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.pg { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.pg h3 { margin: 0; font-size: 17px; }
.pg .id { font-size: 12px; color: var(--muted); direction: ltr; text-align: right; }
.pg .plats { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 4px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.pill .d { width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.pill.running .d { background: var(--ok); } .pill.running { color: var(--text); }
.pill.crashed .d, .pill.starting .d { background: var(--warn); }
.pill.off .d { background: var(--muted); opacity: .5; }
.exp { font-size: 13px; }
.exp.soon { color: var(--warn); font-weight: 600; } .exp.over { color: var(--danger); font-weight: 600; }
.pg .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.logbox { direction: ltr; text-align: left; background: #0b0f14; color: #cfd8e3; font: 12px/1.5 ui-monospace, Consolas, monospace; border-radius: 10px; padding: 10px 12px; max-height: 340px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.secret { font: 600 18px ui-monospace, Consolas, monospace; direction: ltr; letter-spacing: .5px; }
.sec-h { font-size: 13px; font-weight: 700; color: var(--muted); margin: 18px 0 8px; }
.plat-box { border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: var(--surface-2); }
.plat-box .row { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
@media (max-width: 760px) { .pg-list { grid-template-columns: 1fr; } .adm { padding: 16px 16px 60px; } }
