/* =====================================================================
   Alpha4 Foundation — Admin Panel  (RTL/LTR · light/dark · mobile)
   ===================================================================== */
:root {
  color-scheme: light;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef1f5;
  --hover: #f6f8fb;
  --text: #1b2333;
  --text-2: #384258;
  --muted: #6b7690;
  --border: #e4e8f0;
  --border-strong: #cfd6e3;
  --primary: #0e7c6b;
  --primary-600: #0a6758;
  --primary-50: #e7f5f2;
  --primary-text: #0e7c6b;
  --on-primary: #ffffff;
  --accent: #d99a1e;
  --sidebar: #0f1b2d;
  --sidebar-2: #16263d;
  --sidebar-text: #b9c5d8;
  --green: #15803d;  --green-bg: #e7f6ec;
  --red: #c2342b;    --red-bg: #fdecea;
  --amber: #a15f00;  --amber-bg: #fff4dc;
  --blue: #1d5fd1;   --blue-bg: #e8f0fe;
  --purple: #7a3fc6; --purple-bg: #f2eafd;
  --gray: #5b6578;   --gray-bg: #eef1f5;
  --topbar-bg: rgba(243,245,249,.85);
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
  --shadow-lg: 0 10px 40px rgba(16,24,40,.18);
}

/* ---------- Dark theme ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1220;
  --surface: #121a2b;
  --surface-2: #162034;
  --surface-3: #1c2840;
  --hover: #18233a;
  --text: #e6ebf5;
  --text-2: #c3cce0;
  --muted: #92a0b9;
  --border: #243049;
  --border-strong: #34425f;
  --primary: #12a08b;
  --primary-600: #0f8a78;
  --primary-50: rgba(20,184,166,.14);
  --primary-text: #2dd4bf;
  --sidebar: #080e1a;
  --sidebar-2: #0d1627;
  --green: #4ade80;  --green-bg: rgba(74,222,128,.13);
  --red: #f87171;    --red-bg: rgba(248,113,113,.13);
  --amber: #fbbf24;  --amber-bg: rgba(251,191,36,.13);
  --blue: #7aa7ff;   --blue-bg: rgba(122,167,255,.14);
  --purple: #c4a3ff; --purple-bg: rgba(196,163,255,.14);
  --gray: #a3aec4;   --gray-bg: rgba(163,174,196,.12);
  --topbar-bg: rgba(11,18,32,.85);
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1220; --surface: #121a2b; --surface-2: #162034; --surface-3: #1c2840; --hover: #18233a;
    --text: #e6ebf5; --text-2: #c3cce0; --muted: #92a0b9; --border: #243049; --border-strong: #34425f;
    --primary: #12a08b; --primary-600: #0f8a78; --primary-50: rgba(20,184,166,.14); --primary-text: #2dd4bf;
    --sidebar: #080e1a; --sidebar-2: #0d1627;
    --green: #4ade80; --green-bg: rgba(74,222,128,.13); --red: #f87171; --red-bg: rgba(248,113,113,.13);
    --amber: #fbbf24; --amber-bg: rgba(251,191,36,.13); --blue: #7aa7ff; --blue-bg: rgba(122,167,255,.14);
    --purple: #c4a3ff; --purple-bg: rgba(196,163,255,.14); --gray: #a3aec4; --gray-bg: rgba(163,174,196,.12);
    --topbar-bg: rgba(11,18,32,.85);
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Vazirmatn, Tahoma, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.4; }
small.cur { color: var(--muted); font-size: .78em; font-weight: 500; }
.money { white-space: nowrap; display: inline-block; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.ic { flex-shrink: 0; }
.hidden { display: none !important; }

/* theme icon swap */
.when-dark { display: none; }
:root[data-theme="dark"] .when-dark { display: inline-flex; }
:root[data-theme="dark"] .when-light { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .when-dark { display: inline-flex; }
  :root:not([data-theme="light"]) .when-light { display: none; }
}

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 264px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, #14b8a6, #0e7c6b);
  color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 16px;
  box-shadow: 0 6px 18px rgba(20,184,166,.35);
}
.brand-text { min-width: 0; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; opacity: .7; }
.close-btn { display: none; margin-inline-start: auto; color: #fff; }
.nav { padding: 10px 12px; flex: 1; }
.nav-group { font-size: 11.5px; letter-spacing: .02em; color: #6f7f99; padding: 14px 12px 6px; font-weight: 600; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; margin: 2px 0; border-radius: 10px;
  color: var(--sidebar-text); font-weight: 500; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(20,184,166,.16); color: #fff; box-shadow: inset 3px 0 0 #14b8a6; }
[dir="rtl"] .nav-link.active { box-shadow: inset -3px 0 0 #14b8a6; }
.nav-link.active .ic { color: #2dd4bf; }
.nav-count { margin-inline-start: auto; background: var(--accent); color: #1b1300; font-size: 11.5px; font-weight: 700; border-radius: 99px; padding: 0 8px; line-height: 20px; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.07); padding: 10px 12px 14px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; color: inherit; }
.me:hover { text-decoration: none; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #23395a; color: #fff; display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.me-name { color: #fff; font-weight: 600; font-size: 13.5px; }
.me-role { font-size: 12px; opacity: .75; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 28px; background: var(--topbar-bg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.page-title { font-size: 19px; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-end { margin-inline-start: auto; display: flex; gap: 6px; align-items: center; }
.role-chip { font-size: 12.5px; font-weight: 600; padding: 4px 12px; border-radius: 99px; background: var(--gray-bg); color: var(--gray); white-space: nowrap; }
.role-super_admin { background: var(--amber-bg); color: var(--amber); }
.role-info_manager { background: var(--blue-bg); color: var(--blue); }
.role-finance_manager { background: var(--primary-50); color: var(--primary-text); }
.pending-pill { display: inline-flex; align-items: center; gap: 4px; background: var(--accent); color: #1b1300; font-weight: 700; font-size: 13px; border-radius: 99px; padding: 3px 10px; }
.pending-pill:hover { text-decoration: none; filter: brightness(1.05); }
.content { padding: 24px 28px 48px; max-width: 1440px; width: 100%; }
.menu-btn { display: none; }
.icon-btn { border: 0; background: transparent; padding: 7px; border-radius: 9px; color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; font: inherit; }
.icon-btn:hover { background: var(--surface-3); text-decoration: none; }
.pref-btn { font-size: 12.5px; font-weight: 700; color: var(--text-2); border: 1px solid var(--border); background: var(--surface); }
.backdrop { display: none; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-title { font-size: 15.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-head .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 20px; }
.stack { display: grid; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 20px; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0,2fr) minmax(0,1fr); gap: 20px; }
.section-title { font-size: 15px; font-weight: 700; margin: 4px 0 0; display: flex; align-items: center; gap: 8px; }
.welcome { padding: 18px 22px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.welcome .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--shadow); min-width: 0; }
.kpi-body { min-width: 0; }
.kpi-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0; }
.kpi-label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 22px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-sub { font-size: 12.5px; color: var(--muted); }
.kpi-teal .kpi-icon   { background: var(--primary-50); color: var(--primary-text); }
.kpi-green .kpi-icon  { background: var(--green-bg); color: var(--green); }
.kpi-red .kpi-icon    { background: var(--red-bg); color: var(--red); }
.kpi-amber .kpi-icon  { background: var(--amber-bg); color: var(--amber); }
.kpi-blue .kpi-icon   { background: var(--blue-bg); color: var(--blue); }
.kpi-purple .kpi-icon { background: var(--purple-bg); color: var(--purple); }
.kpi-gray .kpi-icon   { background: var(--gray-bg); color: var(--gray); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: start; font-weight: 600; color: var(--muted); font-size: 12.5px; background: var(--surface-2); padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--border); padding: 11px 14px; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.td-person { display: flex; align-items: center; gap: 10px; color: inherit; }
.td-person:hover { text-decoration: none; }
.thumb { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; color: var(--muted); font-weight: 700; flex-shrink: 0; }
.amount-in { color: var(--green); font-weight: 600; }
.amount-out { color: var(--red); font-weight: 600; }
.row-pending { background: color-mix(in srgb, var(--amber-bg) 45%, transparent); }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.badge-green  { background: var(--green-bg);  color: var(--green); }
.badge-red    { background: var(--red-bg);    color: var(--red); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue); }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray   { background: var(--gray-bg);   color: var(--gray); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 16px; font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: background .15s, border-color .15s, filter .15s; white-space: nowrap; line-height: 1.5;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-600); }
.btn-success { background: #15803d; color: #fff; }
.btn-success:hover { filter: brightness(.94); }
.btn-danger { background: #c2342b; color: #fff; }
.btn-outline-danger { background: var(--surface); color: var(--red); border-color: color-mix(in srgb, var(--red) 35%, transparent); }
.btn-outline-danger:hover { background: var(--red-bg); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--hover); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); }
.btn-sm { padding: 4px 11px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.inline-form { display: inline; margin: 0; }

/* ---------- Forms ---------- */
.form-section { padding: 20px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section h3 { font-size: 14.5px; font-weight: 700; margin-bottom: 14px; color: var(--primary-text); display: flex; gap: 8px; align-items: center; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: 1 / -1; }
.field { min-width: 0; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text-2); }
.field label .req { color: var(--red); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password],
input[type=date], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 8px 12px; background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
@media (min-width: 861px) { input, select, textarea { font-size: 14.5px !important; } }
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
input[readonly], input:disabled { background: var(--surface-2); color: var(--muted); }
input[type=file] { font: inherit; font-size: 13px; width: 100%; padding: 8px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input, input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; gap: 10px; padding: 16px 20px; background: var(--surface-2); border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; align-items: center; }
.form-actions .push { margin-inline-start: auto; }
.input-suffix { position: relative; }
.input-suffix input { padding-inline-end: 56px; }
.input-suffix .suffix { position: absolute; inset-inline-end: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; font-weight: 600; pointer-events: none; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-inline-end: 44px; }
.pw-toggle { position: absolute; inset-inline-end: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; display: grid; }
.pw-toggle:hover { color: var(--text); }
.pw-meter { height: 5px; border-radius: 99px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; border-radius: 99px; transition: width .2s, background .2s; }
.pw-meter-text { font-size: 12px; font-weight: 600; margin-top: 2px; min-height: 18px; }
.balance-note { font-size: 12.5px; margin-top: 4px; }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.filters .field { min-width: 140px; flex: 1; max-width: 230px; }
.filters .field label { font-size: 12px; margin-bottom: 3px; }
.filters input, .filters select { padding: 6px 10px; }
.filters .grow { flex: 2; max-width: 340px; }

/* ---------- Alerts / Empty ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.alert-success { background: var(--green-bg); color: var(--green); border-color: color-mix(in srgb, var(--green) 30%, transparent); }
.alert-error   { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.alert-warning { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
.alert-info    { background: var(--blue-bg); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 30%, transparent); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-icon { font-size: 40px; margin-bottom: 8px; }
.empty h2 { color: var(--text); font-size: 18px; margin-bottom: 6px; }

/* ---------- Pager / Tabs ---------- */
.pager { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--border); }
.pager-info { color: var(--muted); font-size: 13px; margin-inline-end: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.card > .tabs { padding: 0 12px; }
.tab { padding: 11px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary-text); border-color: var(--primary); }
.tab .badge { font-size: 11px; padding: 0 7px; }

/* ---------- Profile ---------- */
.profile { display: flex; gap: 20px; align-items: center; padding: 20px; }
.profile-photo { width: 96px; height: 96px; border-radius: 18px; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; font-size: 34px; font-weight: 800; color: var(--muted); flex-shrink: 0; border: 3px solid var(--surface); box-shadow: var(--shadow); }
.profile h2 { font-size: 21px; }
.profile .meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; align-items: center; }
.profile .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; align-self: flex-start; }
.dl { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); margin: 0; }
.dl > div { padding: 12px 20px; border-bottom: 1px solid var(--border); min-width: 0; }
.dl dt { font-size: 12px; color: var(--muted); font-weight: 500; }
.dl dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.doc { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface-2); display: block; color: var(--text); }
.doc:hover { text-decoration: none; border-color: var(--primary); }
.doc-img { height: 110px; background: var(--surface-3) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); }
.doc-cap { padding: 8px 10px; font-size: 12.5px; font-weight: 600; }
.status-banner { display: flex; gap: 12px; align-items: center; padding: 14px 18px; border-radius: var(--radius); border: 1px solid; flex-wrap: wrap; }
.status-banner.pending { background: var(--amber-bg); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
.status-banner.rejected { background: var(--red-bg); color: var(--red); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.status-banner .actions { margin-inline-start: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Approval cards ---------- */
.approval { display: flex; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.approval:last-child { border-bottom: 0; }
.approval .grow { flex: 1 1 220px; min-width: 0; }
.approval .title { overflow-wrap: anywhere; }
.approval .title { font-weight: 700; font-size: 15px; }
.approval .meta { color: var(--muted); font-size: 13px; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 2px; }
.approval .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.approval .amount { font-size: 18px; font-weight: 800; white-space: nowrap; }
.bal-after { font-size: 12.5px; color: var(--muted); }
.bal-after.bad { color: var(--red); font-weight: 600; }

/* ---------- Account cards ---------- */
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.acc { border-radius: var(--radius); padding: 20px; color: #fff; position: relative; overflow: hidden; box-shadow: var(--shadow); min-height: 170px; display: flex; flex-direction: column; }
.acc::after { content: ""; position: absolute; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.08); inset-inline-end: -50px; bottom: -70px; }
.acc-bank { background: linear-gradient(135deg, #0f3d5e, #146a8a); }
.acc-cash { background: linear-gradient(135deg, #3b5d22, #5e8a2e); }
.acc-mobile_wallet { background: linear-gradient(135deg, #4b2a7a, #7a3fc6); }
.acc-gateway_wallet { background: linear-gradient(135deg, #7a4a00, #c07a12); }
.acc.inactive { filter: grayscale(.9); opacity: .75; }
.acc-name { font-weight: 700; font-size: 15px; }
.acc-sub { font-size: 12.5px; opacity: .8; }
.acc-balance { font-size: 26px; font-weight: 800; margin-top: auto; font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.acc-balance small { font-size: 13px; opacity: .8; font-weight: 600; }
.acc-foot { display: flex; justify-content: space-between; font-size: 12.5px; opacity: .9; margin-top: 4px; position: relative; z-index: 1; gap: 8px; flex-wrap: wrap; }
.acc-foot a { color: #fff; text-decoration: underline; }
.acc .warn { background: rgba(255,255,255,.2); padding: 2px 8px; border-radius: 99px; font-size: 11.5px; }

/* ---------- Misc ---------- */
.chart-box { position: relative; height: 290px; }
.chart-box.sm { height: 240px; }
.progress { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #14b8a6, var(--primary)); border-radius: 99px; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); color: inherit; }
a.list-row:hover { background: var(--hover); text-decoration: none; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.list-row .sub { font-size: 12.5px; color: var(--muted); }
details.json summary { cursor: pointer; color: var(--primary-text); font-size: 12.5px; }
details.json pre { direction: ltr; text-align: left; background: #0f1b2d; color: #d6e2f5; padding: 10px; border-radius: 8px; font-size: 12px; max-width: 520px; overflow: auto; white-space: pre-wrap; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: start; }
.report-head { display: none; }
.secret-box { font-family: Consolas, monospace; direction: ltr; background: var(--surface-2); border: 1px dashed var(--border-strong); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 16px; letter-spacing: .03em; user-select: all; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-side {
  background: radial-gradient(circle at 20% 20%, rgba(45,212,191,.25), transparent 50%),
              linear-gradient(150deg, #0b1626 0%, #10304a 55%, #0e7c6b 120%);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; gap: 24px;
}
.auth-side .brand { border: 0; padding: 0; }
.auth-side h1 { font-size: 34px; font-weight: 800; line-height: 1.5; }
.auth-side p { opacity: .8; max-width: 440px; font-size: 15.5px; }
.auth-roles { display: grid; gap: 12px; max-width: 420px; }
.auth-role { display: flex; gap: 12px; align-items: center; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); padding: 12px 14px; border-radius: 12px; }
.auth-role b { display: block; }
.auth-role span { font-size: 13px; opacity: .75; }
.auth-main { display: grid; place-items: center; padding: 70px 20px 40px; background: var(--bg); position: relative; }
.auth-prefs { position: absolute; top: 16px; inset-inline-end: 16px; display: flex; gap: 6px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 24px; font-weight: 800; }
.auth-card .field { margin-bottom: 14px; }
.auth-card input { padding: 11px 14px; }
.auth-mobile-brand { display: none; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-mobile-brand .brand-name { color: var(--text); }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-2-1 { grid-template-columns: minmax(0,1fr); }
  .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dl { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* ----- Tablet & phone: off-canvas sidebar ----- */
@media (max-width: 860px) {
  .sidebar { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; height: 100%; width: min(84vw, 300px);
             transform: translateX(-105%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  .sidebar.open, [dir="rtl"] .sidebar.open { transform: translateX(0); }
  .close-btn { display: inline-flex; }
  .backdrop.show { display: block; position: fixed; inset: 0; background: rgba(5,10,20,.5); z-index: 35; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 12px; gap: 8px; padding-top: max(10px, env(safe-area-inset-top)); }
  .page-title { font-size: 16.5px; }
  .content { padding: 14px 12px 40px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0,1fr); gap: 14px; }
  .stack { gap: 14px; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-mobile-brand { display: flex; }
  .profile { flex-wrap: wrap; padding: 16px; gap: 14px; }
  .profile-photo { width: 76px; height: 76px; font-size: 28px; }
  .profile .actions { margin-inline-start: 0; width: 100%; }
  .welcome .actions { margin-inline-start: 0; width: 100%; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
  .kpi { padding: 12px; gap: 10px; flex-direction: column; }
  .kpi-icon { width: 36px; height: 36px; border-radius: 10px; }
  .kpi-value { font-size: 18px; }
  .card-head { padding: 13px 14px; }
  .card-body { padding: 14px; }
  .form-section { padding: 16px 14px; }
  .form-actions { padding: 14px; }
  .filters { padding: 12px 14px; }
  .filters .field, .filters .grow { min-width: calc(50% - 5px); max-width: none; flex: 1 1 calc(50% - 5px); }
  .filters .grow { flex-basis: 100%; }
  .list-row { padding: 11px 14px; }
  .approval { flex-wrap: wrap; padding: 14px; }
  .approval .actions { width: 100%; }
  .approval .actions .inline-form, .approval .actions .btn { flex: 1; }
  .approval .actions .inline-form .btn { width: 100%; }
  .chart-box { height: 240px; }
  .role-chip { display: none; }
}

/* ----- Phone: tables become cards ----- */
@media (max-width: 700px) {
  .form-grid { grid-template-columns: minmax(0,1fr); }
  .form-grid .span-2 { grid-column: auto; }
  .dl { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
  .dl > div { padding: 10px 14px; }
  .table-wrap { overflow: visible; }
  table.table.cards thead { display: none; }
  table.table.cards, table.table.cards tbody, table.table.cards tr, table.table.cards td, table.table.cards tfoot { display: block; width: 100%; }
  table.table.cards tr { border-bottom: 1px solid var(--border); padding: 10px 14px; }
  table.table.cards tbody tr:last-child { border-bottom: 0; }
  table.table.cards td { border: 0; padding: 4px 0; display: flex; gap: 12px; justify-content: space-between; align-items: center; text-align: end; min-height: 28px; }
  table.table.cards td::before { content: attr(data-label); color: var(--muted); font-size: 12.5px; font-weight: 600; text-align: start; flex-shrink: 0; max-width: 45%; }
  table.table.cards td[data-label=""]::before, table.table.cards td.no-label::before { display: none; }
  table.table.cards td.td-main { justify-content: flex-start; text-align: start; padding-bottom: 6px; }
  table.table.cards td.td-main::before { display: none; }
  table.table.cards td[colspan] { justify-content: center; }
  table.table.cards td[colspan]::before { display: none; }
  table.table.cards .actions { justify-content: flex-start; width: 100%; padding-top: 6px; }
  table.table.cards td:has(> .actions)::before { display: none; }
  table.table.cards tfoot td { background: transparent; border: 0; padding: 4px 0; }
  table.table.cards tfoot tr { background: var(--surface-2); }
  .pager { padding: 10px 14px; }
  .pager-info { width: 100%; }
  .docs { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .acc-grid { grid-template-columns: minmax(0,1fr); }
  .tab { padding: 10px 10px; font-size: 13.5px; }
}
@media (max-width: 380px) {
  .kpis { grid-template-columns: minmax(0,1fr); }
  .kpi { flex-direction: row; }
  .pref-btn span { display: none; }
}

/* ---------- Print ---------- */
@media print {
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --surface-2: #f6f6f6; --text: #000; --muted: #444; --border: #ccc; }
  .sidebar, .topbar, .filters, .btn, .no-print, .pager, form.inline-form, .backdrop, .tabs { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .content { padding: 0; max-width: none; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  .report-head { display: block; text-align: center; margin-bottom: 16px; }
  .chart-box { height: 220px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
}
