:root {
  /* the logo's two blues (sampled from logo.png: the wordmark is #103090, its lighter sweep #2868b8)
     and the flame's orange, used once. Status colours below are semantic and do not follow the brand. */
  --brand: #103090; --brand-600: #2868b8; --brand-050: #eaf0fa; --accent: #e09020;
  --ink: #16213a; --muted: #5b6478; --line: #e3e7ee; --bg: #f5f7fb; --card: #fff;
  /* lightest ink that still clears WCAG AA on both --card (5.0:1) and --bg (4.6:1) */
  --placeholder: #6b7387;
  --ok: #16794c; --ok-bg: #e7f4ec; --warn: #8a5000; --warn-bg: #fbf1e0; --risk: #c02626; --risk-bg: #fbeaea; --na: #6b6b6b; --na-bg: #eef0ef;
  /* tinted borders/fills that pair with the status colours above */
  --risk-line: #f0cccc; --warn-line: #f0d29a; --warn-bg-soft: #fffdf7;
  --field-bg: #f9fafc; --disabled-bg: #f2f4f7;
  --print-line: #ccc; /* --line is too pale to survive a laser printer */
  --radius: 14px; --shadow: 0 1px 3px rgba(16,33,58,.06), 0 4px 16px rgba(16,33,58,.05);
  --tap: 44px; /* WCAG 2.5.5 minimum touch target */
  --hdr: 119px; /* the phone's sticky header: 54px topbar + 65px tab strip. The map and the sticky error read it. */
}
/* the visible label lives in the topbar chrome; each screen still needs a real <h1> */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: 'Cairo', -apple-system, 'Segoe UI', Tahoma, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; -webkit-tap-highlight-color: transparent; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .3em; font-weight: 700; }
.muted { color: var(--muted); } .small { font-size: 13px; } .center { text-align: center; padding: 40px 16px; }
a { color: var(--brand-600); text-decoration: none; }

/* --- layout --- */
.app { min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
/* topbar and tab bar stick as ONE block. Sticking them separately meant the tab bar carried a
   hard-coded offset for the topbar's height — 46px — while the real topbar was 64px on a phone,
   so on every scroll the tabs slid 18px under it and lost the top of their icons. */
.hdr { position: sticky; top: 0; z-index: 20; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 5px 14px; padding-top: calc(5px + env(safe-area-inset-top)); background: var(--card); color: var(--ink); border-bottom: 1px solid var(--line); }
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.brand-chip { display: flex; align-items: center; padding: 5px 0; }
.brand-chip img { height: 20px; width: auto; display: block; }
/* .who is a <button> (it opens the account sheet) and must keep shrinking, so it is styled here
   rather than given .linklike, which would kill the ellipsis. It is the only thing beside the logo:
   the language picker and the logout button live in the sheet now, so a name gets the room. */
.topbar .spacer { flex: 1; } .topbar .who { font-size: 13px; opacity: .95; display: flex; align-items: center; gap: 6px; min-width: 0; background: none; border: 0; color: inherit; font-family: inherit; cursor: pointer; padding: 4px 2px; min-height: var(--tap); }
/* a long name used to push the logout button off-screen (27px of page scroll on a 390px
   phone, on every screen). The name is the only part that may shrink; the rest is chrome. */
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.topbar .tag, .topbar .brand { flex-shrink: 0; }
.topbar .tag { background: var(--brand-050); color: var(--brand); font-weight: 700; padding: 1px 8px; border-radius: 20px; font-size: 11px; }
.langsel .pickpanel { min-width: 150px; }
.login-lang { margin-top: 14px; display: flex; justify-content: center; }
.acct-who { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
/* ponytail: Urdu leans on system naskh/nastaliq fonts + Cairo fallback (no extra webfont). Add Noto Nastaliq Urdu if glyphs look off on target devices. */
html[data-lang="ur"] body { font-family: 'Noto Nastaliq Urdu', 'Jameel Noori Nastaleeq', 'Noto Naskh Arabic', 'Cairo', -apple-system, 'Segoe UI', Tahoma, sans-serif; }
.tabbar { display: flex; background: var(--card); border-bottom: 1px solid var(--line); }
.tab:hover { color: var(--brand-600); }
.tab { flex: 1; border: none; background: none; padding: 11px 6px; color: var(--muted); font-weight: 600; border-bottom: 2.5px solid transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; font-size: 13px; white-space: nowrap; }
.tab .ico { display: flex; } .tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.icon-link { display: inline-flex; align-items: center; gap: 5px; }
.wrap { max-width: 780px; margin: 0 auto; padding: 14px; }
.wrap-wide { max-width: 1100px; }
.wrap-wide .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }

/* --- the desk shell (≥860px): a console with a sidebar and tables, not a phone page stretched
   sideways. App renders .side instead of .hdr at this width, so nothing here fights the tab bar. --- */
@media (min-width: 860px) {
  .app.desk { display: grid; grid-template-columns: 236px minmax(0, 1fr); }
  .side { position: sticky; top: 0; align-self: start; height: 100vh; display: flex; flex-direction: column; gap: 4px; padding: 18px 14px 16px; background: var(--card); color: var(--ink); border-inline-end: 1px solid var(--line); }
  .side-brand { display: flex; padding: 2px 6px 18px; cursor: pointer; }
  .side-brand img { height: 24px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .navi { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 8px 12px; border: 0; border-radius: 10px; background: none; color: var(--muted); font-weight: 600; font-size: 14px; text-align: start; cursor: pointer; transition: background .12s, color .12s; }
  .navi .ico { display: flex; }
  .navi:hover { background: var(--brand-050); color: var(--brand); }
  .navi.active { background: var(--brand); color: #fff; }
  .navi:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }
  .side-who { margin-top: auto; display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); text-align: start; cursor: pointer; }
  .side-who:hover { background: var(--brand-050); border-color: var(--brand-050); }
  .side-who .scard-avatar { background: var(--accent); color: #fff; } /* the logo's flame, used once */
  .side-who-t { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
  .side-who .small { color: var(--muted); }
  .desk .wrap, .desk .wrap-wide { max-width: 1400px; margin: 0; padding: 26px 32px 48px; }
  .desk .wrap-doc { max-width: 940px; } /* a station's file reads like a document; 1400px lines do not */
  .page-h { font-size: 22px; font-weight: 800; margin: 0 0 16px; }
  /* the three counters become filter pills in a row — they are toggles, not a KPI billboard */
  .desk .statrow { display: flex; gap: 8px; margin-bottom: 14px; }
  .desk .stat { flex-direction: row; gap: 8px; padding: 8px 14px; border-radius: 999px; }
  .desk .stat b { font-size: 16px; } .desk .stat span { font-size: 13px; }
  .mapview { height: 72vh; }
  .desk .wrap-map { max-width: none; padding: 0; }
  .mapx-desk { display: grid; grid-template-columns: 460px minmax(0, 1fr); height: 100vh; }
  .mapx-list { overflow-y: auto; height: 100vh; padding: 22px 22px 40px; border-inline-end: 1px solid var(--line); }
  .mapx-desk .mapx-stage, .mapx-desk .mapx-map { height: 100vh; min-height: 0; }
  .mapx-desk .mapx-count { padding: 6px 0 10px; }
}

/* --- desk tables: the stations, the board, the regions and the tasks (see DataTable) --- */
.tcard { padding: 0; overflow: hidden; }
.dtable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.dtable th { text-align: start; font-size: 12px; font-weight: 700; color: var(--muted); padding: 11px 14px; background: var(--field-bg); border-bottom: 1px solid var(--line); white-space: nowrap; }
.dtable td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: middle; font-size: 14px; }
.dtable tbody tr:first-child td { border-top: 0; }
.dtable tbody tr[role="button"] { cursor: pointer; }
.dtable tbody tr[role="button"]:hover, .dtable tbody tr:focus-visible { background: var(--brand-050); outline: none; }
.dtable .num { white-space: nowrap; width: 1%; }
.dtable .code { font-weight: 700; direction: ltr; display: inline-block; }
.tname { font-weight: 700; }
.warn-txt { color: var(--warn); }

/* --- generic --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-050); }
input:disabled { background: var(--disabled-bg); color: var(--muted); }

/* --- Picker: one dropdown for the whole app, drawn in the page instead of the OS wheel --- */
.pick { position: relative; }
.pickb { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: var(--tap);
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; text-align: start; }
.pickb.on, .pickb:focus-visible { border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-050); outline: none; }
.pickb:disabled { background: var(--disabled-bg); color: var(--muted); cursor: default; }
.pickval { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pickph { color: var(--placeholder); font-weight: 400; }
.pickcar { flex-shrink: 0; font-size: 11px; color: var(--muted); }
/* colour is set here, not left to inherit: the panel can hang off chrome that sets its own
   colour (the topbar is white-on-green), and every option <button> inherits it — white on white. */
.pickpanel { position: absolute; z-index: 40; inset-inline: 0; top: calc(100% + 4px); padding: 6px;
  background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.picksearch { margin-bottom: 6px; padding: 9px 10px; }
.picklist { display: flex; flex-direction: column; max-height: 244px; overflow-y: auto; }
.pickopt { width: 100%; min-height: 40px; padding: 9px 10px; border: 0; border-radius: 8px; background: none; text-align: start; cursor: pointer; }
.pickopt:hover, .pickopt:focus-visible { background: var(--bg); outline: none; }
.pickopt.on { background: var(--brand-050); color: var(--brand); font-weight: 700; }
/* a multi-select list reserves the tick slot on every row, so ticking one shifts nothing and the
   ellipsis that trims a long company name never reaches the mark */
.picklist[aria-multiselectable] .pickopt::before { content: '✓'; margin-inline-end: 6px; visibility: hidden; }
.picklist[aria-multiselectable] .pickopt.on::before { visibility: visible; }
.pickempty { padding: 12px 10px; color: var(--muted); font-size: 13px; text-align: center; }
.pickadd { width: 100%; min-height: var(--tap); margin-top: 6px; padding: 10px; border: 1px dashed var(--brand-600);
  border-radius: 8px; background: none; color: var(--brand-600); font-weight: 700; cursor: pointer; }
.pickadd:disabled { opacity: .6; cursor: default; }
.cat-none { color: var(--warn); }
.pickerr { padding: 6px 4px 2px; color: var(--risk); font-size: 12.5px; font-weight: 600; }
/* اسم الشركة + its مسؤول travel together and only for امتياز — box them so that reads at a glance */
.subform { margin-top: 10px; padding: 4px 12px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--field-bg); }
/* auto-fit collapses to one column on its own — no breakpoint to keep in sync with the fields */
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.row { display: flex; gap: 8px; align-items: center; } .rowbetween { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.err { background: var(--risk-bg); color: var(--risk); border: 1px solid var(--risk-line); padding: 10px 12px; border-radius: 10px; margin: 8px 0; font-weight: 600; font-size: 14px; }
.err.sticky { position: sticky; top: var(--hdr); z-index: 15; }
.back { background: none; border: none; color: var(--brand-600); font-weight: 600; padding: 6px 0; margin-bottom: 8px; cursor: pointer; }
.section-h { margin: 6px 0 10px; } .noprint .btn { margin-inline-start: 8px; }

/* --- buttons --- */
/* every tappable control clears --tap; inline-flex so a short label still fills the height
   instead of leaving a 27px hit box under a 44px-looking button */
.btn, .linklike, .chip, .segb, .back, .tab, .archtoggle { min-height: var(--tap); }
.btn, .linklike, .chip, .back { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.btn { border: 1px solid var(--line); background: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 700; cursor: pointer; transition: .12s; }
.btn:active { transform: translateY(1px); } .btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:disabled { opacity: .6; } .btn.danger { color: var(--risk); border-color: var(--risk-line); } .btn.small { padding: 6px 12px; font-size: 13px; }
.btn.block { width: 100%; } .btn.big { padding: 13px 18px; font-size: 16px; } .btn.primary.block.big { margin-top: 14px; }
.linklike { background: none; border: none; color: var(--brand-600); font-weight: 600; cursor: pointer; padding: 6px 8px; }
/* chips inside a card are labels, not controls, and the 20px photo-delete already extends
   its own hit box via ::before — neither should be stretched to 44px */
.chip.small, .archived-chip { min-height: 0; }

/* --- login --- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, var(--brand-050), var(--bg)); }
.login { width: 100%; max-width: 360px; text-align: center; }
.login-logo { width: auto; height: 38px; max-width: 100%; margin-bottom: 10px; } .login h1 { color: var(--brand); } .login label { text-align: start; } .login .block { margin-top: 16px; }

/* --- station list --- */
.statrow { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; box-shadow: var(--shadow); }
.stat b { font-size: 22px; } .stat span { font-size: 12px; color: var(--muted); } .stat.sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-050); }
.stat.warn b { color: var(--warn); } .stat.risk b { color: var(--risk); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; } .filters .search { flex: 1; min-width: 150px; }
.filters .pickb { min-height: 0; padding: 9px 12px; }
/* a filter panel is as wide as its longest name (a company name is long), not as wide as its button */
.filters .pickpanel { inset-inline-end: auto; width: max-content; min-width: 100%; max-width: min(340px, 90vw); }
.filters .pickopt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cards { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.scard { display: flex; align-items: center; gap: 12px; text-align: start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; cursor: pointer; box-shadow: var(--shadow); }
.scard-avatar { flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 15px; background: var(--na-bg); color: var(--na); }
.scard-avatar.band-pass { background: var(--ok-bg); color: var(--ok); } .scard-avatar.band-warning { background: var(--warn-bg); color: var(--warn); } .scard-avatar.band-at_risk { background: var(--risk-bg); color: var(--risk); }
.scard-main { flex: 1; min-width: 0; } .scard-name { font-weight: 700; font-size: 16px; } .scard-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; } .scard-sub .code { font-weight: 700; color: var(--ink); direction: ltr; display: inline-block; }
/* the operator contact — plain text, never a tel: link: the whole card is already a button */
.scard-contact { font-size: 12px; color: var(--muted); margin-top: 2px; }
.scard-when { font-size: 12.5px; color: var(--muted); margin-top: 3px; } .scard-when.over { color: var(--warn); font-weight: 600; }
.scard-score { display: flex; align-items: center; gap: 6px; }
.pill { display: inline-block; padding: 4px 11px; border-radius: 20px; font-weight: 700; font-size: 14px; background: var(--na-bg); color: var(--na); }
.pill.ok { background: var(--ok-bg); color: var(--ok); } .pill.warn { background: var(--warn-bg); color: var(--warn); } .pill.risk { background: var(--risk-bg); color: var(--risk); } .pill.na { background: var(--na-bg); color: var(--na); }

/* --- station detail --- */
.detail-head h2 { color: var(--brand); } .hrow { display: flex; justify-content: space-between; align-items: center; text-align: start; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; }
.hdate { font-weight: 700; }

/* --- forms: the quality check + the file editor --- */
.catblock { margin-bottom: 16px; } .cat-h { color: var(--brand); font-size: 16px; padding-bottom: 6px; border-bottom: 2px solid var(--brand-050); margin-bottom: 10px; }
.crow { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; margin-bottom: 9px; box-shadow: var(--shadow); }
.crow.need { border-color: var(--warn-line); background: var(--warn-bg-soft); }
.crow-text { font-weight: 600; margin-bottom: 9px; line-height: 1.5; } .camtag { display: inline-flex; align-items: center; margin-inline-start: 5px; color: var(--muted); vertical-align: middle; }
/* Translation of the checklist content, under the Arabic البند. Secondary on purpose: the Arabic
   is what the supervisor certifies against, this is only there so a non-Arabic reader knows what
   the item IS. dir="auto" goes on THIS line only, never on the Arabic one — البند 78's text is
   literally "Automation", so dir="auto" up there would flip that one row LTR in the Arabic form
   while every other row stayed RTL. The Arabic keeps inheriting the page, exactly as before. */
.tx { display: block; font-size: 13px; font-weight: 500; color: var(--muted); line-height: 1.4; text-align: start; }
.crow-text + .tx { margin-top: -5px; margin-bottom: 9px; }
.cat-h .tx { font-size: 12.5px; margin-top: 1px; }
.seg { display: flex; gap: 6px; } .segb { flex: 1; padding: 9px 4px; border: 1.5px solid var(--line); background: #fff; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; }
.segb.on { color: #fff; } .segb.on.ok { background: var(--ok); border-color: var(--ok); } .segb.on.bad { background: var(--risk); border-color: var(--risk); } .segb.on.na { background: var(--na); border-color: var(--na); }
.segb.on:not(.ok):not(.bad):not(.na) { background: var(--brand); border-color: var(--brand); }
.lic .grid2 { margin-top: 8px; } .photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }
.thumb { position: relative; width: 62px; height: 62px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); } .thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button { position: absolute; top: 2px; inset-inline-end: 2px; width: 20px; height: 20px; border-radius: 50%; border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }
.thumb button::before { content: ''; position: absolute; inset: -12px; }
.addphoto { height: 62px; padding: 0 14px; border: 1.5px dashed var(--line); background: var(--field-bg); border-radius: 8px; color: var(--muted); font-weight: 700; cursor: pointer; }
.addphoto.need { border-color: var(--warn); color: var(--warn); }

/* --- tasks --- */
/* Two filter rows were taking ~40% of a 390px screen before a single task showed, with one chip
   stranded alone on a second line. Only the horizontal padding shrinks — min-height stays var(--tap),
   because the 44px hit box is a standard this app set deliberately, not slack to reclaim. */
.taskfilter { margin: 0 0 8px; gap: 5px; }
.taskfilter .chip { padding: 5px 10px; font-size: 13.5px; }
/* min-width:0 so a long Arabic title wraps inside the row instead of shoving the pills off it */
.taskmain { min-width: 0; text-align: start; }
.taskpills { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.taskdesc { white-space: pre-wrap; margin: 10px 0 0; }
/* every placeholder, not just this one — browser defaults vary and some fail AA too */
::placeholder { color: var(--placeholder); opacity: 1; }
.submitbar { position: sticky; bottom: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--card); border-top: 1px solid var(--line); padding: 12px 14px; margin: 8px -14px -14px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }

.risk-txt { color: var(--risk); }

/* --- region stats (admin) --- */
/* Two export buttons plus the heading need ~527px; a phone gives ~360. Wrap instead of squashing
   the Arabic labels — only this header, because .rowbetween must keep not wrapping everywhere else. */
.stats-head { flex-wrap: wrap; }
.region-card { display: flex; flex-direction: column; gap: 12px; }
.region-stat-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.region-stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.region-stat b { font-size: 18px; } .region-stat span { font-size: 11.5px; color: var(--muted); }

/* --- quality report --- */
.rep-modes { margin-bottom: 12px; }

/* --- station admin --- */
.pickmap { height: 220px; min-height: 0; margin-top: 6px; }
.linkrow { gap: 8px; align-items: stretch; } .linkrow input { flex: 1; min-width: 0; }
.archtoggle { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
.archived-chip { background: var(--na-bg); color: var(--na); border-color: transparent; margin-inline-end: 6px; }
.archived-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--na-bg); color: var(--muted); font-size: 13px; line-height: 1.5; }

/* --- map --- */
.mapview { width: 100%; height: 68vh; min-height: 380px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.mapview-empty { display: grid; place-items: center; background: var(--card); padding: 24px; }
/* Airbnb's split (see StationsMap). On a phone the map fills the screen under the header, the
   filters float on it and the cards ride a snap strip along its foot; on a desk the cards are a
   scrolling column beside a map that stays put. The pin is a pill carrying the file's %. */
.wrap-map { padding: 0; }
.mapx-stage { position: relative; }
.mapx-map { width: 100%; height: calc(100vh - var(--hdr)); height: calc(100dvh - var(--hdr)); min-height: 380px; background: var(--na-bg); }
.mapx-map.mapview-empty { border-radius: 0; }
.mapx-phone .mapx-tools { position: absolute; top: 10px; inset-inline: 10px; z-index: 5; margin: 0; flex-wrap: nowrap; }
.mapx-phone .mapx-tools .search { min-width: 0; }
.filterbtn { white-space: nowrap; font-weight: 700; } /* the station list's phone shell uses it too */
.filterbtn.on { border-color: var(--brand-600); color: var(--brand); }
.filtersheet { display: grid; gap: 10px; }
/* inside the phone sheet the list opens in flow, so the sheet grows and scrolls as one instead of clipping a floating panel */
.filtersheet .pickpanel { position: static; width: auto; max-width: none; margin-top: 4px; } .filtersheet .picklist { max-height: 50vh; }
.mapx-phone .mapx-tools .search, .mapx-phone .mapx-tools .filterbtn, .mapx-phone .mapx-tools .pickb { background: #fff; border-color: transparent; box-shadow: 0 2px 10px rgba(20,40,30,.16); min-height: var(--tap); }
.mapx-phone .mapx-tools .filterbtn.on { background: var(--brand); border-color: var(--brand); color: #fff; } /* after the white rule above, so it wins */
.mapx-phone .mapx-tools .pickpanel { min-width: 170px; inset-inline-start: auto; inset-inline-end: 0; }
.mapx-strip { position: absolute; bottom: 12px; inset-inline: 0; z-index: 5; display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 4px 14px; scrollbar-width: none; }
.mapx-strip::-webkit-scrollbar { display: none; }
.mapx-strip .scard { flex: 0 0 min(84vw, 340px); scroll-snap-align: center; box-shadow: 0 6px 20px rgba(20,40,30,.2); }
.mapx-count { padding: 10px 14px; }
.mapx-phone .cards { padding: 0 14px 14px; }
.scard.on { border-color: var(--ink); box-shadow: 0 0 0 1.5px var(--ink), var(--shadow); }
.mpin { padding: 5px 9px; border-radius: 999px; background: #fff; color: var(--ink); border: 1px solid var(--line); font-weight: 800; font-size: 12.5px; line-height: 1; white-space: nowrap; direction: ltr; box-shadow: 0 1px 3px rgba(20,40,30,.18), 0 3px 10px rgba(20,40,30,.12); cursor: pointer; transition: transform .12s, background .12s; }
.mpin.band-pass { color: var(--ok); } .mpin.band-warning { color: var(--warn); } .mpin.band-at_risk { color: var(--risk); } .mpin.band-na { color: var(--na); }
.mpin.hot { transform: scale(1.14); }
.mpin.on { background: var(--ink); color: #fff; border-color: var(--ink); transform: scale(1.14); }

/* --- users --- */
.urow-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.utable-card { padding: 16px 14px; margin-top: 8px; }
.utable { width: 100%; border-collapse: collapse; }
.utable th { text-align: start; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 0 8px 8px; white-space: nowrap; }
.utable td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; font-size: 13.5px; }
.utable tbody tr { cursor: pointer; }
.utable tbody tr:hover, .utable tbody tr:focus-visible { background: var(--brand-050); outline: none; }
.ut-nametext { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ut-perms { display: flex; flex-wrap: wrap; gap: 4px; } .ut-perms .pill { font-size: 11.5px; padding: 3px 9px; }
/* Users table on a phone: seven columns in ~360px is not a table, it is confetti. Reflow the row
   the way the Report's does — name + role keep line one, every other field gets its own line
   carrying the column header it lost when thead was hidden. Nothing is dropped, nothing is guessed. */
@media (max-width: 520px) {
  /* six tabs (an admin's) in 374px: no label wraps and none is clipped */
  .tab { padding: 9px 1px; font-size: 12px; }
  /* one scrollable line per filter row, edge to edge — two wrapped rows with a chip stranded on
     each pushed the first task 300px down a 660px screen */
  .chips.taskfilter { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-inline: -14px; padding-inline: 14px; }
  .chips.taskfilter::-webkit-scrollbar { display: none; }
  .chips.taskfilter .chip { flex-shrink: 0; }
  .utable thead { display: none; }
  .utable tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 8px; padding: 12px 0; }
  .utable td { border-top: none; padding: 0; }
  .utable tbody tr + tr { border-top: 1px solid var(--line); }
  /* order, not DOM position: the chip belongs beside the name, but in the markup it sits after
     the username and mobile cells so the desktop column order stays correct. */
  .ut-name { flex: 1 1 auto; min-width: 0; }
  .ut-role { margin-inline-start: auto; order: 0; }
  .ut-sec { order: 1; flex-basis: 100%; display: flex; align-items: baseline; gap: 7px; color: var(--ink); font-size: 12.5px; }
  .ut-sec::before { content: attr(data-label); flex: 0 0 5.5rem; color: var(--muted); font-size: 11.5px; }
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; } .chip { padding: 6px 12px; border: 1.5px solid var(--line); background: #fff; border-radius: 20px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip.small { padding: 3px 10px; font-size: 12px; cursor: default; }
/* native <dialog>: the browser supplies the focus trap, Escape, aria-modal and top layer.
   Top layer also means no z-index — it always paints above the sticky topbar and the map. */
.modal-dialog { border: none; padding: 16px; background: transparent; overflow: auto;
  width: 100%; max-width: 100%; height: 100%; max-height: 100%; }
.modal-dialog[open] { display: grid; place-items: center; }
.modal-dialog::backdrop { background: rgba(20,30,25,.45); }
.modal { width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; margin: 0; }


/* --- print (quality report) --- */
@media print {
  /* The document that reaches وزارة الطاقة is Arabic, whatever language the supervisor was
     working in. Never print a paraphrase of the Ministry's own wording. */
  .tx { display: none !important; }
  .topbar, .tabbar, .noprint, .back { display: none !important; }
  body { background: #fff; font-size: 12px; } .wrap { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 1px solid var(--print-line); break-inside: avoid; }
  /* A quality check is read off a photo of the handheld's screen, so the printed thumb has to be
     big enough to read the number, and `contain` so nothing that matters is cropped away. */
  .report .thumb { width: 150px; height: 150px; } .report .thumb img { object-fit: contain; }
  .report .catblock { break-inside: avoid; } /* a check is one block — never split across pages */

}

/* --- ملف اشتراطات الوزارة --- */
.filebox { margin-top: 18px; }
.filetally { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.filesec { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--card); overflow: hidden; }
.filesec-h { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  min-height: var(--tap); padding: 10px 12px; border: 0; background: none; cursor: pointer; font-weight: 700; text-align: start; }
.filesec-h:focus-visible { outline: 2px solid var(--brand-600); outline-offset: -2px; }
.filerows { border-top: 1px solid var(--line); }
.filerow { padding: 10px 12px; border-top: 1px solid var(--line); }
.filerow:first-child { border-top: 0; }
.filerow-t { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; width: 100%; padding: 0; border: 0; background: none; color: inherit; line-height: inherit; text-align: start; }
/* the title line is the tap target (see FileRow); the chevron is the affordance a phone cannot hover for */
button.filerow-t { cursor: pointer; min-height: var(--tap); }
button.filerow-t:active { opacity: .65; }
.filerow-t .chev { display: flex; flex-shrink: 0; color: var(--muted); margin-top: 3px; }
html[dir="ltr"] .chev svg { transform: scaleX(-1); }
/* A long requirement squeezes the pill until «غير مطابق» breaks across two lines. */
.filerow-t .pill { white-space: nowrap; flex-shrink: 0; }
.filerow-t > span:first-child { min-width: 0; }
.filerow-b { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
/* Attachments sit on the row itself, not behind the editor: checking whether the licence is on
   file should not mean opening a form. Small enough that a 45-row file still scrolls. */
.filethumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.fthumb { display: block; width: 46px; height: 46px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.fthumb img { width: 100%; height: 100%; object-fit: cover; }
/* Removing an attachment is immediate and permanent, on a phone, outdoors. The × asks first and
   the second tap is the one that deletes — a mis-tap must not cost the only scan of a licence. */
.thumb button.delconfirm { top: auto; inset-block-end: 2px; inset-inline: 2px; width: auto; height: 18px;
  border-radius: 6px; background: var(--risk); font-size: 10px; font-weight: 700; white-space: nowrap; }
/* picked but not saved yet, so it is obvious what is already on file and what is still in hand */
.thumb.new { border: 1.5px dashed var(--brand-600); }
/* a PDF has no thumbnail to show, so the tile says what it is */
.pdfchip { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
  background: var(--bg); color: var(--muted); font-weight: 700; font-size: 12px; letter-spacing: .5px; }
/* A board card carries up to five pills. .hrow puts them opposite the name and never wraps, so the
   station with the most problems — the one Aziz most needs to read — was the one that rendered
   worst: its name broken across four lines by a column of pills. Stack them instead. */
.docrow { flex-direction: column; align-items: stretch; gap: 8px; }
.docrow .scard-score { flex-wrap: wrap; }

/* --- station automation: the PTS pipeline board (22 Sep 2026) ---------------
   Its own vocabulary, deliberately: «بانتظار الدفع» is amber and «متوقفة» is red, because the
   board's job for management is to separate the stations money is holding up from the ones a
   problem is. Greens and greys are reused from the file so one app still reads as one app. */
.adots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.adot { width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--line); background: var(--field-bg);
  color: var(--muted); font-size: 12px; font-weight: 700; line-height: 1; cursor: default; padding: 0; }
.adot.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.adot.prog { background: var(--brand-050); border-color: var(--brand-600); color: var(--brand); }
.adot.pay { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.adot.risk { background: var(--risk-bg); border-color: var(--risk-line); color: var(--risk); }

.aprog { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.aprog-bar { flex: 1; min-width: 60px; height: 6px; border-radius: 4px; background: var(--field-bg); overflow: hidden; }
.aprog-bar span { display: block; height: 100%; background: var(--ok); border-radius: 4px; }

.asteps { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.astep-h { display: flex; align-items: flex-start; gap: 10px; }
.astep-t { flex: 1; min-width: 0; }
.astep-name { font-weight: 700; }
.astep-n { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 9px; display: flex; align-items: center;
  justify-content: center; font-weight: 800; background: var(--field-bg); color: var(--muted); }
.astep-n.ok { background: var(--ok-bg); color: var(--ok); }
.astep-n.prog { background: var(--brand-050); color: var(--brand); }
.astep-n.pay { background: var(--warn-bg); color: var(--warn); }
.astep-n.risk { background: var(--risk-bg); color: var(--risk); }
.astep-lock { margin-top: 8px; font-style: italic; }
.astep-note { margin-top: 8px; }
.astep-noteread { margin-top: 6px; }
/* the hardware / software / both badge — the thing the original sheet could not say */
.kind { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--line); background: var(--field-bg); color: var(--muted); }
.kind.k-hw { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-bg); }
.kind.k-sw { background: var(--brand-050); color: var(--brand); border-color: var(--brand-050); }
.kind.k-both { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }

.chip.ok.on { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.chip.prog.on { background: var(--brand-050); color: var(--brand); border-color: var(--brand-600); }
.chip.pay.on { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.chip.risk.on { background: var(--risk-bg); color: var(--risk); border-color: var(--risk-line); }

.pill.prog { background: var(--brand-050); color: var(--brand); }
.pill.pay { background: var(--warn-bg); color: var(--warn); }

.alog { margin: 0; padding-inline-start: 18px; }
.alog li { margin-bottom: 8px; }
.pickopt.arow { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.acct-nav { margin: 10px 0 4px; }
.brd-head { align-items: center; gap: 10px; flex-wrap: wrap; }
.adot-na { background: none; border-style: dashed; color: var(--placeholder); }
.acard { display: block; cursor: pointer; text-align: start; }
.acard .aprog { margin-top: 10px; }

/* --- the executive view: the Line ------------------------------------------------------------
   Nine neutral stops on one track; only the stations carry colour, and it means status and nothing
   else. Read on a laptop and off a projector, then printed — so the type runs a step larger than
   the crew board and every colour survives a laser printer. */
::selection { background: var(--brand-050); color: var(--ink); }
.auto-seg { width: auto; } .auto-seg .segb { flex: 0 0 auto; padding-inline: 14px; min-height: var(--tap); }
.exec-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.exec-title { font-size: 22px; font-weight: 800; margin: 0; line-height: 1.3; }
.exec-date { color: var(--muted); font-size: 13px; margin-top: 2px; }
.exec-lede { font-size: 17px; font-weight: 700; margin: 16px 0 24px; font-variant-numeric: tabular-nums; line-height: 1.5; }
.exec-lede .linklike { font-size: inherit; font-weight: 600; }
.exec-line { position: relative; }
.exec-brackets, .exec-stops { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 8px; }
.exec-bracket { grid-column: 2 / span 2; text-align: center; font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--placeholder); padding-top: 3px; margin: 0 8px 8px; }
.exec-kind-fr { display: none; }
.exec-stops { position: relative; }
/* the track, drawn once behind the dots at their centre line */
.exec-stops::before { content: ''; position: absolute; top: 15px; inset-inline: 5%; height: 2px; background: var(--line); }
.exec-stop { display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; min-width: 0; }
.exec-stop-body { width: 100%; min-width: 0; }
.exec-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--card); border: 2px solid var(--ink); color: var(--ink);
  font-weight: 800; font-size: 14px; display: grid; place-items: center; position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.exec-dot.has { background: var(--ink); color: var(--card); }  /* a filled dot is where the fleet is */
.exec-terminal .exec-dot { border-color: var(--ok); color: var(--ok); }
.exec-terminal .exec-dot.has { background: var(--ok); color: #fff; }
.exec-stopname { font-size: 13px; font-weight: 700; margin-top: 8px; line-height: 1.25; }
.exec-kind { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.exec-trains { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; width: 100%; }
.exec-train { width: 100%; padding: 7px 8px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-weight: 700; font-size: 13px; line-height: 1.3; cursor: pointer; text-align: center; transition: transform .15s ease-out, box-shadow .15s ease-out; }
.exec-train:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.exec-train:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; }
.exec-train.prog { background: var(--brand-050); border-color: var(--brand-600); color: var(--brand); }
.exec-train.pay { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.exec-train.risk { background: var(--risk-bg); border-color: var(--risk-line); color: var(--risk); }
.exec-train.ok { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.exec-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 28px; }
.exec-sec h3 { font-size: 16px; margin: 0 0 6px; }
.exec-row { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); }
.exec-row:first-of-type { border-top: 0; }
.exec-row-main { flex: 1; min-width: 0; }
.exec-row-name { font-weight: 700; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.exec-row-name .linklike { font-size: inherit; font-weight: 700; color: var(--ink); padding: 0; }
.exec-row-sub { color: var(--muted); font-size: 13px; }
.exec-days { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 700; padding-top: 1px; }
.exec-empty { color: var(--muted); padding: 6px 0; }
.exec-foot { display: none; }
/* loading: the shape of the page, greyed, never a spinner in the middle of it */
.skel { background: var(--disabled-bg); border-color: var(--disabled-bg) !important; color: transparent !important; border-radius: 8px; }
.exec-skel .exec-dot.skel { border-width: 0; }

@media (min-width: 1400px) { .exec-lede { font-size: 19px; } .exec-train, .exec-stopname { font-size: 14px; } .exec-kind { font-size: 12.5px; } }

@media (max-width: 859px) {
  .exec-head .row { width: 100%; flex-wrap: wrap; justify-content: flex-start; margin-inline-start: 0; }
  .exec-brackets { display: none; } .exec-kind-fr { display: inline; }
  /* the Line stands up: one track down the start side, a stop per row, its stations beside it */
  .exec-stops { grid-template-columns: 1fr; gap: 0; }
  .exec-stops::before { top: 15px; bottom: 15px; height: auto; width: 2px; inset-inline: auto; inset-inline-start: 14px; }
  .exec-stop { flex-direction: row; align-items: flex-start; text-align: start; gap: 12px; padding: 7px 0; }
  .exec-dot { flex: 0 0 30px; }
  .exec-stopname { margin-top: 5px; }
  .exec-trains { flex-direction: row; flex-wrap: wrap; margin-top: 6px; }
  .exec-train { width: auto; min-height: var(--tap); }
  .exec-cols { grid-template-columns: 1fr; gap: 18px; }
}

@media print {
  .exec { page: exec; }
  @page exec { size: A4 landscape; margin: 12mm; }
  .side, .hdr, .noprint { display: none !important; }
  .app.desk { display: block; }
  .wrap-wide { max-width: none; padding: 0; }
  .exec-lede { font-size: 15px; margin: 8px 0 16px; }
  .exec-stops::before, .exec-row, .exec-bracket { border-color: var(--print-line); }
  .exec-stops::before { background: var(--print-line); }
  .exec-train, .exec-dot, .pill { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .exec-train { box-shadow: none; }
  .exec-line { break-inside: avoid; }
  .exec-cols { display: block; margin-top: 18px; }
  .exec-sec + .exec-sec { margin-top: 18px; }
  .exec-sec h3 { break-after: avoid; }
  .exec-row { break-inside: avoid; }
  .exec-foot { display: block; margin-top: 16px; color: var(--muted); font-size: 11px; border-top: 1px solid var(--print-line); padding-top: 6px; }
}
