:root {
  --brand: #0e7490;
  --bg: #f3f6f8;
  --card: #ffffff;
  --ink: #0f1d2a;
  --muted: #5b6b7a;
  --line: #dfe6ec;
  --ok: #0f8a4b;
  --warn: #b45309;
  --err: #c0262d;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 29, 42, .06), 0 4px 14px rgba(15, 29, 42, .05);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Cairo", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[dir=rtl] body { font-family: "Cairo", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif; }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
small { display: block; color: var(--muted); font-size: .82rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .err { color: var(--err); }
.i { width: 1.15em; height: 1.15em; vertical-align: -.2em; flex: none; }
code { background: #eef3f6; padding: .25rem .45rem; border-radius: 6px; font-size: .85rem; word-break: break-all; }
code.block { display: block; margin: .4rem 0; }

/* ---------- layout ---------- */
#app { max-width: 640px; margin: 0 auto; padding-bottom: 90px; }
#app.role-company_admin, #app.role-superadmin { max-width: 1180px; }
.top { position: sticky; top: 0; z-index: 500; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .65rem 1rem; padding-top: max(.65rem, env(safe-area-inset-top)); background: var(--brand); color: #fff; }
.brand { color: #fff; font-weight: 800; font-size: 1.05rem; display: flex; align-items: center; gap: .45rem; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: .25rem; }
.top .ghost { color: #fff; border-color: rgba(255, 255, 255, .35); }
main { padding: 1rem; }
.loading { height: 3px; margin: 2rem auto; width: 40%; background: linear-gradient(90deg, transparent, var(--brand), transparent); background-size: 200% 100%; animation: ld 1s linear infinite; border-radius: 2px; }
.loading.sm { margin: .6rem 0; }
@keyframes ld { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* customer: bottom tab bar */
.nav-customer { position: fixed; bottom: 0; left: 0; right: 0; z-index: 600; display: flex; justify-content: center; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav-customer a { flex: 1; max-width: 213px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: .5rem; color: var(--muted); font-size: .75rem; }
.nav-customer a.on { color: var(--brand); font-weight: 700; }
.nav-customer .i { width: 1.4em; height: 1.4em; }
.role-customer .sticky-cta { bottom: calc(58px + env(safe-area-inset-bottom)); }

/* office: side nav on wide screens, scrolling tabs on phones */
.nav-company_admin { display: flex; gap: .25rem; overflow-x: auto; padding: .5rem 1rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 52px; z-index: 400; }
.nav-company_admin a { display: flex; align-items: center; gap: .35rem; white-space: nowrap; padding: .45rem .7rem; border-radius: 999px; color: var(--muted); font-size: .9rem; }
.nav-company_admin a.on { background: color-mix(in srgb, var(--brand) 12%, white); color: var(--brand); font-weight: 700; }
@media (min-width: 1000px) {
  #app.role-company_admin { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; max-width: none; }
  .role-company_admin .top { grid-column: 1 / -1; }
  .nav-company_admin { flex-direction: column; overflow: visible; border-bottom: 0; border-inline-end: 1px solid var(--line); min-height: calc(100vh - 52px); top: 52px; align-self: start; padding: 1rem .6rem; }
  .nav-company_admin a { border-radius: 10px; }
  .role-company_admin main { padding: 1.4rem 2rem; max-width: 1100px; }
}

/* ---------- elements ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: .8rem; }
.card h3 { font-size: 1rem; }
h1.page { font-size: 1.35rem; margin-bottom: .8rem; }
h3.sub { font-size: .95rem; margin: 1.1rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
[dir=rtl] h3.sub { text-transform: none; letter-spacing: 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem; margin-bottom: .6rem; }
.page-head h1 { margin: 0; }
.row { display: flex; align-items: center; } .gap { gap: .5rem; } .wrap { flex-wrap: wrap; } .col { display: flex; flex-direction: column; } .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .2rem .8rem; }
.grid2 .span2 { grid-column: 1 / -1; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.cols { display: grid; gap: 1rem; }
@media (min-width: 900px) { .cols { grid-template-columns: 1.4fr 1fr; align-items: start; } }
.list { display: flex; flex-direction: column; gap: .5rem; }
.list .card { margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.empty.sm { padding: 1rem; }
.empty .i { width: 2.4rem; height: 2.4rem; color: var(--ok); }
.empty .primary { margin-top: 1rem; }

label { display: block; font-size: .85rem; color: var(--muted); margin: .45rem 0; }
label > input, label > select, label > textarea, label > .pw, label > .row { margin-top: .25rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .65rem .75rem; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 40%, transparent); border-color: var(--brand); }
input[type=checkbox] { width: 1.2rem; height: 1.2rem; min-height: 0; accent-color: var(--brand); }
input[type=color] { padding: .2rem; height: 44px; }
input.xs { width: 70px; display: inline-block; }
textarea { resize: vertical; }
.pw { display: flex; gap: .4rem; }
label.check { display: flex; align-items: center; gap: .55rem; color: var(--ink); font-size: .95rem; cursor: pointer; }
label.inline { display: flex; align-items: center; gap: .4rem; }
label.inline input { margin: 0; }

button, .primary, .secondary, .ghost, .danger-outline {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 10px; padding: .6rem 1rem; min-height: 44px; border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; text-align: center;
}
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--brand); color: #fff; }
.secondary { background: color-mix(in srgb, var(--brand) 10%, white); color: var(--brand); }
.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.danger-outline { background: #fff; color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, white); }
.sm { min-height: 34px; padding: .3rem .6rem; font-size: .85rem; }
.big { min-height: 52px; font-size: 1.05rem; padding: .7rem 1.4rem; }
.block { display: flex; width: 100%; margin: .6rem 0; }
.round { width: 42px; height: 42px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--brand) 10%, white); color: var(--brand); flex: none; }
.round.wa { background: #e7f8ee; color: #128c4b; }
.chip { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; background: #eef2f5; color: var(--muted); white-space: nowrap; }
.st-unassigned { background: #fdecec; color: var(--err); } .st-assigned { background: #e8f1fb; color: #1d5fa8; }
.st-on_way, .st-arrived { background: #fff4e0; color: var(--warn); } .st-washing { background: #e6f6fa; color: #0e7490; }
.st-done { background: #e6f6ec; color: var(--ok); } .st-cancelled { background: #eef0f2; color: #7b8794; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; background: #b8c2cc; }
.dot.green { background: #16a34a; } .dot.amber { background: #f59e0b; }

#toasts { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 2000; display: flex; flex-direction: column; gap: .4rem; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--shadow); transition: opacity .4s; }
.toast.err { background: var(--err); } .toast.warn { background: var(--warn); } .toast.out { opacity: 0; }

/* ---------- sign in ---------- */
.hero { text-align: center; padding: 1.6rem .5rem 1rem; }
.hero h1 { font-size: 1.7rem; color: var(--brand); }
.hero p { color: var(--muted); margin: 0; }
.auth .msg { color: var(--brand); font-size: .9rem; min-height: 0; margin: .3rem 0 .6rem; }
.auth .big { width: 100%; }
.auth .hint { font-size: .82rem; color: var(--muted); text-align: center; margin: .7rem 0 0; }
.preview { margin-top: 1.2rem; }
.svc-row { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.price { font-weight: 800; color: var(--ink); white-space: nowrap; }
.wa-link { display: inline-flex; gap: .4rem; align-items: center; padding: .8rem; color: #128c4b; font-weight: 600; }
.row-link { display: flex; align-items: center; gap: .7rem; color: var(--ink); }
.row-link .dot { width: 14px; height: 14px; }

/* ---------- booking ---------- */
.banner { display: flex; align-items: center; gap: .6rem; background: #fff4e0; color: var(--ink); padding: .8rem 1rem; border-radius: var(--radius); margin-bottom: .8rem; }
.banner span { flex: 1; }
.step { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: .8rem; }
.step h2 { font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.step .n { width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--brand); color: #fff; font-size: .85rem; display: inline-flex; align-items: center; justify-content: center; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .3rem 0 .5rem; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .3rem; }
.chip-btn { background: #fff; border: 1px solid var(--line); color: var(--ink); border-radius: 999px; min-height: 40px; padding: .35rem .85rem; font-weight: 500; white-space: nowrap; }
.chip-btn.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, white); color: var(--brand); font-weight: 700; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin: .4rem 0; }
.seg button { flex: 1; border-radius: 0; background: #fff; color: var(--ink); font-weight: 600; border: 0; border-inline-end: 1px solid var(--line); }
.seg button:last-child { border-inline-end: 0; }
.seg button.on { background: var(--brand); color: #fff; }
.svc-list { display: flex; flex-direction: column; gap: .5rem; }
.svc { display: flex; justify-content: space-between; align-items: center; gap: .8rem; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: .75rem .9rem; text-align: start; color: var(--ink); font-weight: 400; }
.svc.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, white); box-shadow: inset 0 0 0 1px var(--brand); }
.svc-main { display: flex; flex-direction: column; gap: .1rem; }
.extras { display: flex; flex-direction: column; gap: .1rem; }
.extras .check { justify-content: space-between; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.extras .check span:first-of-type { flex: 1; }
.when { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-bottom: .5rem; }
.when-opt { flex-direction: column; align-items: flex-start; background: #fff; border: 1.5px solid var(--line); color: var(--ink); text-align: start; padding: .8rem; border-radius: 12px; }
.when-opt small { font-weight: 400; }
.when-opt.on { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, white); box-shadow: inset 0 0 0 1px var(--brand); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: .4rem; margin-top: .4rem; }
.slot { background: #fff; border: 1px solid var(--line); color: var(--ink); min-height: 40px; padding: .3rem; font-weight: 600; }
.slot.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.slot.full { color: var(--muted); border-style: dashed; }
.sticky-cta { position: fixed; left: 0; right: 0; bottom: 0; z-index: 550; background: #fff; border-top: 1px solid var(--line); padding: .7rem 1rem; display: flex; justify-content: center; }
.sticky-cta > div { flex: 1; max-width: 420px; }
.sticky-cta b { font-size: 1.25rem; }
.sticky-cta .big { min-width: 160px; }
.book { padding-bottom: 80px; }

.map-box { height: 240px; border-radius: 12px; overflow: hidden; margin: .5rem 0; position: relative; background: #e5ebef; z-index: 1; }
.map-box.tall { height: 340px; }
.map-box.full { height: 62vh; }
.center-pin { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -100%); z-index: 800; pointer-events: none; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .35)); }
.mk { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 800; font-size: .8rem; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.mk-captain { background: #64748b; } .mk-captain.on, .mk-captain:not(.stale) { background: #16a34a; } .mk-captain.stale { background: #94a3b8; }
.mk-job { background: var(--brand); } .mk-job.st-unassigned { background: var(--err); } .mk-job.st-done { background: #94a3b8; }
.mk-base { background: #1e293b; border-radius: 6px; }

/* ---------- tracking ---------- */
.status-card { text-align: center; }
.status-card h2 { font-size: 1.3rem; margin: .3rem 0; }
.status-card .eta { font-size: 1.1rem; font-weight: 800; color: var(--brand); margin: .2rem 0; }
.status-card p { margin: .3rem 0; }
.st-bg-done { background: #effaf3; } .st-bg-cancelled { background: #f3f4f6; } .st-bg-unassigned { background: #fff7f7; }
.steps { list-style: none; display: flex; padding: 0; margin: 0 0 .8rem; gap: .25rem; }
.steps li { flex: 1; text-align: center; font-size: .7rem; color: var(--muted); padding-top: .55rem; border-top: 4px solid var(--line); }
.steps li.past { border-color: color-mix(in srgb, var(--brand) 45%, white); }
.steps li.now { border-color: var(--brand); color: var(--brand); font-weight: 800; }
.person { display: flex; align-items: center; gap: .7rem; }
.person > .i { width: 2rem; height: 2rem; color: var(--brand); }
.person > div { flex: 1; }
.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); flex: none; }
.kv b { text-align: end; font-weight: 600; }
.stars { display: flex; gap: .3rem; justify-content: center; }
.stars button { font-size: 2rem; background: none; color: #f59e0b; min-height: 0; padding: 0 .2rem; }
.rate { text-align: center; }
.rate textarea { margin-top: .5rem; }
.photos { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.photos a { display: block; text-align: center; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; display: block; }
.booking-row { display: flex; align-items: center; gap: .8rem; color: var(--ink); }
.booking-row > div:first-child:not(.time) { flex: 1; min-width: 0; }
.booking-row .time { font-weight: 800; min-width: 3.6rem; }
.booking-row .end { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.li { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.li span { flex: 1; }
details.card summary { cursor: pointer; }
details.card summary small { display: inline; }
details[open] summary { margin-bottom: .5rem; }

/* ---------- captain ---------- */
.shift { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-inline-start: 6px solid #b8c2cc; }
.shift.on { border-inline-start-color: #16a34a; }
.job.main { border: 2px solid var(--brand); }
.job-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: .4rem; }
.job-head b { font-size: 1.05rem; }
.big-money { font-size: 1.15rem; color: var(--ok); }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .4rem; margin: .7rem 0 .3rem; }
.actions .secondary { font-size: .9rem; padding: .5rem; }
label.file { margin: 0; cursor: pointer; }
.today { display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }

/* ---------- office ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem 1rem; }
.stat b { font-size: 1.4rem; }
.stat.warn { background: #fff4f4; } .stat.warn b { color: var(--err); }
.setup { border-inline-start: 5px solid var(--warn); display: flex; flex-direction: column; gap: .35rem; }
.cap-row { display: flex; align-items: center; gap: .7rem; }
.cap-row.off { opacity: .55; }
.share code { display: block; margin: .3rem 0 .5rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.filters input[type=search] { flex: 2; min-width: 200px; }
.filters input, .filters select { flex: 1; width: auto; min-width: 140px; }
.page-head input[type=date] { width: auto; }
.office-form { max-width: 760px; }
.total-line { margin: .6rem 0 0; }
.svc-edit.off { opacity: .6; }
.prices { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; }
@media (max-width: 520px) { .prices { grid-template-columns: 1fr 1fr; } }
.hours { display: flex; flex-direction: column; gap: .3rem; }
.hrow { display: grid; grid-template-columns: 9rem 1fr auto 1fr; gap: .5rem; align-items: center; }
.hrow label { margin: 0; }

/* ---------- invoice ---------- */
.invoice { background: #fff; padding: 1.4rem; border-radius: var(--radius); box-shadow: var(--shadow); margin-top: .8rem; font-size: .9rem; }
.invoice header { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.invoice h2 { font-size: 1.1rem; }
.invoice .qr svg { width: 130px; height: 130px; }
.invoice .parties { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.invoice h4 { color: var(--muted); font-size: .8rem; margin-bottom: .2rem; }
.invoice table { width: 100%; border-collapse: collapse; }
.invoice th, .invoice td { padding: .45rem; border-bottom: 1px solid var(--line); text-align: start; }
.invoice td:not(:first-child), .invoice th:not(:first-child) { text-align: end; white-space: nowrap; }
.invoice tfoot td { font-weight: 600; }
.invoice .grand td { font-size: 1.05rem; font-weight: 800; }
@media print {
  .top, .nav, .noprint, #toasts { display: none !important; }
  body, #app, main { background: #fff; padding: 0; max-width: none; display: block; }
  .invoice { box-shadow: none; }
}
.slots > small { grid-column: 1 / -1; }
