/* ==========================================================
   Dabbirha — design system
   ========================================================== */
:root {
  --brand: #ff5b2e;
  --brand-dark: #e0441a;
  --brand-soft: #fff0eb;
  --ink: #14161f;
  --ink-2: #2b2f3a;
  --muted: #6b7280;
  --bg: #f6f5f2;
  --card: #ffffff;
  --line: #e7e5e0;
  --ok: #12a150;
  --ok-soft: #e7f7ee;
  --warn: #c98a00;
  --warn-soft: #fff6dc;
  --bad: #e5484d;
  --bad-soft: #fdecec;
  --info: #2563eb;
  --info-soft: #e8efff;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(20, 22, 31, .06), 0 8px 24px rgba(20, 22, 31, .06);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.02em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.native .web-only { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }

/* ---------- Brand ---------- */
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 20px; letter-spacing: -.03em; }
.logo-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--brand); display: grid; place-items: center; box-shadow: 0 6px 16px rgba(255, 91, 46, .35); }
.logo-mark svg { width: 22px; height: 22px; }
.logo small { font-weight: 600; font-size: 13px; color: var(--muted); margin-left: 2px; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 11px 18px; font-weight: 700; cursor: pointer; text-decoration: none; transition: transform .08s, background .15s, box-shadow .15s; white-space: nowrap; background: var(--card); border-color: var(--line); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: 0 6px 16px rgba(255, 91, 46, .28); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn-danger { background: #fff; color: var(--bad); border-color: #f3c6c7; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(0, 0, 0, .04); }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.input, select.input, textarea.input { width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 11px 13px; background: #fff; outline: none; transition: border .15s, box-shadow .15s; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
textarea.input { resize: vertical; min-height: 80px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; background: #efede8; padding: 5px; border-radius: 13px; }
.seg button { border: 0; background: transparent; padding: 9px 8px; border-radius: 9px; font-weight: 700; cursor: pointer; color: var(--muted); }
.seg button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }

/* ---------- Cards / badges ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; background: #efede8; color: var(--ink-2); text-transform: capitalize; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand-soft); color: var(--brand-dark); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }
.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(18, 161, 80, .5); } 70% { box-shadow: 0 0 0 8px rgba(18, 161, 80, 0); } 100% { box-shadow: 0 0 0 0 rgba(18, 161, 80, 0); } }

/* ---------- App shell ---------- */
.topbar { position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: rgba(255, 255, 255, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: 10px; font-weight: 700; background: none; border: 0; padding: 4px 6px; border-radius: 999px; cursor: pointer; }
.user-chip:hover { background: rgba(0, 0, 0, .05); }
details.acc { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
details.acc summary { cursor: pointer; font-weight: 700; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; flex-shrink: 0; }

.app { display: grid; grid-template-columns: 440px 1fr; height: calc(100vh - 61px); }
.panel { overflow-y: auto; padding: 18px; border-right: 1px solid var(--line); background: var(--bg); }
.map-wrap { position: relative; }
.map { position: absolute; inset: 0; }
.map-hint { position: absolute; z-index: 500; top: 14px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: 999px; font-weight: 700; font-size: 13px; box-shadow: var(--shadow); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; padding: 10px 12px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; display: flex; align-items: center; gap: 6px; }
.tabs button.active { color: var(--ink); border-color: var(--brand); }
.count { background: var(--brand); color: #fff; font-size: 11px; border-radius: 999px; padding: 1px 7px; }

/* ---------- Services grid ---------- */
.services { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.service { border: 1.5px solid var(--line); background: #fff; border-radius: 14px; padding: 10px 6px; text-align: center; cursor: pointer; transition: all .15s; font-size: 12px; font-weight: 700; line-height: 1.25; }
.service .ico { font-size: 24px; display: block; margin-bottom: 4px; }
.service:hover { border-color: #ffc2b0; }
.service.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); }

.loc-row { display: flex; gap: 8px; align-items: stretch; }
.loc-pin { width: 40px; flex-shrink: 0; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; cursor: pointer; font-size: 18px; }
.loc-pin.active { border-color: var(--brand); background: var(--brand-soft); }

/* ---------- Live price box ---------- */
.quote { border: 1.5px dashed var(--line); border-radius: 14px; padding: 12px 14px; background: #fff; transition: border-color .3s, background .3s; }
.quote.ready { border-style: solid; border-color: #ffc2b0; background: var(--brand-soft); }
.q-main { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.q-km { font-weight: 700; color: var(--ink-2); }
.q-min { font-weight: 800; font-size: 20px; color: var(--brand-dark); letter-spacing: -.02em; }
.q-rule { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Order cards ---------- */
.order { cursor: pointer; transition: border .15s, transform .1s; }
.order:hover { border-color: #d6d3cc; }
.route { display: grid; grid-template-columns: 14px 1fr; gap: 2px 10px; font-size: 14px; margin-top: 10px; }
.route .a, .route .b { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.route .a { background: var(--ok); }
.route .b { background: var(--brand); }
.price { font-weight: 800; font-size: 18px; }

/* ---------- Status timeline ---------- */
.timeline { display: flex; gap: 6px; }
.timeline .step { flex: 1; height: 6px; border-radius: 99px; background: var(--line); }
.timeline .step.done { background: var(--brand); }

/* ---------- Driver card ---------- */
.driver-card { display: flex; gap: 14px; align-items: center; }
.vehicle-ico { width: 52px; height: 52px; border-radius: 16px; background: var(--brand-soft); display: grid; place-items: center; font-size: 28px; flex-shrink: 0; }
.plate { font-family: ui-monospace, Menlo, monospace; background: #fff8d6; border: 1.5px solid #e5d36b; border-radius: 6px; padding: 1px 7px; font-weight: 800; font-size: 13px; }

/* ---------- Chat ---------- */
.chat { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; overflow: hidden; }
.chat-head { padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 800; display: flex; justify-content: space-between; align-items: center; }
.chat-body { height: 260px; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #fbfaf8; }
.bubble { max-width: 80%; padding: 9px 13px; border-radius: 16px; font-size: 14px; word-wrap: break-word; }
.bubble.me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 5px; }
.bubble.them { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble time { display: block; font-size: 10.5px; opacity: .7; margin-top: 2px; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form .input { border-radius: 999px; }

/* ---------- Map markers ---------- */
.mk { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-size: 20px; background: #fff; border: 3px solid var(--ink); box-shadow: 0 4px 12px rgba(0, 0, 0, .25); }
.mk.pickup { border-color: var(--ok); }
.mk.dropoff { border-color: var(--brand); }
.mk.driver { border-color: var(--info); width: 44px; height: 44px; font-size: 24px; }
.mk.me { border-color: var(--info); }
.mk.unpaid { border-color: var(--bad); }
.mk.paid { border-color: var(--ok); }
.mk.job { border-color: var(--brand); width: 34px; height: 34px; font-size: 17px; }

/* ---------- Toasts & modal ---------- */
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 5000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; box-shadow: var(--shadow); animation: up .25s ease; max-width: 90vw; }
.toast.error { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.modal-bg { position: fixed; inset: 0; background: rgba(20, 22, 31, .5); z-index: 4000; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 22px; width: 100%; max-width: 460px; max-height: 92vh; overflow-y: auto; padding: 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); }
.modal h3 { margin-bottom: 16px; font-size: 20px; }
@keyframes fade { from { opacity: 0; } }

.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .big { font-size: 40px; display: block; margin-bottom: 6px; }

.banner { border-radius: var(--radius); padding: 14px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.banner.bad { background: var(--bad-soft); color: #9f1d22; }
.banner.ok { background: var(--ok-soft); color: #0b6b35; }

/* ---------- Toggle switch ---------- */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 800; user-select: none; }
.switch input { display: none; }
.switch .track { width: 50px; height: 28px; border-radius: 99px; background: #d5d2cb; position: relative; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); }
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(22px); }

/* ---------- Stars ---------- */
.stars { display: flex; gap: 4px; }
.stars button { background: none; border: 0; font-size: 30px; cursor: pointer; color: #d5d2cb; padding: 0; }
.stars button.on { color: #f5b301; }

/* ---------- Tables (admin) ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 12px 14px; background: #faf9f7; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid #f0eee9; vertical-align: middle; white-space: nowrap; }
td.wrap { white-space: normal; min-width: 180px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fcfbf9; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 42vh auto; height: auto; }
  .map-wrap { order: -1; height: 38vh; min-height: 240px; position: relative; z-index: 0; }
  .panel { border-right: 0; overflow: visible; }
  .services { grid-template-columns: repeat(4, 1fr); }
  .topbar { padding: 10px 14px; }
  .hide-sm { display: none !important; }
}
@media (max-width: 560px) {
  html, body { overflow-x: hidden; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .logo { font-size: 17px; gap: 8px; }
  .topbar .logo small, #live-dot, .topbar .btn-logout { display: none; }
  .topbar .logo-mark { width: 32px; height: 32px; }
  .switch .track { width: 44px; height: 26px; }
  .switch input:checked + .track::after { transform: translateX(18px); }
  .modal { padding: 20px 18px; border-radius: 20px; }
}
@media (max-width: 420px) {
  .grid-2 { grid-template-columns: 1fr; }
  .services { grid-template-columns: repeat(2, 1fr); }
}
