:root {
  --ink: #1d1d1f;
  --muted: #6b6b72;
  --line: #dcdce1;
  --bg: #f6f6f8;
  --card: #ffffff;
  --accent: #b8862b;
  --accent-ink: #ffffff;
  --ok: #2f7d4f;
  --warn: #a4471f;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.45;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: #111;
  color: #fff;
}
.brand { font-weight: 700; letter-spacing: .02em; }
.save-state { font-size: 13px; color: #d8d8dc; }
.save-state.error { color: #ffb4a2; }

.login { display: grid; place-items: center; padding: 48px 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 420px;
  width: 100%;
}
.card h1 { margin-top: 0; font-size: 24px; }
.card label { display: block; font-weight: 600; margin: 16px 0 6px; }
#codeInput { font-size: 22px; letter-spacing: .12em; text-transform: uppercase; text-align: center; }
.error { color: var(--warn); min-height: 1.4em; }

.app { max-width: 860px; margin: 0 auto; padding: 20px 16px 80px; }
.event-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; align-items: flex-end; }
.event-head h1 { margin: 0; font-size: 24px; }
.event-head p { margin: 4px 0 0; color: var(--muted); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.status-banner {
  background: #eaf5ee;
  border: 1px solid #bfe0cb;
  color: var(--ok);
  border-radius: var(--radius);
  padding: 10px 14px;
}

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 18px 0 12px; padding-bottom: 4px; }
.tab {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  color: var(--ink);
}
.tab[aria-selected="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.tab .count { color: var(--muted); margin-left: 6px; font-size: 12px; }
.tab[aria-selected="true"] .count { color: #cfcfd4; }

.page { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.page h2 { margin: 0 0 4px; }
.page .intro { color: var(--muted); margin: 0 0 12px; }

.block { padding: 14px 0; border-top: 1px solid var(--line); }
.block:first-of-type { border-top: 0; }
.block > .label { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; margin-bottom: 8px; }
.block .hint { font-weight: 400; color: var(--muted); font-size: 13px; }
.req { color: var(--warn); }
.na { font-weight: 400; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.block.is-na .fields { opacity: .4; pointer-events: none; }

.fields { display: grid; gap: 8px; }
.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .two { grid-template-columns: 1fr; } }

input, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }
textarea { min-height: 84px; resize: vertical; }

.choices { display: flex; gap: 8px; flex-wrap: wrap; }
.choices label {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.choices input { width: auto; }

.rating { width: 100%; border-collapse: collapse; }
.rating th, .rating td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: center; font-size: 14px; }
.rating th:first-child, .rating td:first-child { text-align: left; }
.rating input { width: auto; }

.add-row { margin-top: 6px; }

.btn {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
.btn:disabled { opacity: .5; cursor: default; }

.pager { display: flex; justify-content: space-between; margin-top: 16px; }

dialog { border: 1px solid var(--line); border-radius: var(--radius); max-width: 460px; width: calc(100% - 32px); }
dialog h2 { margin-top: 0; }
dialog label { display: block; font-weight: 600; margin: 12px 0 6px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.print-only { display: none; }

@media print {
  @page { size: letter; margin: 0.5in; }
  body { background: #fff; }
  .topbar, .login, .app, dialog { display: none !important; }
  .print-only { display: block; }
  .sheet { break-after: page; font-size: 11pt; }
  .sheet:last-child { break-after: auto; }
  .sheet-head { border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; }
  .sheet-head .co { font-size: 9pt; letter-spacing: .08em; text-transform: uppercase; }
  .sheet-head h2 { margin: 2px 0; font-size: 16pt; }
  .sheet-head .meta { font-size: 9.5pt; }
  .row { display: grid; grid-template-columns: 2.1in 1fr; gap: 8px; padding: 3px 0; border-bottom: 1px solid #ccc; break-inside: avoid; }
  .row .k { font-weight: 600; }
  .row .v { white-space: pre-wrap; }
  .sub { margin: 10px 0 4px; font-weight: 700; break-after: avoid; }
  .ptable { width: 100%; border-collapse: collapse; }
  .ptable th, .ptable td { border: 1px solid #999; padding: 3px 6px; text-align: left; font-size: 10pt; }
  .ptable td.x { text-align: center; }
  .signoff { margin-top: 16px; font-size: 10pt; }
}
