:root {
  --teal-900: #0d3b3f;
  --teal-700: #0d5c63;
  --teal-500: #1a8a8f;
  --paper: #f4f7f6;
  --ink: #1c2b2b;
  --ink-soft: #5b6b6a;
  --line: #d7e1df;
  --amber: #b6791e;
  --amber-bg: #fdf1de;
  --red: #a3352b;
  --red-bg: #fbe9e7;
  --green: #2f6b3f;
  --green-bg: #e9f3ea;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(13,59,63,0.12);
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: 32px; }

/* Row pairing "Admin login" (left) with the "Latest report" shortcut (right)
   on the box login screen only — no login needed for the report link, see
   server.js's public-latest-report handler. */
.login-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.login-bottom-row .link-btn { margin: 0; }
.public-report-link {
  color: var(--teal-700);
  font-weight: 700;
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}
.public-report-link:active { color: var(--teal-900); }

.topbar {
  background: var(--teal-700);
  color: #fff;
  padding: 18px 20px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar .box-no { font-weight: 400; opacity: 0.85; font-size: 0.85rem; }
.topbar.topbar-home { flex-direction: column; justify-content: center; align-items: center; gap: 2px; text-align: center; }
.topbar-title { font-weight: 700; }
.topbar-subtitle { font-weight: 400; font-style: italic; font-size: 0.72rem; color: #fff; opacity: 0.85; }

.page-home-label { margin: 16px 16px 0; color: var(--teal-900); font-size: 1.3rem; }

.panel {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin: 16px;
  padding: 20px;
}

h1, h2, h3 { margin: 0 0 12px; color: var(--teal-900); }
h2 { font-size: 1.1rem; }
p { line-height: 1.5; color: var(--ink-soft); }

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  margin: 14px 0 6px;
}

input[type="text"], input[type="password"], input[type="date"], input[type="email"], input[type="file"], textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--teal-500); outline-offset: 1px; }
input.invalid { border-color: var(--red); }

.date-field { display: flex; gap: 6px; align-items: stretch; position: relative; }
.date-field input[type="text"] { flex: 1 1 auto; min-width: 0; }
.date-pick-btn {
  flex: 0 0 auto; width: 44px; margin: 0; padding: 0;
  border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.date-pick-btn:active { background: #eef2f1; }
/* Fully hidden — reachable only via the icon button's showPicker() call, so
   the native control's own day/month/year segments are never shown to the
   user (that visible-segment look is exactly what this component avoids). */
.date-pick-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; margin: 0; }
table.checklist .date-pick-btn { width: 32px; font-size: 0.9rem; }

button {
  width: 100%;
  padding: 14px;
  margin-top: 18px;
  border: none;
  border-radius: 8px;
  background: var(--teal-700);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
}

/* Two buttons side by side, sharing the row width equally. */
.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
}
/* FA dashboard's Log out / Admin Sign-in row only — narrower, natural-width
   buttons with more breathing room between them, rather than stretching
   edge to edge (per user feedback — the stretched version left almost no
   gap between the two buttons). */
.panel.button-row { gap: 75px; justify-content: center; }
.panel.button-row button { width: auto; flex: 0 1 auto; margin-top: 0; padding-left: 24px; padding-right: 24px; }
.button-row .home-link-btn { flex: 1 1 0; margin: 0; }
button:active { background: var(--teal-900); }
button.secondary { background: #fff; color: var(--teal-700); border: 2px solid var(--teal-700); }
button.danger { background: var(--red); }
button:disabled { background: #b9c4c3; cursor: not-allowed; }

.banner {
  border-radius: 8px;
  padding: 12px 14px;
  margin: 16px 16px 0;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.banner.warn { background: var(--amber-bg); color: var(--amber); }
.banner.danger { background: var(--red-bg); color: var(--red); }
.banner.ok { background: var(--green-bg); color: var(--green); }

.box-registry-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 8px; }
.box-registry-table th, .box-registry-table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.box-registry-table .view-box-btn { width: auto; padding: 6px 10px; font-size: 0.8rem; margin: 0; }
/* Used both in the registry table and on the single-box detail page. */
.confirm-status.ok { color: var(--green); font-weight: 700; }
.confirm-status.warn { color: var(--amber); font-weight: 700; }
.confirm-status.danger { color: var(--red); font-weight: 700; }

.filelist { list-style: none; margin: 0; padding: 0; }
.filelist li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 0.92rem;
}
.filelist li:last-child { border-bottom: none; }
.filelist .tag { font-size: 0.75rem; color: var(--ink-soft); }
.filelist a { color: var(--teal-700); font-weight: 700; text-decoration: none; }

table.checklist { width: 100%; border-collapse: collapse; font-size: 0.78rem; margin-top: 10px; }
table.checklist th, table.checklist td { border: 1px solid var(--line); padding: 6px 4px; text-align: center; }
table.checklist th { background: var(--teal-700); color: #fff; font-weight: 600; }
table.checklist td.item-name { text-align: left; }
table.checklist td.locked { background: #eef2f1; color: var(--ink-soft); }

.checkbox-cell input[type="checkbox"] { width: 20px; height: 20px; }

table.checklist input[type="number"],
table.checklist input[type="text"],
table.checklist input[type="date"] {
  width: 100%;
  min-width: 64px;
  padding: 4px 6px;
  font-size: 0.85rem;
}
table.checklist input:disabled { background: #eef2f1; color: var(--ink-soft); }

.qr-box {
  width: 108px; height: 108px; /* on-screen preview size only */
  margin: 16px auto;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}
/* qrModule.js renders at ~319px (27mm at print-quality 300dpi) so the exported
   PNG stays crisp — scale it down to the preview box on screen only; canvas.width/
   height (the actual pixel buffer exportQRAsPNG reads) are untouched by this. */
.qr-box canvas, .qr-box img { width: 100%; height: 100%; display: block; }

.helptext { font-size: 0.78rem; color: var(--ink-soft); margin-top: 4px; }

.link-btn { background: none; border: none; color: var(--teal-700); font-weight: 700; padding: 0; margin: 8px 0 0; width: auto; text-decoration: underline; }
.home-link-btn { display: block; margin: 12px auto; text-align: center; text-decoration: none; font-size: 0.95rem; }

/* TEST-ONLY — remove this rule along with the .test-only panel in js/app.js's
   screenLogin before production. Deliberately loud/dashed so it can't be
   mistaken for a real production control. */
.panel.test-only {
  border: 2px dashed var(--amber);
  background: var(--amber-bg);
}
.panel.test-only .helptext { color: var(--amber); }
.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--amber);
  cursor: pointer;
}
.toggle-row input[type="checkbox"] { width: 20px; height: 20px; flex: none; }
