:root {
  --navy: #0a2342;
  --cyan: #00aeef;
  --white: #ffffff;
  --paper: #f4f7fb;
  --muted: #5b6b7c;
  --fail: #c0392b;
  --pass: #1e8a4c;
  --due: #d97706;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--paper);
  color: var(--navy);
  min-height: 100dvh;
}
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--navy); color: var(--white);
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
}
.app-header img { height: 36px; width: auto; }
.app-header h1 { font-size: 1.05rem; margin: 0; font-weight: 700; letter-spacing: .02em; }
.app-header .sub { font-size: .72rem; opacity: .8; }
.screen { padding: 14px; max-width: 720px; margin: 0 auto; }
.card {
  background: var(--white);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(10,35,66,.08);
}
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
input, textarea, select {
  width: 100%; font-size: 1rem; padding: 12px;
  border: 1px solid #cdd6e1; border-radius: 10px; background: #fff;
}
.pin-input { letter-spacing: .4em; text-align: center; font-size: 1.4rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; border: 0; border-radius: 10px; padding: 13px 14px;
  font-size: 1rem; font-weight: 700; cursor: pointer;
  background: var(--cyan); color: var(--navy); margin-top: 10px;
}
.btn.navy { background: var(--navy); color: #fff; }
.btn.ghost { background: transparent; color: var(--white); border: 1px solid rgba(255,255,255,.35); width: auto; padding: 6px 10px; font-size: .8rem; margin: 0; }
.btn.pass { background: var(--pass); color: #fff; }
.btn.fail { background: var(--fail); color: #fff; }
.btn.row { flex: 1; margin-top: 0; }
.row-btns { display: flex; gap: 8px; margin-top: 8px; }
.tester-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tester-grid .btn { margin: 0; min-height: 64px; }
.search { margin: 10px 0; }
.area-list, .item-list { list-style: none; padding: 0; margin: 0; }
.area-list li, .item-card {
  background: #fff; border-radius: 12px; padding: 12px;
  margin-bottom: 8px; box-shadow: 0 1px 3px rgba(10,35,66,.07);
}
.area-list button[data-area], .area-list button[data-group] {
  width: 100%; text-align: left; background: none; border: 0;
  font: inherit; color: inherit; padding: 0; cursor: pointer;
}
.area-list .count { float: right; color: var(--cyan); font-weight: 700; }
.meta { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.tag { font-weight: 800; color: var(--navy); }
.badge {
  display: inline-block; font-size: .68rem; font-weight: 700;
  padding: 2px 7px; border-radius: 999px; margin-right: 4px;
  background: #e8f7fd; color: var(--navy);
}
.badge.due { background: #fff3d6; color: var(--due); }
.badge.ok { background: #e5f6ea; color: var(--pass); }
.badge.fail { background: #fde8e6; color: var(--fail); }
.hidden { display: none !important; }
.error { color: var(--fail); font-size: .9rem; margin-top: 8px; }
.note { font-size: .85rem; color: var(--muted); }
.modal {
  position: fixed; inset: 0; background: rgba(10,35,66,.45);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 20; padding: 12px; overflow: hidden;
}
.modal .sheet {
  background: #fff; width: 100%; max-width: 420px;
  border-radius: 16px; padding: 16px 16px 18px;
  margin-top: 8px;
}
.tag-heading {
  font-size: 1rem; font-weight: 800; color: #0a2342; margin-bottom: 8px;
}
.tag-display {
  min-height: 48px; border: 2px solid #0a2342; border-radius: 10px;
  font-size: 1.6rem; font-weight: 800; letter-spacing: .12em;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px; background: #f4f7fb;
}
.keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px;
}
.keypad button {
  height: 52px; border: 0; border-radius: 10px; font-size: 1.25rem; font-weight: 800;
  background: #0a2342; color: #fff; cursor: pointer;
}
.keypad button.key-bs { background: #5b6b7c; }
.keypad button.key-ok { background: #00aeef; color: #0a2342; }

@media print {
  .app-header, .no-print { display: none !important; }
  body { background: #fff; }
  .print-only { display: block !important; }
  .item-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
.print-only { display: none; }

.area-list .count em { font-style: normal; font-weight: 600; color: #d97706; }

.room-head {
  list-style: none;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0a2342;
  padding: 0.85rem 0.2rem 0.25rem;
  border-bottom: 2px solid #00aeef;
  margin-top: 0.35rem;
}

.lic-row { display: flex; align-items: stretch; gap: 8px; }
.lic-prefix {
  display: flex; align-items: center; justify-content: center;
  background: #0a2342; color: #fff; font-weight: 800; letter-spacing: .06em;
  border-radius: 10px; padding: 0 14px; font-size: 1.1rem;
}
.lic-row input { flex: 1; }

.area-row { display: flex; align-items: center; gap: 8px; }
.area-row button[data-area] { flex: 1; }
.btn-x {
  flex: 0 0 auto; border: 0; background: #fde8e6; color: #c0392b;
  font-weight: 700; font-size: .75rem; border-radius: 8px; padding: 8px 10px; cursor: pointer;
}
.badge.miss { background: #eceff3; color: #5b6b7c; }
.item-card.miss { opacity: .72; }

.edit-only { display: none !important; }
body.editing .edit-only { display: block !important; }

.btn-x { display: none !important; }
body.editing .btn-x { display: inline-flex !important; }

.area-list .area-row {
  display: grid !important;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
}
.area-list .area-row > button[data-area] {
  width: auto !important;
  max-width: 100%;
}
.area-list .area-row > .btn-x {
  width: auto !important;
  min-width: 4.6rem;
  justify-self: end;
  background: #c0392b !important;
  color: #fff !important;
  pointer-events: auto;
}

.area-row.prog-green { background: #e5f6ea !important; box-shadow: inset 4px 0 0 #1e8a4c; }
.area-row.prog-yellow { background: #fff6d6 !important; box-shadow: inset 4px 0 0 #d97706; }
.area-row.prog-red { background: #fde8e6 !important; box-shadow: inset 4px 0 0 #c0392b; }

.print-all { display: none; }
@media print {
  body.printing-all .app-header,
  body.printing-all main,
  body.printing-all .modal { display: none !important; }
  body.printing-all .print-all { display: block !important; color: #000; padding: 12px; }
  body.printing-all .print-all h1 { font-size: 18pt; margin: 0 0 4px; color: #0a2342; }
  body.printing-all .print-all h2 { font-size: 13pt; margin: 0 0 12px; }
  body.printing-all .print-all h3 { font-size: 12pt; margin: 16px 0 6px; page-break-after: avoid; }
  body.printing-all .print-all table { width: 100%; border-collapse: collapse; font-size: 9pt; margin-bottom: 12px; page-break-inside: auto; }
  body.printing-all .print-all th, body.printing-all .print-all td { border: 1px solid #333; padding: 3px 5px; text-align: left; }
  body.printing-all .print-all tr { page-break-inside: avoid; }
}

.tag-only { display: flex !important; }
body.editing .tag-only { display: none !important; }

.area-list .area-row { grid-template-columns: 1fr auto auto; }
.btn-ren {
  display: none !important;
  width: auto !important;
  min-width: 4.6rem;
  justify-self: end;
  border: 0; background: #123056; color: #fff;
  font-weight: 700; font-size: .75rem; border-radius: 8px;
  padding: 10px 12px; cursor: pointer;
}
body.editing .btn-ren { display: inline-flex !important; align-items: center; justify-content: center; }

#recycleList .btn-ren { display: inline-flex !important; background: #1e8a4c; }

.tag-big {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: #0a2342;
  margin: 6px 0 2px;
}
.last-tag-hint {
  font-size: .95rem;
  font-weight: 800;
  color: #0a2342;
  margin: 6px 0 10px;
}
