:root {
  --red: #c80405;
  --red-dark: #9e0304;
  --ink: #1e1e1d;
  --ink-2: #545253;
  --ink-3: #85827f;
  --line: #ddd9d2;
  --line-2: #ecead5;
  --bg: #f4f2ee;
  --card: #ffffff;
  --soft: #faf9f7;
  --green: #187a3c;
  --green-bg: #e3f3e8;
  --amber: #9a5b00;
  --amber-bg: #fdf0d8;
  --blue: #1d5fa8;
  --blue-bg: #e2edf9;
  --grey-bg: #ecebe8;
  --red-bg: #fbe3e3;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f2f0ec; --ink-2: #c4c0ba; --ink-3: #8d8983; --line: #3a3835; --line-2: #2c2a28;
    --bg: #141312; --card: #1f1e1c; --soft: #262422; --green: #5bd087; --green-bg: #173323;
    --amber: #f2b552; --amber-bg: #3a2a10; --blue: #7fb3ec; --blue-bg: #172a40; --grey-bg: #2c2a28;
    --red-bg: #3d1515; --red: #e5292a; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--blue); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.hidden { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.bold { font-weight: 650; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap-ok { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stack > * + * { margin-top: 10px; }

/* top bar */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.top .wrap { display: flex; align-items: center; gap: 8px; min-height: 56px; }
.top h1 { font-size: 18px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .logo { height: 34px; width: auto; display: block; }
.iconbtn {
  border: 0; background: transparent; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  font-size: 22px; color: var(--ink);
}
.iconbtn:active { background: var(--grey-bg); }
.who { font-size: 13px; color: var(--ink-3); white-space: nowrap; }

main { padding: 14px 0 calc(110px + var(--safe-b)); }

/* bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabs .wrap { display: grid; grid-template-columns: repeat(4, 1fr); padding: 0 4px; }
.tab {
  border: 0; background: none; padding: 9px 2px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-3); position: relative; min-height: 58px;
}
.tab .ic { font-size: 22px; line-height: 1; }
.tab.on { color: var(--red); }
.tab .badge { position: absolute; top: 4px; left: calc(50% + 8px); }

/* cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 14px; }
.card + .card, .card + .section, .section + .card, .section + .section { margin-top: 14px; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); margin: 18px 4px 8px; display: flex; align-items: center; gap: 8px; }
.list { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); background: none; width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0; }
.item:first-child { border-top: 0; }
button.item:active, .item.tap:active { background: var(--soft); }
.item .sub { font-size: 14px; color: var(--ink-3); }
.chev { color: var(--ink-3); font-size: 20px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); padding: 0 16px; min-height: 48px; font-weight: 650; font-size: 16px; text-decoration: none; color: var(--ink);
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:active { background: var(--red-dark); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--card); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--blue); }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn.small { min-height: 38px; font-size: 14px; padding: 0 12px; border-radius: 10px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.big { min-height: 76px; font-size: 21px; border-radius: 18px; }
.btn.big .ic { font-size: 30px; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btns > .btn { flex: 1 1 140px; }

/* forms */
label.field { display: block; }
label.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 0 0 6px 2px; }
input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%; min-height: 48px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); padding: 10px 12px; font-size: 17px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: transparent; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.stepper button { width: 44px; height: 44px; border: 0; background: var(--soft); font-size: 22px; font-weight: 700; }
.stepper output { min-width: 44px; text-align: center; font-weight: 700; }
.toggle { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.toggle input { width: 24px; height: 24px; accent-color: var(--red); }

/* chips, badges, pills */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 0 14px; min-height: 38px; font-size: 15px; font-weight: 600; white-space: nowrap; color: var(--ink-2); }
.chip.on { background: var(--ink); color: var(--card); border-color: var(--ink); }
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; font-weight: 700; }
.pill { display: inline-flex; align-items: center; gap: 4px; border-radius: 999px; padding: 2px 9px; font-size: 13px; font-weight: 650; white-space: nowrap; }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.amber { background: var(--amber-bg); color: var(--amber); }
.pill.grey { background: var(--grey-bg); color: var(--ink-2); }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.pill.red { background: var(--red-bg); color: var(--red); }

/* status dots */
.dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 16px; font-weight: 800; }
.dot.complete { background: var(--green-bg); color: var(--green); }
.dot.partial { background: var(--amber-bg); color: var(--amber); }
.dot.missing { background: var(--grey-bg); color: var(--ink-3); }
.dot.over { background: var(--blue-bg); color: var(--blue); }

/* progress */
.meter { height: 10px; border-radius: 999px; background: var(--grey-bg); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width .4s; }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--soft); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 24px; line-height: 1.1; }
.stat span { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }

/* boxes */
.thumb { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; background: var(--grey-bg); flex: none; display: grid; place-items: center; color: var(--ink-3); font-size: 22px; }
.boxno { font-weight: 800; font-variant-numeric: tabular-nums; }
.boxcard { padding: 0; overflow: hidden; }
.boxcard .head { display: flex; gap: 12px; padding: 12px 14px; align-items: center; }
.write-on {
  margin: 0 14px 14px; border: 2px dashed var(--line); border-radius: 12px; padding: 10px 12px; display: flex; gap: 10px; align-items: center;
}
.write-on .big { font-size: 26px; font-weight: 850; letter-spacing: .01em; }
.write-on .room { font-size: 18px; font-weight: 800; text-transform: uppercase; color: var(--red); }
.cand { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); min-height: 56px; }
.cand + .cand { margin-top: 8px; }
.cand:active { background: var(--soft); }
.conf { font-size: 13px; font-weight: 700; color: var(--ink-3); }
.photos { display: flex; gap: 8px; overflow-x: auto; }
.photos img { height: 160px; border-radius: 12px; background: var(--grey-bg); }

/* banners */
.banner { border-radius: 12px; padding: 12px 14px; font-size: 15px; display: flex; gap: 10px; align-items: flex-start; }
.banner.warn { background: var(--amber-bg); color: var(--amber); }
.banner.info { background: var(--blue-bg); color: var(--blue); }
.banner.bad { background: var(--red-bg); color: var(--red); }
.banner.good { background: var(--green-bg); color: var(--green); }
.banner .ic { font-size: 18px; line-height: 1.3; }

/* sheet */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; animation: fade .15s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--bg); border-radius: 18px 18px 0 0;
  max-height: 92vh; max-height: 92dvh; overflow-y: auto; animation: up .2s ease-out; padding-bottom: calc(16px + var(--safe-b));
  overscroll-behavior: contain;
}
@media (min-width: 760px) { .sheet { left: 50%; transform: translateX(-50%); width: 720px; } }
.sheet.tall { height: 88vh; height: 88dvh; }
.sheet .grab { position: sticky; top: 0; background: var(--bg); padding: 8px 16px 6px; z-index: 2; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.sheet .grab h2 { font-size: 18px; flex: 1; }
.sheet .body { padding: 14px 16px 4px; }
@keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
@media (min-width: 760px) { @keyframes up { from { opacity: .5; } to { opacity: 1; } } }
@keyframes fade { from { opacity: 0; } }

/* toast */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(76px + var(--safe-b)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--card); border-radius: 12px; padding: 12px 16px; font-size: 15px; font-weight: 600; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: 560px; pointer-events: auto; animation: up .2s; }
.toast.bad { background: var(--red); color: #fff; }

.net { position: sticky; top: calc(56px + env(safe-area-inset-top, 0px)); z-index: 19; background: var(--amber-bg); color: var(--amber); text-align: center; font-size: 14px; font-weight: 650; padding: 6px 12px; }

/* sign-in */
.signin { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.signin .card { width: 100%; max-width: 420px; padding: 22px; }
.signin img { width: 210px; display: block; margin: 0 auto 6px; }
/* The logo has black lettering: give it a light plate in dark mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) img.logo, :root:not([data-theme="light"]) .signin img { background: #fff; border-radius: 10px; padding: 4px 8px; }
}

.spin { width: 18px; height: 18px; border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rot .8s linear infinite; display: inline-block; flex: none; }
@keyframes rot { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 26px 12px; color: var(--ink-3); }
.empty .ic { font-size: 40px; display: block; margin-bottom: 6px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.kbd { font-family: ui-monospace, Menlo, monospace; font-size: 14px; background: var(--grey-bg); padding: 1px 6px; border-radius: 6px; }

/* report */
.rep h2 { font-size: 22px; }
.tablewrap { overflow-x: auto; margin: 0 -4px; -webkit-overflow-scrolling: touch; }
.rep table { width: 100%; min-width: 460px; border-collapse: collapse; font-size: 15px; }
.rep th, .rep td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.rep th { font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
.rep td.num, .rep th.num { text-align: right; font-variant-numeric: tabular-nums; }
.print-only { display: none; }
@media print {
  :root { --bg: #fff; --card: #fff; }
  body { font-size: 12pt; background: #fff; color: #000; }
  .top, .tabs, .no-print, .toasts, .net { display: none !important; }
  main { padding: 0; }
  .card, .list { box-shadow: none; border-color: #bbb; break-inside: avoid; }
  .print-only { display: block; }
  .rep table { font-size: 10.5pt; min-width: 0; }
  .tablewrap { overflow: visible; }
  .rep tr { break-inside: avoid; }
  .section-title { color: #000; }
}
