:root {
  --brand: #1592e6;
  --brand-600: #0f7fcc;
  --brand-ink: #0b4f8c;
  --brand-deep: #072f55;
  --brand-soft: #e8f4fd;
  --bg: #f3f6fa;
  --card: #ffffff;
  --text: #0f2a44;
  --text-2: #4a5d73;
  --muted: #7a8899;
  --border: #e3e9f0;
  --border-2: #d3dce6;
  --ok: #0ca30c;
  --ok-soft: #e4f6e4;
  --bad: #d03b3b;
  --bad-soft: #fcebeb;
  --warn: #b7791f;
  --warn-soft: #fef3e2;
  --info: #2a78d6;
  --info-soft: #e6eefe;
  --s1: #1592e6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4;
  --shadow: 0 1px 2px rgba(15, 42, 68, .05), 0 4px 16px rgba(15, 42, 68, .05);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Cairo', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; color: var(--text); }
a { color: var(--brand-600); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1em; margin: 4px 0 10px; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- عناصر الفورم ---------- */
input, select, textarea {
  width: 100%; height: 42px; border: 1px solid var(--border-2); border-radius: 10px; padding: 0 12px;
  font: inherit; background: #fff; color: var(--text); transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 120px; padding: 10px 12px; line-height: 1.8; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(21, 146, 230, .15); }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); }
input[type=file] { padding: 8px; height: auto; }
label.field { display: block; font-weight: 600; font-size: 13px; color: var(--text-2); margin-bottom: 12px; }
label.field > input, label.field > select, label.field > textarea { margin-top: 6px; }
.hint { font-weight: 400; font-size: 12px; color: var(--muted); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 14px; cursor: pointer; }

button, .btn {
  font: inherit; font-weight: 700; height: 40px; padding: 0 18px; border: 0; border-radius: 10px;
  background: var(--brand); color: #fff; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  transition: background .15s, transform .05s; white-space: nowrap;
}
button:hover { background: var(--brand-600); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: #fff; color: var(--text); border: 1px solid var(--border-2); }
button.ghost:hover { background: var(--bg); }
button.danger { background: var(--bad); }
button.danger:hover { background: #b52f2f; }
button.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
button.link { background: none; color: var(--brand-600); height: auto; padding: 0; font-weight: 600; }
button.link.danger { color: var(--bad); background: none; }
button.link:hover { text-decoration: underline; background: none; }
svg.i { width: 18px; height: 18px; flex: none; }

/* ---------- الدخول ---------- */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 80% -10%, #1f9ff0 0%, transparent 60%), linear-gradient(160deg, var(--brand-ink), var(--brand-deep)); }
.auth-card { background: #fff; border-radius: 22px; padding: 30px; width: 100%; max-width: 400px; box-shadow: 0 30px 80px rgba(0,0,0,.25); }
.auth-card input { margin-bottom: 12px; }
.auth-card button { width: 100%; height: 46px; }
.login-logo { display: block; width: 190px; margin: 0 auto 6px; }
.center-text { text-align: center; margin: 0 0 18px; }

/* ---------- التخطيط ---------- */
.layout { display: flex; min-height: 100vh; }
aside { width: 252px; background: var(--brand-deep); color: #fff; padding: 18px 12px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font-weight: 800; font-size: 19px; }
.brand img { width: 38px; height: 38px; object-fit: contain; background: #fff; border-radius: 10px; padding: 5px; }
.brand span { display: block; font-size: 12px; opacity: .6; font-weight: 600; }
.nav-group { font-size: 11px; font-weight: 700; color: #7fa6c9; padding: 14px 12px 6px; letter-spacing: .3px; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav button { background: transparent; justify-content: flex-start; color: #c9dcee; font-weight: 600; height: 40px; padding: 0 12px; gap: 10px; }
nav button svg.i { opacity: .8; }
nav button:hover { background: rgba(255,255,255,.07); color: #fff; }
nav button.on { background: var(--brand); color: #fff; box-shadow: 0 6px 18px rgba(21,146,230,.35); }
nav button.on svg.i { opacity: 1; }
.badge { background: var(--bad); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; margin-inline-start: auto; line-height: 18px; }
.spacer { flex: 1; min-height: 12px; }
.who { color: #9fbcd8; font-size: 12px; padding: 0 12px 8px; }
.logout { background: rgba(255,255,255,.08); }
.logout:hover { background: rgba(255,255,255,.14); }

main { flex: 1; padding: 26px 30px 60px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 22px; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.actions select { width: auto; height: 38px; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card h3 { font-size: 16px; margin-bottom: 4px; }
.card .card-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.section-title { font-size: 15px; font-weight: 800; margin: 26px 0 12px; }

/* ---------- الأرقام ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; }
.tile { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.tile .label { color: var(--text-2); font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tile .big { font-size: 28px; font-weight: 800; margin-top: 6px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.tile .foot { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tile.hero { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-ink) 100%); color: #fff; border: 0; }
.tile.hero .label, .tile.hero .foot { color: rgba(255,255,255,.85); }
.tile.warn { background: var(--warn-soft); border-color: #f6dcb0; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------- الرسومات ---------- */
.charts { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; margin-top: 16px; }
.charts > .card { margin: 0; min-width: 0; }
.span-8 { grid-column: span 8; } .span-6 { grid-column: span 6; } .span-4 { grid-column: span 4; } .span-12 { grid-column: span 12; }
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 220px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 80px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { height: 10px; background: #eef2f7; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--brand); border-radius: 4px; }
.split { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; background: #fff; margin: 10px 0; }
.split > div { height: 100%; }

/* ---------- الجداول ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: right; color: var(--muted); font-weight: 700; font-size: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: #f8fafc; }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover td { background: #fafcfe; }
tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }
.addr { max-width: 260px; }
.empty { text-align: center; padding: 40px; color: var(--muted); }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: #eef1f5; color: var(--text-2); white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: #087a08; }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.brand { background: var(--brand-soft); color: var(--brand-ink); }
.money-pos { color: #087a08; font-weight: 700; }
.money-neg { color: var(--bad); font-weight: 700; }
.row-actions { white-space: nowrap; }
.row-actions > * + * { margin-inline-start: 8px; }
.bbody .row-actions, .vcard .row-actions { white-space: normal; }
.toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { max-width: 280px; height: 38px; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--border-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { background: transparent; color: var(--text-2); height: 32px; padding: 0 12px; font-weight: 600; border-radius: 8px; }
.seg button.on { background: var(--brand); color: #fff; }

/* ---------- بطاقات (أنواع العربيات، البانرات) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.vcard { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.vcard.off { opacity: .55; }
.vcard .vhead { display: flex; align-items: center; gap: 12px; }
.vcard .vicon { font-size: 30px; width: 54px; height: 54px; display: grid; place-items: center; background: var(--brand-soft); border-radius: 14px; }
.vcard .vname { font-weight: 800; font-size: 16px; }
.price-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; background: #f8fafc; border-radius: 10px; padding: 10px 12px; }
.price-grid b { font-variant-numeric: tabular-nums; }
.banner-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.banner-card img { width: 100%; aspect-ratio: 12 / 5; object-fit: cover; display: block; background: #eef2f7; }
.banner-card .bbody { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.banner-card.off img { filter: grayscale(1); opacity: .6; }

/* ---------- السويتش ---------- */
.switch { position: relative; width: 42px; height: 24px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::after { content: ''; position: absolute; width: 18px; height: 18px; top: 3px; right: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { right: 21px; }

/* ---------- الربط ---------- */
.integ { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; }
.integ .card { margin: 0; }
.integ-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.integ-logo { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 16px; flex: none; }
.status-line { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin-top: 4px; }
.test-result { font-size: 13px; margin-top: 10px; padding: 10px 12px; border-radius: 10px; }
.test-result.ok { background: var(--ok-soft); color: #087a08; }
.test-result.bad { background: var(--bad-soft); color: var(--bad); }
.note { background: var(--brand-soft); color: var(--brand-ink); border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.8; margin-bottom: 14px; }
.note.warn { background: var(--warn-soft); color: #8a5a12; }
code { background: #eef2f7; padding: 1px 6px; border-radius: 6px; font-size: 12.5px; direction: ltr; display: inline-block; }

/* ---------- المودال والتوست ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(7, 26, 46, .45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; box-shadow: 0 30px 80px rgba(0,0,0,.3); animation: pop .18s ease-out; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 18px 22px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-start; padding: 14px 22px 20px; }
.x { background: none; color: var(--muted); height: 32px; width: 32px; padding: 0; font-size: 22px; }
.x:hover { background: var(--bg); }
#toasts { position: fixed; bottom: 20px; left: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: #fff; padding: 12px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.2); animation: pop .2s; max-width: 360px; }
.toast.bad { background: var(--bad); }
.toast.ok { background: #087a08; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.skeleton { height: 120px; border-radius: var(--radius); background: linear-gradient(90deg, #eef2f7 25%, #f6f8fb 50%, #eef2f7 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (max-width: 1100px) {
  .span-8, .span-6, .span-4 { grid-column: span 12; }
}
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  aside { width: 100%; height: auto; position: static; padding: 12px; }
  .brand { padding: 0 4px 8px; }
  .nav-group { display: none; }
  nav { flex-direction: row; overflow-x: auto; }
  nav button { white-space: nowrap; height: 38px; }
  .spacer, .who { display: none; }
  .logout { align-self: flex-start; height: 34px; margin-top: 8px; }
  main { padding: 16px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 60px; }
  .integ { grid-template-columns: 1fr; }
}

/* ---------- مستندات الكباتن ---------- */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.doc-card { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.doc-thumb { height: 160px; background: #f3f6fa; display: grid; place-items: center; overflow: hidden; }
.doc-thumb img { width: 100%; height: 160px; object-fit: cover; display: block; cursor: zoom-in; }
.doc-info { padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.doc-actions { display: flex; gap: 6px; align-items: center; margin-top: 4px; }
.doc-actions input[type=date] { height: 32px; flex: 1; min-width: 0; font-size: 12px; padding: 0 8px; }

/* ---------- الإصدار 4 ---------- */
.zone-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.zone-row input[type=number] { padding: 0 6px; }
.chat-log { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; background: #f8fafc; border-radius: 12px; padding: 12px; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 12px; font-size: 13.5px; }
.bubble.rider { background: #fff; border: 1px solid var(--border); align-self: flex-start; }
.bubble.driver { background: var(--brand-soft); align-self: flex-end; }
.leaflet-container { font-family: 'Cairo', system-ui, sans-serif; }
