/* YAQIZ Inspect AI — shared styles (landing + app). Tokens follow the YAQIZ brand (yaqiz-lms). */
:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --sunk: #eef0ed;
  --ink: #18212b;
  --ink-2: #2b3744;
  --muted: #5b6673;
  --line: #dde1dd;
  --accent: #c98a12;
  --accent-ink: #8a5d06;
  --accent-soft: #fbf1dc;
  --ok: #2f7d4f;
  --ok-soft: #e3f2e8;
  --warn: #a96500;
  --warn-soft: #fdf0d8;
  --bad: #b3352b;
  --bad-soft: #fbe4e1;
  --off: #55606c;
  --off-soft: #e9ecef;
  --scrim: rgba(16, 22, 28, .48);
  --shadow: 0 1px 2px rgba(16, 22, 28, .06), 0 4px 16px rgba(16, 22, 28, .06);
  --r: 12px;
  --r-sm: 9px;
  --f-ui: "Archivo", "Noto Kufi Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --tap: 48px;
  --nav-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not(.force-light) {
    --bg: #12171d; --surface: #1a2129; --sunk: #151b21; --ink: #e7eae6; --ink-2: #cfd5d0; --muted: #9ba5b0;
    --line: #2b343e; --accent: #e2a63b; --accent-ink: #f0c26e; --accent-soft: #2d2514;
    --ok: #5cc184; --ok-soft: #173023; --warn: #e6a547; --warn-soft: #33270f; --bad: #f07a6e; --bad-soft: #3a1d1a;
    --off: #a3adb8; --off-soft: #252d36; --scrim: rgba(0, 0, 0, .6);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-ui);
  font-size: 16px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
html[lang="ar"] body { line-height: 1.75; }
img { max-width: 100%; display: block; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.num, .mono { font-family: var(--f-num); direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* bilingual inline spans: show only the active language */
html[lang="ar"] [lang="en"].l, html[lang="en"] [lang="ar"].l { display: none; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; }
.mark { width: 34px; height: 34px; flex: none; }
.btn { white-space: nowrap; }
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: .01em; white-space: nowrap; }
.brand-name small { display: block; font-size: .72rem; font-weight: 500; color: var(--muted); letter-spacing: .04em; line-height: 1.2; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: var(--ink-2); }
.btn-accent { background: var(--accent); color: #1b1305; border-color: var(--accent); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--sunk); }
.btn-lg { min-height: 56px; font-size: 1.05rem; padding: 0 22px; }
.btn-xl { min-height: 72px; font-size: 1.2rem; padding: 0 26px; border-radius: var(--r); }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: .9rem; }
.icon-btn { min-width: var(--tap); padding: 0 10px; }

/* ---------- chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: .82rem; font-weight: 600; background: var(--off-soft); color: var(--off); white-space: nowrap; line-height: 1.6;
}
.chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.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-off { background: var(--off-soft); color: var(--off); }
.chip.plain::before { display: none; }
.badge-overdue {
  display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 6px; font-size: .78rem; font-weight: 700;
  background: var(--bad); color: #fff; letter-spacing: .02em; white-space: nowrap;
}
.badge-soon { background: var(--warn-soft); color: var(--warn); }

/* ---------- alerts ---------- */
.alert { border-radius: var(--r-sm); padding: 12px 14px; border: 1px solid; margin: 12px 0; }
.alert p { margin: 0; }
.alert .sub { font-size: .88rem; opacity: .85; margin-top: 2px; }
.alert code { display: block; margin-top: 6px; font-family: var(--f-num); font-size: .8rem; opacity: .75; word-break: break-word; }
.alert .btn { margin-top: 10px; }
.alert-bad { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 35%, transparent); color: var(--bad); }
.alert-warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.alert-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.alert-info { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--accent-ink); }

/* =================================================================== APP */
.app-header {
  position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.app-header .bar { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 60px; }
.app-header .spacer { flex: 1; }
.top-nav { display: none; gap: 4px; margin-inline-start: 16px; }
.top-nav a { text-decoration: none; padding: 8px 14px; border-radius: var(--r-sm); font-weight: 600; color: var(--muted); }
.top-nav a.active { color: var(--ink); background: var(--sunk); }
.lang-btn { font-weight: 700; min-width: 52px; }

.demo-strip { background: var(--accent-soft); color: var(--accent-ink); text-align: center; font-size: .85rem; padding: 6px 12px; font-weight: 600; }
.net-strip { background: var(--bad); color: #fff; text-align: center; font-size: .88rem; padding: 6px 12px; font-weight: 600; }

main#view { max-width: 1120px; margin: 0 auto; padding: 16px 14px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); }

.bottom-nav {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: 1fr 1.2fr 1fr;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: .78rem; font-weight: 600;
}
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a.active { color: var(--ink); }
.bottom-nav a.cta span.ic {
  width: 52px; height: 52px; border-radius: 16px; background: var(--ink); color: var(--bg);
  display: grid; place-items: center; margin-top: -22px; box-shadow: var(--shadow); border: 3px solid var(--surface);
}
.bottom-nav a.cta.active span.ic { background: var(--accent); color: #1b1305; }

@media (min-width: 900px) {
  .top-nav { display: flex; }
  .bottom-nav { display: none; }
  main#view { padding: 24px 20px 48px; }
}

/* ---------- layout pieces ---------- */
.page-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.page-title h1 { font-size: 1.45rem; margin: 0; line-height: 1.3; }
.page-title .spacer { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h2 { font-size: 1.1rem; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.step-n { width: 28px; height: 28px; border-radius: 8px; background: var(--ink); color: var(--bg); display: inline-grid; place-items: center; font-size: .9rem; font-family: var(--f-num); flex: none; }
.section-h { font-size: 1rem; margin: 22px 0 10px; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty svg { width: 40px; height: 40px; margin: 0 auto 8px; opacity: .6; }

/* dashboard */
.cta-row { margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stats .stat:last-child:nth-child(odd) { grid-column: span 2; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } .stats .stat:last-child:nth-child(odd) { grid-column: auto; } }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; text-decoration: none;
  display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); min-height: 92px; position: relative; overflow: hidden;
}
.stat::before { content: ""; position: absolute; inset-inline-start: 0; top: 0; bottom: 0; width: 4px; background: var(--line); }
.stat .v { font-family: var(--f-num); font-size: 1.85rem; font-weight: 500; line-height: 1.15; }
.stat .k { font-size: .86rem; color: var(--muted); font-weight: 600; }
.stat.ok::before { background: var(--ok); } .stat.ok .v { color: var(--ok); }
.stat.warn::before { background: var(--warn); } .stat.warn .v { color: var(--warn); }
.stat.bad::before { background: var(--bad); } .stat.bad .v { color: var(--bad); }
.stat.acc::before { background: var(--accent); }
.skel { background: linear-gradient(90deg, var(--sunk), var(--line), var(--sunk)); background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: 6px; color: transparent !important; }
@keyframes sk { to { background-position: -200% 0; } }

/* list rows (due soon, register cards) */
.list { display: flex; flex-direction: column; gap: 10px; }
.row-card {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; min-height: 64px; box-shadow: var(--shadow);
}
.row-card:active { background: var(--sunk); }
.row-card .t { font-weight: 700; font-family: var(--f-num); direction: ltr; unicode-bidi: isolate; }
.row-card .s { color: var(--muted); font-size: .88rem; grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; }
.row-card .end { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.row-card.is-overdue { border-inline-start: 4px solid var(--bad); }

/* register */
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.search { position: relative; }
.search svg { position: absolute; inset-inline-start: 14px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.search input[type="search"] { padding-inline-start: 44px; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.filters::-webkit-scrollbar { display: none; }
.fchip {
  flex: none; min-height: 42px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: .9rem; cursor: pointer; color: var(--muted); white-space: nowrap;
}
.fchip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.fchip.overdue[aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.count-line { color: var(--muted); font-size: .88rem; margin: 0 0 10px; }
.reg-table { display: none; width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.reg-table th, .reg-table td { padding: 11px 12px; text-align: start; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: middle; }
.reg-table td.num { white-space: nowrap; }
.reg-table th { background: var(--sunk); font-size: .8rem; color: var(--muted); font-weight: 700; letter-spacing: .02em; }
.reg-table tr:last-child td { border-bottom: 0; }
.reg-table tbody tr { cursor: pointer; }
.reg-table tbody tr:hover { background: var(--sunk); }
.reg-table tr.is-overdue td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
html[dir="rtl"] .reg-table tr.is-overdue td:first-child { box-shadow: inset -4px 0 0 var(--bad); }
@media (min-width: 900px) {
  .toolbar { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .toolbar .search { flex: 1 1 320px; }
  .reg-cards { display: none; }
  .reg-table { display: table; }
}

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > label, .field > .lbl { font-weight: 600; font-size: .9rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.field .req { color: var(--bad); }
.input, input[type="text"], input[type="search"], input[type="date"], input[type="password"], input[type="tel"], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 14px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); font-size: 16px; /* prevents iOS zoom */
}
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.field.invalid input, .field.invalid .seg { border-color: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.ai-flag { font-size: .74rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.ai-flag.read { background: var(--ok-soft); color: var(--ok); }
.ai-flag.miss { background: var(--warn-soft); color: var(--warn); }
.ai-flag.chk { background: var(--bad-soft); color: var(--bad); }

/* capture */
.capture {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; cursor: pointer;
  min-height: 210px; border: 2px dashed var(--line); border-radius: var(--r); background: var(--sunk); color: var(--muted); padding: 18px; position: relative; overflow: hidden;
}
.capture svg { width: 46px; height: 46px; color: var(--ink); }
.capture strong { color: var(--ink); font-size: 1.1rem; }
.capture.has-photo { padding: 0; border-style: solid; background: #000; min-height: 0; }
.capture.has-photo img { width: 100%; max-height: 420px; object-fit: contain; }
.capture-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.capture-actions .btn { flex: 1 1 160px; }
.photo-meta { font-size: .8rem; color: var(--muted); margin-top: 6px; }

/* AI card */
.ai-card { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-top: 14px; background: var(--surface); }
.ai-card .ai-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--sunk); flex-wrap: wrap; }
.ai-card .ai-head .tag { font-weight: 700; font-size: .85rem; letter-spacing: .02em; }
.ai-card .ai-head .spacer { flex: 1; }
.ai-card.pass { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.ai-card.refer_to_inspector { border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
.ai-card .ai-img { background: #000; }
.ai-card .ai-img img { width: 100%; max-height: 380px; object-fit: contain; }
.ai-body { padding: 12px 14px; }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 8px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; overflow-wrap: anywhere; }
.ai-defects { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ai-note { margin: 10px 0 0; font-size: .92rem; color: var(--ink-2); background: var(--sunk); padding: 8px 10px; border-radius: 8px; }
.disclaimer {
  display: flex; gap: 8px; align-items: flex-start; font-size: .82rem; color: var(--accent-ink); background: var(--accent-soft);
  padding: 9px 12px; border-radius: 8px; margin-top: 12px; font-weight: 600;
}
.disclaimer svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.analyzing { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: var(--r); background: var(--sunk); margin-top: 14px; font-weight: 600; }
.spinner { width: 24px; height: 24px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* defect chips (toggle) */
.dchips { display: flex; flex-wrap: wrap; gap: 8px; }
.dchip {
  min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: .9rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.dchip[aria-pressed="true"] { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.dchip[aria-pressed="true"]::before { content: "✓"; font-weight: 800; }
.dchip .ai-dot { font-size: .68rem; font-weight: 800; background: var(--accent-soft); color: var(--accent-ink); padding: 0 6px; border-radius: 6px; }

/* segmented decision */
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; border-radius: var(--r); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  min-height: 64px; border: 2px solid var(--line); border-radius: var(--r); display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 700; cursor: pointer; background: var(--surface); text-align: center; padding: 6px; gap: 2px; font-size: .98rem;
}
.seg label small { font-weight: 500; font-size: .74rem; color: var(--muted); }
.seg input:focus-visible + label { outline: 3px solid var(--accent); outline-offset: 2px; }
.seg input[value="pass"]:checked + label { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.seg input[value="fail"]:checked + label { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.seg input[value="refer_to_inspector"]:checked + label { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.check-confirm { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: var(--r-sm); background: var(--sunk); cursor: pointer; font-weight: 600; font-size: .92rem; }
.check-confirm input { width: 24px; height: 24px; flex: none; accent-color: var(--ink); margin: 2px 0 0; }
.save-bar {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); z-index: 5; margin-top: 14px;
  background: color-mix(in srgb, var(--bg) 85%, transparent); padding: 8px 0; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
@media (min-width: 900px) { .save-bar { bottom: 8px; } }
.err-list { margin: 8px 0 0; padding-inline-start: 20px; }

.success { text-align: center; padding: 28px 16px; }
.success .big-ic { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 10px; background: var(--ok-soft); color: var(--ok); }
.success .big-ic svg { width: 36px; height: 36px; }
.success h2 { justify-content: center; font-size: 1.3rem; }
.success .actions { display: grid; gap: 10px; margin-top: 16px; max-width: 420px; margin-inline: auto; }

/* item history */
.item-head .tagline { font-family: var(--f-num); font-size: 1.5rem; font-weight: 500; direction: ltr; unicode-bidi: isolate; }
.item-head .chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 12px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; inset-inline-start: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding-inline-start: 42px; margin-bottom: 14px; }
.timeline .dot { position: absolute; inset-inline-start: 6px; top: 14px; width: 20px; height: 20px; border-radius: 50%; border: 4px solid var(--surface); background: var(--off); box-shadow: 0 0 0 1px var(--line); }
.timeline .dot.ok { background: var(--ok); } .timeline .dot.bad { background: var(--bad); } .timeline .dot.warn { background: var(--warn); }
.tl-card { display: grid; grid-template-columns: 1fr 76px; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow); }
.tl-card .thumb { width: 76px; height: 76px; border-radius: 8px; object-fit: cover; background: var(--sunk); }
.tl-card .meta { color: var(--muted); font-size: .86rem; }
.tl-card .acts { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- PIN gate ---------- */
.gate { position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.gate-box { width: 100%; max-width: 380px; text-align: center; }
.gate-box .mark { width: 64px; height: 64px; margin: 0 auto 10px; }
.gate-box h1 { margin: 0 0 4px; font-size: 1.4rem; }
.gate-box p { margin: 0 0 18px; color: var(--muted); }
.pin-input { text-align: center; font-family: var(--f-num); font-size: 1.6rem !important; letter-spacing: .4em; min-height: 64px !important; direction: ltr; }
.gate-box .btn { margin-top: 12px; }
.gate-box .lang-btn { margin-top: 18px; }
.gate-consent { display: flex; align-items: flex-start; gap: 10px; margin: 18px 0 4px; text-align: start; font-size: .9rem; color: var(--muted); cursor: pointer; line-height: 1.4; }
.gate-consent input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--accent, currentColor); }
.gate-privacy { display: inline-block; font-size: .8rem; color: var(--muted); text-decoration: underline; }
.gate-or { display: flex; align-items: center; gap: 12px; margin: 18px 0 12px; color: var(--muted); font-size: .85rem; }
.gate-or::before, .gate-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.gsi-btn { display: flex; justify-content: center; min-height: 44px; color-scheme: light; }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 120; inset-inline: 12px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (min-width: 900px) { .toasts { bottom: 20px; } }
.toast { pointer-events: auto; max-width: 520px; width: 100%; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: var(--r-sm); box-shadow: var(--shadow); font-weight: 600; animation: tin .2s ease-out; }
.toast .sub { display: block; font-weight: 500; opacity: .75; font-size: .85rem; }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ================================================================ REPORT */
.report-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.report-actions .spacer { flex: 1; }
.sheet {
  background: #fff; color: #18212b; max-width: 210mm; margin: 0 auto; padding: 14mm 13mm; border-radius: 4px;
  box-shadow: 0 2px 18px rgba(0, 0, 0, .12); font-size: 10.5pt; line-height: 1.45; --line: #d4d9d4;
}
.sheet .r-head { display: flex; align-items: center; gap: 12px; border-bottom: 3px solid #18212b; padding-bottom: 10px; }
.sheet .r-head .mark { width: 46px; height: 46px; }
.sheet .r-head .ttl { flex: 1; }
.sheet .r-head .ttl b { display: block; font-size: 14pt; }
.sheet .r-head .ttl span { display: block; font-size: 10pt; color: #5b6673; }
.sheet .r-head .meta { text-align: end; font-size: 9pt; color: #5b6673; }
.sheet .r-head .meta .num { color: #18212b; font-weight: 600; }
.sheet .accent-rule { height: 3px; background: #c98a12; width: 64px; margin-top: -3px; }
.r-result { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 8px; margin: 12px 0; border: 2px solid; }
.r-result .big { font-size: 15pt; font-weight: 800; }
.r-result.ok { background: #e3f2e8; border-color: #2f7d4f; color: #2f7d4f; }
.r-result.bad { background: #fbe4e1; border-color: #b3352b; color: #b3352b; }
.r-result.warn { background: #fdf0d8; border-color: #a96500; color: #a96500; }
.r-result.off { background: #e9ecef; border-color: #55606c; color: #55606c; }
.r-result .due { text-align: end; font-size: 9.5pt; color: #18212b; }
.r-sec { margin: 10px 0; break-inside: avoid; page-break-inside: avoid; }
.r-sec h3 { font-size: 10pt; margin: 0 0 6px; padding-bottom: 3px; border-bottom: 1px solid #d4d9d4; text-transform: none; letter-spacing: .02em; }
.r-table { width: 100%; border-collapse: collapse; }
.r-table th, .r-table td { border: 1px solid #d4d9d4; padding: 5px 8px; text-align: start; vertical-align: top; font-size: 9.5pt; }
.r-table th { background: #f4f5f3; width: 24%; font-weight: 600; color: #3a4552; }
.bl-lbl { display: block; line-height: 1.25; }
.bl-lbl .s { display: block; font-weight: 500; font-size: 8pt; color: #6b7682; }
.r-list { margin: 0; padding-inline-start: 18px; }
.r-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.r-photos figure { margin: 0; border: 1px solid #d4d9d4; border-radius: 6px; overflow: hidden; break-inside: avoid; }
.r-photos img { width: 100%; height: 68mm; object-fit: contain; background: #f4f5f3; }
.r-photos figcaption { font-size: 8.5pt; padding: 4px 8px; color: #5b6673; border-top: 1px solid #d4d9d4; }
.r-photos .nophoto { height: 68mm; display: grid; place-items: center; color: #9aa3ad; background: #f4f5f3; font-size: 9pt; }
.r-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 14px; break-inside: avoid; }
.r-sign .box { border: 1px solid #d4d9d4; border-radius: 6px; padding: 8px 10px; }
.r-sign .box b { display: block; font-size: 9.5pt; margin-bottom: 6px; }
.r-sign .ln { display: flex; gap: 8px; align-items: flex-end; font-size: 8.5pt; color: #5b6673; margin-top: 12px; }
.r-sign .ln span.l { flex: 1; border-bottom: 1px solid #18212b; min-height: 18px; color: #18212b; font-size: 9.5pt; padding: 0 4px; }
.r-disc { margin-top: 12px; padding: 8px 10px; border: 1px dashed #c98a12; background: #fbf1dc; color: #6b4705; font-size: 8.8pt; border-radius: 6px; font-weight: 600; break-inside: avoid; }
.r-foot { margin-top: 8px; display: flex; justify-content: space-between; font-size: 8pt; color: #8a939c; gap: 10px; }
.r-chip { display: inline-block; padding: 0 7px; border-radius: 4px; background: #fbe4e1; color: #b3352b; font-size: 8.5pt; font-weight: 600; margin: 1px 2px; }

@media print {
  @page { size: A4; margin: 8mm 10mm; }
  :root { color-scheme: light; }
  html, body { background: #fff !important; }
  .app-header, .bottom-nav, .toasts, .demo-strip, .net-strip, .no-print, .gate { display: none !important; }
  main#view { padding: 0 !important; max-width: none !important; }
  .sheet { box-shadow: none; padding: 0; max-width: none; border-radius: 0; font-size: 10pt; }
  .r-photos img, .r-photos .nophoto { height: 44mm; }
  .r-foot { margin-top: 4px; }
  .sheet .r-head .mark { width: 38px; height: 38px; }
  .sheet { font-size: 9.5pt; line-height: 1.35; }
  .r-sec { margin: 7px 0; }
  .r-result { margin: 8px 0; padding: 7px 12px; }
  .r-table th, .r-table td { padding: 3px 7px; }
  .r-sign { margin-top: 8px; }
  .r-sign .ln { margin-top: 8px; }
  .r-disc { margin-top: 8px; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  a { text-decoration: none; }
}

/* ============================================================== LANDING */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.site-header .bar { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.site-header .spacer { flex: 1; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.l-hero { padding: 40px 0 28px; }
.eyebrow { display: inline-flex; gap: 8px; align-items: center; font-size: .82rem; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; letter-spacing: .03em; }
.l-hero h1 { font-size: clamp(1.9rem, 5.5vw, 3rem); line-height: 1.2; margin: 14px 0 12px; letter-spacing: -.01em; }
html[lang="ar"] .l-hero h1 { letter-spacing: 0; line-height: 1.4; }
.l-hero h1 em { font-style: normal; color: var(--accent); }
.l-hero .lede { font-size: 1.1rem; color: var(--ink-2); max-width: 62ch; margin: 0 0 22px; }
.l-hero .ctas { display: flex; gap: 10px; flex-wrap: wrap; }
.l-sec { padding: 26px 0; }
.l-sec h2 { font-size: 1.45rem; margin: 0 0 6px; display: flex; align-items: center; gap: 10px; }
.l-sec h2::before { content: ""; width: 6px; height: 26px; border-radius: 3px; background: var(--accent); }
.l-sec .intro { color: var(--muted); margin: 0 0 16px; max-width: 70ch; }
.mv { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .mv { grid-template-columns: 1fr 1fr; } }
.mv .card { margin: 0; }
.mv .card h3 { margin: 0 0 6px; font-size: 1.15rem; display: flex; align-items: center; gap: 10px; }
.mv .card h3 svg { width: 26px; height: 26px; color: var(--accent); }
.mv .card p { margin: 0; color: var(--ink-2); }
.goals { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; grid-template-columns: 1fr; counter-reset: g; }
@media (min-width: 760px) { .goals { grid-template-columns: 1fr 1fr; } }
.goals li { counter-increment: g; display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.goals li::before { content: counter(g, decimal-leading-zero); font-family: var(--f-num); font-weight: 500; width: 40px; height: 40px; border-radius: 10px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-size: .9rem; }
.goals b { display: block; margin-bottom: 2px; }
.goals span { color: var(--muted); font-size: .94rem; }
.how { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .how { grid-template-columns: repeat(4, 1fr); } }
.how li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; position: relative; }
.how .ic { width: 44px; height: 44px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; margin-bottom: 10px; }
.how .ic svg { width: 24px; height: 24px; }
.how b { display: block; margin-bottom: 4px; }
.how span { color: var(--muted); font-size: .93rem; }
.how .n { position: absolute; inset-inline-end: 14px; top: 12px; font-family: var(--f-num); color: var(--line); font-size: 1.6rem; font-weight: 500; }
.l-cta { background: var(--ink); color: var(--bg); border-radius: 16px; padding: 24px; display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between; margin: 20px 0; }
.l-cta h3 { margin: 0; font-size: 1.25rem; }
.l-cta p { margin: 4px 0 0; opacity: .8; }
.site-footer { border-top: 1px solid var(--line); padding: 20px 0 32px; color: var(--muted); font-size: .88rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }

/* ============================================================== v2: QR · clients · billing · renewals */
.bottom-nav { grid-template-columns: 1fr 1.2fr 1fr 1fr; }
.stats-3 { grid-template-columns: repeat(3, 1fr); margin-bottom: 14px; }
.stats-3 .stat .v { font-size: 1.35rem; }
@media (max-width: 520px) { .stats-3 { grid-template-columns: 1fr 1fr; } .stats-3 .stat:first-child { grid-column: span 2; } }

/* QR card (item page) */
.qr-card { display: grid; grid-template-columns: 148px 1fr; gap: 16px; align-items: start; }
.qr-box { background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px; }
.qr-box svg, .r-qr svg, .lbl-qr svg { width: 100%; height: auto; display: block; }
.qr-txt h2 { margin-bottom: 6px; }
.qr-txt p { margin: 0 0 8px; font-size: .9rem; }
.qr-url { display: block; background: var(--sunk); border-radius: 8px; padding: 8px 10px; font-size: .78rem; word-break: break-all; margin: 6px 0 10px; text-align: start; }
@media (max-width: 520px) { .qr-card { grid-template-columns: 1fr; } .qr-box { width: 170px; margin: 0 auto; } }

/* QR on the A4 report */
.r-result { position: relative; }
.r-qr { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 22mm; flex: none; font-size: 6.5pt; line-height: 1.15; text-align: center; color: #3a4552; }
.r-qr svg { width: 20mm; }

/* Renewals card (dashboard) */
.renew { padding: 12px 14px; margin-bottom: 0; }
.renew.has-overdue { border-inline-start: 4px solid var(--bad); }
.renew-h { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.renew-h .spacer { flex: 1; }
.renew-h a:not(.btn) { text-decoration: none; }
.renew-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rtag { display: inline-flex; flex-direction: column; text-decoration: none; background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 3px 9px; font-size: .82rem; font-weight: 600; line-height: 1.3; }
.rtag small { font-weight: 500; font-size: .72rem; opacity: .85; }
.rtag.od { background: var(--bad-soft); color: var(--bad); }

/* Clients & billing */
.cl-card .unbilled { color: var(--accent-ink); font-weight: 600; }
.bill-tools { display: flex; gap: 6px; margin-bottom: 6px; }
.bill-lines { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.bill-line { display: grid; grid-template-columns: 26px 92px minmax(80px, 1fr) minmax(0, 1.2fr) auto 92px; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: .9rem; cursor: pointer; }
.bill-line:last-child { border-bottom: 0; }
.bill-line input { width: 20px; height: 20px; accent-color: var(--ink); }
.bill-line .fee { text-align: end; font-weight: 600; }
.bill-line .fee small { color: var(--muted); margin-inline-start: 2px; }
.bill-line .bl-type { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 620px) {
  .bill-line { grid-template-columns: 26px 1fr auto; row-gap: 2px; }
  .bill-line > :nth-child(2) { grid-column: 2; grid-row: 2; color: var(--muted); font-size: .8rem; }
  .bill-line > :nth-child(3) { grid-column: 2; grid-row: 1; }
  .bill-line .bl-type, .bill-line > :nth-child(5) { display: none; }
  .bill-line .fee { grid-column: 3; grid-row: 1 / 3; }
  .bill-line input { grid-row: 1 / 3; }
}
.bill-tot { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: flex-end; align-items: baseline; padding: 12px 4px 0; color: var(--muted); font-size: .9rem; }
.bill-tot b { color: var(--ink); }
.bill-tot .grand { font-size: 1.05rem; color: var(--ink); }
.pay-edit summary { cursor: pointer; font-weight: 600; }
.pay-edit textarea { width: 100%; margin-top: 10px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; background: var(--surface); font-family: var(--f-num); font-size: .85rem; }

/* Statement sheet */
.stmt .st-lines th, .stmt .st-lines td { text-align: start; }
.stmt .st-lines .amt { text-align: end; white-space: nowrap; }
.stmt .st-lines tfoot td { border-top: 1px solid #c9ced3; font-weight: 600; }
.stmt .st-lines tfoot tr.grand td { font-size: 11.5pt; border-top: 2px solid #18212b; background: #fbf1dc; }
.stmt .pay-text { white-space: pre-wrap; margin: 0; font-family: "IBM Plex Mono", monospace; font-size: 8.5pt; }

/* QR label sheet: A4, 3 × 8 labels of 63 × 34 mm */
.labels-sheet { display: grid; grid-template-columns: repeat(3, 63mm); grid-auto-rows: 34mm; gap: 0 2mm; justify-content: center; background: #fff; color: #18212b; padding: 6mm 0; border-radius: var(--r); box-shadow: var(--shadow); overflow-x: auto; }
.lbl { display: grid; grid-template-columns: 27mm 1fr; gap: 2mm; align-items: center; padding: 2mm 2.5mm; border: 0.2mm dashed #c4c9ce; break-inside: avoid; page-break-inside: avoid; overflow: hidden; font-family: "Archivo", "Noto Kufi Arabic", sans-serif; }
.lbl-qr svg { width: 27mm; height: 27mm; }
.lbl-t { display: flex; flex-direction: column; gap: .4mm; min-width: 0; font-size: 6.5pt; line-height: 1.2; }
.lbl-t b.num { font-size: 10pt; overflow-wrap: anywhere; }
.lbl-t .lbl-brand { font-weight: 800; color: #8a5d06; font-size: 6.5pt; letter-spacing: .04em; }
.lbl-t .lbl-due b { font-size: 7.5pt; }
.lbl-t small { color: #5b6673; font-size: 5.8pt; }

/* Public pages (verify / portal) */
.pub-main { max-width: 720px; margin: 0 auto; padding: 16px 16px 8px; }
.pub-foot { max-width: 720px; margin: 0 auto; padding: 0 16px 28px; }
.verdict { border-radius: var(--r); padding: 22px 18px; text-align: center; color: #fff; margin-bottom: 14px; box-shadow: var(--shadow); }
.verdict .v-main { font-size: clamp(2rem, 9vw, 3rem); font-weight: 800; letter-spacing: .03em; line-height: 1.15; }
html[lang="ar"] .verdict .v-main { letter-spacing: 0; }
.verdict .v-alt { font-size: 1.05rem; font-weight: 700; opacity: .9; }
.verdict .v-sub { margin-top: 6px; font-size: .95rem; opacity: .95; }
.verdict-ok { background: #2f7d4f; }
.verdict-warn { background: #a96500; }
.verdict-bad { background: #b3352b; }
.pub-tag { display: flex; flex-direction: column; margin-bottom: 12px; }
.pub-tag b { font-size: 1.7rem; line-height: 1.2; }
.kv dt .alt { display: block; font-size: .72rem; opacity: .8; }
.pub-note { color: var(--muted); font-size: .8rem; margin: 12px 0 0; }
.pub-cta { display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--ink); color: var(--bg); border-radius: var(--r); padding: 16px; margin-top: 18px; }
.pub-cta small { display: block; opacity: .75; font-size: .82rem; }
.pub-cta .btn svg { width: 20px; height: 20px; }
.pub-legal { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 14px; }
.pub .demo-strip { display: block; }
.landing-verify { display: flex; gap: 10px; align-items: center; margin-top: 16px; color: var(--muted); font-size: .92rem; }
.landing-verify svg { width: 22px; height: 22px; flex: none; color: var(--accent); }

@media print {
  .labels-sheet { box-shadow: none; border-radius: 0; padding: 0; overflow: visible; }
  .lbl { border-color: #e2e5e8; }
  .pub-foot .pub-cta, .pub .site-header .lang-btn { display: none !important; }
  .stmt .st-lines tfoot tr.grand td { font-size: 10.5pt; }
}
.pub-cta .btn { white-space: normal; flex-wrap: wrap; max-width: 100%; height: auto; padding-block: 10px; justify-content: center; }
.stmt .r-table td.num { white-space: nowrap; }
.card h2 > svg { width: 22px; height: 22px; flex: none; color: var(--accent); }
