/* رَكيزة — app shell styles (RTL, mobile-first) */
@font-face { font-family: "Cairo"; font-weight: 400; font-display: swap; src: url("/static/fonts/cairo-arabic-400-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Cairo"; font-weight: 600; font-display: swap; src: url("/static/fonts/cairo-arabic-600-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Cairo"; font-weight: 700; font-display: swap; src: url("/static/fonts/cairo-arabic-700-normal.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFC; }
@font-face { font-family: "Cairo"; font-weight: 400; font-display: swap; src: url("/static/fonts/cairo-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Cairo"; font-weight: 600; font-display: swap; src: url("/static/fonts/cairo-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2212; }
@font-face { font-family: "Cairo"; font-weight: 700; font-display: swap; src: url("/static/fonts/cairo-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+2000-206F, U+2212; }

:root {
  --bg: #f3f5f8; --surface: #ffffff; --surface-2: #f8fafc; --text: #16212e; --muted: #5d6b7c; --line: #e3e8ee;
  --primary: #16324f; --primary-ink: #ffffff; --accent: #d99a2b; --accent-ink: #1b1400;
  --ok: #1f8a4c; --ok-bg: #e7f6ec; --warn: #b7791f; --warn-bg: #fff6e0; --bad: #c0392b; --bad-bg: #fdecea; --info-bg: #e9f1fb;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --nav-h: 56px; --tabs-h: 62px; --num: "tnum" 1;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1b2d; --surface: #152538; --surface-2: #1b2d44; --text: #e8edf3; --muted: #a2b0c2; --line: #27405c; --primary: #1d4a76; --accent: #e3ad4a;
          --ok: #4ccb84; --ok-bg: #163b2a; --warn: #f0b85a; --warn-bg: #3d2f12; --bad: #ff7a6b; --bad-bg: #4a1f1a; --info-bg: #1a3350; --shadow: none; }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: "Cairo", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif; font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg); direction: rtl; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.3; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.12rem; } h3 { font-size: 1rem; color: var(--muted); font-weight: 600; }
.num, td.num, th.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: embed; text-align: left; }
.ltr { direction: ltr; unicode-bidi: embed; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .xs { font-size: .78rem; }
.pos { color: var(--ok); } .neg { color: var(--bad); } .warn { color: var(--warn); }
.b { font-weight: 700; }

/* layout */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--nav-h); background: var(--primary); color: var(--primary-ink); display: flex; align-items: center; gap: 12px; padding: 0 14px; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
.topbar .brand { font-weight: 700; font-size: 1.1rem; color: #fff; display: flex; align-items: center; gap: 8px; }
.topbar .brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.topbar .co { color: rgba(255,255,255,.75); font-size: .85rem; }
.topbar .grow { flex: 1; }
.topbar .user { color: #fff; font-size: .9rem; display: flex; align-items: center; gap: 10px; }
.topbar .user form { margin: 0; }
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; border: 0; padding: 6px 10px; border-radius: 10px; cursor: pointer; font: inherit; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr); min-height: calc(100vh - var(--nav-h)); }
.layout > * { min-width: 0; }
.sidenav { display: none; }
.main { padding: 14px 14px calc(var(--tabs-h) + 18px); max-width: 1400px; margin: 0 auto; width: 100%; min-width: 0; overflow-x: clip; }
@media (min-width: 1024px) {
  .layout { grid-template-columns: 236px minmax(0, 1fr); }
  .sidenav { display: block; background: var(--surface); border-left: 1px solid var(--line); padding: 14px 10px; position: sticky; top: var(--nav-h); height: calc(100vh - var(--nav-h)); overflow: auto; }
  .main { padding: 22px 26px 40px; }
  .tabs { display: none !important; }
}
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text); font-weight: 600; font-size: .95rem; }
.sidenav a.active, .sidenav a:hover { background: var(--info-bg); text-decoration: none; }
.sidenav .sec { margin: 14px 12px 6px; font-size: .75rem; color: var(--muted); letter-spacing: .3px; }
.tabs { position: fixed; bottom: 0; right: 0; left: 0; height: var(--tabs-h); background: var(--surface); border-top: 1px solid var(--line); display: flex; z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .72rem; color: var(--muted); }
.tabs a.active { color: var(--primary); font-weight: 700; }
.tabs a .ic { font-size: 1.25rem; line-height: 1; }

/* cards & grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; margin-bottom: 14px; }
.card.tight { padding: 10px 12px; }
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .grid.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.kpi .l { color: var(--muted); font-size: .8rem; }
.kpi .v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; text-align: right; }
.kpi .s { font-size: .78rem; color: var(--muted); }
.kpi.accent { border-color: var(--accent); background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 12%, var(--surface)), var(--surface)); }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.info { background: var(--info-bg); color: var(--primary); border-color: transparent; }
.alert { padding: 10px 12px; border-radius: 10px; margin-bottom: 8px; background: var(--warn-bg); border-right: 4px solid var(--warn); }
.alert.bad { background: var(--bad-bg); border-color: var(--bad); }
.alert.ok { background: var(--ok-bg); border-color: var(--ok); }
.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; background: var(--ok-bg); color: var(--ok); font-weight: 600; }
.flash.err { background: var(--bad-bg); color: var(--bad); }

/* tables */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 10px; border: 1px solid var(--line); max-width: 100%; }
.card, .kpi, .grid { min-width: 0; }
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; background: var(--surface); }
table.t th, table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
table.t th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .8rem; position: sticky; top: 0; z-index: 1; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover td { background: color-mix(in srgb, var(--info-bg) 60%, transparent); }
table.t td.wrap, table.t th.wrap { white-space: normal; min-width: 180px; }
table.t tfoot td { font-weight: 700; background: var(--surface-2); }
table.t .sticky { position: sticky; right: 0; background: var(--surface); z-index: 2; box-shadow: -6px 0 8px -6px rgba(0,0,0,.15); }
table.t th.sticky { z-index: 3; background: var(--surface-2); }
.bar { height: 8px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--primary); }

/* forms */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { display: flex; flex-direction: column; font-size: .78rem; color: var(--muted); gap: 3px; }
input, select, button, textarea { font: inherit; }
input[type=text], input[type=search], input[type=date], input[type=number], input[type=password], input[type=month], select, textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); min-width: 0; }
input[type=date], input[type=month] { direction: ltr; }
.btn { padding: 8px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.sm { padding: 4px 10px; font-size: .82rem; }
.chips a { display: inline-block; padding: 4px 10px; margin: 0 0 6px 6px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: .82rem; }
.chips a.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.sp { flex: 1; }
.pager { display: flex; gap: 6px; align-items: center; justify-content: center; margin: 14px 0; }
.stat-list { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; font-size: .92rem; }
.stat-list dt { color: var(--muted); } .stat-list dd { margin: 0; text-align: left; font-variant-numeric: tabular-nums; direction: ltr; font-weight: 600; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 80% -10%, color-mix(in srgb, var(--accent) 25%, transparent), transparent), var(--primary); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px; padding: 26px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-card input { width: 100%; margin-bottom: 10px; }
.brandmark { width: 54px; height: 54px; border-radius: 16px; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 1.6rem; font-weight: 700; margin: 0 auto 10px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; direction: ltr; unicode-bidi: embed; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
details summary { cursor: pointer; font-weight: 600; }
.perm-grid { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; font-size: .9rem; }
.perm-grid .opts { display: flex; gap: 4px; }
.perm-grid .opts label { display: inline-flex; align-items: center; gap: 3px; font-size: .8rem; padding: 2px 6px; border: 1px solid var(--line); border-radius: 8px; }
/* mobile cards for lists */
.cards { display: grid; gap: 8px; }
.mcard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; }
.mcard .t { font-weight: 700; } .mcard .s { font-size: .8rem; color: var(--muted); }
.mcard .amt { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; direction: ltr; text-align: left; align-self: center; }
@media (min-width: 720px) { .only-m { display: none !important; } }
@media (max-width: 719px) { .only-d { display: none !important; } h1 { font-size: 1.2rem; } .kpi .v { font-size: 1.15rem; } }
@media print {
  .topbar, .tabs, .sidenav, .filters, .noprint, .btn { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; } .main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; } table.t th { position: static; }
}

/* statement cards (phone) */
.scard { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.scard .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.scard .nums span { display: flex; flex-direction: column; direction: ltr; text-align: left; font-size: .95rem; }
.scard .nums i { font-style: normal; font-size: .68rem; color: var(--muted); direction: rtl; text-align: right; }
a.mcard:hover, a.card:hover { text-decoration: none; }
