/* Nabbih — single hand-written stylesheet (no framework) to keep the scan
   page tiny on 4G (NFR-02). Logical properties make RTL/LTR symmetric. */
:root {
  --bg: #f6f5f1; --surface: #ffffff; --ink: #1d232b; --muted: #636b75; --line: #e3e1da;
  --brand: #e8590c; --brand-ink: #ffffff; --brand-soft: #fff1e6;
  --ok: #2b8a3e; --ok-soft: #e6f4ea; --warn: #b7791f; --warn-soft: #fdf3e1;
  --bad: #c92a2a; --bad-soft: #fdecec; --info: #1864ab; --info-soft: #e7f1fb;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 20, 20, .05), 0 4px 16px rgba(20, 20, 20, .05);
  --font: "Segoe UI", Tahoma, "Noto Sans Arabic", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b; --surface: #1d2127; --ink: #eceae4; --muted: #9aa1ab; --line: #2d333b;
    --brand: #ff7a2f; --brand-soft: #3a2416; --ok-soft: #173322; --warn-soft: #3a2f16;
    --bad-soft: #3d1c1c; --info-soft: #172a3d;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--font); }
a { color: var(--brand); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .6em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
small, .muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: .92em; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 480px; margin: 0 auto; padding: 0 16px; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--line); }
.top .wrap, .top .narrow { display: flex; align-items: center; gap: 12px; min-height: 56px; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.25rem; color: var(--ink); text-decoration: none; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 1rem; }
.top .spacer { flex: 1; }
.top a.lang { font-size: .9rem; color: var(--muted); text-decoration: none; }
.banner { background: var(--warn-soft); color: var(--warn); font-size: .85rem; text-align: center; padding: 6px 16px; }

main { padding: 24px 0 48px; }

/* cards & layout */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > :last-child { margin-bottom: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

/* forms */
label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; min-height: 46px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, .reason input:focus-visible + span {
  outline: 3px solid color-mix(in srgb, var(--brand) 45%, transparent); outline-offset: 2px;
}
.field { margin-bottom: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { width: 20px; height: 20px; margin-top: 3px; flex: none; accent-color: var(--brand); }
.hint { font-size: .85rem; color: var(--muted); margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 700;
  border: 1px solid transparent; border-radius: 10px; padding: 10px 18px; min-height: 46px; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); text-decoration: none; }
.btn:hover { filter: brightness(1.05); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--bad); }
.btn.sm { min-height: 34px; padding: 4px 12px; font-size: .88rem; font-weight: 600; }
.btn.ok { background: var(--ok); }
form.inline { display: inline; }

/* reason picker (scan page): big touch targets, 3 taps max (NFR-12) */
.reasons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.reason input { position: absolute; opacity: 0; pointer-events: none; }
.reason span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 64px;
  padding: 8px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 600; cursor: pointer; }
.reason input:checked + span { border-color: var(--brand); background: var(--brand-soft); }
.reasons.em .reason input:checked + span { border-color: var(--bad); background: var(--bad-soft); }
.vehicle-id { display: flex; gap: 12px; align-items: center; background: var(--info-soft); border-radius: 12px; padding: 12px 14px; margin-bottom: 18px; }
.vehicle-id .car { font-size: 1.8rem; }
.vehicle-id strong { display: block; font-size: 1.1rem; }
details.emergency { border: 1px solid var(--bad); border-radius: var(--radius); padding: 12px 16px; background: var(--surface); margin-top: 16px; }
details.emergency summary { cursor: pointer; font-weight: 700; color: var(--bad); }
.em-numbers { font-weight: 700; direction: ltr; unicode-bidi: plaintext; }

/* alerts & status */
.alert { border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: .95rem; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.info { background: var(--info-soft); color: var(--info); }
.big-status { text-align: center; padding: 28px 12px; }
.big-status .icon { font-size: 3rem; line-height: 1; }
.big-status h1 { margin-top: 12px; }
.steps { display: flex; justify-content: center; gap: 6px; margin: 12px 0; }
.steps i { width: 44px; height: 6px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--ok); }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: start; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .8rem; font-weight: 600; background: var(--line); color: var(--ink); white-space: nowrap; }
.pill.ok, .pill.active, .pill.delivered, .pill.read, .pill.accepted { background: var(--ok-soft); color: var(--ok); }
.pill.warn, .pill.paused, .pill.queued, .pill.sent, .pill.invited, .pill.pending, .pill.held { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .pill.revoked, .pill.failed, .pill.blocked, .pill.suspended, .pill.declined { background: var(--bad-soft); color: var(--bad); }
.pill.info, .pill.unassigned { background: var(--info-soft); color: var(--info); }

/* dashboards */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 20px; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 3px solid transparent; font-weight: 600; }
.tabs a.on { color: var(--ink); border-color: var(--brand); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat .k { color: var(--muted); font-size: .85rem; }
.stat .v { font-size: 1.7rem; font-weight: 800; line-height: 1.2; margin-top: 4px; }
.stat .tgt { font-size: .8rem; margin-top: 2px; }
.stat .tgt.ok { color: var(--ok); } .stat .tgt.bad { color: var(--bad); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bars span.b { width: 100%; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars small { font-size: .68rem; }
.sticker-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 0; border-top: 1px dashed var(--line); }
.empty { color: var(--muted); text-align: center; padding: 20px; }
.counter { font-size: .8rem; color: var(--muted); text-align: end; }

/* optional photo */
.photo-preview { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.photo-preview img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.photo-preview[hidden] { display: none; }
.photo-ui .alert { margin-top: 10px; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }

/* print sheet */
.sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.sticker { border: 1.5px dashed #999; border-radius: 12px; padding: 12px; text-align: center; background: #fff; color: #111; break-inside: avoid; }
.sticker svg { width: 150px; height: 150px; }
.sticker .s-title { font-weight: 800; font-size: 1.05rem; }
.sticker .s-domain { font-family: ui-monospace, monospace; font-size: .8rem; }
.sticker .s-code { font-family: ui-monospace, monospace; font-weight: 700; letter-spacing: 1px; }
@media print {
  .no-print, .top, .banner { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .sheet { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 400px) { .reasons { grid-template-columns: 1fr 1fr; } .card { padding: 16px; } }
