/* Portal stylesheet — one file, no external fonts, mobile first.
   Building blocks (use these classes; do not add a framework):
   layout     .container .narrow .stack .row .cards .card .grid-2 .toolbar .spacer
   text       h1 h2 h3 .muted .small .mono
   buttons    .btn (+ .btn-primary .btn-danger .btn-quiet .btn-small .btn-block)
   forms      .field (label + input/select/textarea) .help .error .req .choices (radio/checkbox rows)
              .field.has-error  [data-autosave] + .save-state (.saved / .save-failed)
   tables     table.table (+ .table-compact), .table-wrap for horizontal scroll
   status     .badge (+ .badge-ok .badge-warn .badge-danger .badge-info .badge-muted)
   alerts     .alert (+ .alert-info .alert-success .alert-warning .alert-error), .banner-danger
              .site-banners (slot under the header for core.banners; put an .alert inside)
   special    .big-result (randomization result), .demo-banner, .steps (ordered checklist),
              .split (image | fields, stacks on phones), .thumbs, dl.kv (key/value list), .tabs
*/
:root {
  --bg: #f5f6f8; --surface: #ffffff; --text: #1c2430; --muted: #5b6676; --line: #d9dee6;
  --primary: #0b5cab; --primary-dark: #084a8a; --primary-soft: #e6f0fb;
  --ok: #1a7f4b; --ok-soft: #e3f4ea; --warn: #9a6200; --warn-soft: #fff3d6;
  --danger: #b3261e; --danger-soft: #fde8e6; --info: #0b5cab; --info-soft: #e6f0fb;
  --radius: 8px; --gap: 1rem;
}
* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.45;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--muted); } .small { font-size: .875rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.demo-banner { background: #7a1fa2; color: #fff; text-align: center; font-weight: 700; font-size: .8rem;
  letter-spacing: .04em; padding: .3rem .5rem; }
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap;
  align-items: center; gap: .5rem 1rem; padding: .6rem 1rem; position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; margin-right: auto; }
/* the menu (.nav-toggle, .mainnav, its groups): css/nav.css */
.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.site-banners { max-width: 1100px; margin: 0 auto; padding: .75rem 1rem 0; display: grid; gap: .5rem; }
.site-banners > * { margin: 0; }
.narrow { max-width: 460px; margin: 1.5rem auto; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem; }
.stack > * + * { margin-top: var(--gap); }
.row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.spacer { flex: 1; }
/* minmax(0, …): a wide line inside a card (a row of badges, a long select) wraps or shrinks instead of widening
   the page on a phone (golive H-06) */
.cards { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 800px) { .cards, .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem;
  min-width: 0; }
select { max-width: 100%; }
/* A table read row by row on a phone (golive H-07): <table class="table stack-table">, each cell with
   data-label="column name" */
@media (max-width: 640px) {
  table.stack-table thead { display: none; }
  table.stack-table, table.stack-table tbody, table.stack-table tr, table.stack-table td { display: block; width: 100%; }
  table.stack-table tr { border-bottom: 1px solid var(--line); padding: .5rem 0; }
  table.stack-table td { border: 0; padding: .2rem 0; }
  table.stack-table td[data-label]::before { content: attr(data-label) ": "; font-weight: 700; color: var(--muted);
    font-size: .8rem; }
  table.stack-table td.row { display: flex; }
}
.card > :last-child { margin-bottom: 0; }

.btn { display: inline-block; font: inherit; font-weight: 600; text-decoration: none; text-align: center;
  cursor: pointer; padding: .6rem 1rem; min-height: 44px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); }
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-quiet { background: transparent; }
.btn-small { padding: .3rem .6rem; min-height: 32px; font-size: .875rem; }
.btn-block { display: block; width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

.field { margin-bottom: .9rem; }
.field > label, .field > .label { display: block; font-weight: 600; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date],
input[type=time], input[type=datetime-local], input[type=tel], input[type=search], input[type=file],
select, textarea { font: inherit; width: 100%; padding: .55rem .6rem; min-height: 44px; border: 1px solid #aab3c0;
  border-radius: 6px; background: #fff; color: var(--text); }
textarea { min-height: 5rem; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid #9cc4f0; outline-offset: 1px; }
.help { color: var(--muted); font-size: .875rem; margin: .25rem 0 0; }
.error { color: var(--danger); font-size: .875rem; margin: .25rem 0 0; font-weight: 600; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.req { color: var(--danger); }
.choices { display: flex; flex-wrap: wrap; gap: .4rem; }
.choices label { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; padding: .45rem .7rem;
  min-height: 44px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; }
.choices input { width: 1.15rem; height: 1.15rem; min-height: 0; }
.choices label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.save-state { font-size: .8rem; color: var(--muted); min-height: 1.1em; }
.saved .save-state { color: var(--ok); }
.save-failed .save-state { color: var(--danger); font-weight: 700; }
.save-failed { outline: 2px solid var(--danger); outline-offset: 4px; border-radius: 6px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table-compact th, .table-compact td { padding: .3rem .5rem; font-size: .9rem; }
.wrap-anywhere { overflow-wrap: anywhere; }  /* long codes (page ids) break instead of pushing the row off a phone */
.table tr:hover td { background: #fafbfc; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 700;
  background: #e9edf2; color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: #e9edf2; color: var(--muted); }

.alert { padding: .7rem .9rem; border-radius: 6px; border: 1px solid var(--line); background: var(--surface);
  margin-bottom: .8rem; }
.alert-info { background: var(--info-soft); border-color: #b9d4f1; }
.alert-success { background: var(--ok-soft); border-color: #b5dfc6; }
.alert-warning { background: var(--warn-soft); border-color: #f0d48a; }
.alert-error, .alert-danger { background: var(--danger-soft); border-color: #f1b8b3; }
.banner-danger { background: var(--danger); color: #fff; font-weight: 700; padding: .7rem 1rem; border-radius: 6px; }

.big-result { text-align: center; background: var(--surface); border: 3px solid var(--primary);
  border-radius: 12px; padding: 1.5rem 1rem; margin: 1rem 0; }
.big-result .label { font-size: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.big-result .value { font-size: clamp(3rem, 16vw, 7rem); font-weight: 800; line-height: 1.05;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.big-result.is-error { border-color: var(--danger); } .big-result.is-error .value { color: var(--danger); font-size: 2rem; }

.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; gap: .6rem; align-items: flex-start; padding: .5rem 0; border-bottom: 1px solid var(--line); }
/* a long next-step badge ("Visita V1 na janela (dia combinado …)") wraps inside the list on a phone (golive H-06) */
.steps li > * { min-width: 0; }
.steps .badge, a.badge { white-space: normal; max-width: 100%; }
.steps li::before { content: "○"; color: var(--muted); font-weight: 700; }
.steps li.done::before { content: "✓"; color: var(--ok); }
.steps li.blocked::before { content: "✕"; color: var(--danger); }

dl.kv { display: grid; grid-template-columns: minmax(8rem, 14rem) minmax(0, 1fr); gap: .3rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { dl.kv { grid-template-columns: minmax(0, 1fr); } dl.kv dt { margin-top: .4rem; } }

.split { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .split { grid-template-columns: 1fr 1fr; align-items: start; }
  .split > .sticky { position: sticky; top: 4.5rem; max-height: calc(100vh - 5.5rem); overflow: auto; } }
.scan-view { background: #222; border-radius: var(--radius); overflow: auto; max-height: 80vh; }
.scan-view img { display: block; width: 100%; height: auto; transform-origin: top left; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .6rem; }
.thumbs img { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
.tabs { display: flex; flex-wrap: wrap; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .5rem .8rem; text-decoration: none; color: var(--text); border-radius: 6px 6px 0 0; }
.tabs a.active { background: var(--surface); border: 1px solid var(--line); border-bottom-color: var(--surface); font-weight: 700; }
.pagination { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1rem 0; }
.dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; max-width: 30rem; }
.dialog-actions { display: flex; gap: .6rem; justify-content: flex-end; }
.panel-list > section { margin-bottom: 1rem; }
.htmx-request .btn-primary { opacity: .6; }
/* print: never the header, banners (they can name another participant), messages or buttons, on any page */
@media print { .topbar, .footer, .demo-banner, .site-banners, .messages, .btn, .no-print { display: none !important; } body { background: #fff; } }

/* The visit as one guided route (usability round, N1): the strip under the participant's name on every screen of
   a visit, and the step list of the visit page. One compact line on a phone; the list opens on a tap (details). */
.visit-progress { margin: .2rem 0 1rem; }
.visit-progress .vp-details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.visit-progress summary { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; min-height: 44px;
  padding: .45rem .8rem; cursor: pointer; list-style: none; }
.visit-progress summary::-webkit-details-marker { display: none; }
.visit-progress summary::after { content: "▾"; color: var(--muted); margin-left: auto; }
.visit-progress details[open] summary::after { content: "▴"; }
.visit-progress summary:focus-visible, .vp-steps a:focus-visible, .vp-actions a:focus-visible { outline: 3px solid #9cc4f0;
  outline-offset: 1px; }
.vp-where { min-width: 0; overflow-wrap: anywhere; }
.vp-open { color: var(--primary); font-size: .875rem; }
.vp-body { padding: 0 .8rem .6rem; }
.vp-next { margin-top: .5rem; }
.steps.vp-steps li { padding: .35rem 0; align-items: center; }
.vp-steps li a { display: inline-flex; align-items: center; min-height: 44px; }
.vp-steps li.vp-current { font-weight: 700; }
.steps li.vp-waiting_participant::before { content: "◔"; color: var(--warn); }
.steps li.vp-deferred::before { content: "…"; color: var(--muted); }
.steps li.vp-blocked { color: var(--muted); }
.steps li.vp-blocked::before { content: "–"; color: var(--muted); }
.vp-steps .vp-meta { display: block; }
.vp-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .3rem; }
.vp-actions .btn { min-height: 44px; }
.vp-summary { font-weight: 700; }
.vp-all { margin: .4rem 0 0; }
fieldset.field { border: 0; padding: 0; margin: 0 0 .9rem; min-width: 0; }
fieldset.field > legend { display: block; font-weight: 600; margin-bottom: .25rem; padding: 0; }
