/* EHS QR Reporting – mobile-first styles (public form + admin) */
:root {
  --brand: #0f5132;
  --brand-2: #157347;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f4;
  --card: #ffffff;
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --ok-bg: #ecfdf5;
  --hazard: #c2410c;
  --condition: #b45309;
  --act: #b91c1c;
  --near: #1d4ed8;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.hi { display: block; font-size: .82em; font-weight: 500; color: var(--muted); }
h1 .hi { color: rgba(255,255,255,.85); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp { position: absolute; left: -9999px; top: -9999px; height: 0; overflow: hidden; }

/* ---------- header ---------- */
.top { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; padding: 18px 16px 22px; }
.top-inner { max-width: 640px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; opacity: .95; color: inherit; text-decoration: none; }
.brand-mark { background: #facc15; color: #111; font-weight: 800; font-size: 12px; letter-spacing: .05em; padding: 3px 7px; border-radius: 6px; }
.top h1 { margin: 10px 0 4px; font-size: 24px; line-height: 1.2; }
.top .sub { margin: 0; font-size: 14px; opacity: .9; }

/* ---------- layout ---------- */
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 40px; }
.card { background: var(--card); border-radius: var(--radius); padding: 18px 16px; box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 6px 20px rgba(15,23,42,.05); }
.grid2 { display: grid; gap: 0 14px; }
@media (min-width: 560px) { .grid2 { grid-template-columns: 1fr 1fr; } .card { padding: 24px; } }

.when { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 2px 10px; background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 18px; }
.when span { font-size: 13px; color: var(--muted); font-weight: 600; }
.when strong { font-size: 16px; text-align: right; }
.when small { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.when .hi { display: inline; margin-left: 4px; }

/* ---------- fields ---------- */
.field { border: 0; margin: 0 0 18px; padding: 0; min-width: 0; }
.field > label, .field > legend, .field > .label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 15px; padding: 0; }
.req { color: var(--error); font-weight: 700; }
.opt { color: var(--muted); font-weight: 400; font-size: 13px; }
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: inherit;
  padding: 12px 12px; border: 1.5px solid #cbd5e1; border-radius: 10px; background: #fff;
  min-height: 48px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 120px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #475569 50%), linear-gradient(135deg, #475569 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(21,115,71,.18); }
.other { margin-top: 8px; }
.counter { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.err { color: var(--error); font-size: 13.5px; margin: 6px 0 0; font-weight: 500; }
.err:empty { display: none; }
.has-error input[type=text], .has-error select, .has-error textarea { border-color: var(--error); }
.has-error .types { outline: 2px solid var(--error); outline-offset: 4px; border-radius: 12px; }

/* report type cards */
.types { display: grid; gap: 10px; }
@media (min-width: 560px) { .types { grid-template-columns: 1fr 1fr; } }
.type { --c: var(--brand); position: relative; display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1.5px solid var(--line); border-left: 6px solid var(--c); border-radius: 12px; cursor: pointer; background: #fff; transition: background .15s, border-color .15s; }
.type-hazard { --c: var(--hazard); } .type-unsafe_condition { --c: var(--condition); }
.type-unsafe_act { --c: var(--act); } .type-near_miss { --c: var(--near); }
.type input { margin-top: 3px; width: 20px; height: 20px; accent-color: var(--c); flex: none; }
.type-name { display: block; font-weight: 700; }
.type-name .hi { display: inline; margin-left: 6px; font-size: .85em; }
.type-help { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.type:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 8%, #fff); }

/* photos */
.photo-btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px; min-height: 48px; border: 1.5px dashed #94a3b8; border-radius: 10px; cursor: pointer; font-weight: 600; background: #f8fafc; }
.photo-btn.disabled { opacity: .45; pointer-events: none; }
.photo-btn:focus-within, #photos:focus + .previews { outline: 2px solid var(--brand-2); }
.previews { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.previews:empty { display: none; }
.preview { position: relative; width: 92px; height: 92px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.preview img { width: 100%; height: 100%; object-fit: cover; }
.preview-remove { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(15,23,42,.75); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }

.remember { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); margin: 4px 0 16px; }
.remember input { width: 18px; height: 18px; accent-color: var(--brand-2); }

/* buttons */
.submit { display: block; width: 100%; text-align: center; text-decoration: none; padding: 15px 18px; min-height: 54px; border: 0; border-radius: 12px; background: var(--brand-2); color: #fff; font: inherit; font-size: 17px; font-weight: 700; cursor: pointer; }
.submit .hi { display: inline; color: rgba(255,255,255,.85); margin-left: 6px; }
.submit:hover { background: var(--brand); }
.submit:disabled { opacity: .7; cursor: progress; }
.submit.loading .btn-label::after { content: " – sending…"; }

.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-weight: 500; }
.alert-error { background: var(--error-bg); color: var(--error); border: 1px solid #fecaca; }
.alert-ok { background: var(--ok-bg); color: #065f46; border: 1px solid #a7f3d0; }
.emergency { margin: 16px 4px 0; font-size: 13.5px; color: #7f1d1d; background: #fff1f2; border: 1px solid #fecdd3; border-radius: 10px; padding: 10px 12px; }
.err-list { color: var(--error); }

/* thanks */
.thanks { text-align: center; padding: 30px 20px; }
.thanks h2 { margin: 8px 0; }
.thanks .hi { margin-top: 4px; }
.tick { width: 72px; height: 72px; margin: 0 auto; border-radius: 50%; background: var(--ok-bg); color: var(--brand-2); font-size: 40px; line-height: 72px; font-weight: 800; }
.ref { font-size: 14px; color: var(--muted); margin: 18px 0 4px; }
.ref strong { font-size: 22px; color: var(--ink); letter-spacing: .03em; }
.thanks .submit { margin-top: 22px; }

/* ---------- admin ---------- */
body.admin { background: #f6f7f9; }
.admin-bar { background: var(--brand); color: #fff; }
.admin-bar-inner { max-width: 1200px; margin: 0 auto; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: center; justify-content: space-between; }
.admin-bar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.admin-bar nav a { color: #fff; text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 14px; opacity: .85; }
.admin-bar nav a.active, .admin-bar nav a:hover { background: rgba(255,255,255,.15); opacity: 1; }
.admin-main { max-width: 1200px; margin: 0 auto; padding: 20px 16px 40px; }
.admin h1 { font-size: 22px; margin: 0 0 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: #fff; border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line); border-left: 5px solid var(--c, var(--brand)); }
.stat b { display: block; font-size: 24px; }
.stat span { font-size: 13px; color: var(--muted); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; background: #fff; padding: 12px; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; }
.filters input, .filters select { min-height: 38px; padding: 6px 10px; font-size: 14px; width: auto; }
.filters input[type=date] { font: inherit; font-size: 14px; border: 1.5px solid #cbd5e1; border-radius: 10px; }
.btn { display: inline-block; padding: 9px 14px; border-radius: 9px; border: 1.5px solid var(--brand-2); background: var(--brand-2); color: #fff; font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.secondary { background: #fff; color: var(--brand-2); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 12px; border: 1px solid var(--line); }
table.reports { width: 100%; border-collapse: collapse; font-size: 14px; }
table.reports th, table.reports td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.reports th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; }
table.reports tr:hover td { background: #fafcfb; }
table.reports a { color: var(--brand-2); font-weight: 600; }
.desc-cell { max-width: 360px; color: #334155; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #fff; background: var(--c, #475569); white-space: nowrap; }
.badge.t-hazard { --c: var(--hazard); } .badge.t-unsafe_condition { --c: var(--condition); }
.badge.t-unsafe_act { --c: var(--act); } .badge.t-near_miss { --c: var(--near); }
.badge.m-sent { background: #dcfce7; color: #166534; } .badge.m-failed { background: #fee2e2; color: #991b1b; } .badge.m-pending { background: #fef9c3; color: #854d0e; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: 14px; }
.detail { display: grid; grid-template-columns: 170px 1fr; gap: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.detail dt, .detail dd { margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.detail dt { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: 14px; }
.detail dd { white-space: pre-wrap; word-break: break-word; }
@media (max-width: 560px) { .detail { grid-template-columns: 1fr; } .detail dt { border-bottom: 0; padding-bottom: 2px; } }
.gallery { display: flex; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.gallery img { max-width: 300px; width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.login-card { max-width: 380px; margin: 40px auto; }
.login-card input { margin-bottom: 12px; }
.check-list { list-style: none; padding: 0; margin: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.check-list li { padding: 10px 14px; border-bottom: 1px solid var(--line); }
.check-list li:last-child { border-bottom: 0; }
.ok { color: #166534; font-weight: 600; } .bad { color: var(--error); font-weight: 600; }
