@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  --navy: #0B1B2B; --navy2: #13263A; --line-d: #22384F;
  --green: #12C27A; --green-d: #077A4A; --green-bg: #E6F9F0;
  --amber: #FFB020; --amber-bg: #FFF4DB; --amber-d: #8A5300;
  --red: #C8333A; --red-bg: #FDECEC; --red-l: #FF7A7E;
  --ink: #0B1B2B; --muted: #5B6B7B; --muted-d: #9FB0C2;
  --bg: #F4F7FA; --line: #E3E8EE; --white: #FFFFFF;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
body.dark { background: var(--navy); color: #fff; }
button, input, select, textarea { font: inherit; }
a { color: var(--green-d); }
body.dark a { color: var(--green); }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.screen { min-height: 100%; display: flex; flex-direction: column; }
.pad { padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.center { text-align: center; }
.muted { color: var(--muted); }
body.dark .muted { color: var(--muted-d); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.bold { font-weight: 700; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 18px; margin: 0; }

/* ---------- logo ---------- */
.logo {
  width: 44px; height: 44px; border-radius: 13px; background: var(--green); color: var(--navy);
  font-weight: 700; font-size: 22px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.logo.big { width: 84px; height: 84px; border-radius: 26px; font-size: 44px; box-shadow: 0 16px 36px rgba(18,194,122,.35); }

/* ---------- inputs ---------- */
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
body.dark label.field { color: var(--muted-d); }
.input {
  height: 52px; border-radius: 14px; border: 1.5px solid #CBD3DC; padding: 0 14px;
  font-size: 16px; color: var(--ink); background: #fff; width: 100%;
}
.input:focus { outline: none; border-color: var(--green); }
body.dark .input { background: var(--navy2); border-color: var(--line-d); color: #fff; }
.ltr { direction: ltr; text-align: right; }

/* ---------- buttons ---------- */
.btn {
  min-height: 52px; border-radius: 14px; border: 0; padding: 0 18px; cursor: pointer;
  font-size: 16px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; width: 100%;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--green); color: var(--navy); box-shadow: 0 8px 20px rgba(18,194,122,.30); }
.btn.dark { background: var(--navy); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid #CBD3DC; }
body.dark .btn.ghost { color: #fff; border-color: var(--line-d); background: var(--navy2); }
.btn.danger { background: #fff; color: var(--red); border: 1.5px solid var(--red); }
body.dark .btn.danger { background: transparent; color: var(--red-l); border-color: var(--red-l); }
.btn.sm { min-height: 40px; font-size: 14px; border-radius: 11px; width: auto; padding: 0 14px; }
.icon-btn {
  width: 48px; height: 48px; border-radius: 14px; border: 0; background: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 2px 10px rgba(11,27,43,.1); flex-shrink: 0;
  text-decoration: none; color: var(--ink);
}
body.dark .icon-btn { background: var(--navy2); border: 1px solid var(--line-d); color: #fff; box-shadow: none; }

/* segmented */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--bg); }
body.dark .seg { background: var(--navy2); }
.seg button { height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; }
body.dark .seg button.on { background: var(--green); color: var(--navy); }

/* option cards */
.opt {
  display: flex; align-items: center; justify-content: space-between; min-height: 64px; padding: 10px 16px; border-radius: 16px;
  border: 2px solid var(--line); background: #fff; cursor: pointer; text-align: start; color: var(--ink); width: 100%;
}
.opt.on { border-color: var(--green); background: #EBFBF3; }

/* ---------- cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
body.dark .card { background: var(--navy2); border-color: var(--line-d); }
.badge { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; display: inline-block; }
.b-green { background: var(--green-bg); color: #055A36; }
.b-amber { background: var(--amber-bg); color: var(--amber-d); }
.b-red { background: var(--red-bg); color: #A32028; }
.b-gray { background: #EEF2F6; color: #3A4A5A; }
.price { font-size: 30px; font-weight: 700; }
.price small { font-size: 16px; }
.plate { font-weight: 700; letter-spacing: 1px; padding: 4px 10px; border-radius: 8px; border: 2px solid var(--ink); direction: ltr; display: inline-block; }
body.dark .plate { border-color: var(--amber); color: var(--amber); }

/* ---------- map page ---------- */
.map-page { position: fixed; inset: 0; display: flex; flex-direction: column; }
#map { position: absolute; inset: 0; z-index: 1; }
.topbar { position: absolute; top: 0; right: 0; left: 0; z-index: 500; padding: 16px; display: flex; gap: 10px; align-items: center; justify-content: space-between; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.pill { background: var(--navy); color: #fff; border-radius: 14px; padding: 10px 14px; font-size: 14px; font-weight: 600; box-shadow: 0 6px 18px rgba(11,27,43,.25); }
.sheet {
  position: absolute; bottom: 0; right: 0; left: 0; z-index: 600; background: #fff; border-radius: 26px 26px 0 0;
  padding: 12px 18px 22px; box-shadow: 0 -6px 24px rgba(11,27,43,.12); max-height: 72vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.sheet::before { content: ''; width: 44px; height: 5px; border-radius: 3px; background: #D3DAE2; align-self: center; flex-shrink: 0; }
body.dark .sheet { background: var(--navy); border-top: 1px solid var(--line-d); }
.route { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 14px; background: var(--bg); font-size: 14px; }
body.dark .route { background: var(--navy2); }
.dot { width: 10px; height: 10px; border-radius: 5px; background: var(--green); display: inline-block; flex-shrink: 0; }
.dot.sq { border-radius: 2px; background: var(--ink); }
body.dark .dot.sq { background: var(--amber); }

/* leaflet markers */
.mk { width: 22px; height: 22px; border-radius: 11px; border: 4px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.mk.pick { background: var(--green); }
.mk.dest { background: var(--navy); border-radius: 5px; }
.mk.car { width: 30px; height: 30px; border-radius: 15px; background: var(--navy); display: flex; align-items: center; justify-content: center; color: var(--green); font-size: 16px; }

/* toast */
#toast { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 9999; max-width: 92vw;
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,.3); opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }
#toast.err { background: var(--red); }
#toast.ok { background: var(--green); color: var(--navy); }

/* spinner */
.spin { width: 56px; height: 56px; border-radius: 50%; border: 5px solid var(--green-bg); border-top-color: var(--green); animation: sp 1s linear infinite; margin: 8px auto; }
@keyframes sp { to { transform: rotate(360deg); } }

/* stars */
.stars { display: flex; justify-content: center; gap: 4px; direction: ltr; }
.stars button { width: 48px; height: 48px; border: 0; background: transparent; font-size: 34px; color: #D3DAE2; cursor: pointer; line-height: 1; }
.stars button.on { color: var(--amber); }

/* toggle switch */
.switch { width: 56px; height: 32px; border-radius: 16px; padding: 4px; display: flex; background: var(--line-d); justify-content: flex-end; flex-shrink: 0; }
.switch span { width: 24px; height: 24px; border-radius: 12px; background: var(--muted-d); }
.switch.on { background: var(--navy); justify-content: flex-start; }
.switch.on span { background: var(--green); }

/* tables (admin) */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: start; padding: 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 10px; border-bottom: 1px solid #EEF2F6; vertical-align: middle; }

/* admin layout */
.admin { display: flex; flex-wrap: wrap; min-height: 100vh; }
.admin nav { flex: 1 1 220px; background: var(--navy); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 6px; }
.admin nav button { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 0; background: transparent; color: #C9D4DF; cursor: pointer; text-align: start; font-size: 14px; }
.admin nav button.on { background: var(--green); color: var(--navy); font-weight: 700; }
.admin main { flex: 999 1 560px; min-width: 0; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.stat { flex: 1 1 160px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.stat b { font-size: 26px; }
