/* پنل مدیریت اقتصاد پلاس — راست‌به‌چپ، وزیرمتن، روشن/تاریک */
@font-face { font-family: Vazirmatn; src: url(fonts/vazirmatn_regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(fonts/vazirmatn_medium.ttf) format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(fonts/vazirmatn_bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --brand: #E30613; --brand-2: #B0050E; --brand-soft: #FDE8E9; --on-brand: #fff;
  --bg: #F6F5F2; --surface: #FFFFFF; --surface-2: #F3F1EE; --surface-3: #ECE9E4;
  --text: #16161A; --text-2: #5F5F66; --text-3: #8E8E96; --line: #E7E4DF; --line-2: #EFEDE9;
  --up: #0A8F5B; --up-soft: #E3F5EC; --warn: #C77700; --warn-soft: #FFF3DC; --down: #E30613; --down-soft: #FDE8E9;
  --info: #2563EB; --info-soft: #E6EEFF;
  --shadow: 0 1px 2px rgba(16,16,20,.04), 0 4px 16px rgba(16,16,20,.05);
  --shadow-lg: 0 10px 40px rgba(16,16,20,.18);
  --r: 14px; --r-lg: 20px; --side: 264px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --brand: #FF4D55; --brand-2: #E30613; --brand-soft: #3A1014; --on-brand: #fff;
  --bg: #0C0C0E; --surface: #151518; --surface-2: #1C1C21; --surface-3: #25252B;
  --text: #F1F1F3; --text-2: #B1B1B8; --text-3: #7C7C85; --line: #2A2A31; --line-2: #222228;
  --up: #3DDC97; --up-soft: #12301F; --warn: #F5B544; --warn-soft: #33270F; --down: #FF5A61; --down-soft: #3A1014;
  --info: #7AA2FF; --info-soft: #172443;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 10px 40px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: Vazirmatn, Tahoma, sans-serif; font-size: 14px; line-height: 1.75;
  background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--brand-soft); }
h1, h2, h3, h4 { margin: 0; line-height: 1.5; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); font-size: 12px; }
.ltr { direction: ltr; unicode-bidi: plaintext; text-align: left; }
.num { font-feature-settings: "tnum"; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.col { display: flex; flex-direction: column; gap: 12px; }
.hidden { display: none !important; }
.sp { height: 16px; }

/* ---------- اسکلت صفحه ---------- */
.layout { display: flex; min-height: 100vh; }
.side {
  width: var(--side); flex: 0 0 var(--side); background: var(--surface); border-left: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 18px 14px 24px; display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; }
.brand img { width: 42px; height: 42px; border-radius: 12px; object-fit: contain; background: var(--surface-2); }
.brand b { font-size: 16px; display: block; }
.brand span { font-size: 11.5px; color: var(--text-3); }
.nav-group { margin-top: 14px; }
.nav-title { font-size: 11px; color: var(--text-3); padding: 0 12px 6px; letter-spacing: .2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 12px; color: var(--text-2);
  font-weight: 500; transition: background .15s, color .15s;
}
.nav a svg { width: 19px; height: 19px; flex: none; stroke: currentColor; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.on { background: var(--brand-soft); color: var(--brand); }
.side-foot { margin-top: auto; padding: 16px 10px 0; font-size: 11.5px; color: var(--text-3); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-x: clip; }
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-2);
}
.top h1 { font-size: 18px; font-weight: 700; }
.top .sub { font-size: 12px; color: var(--text-3); }
.btn.burger { display: none; }
.quick { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); color: var(--text); }
.quick:hover { background: var(--surface-3); }
.quick svg { width: 18px; height: 18px; flex: none; stroke: var(--brand); }
.content { padding: 24px 28px 110px; max-width: 1280px; width: 100%; }
.scrim { display: none; }

@media (max-width: 960px) {
  .side { position: fixed; right: 0; top: 0; z-index: 60; transform: translateX(100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .side.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 55; }
  .btn.burger { display: inline-flex; }
  .top { padding: 10px 16px; }
  .content { padding: 16px 16px 120px; }
}

/* ---------- اجزا ---------- */
.card { background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-h h3 { font-size: 15px; font-weight: 700; }
.card-h .faint { margin-top: 2px; }
.card-b { padding: 18px 20px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g6 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .g6 { grid-template-columns: repeat(2, 1fr); } }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; stroke: currentColor; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.danger { color: var(--down); }
.btn.danger:hover { background: var(--down-soft); border-color: transparent; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 10px; }
.btn.icon { width: 36px; padding: 0; height: 36px; }
.btn.icon.sm { width: 30px; height: 30px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 11.5px; color: var(--text-3); line-height: 1.6; }
.input, select.input, textarea.input {
  width: 100%; height: 42px; padding: 0 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 96px; padding: 10px 13px; resize: vertical; line-height: 1.8; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.input.ltr { text-align: left; direction: ltr; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: 16px 18px, 21px 18px; background-size: 5px 5px; background-repeat: no-repeat; padding-left: 34px; }

.switch { position: relative; width: 44px; height: 26px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--surface-3); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(-18px); }
.switch input:focus-visible + i { outline: 2px solid var(--brand); outline-offset: 2px; }
.check-row { display: flex; align-items: center; gap: 12px; justify-content: space-between; padding: 10px 0; }
.check-row + .check-row { border-top: 1px solid var(--line-2); }
.check-row .t { font-weight: 500; }
.check-row .d { font-size: 12px; color: var(--text-3); }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 99px; font-size: 11.5px;
  font-weight: 500; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.badge.up { background: var(--up-soft); color: var(--up); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.down { background: var(--down-soft); color: var(--down); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; height: 34px; padding: 0 14px; border-radius: 10px; cursor: pointer; color: var(--text-2); font-weight: 500; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.kpi { padding: 16px 18px; }
.kpi .l { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 4px; line-height: 1.3; }
.kpi .s { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.kpi .ic { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); margin-bottom: 10px; }
.kpi .ic svg { width: 18px; height: 18px; stroke: currentColor; }

/* فهرست‌ها */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 14px; padding: 12px 20px; border-top: 1px solid var(--line-2); background: var(--surface); }
.item:first-child { border-top: 0; }
.item .t { font-weight: 700; }
.item .s { font-size: 12px; color: var(--text-3); }
.item.dragging { opacity: .5; }
.item.over { box-shadow: inset 0 3px 0 var(--brand); }
.item.off .t, .item.off .thumb { opacity: .5; }
.handle { cursor: grab; color: var(--text-3); display: grid; place-items: center; width: 22px; flex: none; }
.handle svg { width: 18px; height: 18px; stroke: currentColor; }
.thumb { width: 64px; height: 64px; border-radius: 14px; object-fit: cover; flex: none; background: var(--surface-2); display: grid; place-items: center; font-size: 28px; overflow: hidden; }
.thumb.wide { width: 148px; height: 36px; border-radius: 9px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.empty { padding: 44px 20px; text-align: center; color: var(--text-3); }
.empty svg { width: 42px; height: 42px; stroke: currentColor; opacity: .6; margin-bottom: 8px; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: right; font-weight: 500; color: var(--text-3); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl-wrap { overflow-x: auto; }

/* انتخاب‌گر نماد */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 6px 0 12px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--line-2); font-size: 13px; cursor: grab; user-select: none; }
.chip b { font-weight: 500; }
.chip .n { color: var(--text-3); font-size: 11px; min-width: 16px; text-align: center; }
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--text-3); width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; }
.chip button:hover { background: var(--surface-3); color: var(--down); }
.chip.dragging { opacity: .4; }
.chip.over { border-color: var(--brand); }

/* مودال */
.modal-back { position: fixed; inset: 0; z-index: 100; background: rgba(10,10,14,.45); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
.modal { width: min(620px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface);
  border-radius: 22px; box-shadow: var(--shadow-lg); animation: pop .18s; }
.modal.wide { width: min(880px, 100%); }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-h h3 { font-size: 16px; font-weight: 700; }
.modal-b { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-f { display: flex; gap: 10px; justify-content: flex-start; padding: 14px 20px; border-top: 1px solid var(--line-2); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* اعلان */
.toasts { position: fixed; bottom: 22px; left: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { min-width: 240px; max-width: 380px; padding: 12px 16px; border-radius: 14px; background: var(--text); color: var(--bg);
  box-shadow: var(--shadow-lg); font-size: 13px; animation: pop .2s; display: flex; gap: 10px; align-items: center; }
.toast.err { background: var(--down); color: #fff; }
.toast.ok { background: var(--up); color: #fff; }

/* نوار ذخیره */
.savebar { position: fixed; bottom: 18px; left: 50%; transform: translate(-50%, 140%); z-index: 40; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px 10px 18px; background: var(--text); color: var(--bg); border-radius: 18px; box-shadow: var(--shadow-lg);
  visibility: hidden; transition: transform .25s, visibility .25s; }
.savebar.show { transform: translate(-50%, 0); visibility: visible; }
.savebar .btn { height: 36px; }
.savebar .btn.ghost { color: var(--bg); }
.savebar .btn.ghost:hover { background: rgba(255,255,255,.12); }
@media (min-width: 961px) { .savebar { margin-right: calc(var(--side) / -2); } }

/* ورود */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 500px at 80% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent), var(--bg); }
.auth .card { width: min(420px, 100%); padding: 30px 28px; }
.auth .logo { width: 64px; height: 64px; border-radius: 18px; display: block; margin: 0 auto 12px; object-fit: contain; background: var(--surface-2); }
.auth h2 { text-align: center; font-size: 20px; }
.auth p { text-align: center; margin: 4px 0 22px; color: var(--text-3); font-size: 13px; }
.err-box { background: var(--down-soft); color: var(--down); border-radius: 12px; padding: 10px 14px; font-size: 13px; }
.note { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; font-size: 12.5px; color: var(--text-2); line-height: 1.9; }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.info { background: var(--info-soft); color: var(--info); }

/* انتخاب عکس */
.imgpick { display: flex; flex-direction: column; gap: 8px; }
.imgpick .pv { border-radius: 14px; background: var(--surface-2) center/cover no-repeat; border: 1px dashed var(--line); display: grid; place-items: center;
  color: var(--text-3); font-size: 12px; overflow: hidden; }
.imgpick .pv img { width: 100%; height: 100%; object-fit: contain; display: block; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--brand); width: 0; transition: width .2s; }

/* نمودار */
.chart { width: 100%; display: block; }
.chart .grid-l { stroke: var(--line-2); }
.chart .axis { fill: var(--text-3); font-size: 10px; font-family: Vazirmatn, Tahoma; }
.chart .ln { fill: none; stroke: var(--brand); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln2 { fill: none; stroke: var(--text-3); stroke-width: 1.6; stroke-dasharray: 4 4; }
.chart .ar { fill: url(#ga); }
.chart .bar { fill: var(--brand); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart .pt { fill: var(--surface); stroke: var(--brand); stroke-width: 2; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; background: var(--brand); vertical-align: middle; margin-left: 6px; }
.legend i.prev { background: var(--text-3); }
.share { display: flex; flex-direction: column; gap: 10px; }
.share .r { display: grid; grid-template-columns: minmax(0, 1fr) 54px; gap: 4px 10px; align-items: center; font-size: 12.5px; }
.share .bar-t { grid-column: 1 / -1; height: 7px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.share .bar-t i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.share .r span:nth-child(2) { text-align: left; color: var(--text-3); }

/* پیش‌نمایش گوشی */
.phone { width: 280px; margin: 0 auto; border-radius: 34px; border: 8px solid var(--text); background: var(--bg); padding: 14px 12px 18px;
  box-shadow: var(--shadow-lg); }
.phone .bar { height: 30px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line-2); margin-bottom: 10px; display: flex; align-items: center; padding: 0 10px; gap: 8px; font-size: 11px; font-weight: 700; }
.phone .blk { border-radius: 12px; background: var(--surface); border: 1px solid var(--line-2); padding: 8px 10px; margin-bottom: 8px; font-size: 11px; }
.phone .blk b { display: block; font-size: 11.5px; }
.phone .blk.banner { height: 48px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; border: 0; display: grid; place-items: center; }
.phone .tabbar { display: flex; justify-content: space-around; margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line-2); font-size: 10px; color: var(--text-3); }
.phone .tabbar .on { color: var(--brand); font-weight: 700; }

pre.code { direction: ltr; text-align: left; background: var(--surface-2); border-radius: 14px; padding: 14px; overflow: auto; max-height: 520px;
  font: 12px/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-word; margin: 0; }
.color-sw { display: flex; gap: 8px; flex-wrap: wrap; }
.color-sw button { width: 30px; height: 30px; border-radius: 10px; border: 2px solid transparent; cursor: pointer; }
.color-sw button.on { border-color: var(--text); }
input[type=color].input { padding: 4px; width: 56px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--brand); animation: spin .8s linear infinite; }
.loading { display: grid; place-items: center; padding: 60px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 10px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 14px; }
.menu { position: absolute; top: 52px; left: 20px; z-index: 50; min-width: 200px; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 16px; box-shadow: var(--shadow-lg); padding: 6px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 10px; border: 0; background: transparent; padding: 9px 12px; border-radius: 10px; cursor: pointer; text-align: right; }
.menu button:hover { background: var(--surface-2); }
.menu button svg { width: 17px; height: 17px; stroke: currentColor; }
.menu .who { padding: 8px 12px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.avatar { width: 36px; height: 36px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; cursor: pointer; border: 0; }
.status-on { color: var(--up); }
.kbd { font-size: 11px; background: var(--surface-2); border-radius: 6px; padding: 1px 6px; color: var(--text-2); }

/* گوشی: ردیف‌ها می‌شکنند، تب‌ها افقی اسکرول می‌خورند */
@media (max-width: 760px) {
  .top h1 { font-size: 16px; }
  .top .sub { display: none; }
  .tabs { display: flex; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .tabs button { flex: none; }
  .item { flex-wrap: wrap; padding: 12px 14px; gap: 10px; }
  .item > .grow { flex: 1 1 55%; min-width: 0; }
  .thumb { width: 52px; height: 52px; font-size: 22px; }
  .thumb.wide { width: 124px !important; height: 30px !important; }
  .card-h { flex-wrap: wrap; }
  .card-b { padding: 14px; }
  .kpi .v { font-size: 22px; }
  .modal-back { padding: 0; align-items: end; }
  .modal { max-height: 92vh; border-radius: 22px 22px 0 0; }
  .savebar { width: calc(100% - 24px); justify-content: space-between; }
  .phone { width: 240px; }
}
