/* Girfan dashboard — light/dark, RTL/LTR. Same tokens as the mobile app (SPEC.md). */
:root {
  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --surface-2: #F7F8FC;
  --border: #E4E8F2;
  --ink: #0E1530;
  --muted: #5A6380;
  --primary: #2453D6;
  --primary-ink: #FFFFFF;
  --primary-soft: #E8EEFD;
  --hero: #101B45;
  --sidebar: #101B45;
  --sidebar-ink: rgba(255, 255, 255, .78);
  --sidebar-active: rgba(255, 255, 255, .12);
  --good: #0B7A5E;
  --good-soft: #E3F4EE;
  --bad: #C92A35;
  --bad-soft: #FDEDEE;
  --warn: #9A6700;
  --warn-soft: #FFF4D6;
  --shadow: 0 1px 2px rgba(14, 21, 48, .04), 0 4px 16px rgba(14, 21, 48, .04);
  --radius: 18px;
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0B1020;
  --surface: #141B33;
  --surface-2: #1A2240;
  --border: #232C4A;
  --ink: #E8ECF8;
  --muted: #9AA3BF;
  --primary: #5B8DEF;
  --primary-ink: #0B1020;
  --primary-soft: #1C2A5C;
  --hero: #1A2552;
  --sidebar: #0F1630;
  --good: #6EE7B7;
  --good-soft: rgba(110, 231, 183, .12);
  --bad: #FCA5A5;
  --bad-soft: rgba(252, 165, 165, .12);
  --warn: #FCD34D;
  --warn-soft: rgba(252, 211, 77, .12);
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Vazirmatn", "Inter", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
html[lang="en"] body { font-family: "Inter", "Vazirmatn", system-ui, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.num, .money, td.num { font-family: "Inter", "Vazirmatn", sans-serif; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1, h2, h3 { margin: 0; line-height: 1.3; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 264px; flex-shrink: 0; background: var(--sidebar); color: #fff;
  display: flex; flex-direction: column; padding: 18px 14px; gap: 6px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 6px 8px 18px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px; background: #2453D6; display: grid; place-items: center; flex-shrink: 0;
}
.brand-name { font-weight: 800; font-size: 18px; }
.brand-sub { font-size: 12px; color: var(--sidebar-ink); }
.nav-section { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: rgba(255, 255, 255, .5);
  padding: 14px 10px 6px; text-transform: uppercase; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--sidebar-ink); font-weight: 600; min-height: 44px;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; }
.nav-link svg { flex-shrink: 0; opacity: .9; }
.nav-badge { margin-inline-start: auto; background: #E0A21B; color: #101B45; font-size: 11px; font-weight: 800;
  border-radius: 999px; padding: 1px 8px; font-family: "Inter", sans-serif; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar .grow { flex: 1; }
.content { padding: 28px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px; }
.page-head h1 { font-size: 24px; font-weight: 800; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink); display: inline-grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.menu-btn { display: none; }
.lang-switch { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 3px; }
.lang-switch a { padding: 6px 10px; border-radius: 9px; color: var(--muted); font-weight: 700; font-size: 12px; }
.lang-switch a:hover { text-decoration: none; color: var(--ink); }
.lang-switch a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
html[data-theme="dark"] .lang-switch a.on { background: var(--primary-soft); }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-weight: 800; overflow: hidden; flex-shrink: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 72px; height: 72px; font-size: 26px; }

/* ---------- cards & grids */
.grid { display: grid; gap: 16px; }
.grid.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: 2fr 1fr; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 15px; font-weight: 800; margin-bottom: 14px; display: flex; justify-content: space-between;
  align-items: center; gap: 8px; }
.card h2 a { font-size: 13px; font-weight: 700; }
.hero {
  position: relative; overflow: hidden; background: var(--hero); color: #fff; border-radius: 24px; padding: 24px;
  margin-bottom: 16px;
}
.hero::before, .hero::after {
  content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .08);
}
.hero::before { width: 300px; height: 300px; top: -150px; inset-inline-end: -80px; }
.hero::after { width: 200px; height: 200px; top: -90px; inset-inline-end: -20px; }
.hero h1 { font-size: 22px; font-weight: 800; }
.hero p { margin: 6px 0 0; color: rgba(255, 255, 255, .72); }
.hero-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 20px; position: relative; }
.hero-tile { background: rgba(255, 255, 255, .07); border-radius: 16px; padding: 12px 14px; }
.hero-tile .label { font-size: 12px; color: rgba(255, 255, 255, .72); }
.hero-tile .value { font-family: "Inter", sans-serif; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-family: "Inter", sans-serif; font-size: 26px; font-weight: 800; margin-top: 4px;
  font-variant-numeric: tabular-nums; }
.kpi .icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary); margin-bottom: 10px; }
.chart-box { position: relative; height: 240px; }
.chart-box.round { height: 220px; }

/* ---------- tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: start; font-size: 12px; color: var(--muted); font-weight: 700; padding: 10px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .user-cell { display: flex; align-items: center; gap: 10px; }
.table .user-cell .avatar { width: 34px; height: 34px; font-size: 13px; }

/* ---------- badges & buttons */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 700; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.blue { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 16px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.btn.danger { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; font-size: 13px; }
.field .help { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--bad); font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search],
input[type=url], input[type=tel], select, textarea {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--ink); padding: 10px 12px; font: inherit;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { min-width: 150px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
  padding: 4px; width: fit-content; margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 700; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
html[data-theme="dark"] .tabs a.on { background: var(--primary-soft); }

/* ---------- misc */
.alert { padding: 12px 16px; border-radius: 14px; margin-bottom: 16px; font-weight: 600; }
.alert.success { background: var(--good-soft); color: var(--good); }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 10px 18px; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; font-weight: 600; }
.ltr { direction: ltr; unicode-bidi: isolate; }

/* ---------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 420px; }
.login-card .hero { margin-bottom: 0; border-radius: 24px 24px 0 0; }
.login-card .card { border-radius: 0 0 24px 24px; border-top: 0; padding: 24px; }
.login-tools { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

/* ---------- responsive */
.scrim { display: none; }
@media (max-width: 1100px) {
  .grid.kpis, .hero-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.three { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 50; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 40; }
  .menu-btn { display: inline-grid; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .grid.two, .form-grid { grid-template-columns: 1fr; }
  .topbar .search { display: none; }
}
@media (max-width: 520px) {
  .grid.kpis, .hero-tiles { grid-template-columns: 1fr 1fr; }
  .lang-switch a { padding: 6px 7px; }
  .page-head h1 { font-size: 20px; }
}
