/* =====================================================================
   Daily Site Reports — styles
   Mobile-first. Big touch targets (usable with work gloves), high
   contrast (readable in direct sunlight), light + dark themes.
   ===================================================================== */

:root {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --border:    #cbd5e1;
  --text:      #0f172a;
  --text-dim:  #475569;
  --accent:    #ea580c;
  --accent-ink:#ffffff;
  --ok:        #15803d;
  --warn:      #b45309;
  --danger:    #b91c1c;
  --shadow:    0 1px 2px rgba(15,23,42,.08), 0 4px 12px rgba(15,23,42,.06);
  --radius:    14px;
  --tap:       52px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
  --safe-t:    env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0b1220;
    --surface:   #131c2e;
    --surface-2: #1a2437;
    --border:    #2c3a52;
    --text:      #e8eef7;
    --text-dim:  #9aabc2;
    --accent:    #f97316;
    --accent-ink:#1a0f04;
    --ok:        #4ade80;
    --warn:      #fbbf24;
    --danger:    #f87171;
    --shadow:    0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  }
}

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

/* `display:flex` on .sheet/.lightbox would otherwise beat the hidden
   attribute and leave an invisible layer swallowing every tap. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: contain;
}

body { padding-bottom: calc(74px + var(--safe-b)); }
body.no-tabs { padding-bottom: var(--safe-b); }

/* ---------------- banners ---------------- */
/* In normal flow, not sticky — otherwise it and the sticky top bar both
   pin to top:0 and print on top of each other. */
.banner {
  position: relative; z-index: 60;
  padding: 8px 14px; font-size: 14px; font-weight: 600; text-align: center;
}
.banner--warn { background: var(--warn); color: #1a1206; }
.banner--demo { background: #0ea5e9; color: #04202b; }

/* ---------------- top bar ---------------- */
#topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + var(--safe-t)) 12px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
#topbar h1 {
  flex: 1; margin: 0; font-size: 17px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 4px; }

.icon-btn {
  min-width: 42px; height: 42px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 0; border-radius: 10px;
  color: var(--text); font-size: 19px; font-weight: 700; cursor: pointer;
}
.icon-btn:active { background: var(--surface-2); }

.pill {
  min-width: 26px; height: 26px; padding: 0 8px; border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
}
.pill--queue { background: var(--warn); color: #1a1206; }

/* ---------------- layout ---------------- */
main { padding: 14px 14px 24px; max-width: 780px; margin: 0 auto; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card--tap { cursor: pointer; }
.card--tap:active { background: var(--surface-2); }

h2 { font-size: 20px; margin: 4px 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; color: var(--text-dim);
     text-transform: uppercase; letter-spacing: .06em; }
p  { margin: 0 0 10px; }
.muted { color: var(--text-dim); }
.small { font-size: 13.5px; }
.center { text-align: center; }
.row { display: flex; gap: 10px; align-items: center; }
.row--between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }

/* ---------------- forms ---------------- */
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }

input, select, textarea {
  width: 100%; min-height: var(--tap);
  padding: 12px 14px;
  font-size: 16px;                 /* 16px stops iOS zooming on focus */
  font-family: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  appearance: none;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
                    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position: calc(100% - 20px) 22px, calc(100% - 14px) 22px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
.field { margin-bottom: 16px; }
.field--half { flex: 1; margin-bottom: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 12px 20px;
  font-size: 16px; font-weight: 700; font-family: inherit;
  border: 1.5px solid transparent; border-radius: 12px;
  cursor: pointer; text-decoration: none;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--ghost   { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn--ok      { background: var(--ok);     color: #04140a; }
.btn--danger  { background: transparent;   color: var(--danger); border-color: var(--danger); }
.btn--block   { width: 100%; }
.btn--lg      { min-height: 62px; font-size: 18px; }
.btn:active   { transform: translateY(1px); }
.btn[disabled]{ opacity: .5; pointer-events: none; }

/* ---------------- photos ---------------- */
.photo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.photo {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
}
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo__del {
  position: absolute; top: 4px; right: 4px;
  width: 30px; height: 30px; border-radius: 50%;
  background: rgba(0,0,0,.68); color: #fff; border: 0;
  font-size: 17px; line-height: 1; cursor: pointer;
}
.photo-add {
  aspect-ratio: 1; border: 2px dashed var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.photo-add span:first-child { font-size: 26px; }

/* ---------------- report list ---------------- */
.rep {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
}
.rep:last-child { border-bottom: 0; }
.rep:active { background: var(--surface-2); }
.rep__thumb {
  width: 56px; height: 56px; flex: 0 0 56px; border-radius: 10px;
  object-fit: cover; background: var(--surface-2); border: 1px solid var(--border);
}
.rep__thumb--empty { display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: var(--text-dim); }
.rep__title { font-weight: 700; margin-bottom: 2px; }
.rep__meta  { font-size: 13px; color: var(--text-dim); }
.rep__body  { font-size: 14px; margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; }
.list-card { padding: 0; overflow: hidden; }

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.tag--submitted { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.tag--approved  { background: color-mix(in srgb, var(--ok)   22%, transparent); color: var(--ok); }
.tag--rejected  { background: color-mix(in srgb, var(--danger) 20%, transparent); color: var(--danger); }
.tag--pending   { background: color-mix(in srgb, #0ea5e9 22%, transparent); color: #0284c7; }

/* ---------------- tab bar ---------------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55;
  display: flex; background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}
.tab {
  flex: 1; min-height: 62px; padding: 8px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-dim); font-size: 11.5px; font-weight: 700; font-family: inherit;
}
.tab-ico { font-size: 20px; line-height: 1; }
.tab.is-active { color: var(--accent); }
.tab--primary .tab-ico {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.tab--primary { color: var(--accent); }

/* ---------------- sheet / modal ---------------- */
.sheet { position: fixed; inset: 0; z-index: 90; display: flex; align-items: flex-end; }
.sheet__backdrop { position: absolute; inset: 0; background: rgba(2,6,23,.6); }
.sheet__panel {
  position: relative; width: 100%; max-height: 88vh; overflow-y: auto;
  background: var(--surface); border-radius: 20px 20px 0 0;
  padding: 20px 18px calc(20px + var(--safe-b));
  animation: slideUp .18s ease-out;
}
@keyframes slideUp { from { transform: translateY(18px); opacity: .5 } to { transform: none; opacity: 1 } }
@media (min-width: 620px) {
  .sheet { align-items: center; justify-content: center; }
  .sheet__panel { max-width: 520px; border-radius: 18px; }
}

/* ---------------- toast ---------------- */
.toast {
  position: fixed; left: 50%; bottom: calc(88px + var(--safe-b));
  transform: translateX(-50%); z-index: 100;
  max-width: 90vw; padding: 12px 18px; border-radius: 12px;
  background: #0f172a; color: #f8fafc; font-size: 14.5px; font-weight: 600;
  box-shadow: 0 8px 28px rgba(0,0,0,.35);
}
.toast--err { background: var(--danger); color: #fff; }
.toast--ok  { background: var(--ok);     color: #04140a; }

/* ---------------- lightbox ---------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 110; background: rgba(2,6,23,.94);
  display: flex; align-items: center; justify-content: center;
}
.lightbox img { max-width: 96vw; max-height: 88vh; object-fit: contain; }
.lightbox__close {
  position: absolute; top: calc(12px + var(--safe-t)); right: 14px;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.15); color: #fff; border: 0; font-size: 26px; cursor: pointer;
}

/* ---------------- misc ---------------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-dim); }
.empty__ico { font-size: 44px; margin-bottom: 10px; opacity: .5; }
.spinner {
  width: 22px; height: 22px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; margin: 30px auto;
}
@keyframes spin { to { transform: rotate(360deg) } }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0;
      border-bottom: 1px solid var(--border); font-size: 14.5px; }
.kv:last-child { border-bottom: 0; }
.kv__k { color: var(--text-dim); }
.kv__v { font-weight: 600; text-align: right; }

/* ---------------- print (PDF export) ---------------- */
@media print {
  #topbar, #tabbar, .banner, .btn, .no-print,
  #toast, #sheet, #lightbox { display: none !important; }
  body { padding: 0; background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 1px solid #999; break-inside: avoid; page-break-inside: avoid; }
  .print-report { break-after: page; page-break-after: always; }
  .print-report:last-child { break-after: auto; page-break-after: auto; }
  .photo-grid { grid-template-columns: repeat(3, 1fr); }
  .photo { aspect-ratio: 4/3; }
}

/* =====================================================================
   Admin: tiles, stock, material rows, checkbox lists
   ===================================================================== */

/* --- admin hub tiles --- */
.tile { display: flex; align-items: center; gap: 14px; }
.tile__ico { font-size: 28px; width: 44px; text-align: center; flex: 0 0 44px; }
.tile__title { font-size: 17px; font-weight: 700; }
.tile__sub { font-size: 13.5px; color: var(--text-dim); margin-top: 2px; }
.chev { font-size: 26px; color: var(--text-dim); line-height: 1; flex: 0 0 auto; }

/* --- material rows on the report form --- */
.mat-wrap { margin-bottom: 12px; }
.mat-row {
  display: grid; grid-template-columns: 1fr 96px 40px;
  gap: 8px; align-items: center;
}
.mat-row select, .mat-row input { min-height: 48px; padding: 10px; }
.mat-row .icon-btn { min-width: 40px; height: 48px; color: var(--danger); }
.mat-row input.is-over { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, var(--surface-2)); }

.mat-hint { font-size: 12.5px; color: var(--text-dim); margin: 5px 2px 0; }
.mat-hint--over { color: var(--warn); font-weight: 700; }

/* --- stock figures --- */
.stock-num { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stock-num--neg { color: var(--danger); }
.stock-num--in  { color: var(--ok); }
.stock-num--out { color: var(--text-dim); }
.stock-big {
  font-size: 34px; font-weight: 800; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* --- movement direction badge --- */
.mv {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; font-weight: 800;
}
.mv--in     { background: color-mix(in srgb, var(--ok) 20%, transparent);     color: var(--ok); }
.mv--out    { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.mv--adjust { background: color-mix(in srgb, #0ea5e9 20%, transparent);       color: #0284c7; }

/* --- checkbox list (site assignment) --- */
.check-list {
  border: 1.5px solid var(--border); border-radius: 12px;
  overflow: hidden; max-height: 260px; overflow-y: auto;
}
.check {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: var(--tap);
  border-bottom: 1px solid var(--border);
  font-weight: 500; margin: 0; cursor: pointer;
}
.check:last-child { border-bottom: 0; }
.check input {
  width: 22px; height: 22px; min-height: 22px; flex: 0 0 22px;
  accent-color: var(--accent); margin: 0; padding: 0;
}

/* =====================================================================
   Attachments, floor/axis, one-tap site filter
   ===================================================================== */

/* --- site filter chips above the reports list --- */
.chiprow {
  display: flex; gap: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 2px 2px 12px;
  scrollbar-width: none;
}
.chiprow::-webkit-scrollbar { display: none; }
.fchip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 40px; padding: 8px 14px;
  border: 1.5px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 600; font-family: inherit; line-height: 1;
  white-space: nowrap; cursor: pointer;
}
.fchip:active { transform: translateY(1px); }
.fchip.is-on {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.fchip__n {
  font-size: 12px; font-weight: 700; opacity: .65;
  font-variant-numeric: tabular-nums;
}

/* --- floor / axis line --- */
.place {
  color: var(--accent); font-weight: 600; font-size: 13px; margin-top: 2px;
}

/* --- attachment list --- */
.filelist {
  border: 1px solid var(--border); border-radius: 12px;
  overflow: hidden; margin-bottom: 12px;
}
.filerow {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; min-height: var(--tap);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.filerow:last-child { border-bottom: 0; }
.filerow--tap { cursor: pointer; }
.filerow--tap:active { background: var(--surface); }
.filerow__ico { font-size: 22px; flex: 0 0 26px; text-align: center; }
.filerow__name {
  display: block; font-weight: 600; font-size: 14.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.filerow__meta {
  display: block; font-size: 12.5px; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.filerow__open {
  flex: 0 0 auto; font-size: 13px; font-weight: 700; color: var(--accent);
}
.filerow .icon-btn { flex: 0 0 40px; min-width: 40px; height: 40px; color: var(--danger); }
