/* Speedly Ambassador — admin panel (RTL, Tajawal, light + dark) */
:root {
  --brand: #FF891F; --brand-600: #F07A10; --brand-700: #D96A05; --brand-50: #FFF4EA; --brand-100: #FFE4CC;
  --bg: #F5F6F8; --surface: #FFFFFF; --surface-2: #FAFAFB; --line: #E9EAEE; --line-2: #F1F2F4;
  --ink: #1C2130; --ink-2: #3A4152; --muted: #6E7586;
  --green: #16A34A; --green-50: #EAF7EF; --red: #DC2626; --red-50: #FDEDED; --amber: #B45309; --amber-50: #FEF5E6;
  --blue: #2563EB; --blue-50: #EBF1FE; --purple: #7C3AED; --purple-50: #F2ECFE; --gray-50: #F1F2F4;
  --radius: 14px; --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(28,33,48,.04), 0 4px 16px rgba(28,33,48,.05);
  --sidebar: 264px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0F1218; --surface: #171B23; --surface-2: #1C212B; --line: #262C37; --line-2: #20252F;
  --ink: #ECEEF2; --ink-2: #C9CDD6; --muted: #8E95A4;
  --brand-50: #2A1E12; --brand-100: #3A2814;
  --green-50: #12261A; --red-50: #2B1515; --amber-50: #2A2010; --blue-50: #131D33; --purple-50: #1F1730; --gray-50: #1F242E;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 6px 20px rgba(0,0,0,.25);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Tajawal', system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.6; }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: embed; }
.inline { display: inline; }
.hidden { display: none !important; }

/* ---------- sidebar ---------- */
.sidebar { position: fixed; inset-block: 0; right: 0; width: var(--sidebar); background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; z-index: 40; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 16px; text-decoration: none !important; color: var(--ink); }
.brand img { width: 40px; height: 40px; border-radius: 12px; }
.brand b { display: block; font-size: 16px; font-weight: 800; }
.brand small { color: var(--muted); font-size: 12px; }
nav { padding: 4px 12px 24px; }
.nav-group { font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 16px 12px 6px; letter-spacing: .02em; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--ink-2); font-weight: 500; text-decoration: none !important; transition: background .15s, color .15s; }
.nav-link svg { flex: none; color: var(--muted); }
.nav-link:hover { background: var(--gray-50); color: var(--ink); }
.nav-link.active { background: var(--brand-50); color: var(--brand-700); font-weight: 700; }
.nav-link.active svg { color: var(--brand-600); }
.nav-count { margin-inline-start: auto; font-style: normal; font-size: 12px; font-weight: 700; background: var(--brand); color: #fff; border-radius: 999px; padding: 0 8px; min-width: 22px; text-align: center; }
.sidebar-backdrop { display: none; }

/* ---------- main ---------- */
.main { margin-right: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.page-title { font-size: 20px; font-weight: 800; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { border-color: var(--brand-100); color: var(--brand-700); }
.user-chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); font-weight: 500; text-decoration: none !important; }
.only-mobile { display: none; }
.content { padding: 24px 28px 48px; max-width: 1440px; width: 100%; }

/* ---------- cards & grid ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 16px; font-weight: 800; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat .label { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 24px; font-weight: 800; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.stat.accent { background: linear-gradient(150deg, var(--brand), var(--brand-700)); color: #fff; border-color: transparent; }
.stat.accent .label, .stat.accent .sub { color: rgba(255,255,255,.85); }
.stat.attention { border-color: var(--brand-100); background: var(--brand-50); }
.stat a.stretched::after { content: ''; position: absolute; inset: 0; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: right; font-weight: 700; color: var(--muted); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2); }
table.data td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tr:hover td { background: var(--surface-2); }
table.data td.actions { white-space: nowrap; text-align: left; }
.empty { text-align: center; color: var(--muted); padding: 36px 12px !important; }
.pager { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; gap: 8px; }
.pager > div { display: flex; gap: 6px; }

/* ---------- filters & forms ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 16px; }
.filters .field { min-width: 150px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.filters .field { margin-bottom: 0; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 12px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 16px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700; font-size: 14px; padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; background: var(--brand); color: #fff; cursor: pointer; text-decoration: none !important; transition: background .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--brand-600); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--gray-50); }
.btn-green { background: var(--green); } .btn-green:hover { background: #12873D; }
.btn-red { background: var(--red); } .btn-red:hover { background: #B91C1C; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- badges ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.badge-green { background: var(--green-50); color: var(--green); }
.badge-red { background: var(--red-50); color: var(--red); }
.badge-amber { background: var(--amber-50); color: var(--amber); }
.badge-blue { background: var(--blue-50); color: var(--blue); }
.badge-purple { background: var(--purple-50); color: var(--purple); }
.badge-gray { background: var(--gray-50); color: var(--muted); }
.pos { color: var(--green); font-weight: 700; } .neg { color: var(--red); font-weight: 700; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; text-decoration: none !important; white-space: nowrap; }
.tabs a.active { color: var(--brand-700); border-bottom-color: var(--brand); }

/* ---------- misc ---------- */
.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 16px; }
.alert-warning { background: var(--amber-50); color: var(--amber); }
.alert-info { background: var(--blue-50); color: var(--blue); }
.alert-error { background: var(--red-50); color: var(--red); }
.alert-success { background: var(--green-50); color: var(--green); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 22px 16px 0; border-right: 2px solid var(--line); }
.timeline li::before { content: ''; position: absolute; right: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--brand); border: 2px solid var(--surface); }
.timeline li:last-child { border-right-color: transparent; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.doc { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); }
.doc img, .doc iframe { width: 100%; height: 200px; object-fit: contain; display: block; background: #000; border: 0; }
.doc .doc-cap { padding: 8px 12px; font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; }
.chart-box { position: relative; height: 280px; }
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state svg { color: var(--brand); margin-bottom: 12px; }
.empty-state h2 { font-size: 18px; margin-bottom: 16px; }

/* ---------- toasts & modal ---------- */
.toasts { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 100; max-width: min(420px, calc(100vw - 40px)); }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--surface); box-shadow: 0 10px 30px rgba(0,0,0,.18); font-weight: 500; animation: toast-in .25s ease-out; }
.toast-success { background: var(--green); color: #fff; } .toast-error { background: var(--red); color: #fff; } .toast-warning { background: var(--amber); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
dialog.modal { border: 0; border-radius: 16px; padding: 24px; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(0,0,0,.25); }
dialog.modal::backdrop { background: rgba(15,18,24,.45); }
dialog.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 18px; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 100% 0, var(--brand-50), transparent), var(--bg); padding: 20px; }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.login-card .brand { padding: 0 0 20px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-2-1 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .sidebar { transform: translateX(100%); transition: transform .2s ease; box-shadow: -10px 0 40px rgba(0,0,0,.15); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
  .main { margin-right: 0; }
  .only-mobile { display: inline-grid; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .user-chip span { display: none; }
  .kv { grid-template-columns: 120px 1fr; }
}

/* processing steps (top-up dual approval) */
.steps { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.steps li { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); }
.steps li b { color: var(--text, inherit); }
.steps li small { font-size: 12px; }
.steps li.current { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, transparent); }
.steps li.current b { color: var(--brand); }
.steps li.done { border-color: var(--green, #16A34A); }
.steps li.done b::after { content: ' ✓'; color: var(--green, #16A34A); }
