/* WECAN shared design system — mobile first, RTL/LTR via logical properties */
:root {
  --ink: #1f2328;
  --ink-2: #4a5159;
  --muted: #7b838c;
  --line: #e6e8eb;
  --bg: #f5f4f2;
  --card: #ffffff;
  --brand: #f26a1b;
  --brand-dark: #d4560f;
  --brand-soft: #fff1e8;
  --ok: #1e8e4e;
  --ok-soft: #e6f5ec;
  --warn: #b7791f;
  --warn-soft: #fdf3dc;
  --bad: #c9372c;
  --bad-soft: #fdeceb;
  --info: #2563a8;
  --info-soft: #e8f0fa;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 28, .06), 0 4px 14px rgba(20, 24, 28, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Arabic", "Noto Kufi Arabic", Tahoma, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
}
html[dir="rtl"] body { line-height: 1.65; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .6em; }
a { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; unicode-bidi: plaintext; }
bdi, .ltr { unicode-bidi: isolate; }
.ltr { direction: ltr; display: inline-block; }

/* ---------- layout ---------- */
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin-inline: auto; background: var(--bg); position: relative; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .5rem;
  padding: .65rem 1rem; background: var(--ink); color: #fff; min-height: 56px;
}
.topbar .brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; text-decoration: none; color: #fff; }
.topbar .brand small { display: block; font-weight: 400; font-size: .7rem; opacity: .7; letter-spacing: .02em; }
.logo { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1.2rem; flex: none; }
.topbar .back { background: none; border: 0; color: #fff; font-size: 1.4rem; padding: .25rem .5rem; cursor: pointer; }
.icon-btn { position: relative; background: rgba(255, 255, 255, .1); border: 0; color: #fff; border-radius: 10px; min-width: 40px; height: 40px; font-size: 1.1rem; cursor: pointer; padding: 0 .6rem; }
.icon-btn:hover { background: rgba(255, 255, 255, .2); }
.badge-dot { position: absolute; top: 3px; inset-inline-end: 3px; background: var(--brand); color: #fff; font-size: .65rem; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }
.main { flex: 1; padding: 1rem 1rem 6rem; }
.nav {
  position: fixed; bottom: 0; inset-inline: 0; max-width: 560px; margin-inline: auto; z-index: 20;
  display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav a { flex: 1; text-align: center; padding: .55rem .25rem .5rem; text-decoration: none; color: var(--muted); font-size: .74rem; position: relative; }
.nav a .ic { display: block; font-size: 1.35rem; line-height: 1.2; filter: grayscale(1); opacity: .75; }
.nav a.on { color: var(--brand-dark); font-weight: 700; }
.nav a.on .ic { filter: none; opacity: 1; }
.ribbon { background: var(--warn-soft); color: var(--warn); font-size: .78rem; text-align: center; padding: .3rem .75rem; border-bottom: 1px solid #f0e2b8; }

/* ---------- components ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: .85rem; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card h3 { margin-bottom: .5rem; }
.stack > * + * { margin-top: .75rem; }
.row { display: flex; align-items: center; gap: .6rem; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tiny { font-size: .75rem; }
.bold { font-weight: 700; }
.center { text-align: center; }
.mt { margin-top: .75rem; } .mt2 { margin-top: 1.25rem; } .mb { margin-bottom: .75rem; }
.hr { border: 0; border-top: 1px solid var(--line); margin: .85rem 0; }
.section-title { font-size: .85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 1.2rem .25rem .5rem; }
html[dir="rtl"] .section-title { text-transform: none; letter-spacing: 0; font-size: .92rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; border: 0; cursor: pointer;
  background: var(--brand); color: #fff; font-weight: 700; padding: .8rem 1.2rem; border-radius: 12px; min-height: 48px;
  text-decoration: none; text-align: center; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn.block { display: flex; width: 100%; }
.btn.secondary { background: var(--ink); }
.btn.secondary:hover { background: #343a42; }
.btn.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn.ghost:hover { background: #f1f1f0; }
.btn.danger { background: var(--bad); }
.btn.ok { background: var(--ok); }
.btn.sm { min-height: 38px; padding: .45rem .85rem; font-size: .9rem; border-radius: 10px; }
.btn[disabled], .btn.loading { opacity: .55; pointer-events: none; }
.btn.loading::after { content: ""; width: 1em; height: 1em; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

label.field { display: block; margin-bottom: .85rem; }
label.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--ink-2); margin-bottom: .3rem; }
label.field > span em { color: var(--bad); font-style: normal; }
.input, select.input, textarea.input {
  width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: .7rem .85rem; min-height: 48px; outline: none;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(242, 106, 27, .15); }
.input.ltr-input { direction: ltr; text-align: start; }
html[dir="rtl"] .input.ltr-input { text-align: right; }
.hint { font-size: .8rem; color: var(--muted); margin-top: .25rem; }
.err { color: var(--bad); font-size: .88rem; margin: .4rem 0; }

.chip { display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 700; background: #eceeef; color: var(--ink-2); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--info-soft); color: var(--info); }
.chip.brand { background: var(--brand-soft); color: var(--brand-dark); }
.chip-btn { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: .35rem .85rem; cursor: pointer; font-size: .88rem; }
.chip-btn.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; }

.tabs { display: flex; gap: .4rem; background: #e9e8e5; padding: .25rem; border-radius: 12px; margin-bottom: .85rem; }
.tabs button { flex: 1; border: 0; background: transparent; padding: .55rem .5rem; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--ink-2); }
.tabs button.on { background: #fff; box-shadow: var(--shadow); color: var(--ink); }

.list { display: flex; flex-direction: column; gap: .6rem; }
.item { display: flex; gap: .75rem; align-items: center; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .85rem 1rem; text-decoration: none; color: inherit; cursor: pointer; border: 0; width: 100%; text-align: start; }
.item .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--brand-soft); display: grid; place-items: center; font-size: 1.4rem; flex: none; }
.item .t { font-weight: 700; }
.item .s { color: var(--muted); font-size: .85rem; }
.item .chev { color: var(--muted); font-size: 1.2rem; }
html[dir="rtl"] .item .chev { transform: scaleX(-1); }

.kv { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; }
.kv span:first-child { color: var(--muted); }
.kv.total { border-top: 1px dashed var(--line); margin-top: .35rem; padding-top: .6rem; font-weight: 800; font-size: 1.05rem; }

.empty { text-align: center; color: var(--muted); padding: 2.2rem 1rem; }
.empty .big { font-size: 2.6rem; margin-bottom: .3rem; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; margin: 2.5rem auto; }

.alert { border-radius: var(--radius-sm); padding: .75rem .9rem; font-size: .92rem; margin-bottom: .75rem; }
.alert.info { background: var(--info-soft); color: #1d4d82; }
.alert.warn { background: var(--warn-soft); color: #7a5412; }
.alert.bad { background: var(--bad-soft); color: #8e241b; }
.alert.ok { background: var(--ok-soft); color: #176b3b; }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding-inline-start: 1.6rem; padding-bottom: .9rem; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: .35rem; top: .35rem; bottom: -.1rem; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; inset-inline-start: 0; top: .3rem; width: .75rem; height: .75rem; border-radius: 50%; background: var(--line); }
.timeline li.done::after { background: var(--ok); }
.timeline li.now::after { background: var(--brand); box-shadow: 0 0 0 4px rgba(242, 106, 27, .2); }
.timeline li.bad::after { background: var(--bad); }
.timeline .tl-t { font-weight: 600; font-size: .95rem; }
.timeline .tl-s { font-size: .8rem; color: var(--muted); }

/* progress */
.steps { display: flex; gap: 4px; margin: .6rem 0 .2rem; }
.steps i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--brand); }
.steps.cancelled i.on { background: var(--bad); }

/* photos */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.photos .ph { aspect-ratio: 1; border-radius: 10px; background: #eceae7 center/cover no-repeat; position: relative; cursor: pointer; overflow: hidden; border: 0; padding: 0; }
.photos .ph .tag { position: absolute; bottom: 4px; inset-inline-start: 4px; background: rgba(0, 0, 0, .65); color: #fff; font-size: .65rem; padding: 1px 6px; border-radius: 6px; }
.photos .ph .x { position: absolute; top: 4px; inset-inline-end: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0, 0, 0, .65); color: #fff; border: 0; cursor: pointer; line-height: 1; }
.photos .add { aspect-ratio: 1; border: 2px dashed #cfd2d6; border-radius: 10px; display: grid; place-items: center; color: var(--muted); cursor: pointer; font-size: .8rem; text-align: center; background: #fff; }
.photos .add b { display: block; font-size: 1.6rem; }

/* chat */
.chat { display: flex; flex-direction: column; gap: .4rem; max-height: 340px; overflow-y: auto; padding: .25rem; }
.msg { max-width: 82%; padding: .5rem .75rem; border-radius: 14px; background: #eef0f2; font-size: .95rem; word-wrap: break-word; white-space: pre-wrap; }
.msg.mine { align-self: flex-end; background: var(--brand-soft); }
.msg .who { font-size: .7rem; color: var(--muted); display: block; }
.msg .when { font-size: .65rem; color: var(--muted); display: block; margin-top: 2px; }
.chat-form { display: flex; gap: .5rem; margin-top: .6rem; }
.chat-form .input { min-height: 44px; }

/* modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(15, 18, 22, .55); z-index: 100; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 20px 20px 0 0; padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet h2 { margin-bottom: .75rem; }
.sheet .actions { display: flex; gap: .6rem; margin-top: 1rem; }
.sheet .actions .btn { flex: 1; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.toast-wrap { position: fixed; top: 70px; inset-inline: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; gap: .5rem; pointer-events: none; padding: 0 1rem; }
.toast { background: var(--ink); color: #fff; padding: .7rem 1rem; border-radius: 12px; box-shadow: var(--shadow); max-width: 440px; font-size: .92rem; animation: up .2s ease-out; }
.toast.bad { background: var(--bad); } .toast.ok { background: var(--ok); }

/* auth */
.hero { background: linear-gradient(160deg, var(--ink) 0%, #343b44 100%); color: #fff; padding: 2rem 1.25rem 2.4rem; border-radius: 0 0 28px 28px; margin: -1rem -1rem 1.25rem; }
.hero h1 { font-size: 1.55rem; margin-bottom: .35rem; }
.hero p { opacity: .8; margin: 0; }
.otp { letter-spacing: .5em; text-align: center; font-size: 1.6rem; direction: ltr; }
.code-box { background: var(--ink); color: #fff; border-radius: var(--radius); padding: .9rem 1rem; text-align: center; }
.code-box b { display: block; font-size: 2.2rem; letter-spacing: .3em; direction: ltr; color: #ffb27d; }
.stars { display: flex; gap: .25rem; justify-content: center; font-size: 2.2rem; }
.stars button { background: none; border: 0; cursor: pointer; color: #cfd2d6; font-size: inherit; padding: 0 .1rem; }
.stars button.on { color: #f5a623; }
.sw { position: relative; display: inline-block; width: 52px; height: 30px; flex: none; }
.sw input { opacity: 0; width: 0; height: 0; }
.sw i { position: absolute; inset: 0; background: #cfd2d6; border-radius: 30px; transition: .2s; cursor: pointer; }
.sw i::before { content: ""; position: absolute; width: 24px; height: 24px; inset-inline-start: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.sw input:checked + i { background: var(--ok); }
.sw input:checked + i::before { inset-inline-start: 25px; }

@media (min-width: 700px) {
  body { background: #e9e8e5; }
  .app { box-shadow: 0 0 40px rgba(0, 0, 0, .08); }
  .sheet { border-radius: 20px; margin-bottom: 4vh; align-self: center; }
  .overlay { align-items: center; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
