:root {
  color-scheme: light dark;
  --fg: #1a1a1a;
  --bg: #ffffff;
  --muted: #666;
  --border: #ddd;
  --accent: #b3261e;
  --accent-fg: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fg: #eee;
    --bg: #16181a;
    --muted: #999;
    --border: #333;
  }
}

* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fg);
  background: var(--bg);
  margin: 0;
  line-height: 1.5;
}
.container { max-width: 40rem; margin: 0 auto; padding: 1rem; }

.site-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.site-header .brand { font-weight: 700; text-decoration: none; color: inherit;
  display: inline-flex; align-items: center; gap: 0.4rem; }
.brand-logo { width: 1.3rem; height: 1.3rem; }
.site-header nav a { margin-left: 1rem; color: inherit; text-decoration: none; }
.site-header nav a:hover { text-decoration: underline; }

.card {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

label { display: block; margin-bottom: 0.75rem; font-size: 0.9rem; color: var(--muted); }
.checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.5rem 1rem;
  margin: 0.75rem 0;
}
.checkbox-label { display: flex; align-items: center; gap: 0.4rem; margin: 0;
  font-size: 0.9rem; color: var(--fg); width: auto; min-width: 0; }
.checkbox-label input { width: auto; margin-top: 0; flex-shrink: 0; }
input, textarea, select { display: block; width: 100%; margin-top: 0.25rem; padding: 0.5rem; font: inherit;
  border: 1px solid var(--border); border-radius: 0.3rem; background: var(--bg); color: var(--fg); }
textarea { min-height: 4rem; resize: vertical; }

code { overflow-wrap: anywhere; word-break: break-word; }

.button, button {
  display: inline-block;
  padding: 0.5rem 1rem;
  border: 1px solid var(--fg);
  border-radius: 0.3rem;
  background: var(--fg);
  color: var(--bg);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.button-small { font-size: 0.8rem; padding: 0.25rem 0.6rem; border-radius: 0.3rem; cursor: pointer; }
.button-danger { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }

.inline-form { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: end; margin-top: 0.75rem; }
.inline-form input { width: auto; flex: 1; min-width: 8rem; }
.inline-form .checkbox-label { align-items: center; }
.inline-form .checkbox-label input { flex: 0 0 auto; min-width: 0; }
.inline { display: inline; margin-left: 0.5rem; }
@media (max-width: 30rem) {
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form input { width: 100%; min-width: 0; }
  .inline-form .checkbox-label input { width: auto; }

  /* Below this width a multi-column table has no room to breathe — 3-5
     columns squeezed into ~300px forces every cell to wrap, so values like
     a phone number or "Spouse and emergency proxy" become unreadable even
     inside a scroll container. Re-lay each row as a small vertical card of
     label/value pairs instead (a standard responsive-table technique) —
     the label comes from each <td>'s data-label attribute, which mirrors
     its column header (translated on the public page, same as the header
     itself). No horizontal scrolling needed anymore at this width. */
  .table-scroll { overflow-x: visible; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table { border: 1px solid var(--border); border-radius: 0.4rem; overflow: hidden; }
  .table tr { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: none; }
  .table td { padding: 0.15rem 0; border-bottom: none; }
  .table td:empty { display: none; }
  .table td[data-label]::before {
    content: attr(data-label); display: block; font-size: 0.7rem;
    color: var(--muted); font-weight: 600;
  }
}

.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; margin-bottom: 0.5rem; }
.table th, .table td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
.table td.nowrap { white-space: nowrap; }
.table-filter { margin-bottom: 0.5rem; }
.table th[data-sort-index] { cursor: pointer; user-select: none; }
.table th[data-sort-index]:hover { text-decoration: underline; }
.table th[data-sort-index]::after { content: "\21C5"; margin-left: 0.3rem; font-size: 0.75em; opacity: 0.35; }
.table th[data-sort-index].sort-asc::after { content: "\25B2"; opacity: 1; }
.table th[data-sort-index].sort-desc::after { content: "\25BC"; opacity: 1; }

.vaccine-group { margin-bottom: 1rem; }
.vaccine-group h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.vaccine-group:last-child { margin-bottom: 0; }

.doc-list { list-style: none; padding: 0; }
.doc-list li { padding: 0.4rem 0; border-bottom: 1px solid var(--border); }

.field { margin-bottom: 1rem; }
.field-value { font-size: 1.1rem; white-space: pre-wrap; }

.label-stack { display: flex; flex-direction: column; gap: 0.05rem; margin-bottom: 0.15rem; }
.label-primary { font-weight: 700; font-size: 1rem; }
.label-alt { font-size: 0.75rem; color: var(--muted); }
h1 .label-stack .label-primary, h2 .label-stack .label-primary { font-size: inherit; }
h1 .label-stack .label-alt, h2 .label-stack .label-alt { font-weight: 400; }

.error { color: var(--accent); font-weight: 600; }
.pin-reveal { font-size: 2.5rem; letter-spacing: 0.3em; font-weight: 700; text-align: center; }

body.public .card { max-width: 30rem; margin: 2rem auto; }

.lang-switch { display: flex; flex-wrap: wrap; gap: 0.4rem; max-width: 30rem; margin: 1rem auto 0; }
.lang-switch a { padding: 0.3rem 0.6rem; border: 1px solid var(--border); border-radius: 1rem;
  text-decoration: none; color: var(--fg); font-size: 0.85rem; }
.lang-switch a.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.print-card { border: 2px dashed var(--border); padding: 1rem; width: 12rem; text-align: center; margin: 2rem auto; }
.print-name { font-weight: 700; }
.print-pin { font-size: 1.1rem; font-weight: 700; letter-spacing: 0.15em; }
.print-hint { font-size: 0.7rem; color: var(--muted); }
@media print { .no-print { display: none; } }
