/* TCF1 – mobile-first RTL. Fonts: Cairo (ar/en) + Noto Nastaliq Urdu via Google Fonts, system fallback. */
:root {
  --bg: #f3f5f8; --card: #fff; --ink: #1b2430; --muted: #5d6b7c; --line: #dfe5ec;
  --brand: #1f3a5f; --brand-2: #2d5a8c;
  --open: #c0392b; --open-bg: #fdecea; --submitted: #b26a00; --submitted-bg: #fff4de;
  --closed: #1e8449; --closed-bg: #e8f6ee; --info: #138d90; --info-bg: #e6f6f6;
  --sev-crit: #8e1b1b; --sev-high: #c9641a; --sev-med: #b8860b; --sev-low: #2e7d32;
  --sev-clar: #5f7a8c; --sev-pos: #138d90;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 16px;
  --tap: 44px; --topbar-h: 56px; --maxw: 960px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Cairo", system-ui, "Segoe UI", Tahoma, Arial, sans-serif; font-size: 16px; line-height: 1.6;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: .92rem; margin: .4rem 0; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 44px; padding: .5rem 1rem; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; font-weight: 600; background: var(--surface-2); color: var(--ink);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: .35rem .8rem; font-size: .92rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-ok { background: var(--closed); color: #fff; }
.btn-warn { background: var(--submitted); color: #fff; }
.btn-danger { background: var(--open); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: inherit; }

/* top bar + tabs */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .4rem .75rem; min-height: var(--topbar-h);
}
.topbar-title { font-weight: 700; font-size: 1rem; line-height: 1.3; min-width: 0; }
.topbar-user { display: flex; align-items: center; gap: .4rem; flex-shrink: 0; }
.topbar .btn-ghost { border-color: rgba(255,255,255,.45); color: #fff; }
.role-chip { font-size: .8rem; background: rgba(255,255,255,.16); padding: .15rem .55rem; border-radius: 99px; white-space: nowrap; max-width: 48vw; overflow: hidden; text-overflow: ellipsis; display: inline-flex; align-items: center; gap: .3rem; }
.role-chip .u-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.role-chip .u-sep { opacity: .6; }
.role-chip .u-role { opacity: .9; font-weight: 400; }
.tabs { display: flex; gap: .25rem; padding: .4rem .5rem 0; background: var(--card); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  min-height: 44px; display: inline-flex; align-items: center; gap: .3rem; padding: 0 .75rem;
  color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; font-size: .93rem;
}
.tab.active { color: var(--brand-ink); border-bottom-color: var(--brand-ink); }
.tab-n { background: var(--submitted); color: #fff; border-radius: 99px; font-size: .75rem; padding: 0 .45rem; }
.tab-n:empty { display: none; }

main { max-width: var(--maxw); margin: 0 auto; padding: .75rem; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--card); border-radius: var(--radius); padding: .6rem .75rem; border-inline-start: 5px solid var(--line); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.stat b { display: block; font-size: 1.6rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .88rem; }
.stat.s-open { border-color: var(--open); } .stat.s-submitted { border-color: var(--submitted); }
.stat.s-closed { border-color: var(--closed); } .stat.s-total { border-color: var(--brand-ink); }
.progress-wrap { margin: .75rem 0; }
.progress { height: 12px; background: var(--line); border-radius: 99px; overflow: hidden; display: flex; }
.progress-bar { height: 100%; background: var(--closed); width: 0; transition: width .4s; }
.progress-bar.sub { background: var(--submitted); opacity: .7; }
.progress-label { font-size: .88rem; color: var(--muted); margin-top: .2rem; }

.by-loc { background: var(--card); border-radius: var(--radius); padding: .25rem .75rem; margin-bottom: .75rem; }
.by-loc summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }
.loc-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .2rem .5rem; padding: .45rem 0; border-top: 1px solid var(--line); cursor: pointer; }
.loc-row .nm { font-size: .9rem; min-width: 0; overflow-wrap: anywhere; }
.loc-row .nums { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.loc-row .progress { grid-column: 1 / -1; height: 7px; }
.loc-grp { font-size: .8rem; color: var(--brand-2); font-weight: 700; padding-top: .5rem; }

/* filters */
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; margin-bottom: .5rem; }
.filters input[type=search] { grid-column: 1 / -1; }
.filters input, .filters select {
  width: 100%; min-width: 0; min-height: 44px; padding: .4rem .6rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--card);
}
@media (min-width: 760px) { .filters { grid-template-columns: 2fr repeat(4, minmax(0, 1fr)); } .filters input[type=search] { grid-column: auto; } }
.list-head { color: var(--muted); font-size: .88rem; margin: .25rem 0 .5rem; }

/* cards */
.cards { display: grid; gap: .6rem; }
@media (min-width: 760px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.card {
  display: flex; gap: .6rem; background: var(--card); border-radius: var(--radius); padding: .6rem;
  text-decoration: none; color: inherit; box-shadow: 0 1px 2px rgba(0,0,0,.06); min-width: 0;
  border-inline-start: 4px solid transparent;
}
.card.st-open { border-color: var(--open); } .card.st-submitted { border-color: var(--submitted); }
.card.st-closed { border-color: var(--closed); } .card.st-info { border-color: var(--info); }
.card-thumb { width: 84px; height: 84px; flex-shrink: 0; border-radius: 8px; object-fit: cover; background: var(--img-bg); }
.card-thumb.none { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .75rem; text-align: center; }
.card-body { min-width: 0; flex: 1; }
.card-top { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; margin-bottom: .15rem; }
.card-id { font-weight: 700; font-size: .85rem; direction: ltr; unicode-bidi: isolate; }
.card-title { font-weight: 600; font-size: .95rem; line-height: 1.45; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; background: var(--card); border-radius: var(--radius); }

/* badges */
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: .05rem .5rem; border-radius: 99px; color: #fff; white-space: nowrap; line-height: 1.6; }
.sev-crit { background: var(--sev-crit); }
.sev-high { background: var(--sev-high); }
.sev-med { background: var(--sev-med); color: #3b2f00; }
.sev-low { background: var(--sev-low); }
.sev-clar { background: var(--sev-clar); }
.sev-pos { background: var(--sev-pos); }
.b-open { background: var(--open); } .b-submitted { background: var(--submitted); }
.b-closed { background: var(--closed); } .b-info { background: var(--info); }
.b-plain { background: var(--surface-2); color: var(--ink); font-weight: 600; }

/* detail */
.back { margin-bottom: .5rem; }
.panel { background: var(--card); border-radius: var(--radius); padding: .8rem; margin-bottom: .75rem; box-shadow: 0 1px 2px rgba(0,0,0,.05); overflow-wrap: anywhere; }
.panel h2 { font-size: 1.1rem; margin: .3rem 0 .4rem; line-height: 1.5; }
.panel h3 { font-size: 1rem; margin: 0 0 .5rem; color: var(--brand-ink); }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .15rem .6rem; font-size: .88rem; margin-top: .5rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.rec { background: var(--rec-bg); border-inline-start: 4px solid var(--brand-2); padding: .5rem .7rem; border-radius: 6px; }
.pgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
@media (min-width: 640px) { .pgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.pgrid figure { margin: 0; min-width: 0; }
.pgrid button { padding: 0; border: 0; background: none; width: 100%; cursor: zoom-in; display: block; }
.pgrid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--img-bg); }
.pgrid figcaption { font-size: .76rem; color: var(--muted); line-height: 1.45; margin-top: .2rem; }
.pgrid .pid { direction: ltr; unicode-bidi: isolate; font-weight: 700; color: var(--ink); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 1.1rem .7rem 0; border-inline-start: 2px solid var(--line); margin-inline-start: .4rem; }
.timeline li::before { content: ""; position: absolute; inset-inline-start: -7px; top: .45rem; width: 12px; height: 12px; border-radius: 50%; background: var(--brand-2); }
.timeline li.t-close::before, .timeline li.t-direct_close::before { background: var(--closed); }
.timeline li.t-keep_open::before, .timeline li.t-reopen::before { background: var(--open); }
.timeline li.t-submit::before { background: var(--submitted); }
.timeline .t-h { font-weight: 600; font-size: .9rem; }
.timeline .t-d { font-size: .78rem; color: var(--muted); }
.timeline .t-n { font-size: .88rem; white-space: pre-wrap; }

.sub { border: 1px solid var(--line); border-radius: 8px; padding: .6rem; margin-bottom: .6rem; }
.sub.pending { border-color: var(--submitted); background: var(--pending-bg); }
.sub-h { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
.sub-note { white-space: pre-wrap; margin: .2rem 0 .5rem; }
.decision { font-size: .88rem; padding: .4rem .6rem; border-radius: 6px; background: var(--surface-3); margin-top: .4rem; white-space: pre-wrap; }

.actions { display: grid; gap: .5rem; margin-top: .6rem; }
.actions .row { display: flex; flex-wrap: wrap; gap: .5rem; }
.actions .row .btn { flex: 1 1 140px; }
textarea { width: 100%; min-height: 84px; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); resize: vertical; }
.confirm-box { border: 2px dashed var(--brand-2); border-radius: 8px; padding: .6rem; background: var(--surface-3); }
.confirm-box p { margin: 0 0 .5rem; font-weight: 600; }

.upload-form .file-btn { position: relative; overflow: hidden; }
.upload-form input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.previews { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; margin: .5rem 0; }
.previews .pv { position: relative; }
.previews img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--img-bg); }
.previews .rm { position: absolute; top: 2px; inset-inline-end: 2px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; }
.upbar { height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; margin: .4rem 0; }
.upbar div { height: 100%; width: 0; background: var(--brand-2); transition: width .2s; }
.msg { padding: .5rem .7rem; border-radius: 8px; font-size: .92rem; margin: .5rem 0 0; }
.msg-err { background: var(--err-bg); color: var(--err-ink); }
.msg-ok { background: var(--ok-bg); color: var(--ok-ink); }
.notice { padding: .6rem .8rem; border-radius: 8px; background: var(--warn-bg); color: var(--warn-ink); font-weight: 600; }
.notice.ok { background: var(--ok-bg); color: var(--ok-ink); }

/* lightbox */
.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center; flex-direction: column; padding: 3.2rem .5rem 1rem; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 9rem); object-fit: contain; }
.lb-cap { color: #e6e6e6; font-size: .88rem; max-width: 760px; padding: .6rem .5rem 0; text-align: center; overflow-wrap: anywhere; }
.lb-close { position: absolute; top: .4rem; inset-inline-end: .4rem; width: 48px; height: 48px; font-size: 1.4rem; border-radius: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; cursor: pointer; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 2rem; cursor: pointer; border-radius: 8px; }
.lb-prev { inset-inline-start: .3rem; } .lb-next { inset-inline-end: .3rem; }

.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); z-index: 120; background: var(--toast-bg); color: var(--toast-ink); padding: .6rem 1rem; border-radius: 8px; max-width: calc(100% - 2rem); box-shadow: 0 4px 14px rgba(0,0,0,.25); }

/* login */
.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(160deg, #1f3a5f, #2d5a8c); }
.login-card { background: var(--card); border-radius: 14px; padding: 1.4rem 1.2rem; width: 100%; max-width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.login-card h1 { font-size: 1.25rem; margin: 0 0 .2rem; color: var(--brand-ink); }
.role-pick { border: 0; padding: 0; margin: 1rem 0; display: grid; gap: .5rem; }
.role-pick legend { font-weight: 600; margin-bottom: .4rem; }
.role-opt { display: flex; align-items: center; gap: .6rem; min-height: 48px; padding: 0 .8rem; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.role-opt input { width: 20px; height: 20px; }
.field { display: grid; gap: .3rem; margin-bottom: 1rem; font-weight: 600; }
.field input { min-height: 48px; padding: .4rem .7rem; border: 1px solid var(--line); border-radius: 8px; font-weight: 400; }

/* ===================== Binaey TCF1 – field survey (collect.html) ===================== */
.tb-sub { font-weight: 400; font-size: .8rem; opacity: .85; margin-inline-start: .4rem; }
.where-grid { display: grid; grid-template-columns: 1fr; gap: .4rem; }
@media (min-width: 560px) { .where-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.where-grid .field { margin-bottom: .3rem; }
.field select, .field textarea { min-height: 48px; padding: .4rem .7rem; border: 1px solid var(--line); border-radius: 8px; font-weight: 400; background: var(--card); width: 100%; }
.field textarea { min-height: 64px; }
.unit-name { color: var(--brand-2); font-weight: 600; font-size: .9rem; min-height: 1.2rem; }
.unit-chips { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-top: .4rem; }
.uchip { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: .15rem .6rem; font-size: .82rem; cursor: pointer; }
.uchip.active { border-color: var(--brand-ink); background: var(--brand); color: #fff; }
.uchip small b.o, .ck-cnt b.o { color: var(--open); } .uchip small b.c, .ck-cnt b.c { color: var(--closed); }
.uchip.active small b { color: #fff; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.muted-inline { color: var(--muted); font-weight: 400; font-size: .85rem; }
.checklist { display: grid; gap: .35rem; }
.ck-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .4rem; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: .3rem .5rem; background: var(--card); }
.ck-row.done { background: var(--ok-bg); border-color: var(--closed); }
.ck-box { display: flex; align-items: center; gap: .5rem; min-height: 40px; cursor: pointer; min-width: 0; }
.ck-box input { width: 22px; height: 22px; flex-shrink: 0; }
.ck-box span { overflow-wrap: anywhere; font-weight: 600; font-size: .92rem; }
.ck-cnt { font-size: .78rem; white-space: nowrap; }
.ck-add { white-space: nowrap; }
.group-head { font-weight: 700; color: var(--brand-ink); background: var(--surface-2); padding: .3rem .6rem; border-radius: 6px; margin-top: .3rem; font-size: .9rem; }
.badge.st-open { background: var(--open); } .badge.st-closed { background: var(--closed); }
.card { text-decoration: none; color: inherit; }
.kvf { display: grid; gap: .15rem; font-size: .9rem; margin: .5rem 0; } .kvf b { color: var(--muted); font-weight: 600; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: .4rem 0; }
.view-ph img { cursor: zoom-in; }
.note { border: 1px solid var(--line); border-inline-start: 4px solid var(--brand-2); border-radius: 8px; padding: .5rem .7rem; margin-bottom: .5rem; background: var(--card); }
.note.k-close { border-inline-start-color: var(--closed); background: var(--ok-bg); }
.note.k-reopen { border-inline-start-color: var(--open); background: var(--err-bg); }
.note-head { font-size: .82rem; color: var(--muted); margin-bottom: .2rem; }
.file-row { display: flex; gap: .5rem; flex-wrap: wrap; margin: .3rem 0; }
.file-row .file-btn { position: relative; overflow: hidden; flex: 1 1 140px; text-align: center; }
.file-row input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.fu-actions, .out-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.fu-actions .btn, .out-actions .btn { flex: 1 1 150px; text-align: center; }
.up-progress { margin: .4rem 0; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { cursor: pointer; } .chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip .badge { opacity: .45; border: 2px solid transparent; font-size: .85rem; padding: .15rem .7rem; }
.chip input:checked + .badge { opacity: 1; border-color: var(--ink); }
.edit-form .field { margin-bottom: .6rem; }
.tbl { border-collapse: collapse; width: 100%; font-size: .9rem; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: .35rem .5rem; text-align: start; }
.tbl th { background: var(--surface-2); } .tbl .num { text-align: center; font-variant-numeric: tabular-nums; }
.tbl a { text-decoration: none; margin-inline-end: .4rem; }
.sheet { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { background: var(--bg); width: 100%; max-width: 640px; max-height: 94vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: .7rem .9rem calc(1rem + env(safe-area-inset-bottom, 0px)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.sheet-where { font-size: .9rem; color: var(--brand-2); margin-bottom: .5rem; }
.sheet .field { margin-bottom: .55rem; }
.sheet-actions { margin-top: .5rem; }
details.panel summary { cursor: pointer; font-weight: 600; color: var(--brand-ink); }

/* ---- language switcher / i18n ---- */
.lang-sel { font: inherit; font-size: .8rem; min-height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: inherit; padding: 0 .4rem; }
.topbar .lang-sel { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.4); }
.topbar .lang-sel option { color: #111; }
#langSlot { display: flex; justify-content: center; margin-bottom: .6rem; }
:lang(ur) { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Urdu Typesetting", system-ui, "Segoe UI", Tahoma, Arial, sans-serif; }
:lang(ur) { line-height: 2; }
:lang(ur) body, :lang(ur) input, :lang(ur) select, :lang(ur) textarea, :lang(ur) button { line-height: 2; }

/* ---------- summary page ---------- */
.summary { max-width: 1100px; margin: 0 auto; }
.sum-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; flex-wrap: wrap; margin: .4rem 0 .7rem; }
.sum-title { font-size: 1.25rem; margin: 0; color: var(--brand-ink); line-height: 1.4; }
.sum-meta, .sum-sub { color: var(--muted); font-size: .85rem; margin: .15rem 0 .4rem; }
.sum-tools { display: flex; gap: .4rem; }
.sec-title { font-size: 1.05rem; margin: 0 0 .5rem; color: var(--brand-ink); border-inline-start: 4px solid var(--brand-2); padding-inline-start: .5rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .5rem; margin-bottom: .75rem; }
.kpi { background: var(--card); border-radius: var(--radius); padding: .6rem .7rem; text-align: center; box-shadow: 0 1px 2px rgba(0,0,0,.05); border-top: 4px solid var(--brand-2); }
.kpi-v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi-l { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.kpi-open { border-top-color: var(--open); } .kpi-open .kpi-v { color: var(--open); }
.kpi-submitted { border-top-color: var(--submitted); } .kpi-submitted .kpi-v { color: var(--submitted); }
.kpi-closed { border-top-color: var(--closed); } .kpi-closed .kpi-v { color: var(--closed); }
.kpi-pct { border-top-color: var(--brand-ink); } .kpi-info { border-top-color: var(--info); }
.sev-strip { display: flex; flex-wrap: wrap; gap: .4rem .9rem; margin-top: .6rem; }
.sev-cell { display: flex; align-items: center; gap: .35rem; font-size: .9rem; font-variant-numeric: tabular-nums; }
.sev-n small { color: var(--muted); }
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sum-tbl { min-width: 560px; }
.sum-tbl td, .sum-tbl th { white-space: nowrap; font-variant-numeric: tabular-nums; vertical-align: middle; }
.sum-tbl .td-name, .sum-tbl .td-title { white-space: normal; min-width: 160px; }
.sum-tbl .td-sub { color: var(--muted); font-size: .78rem; }
.sum-tbl tfoot th { background: var(--surface-2); }
.sum-tbl .c-open { color: var(--open); font-weight: 600; } .sum-tbl .c-sub { color: var(--submitted); } .sum-tbl .c-closed { color: var(--closed); font-weight: 600; }
.sum-tbl .w-bar { min-width: 150px; }
.sum-tbl .pct { font-size: .8rem; color: var(--muted); margin-inline-start: .3rem; }
.sum-tbl .empty { text-align: center; color: var(--muted); padding: 1rem; }
.mbar { display: inline-flex; width: 100px; height: 9px; border-radius: 5px; background: var(--surface-2); overflow: hidden; vertical-align: middle; }
.mbar span { display: block; height: 100%; } .mb-closed { background: var(--closed); } .mb-sub { background: var(--submitted); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }
.pivot { border: 1px solid var(--line); border-radius: 8px; margin-bottom: .5rem; background: var(--card); }
.pivot summary { cursor: pointer; padding: .5rem .7rem; font-weight: 600; display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.pivot .pv-n { color: var(--muted); font-weight: 400; font-size: .85rem; }
.pivot-tbl { font-size: .82rem; }
.pivot-tbl th, .pivot-tbl td { text-align: center; white-space: nowrap; padding: .25rem .4rem; font-variant-numeric: tabular-nums; }
.pivot-tbl th.sticky { position: sticky; inset-inline-start: 0; background: var(--surface-2); text-align: start; z-index: 1; min-width: 140px; white-space: normal; }
.pivot-tbl td.dim { color: var(--dim); }
.pivot-tbl td.has-open { background: var(--err-bg); color: var(--open); font-weight: 600; }
.pivot-tbl td.all-closed { background: var(--ok-bg); color: var(--closed); }
.pivot-tbl .of { color: var(--muted); font-weight: 400; font-size: .75em; }
.pivot-tbl td.tot, .pivot-tbl tfoot th { font-weight: 700; background: var(--surface-3); }
.daily { margin-bottom: .8rem; }
.daily-legend { display: flex; gap: .9rem; font-size: .8rem; color: var(--muted); margin-bottom: .3rem; }
.lg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: .3rem; vertical-align: middle; }
.lg-sub::before { background: var(--submitted); } .lg-closed::before { background: var(--closed); }
.daily-bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; height: 90px; align-items: end; }
.day { display: flex; flex-direction: column; align-items: center; height: 100%; }
.db { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 2px; }
.db span { display: block; width: 40%; min-height: 1px; border-radius: 2px 2px 0 0; }
.db-sub { background: var(--submitted); } .db-closed { background: var(--closed); }
.day-l { font-size: .68rem; color: var(--muted); margin-top: .2rem; }
.tl-item { border-inline-start: 3px solid var(--line); padding: .3rem .6rem .5rem; margin-bottom: .4rem; }
.tl-submit { border-color: var(--submitted); } .tl-close, .tl-direct_close { border-color: var(--closed); } .tl-keep_open, .tl-reopen { border-color: var(--open); }
.tl-head { font-size: .85rem; } .tl-body { font-size: .9rem; } .tl-note { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.muted { color: var(--muted); }
@media print {
  body { background: #fff; font-size: 11px; }
  .topbar, .tabs, .no-print, .toast { display: none !important; }
  .summary { max-width: none; }
  .panel, .kpi, .pivot { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .sum-tbl, .pivot-tbl { min-width: 0; font-size: 10px; }
  .tbl-wrap { overflow: visible; }
  .pivot { break-inside: auto; }
  .pivot[open] summary { break-after: avoid; }
  .mbar { border: 1px solid #ccc; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- wave 2: readable list ---------- */
.filters-wrap { position: sticky; top: var(--topbar-h); z-index: 15; background: var(--bg); padding: .35rem 0 .3rem; margin-bottom: .3rem; }
.search-row { display: flex; gap: .4rem; }
.search-row input[type=search] { flex: 1; min-width: 0; min-height: 44px; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
#fToggle { white-space: nowrap; background: var(--card); }
.filters-wrap .filters { display: none; margin-top: .5rem; margin-bottom: 0; }
.filters-wrap .filters.open { display: grid; }
.filters-wrap .filters.has-active { border-inline-start: 3px solid var(--brand-2); padding-inline-start: .4rem; }
@media (min-width: 760px) {
  .filters-wrap .filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #fToggle { display: none; }
  .filters-wrap { position: static; }
}
@media (min-width: 1000px) { .filters-wrap .filters { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.status-chips { display: flex; gap: .35rem; margin-top: .5rem; overflow-x: auto; padding-bottom: .1rem; }
.schip { flex-shrink: 0; min-height: 36px; padding: .2rem .7rem; border-radius: 99px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-size: .88rem; color: var(--muted); }
.schip b { font-variant-numeric: tabular-nums; color: var(--ink); }
.schip.active { color: #fff; border-color: transparent; background: var(--brand); } .schip.active b { color: #fff; }
.schip.sc-open.active { background: var(--open); } .schip.sc-submitted.active { background: var(--submitted); } .schip.sc-closed.active { background: var(--closed); }
.card { position: relative; border-inline-start: none; padding-inline-start: .9rem; overflow: hidden; }
.card-stripe { position: absolute; inset-block: 0; inset-inline-start: 0; width: 6px; background: var(--line); }
.card-stripe.sev-crit { background: var(--sev-crit); } .card-stripe.sev-high { background: var(--sev-high); }
.card-stripe.sev-med { background: var(--sev-med); } .card-stripe.sev-low { background: var(--sev-low); }
.card-stripe.sev-clar { background: var(--sev-clar); } .card-stripe.sev-pos { background: var(--sev-pos); }
.card.st-submitted { box-shadow: 0 0 0 1px var(--submitted) inset, 0 1px 2px rgba(0,0,0,.06); }
.card.st-closed { opacity: .82; }
.badge.b-returned { background: var(--card); color: var(--open); border: 1px solid var(--open); }
.card-title { font-size: 1rem; }
.empty .btn { margin-top: .6rem; }

/* ---------- wave 3: simpler input ---------- */
.quick-chips { display: flex; flex-wrap: wrap; gap: .35rem; margin: .2rem 0 .4rem; }
.qchip { min-height: 36px; padding: .15rem .7rem; border-radius: 99px; border: 1px solid var(--brand-2); background: var(--surface-3); color: var(--brand-ink); cursor: pointer; font-size: .88rem; font-weight: 500; }
.qchip:active { background: var(--brand-2); color: #fff; }
.qitem { display: grid; gap: .3rem; }
.q-actions { background: var(--card); border-radius: var(--radius); padding: .5rem .6rem; margin-top: -.3rem; border-inline-start: 6px solid var(--submitted); }
.q-actions .row { display: flex; gap: .4rem; flex-wrap: wrap; }
.q-actions .btn { flex: 1 1 140px; }
.upload-form .btn-primary.btn-block { font-size: 1.05rem; min-height: 52px; }

/* ---------- wave 4: professional output ---------- */
.obs-tools { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.ba { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.ba figure { margin: 0; min-width: 0; }
.ba button { padding: 0; border: 0; background: none; width: 100%; cursor: zoom-in; display: block; }
.ba img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: var(--img-bg); border: 3px solid var(--open); }
.ba figure:last-child img { border-color: var(--closed); }
.ba-l { font-weight: 700; font-size: .85rem; color: var(--open); margin-bottom: .25rem; }
.ba-l.ba-after { color: var(--closed); }
.ba figcaption { font-size: .76rem; color: var(--muted); margin-top: .2rem; }
/* print page */
.page-print { background: var(--bg); }
.print-tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .5rem; align-items: end; max-width: 900px; margin: .6rem auto; padding: 0 .6rem; }
.print-tools .btn { min-height: 44px; }
.report { background: var(--card); max-width: 900px; margin: 0 auto 1rem; padding: 1rem 1.1rem; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.rep-head { border-bottom: 3px solid var(--brand); padding-bottom: .6rem; margin-bottom: .8rem; }
.rep-brand { color: var(--brand-2); font-size: .85rem; font-weight: 700; }
.rep-title { font-size: 1.3rem; margin: .2rem 0 .3rem; color: var(--brand-ink); }
.rep-meta { display: flex; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-size: .82rem; }
.rep-kpis { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.rk { flex: 1 1 100px; text-align: center; border: 1px solid var(--line); border-top: 4px solid var(--brand); border-radius: 6px; padding: .3rem .4rem; font-size: .78rem; color: var(--muted); }
.rk b { display: block; font-size: 1.25rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.rk-open { border-top-color: var(--open); } .rk-submitted { border-top-color: var(--submitted); } .rk-closed { border-top-color: var(--closed); } .rk-info { border-top-color: var(--info); }
.rep-loc { font-size: 1.1rem; color: var(--brand-ink); border-inline-start: 5px solid var(--brand); padding-inline-start: .5rem; margin: 1.2rem 0 .5rem; break-after: avoid; }
.rep-place-h { font-size: .95rem; margin: .8rem 0 .4rem; color: var(--brand-2); border-bottom: 1px solid var(--line); padding-bottom: .2rem; break-after: avoid; }
.rep-place-h small { color: var(--muted); font-weight: 400; }
.pitem { border: 1px solid var(--line); border-inline-start: 5px solid var(--open); border-radius: 6px; padding: .5rem .7rem; margin-bottom: .5rem; break-inside: avoid; }
.pitem.st-submitted { border-inline-start-color: var(--submitted); } .pitem.st-closed { border-inline-start-color: var(--closed); } .pitem.st-info { border-inline-start-color: var(--info); }
.pi-head { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; font-size: .8rem; }
.pi-id { font-weight: 700; direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, Consolas, monospace; }
.pi-place { color: var(--muted); margin-inline-start: auto; }
.pi-title { font-weight: 700; margin: .25rem 0; font-size: .98rem; }
.pi-detail { font-size: .88rem; line-height: 1.6; }
.pi-rec { font-size: .86rem; background: var(--rec-bg); border-inline-start: 3px solid var(--brand-2); padding: .3rem .5rem; margin-top: .3rem; border-radius: 4px; }
.pi-photos { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .45rem; }
.pcol-l { font-size: .75rem; font-weight: 700; color: var(--open); margin-bottom: .2rem; }
.pcol:last-child .pcol-l { color: var(--closed); }
.prow { display: flex; gap: .4rem; }
.prow.wrap { flex-wrap: wrap; margin-bottom: .5rem; }
.pf { margin: 0; flex: 1 1 0; min-width: 0; max-width: 220px; }
.prow.wrap .pf { flex: 0 0 calc(33.33% - .3rem); }
.pf img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; background: var(--img-bg); }
.pf figcaption { font-size: .68rem; color: var(--muted); direction: ltr; text-align: start; }
.pi-foot { display: flex; flex-direction: column; gap: .15rem; font-size: .8rem; color: var(--muted); margin-top: .4rem; border-top: 1px dashed var(--line); padding-top: .3rem; }
.pitem.single h3 { font-size: .95rem; color: var(--brand-ink); margin: .9rem 0 .4rem; }
.psub { border: 1px solid var(--line); border-radius: 6px; padding: .4rem .6rem; margin-bottom: .4rem; font-size: .88rem; }
.psub-h { color: var(--muted); font-size: .8rem; margin-bottom: .2rem; }
.pdec { margin-top: .3rem; font-size: .84rem; color: var(--closed); }
.ptl { width: 100%; border-collapse: collapse; font-size: .8rem; }
.ptl th, .ptl td { border: 1px solid var(--line); padding: .25rem .4rem; text-align: start; vertical-align: top; }
.ptl th { background: var(--surface-2); }
.rep-foot { display: flex; gap: 1.5rem; margin-top: 2rem; padding-top: .6rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.sig { flex: 1 1 160px; font-size: .82rem; color: var(--muted); display: flex; flex-direction: column; gap: 1.6rem; }
.sig .line { border-bottom: 1px solid var(--ink); }
.report .empty, .report .loading { text-align: center; color: var(--muted); padding: 2rem; }
@media (max-width: 600px) { .pi-photos { grid-template-columns: 1fr; } .prow.wrap .pf { flex-basis: calc(50% - .2rem); } }
@media print {
  @page { size: A4; margin: 12mm; }
  .page-print { background: #fff; }
  .print-tools { display: none !important; }
  .report { max-width: none; margin: 0; padding: 0; box-shadow: none; }
  .pitem { break-inside: avoid; }
  .pf img { aspect-ratio: 4 / 3; }
  .rep-foot { break-inside: avoid; }
}

.rep-loc.rep-ok { border-inline-start-color: var(--closed); color: var(--closed); margin-top: 1.6rem; }

/* ---------- wave 5 (DEV-A): icons, a11y, shared sheets, two-step login ---------- */
.icon { width: 1.15em; height: 1.15em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.2em; flex-shrink: 0; }
[dir=rtl] .icon-flip { transform: scaleX(-1); }
.tab .icon { width: 1.05em; height: 1.05em; }
.tab-sep { width: 1px; align-self: stretch; margin: .5rem .15rem; background: var(--line); flex-shrink: 0; }
:focus-visible { outline: 3px solid var(--brand-2); outline-offset: 2px; }
.topbar :focus-visible, .lightbox :focus-visible { outline-color: #fff; }
.chip:focus-within .badge, .chip input:focus-visible + .badge { outline: 3px solid var(--brand-2); outline-offset: 2px; }
body.no-scroll { overflow: hidden; }
.sheet.sheet-center { align-items: center; padding: 1rem; }
.sheet.sheet-center .sheet-card { border-radius: var(--radius-lg); max-width: 420px; }
.sheet-card h3 { font-size: 1.05rem; }
.confirm-text { margin: .2rem 0 .6rem; }
.t-by { font-size: .85rem; color: var(--brand-2); margin-top: .1rem; }
.step-ok { background: var(--closed-bg); color: var(--ok-ink); font-weight: 600; padding: .5rem .7rem; border-radius: var(--radius-sm); margin: .6rem 0 .4rem; }
#uiName .field { margin-top: .4rem; }
@media (max-width: 420px) { .topbar-title .tb-sub { display: none; } }

/* ---------------------------------------------------------------- W7 dark theme */
:root { --bg: #f3f5f8; --card: #fff; --ink: #1b2430; --muted: #5d6b7c; --line: #dfe5ec;
    --brand: #1f3a5f; --brand-2: #2d5a8c; --brand-ink: #1f3a5f;
    --open-bg: #fdecea; --submitted-bg: #fff4de; --closed-bg: #e8f6ee; --info-bg: #e6f6f6;
    --surface-2: #e9eef4; --surface-3: #f4f6f9; --img-bg: #e3e8ee; --rec-bg: #eef5ff; --pending-bg: #fffaf0;
    --err-bg: #fdecea; --err-ink: #8a1c12; --ok-bg: #e8f6ee; --ok-ink: #145a32; --warn-bg: #fff4de; --warn-ink: #6b4300;
    --toast-bg: #1b2430; --toast-ink: #fff; --dim: #c5ccd6;
    --sev-clar: #5f7a8c; --sev-low: #2e7d32; color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #0f141b; --card: #1a2230; --ink: #e6ebf2; --muted: #9aa7b8; --line: #2c3644;
    --brand: #24466f; --brand-2: #5b8fd0; --brand-ink: #9cc4f0;
    --open-bg: #3a1a17; --submitted-bg: #3a2d10; --closed-bg: #12301d; --info-bg: #0f3233;
    --surface-2: #242e3c; --surface-3: #202938; --img-bg: #2a3442; --rec-bg: #1b2a3d; --pending-bg: #2a2414;
    --err-bg: #3a1a17; --err-ink: #ffb4ab; --ok-bg: #12301d; --ok-ink: #8fe0b0; --warn-bg: #3a2d10; --warn-ink: #ffd58a;
    --toast-bg: #e6ebf2; --toast-ink: #0f141b; --dim: #3d4858;
    --sev-clar: #8fa6b8; --sev-low: #3f9a44; color-scheme: dark; }
}
:root[data-theme="dark"] { --bg: #0f141b; --card: #1a2230; --ink: #e6ebf2; --muted: #9aa7b8; --line: #2c3644;
    --brand: #24466f; --brand-2: #5b8fd0; --brand-ink: #9cc4f0;
    --open-bg: #3a1a17; --submitted-bg: #3a2d10; --closed-bg: #12301d; --info-bg: #0f3233;
    --surface-2: #242e3c; --surface-3: #202938; --img-bg: #2a3442; --rec-bg: #1b2a3d; --pending-bg: #2a2414;
    --err-bg: #3a1a17; --err-ink: #ffb4ab; --ok-bg: #12301d; --ok-ink: #8fe0b0; --warn-bg: #3a2d10; --warn-ink: #ffd58a;
    --toast-bg: #e6ebf2; --toast-ink: #0f141b; --dim: #3d4858;
    --sev-clar: #8fa6b8; --sev-low: #3f9a44; color-scheme: dark; }
.theme-btn { font: inherit; font-size: 1rem; min-width: 36px; min-height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: inherit; cursor: pointer; padding: 0 .4rem; line-height: 1; }
.topbar .theme-btn { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.4); }
.msg-warn { background: var(--warn-bg); color: var(--warn-ink); }
.timeline li.t-verify_accept::before { background: var(--info); } .timeline li.t-unverify::before { background: var(--open); }
.tl-verify_accept { border-color: var(--info); } .tl-unverify { border-color: var(--open); }
.card-thumb, .pgrid img, .previews img, .ba img, .pf img { background: var(--img-bg); }
@media print {
  :root, :root[data-theme="dark"] { --bg: #f3f5f8; --card: #fff; --ink: #1b2430; --muted: #5d6b7c; --line: #dfe5ec;
    --brand: #1f3a5f; --brand-2: #2d5a8c; --brand-ink: #1f3a5f;
    --open-bg: #fdecea; --submitted-bg: #fff4de; --closed-bg: #e8f6ee; --info-bg: #e6f6f6;
    --surface-2: #e9eef4; --surface-3: #f4f6f9; --img-bg: #e3e8ee; --rec-bg: #eef5ff; --pending-bg: #fffaf0;
    --err-bg: #fdecea; --err-ink: #8a1c12; --ok-bg: #e8f6ee; --ok-ink: #145a32; --warn-bg: #fff4de; --warn-ink: #6b4300;
    --toast-bg: #1b2430; --toast-ink: #fff; --dim: #c5ccd6;
    --sev-clar: #5f7a8c; --sev-low: #2e7d32; color-scheme: light; }
  body { background: #fff; color: #111; }
}

/* W8: inline "+ add building" */
.addloc { margin: -.6rem 0 .8rem; }
.addloc-form { display: grid; gap: .45rem; margin-top: .45rem; padding: .6rem; border: 1px dashed var(--line); border-radius: 8px; background: var(--card); }
.addloc-form input, .addloc-form select { min-height: 44px; padding: .35rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: inherit; }
.edit-form { display: grid; gap: .2rem; }
.edit-form textarea { min-height: 80px; }
.t-edit .t-n, .chg { white-space: pre-line; font-size: .88rem; }
.chg del { color: #b3261e; } .chg ins { color: #1b7f4a; text-decoration: none; }
