/* Fox Cafe — design system (tokens + components). RTL, mobile-first.
   Dark is default; [data-theme="light"] on <html> swaps the palette. */
@import url("../assets/fonts/fonts.css");

:root {
  /* six core tokens */
  --bg:      oklch(0.185 0.060 284);
  --surface: oklch(0.236 0.075 283.4);
  --fg:      oklch(0.975 0.008 70);
  --muted:   oklch(0.770 0.035 280);
  --border:  oklch(0.340 0.060 283);
  --accent:  oklch(0.682 0.186 44.8);

  /* supporting */
  --surface-2: oklch(0.280 0.075 283);
  --surface-3: oklch(0.325 0.075 283);
  --on-accent: oklch(0.200 0.060 284);
  --accent-ink: oklch(0.760 0.160 48);       /* orange used as text */
  --reward:  oklch(0.813 0.165 75);
  --reward-ink: oklch(0.840 0.150 78);
  --success: oklch(0.770 0.150 158);
  --danger:  oklch(0.700 0.180 25);
  --info:    oklch(0.760 0.110 240);
  --accent-soft: color-mix(in oklch, var(--accent) 16%, transparent);
  --reward-soft: color-mix(in oklch, var(--reward) 16%, transparent);
  --success-soft: color-mix(in oklch, var(--success) 16%, transparent);
  --danger-soft: color-mix(in oklch, var(--danger) 16%, transparent);
  --info-soft: color-mix(in oklch, var(--info) 16%, transparent);
  --fg-soft: color-mix(in oklch, var(--fg) 7%, transparent);
  --scrim: color-mix(in oklch, oklch(0.12 0.05 284) 70%, transparent);

  /* mascot palette */
  --fox-1: oklch(0.760 0.160 55);
  --fox-2: oklch(0.682 0.186 44.8);
  --fox-3: oklch(0.580 0.180 38);
  --fox-white: oklch(0.985 0.006 70);
  --fox-ink: oklch(0.200 0.060 284);

  /* type */
  --font-display: "Lalezar", "Vazirmatn", system-ui, sans-serif;
  --font-body: "Vazirmatn", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
  --fs-display: 40px; --fs-h1: 30px; --fs-h2: 22px; --fs-h3: 17px;
  --fs-body: 15px; --fs-sm: 13.5px; --fs-xs: 12px;

  /* space, radius, elevation */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s7: 32px; --s8: 48px;
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;
  --e1: 0 1px 0 color-mix(in oklch, var(--fg) 5%, transparent) inset, 0 1px 2px oklch(0.1 0.04 284 / 0.35);
  --e2: 0 8px 24px oklch(0.1 0.05 284 / 0.40);
  --e3: 0 24px 60px oklch(0.08 0.05 284 / 0.55);
  --hex: polygon(25% 3%, 75% 3%, 100% 50%, 75% 97%, 25% 97%, 0% 50%);
  --hex-v: polygon(50% 0%, 96% 25%, 96% 75%, 50% 100%, 4% 75%, 4% 25%);
  --rail-w: 248px;
}
[data-theme="light"] {
  --bg:      oklch(0.975 0.008 70);
  --surface: oklch(0.995 0.003 70);
  --fg:      oklch(0.236 0.075 283.4);
  --muted:   oklch(0.470 0.040 283);
  --border:  oklch(0.890 0.015 283);
  --accent:  oklch(0.640 0.190 44.8);
  --surface-2: oklch(0.955 0.010 70);
  --surface-3: oklch(0.925 0.014 70);
  --on-accent: oklch(0.200 0.060 284);
  --accent-ink: oklch(0.520 0.170 42);
  --reward:  oklch(0.780 0.160 72);
  --reward-ink: oklch(0.500 0.120 62);
  --success: oklch(0.550 0.140 158);
  --danger:  oklch(0.550 0.200 25);
  --info:    oklch(0.520 0.130 245);
  --scrim: color-mix(in oklch, oklch(0.2 0.06 284) 45%, transparent);
  --e1: 0 1px 2px oklch(0.3 0.05 284 / 0.08);
  --e2: 0 8px 24px oklch(0.3 0.05 284 / 0.12);
  --e3: 0 24px 60px oklch(0.25 0.06 284 / 0.22);
}

/* ─── base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: var(--font-body); font-size: var(--fs-body); line-height: 1.7;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
p { margin: 0; text-wrap: pretty; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; font-weight: 400; }
.display, h1, h2 { font-family: var(--font-display); letter-spacing: 0; line-height: 1.35; }
.display { font-size: var(--fs-display); }
h1, .h1 { font-size: var(--fs-h1); }
h2, .h2 { font-size: var(--fs-h2); }
h3, .h3 { font-family: var(--font-body); font-size: var(--fs-h3); font-weight: 700; line-height: 1.5; }
.muted { color: var(--muted); }
.sm { font-size: var(--fs-sm); } .xs { font-size: var(--fs-xs); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: var(--font-mono); font-size: 12px; direction: ltr; unicode-bidi: isolate; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.reward-ink { color: var(--reward-ink); }
.accent-ink { color: var(--accent-ink); }
.success-ink { color: var(--success); } .danger-ink { color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ─── layout ───────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s6); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2, .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.split { display: grid; gap: var(--s5); grid-template-columns: 1fr; }
@media (min-width: 1100px) { .split { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; } }

/* ─── app shell ────────────────────────────────────── */
.shell { min-height: 100vh; }
.appbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--s3);
  padding: 10px var(--s4); min-height: 60px;
  background: color-mix(in oklch, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 20px; white-space: nowrap; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.appbar .spacer { flex: 1; }
.ctx-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px 0 10px;
  border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--surface); font-size: var(--fs-sm); font-weight: 600;
}
.ctx-btn:hover { background: var(--surface-2); }
.ctx-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 50%;
  border: 1px solid transparent; background: transparent; position: relative; flex: none;
}
.icon-btn:hover { background: var(--fg-soft); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .pip { position: absolute; top: 9px; inset-inline-end: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
.page { padding: var(--s5) var(--s4) calc(96px + env(safe-area-inset-bottom)); max-width: 1320px; margin-inline: auto; }
.page.narrow { max-width: 720px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s5); }
.page-head p { color: var(--muted); font-size: var(--fs-sm); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); margin: var(--s6) 0 var(--s3); }
.section-head h2 { font-size: 20px; }
.section-head a { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; }
.section-head a:hover { color: var(--fg); }

.bottomnav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in oklch, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.bottomnav a, .bottomnav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 56px;
  border: 0; background: none; border-radius: var(--r-md); font-size: 11.5px; font-weight: 600; color: var(--muted);
}
.bottomnav svg { width: 24px; height: 24px; }
.bottomnav a:hover, .bottomnav button:hover { color: var(--fg); background: var(--fg-soft); }
.bottomnav [aria-current="page"] { color: var(--fg); }
.bottomnav [aria-current="page"] .ni { background: var(--accent); color: var(--on-accent); }
.bottomnav .ni { display: grid; place-items: center; width: 52px; height: 30px; border-radius: var(--r-pill); }

.rail { display: none; }
@media (min-width: 960px) {
  .bottomnav { display: none; }
  .rail {
    display: flex; flex-direction: column; gap: 4px; position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: var(--rail-w);
    padding: var(--s4) var(--s3); background: var(--surface); border-inline-end: 1px solid var(--border); overflow-y: auto; z-index: 31;
  }
  .rail .brand { padding: 4px 8px 16px; }
  .rail .grp { font-size: var(--fs-xs); color: var(--muted); font-weight: 700; padding: 14px 12px 4px; }
  .rail a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--r-sm); font-weight: 600; font-size: var(--fs-sm); color: var(--muted); }
  .rail a svg { width: 20px; height: 20px; }
  .rail a:hover { background: var(--fg-soft); color: var(--fg); }
  .rail a[aria-current="page"] { background: var(--accent-soft); color: var(--fg); }
  .rail .rail-foot { margin-top: auto; padding-top: var(--s4); }
  .shell { padding-inline-start: var(--rail-w); }
  .appbar .brand { display: none; }
  .page { padding: var(--s6) var(--s7) var(--s8); }
}

.banner {
  display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s4); font-size: var(--fs-sm); font-weight: 600;
  background: var(--info-soft); border-bottom: 1px solid var(--border);
}
.banner.warn { background: var(--reward-soft); }
.banner.danger { background: var(--danger-soft); }
.banner svg { width: 18px; height: 18px; flex: none; }
.banner .grow { min-width: 0; }

/* ─── buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px;
  border-radius: var(--r-md); border: 1px solid transparent; font-weight: 700; font-size: 15px; white-space: nowrap;
  transition: background .15s, transform .1s, border-color .15s;
}
.btn svg { width: 20px; height: 20px; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: oklch(from var(--accent) calc(l + 0.07) c h); }
.btn-secondary { background: var(--surface-2); color: var(--fg); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-ghost { background: transparent; color: var(--fg); }
.btn-ghost:hover { background: var(--fg-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in oklch, var(--danger) 35%, transparent); }
.btn-danger:hover { background: color-mix(in oklch, var(--danger) 26%, transparent); }
.btn-success { background: var(--success); color: var(--on-accent); }
.btn-success:hover { background: oklch(from var(--success) calc(l + 0.06) c h); }
.btn-sm { min-height: 44px; padding: 0 14px; font-size: 13.5px; border-radius: var(--r-sm); }
.btn-lg { min-height: 56px; font-size: 16px; padding: 0 26px; border-radius: var(--r-lg); }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.link { color: var(--accent-ink); font-weight: 700; }
.link:hover { text-decoration: underline; }

/* ─── cards ────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--e1); }
.card-pad { padding: var(--s5); }
.card-sm { padding: var(--s4); border-radius: var(--r-md); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }
.card-body { padding: var(--s4) var(--s5); }
a.card:hover, button.card:hover, .card.hover:hover { background: var(--surface-2); }
.inset { background: var(--surface-2); border-radius: var(--r-md); padding: var(--s3) var(--s4); }

/* stat */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.stat .value { font-family: var(--font-display); font-size: 28px; line-height: 1.3; }
.stat .value small { font-family: var(--font-body); font-size: 13px; color: var(--muted); font-weight: 600; margin-inline-start: 4px; }
.delta { font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; gap: 2px; }
.delta.up { color: var(--success); } .delta.down { color: var(--danger); }

/* ─── tags & badges ────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 700; background: var(--fg-soft); color: var(--fg); white-space: nowrap;
}
.tag svg { width: 14px; height: 14px; }
.tag .d { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-success { background: var(--success-soft); color: var(--success); }
.tag-warn    { background: var(--reward-soft); color: var(--reward-ink); }
.tag-danger  { background: var(--danger-soft); color: var(--danger); }
.tag-info    { background: var(--info-soft); color: var(--info); }
.tag-accent  { background: var(--accent-soft); color: var(--accent-ink); }
.tag-outline { background: transparent; border: 1px solid var(--border); color: var(--muted); }

.hex { clip-path: var(--hex-v); }
.avatar {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; clip-path: var(--hex-v);
  background: var(--surface-3); font-weight: 800; font-size: 15px; color: var(--fg);
}
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }
.avatar.xl { width: 104px; height: 104px; font-size: 34px; }
.avatar.sm { width: 34px; height: 34px; font-size: 12px; }
.avatar.o { background: var(--accent); color: var(--on-accent); }
.avatar.a { background: var(--reward); color: var(--on-accent); }
.avatar.i { background: color-mix(in oklch, var(--info) 40%, var(--surface-2)); }
.avatar.s { background: color-mix(in oklch, var(--success) 40%, var(--surface-2)); }
.medal { width: 64px; height: 72px; clip-path: var(--hex-v); display: grid; place-items: center; background: var(--reward-soft); color: var(--reward-ink); }
.medal svg { width: 28px; height: 28px; }
.medal.locked { background: var(--fg-soft); color: var(--muted); }

/* ─── progress / xp ────────────────────────────────── */
.bar { height: 10px; border-radius: var(--r-pill); background: var(--fg-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--reward); }
.bar.accent > i { background: var(--accent); }
.bar.success > i { background: var(--success); }
.bar.thin { height: 6px; }
.level-gem {
  width: 56px; height: 64px; clip-path: var(--hex-v); display: grid; place-items: center; flex: none;
  background: linear-gradient(160deg, var(--reward), oklch(from var(--reward) calc(l - 0.12) c calc(h - 18)));
  color: var(--on-accent); font-family: var(--font-display); font-size: 24px; line-height: 1;
}
.coin { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--reward); color: var(--on-accent); font-size: 12px; font-weight: 800; }

/* ─── inputs ───────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field > .label { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.field .err { font-size: var(--fs-xs); color: var(--danger); font-weight: 600; }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--fg); font-size: 15px;
}
.textarea { padding: 12px 14px; min-height: 96px; resize: vertical; line-height: 1.7; }
.input::placeholder, .textarea::placeholder { color: color-mix(in oklch, var(--muted) 80%, transparent); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in oklch, var(--fg) 30%, var(--border)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.input-icon { position: relative; }
.input-icon svg { position: absolute; inset-inline-start: 14px; top: 50%; translate: 0 -50%; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.input-icon .input { padding-inline-start: 42px; }
.otp { display: flex; gap: 10px; direction: ltr; justify-content: center; }
.otp input {
  width: 52px; height: 60px; text-align: center; font-size: 26px; font-weight: 800; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--fg);
}
.otp input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border); transition: .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--fg); transition: .15s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); }
.switch input:checked + span::after { inset-inline-start: 23px; background: var(--on-accent); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.check { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.stepper button { width: 44px; height: 44px; border: 0; background: none; font-size: 20px; font-weight: 700; border-radius: var(--r-md); }
.stepper button:hover { background: var(--fg-soft); }
.stepper output { min-width: 40px; text-align: center; font-weight: 800; font-size: 17px; }

/* ─── tabs / segmented / chips ─────────────────────── */
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; overflow-x: auto; }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: var(--r-sm); background: none; font-weight: 700; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.seg button:hover { color: var(--fg); background: var(--fg-soft); }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--e1); }
[data-theme="light"] .seg button[aria-selected="true"] { background: var(--fg); color: var(--bg); }
.tabs { display: flex; gap: var(--s5); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { position: relative; min-height: 46px; padding: 0 2px; border: 0; background: none; font-weight: 700; color: var(--muted); white-space: nowrap; }
.tabs button:hover { color: var(--fg); }
.tabs button[aria-selected="true"] { color: var(--fg); }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; inset-inline: 0; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: var(--fg); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface); font-size: 13.5px; font-weight: 600; white-space: nowrap; color: var(--fg);
}
.chip svg { width: 16px; height: 16px; }
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
[data-tab-panel][hidden] { display: none !important; }

/* ─── lists & tables ───────────────────────────────── */
.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: var(--s3); padding: 12px var(--s5); min-height: 64px; border-top: 1px solid var(--border); }
.list-row:first-child { border-top: 0; }
a.list-row:hover, button.list-row:hover, .list-row.hover:hover { background: var(--fg-soft); }
button.list-row { width: 100%; border-inline: 0; border-bottom: 0; background: none; text-align: start; }
.list-row .t { font-weight: 700; font-size: 14.5px; line-height: 1.5; }
.list-row .s { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.list-row .amt { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ico { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: var(--r-sm); background: var(--fg-soft); }
.ico svg { width: 20px; height: 20px; }
.ico.o { background: var(--accent-soft); color: var(--accent-ink); }
.ico.a { background: var(--reward-soft); color: var(--reward-ink); }
.ico.g { background: var(--success-soft); color: var(--success); }
.ico.r { background: var(--danger-soft); color: var(--danger); }
.ico.b { background: var(--info-soft); color: var(--info); }

.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface); position: sticky; top: 0; }
.tbl td.wrap-cell { white-space: normal; min-width: 180px; }
.tbl tbody tr:hover { background: var(--fg-soft); }
.tbl tbody tr.sel { background: var(--accent-soft); }
.tbl .num { text-align: end; font-variant-numeric: tabular-nums; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl-row-link { cursor: pointer; }

/* ─── charts ───────────────────────────────────────── */
.chart { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font-body); font-size: 11px; fill: var(--muted); }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .bar-f { fill: color-mix(in oklch, var(--fg) 26%, var(--surface)); }
.chart .bar-f.hi { fill: var(--accent); }
.chart .area { fill: var(--accent-soft); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.b { stroke: var(--info); }
.chart .dotm { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; }
.legend { display: flex; flex-wrap: wrap; gap: var(--s4); font-size: 12px; color: var(--muted); font-weight: 600; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-end: 6px; vertical-align: -1px; }
.heat { display: grid; gap: 3px; }
.heat i { aspect-ratio: 1; border-radius: 4px; background: var(--accent); }

/* ─── modal / sheet / toast ────────────────────────── */
dialog.modal {
  border: 1px solid var(--border); border-radius: var(--r-xl); padding: 0; background: var(--surface); color: var(--fg);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: var(--e3);
}
dialog.modal::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
dialog.modal.sheet { margin-bottom: 0; width: min(560px, 100vw); max-width: 100vw; border-radius: var(--r-xl) var(--r-xl) 0 0; }
@media (min-width: 960px) { dialog.modal.sheet { margin-bottom: auto; border-radius: var(--r-xl); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 20px; }
.modal-body { padding: var(--s5); display: flex; flex-direction: column; gap: var(--s4); }
.modal-foot { display: flex; gap: var(--s3); padding: var(--s4) var(--s5); border-top: 1px solid var(--border); }
.modal-foot .btn { flex: 1; }
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 10px auto 0; }
.toast-host { position: fixed; z-index: 100; inset-inline: 0; bottom: 92px; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
@media (min-width: 960px) { .toast-host { bottom: 24px; padding-inline-start: var(--rail-w); } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; min-height: 52px; max-width: 440px;
  border-radius: var(--r-md); background: var(--fg); color: var(--bg); font-weight: 600; font-size: 14px; box-shadow: var(--e3);
  animation: toast-in .25s ease-out;
}
.toast svg { width: 20px; height: 20px; flex: none; }
.toast.success svg { color: var(--success); } .toast.danger svg { color: var(--danger); } .toast.reward svg { color: var(--reward); }
[data-theme="light"] .toast.success svg { color: oklch(0.80 0.15 158); }
[data-theme="light"] .toast.danger svg { color: oklch(0.75 0.17 25); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* ─── states ───────────────────────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3); padding: var(--s7) var(--s5); }
.empty .fox { width: 120px; }
.empty h3 { font-size: 18px; }
.empty p { color: var(--muted); max-width: 34ch; font-size: var(--fs-sm); }
.skel { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--fg-soft) 0%, color-mix(in oklch, var(--fg) 13%, transparent) 50%, var(--fg-soft) 100%); background-size: 200% 100%; animation: skel 1.3s linear infinite; }
@keyframes skel { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel, .fox-bob { animation: none !important; } }
.fox-bob { animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--fg-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── permission matrix ────────────────────────────── */
.pm { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.pm-group { border-top: 1px solid var(--border); }
.pm-group:first-child { border-top: 0; }
.pm-gh { display: flex; align-items: center; gap: var(--s3); padding: 12px var(--s4); background: var(--surface-2); font-weight: 800; font-size: 14px; }
.pm-gh .count { margin-inline-start: auto; font-size: 12px; color: var(--muted); font-weight: 700; }
.pm-row { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s4); min-height: 56px; border-top: 1px solid var(--border); }
.pm-row:hover { background: var(--fg-soft); }
.pm-row .t { font-weight: 600; font-size: 14px; line-height: 1.5; }
.pm-row .mono { color: var(--muted); }
.pm-row.sensitive .t::after { content: "حساس"; margin-inline-start: 8px; font-size: 11px; font-weight: 800; color: var(--danger); background: var(--danger-soft); padding: 1px 7px; border-radius: 999px; }

/* ─── mascot + misc ────────────────────────────────── */
.fox { display: block; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; text-align: end; }
.timeline { display: flex; flex-direction: column; }
.tl-item { position: relative; padding-inline-start: 28px; padding-bottom: var(--s4); }
.tl-item::before { content: ""; position: absolute; inset-inline-start: 6px; top: 8px; bottom: -8px; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-item::after { content: ""; position: absolute; inset-inline-start: 0; top: 6px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface-3); border: 2px solid var(--muted); }
.tl-item.ok::after { background: var(--success); border-color: var(--success); }
.tl-item.now::after { background: var(--accent); border-color: var(--accent); }
.mafia-tile {
  display: flex; align-items: center; gap: var(--s4); padding: var(--s4); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--e1); text-align: start; width: 100%;
}
.mafia-tile:hover { background: var(--surface-2); }
.mafia-tile .app-icon { width: 72px; height: 72px; flex: none; }
.opening { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: oklch(0.14 0.05 284); color: oklch(0.975 0.008 70); }
.opening[hidden] { display: none; }
.opening .inner { display: flex; flex-direction: column; align-items: center; gap: var(--s4); text-align: center; padding: var(--s5); }
.opening .app-icon { width: 112px; height: 112px; animation: pop .5s cubic-bezier(.2,1.4,.4,1); }
.opening .bar { width: 180px; background: oklch(0.3 0.06 284); }
.opening .bar > i { background: oklch(0.682 0.186 44.8); animation: load 1.8s ease-in-out forwards; width: 0; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes load { to { width: 100%; } }
.sample-note { font-size: 11px; color: var(--muted); font-weight: 600; }
.is-locked { opacity: .5; cursor: not-allowed; }
