@font-face { font-family: Inter; src: url(vendor/fonts/Inter_400Regular.ttf) format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: Inter; src: url(vendor/fonts/Inter_500Medium.ttf) format('truetype'); font-weight: 500; font-display: swap; }
@font-face { font-family: Inter; src: url(vendor/fonts/Inter_600SemiBold.ttf) format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: Inter; src: url(vendor/fonts/Inter_700Bold.ttf) format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: Archivo; src: url(vendor/fonts/Archivo_800ExtraBold.ttf) format('truetype'); font-weight: 800; font-display: swap; }
@font-face { font-family: PlexArabic; src: url(vendor/fonts/IBMPlexSansArabic_400Regular.ttf) format('truetype'); font-weight: 100 900; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }

:root {
  --navy:#0A1B36; --navy2:#132B55; --gold:#DDA853; --gold-text:#8A6516; --gold-wash:#FFF4DE;
  --bg:#F4F6FA; --surface:#fff; --surface2:#EEF2F8; --line:#E3E8F0; --line-strong:#C9D1DE;
  --text:#0A1B36; --muted:#667085; --faint:#98A2B3;
  --red:#D92D2D; --red-wash:#FDECEC; --green:#1E6B3A; --green-wash:#E7F5EC; --blue:#2E6BFF;
  --side:#0A1B36; --side2:#132B55; --side-muted:#A9B4C8;
  --lift:0 4px 14px rgba(10,27,54,.06); --mine:#0A1B36; --on-mine:#fff;
  --r:18px; --r-sm:12px;
  --bar:#0A1B36; --pill-on:#0A1B36; --on-pill-on:#fff; --btn-dark:#0A1B36; --btn-dark-line:#0A1B36;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --gold:#E2B45E; --gold-text:#E2B45E; --gold-wash:#2A2212;
  --bg:#060D19; --surface:#0F1A2D; --surface2:#16233A; --line:#1E2C44; --line-strong:#2B3B57;
  --text:#EEF2F8; --muted:#94A3B8; --faint:#64748B;
  --red:#F26B6B; --red-wash:#2C1416; --green:#4CC38A; --green-wash:#0F2A1F; --blue:#6E9BFF;
  --side:#0B1526; --side2:#16233A; --side-muted:#94A3B8;
  --lift:none; --mine:#E2B45E; --on-mine:#0A1B36;
  --bar:#3B5583; --pill-on:#E2B45E; --on-pill-on:#0A1B36; --btn-dark:#16233A; --btn-dark-line:#2B3B57;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gold:#E2B45E; --gold-text:#E2B45E; --gold-wash:#2A2212;
    --bg:#060D19; --surface:#0F1A2D; --surface2:#16233A; --line:#1E2C44; --line-strong:#2B3B57;
    --text:#EEF2F8; --muted:#94A3B8; --faint:#64748B;
    --red:#F26B6B; --red-wash:#2C1416; --green:#4CC38A; --green-wash:#0F2A1F; --blue:#6E9BFF;
    --side:#0B1526; --side2:#16233A; --side-muted:#94A3B8;
    --lift:none; --mine:#E2B45E; --on-mine:#0A1B36;
    --bar:#3B5583; --pill-on:#E2B45E; --on-pill-on:#0A1B36; --btn-dark:#16233A; --btn-dark-line:#2B3B57;
    color-scheme: dark;
  }
}

* { box-sizing:border-box }
html, body { margin:0; background:var(--bg); color:var(--text); font:15px/1.55 Inter, PlexArabic, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing:antialiased }
a { color:var(--blue); text-decoration:none } a:hover { text-decoration:underline }
.shell { display:flex; min-height:100vh }

/* sidebar */
aside { width:248px; flex:none; background:var(--side); color:#fff; display:flex; flex-direction:column; padding:22px 14px; position:sticky; top:0; height:100vh; border-right:1px solid var(--line) }
.brand { font-family:Archivo, Inter, sans-serif; font-weight:800; font-size:24px; letter-spacing:.5px; padding:0 10px 26px; display:flex; align-items:baseline; gap:8px }
.brand span { color:var(--gold); font-family:Inter; font-weight:600; font-size:12px; letter-spacing:0 }
nav { display:flex; flex-direction:column; gap:2px; flex:1; overflow-y:auto }
nav .group { color:var(--side-muted); font-size:12px; font-weight:600; padding:14px 12px 6px; opacity:.8 }
nav button { all:unset; cursor:pointer; display:flex; align-items:center; gap:10px; padding:9px 12px; border-radius:11px; color:var(--side-muted); font-size:14px; font-weight:500 }
nav button svg { width:18px; height:18px; flex:none }
nav button .label { flex:1 }
nav button:hover { background:var(--side2); color:#fff }
nav button[aria-current="page"] { background:var(--side2); color:#fff; box-shadow:inset 3px 0 0 var(--gold) }
nav button:focus-visible, .seg button:focus-visible { outline:2px solid var(--gold); outline-offset:2px }
nav .count { min-width:22px; text-align:center; background:var(--gold); color:#0A1B36; border-radius:999px; padding:0 7px; font-size:12px; font-weight:700 }
.side-foot { border-top:1px solid rgba(255,255,255,.1); padding:14px 6px 0; display:flex; flex-direction:column; gap:10px }
.who { font-size:13px; color:var(--side-muted); display:flex; justify-content:space-between; align-items:center; gap:8px }
.seg { display:flex; background:rgba(255,255,255,.08); border-radius:10px; padding:3px; gap:3px }
.seg button { all:unset; cursor:pointer; flex:1; text-align:center; font-size:12px; font-weight:600; padding:5px 0; border-radius:8px; color:var(--side-muted) }
.seg button[aria-pressed="true"] { background:var(--gold); color:#0A1B36 }
button.link { all:unset; cursor:pointer; color:#fff; font-size:13px; font-weight:600 }
button.link:hover { color:var(--gold) }

main { flex:1; min-width:0; padding:36px 44px 72px }
.wrap { max-width:1240px }
.page-head { display:flex; justify-content:space-between; align-items:flex-end; gap:16px; margin-bottom:24px; flex-wrap:wrap }
h1 { font-family:Archivo, Inter, PlexArabic, sans-serif; font-weight:800; font-size:30px; line-height:1.15; margin:0 0 6px; letter-spacing:-.3px }
h2 { font-size:17px; font-weight:700; margin:28px 0 12px }
h3 { font-size:15px; font-weight:700; margin:0 0 10px }
.lede { color:var(--muted); margin:0; max-width:70ch }
.muted { color:var(--muted) } .faint { color:var(--faint) } .small { font-size:13px } .tiny { font-size:12px } .strong { font-weight:600 }
.back { display:inline-flex; gap:6px; align-items:center; color:var(--muted); font-size:14px; font-weight:500; margin-bottom:14px; cursor:pointer; background:none; border:0; padding:0 }
.back:hover { color:var(--text) }

.card { background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:20px; box-shadow:var(--lift) }
.card + .card { margin-top:12px }
.card.band { background:var(--navy); border-color:var(--navy); color:#fff }
.card.band .muted { color:#A9B4C8 }
.card.attention { border-color:var(--gold); border-width:1.5px }
.card.alarm { border-color:var(--red); border-width:1.5px }
.card-head { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; margin-bottom:6px }
.card-title { font-weight:700; font-size:16px }
.grid { display:grid; gap:16px }
.g2 { grid-template-columns:minmax(0,1.15fr) minmax(0,1fr) } .g3 { grid-template-columns:repeat(3,minmax(0,1fr)) }
.stack { display:flex; flex-direction:column; gap:12px }

.stats { display:grid; grid-template-columns:repeat(auto-fill,minmax(190px,1fr)); gap:12px }
.stat { background:var(--surface); border:1px solid var(--line); border-radius:var(--r); padding:18px 20px; box-shadow:var(--lift) }
.stat b { display:block; font-family:Archivo, Inter, sans-serif; font-weight:800; font-size:26px; letter-spacing:-.4px; line-height:1.2 }
.stat span { color:var(--muted); font-size:13px }
.stat.alert b { color:var(--red) } .stat.alert { border-color:var(--red) }
.stat.feature { background:var(--navy); border-color:var(--navy); color:#fff } .stat.feature span { color:#A9B4C8 } .stat.feature b { color:var(--gold) }
.stat.click { cursor:pointer } .stat.click:hover { border-color:var(--line-strong) }

.chart { display:flex; align-items:flex-end; gap:6px; height:150px; padding-top:10px }
.chart .col { flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; height:100% ; justify-content:flex-end }
.chart .bar { width:100%; background:var(--bar); border-radius:6px 6px 3px 3px; min-height:3px }
.chart .bar.today { background:var(--gold) }
.chart .lbl { font-size:11px; color:var(--faint) }

.row { display:flex; gap:8px; align-items:center; flex-wrap:wrap }
.spread { justify-content:space-between }
.meta { color:var(--muted); font-size:13px; margin:2px 0 10px }
.kv { display:flex; justify-content:space-between; gap:12px; padding:7px 0; font-size:14px }
.kv + .kv { border-top:1px solid var(--line) }
.kv .k { color:var(--muted) } .kv .v { font-weight:600; text-align:right }
.kv.total .v { font-family:Archivo, Inter, sans-serif; font-weight:800; font-size:18px }

button, .btn { font:inherit; font-size:14px; font-weight:600; border-radius:var(--r-sm); border:1.5px solid var(--line-strong); background:transparent; color:var(--text); padding:8px 15px; cursor:pointer; transition:background .12s, transform .12s; white-space:nowrap }
button:hover { background:var(--surface2) }
button:active { transform:scale(.98) }
button:focus-visible { outline:2px solid var(--blue); outline-offset:2px }
button.primary { background:var(--gold); border-color:var(--gold); color:#0A1B36 } button.primary:hover { filter:brightness(.95) }
button.dark { background:var(--btn-dark); border-color:var(--btn-dark-line); color:#fff }
button.danger { color:var(--red) } button.danger:hover { background:var(--red-wash) }
button.ghost { border-color:transparent; color:var(--muted); padding:6px 8px } button.ghost:hover { color:var(--text); background:transparent }
button:disabled { opacity:.45; cursor:default }
input, textarea, select { font:inherit; font-size:14px; border:1.5px solid var(--line); border-radius:var(--r-sm); padding:9px 12px; width:100%; background:var(--surface); color:var(--text) }
input:focus, select:focus, textarea:focus { outline:none; border-color:var(--text) }
label { display:block; font-weight:600; font-size:14px; margin:14px 0 6px }
.help { font-size:13px; color:var(--faint); margin-top:4px }

.filters { display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-bottom:14px }
.pill { border:1.5px solid var(--line); background:var(--surface); border-radius:999px; padding:6px 14px; font-size:13px; font-weight:600; color:var(--text) }
.pill[aria-pressed="true"] { background:var(--pill-on); border-color:var(--pill-on); color:var(--on-pill-on) }
.search { max-width:320px; margin-left:auto }

.table { background:var(--surface); border:1px solid var(--line); border-radius:var(--r); overflow:auto; box-shadow:var(--lift) }
table { width:100%; border-collapse:collapse }
th, td { text-align:left; padding:12px 14px; border-bottom:1px solid var(--line); vertical-align:middle; font-size:14px }
tbody tr:last-child td { border-bottom:0 }
th { color:var(--muted); font-weight:600; font-size:12px; background:var(--surface2); white-space:nowrap }
tr.click { cursor:pointer } tr.click:hover td { background:var(--surface2) }
td.num { font-variant-numeric:tabular-nums; white-space:nowrap }
.cell2 { display:flex; flex-direction:column; gap:1px }
.route { display:flex; flex-direction:column; gap:2px; max-width:260px }
.route .to::before { content:"→ "; color:var(--faint) }

.badge { display:inline-flex; align-items:center; gap:4px; padding:3px 9px; border-radius:8px; font-size:12px; font-weight:700; background:var(--surface2); color:var(--text); white-space:nowrap }
.badge.red { background:var(--red-wash); color:var(--red) } .badge.green { background:var(--green-wash); color:var(--green) } .badge.gold { background:var(--gold-wash); color:var(--gold-text) }
.chips { display:flex; gap:6px; flex-wrap:wrap }
.chip { padding:3px 10px; border-radius:999px; border:1px solid var(--line); font-size:13px; background:var(--surface) }
.chip.add { border-color:var(--green); color:var(--green); background:var(--green-wash) }
.chip.remove { border-color:var(--red-wash); color:var(--red); background:var(--red-wash); text-decoration:line-through }
.stars { color:var(--gold); letter-spacing:1px; white-space:nowrap }
.notice { background:var(--gold-wash); color:var(--gold-text); border-radius:var(--r-sm); padding:12px 14px; margin:8px 0; font-size:14px }
.notice.err { background:var(--red-wash); color:var(--red) }
.empty { text-align:center; padding:48px 20px; color:var(--muted); background:var(--surface); border:1px dashed var(--line-strong); border-radius:var(--r) }
img.id { max-width:100%; max-height:420px; border-radius:12px; border:1px solid var(--line); display:block; margin-top:12px }

.avatar { width:44px; height:44px; border-radius:50%; background:#0A1B36; border:1px solid var(--line-strong); color:#DDA853; display:inline-flex; align-items:center; justify-content:center; font-weight:700; flex:none; font-size:15px }
.avatar.lg { width:64px; height:64px; font-size:22px }
.person { display:flex; gap:12px; align-items:center }
.phone { font-weight:600; font-variant-numeric:tabular-nums }

.timeline { list-style:none; margin:0; padding:0 }
.timeline li { display:grid; grid-template-columns:16px 1fr auto; gap:10px; padding:6px 0; position:relative; font-size:14px }
.timeline li::before { content:""; width:10px; height:10px; border-radius:50%; background:var(--gold); margin-top:6px }
.timeline li:not(:last-child)::after { content:""; position:absolute; left:4px; top:20px; bottom:-6px; width:2px; background:var(--line) }
.timeline .when { color:var(--faint); font-size:12px; white-space:nowrap }

.chat { display:flex; flex-direction:column; gap:8px; max-height:460px; overflow-y:auto; padding:4px 2px }
.msg { max-width:80%; padding:9px 13px; border-radius:16px; font-size:14px; background:var(--surface2) }
.msg.customer { align-self:flex-start; border-bottom-left-radius:5px }
.msg.provider { align-self:flex-end; background:var(--mine); color:var(--on-mine); border-bottom-right-radius:5px }
.msg .by { display:block; font-size:11px; opacity:.7; margin-bottom:2px; font-weight:600 }

.login-wrap { min-height:100vh; display:grid; place-items:center; width:100%; background:#0A1B36; padding:20px }
.login { width:100%; max-width:400px; background:var(--surface); border-radius:24px; padding:34px }
.login .brand { color:var(--text); padding:0 0 18px }
.login button.primary { width:100%; margin-top:16px; padding:12px }
main.bare { padding:0 }

#toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:#0A1B36; color:#fff; padding:12px 18px; border-radius:12px; display:none; max-width:90vw; font-size:14px; box-shadow:0 8px 24px rgba(10,27,54,.25); z-index:10 }
#toast.show { display:block } #toast.err { background:var(--red) }

@media (max-width:1100px) { .g2, .g3 { grid-template-columns:1fr } }
/* ---------- phones and tablets: drawer navigation, full-width forms, scrollable tables ---------- */
.topbar { display:none }
.scrim { display:none }
@media (max-width:900px) {
  .shell { display:block }
  .topbar { display:flex; align-items:center; gap:12px; position:sticky; top:0; z-index:20; background:var(--side); color:#fff;
    padding:calc(8px + env(safe-area-inset-top)) 12px 8px; padding-inline:max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); min-height:56px }
  .topbar[hidden] { display:none !important }
  .menu { all:unset; cursor:pointer; width:44px; height:44px; display:inline-flex; flex-direction:column; justify-content:center; align-items:center; gap:5px; border-radius:12px }
  .menu span { display:block; width:20px; height:2px; background:#fff; border-radius:2px }
  .menu:focus-visible { outline:2px solid var(--gold); outline-offset:2px }
  .top-title { font-weight:700; font-size:16px; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
  .top-count { background:var(--gold); color:#0A1B36; border-radius:999px; padding:3px 10px; font-size:12px; font-weight:700; cursor:pointer; white-space:nowrap }
  aside { position:fixed; inset-block:0; inset-inline-start:0; z-index:30; width:min(300px, 84vw); height:100dvh; transform:translateX(-102%);
    transition:transform .22s ease; padding-top:calc(18px + env(safe-area-inset-top)); padding-bottom:calc(14px + env(safe-area-inset-bottom)); box-shadow:0 0 40px rgba(0,0,0,.35) }
  [dir="rtl"] aside { transform:translateX(102%) }
  body.nav-open aside { transform:none }
  body.nav-open .scrim { display:block; position:fixed; inset:0; background:rgba(6,13,25,.55); z-index:25 }
  body.nav-open { overflow:hidden }
  nav button { box-sizing:border-box; padding:11px 12px; min-height:44px; font-size:15px }
  main { padding:18px 16px 56px; padding-inline:max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)) }
  h1 { font-size:24px }
  .page-head { flex-direction:column; align-items:stretch; margin-bottom:16px }
  .page-head > button, .page-head > .btn { width:100% }
  .search { max-width:none; margin-left:0 }
  .card { padding:16px }
  .stats { grid-template-columns:repeat(2, minmax(0,1fr)) }
  .stat { padding:14px }
  .stat b { font-size:22px }
  button, .btn { min-height:44px; padding:10px 14px }
  .pill { min-height:38px }
  input, textarea, select { font-size:16px; padding:11px 12px }   /* 16px stops phones zooming into fields */
  .filters.scroll { flex-wrap:nowrap; overflow-x:auto; padding-bottom:4px; margin-inline:-16px; padding-inline:16px; scrollbar-width:none }
  .filters.scroll .pill { flex:none }
  .table table { min-width:560px }   /* scroll sideways inside the box, never the whole page */
  .kv { flex-wrap:wrap; gap:2px 12px }
  .kv .v { text-align:end; margin-inline-start:auto; overflow-wrap:anywhere }
  .row > button, .row > .btn { flex:1 1 auto }
  .card-head { flex-wrap:wrap }
  .grid2.tight, .side-by { grid-template-columns:1fr }
  #toast { inset-inline:16px; transform:none; left:16px; bottom:calc(16px + env(safe-area-inset-bottom)); max-width:none }
}
@media (max-width:420px) { .stats { grid-template-columns:1fr } }
@media (prefers-reduced-motion:reduce) { * { transition:none !important } }
.thumbs { display:flex; gap:8px; flex-wrap:wrap; margin:6px 0 }
.thumb { width:84px; height:84px; border-radius:12px; background:var(--surface2); display:inline-flex; align-items:center; justify-content:center; overflow:hidden; font-size:12px; font-weight:600; color:var(--muted); text-decoration:none; border:1px solid var(--line) }
.thumb img { width:100%; height:100%; object-fit:cover }
.msg .thumbs { margin:4px 0 }
/* support messages: the customer on the left, RESQ on the right */
.msg { align-self:flex-start }
.msg.me { align-self:flex-end; background:var(--mine); color:var(--on-mine); border-bottom-right-radius:5px }
.msg .strong { font-weight:600 }
.card textarea { margin-top:10px }
.card label { display:block; margin:10px 0 4px; font-size:13px; font-weight:600 }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size:13px; background:var(--surface2); padding:2px 6px; border-radius:6px; word-break:break-all }
.login img { display:block; margin:12px 0 }
.login form { display:flex; flex-direction:column }
.login form label { margin-top:12px }
.login form .primary { margin-top:16px }
[hidden] { display:none !important }
.login .link { color:var(--text); background:none; border:0; padding:0; font-weight:600; text-decoration:underline; cursor:pointer }
.login .help { margin-top:12px }
.grid2 { display:grid; grid-template-columns:repeat(auto-fit, minmax(280px, 1fr)); gap:16px }
.card select, .card input:not([type=checkbox]) { width:100% }
.card label.row { display:flex; align-items:center; gap:8px; font-weight:500 }
input[type=checkbox] { width:auto !important; margin:0 }
.card label.row { flex-direction:row; justify-content:flex-start }

/* cases, helpers */
a.card.case { display:block; color:inherit; text-decoration:none }
a.card.case:hover { border-color:var(--line-strong); text-decoration:none }
.min0 { min-width:0 }
.clip { overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
.clamp2 { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; margin:6px 0 }
.pre { white-space:pre-wrap; overflow-wrap:anywhere; unicode-bidi:plaintext; margin:6px 0 }
.card-title, td, .meta { overflow-wrap:anywhere; unicode-bidi:plaintext }
.row.end { justify-content:flex-end }
.side-by { display:grid; grid-template-columns:1fr 1fr; gap:16px }
.grid2.tight { grid-template-columns:1fr 1fr; gap:12px }
.checks { display:flex; flex-direction:column; gap:2px }
.checks label.row { margin:6px 0; font-weight:500 }
.timeline li > div { min-width:0 }
.card label.row { flex-wrap:nowrap; align-items:flex-start }
.card label.row input[type=checkbox] { margin-top:4px; flex:none }
@media (max-width:900px) { .side-by, .grid2.tight { grid-template-columns:1fr } }
