/* پایه‌ی طراحی: کلاسیک، مشکی و طلاییِ عتیقه، فونتِ وزیرمتن.
   رنگ‌ها فقط از متغیرها خوانده شوند تا تم‌های برند (data-theme) همه‌جا اعمال شوند. */

@font-face { font-family: "Vazirmatn"; font-weight: 400; font-display: swap; src: url("/fonts/Vazirmatn-Regular.ttf") format("truetype"); }
@font-face { font-family: "Vazirmatn"; font-weight: 500; font-display: swap; src: url("/fonts/Vazirmatn-Medium.ttf") format("truetype"); }
@font-face { font-family: "Vazirmatn"; font-weight: 700; font-display: swap; src: url("/fonts/Vazirmatn-Bold.ttf") format("truetype"); }
@font-face { font-family: "Vazirmatn"; font-weight: 800; font-display: swap; src: url("/fonts/Vazirmatn-ExtraBold.ttf") format("truetype"); }
@font-face { font-family: "Vazirmatn"; font-weight: 900; font-display: swap; src: url("/fonts/Vazirmatn-Black.ttf") format("truetype"); }

:root, [data-theme="gold"] {
  --bg: #0b0a08;
  --bg-2: #12100c;
  --surface: #17140f;
  --surface-2: #1f1b14;
  --surface-3: #29241a;
  --line: rgba(212, 175, 55, .20);
  --line-strong: rgba(212, 175, 55, .45);
  --accent: #d4af37;
  --accent-2: #b8912f;
  --accent-3: #f3e2a9;
  --accent-ink: #1a1408;
  --text: #f2ead6;
  --muted: #a89d82;
  --faint: #6f6754;
  --ok: #7fae6c;
  --warn: #e0a64a;
  --danger: #cf5b45;
  --info: #7aa7c7;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --glow: 0 0 0 1px rgba(212, 175, 55, .25), 0 8px 24px rgba(0, 0, 0, .5);
  --radius: 14px;
  --radius-sm: 10px;
  --gap: 14px;
  --gold-grad: linear-gradient(180deg, #f6e4a6 0%, #d9b552 38%, #b08a2e 70%, #8a6a1f 100%);
}
[data-theme="silver"] {
  --bg: #0a0c10; --bg-2: #0f121a; --surface: #141823; --surface-2: #1a2030; --surface-3: #232a3d;
  --line: rgba(192, 200, 214, .20); --line-strong: rgba(192, 200, 214, .45);
  --accent: #c9d1de; --accent-2: #9aa6ba; --accent-3: #eef2f8; --accent-ink: #10141c;
  --text: #edf0f6; --muted: #9aa3b5; --faint: #646d80;
  --gold-grad: linear-gradient(180deg, #ffffff 0%, #d5dbe6 40%, #9ea9bc 75%, #6f7a8e 100%);
}
[data-theme="wine"] {
  --bg: #0d0709; --bg-2: #14090d; --surface: #1c0d12; --surface-2: #261219; --surface-3: #331821;
  --line: rgba(230, 170, 150, .22); --line-strong: rgba(230, 170, 150, .48);
  --accent: #e7b29c; --accent-2: #c48a74; --accent-3: #f7dccf; --accent-ink: #2a0e14;
  --text: #f5e7e1; --muted: #b8968c; --faint: #7a5d57;
  --gold-grad: linear-gradient(180deg, #fbe3d6 0%, #e7b29c 40%, #b97c66 75%, #8a5545 100%);
}
[data-theme="emerald"] {
  --bg: #060b09; --bg-2: #0a120e; --surface: #0e1813; --surface-2: #13211a; --surface-3: #1a2c23;
  --line: rgba(212, 175, 55, .22); --line-strong: rgba(212, 175, 55, .48);
  --accent: #d4af37; --accent-2: #b8912f; --accent-3: #f3e2a9; --accent-ink: #0c1a12;
  --text: #ecf1e8; --muted: #9fb0a2; --faint: #66776a;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  background:
    radial-gradient(1200px 500px at 50% -120px, rgba(212, 175, 55, .10), transparent 60%),
    radial-gradient(800px 400px at 100% 100%, rgba(212, 175, 55, .05), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
::selection { background: rgba(212, 175, 55, .35); }

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px calc(env(safe-area-inset-bottom, 0px) + 40px);
}

/* ---------- تایپوگرافی ---------- */
.h1 { font-size: 24px; font-weight: 900; line-height: 1.4; margin: 0; letter-spacing: -.2px; }
.h2 { font-size: 18px; font-weight: 800; line-height: 1.5; margin: 0; }
.h3 { font-size: 15px; font-weight: 700; margin: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.num { font-feature-settings: "tnum"; }
.gold-text {
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack > * + * { margin-top: var(--gap); }
.hidden { display: none !important; }

/* ---------- سربرگِ صفحه ---------- */
.page-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; }
.page-head .titles { flex: 1 1 auto; min-width: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.back-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; flex: 0 0 auto;
}
.back-btn::before { content: "→"; font-size: 18px; color: var(--accent); }
.ornament {
  display: flex; align-items: center; gap: 10px; color: var(--accent); margin: 22px 0 12px;
  font-weight: 800; font-size: 15px;
}
.ornament::before, .ornament::after {
  content: ""; flex: 1 1 auto; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}
.ornament .diamond { width: 7px; height: 7px; transform: rotate(45deg); background: var(--accent); flex: 0 0 auto; }

/* ---------- کارت ---------- */
.card {
  position: relative;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card.framed::after {
  content: ""; position: absolute; inset: 5px; border: 1px solid var(--line); border-radius: calc(var(--radius) - 5px);
  pointer-events: none;
}
.card.tap { cursor: pointer; transition: transform .12s ease, border-color .12s ease; }
.card.tap:active { transform: scale(.985); }
.card.tap:hover { border-color: var(--line-strong); }
.card + .card { margin-top: 12px; }
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-title .icon { font-size: 22px; line-height: 1; }
.divider { height: 1px; background: var(--line); margin: 12px 0; border: 0; }

/* ---------- دکمه‌ها ---------- */
.btn {
  appearance: none; border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  border-radius: 12px; padding: 11px 16px; font-weight: 700; font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px;
  transition: filter .12s ease, transform .08s ease, opacity .12s;
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--gold-grad); color: var(--accent-ink); border-color: transparent; box-shadow: 0 6px 18px rgba(212, 175, 55, .22); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { border-color: rgba(207, 91, 69, .6); color: #f2b3a6; background: rgba(207, 91, 69, .08); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn .spinner { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1 1 140px; }

/* ---------- فرم ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-weight: 700; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 12.5px; }
.input, .select, .textarea {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px;
  outline: none; min-height: 46px; transition: border-color .12s, box-shadow .12s;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.8; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(212, 175, 55, .15); }
.input.ltr { direction: ltr; text-align: left; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  flex: 1 1 auto; min-width: 64px; min-height: 42px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-2); cursor: pointer; padding: 6px 10px; font-weight: 600;
}
.seg button.on { background: var(--gold-grad); color: var(--accent-ink); border-color: transparent; font-weight: 800; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; cursor: pointer; }
.switch .knob {
  width: 48px; height: 28px; border-radius: 99px; background: var(--surface-3); border: 1px solid var(--line);
  position: relative; flex: 0 0 auto; transition: background .15s;
}
.switch .knob::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--muted); transition: transform .15s, background .15s;
}
.switch.on .knob { background: rgba(212, 175, 55, .35); border-color: var(--accent); }
.switch.on .knob::after { transform: translateX(-20px); background: var(--accent); }

/* ---------- نشان‌ها و آمار ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 99px; font-size: 12px;
  font-weight: 700; border: 1px solid var(--line-strong); color: var(--accent); background: rgba(212, 175, 55, .08);
  white-space: nowrap;
}
.badge.ok { color: #b9dcae; border-color: rgba(127, 174, 108, .5); background: rgba(127, 174, 108, .1); }
.badge.warn { color: #f1c98a; border-color: rgba(224, 166, 74, .5); background: rgba(224, 166, 74, .1); }
.badge.danger { color: #f2b3a6; border-color: rgba(207, 91, 69, .5); background: rgba(207, 91, 69, .1); }
.badge.muted { color: var(--muted); border-color: var(--line); background: transparent; }
.sep { display: inline-block; width: 1px; height: .95em; background: currentColor; opacity: .35; margin: 0 .55em; vertical-align: -.12em; }
.badge.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.stat .v { font-size: 22px; font-weight: 900; }
.stat .k { color: var(--muted); font-size: 12.5px; }
.progress { height: 8px; border-radius: 99px; background: var(--bg-2); border: 1px solid var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--gold-grad); border-radius: 99px; transition: width .4s; }

/* ---------- لیست ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item.tap { cursor: pointer; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center; font-weight: 800;
  background: radial-gradient(circle at 35% 30%, var(--surface-3), var(--bg-2)); border: 1px solid var(--line-strong);
  color: var(--accent);
}
.rank { width: 30px; text-align: center; font-weight: 900; color: var(--accent); flex: 0 0 auto; }

/* ---------- تب ---------- */
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 13px; margin-bottom: 14px; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1 0 auto; border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; cursor: pointer;
  font-weight: 700; color: var(--muted); white-space: nowrap;
}
.tabs button.on { background: var(--surface-3); color: var(--accent); box-shadow: inset 0 0 0 1px var(--line-strong); }

/* ---------- حالت‌ها ---------- */
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty .icon { font-size: 40px; margin-bottom: 6px; opacity: .85; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 60px 0; }
.error-box { border-color: rgba(207, 91, 69, .5); }

/* ---------- توست و پنجره ---------- */
#toasts {
  position: fixed; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); display: flex;
  flex-direction: column; align-items: center; gap: 8px; z-index: 1000; pointer-events: none; padding: 0 16px;
}
.toast {
  pointer-events: auto; max-width: 520px; width: 100%; background: var(--surface-3); border: 1px solid var(--line-strong);
  border-radius: 12px; padding: 11px 14px; box-shadow: var(--shadow); font-weight: 600;
  animation: toast-in .2s ease-out;
}
.toast.ok { border-color: rgba(127, 174, 108, .6); }
.toast.error { border-color: rgba(207, 91, 69, .7); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 900; display: flex; align-items: flex-end;
  justify-content: center; animation: fade-in .15s ease-out;
}
.sheet {
  width: 100%; max-width: 760px; max-height: 92vh; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(env(safe-area-inset-bottom, 0px) + 18px); animation: sheet-in .2s ease-out;
}
.sheet .grip { width: 44px; height: 4px; border-radius: 4px; background: var(--line-strong); margin: -6px auto 12px; }
@keyframes sheet-in { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (min-width: 700px) {
  body { font-size: 15.5px; }
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; border-bottom: 1px solid var(--line-strong); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
