:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --line: #e4e8ef;
  --text: #1a2233;
  --muted: #6b7686;
  --primary: #1f5fa8;
  --primary-2: #1a9c8f;
  --accent: #7ac142;
  --ok: #16a34a;
  --warn: #d97706;
  --err: #dc2626;
  --nav: #0f1e3a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
  --font: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); direction: rtl; min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
.num, .ltr { direction: ltr; unicode-bidi: embed; font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar { background: var(--nav); color: #fff; height: 64px; display: flex; align-items: center; padding: 0 22px; gap: 22px; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo-box { background: #fff; border-radius: 10px; padding: 5px 10px; display: flex; align-items: center; height: 42px; }
.brand img { height: 30px; width: auto; display: block; }
.brand .title { font-weight: 700; font-size: 17px; line-height: 1.15; }
.brand .title small { display: block; font-weight: 400; font-size: 11.5px; color: #b8c4d8; }
.nav { display: flex; gap: 4px; margin-right: 10px; }
.nav a { color: #c9d3e6; padding: 8px 14px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.topbar .spacer { flex: 1; }
.live { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #c9d3e6; }
.live .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 0 rgba(122,193,66,.7); animation: pulse 2s infinite; }
.live .dot.busy { background: #f59e0b; }
.live .dot.err { background: var(--err); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(122,193,66,.6);} 70% { box-shadow: 0 0 0 8px rgba(122,193,66,0);} 100% { box-shadow: 0 0 0 0 rgba(122,193,66,0);} }
.topbar .btn { background: var(--primary-2); }
.topbar .btn.ghost { background: transparent; border: 1px solid rgba(255,255,255,.25); }

/* ---------- layout ---------- */
.page { max-width: 1440px; margin: 0 auto; padding: 20px 22px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.charts { grid-template-columns: repeat(12, 1fr); }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; } .span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 1100px) { .span-3, .span-4, .span-5 { grid-column: span 6; } .span-7, .span-8 { grid-column: span 12; } }
@media (max-width: 720px) { .charts > * { grid-column: span 12 !important; } .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; min-width: 0; }
.card h3 { margin: 0 0 10px; font-size: 14.5px; color: var(--muted); font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.card h3 .hint { font-size: 11.5px; font-weight: 400; }
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.tall { height: 340px; }

.kpi { position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 5px; background: var(--kpi, var(--primary)); }
.kpi .label { color: var(--muted); font-size: 12.5px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.3px; }
.kpi .value small { font-size: 12px; color: var(--muted); font-weight: 500; margin-inline-start: 4px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi.mini { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; box-shadow: none; }
.kpi.mini .value { font-size: 20px; }
.kpis.today { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .kpis.today { grid-template-columns: repeat(2, 1fr); } }
.kpi.blue { --kpi: var(--primary); } .kpi.teal { --kpi: var(--primary-2); } .kpi.green { --kpi: var(--ok); } .kpi.amber { --kpi: var(--warn); } .kpi.red { --kpi: var(--err); } .kpi.gray { --kpi: #94a3b8; } .kpi.purple { --kpi: #7c3aed; }

table.tbl { border-collapse: collapse; width: 100%; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tfoot td { font-weight: 700; background: #f8fafc; }
.scroll-x { overflow-x: auto; }

.btn { display: inline-flex; align-items: center; gap: 6px; background: var(--primary); color: #fff; border: 0; border-radius: 9px; padding: 9px 16px; cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 600; text-decoration: none; line-height: 1; }
.btn.gray { background: #64748b; } .btn.light { background: #eef2f7; color: var(--text); } .btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .6; cursor: default; }
.pill { display: inline-block; border-radius: 999px; padding: 3px 10px; font-size: 12px; background: #e5e7eb; font-weight: 600; }
.pill.add { background: #dcfce7; color: #166534; } .pill.rem { background: #fee2e2; color: #991b1b; } .pill.chg { background: #fef3c7; color: #92400e; } .pill.ok { background: #dbeafe; color: #1e40af; }
.ok { color: var(--ok); } .err { color: var(--err); } .warn { color: var(--warn); } .muted { color: var(--muted); font-size: 12.5px; }
.flash { background: #ecfdf5; border: 1px solid #6ee7b7; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }
.flash.err { background: #fef2f2; border-color: #fca5a5; }
pre.log { background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 10px; direction: ltr; text-align: left; font-size: 12px; overflow: auto; max-height: 70vh; }
label { display: block; margin: 12px 0 5px; color: #374151; font-weight: 600; font-size: 13px; }
label .key { color: var(--muted); font-weight: 400; font-size: 11.5px; direction: ltr; unicode-bidi: embed; }
input[type=text], input[type=password] { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 9px; direction: ltr; font-family: inherit; font-size: 14px; background: #fff; }
input:focus { outline: 2px solid rgba(31,95,168,.25); border-color: var(--primary); }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; }
.foot { color: var(--muted); font-size: 12px; text-align: center; margin-top: 26px; }

/* ---------- login ---------- */
.login-bg { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(1200px 600px at 80% -10%, #1f5fa8 0%, transparent 60%), radial-gradient(900px 500px at 0% 110%, #1a9c8f 0%, transparent 55%), var(--nav); padding: 24px; }
.login-card { width: 100%; max-width: 440px; background: #fff; border-radius: 20px; box-shadow: 0 30px 80px rgba(0,0,0,.35); padding: 30px 32px 26px; }
.login-logos { display: flex; align-items: center; justify-content: center; gap: 18px; margin-bottom: 18px; }
.login-logos img { height: 44px; width: auto; }
.login-logos .x { color: #cbd5e1; font-size: 20px; }
.login-card h1 { font-size: 19px; margin: 6px 0 2px; text-align: center; }
.login-card p { color: var(--muted); margin: 0 0 8px; font-size: 13px; text-align: center; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 18px; padding: 12px; font-size: 15px; }
