@font-face { font-family: IRANSansX; src: url(fonts/IRANSansXFaNum-Regular.ttf); font-weight: 400; }
@font-face { font-family: IRANSansX; src: url(fonts/IRANSansXFaNum-Medium.ttf); font-weight: 500; }
@font-face { font-family: IRANSansX; src: url(fonts/IRANSansXFaNum-DemiBold.ttf); font-weight: 600; }
@font-face { font-family: IRANSansX; src: url(fonts/IRANSansXFaNum-Bold.ttf); font-weight: 700; }
@font-face { font-family: IRANSansX; src: url(fonts/IRANSansXFaNum-ExtraBold.ttf); font-weight: 800; }

:root {
  --rose: #B83E66;
  --rose-tint: #FBEAF0;
  --ink: #1E1D24;
  --ink-soft: #3D3C46;
  --muted: #6B6A75;
  --field: #F4F3F6;
  --bg: #F2F1F4;
  --surface: #FFFFFF;
  --surface-focus: #FFFFFF;
  --hover: #FAF9FB;
  --border: #ECEAF0;
  --success: #2E7D4F;
  --success-tint: #E6F4EC;
  --warning: #A86400;
  --warning-tint: #FFF3D6;
  --danger: #C0392B;
  --danger-tint: #FDECEA;
  --on-accent: #FFFFFF;
  --strong-bg: #1E1D24;   /* toasts, selected tab */
  --strong-fg: #FFFFFF;
  --overlay: rgba(30, 29, 36, .35);
  --radius: 22px;
  color-scheme: light;
}

/* Dark theme: chosen in the panel (data-theme) or by the system. */
:root[data-theme="dark"] {
  --rose: #E0708F;
  --rose-tint: #3A2430;
  --ink: #F1EFF5;
  --ink-soft: #D3D0DB;
  --muted: #A09DAB;
  --field: #2A2832;
  --bg: #141318;
  --surface: #1E1D24;
  --surface-focus: #24232B;
  --hover: #26252D;
  --border: #33313B;
  --success: #6FCF97;
  --success-tint: #1D3326;
  --warning: #F2B661;
  --warning-tint: #3A2E1A;
  --danger: #F28B82;
  --danger-tint: #3D2120;
  --on-accent: #FFFFFF;
  --strong-bg: #F1EFF5;
  --strong-fg: #1E1D24;
  --overlay: rgba(0, 0, 0, .55);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --rose: #E0708F;
    --rose-tint: #3A2430;
    --ink: #F1EFF5;
    --ink-soft: #D3D0DB;
    --muted: #A09DAB;
    --field: #2A2832;
    --bg: #141318;
    --surface: #1E1D24;
    --surface-focus: #24232B;
    --hover: #26252D;
    --border: #33313B;
    --success: #6FCF97;
    --success-tint: #1D3326;
    --warning: #F2B661;
    --warning-tint: #3A2E1A;
    --danger: #F28B82;
    --danger-tint: #3D2120;
    --on-accent: #FFFFFF;
    --strong-bg: #F1EFF5;
    --strong-fg: #1E1D24;
    --overlay: rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: IRANSansX, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  direction: rtl;
}
button, input, select, textarea { font: inherit; color: inherit; }
button, [data-click], .row-link, a { cursor: pointer; }
input, textarea, select { cursor: text; }
select { cursor: pointer; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }

/* ---------- layout */
.app { display: grid; grid-template-columns: 250px 1fr; height: 100vh; gap: 20px; padding: 20px; }
.side {
  background: var(--surface); border-radius: 28px; padding: 22px 16px; display: flex; flex-direction: column; gap: 6px;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 0 10px 18px; }
.brand-logo { width: 34px; height: 34px; flex: none; }
.brand b { font-size: 26px; font-weight: 800; color: var(--rose); }
.brand span { font-size: 12px; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; border-radius: 14px;
  color: var(--ink-soft); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--field); }
.nav a.active { background: var(--rose); color: var(--on-accent); font-weight: 700; }
.nav svg { width: 20px; height: 20px; flex: none; }
.side .spacer { flex: 1; }
.me { background: var(--field); border-radius: 16px; padding: 12px 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.me .who { flex: 1 1 100%; min-width: 0; margin-bottom: 4px; }
.me .who b { display: block; font-size: 13px; }
.me .who span { font-size: 11px; color: var(--muted); }

.main { overflow: auto; padding-bottom: 20px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; font-weight: 800; margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.page-head .grow { flex: 1; }

.card { background: var(--surface); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 16px; font-weight: 800; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card h2 .grow { flex: 1; }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 1100px) { .grid.two { grid-template-columns: 1fr; } }

.stat { background: var(--surface); border-radius: var(--radius); padding: 18px 20px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat b { display: block; font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat.rose b { color: var(--rose); }

/* ---------- controls */
.btn {
  height: 42px; padding: 0 18px; border-radius: 14px; border: 0; background: var(--rose); color: var(--on-accent);
  font-weight: 700; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); }
.btn svg { width: 18px; height: 18px; flex: none; }
a.btn { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--field); color: var(--ink); }
.btn.danger { background: var(--danger-tint); color: var(--danger); }
.btn.small { height: 34px; padding: 0 12px; border-radius: 11px; font-size: 12px; }
.icon-btn { width: 36px; height: 36px; border-radius: 11px; border: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.icon-btn:hover { background: var(--field); color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.field small { font-size: 11px; color: var(--muted); }
.input, select.input, textarea.input {
  height: 44px; border: 1.5px solid transparent; background: var(--field); border-radius: 14px; padding: 0 14px; outline: none; width: 100%;
}
textarea.input { height: auto; padding: 10px 14px; }
.input:focus { border-color: var(--rose); background: var(--surface-focus); }
.form { display: grid; gap: 14px; }
.form.cols { grid-template-columns: 1fr 1fr; }
.form .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--rose); cursor: pointer; }
.search { position: relative; }
.search input { padding-right: 40px; width: 340px; background: var(--surface); }
.search input:focus { background: var(--surface); }
.search svg { position: absolute; right: 13px; top: 12px; width: 19px; height: 19px; color: var(--muted); }

/* ---------- tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: right; font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 10px 10px; }
td { padding: 12px 10px; border-top: 1px solid var(--border); vertical-align: middle; }
tr.row-link:hover td { background: var(--hover); }
td.num, th.num { text-align: left; }
.sub { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.sub.ltr { display: block; text-align: right; }
td.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 9px; font-size: 11px; font-weight: 700;
  background: var(--field); color: var(--ink-soft); margin-left: 4px; white-space: nowrap;
}
.chip.rose { background: var(--rose-tint); color: var(--rose); }
.chip.ok { background: var(--success-tint); color: var(--success); }
.chip.warn { background: var(--warning-tint); color: var(--warning); }
.chip.bad { background: var(--danger-tint); color: var(--danger); }

.pager { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; color: var(--muted); font-size: 12px; }
.pager .btns { display: flex; gap: 6px; }

.kv { display: grid; grid-template-columns: 140px 1fr; row-gap: 10px; font-size: 13px; }
.kv span { color: var(--muted); }

.module-card { border: 1.5px solid var(--border); border-radius: 18px; padding: 16px; }
.module-card + .module-card { margin-top: 12px; }
.module-card header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.module-card header b { font-size: 15px; }
.module-card header .grow { flex: 1; }
.feature-list { display: flex; flex-wrap: wrap; gap: 6px; }

.features-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 16px; }
.group-title { font-size: 12px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; grid-column: 1 / -1; }

.tabs { display: inline-flex; background: var(--surface); border-radius: 14px; padding: 4px; gap: 4px; }
.tabs button { border: 0; background: transparent; height: 36px; padding: 0 16px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.tabs button.on { background: var(--strong-bg); color: var(--strong-fg); }

.plan-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }

/* ---------- login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px 0; }
.login .card { width: min(400px, calc(100vw - 32px)); padding: 32px; }
.login .card .brand { justify-content: flex-start; }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }

/* ---------- dialog & toast */
.overlay { position: fixed; inset: 0; background: var(--overlay); display: grid; place-items: center; z-index: 10; }
.dialog { background: var(--surface); border-radius: 26px; padding: 24px; width: min(560px, 92vw); max-height: 88vh; overflow: auto; }
.dialog h3 { margin: 0 0 16px; font-size: 18px; }
.dialog .actions { display: flex; justify-content: flex-start; gap: 8px; margin-top: 20px; flex-direction: row-reverse; }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 14px; font-size: 13px; z-index: 20; max-width: 80vw;
  background: var(--strong-bg); color: var(--strong-fg);
}
.toast.bad { background: var(--danger); color: #fff; }
.note { padding: 10px 14px; border-radius: 12px; font-size: 12px; line-height: 1.9; }
.note { background: var(--field); color: var(--ink-soft); }
.note.warn { background: var(--warning-tint); color: var(--warning); }
.note.ok { background: var(--success-tint); color: var(--success); }
.copy-box { background: var(--field); border-radius: 12px; padding: 10px 12px; font-size: 12px; word-break: break-all; direction: ltr; text-align: left; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--rose); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- theme button, mobile top bar */
.theme-btn { position: fixed; top: 14px; left: 14px; z-index: 5; background: var(--surface); }
.topbar { display: none; }
.nav-close { display: none !important; }
.content { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.content .main { flex: 1; min-height: 0; }
.scrim { display: none; }
.app { transition: none; }
img.brand-logo { background: transparent; }
.pay-wrap, .card { max-width: 100%; }

/* ---------- tablet */
@media (max-width: 1100px) {
  .app { grid-template-columns: 220px 1fr; gap: 14px; padding: 14px; }
  .plan-cards { grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); }
}

/* ---------- phone: the menu becomes a drawer, everything one column */
@media (max-width: 860px) {
  body { font-size: 13.5px; }
  .app { display: block; height: auto; min-height: 100vh; padding: 0 12px 24px; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 6;
    margin: 0 -12px 12px; padding: 10px 12px; background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .topbar .brand { padding: 0; flex: 1; }
  .topbar .brand b { font-size: 20px; }
  .topbar .brand-logo { width: 28px; height: 28px; }
  .side {
    position: fixed; top: 0; bottom: 0; right: 0; width: min(290px, 84vw); z-index: 30;
    border-radius: 24px 0 0 24px; transform: translateX(105%); transition: transform .22s ease;
    overflow-y: auto; box-shadow: 0 0 40px rgba(0, 0, 0, .25);
  }
  .app.nav-open .side { transform: none; }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 25; }
  .content { display: block; }
  .main { overflow: visible; padding-bottom: 0; }
  .nav-close { display: grid !important; }
  .page-head { flex-wrap: wrap; gap: 10px; }
  .page-head h1 { font-size: 19px; }
  .page-head > :not(.grow) { flex-wrap: wrap; }
  .card { padding: 16px; border-radius: 18px; overflow-x: auto; }
  .card table:has(th:nth-child(5)) { min-width: 640px; }
  .card table:has(th:nth-child(4)) { min-width: 480px; }
  .grid.stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; border-radius: 18px; }
  .stat b { font-size: 20px; }
  .form.cols { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; row-gap: 2px; }
  .kv > span { margin-top: 8px; }
  .search, .search input { width: 100%; }
  .features-grid { grid-template-columns: 1fr; }
  .plan-cards { grid-template-columns: 1fr; }
  .tabs { display: flex; overflow-x: auto; max-width: 100%; }
  .tabs button { flex: none; }
  .dialog { width: calc(100vw - 20px); max-height: 92vh; padding: 18px; border-radius: 20px; }
  .dialog .actions { flex-wrap: wrap; }
  .dialog [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .module-card header { flex-wrap: wrap; }
  .btn { height: 40px; padding: 0 14px; }
  .toast { bottom: 16px; max-width: calc(100vw - 32px); }
  .theme-btn { top: 10px; left: 10px; }
}

/* ---------- profile pictures, support conversation */
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; object-fit: cover;
  background: var(--rose-tint); color: var(--rose); font-weight: 800; overflow: hidden; }
.me-avatar { border: 0; padding: 0; background: none; cursor: pointer; border-radius: 50%; }
.me .who { flex: 1 1 calc(100% - 60px); }
.avatar-row { display: flex; align-items: center; gap: 16px; }
.avatar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.msg { display: flex; align-items: flex-start; gap: 10px; max-width: 86%; align-self: flex-end; flex-direction: row-reverse; }
.msg.kasra { align-self: flex-start; flex-direction: row; }
.msg-body { background: var(--field); border-radius: 16px; padding: 10px 14px; white-space: pre-wrap; line-height: 1.9; min-width: 0; }
.msg.kasra .msg-body { background: var(--rose-tint); }

.table-wrap { overflow-x: auto; }
