/* TCF1 – mobile-first RTL, system fonts only (no external resources) */
:root {
  --bg: #f3f5f8; --card: #fff; --ink: #1b2430; --muted: #5d6b7c; --line: #dde3ea;
  --brand: #1f3a5f; --brand-2: #2d5a8c;
  --open: #c0392b; --submitted: #b26a00; --closed: #1e8449; --info: #138d90;
  --sev-crit: #7b0d0d; --sev-high: #e67e22; --sev-med: #f1c40f; --sev-low: #5f7a8c;
  --sev-clar: #7e57c2; --sev-pos: #1e8449;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: 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: #e9eef4; 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: 56px;
}
.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; }
.tabs { display: flex; gap: .25rem; padding: .4rem .5rem 0; background: #fff; 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); border-bottom-color: var(--brand); }
.tab-n { background: var(--submitted); color: #fff; border-radius: 99px; font-size: .75rem; padding: 0 .45rem; }
.tab-n:empty { display: none; }

main { max-width: 960px; 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); }
.progress-wrap { margin: .75rem 0; }
.progress { height: 12px; background: #dfe5ec; 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: #fff;
}
@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: #e3e8ee; }
.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: #e9eef4; 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); }
.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: #eef5ff; 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: #e3e8ee; }
.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: #fffaf0; }
.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: #f1f4f7; 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: #fff; resize: vertical; }
.confirm-box { border: 2px dashed var(--brand-2); border-radius: 8px; padding: .6rem; background: #f6f9fc; }
.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: #e3e8ee; }
.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: #dfe5ec; 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: #fdecea; color: #8a1c12; }
.msg-ok { background: #e8f6ee; color: #145a32; }
.notice { padding: .6rem .8rem; border-radius: 8px; background: #fff4de; color: #6b4300; font-weight: 600; }
.notice.ok { background: #e8f6ee; color: #145a32; }

/* 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: #1b2430; color: #fff; 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: #fff; 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); }
.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: #fff; 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: #fff; border-radius: 99px; padding: .15rem .6rem; font-size: .82rem; cursor: pointer; }
.uchip.active { border-color: var(--brand); 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: #fff; }
.ck-row.done { background: #f0faf3; border-color: #bfe3cb; }
.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); background: #e9eef4; 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: #fff; }
.note.k-close { border-inline-start-color: var(--closed); background: #f0faf3; }
.note.k-reopen { border-inline-start-color: var(--open); background: #fff5f4; }
.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: right; }
.tbl th { background: #e9eef4; } .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); }
