/*
 * IMARQ — bilingual design system, built for an installed mobile app.
 *
 * No framework: the registry is unreachable on this host. Layout uses logical
 * properties throughout so the same stylesheet serves Arabic (RTL) and English (LTR)
 * without a mirrored copy — direction is switched by <html dir> alone.
 */

:root {
  --bg: #f2f5f8;
  --surface: #ffffff;
  --surface-2: #f7fafc;
  --ink: #10202f;
  --muted: #5f7183;
  --faint: #8a9bab;
  --line: #dde5ec;
  --line-strong: #c4d1dd;

  --brand: #0b5d8f;
  --brand-ink: #08496f;
  --brand-soft: #e6f1f9;
  --brand-hover: #0d74b3;

  --ok: #12734b;
  --ok-soft: #e2f5ec;
  --warn: #9a6b00;
  --warn-soft: #fdf2dc;
  --bad: #b3123c;
  --bad-soft: #fde8ee;
  --info: #3a4f8a;
  --info-soft: #e9edf9;

  --r: 10px;
  --r-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 32, 47, .06), 0 4px 14px rgba(16, 32, 47, .06);
  --shadow-lg: 0 10px 40px rgba(16, 32, 47, .18);
  --nav-h: 62px;
  /* iOS notch and home indicator; zero on every other platform. */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  /* A finger needs 44pt on iOS and 48dp on Android; 46 satisfies both. */
  --tap: 46px;
  --font: "Segoe UI", "Tahoma", "Noto Naskh Arabic", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* Grey flash on tap looks broken in an installed app. */
  -webkit-tap-highlight-color: transparent;
  /* Stops the whole page rubber-banding behind the installed shell. */
  overscroll-behavior-y: none;
}

/* Removes the 300 ms click delay without disabling pinch-zoom on content. */
button, a, .chip, .step, .ritem, .tick, label { touch-action: manipulation; }

/* Chrome is not selectable text; form values and report data still are. */
.sidebar, .bottomnav, .topbar, .stepper { -webkit-user-select: none; user-select: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.3; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ------------------------------------------------------------------- layout */

#app { min-height: 100%; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 254px;
  flex: 0 0 254px;
  background: #0e2233;
  color: #dbe7f1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  padding: calc(18px + var(--safe-top)) 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .brand b { font-size: 21px; color: #fff; letter-spacing: .5px; display: block; }
.sidebar .brand span { font-size: 11.5px; color: #7d99b1; }

.sidebar nav { padding: 10px 8px; flex: 1; overflow-y: auto; }
.sidebar nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: none;
  border: 0;
  color: #b9cddd;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: start;
  font-size: 14.5px;
  margin-bottom: 2px;
}
.sidebar nav button:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar nav button.on { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar nav button .ico { font-size: 17px; width: 22px; text-align: center; }
.sidebar nav button .count {
  margin-inline-start: auto;
  background: rgba(255, 255, 255, .15);
  border-radius: 20px;
  padding: 1px 8px;
  font-size: 12px;
}
.sidebar nav button.on .count { background: rgba(0, 0, 0, .25); }

/* Who is signed in — at the top, under the brand. */
.sidebar .profile {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 16px; border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar .avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 42px; object-fit: cover;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 15px;
  border: 2px solid rgba(255, 255, 255, .18);
}
.sidebar .pinfo { min-width: 0; line-height: 1.3; }
.sidebar .pinfo b, .sidebar .pinfo span, .sidebar .pinfo small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .pinfo b { color: #fff; font-size: 14px; }
.sidebar .pinfo span { color: #9db4c8; font-size: 12px; }
.sidebar .pinfo small { color: #6f8ba3; font-size: 11px; }

/* The primary action, set apart from the navigation it sits above. */
.sidebar nav button.primary {
  background: var(--brand); color: #fff; font-weight: 600;
  margin-bottom: 8px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
.sidebar nav button.primary:hover { filter: brightness(1.1); }
.sidebar nav button.primary.on { outline: 2px solid rgba(255, 255, 255, .35); }

/* Footer: the language switch and sign-out side by side. */
.sidebar .who .row { display: flex; gap: 8px; }
.sidebar .who .row > * { flex: 1; margin-top: 0; }
.sidebar .lang-mini {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: rgba(255, 255, 255, .09); border: 0; color: #dbe7f1;
  padding: 7px 10px; border-radius: var(--r-sm); cursor: pointer; font-size: 13px;
}
.sidebar .lang-mini:hover { background: rgba(255, 255, 255, .16); color: #fff; }

.sidebar .who {
  padding: 12px 16px calc(12px + var(--safe-bottom));
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 13px;
}
.sidebar .who b { display: block; color: #fff; }
.sidebar .who span { color: #7d99b1; font-size: 11.5px; }
.sidebar .who button {
  margin-top: 8px;
  width: 100%;
  background: rgba(255, 255, 255, .09);
  border: 0;
  color: #dbe7f1;
  padding: 7px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.sidebar .who button:hover { background: rgba(255, 90, 90, .3); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: calc(14px + var(--safe-top)) calc(24px + var(--safe-right)) 14px calc(24px + var(--safe-left));
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 19px; }
.topbar .sub { color: var(--muted); font-size: 13px; }
.topbar .spacer { margin-inline-start: auto; }

.content { padding: 22px 24px 60px; flex: 1; }
.content.narrow { max-width: 1040px; }

/* --------------------------------------------------------------- components */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.card > header {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card > header h2 { font-size: 15.5px; }
.card > header .spacer { margin-inline-start: auto; }
.card .body { padding: 16px; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* KPI ---------------------------------------------------------------------- */

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 15px 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: '';
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 4px;
  background: var(--brand);
}
.kpi.ok::before { background: var(--ok); }
.kpi.warn::before { background: var(--warn); }
.kpi.bad::before { background: var(--bad); }
.kpi .lab { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.kpi .num { font-size: 30px; font-weight: 700; line-height: 1.15; margin-top: 4px; }
.kpi .hint { font-size: 12px; color: var(--faint); }

/* buttons ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 15px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background .12s, border-color .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { filter: brightness(1.12); }
.btn.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.bad:hover { filter: brightness(1.12); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.btn { min-height: var(--tap); }
.btn.sm { min-height: 36px; }
.btn.block { width: 100%; }

/* pills / badges ------------------------------------------------------------ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.pill.DRAFT { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.VERIFIED { background: var(--brand-soft); color: var(--brand); }
.pill.UPDATED { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.pill.SUBMITTED { background: var(--warn-soft); color: var(--warn); }
.pill.APPROVED { background: var(--ok-soft); color: var(--ok); }
.pill.REJECTED, .pill.NOT_READY { background: var(--bad-soft); color: var(--bad); }
.pill.PASS { background: var(--ok-soft); color: var(--ok); }
.pill.FAIL { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.plain { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 6px 13px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--muted);
}
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

/* tables ------------------------------------------------------------------- */

.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: start;
  padding: 9px 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
table.data td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr.clickable { cursor: pointer; }
table.data .mono { font-family: Consolas, "Courier New", monospace; font-weight: 600; font-size: 13px; }
table.data .nowrap { white-space: nowrap; }

/* forms -------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 2px; }
.field.span2 { grid-column: span 2; }
.field > label { font-size: 13px; font-weight: 600; color: var(--ink); }
.field > label .en { font-weight: 400; color: var(--faint); font-size: 11.5px; }
.field > label .req { color: var(--bad); }
.field .hint { font-size: 11.5px; color: var(--faint); }
.field .err { font-size: 12px; color: var(--bad); }

.input, select.input, textarea.input {
  width: 100%;
  /* Never below 16px: iOS Safari zooms the viewport on focus otherwise, and the
     technician then has to pinch back out after every field. */
  font-size: 16px;
  min-height: var(--tap);
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.input:disabled, .input[readonly] { background: var(--surface-2); color: var(--muted); }
textarea.input { min-height: 78px; resize: vertical; }
.input.bad { border-color: var(--bad); }

.withunit { position: relative; }
.withunit .unit {
  position: absolute;
  inset-inline-end: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--faint);
  pointer-events: none;
}
.withunit .input { padding-inline-end: 52px; }

.computed {
  background: var(--brand-soft);
  border: 1px dashed var(--brand);
  border-radius: var(--r-sm);
  padding: 9px 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}
.computed .u { font-size: 11.5px; font-weight: 400; color: var(--muted); }
.computed.empty { background: var(--surface-2); border-color: var(--line-strong); color: var(--faint); font-weight: 400; }

fieldset.sec {
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 0;
  margin: 0 0 16px;
  background: var(--surface);
}
fieldset.sec > legend {
  padding: 4px 12px;
  margin-inline-start: 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  border-radius: 20px;
}
fieldset.sec .fields { padding: 14px 16px 16px; display: grid; gap: 13px; grid-template-columns: repeat(3, minmax(0, 1fr)); }

/* stage stepper ------------------------------------------------------------ */

.stepper {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding: 4px 0 2px;
}
.step {
  flex: 1 1 0;
  min-width: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  position: relative;
  cursor: pointer;
  padding-top: 2px;
}
.step .line {
  position: absolute;
  top: 15px;
  inset-inline-end: 50%;
  width: 100%;
  height: 2px;
  background: var(--line-strong);
  z-index: 0;
}
.step.done .line, .step.active .line { background: var(--ok); }
.step .dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  background: var(--surface);
  border: 2px solid var(--line-strong);
  color: var(--faint);
  position: relative;
  z-index: 1;
}
.step.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.active .dot { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.step.failed .dot { background: var(--bad); border-color: var(--bad); color: #fff; }
.step .nm { font-size: 11px; text-align: center; line-height: 1.25; color: var(--muted); }
.step.done .nm, .step.active .nm { color: var(--ink); font-weight: 600; }
.step .cnt { font-size: 10px; color: var(--faint); font-family: Consolas, monospace; }
.step:hover .dot { border-color: var(--brand); }

.nextup {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--r-sm);
  background: var(--brand-soft);
  border: 1px solid var(--brand);
  font-size: 13.5px;
}
.nextup b { color: var(--brand); }
.nextup .spacer { margin-inline-start: auto; }

.qrbox {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.qrbox svg { border-radius: 4px; flex: 0 0 auto; }
.qrbox .t { font-size: 12px; color: var(--muted); line-height: 1.5; }
.qrbox .t b { display: block; color: var(--ink); font-size: 13px; }

/* misc --------------------------------------------------------------------- */

.empty { text-align: center; padding: 46px 20px; color: var(--faint); }
.empty .big { font-size: 40px; display: block; margin-bottom: 8px; }

.bar { height: 8px; background: var(--surface-2); border-radius: 20px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 20px; }
.bar > i.ok { background: var(--ok); }
.bar > i.bad { background: var(--bad); }

.breadcrumb { font-size: 13px; color: var(--muted); display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.breadcrumb a { cursor: pointer; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 11px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); margin-top: 6px; flex: 0 0 9px; }
.timeline .dot.APPROVED { background: var(--ok); }
.timeline .dot.REJECTED, .timeline .dot.NOT_READY { background: var(--bad); }
.timeline .dot.SUBMITTED { background: var(--warn); }
.timeline .dot.VERIFIED { background: var(--brand); }
.timeline .when { margin-inline-start: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }

/* toast + modal ------------------------------------------------------------ */

#toasts { position: fixed; inset-block-start: 16px; inset-inline-end: 16px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #10202f;
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  max-width: 380px;
  animation: pop .18s ease-out;
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
@keyframes pop { from { opacity: 0; transform: translateY(-8px); } }

.modalbg {
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 33, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: auto;
}
.modal header { padding: 15px 18px; border-bottom: 1px solid var(--line); }
.modal .body { padding: 18px; display: flex; flex-direction: column; gap: 13px; }
.modal footer { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: flex-start; }

/* login -------------------------------------------------------------------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(150deg, #0e2233 0%, #0b5d8f 100%);
}
.login .box { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(410px, 100%); padding: 30px 28px; }
.login .logo { text-align: center; margin-bottom: 22px; }
.login .logo b { font-size: 34px; color: var(--brand); letter-spacing: 1px; display: block; }
.login .logo span { color: var(--muted); font-size: 13px; }
.login .demo { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; font-size: 12.5px; color: var(--muted); }
.login .demo code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* charts ------------------------------------------------------------------- */

.chart { width: 100%; height: auto; overflow: visible; }
/* A donut is read at a glance, not by the pixel: a fixed size that only shrinks on a
   narrow screen, whatever the card's width. The bar chart keeps the full width above. */
.chart.donut { width: 220px; max-width: 100%; height: auto; flex: 0 0 auto; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 11px; }
.chart .val { fill: var(--ink); font-weight: 700; font-size: 12px; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-inline-end: 5px; }

/* ------------------------------------------------------- technician (mobile) */

.tech { padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 20px); }

.tech .hero {
  background: linear-gradient(140deg, #0e2233, #0b5d8f);
  color: #fff;
  /* Fills the notch area with brand colour instead of leaving a white strip. */
  padding: calc(20px + var(--safe-top)) calc(18px + var(--safe-right)) 24px calc(18px + var(--safe-left));
}
.tech .hero .hi { font-size: 13px; color: #a8c6dd; }
.tech .hero b { font-size: 22px; display: block; }
.tech .hero .meta { font-size: 12.5px; color: #a8c6dd; margin-top: 3px; }

.tech .quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 14px; margin-top: -18px; }
.tech .quick .q {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 6px;
  text-align: center;
  box-shadow: var(--shadow);
}
.tech .quick .q b { display: block; font-size: 20px; }
.tech .quick .q span { font-size: 11px; color: var(--muted); }

.tech .sect { padding: 18px 14px 0; }
.tech .sect > h3 { font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.tech .sect > h3 .spacer { margin-inline-start: auto; }

.formgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.formgrid button {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 12px;
  text-align: start;
  cursor: pointer;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 92px;
}
.formgrid button:hover { border-color: var(--brand); }
.formgrid button .ico { font-size: 22px; }
.formgrid button .nm { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.formgrid button .cd { font-size: 10.5px; color: var(--faint); font-family: Consolas, monospace; }

.rlist { display: flex; flex-direction: column; gap: 9px; }
.ritem {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.ritem:hover { border-color: var(--brand); }
.ritem .top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ritem .top .no { font-family: Consolas, monospace; font-weight: 700; font-size: 13px; }
.ritem .top .spacer { margin-inline-start: auto; }
.ritem .nm { font-size: 14px; font-weight: 600; }
.ritem .meta { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 10px; flex-wrap: wrap; }

.bottomnav {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  /* Grows by the home-indicator inset so the bar is never half-swallowed. */
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex;
  z-index: 50;
  box-shadow: 0 -2px 12px rgba(16, 32, 47, .07);
}
.bottomnav button {
  flex: 1;
  min-height: var(--tap);
  background: none;
  border: 0;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  position: relative;
}
.bottomnav button .ico { font-size: 19px; }
.bottomnav button.on { color: var(--brand); font-weight: 700; }
.bottomnav button .badge {
  position: absolute;
  top: 6px;
  inset-inline-end: 50%;
  transform: translateX(50%) translateX(16px);
  background: var(--bad);
  color: #fff;
  border-radius: 20px;
  font-size: 10px;
  padding: 0 5px;
  min-width: 16px;
}

.sticky-actions {
  position: sticky;
  inset-block-end: calc(var(--nav-h) + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding: 11px 14px;
  display: flex;
  gap: 9px;
  margin: 16px -14px 0;
}
.sticky-actions .btn { flex: 1; min-height: var(--tap); }

/* ------------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  fieldset.sec .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 100; transition: transform .2s; }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  html[dir="ltr"] .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none !important; }
  .content { padding: 16px 14px 50px; }
  .topbar { padding: 12px 14px; }
}

@media (max-width: 640px) {
  .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); }
  fieldset.sec .fields { grid-template-columns: minmax(0, 1fr); }
  .field.span2 { grid-column: span 1; }
  .formgrid { grid-template-columns: repeat(2, 1fr); }
  .modal { max-height: 94vh; }
}

@media print {
  .bottomnav, .sidebar, .topbar, .sticky-actions { display: none !important; }
}


/* ------------------------------------------------- installed app / touch */

/*
 * Hover styles fire and then stick on touch, leaving buttons looking pressed.
 * Scope every hover rule that matters to devices that actually have a pointer.
 */
@media (hover: none) {
  .btn:hover, .chip:hover, .ritem:hover, .formgrid button:hover,
  .toc a:hover, .step:hover .dot { background: inherit; border-color: inherit; }
  .btn:active, .chip:active, .ritem:active, .formgrid button:active { transform: scale(.985); }
}

/* Lists and dialogs scroll with momentum and do not drag the page behind them. */
.tablewrap, .modal, .sidebar nav, .stepper {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* A standalone window has no browser chrome, so the app owns the whole surface. */
@media (display-mode: standalone) {
  body { overscroll-behavior-y: contain; }
  /* Pull-to-refresh would reload and lose an unsaved form. */
  .tech { min-height: 100vh; }
}

/* Offline indicator, shown when a response came from the service-worker cache. */
.offline-bar {
  position: fixed;
  inset-inline: 0;
  inset-block-start: 0;
  z-index: 200;
  background: var(--warn);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  text-align: center;
  padding: calc(5px + var(--safe-top)) 10px 5px;
}

/* Install prompt — a quiet card, never a modal that blocks the work. */
.install-card {
  position: fixed;
  inset-inline: 12px;
  inset-block-end: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.install-card b { font-size: 14.5px; }
.install-card p { margin: 0; font-size: 13px; color: var(--muted); }
.install-card .row { gap: 8px; }
.install-card .btn { flex: 1; }

/* The language switch sits in both shells. */
.langswitch {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  overflow: hidden;
  background: var(--surface);
}
.langswitch button {
  border: 0;
  background: none;
  padding: 5px 13px;
  font-size: 12.5px;
  cursor: pointer;
  color: var(--muted);
  min-height: 32px;
}
.langswitch button.on { background: var(--brand); color: #fff; font-weight: 600; }

/* Print never carries the app chrome. */
@media print {
  .offline-bar, .install-card, .langswitch { display: none !important; }
}

/* ------------------------------------------------------------- evidence */

.evidence h3 { margin: 0 0 10px; font-size: 15px; }

.ev-photos {
  display: grid;
  /* auto-fill rather than a fixed count: three across on a tablet, two on a phone,
     without a media query per breakpoint. */
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
}

.ev-tile {
  position: relative;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-2, #f3f6f9);
}
.ev-tile img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.ev-cap, .ev-geo { padding: 3px 6px; font-size: 11px; color: var(--muted); }
.ev-geo a { color: inherit; text-decoration: none; }

.ev-del {
  position: absolute;
  inset-block-start: 4px;
  inset-inline-end: 4px;
  width: 26px; height: 26px;
  border: 0; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff;
  font-size: 13px; line-height: 1; cursor: pointer;
}

.ev-actions { margin-top: 10px; }

.ev-sigs {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.ev-sig {
  margin: 0; padding: 6px;
  border: 1px solid var(--line); border-radius: 8px;
  text-align: center; background: #fff;
}
.ev-sig.clickable { cursor: pointer; }
.ev-sig img { display: block; width: 100%; height: 54px; object-fit: contain; }
.ev-sigline {
  height: 54px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px;
  border-bottom: 1px dashed var(--line);
}
.ev-role { margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--muted); }

.sig-wrap { text-align: center; }
.sigpad {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  /* Without this the page scrolls under the finger that is signing. */
  touch-action: none;
  max-width: 100%;
}

.gps-field {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 0;
}
.gps-readout { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------- quality registers */

.spec-notice {
  margin: 10px 0 0;
  padding: 8px 11px;
  border-radius: var(--r-sm, 6px);
  background: var(--ok-soft, #eaf6ee);
  font-size: 13px;
  line-height: 1.5;
}
.spec-notice.overridden { background: var(--bad-soft, #fdeceb); }
.spec-notice .ref { color: var(--muted); }

.banner {
  padding: 10px 13px;
  border-radius: var(--r-sm, 6px);
  font-size: 13.5px;
}
.banner.warn { background: var(--bad-soft, #fdeceb); }

label.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
label.check input { width: 16px; height: 16px; }

/* -------------------------------------------------- chain of custody */

.banner.ok { background: var(--ok-soft, #eaf6ee); }
.banner ul { margin: 6px 0 0; padding-inline-start: 20px; }

ol.custody { list-style: none; margin: 0; padding: 0; }
ol.custody li {
  position: relative;
  padding: 0 0 14px 18px;
  padding-inline-start: 18px;
  /* The line that makes it read as a chain rather than a list of rows. */
  border-inline-start: 2px solid var(--line);
}
ol.custody li::before {
  content: '';
  position: absolute;
  inset-inline-start: -6px;
  top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent, #0b5d8f);
}
ol.custody li:last-child { border-inline-start-color: transparent; }
.c-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.c-head time { color: var(--muted); font-size: 12px; }
.c-body { font-size: 13px; color: var(--muted); margin-top: 2px; }
.c-note { font-size: 12.5px; margin-top: 3px; padding: 4px 8px;
          background: var(--surface-2, #f3f6f9); border-radius: 5px; }
.c-hash { font-family: ui-monospace, monospace; font-size: 10.5px;
          color: var(--muted); opacity: .7; margin-top: 3px; }
.pill.sm { font-size: 10.5px; padding: 1px 6px; }
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-item .k { font-size: 11.5px; color: var(--muted); }
.meta-item .v { font-size: 13.5px; }

/* ----------------------------------------------- organisation & licence */

.logo-preview {
  max-height: 60px; max-width: 200px;
  padding: 6px; margin-bottom: 6px;
  border: 1px solid var(--line); border-radius: var(--r-sm, 6px);
  background: #fff; object-fit: contain;
}
.modules { display: flex; flex-wrap: wrap; gap: 6px; }
.meta-item .v.bad { color: var(--bad, #c0392b); font-weight: 600; }
.grid.g2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }


/* The secondary label — the field's name in the reader's other language — was too
   small and too faint to read at a glance. It is the same information, so it gets
   nearly the same weight. */
.field label .en { font-size: 13px; color: var(--ink); opacity: .78; font-weight: 500; margin-inline-start: 6px; }
.field .hint { font-size: 12.5px; color: var(--muted); }

/* ---- Hijri range calendar ---- */
.hcal { position: fixed; z-index: 1000; width: 300px; padding: 12px; font-size: 13.5px;
        background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
        box-shadow: 0 10px 30px rgba(20, 33, 44, .18); }
.hcal .hd { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.hcal .hd b { font-size: 14px; }
.hcal .hd button { background: none; border: 1px solid var(--line); border-radius: 6px; width: 30px; height: 30px;
                   cursor: pointer; color: var(--ink); font-size: 16px; }
.hcal .hint { font-size: 12px; color: var(--muted); margin: 0 0 6px; }
.hcal .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.hcal .dow { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.hcal .d { border: 0; background: none; border-radius: 6px; padding: 7px 0; cursor: pointer; color: var(--ink);
           font-variant-numeric: tabular-nums; }
.hcal .d:hover { background: #e3edf3; }
.hcal .d.today { outline: 1px dashed var(--brand); }
.hcal .d.in { background: rgba(8, 73, 111, .14); border-radius: 0; }
.hcal .d.from, .hcal .d.to { background: var(--brand); color: #fff; }
.hcal .d.from { border-radius: 6px 0 0 6px; }
.hcal .d.to { border-radius: 0 6px 6px 0; }
html[dir='rtl'] .hcal .d.from { border-radius: 0 6px 6px 0; }
html[dir='rtl'] .hcal .d.to { border-radius: 6px 0 0 6px; }
.hcal .d.from.to { border-radius: 6px; }
.hcal .ft { display: flex; gap: 6px; justify-content: flex-end; margin-top: 10px; }
.hcal .ft button { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px;
                   cursor: pointer; color: var(--ink); font-size: 12.5px; }
.hcal .ft button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }