/* ==========================================================================
   पुरावा पत्रक — field tool for SBM-U evidence sheets
   Built for cheap Android phones, outdoors, in sunlight.
   High contrast, big targets, no thin grey text on anything that matters.
   ========================================================================== */

@font-face {
  font-family: 'Noto Sans Devanagari';
  src: url('../fonts/NotoSansDevanagari-Regular.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: block;
}
@font-face {
  font-family: 'Noto Sans Devanagari';
  src: url('../fonts/NotoSansDevanagari-Bold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: block;
}

:root {
  --ink:      #16162E;   /* body text */
  --indigo:   #2E2C8F;   /* Majhi Vasundhara blue — structure */
  --indigo-d: #1F1D6B;
  --amber:    #F5A302;   /* the sheet's own photo-frame yellow — actions */
  --amber-d:  #C98200;
  --paper:    #FFFFFF;
  --mist:     #F1F3F8;
  --line:     #D7DCE8;
  --muted:    #5A6076;
  --red:      #C81E1E;
  --green:    #157A46;

  /* sheet ink */
  --sheet-magenta: #E5007D;
  --sheet-blue:    #1F5FC4;
  --sheet-yellow:  #FFE800;
  --sheet-red:     #D50000;

  --tap: 52px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--mist);
  color: var(--ink);
  font-family: 'Noto Sans Devanagari', system-ui, sans-serif;
  font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body { padding-bottom: env(safe-area-inset-bottom); }
[hidden] { display: none !important; }
i { font-style: normal; color: var(--muted); font-size: .82em; }

/* ── boot ---------------------------------------------------------------- */
.boot { position: fixed; inset: 0; display: grid; place-content: center;
        justify-items: center; gap: 18px; background: var(--paper); z-index: 90; }
.boot p { margin: 0; color: var(--muted); }
.boot-mark { width: 44px; height: 44px; border-radius: 50%;
             border: 4px solid var(--line); border-top-color: var(--indigo);
             animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .boot-mark { animation-duration: 3s; } }

/* ── login --------------------------------------------------------------- */
.login-view { min-height: 100dvh; display: grid; place-items: center; padding: 24px;
              background: linear-gradient(180deg, var(--indigo) 0 38%, var(--mist) 38% 100%); }
.login-card { width: 100%; max-width: 380px; background: var(--paper);
              border-radius: 14px; padding: 28px 22px 22px;
              box-shadow: 0 12px 34px rgba(22,22,46,.18); }
.login-title { margin: 0; font-size: 30px; font-weight: 700; color: var(--indigo); letter-spacing: -.01em; }
.login-sub { margin: 2px 0 22px; color: var(--muted); font-size: 14px; }
.login-foot { margin: 18px 0 0; font-size: 13px; color: var(--muted); text-align: center; line-height: 1.6; }

/* ── chrome -------------------------------------------------------------- */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 6px;
          background: var(--indigo); color: #fff; padding: 10px 8px;
          padding-top: calc(10px + env(safe-area-inset-top)); }
.topbar h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 700; text-align: center; }
.icon-btn { width: var(--tap); height: 44px; border: 0; background: transparent; color: #fff;
            font-size: 26px; line-height: 1; border-radius: 10px; cursor: pointer; }
.icon-btn:active { background: rgba(255,255,255,.16); }

.net-banner { padding: 9px 16px; font-size: 14px; font-weight: 700; color: #43290A;
              background: var(--amber); display: flex; justify-content: space-between; gap: 10px; }
.net-banner button { border: 0; background: rgba(0,0,0,.14); color: #43290A;
                     border-radius: 7px; padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }

.view { min-height: 0; }

/* ── forms --------------------------------------------------------------- */
.field, .field-label { display: block; margin-bottom: 16px; }
.field > span, .field-label { display: block; font-size: 14px; font-weight: 700; margin-bottom: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input[type=text], input[type=email], input[type=password], input[type=date],
select, textarea {
  width: 100%; min-height: var(--tap); padding: 12px 14px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--paper); border: 2px solid var(--line); border-radius: 10px;
}
textarea { min-height: 96px; line-height: 1.7; resize: vertical; }
select { appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235A6076' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 1px; }
input:focus, select:focus, textarea:focus { border-color: var(--indigo); outline: none; }

/* ── buttons ------------------------------------------------------------- */
.btn { min-height: var(--tap); padding: 0 20px; border: 2px solid transparent; border-radius: 10px;
       font: inherit; font-size: 16px; font-weight: 700; cursor: pointer;
       display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary { background: var(--amber); color: #3A2400; }
.btn-primary:active { background: var(--amber-d); }
.btn-primary[disabled] { background: var(--line); color: var(--muted); cursor: default; }
.btn-ghost { background: var(--paper); color: var(--indigo); border-color: var(--line); }
.btn-ghost:active { background: var(--mist); }
.btn-block { width: 100%; }
.btn-lg { width: 100%; min-height: 56px; font-size: 17px; }
.btn-sm { min-height: 40px; font-size: 14px; padding: 0 14px; }

.msg { margin: 0 0 12px; padding: 10px 12px; border-radius: 8px; font-size: 14px;
       background: #FDECEC; color: #8A1414; font-weight: 700; }

/* ── list ---------------------------------------------------------------- */
.list-body { padding: 14px 14px 96px; display: grid; gap: 10px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
        padding: 13px 14px; display: grid; gap: 5px; }
.card-top { display: flex; align-items: baseline; gap: 8px; }
.card-title { font-weight: 700; font-size: 15px; flex: 1;
              overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 13px; color: var(--muted); }
.card-actions { display: flex; gap: 8px; margin-top: 6px; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.synced  { background: var(--green); }
.dot.pending { background: var(--amber); }
.dot.failed  { background: var(--red); }

.empty { text-align: center; padding: 64px 24px; color: var(--muted); }
.empty strong { display: block; font-size: 17px; color: var(--ink); margin-bottom: 6px; }

.fab { position: fixed; right: 16px; bottom: calc(18px + env(safe-area-inset-bottom));
       min-height: 56px; padding: 0 24px; border: 0; border-radius: 28px;
       background: var(--amber); color: #3A2400; font: inherit; font-size: 17px; font-weight: 700;
       box-shadow: 0 8px 22px rgba(22,22,46,.26); cursor: pointer; z-index: 15; }

/* ── form view ----------------------------------------------------------- */
.form-view, .done-view { display: flex; flex-direction: column; min-height: calc(100dvh - 64px); }
.form-body { flex: 1; padding: 16px 14px 20px; }
.action-bar { position: sticky; bottom: 0; display: flex; gap: 10px; padding: 12px 14px;
              padding-bottom: calc(12px + env(safe-area-inset-bottom));
              background: var(--paper); border-top: 1px solid var(--line); }
.action-bar .btn { flex: 1; }

.photo-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.photo-strip:empty { display: none; }
.thumb { position: relative; aspect-ratio: 4/3; border-radius: 8px; overflow: hidden;
         background: var(--mist); border: 2px solid var(--sheet-yellow); }
.thumb img { width: 100%; height: 100%; object-fit: cover; object-position: bottom; display: block; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 26px; height: 26px;
                border: 0; border-radius: 50%; background: rgba(0,0,0,.66); color: #fff;
                font-size: 15px; line-height: 26px; padding: 0; cursor: pointer; }
.geo-note { margin: 0; font-size: 13px; color: var(--muted); }

.preview-block { margin-top: 20px; }
.preview-frame { background: var(--mist); border: 1px solid var(--line); border-radius: 10px;
                 padding: 10px; overflow: hidden; display: flex; justify-content: center; }
#preview-scaler { transform-origin: top center; }

/* ── done ---------------------------------------------------------------- */
.done-body { flex: 1; display: grid; align-content: start; justify-items: center;
             gap: 6px; padding: 44px 22px; text-align: center; }
.done-mark { width: 66px; height: 66px; border-radius: 50%; background: var(--green); color: #fff;
             font-size: 34px; line-height: 66px; margin-bottom: 8px; }
.done-body h2 { margin: 0; font-size: 22px; }
.done-name { margin: 0; font-size: 13px; color: var(--muted); word-break: break-all; }
.done-sync { margin: 4px 0 22px; font-size: 14px; font-weight: 700; }
.done-actions { width: 100%; max-width: 340px; display: grid; gap: 10px; }

/* ── admin --------------------------------------------------------------- */
.admin-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px 14px 0; }
.admin-filters select { grid-column: 1 / -1; }
.admin-filters .btn { grid-column: 1 / -1; }

/* ── menu ---------------------------------------------------------------- */
.menu-scrim { position: fixed; inset: 0; z-index: 40; background: rgba(22,22,46,.45);
              display: flex; align-items: flex-end; }
.menu-card { width: 100%; background: var(--paper); border-radius: 16px 16px 0 0; padding: 8px 8px 16px;
             padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.menu-who { margin: 12px 14px 8px; font-size: 14px; color: var(--muted); }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: var(--tap);
             padding: 0 14px; border: 0; background: transparent; border-radius: 10px;
             font: inherit; font-size: 16px; font-weight: 700; color: var(--ink);
             text-align: left; cursor: pointer; }
.menu-item:active { background: var(--mist); }
.menu-item.danger { color: var(--red); }
.menu-item.quiet { color: var(--muted); font-weight: 400; justify-content: center; }

/* ── toast --------------------------------------------------------------- */
.toast { position: fixed; left: 50%; transform: translateX(-50%);
         bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 60;
         max-width: 88vw; padding: 12px 18px; border-radius: 10px;
         background: var(--ink); color: #fff; font-size: 14px; font-weight: 700;
         box-shadow: 0 8px 22px rgba(0,0,0,.3); }

/* ==========================================================================
   THE A4 SHEET
   Fixed 1240 x 1754 px = A4 at 150 DPI. Never responsive: if this inherits a
   phone viewport width the capture is 360px wide and the print is unusable.
   The preview scales it with transform only, which does not change layout.
   ========================================================================== */
#stage { position: absolute; left: -99999px; top: 0; width: 1240px; height: 1754px; }

.sheet {
  width: 1240px; height: 1754px; position: relative; overflow: hidden;
  background: #fff; color: #000;
  font-family: 'Noto Sans Devanagari', sans-serif;
  padding: 47px;                      /* 8mm safe inset */
  display: flex; flex-direction: column;
}
.sheet-inner { flex: 1; border: 1px solid #000; padding: 22px 26px 26px;
               display: flex; flex-direction: column; position: relative; }

.sheet-head { border: 1px solid #000; padding: 14px 18px;
              display: flex; align-items: center; justify-content: space-around; gap: 14px; }
.sheet-head img { display: block; object-fit: contain; }

.sheet-title { margin: 20px 0 0; text-align: center; font-size: 52px; font-weight: 700;
               color: var(--sheet-magenta); line-height: 1.2; }
.sheet-code  { margin: 6px 0 0; text-align: center; font-size: 32px; font-weight: 700;
               color: var(--sheet-blue); }
.sheet-line  { margin: 12px auto 0; max-width: 86%; text-align: center;
               font-size: 27px; line-height: 1.65; }

.sheet-grid { flex: 1; display: grid; gap: 20px; align-content: center;
              padding: 18px 0; position: relative; z-index: 1; }
.sheet-grid.n2 { grid-template-columns: 1fr 1fr; }
.sheet-grid.n4 { grid-template-columns: 1fr 1fr; }
.sheet-grid.n6 { grid-template-columns: 1fr 1fr; }
.sheet-cell { aspect-ratio: 4/3; border: 9px solid var(--sheet-yellow); border-radius: 14px;
              overflow: hidden; background: #EFEFEF; }
.sheet-cell img { width: 100%; height: 100%; object-fit: cover; object-position: bottom; display: block; }

.sheet-mark { position: absolute; left: 50%; top: 54%; transform: translate(-50%,-50%);
              width: 58%; z-index: 0; pointer-events: none; }
.sheet-foot { margin-top: auto; text-align: center; font-size: 38px; font-weight: 700;
              color: var(--sheet-red); padding-top: 12px; }
.sheet-agency { position: absolute; right: 26px; bottom: 22px; height: 54px; }

/* ── sign-up, approval gate, staff panel ────────────────────────────────── */
.link { color: var(--indigo); font-weight: 700; text-decoration: underline; }

.pending-mark { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.pend-who { margin: 0 0 20px; font-size: 14px; color: var(--muted); word-break: break-all; }

.tabs { display: flex; gap: 6px; padding: 12px 14px 0; }
.tab { flex: 1; min-height: 44px; border: 2px solid var(--line); border-radius: 10px;
       background: var(--paper); font: inherit; font-size: 15px; font-weight: 700;
       color: var(--muted); cursor: pointer; display: flex; align-items: center;
       justify-content: center; gap: 6px; }
.tab.is-on { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.badge { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
         background: var(--amber); color: #3A2400; font-size: 13px; line-height: 22px; }

.sect { margin: 22px 14px 0; font-size: 15px; color: var(--muted); }

.staff-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
              padding: 13px 14px; display: grid; gap: 8px; }
.staff-card.is-new { border-color: var(--amber); border-width: 2px; }
.staff-name { font-weight: 700; font-size: 16px; }
.staff-meta { font-size: 13px; color: var(--muted); word-break: break-all; }
.staff-want { font-size: 14px; background: var(--mist); border-radius: 8px; padding: 8px 10px; }
.staff-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.staff-controls select { grid-column: 1 / -1; }
.staff-off { opacity: .55; }

/* ── camera ─────────────────────────────────────────────────────────────── */
.cam { position: fixed; inset: 0; z-index: 80; background: #000; display: flex;
       flex-direction: column; }
.cam video { flex: 1; width: 100%; object-fit: cover; background: #000; }
.cam-status { position: absolute; top: calc(14px + env(safe-area-inset-top)); left: 50%;
              transform: translateX(-50%); max-width: 90vw; padding: 9px 16px;
              border-radius: 20px; background: rgba(0,0,0,.72); color: #fff;
              font-size: 14px; font-weight: 700; text-align: center; }
.cam-status.ok   { background: rgba(21,122,70,.9); }
.cam-status.warn { background: rgba(200,30,30,.9); }
.cam-bar { display: flex; align-items: center; justify-content: space-between;
           padding: 18px 22px; padding-bottom: calc(18px + env(safe-area-inset-bottom));
           background: #000; }
.cam-btn { min-width: 64px; min-height: 46px; border: 0; background: transparent;
           color: #fff; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
.cam-count { min-width: 64px; color: #fff; font-size: 15px; font-weight: 700; text-align: right; }
.cam-shot { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff;
            background: var(--amber); cursor: pointer; }
.cam-shot[disabled] { background: #555; border-color: #888; }

/* ── ULB manager ────────────────────────────────────────────────────────── */
.seal-row { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.seal-prev { height: 64px; width: auto; border: 1px solid var(--line); border-radius: 8px;
             padding: 4px; background: #fff; }
.checkline { display: flex; align-items: center; gap: 10px; }
.checkline input { width: 22px; height: 22px; min-height: 0; flex: none; }
.checkline span { font-weight: 400; font-size: 15px; margin: 0; }
.a-count { margin: 10px 14px 0; font-size: 14px; font-weight: 700; color: var(--muted); }
.ulb-row { display: flex; align-items: center; gap: 12px; background: var(--paper);
           border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; }
.ulb-row img { height: 42px; width: auto; flex: none; }
.ulb-row div { flex: 1; min-width: 0; }
.ulb-row .n { font-weight: 700; font-size: 15px; }

/* ── merged sheet viewer ────────────────────────────────────────────────── */
.viewer { padding: 0 14px 16px; }
.viewer iframe { width: 100%; height: 78vh; border: 1px solid var(--line);
                 border-radius: 12px; background: var(--paper); }
.tpl-preview { padding: 12px 14px; background: var(--mist); border-radius: 10px;
               font-size: 15px; line-height: 1.7; min-height: 52px; }
.act-row { display: flex; gap: 8px; align-items: center; background: var(--paper);
           border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.act-row input { flex: 1; min-height: 42px; }
.act-row .nm { flex: none; width: 34%; font-size: 13px; font-weight: 700; color: var(--muted); }

.scope { flex: none; font-size: 12px; font-weight: 700; color: var(--indigo);
         background: var(--mist); border-radius: 6px; padding: 3px 8px; }
.card .a-phrase, .card .a-tpl { width: 100%; margin-top: 4px; }
.card .a-tpl { min-height: 60px; font-size: 14px; }
.admin-filters { grid-template-columns: 1fr 1fr; }
.admin-filters select, .admin-filters .btn { grid-column: 1 / -1; }

.bar-stack { flex-direction: column; gap: 8px; }
.bar-stack .btn { width: 100%; }

.staff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin-top: 4px; }
.staff-grid div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.staff-grid b { font-size: 12px; font-weight: 700; color: var(--muted); }
.staff-grid span { font-size: 14px; word-break: break-word; }
.who-chip { display: block; margin: 8px 14px 0; padding: 8px 12px; border: 0; border-radius: 8px;
            background: var(--amber); color: #3A2400; font: inherit; font-size: 13px;
            font-weight: 700; cursor: pointer; text-align: left; width: calc(100% - 28px); }

/* ── select, repair, delete ─────────────────────────────────────────────── */
.bulk-bar { display: flex; align-items: center; gap: 12px; margin: 10px 14px 0;
            padding: 10px 12px; background: var(--paper); border: 1px solid var(--line);
            border-radius: 10px; }
.bulk-bar .checkline { margin: 0; flex: none; }
.picked { flex: 1; font-size: 13px; font-weight: 700; color: var(--muted); }
.card.is-picked { border-color: var(--indigo); border-width: 2px; }
.pick-row { display: flex; align-items: flex-start; gap: 10px; }
.pick-row input { width: 22px; height: 22px; min-height: 0; flex: none; margin-top: 2px; }
.pick-row > div { flex: 1; min-width: 0; }

.fix-card { width: 100%; max-height: 92vh; overflow-y: auto; background: var(--paper);
            border-radius: 16px 16px 0 0; padding: 20px 16px;
            padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.fix-title { margin: 0 0 4px; font-size: 20px; }
.fix-note { margin: 0 0 18px; font-size: 14px; color: var(--muted); line-height: 1.6; }

.owner-tag { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 6px;
             background: var(--indigo); color: #fff; font-size: 11px; font-weight: 700;
             vertical-align: middle; }

.tick-list { display: grid; gap: 4px; margin-bottom: 16px; max-height: 34vh; overflow-y: auto;
             border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.tick-list label { display: flex; align-items: center; gap: 10px; min-height: 42px;
                   padding: 0 8px; border-radius: 8px; cursor: pointer; }
.tick-list label:active { background: var(--mist); }
.tick-list input { width: 20px; height: 20px; min-height: 0; flex: none; }
.tick-list span { font-size: 15px; }
.tick-list .none { color: var(--muted); font-size: 14px; padding: 8px; }

.locked { align-self: center; font-size: 12px; font-weight: 700; color: var(--muted);
          background: var(--mist); border-radius: 6px; padding: 6px 10px; }
