/*
 * The Venta: app components (Material 3 structure, the brand brief's look).
 * Uses tokens.css roles only. Mobile-first; rail from 840px.
 *
 * Contents: shell · page header · buttons · fields · selection controls ·
 * segmented · chips · cards · lists · tables · banners · snackbars · dialogs ·
 * progress · empty states · stats · money · auth · guest · station/PIN ·
 * wizard · utilities
 */

/* ---------- Shell ---------- */

.skip-link {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  padding: 12px 16px; border-radius: var(--venta-radius-md);
  background: var(--venta-filled-bg); color: var(--venta-filled-label);
}
.skip-link:focus { top: 8px; }

body.app { min-height: 100vh; min-height: 100dvh; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 64px;
  padding: 8px var(--venta-gutter);
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--md-sys-color-surface-container-lowest);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.topbar__brand { display: flex; align-items: center; gap: 12px; min-width: 0; color: inherit; text-decoration: none; border-radius: var(--venta-radius-sm); }
.topbar__mark { display: inline-flex; color: var(--md-sys-color-primary); flex: none; }
.topbar__mark svg { width: 40px; height: auto; }
.topbar__titles { display: flex; flex-direction: column; min-width: 0; }
.topbar__title { font: var(--md-sys-typescale-title-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__sub { font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__actions { display: flex; align-items: center; gap: 8px; flex: none; }

.shell { display: flex; align-items: stretch; }
.main {
  flex: 1; min-width: 0;
  width: 100%; max-width: var(--venta-width-dashboard);
  margin: 0 auto;
  padding: 24px var(--venta-gutter) 120px;
}
.main:focus { outline: none; }

.rail { display: none; }
@media (min-width: 840px) {
  .rail {
    position: sticky; top: 64px; align-self: flex-start;
    display: flex; flex-direction: column; gap: 4px;
    width: 96px; flex: none; height: calc(100vh - 64px);
    padding: 16px 8px;
    border-right: 1px solid var(--md-sys-color-outline-variant);
    background: var(--md-sys-color-surface);
    overflow-y: auto;
  }
  .rail__item {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 6px 0 8px; border-radius: var(--venta-radius-md);
    color: var(--md-sys-color-on-surface-variant); text-decoration: none;
    font: var(--md-sys-typescale-label-medium); text-align: center;
  }
  .rail__icon {
    display: grid; place-items: center; width: 56px; height: 32px;
    border-radius: var(--venta-radius-full);
    transition: background-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
  }
  .rail__icon svg { width: 24px; height: 24px; fill: currentColor; }
  .rail__item:hover .rail__icon { background: var(--md-sys-color-surface-container-high); }
  .rail__item.is-active { color: var(--md-sys-color-on-surface); font-weight: 600; }
  .rail__item.is-active .rail__icon { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
  .main { padding-bottom: 64px; }
}

.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 4px max(6px, env(safe-area-inset-bottom));
  background: var(--md-sys-color-surface-container-lowest);
  border-top: 1px solid var(--md-sys-color-outline-variant);
}
@media (min-width: 840px) { .bottombar { display: none; } }
.bottombar__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-height: 56px; padding: 4px 2px; list-style: none; cursor: pointer;
  color: var(--md-sys-color-on-surface-variant); text-decoration: none;
  font: var(--md-sys-typescale-label-small); border-radius: var(--venta-radius-md);
}
.bottombar__item::-webkit-details-marker { display: none; }
.bottombar__icon { display: grid; place-items: center; width: 56px; height: 30px; border-radius: var(--venta-radius-full); }
.bottombar__icon svg { width: 24px; height: 24px; fill: currentColor; }
.bottombar__item.is-active { color: var(--md-sys-color-on-surface); font-weight: 600; }
.bottombar__item.is-active .bottombar__icon { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.bottombar__more { flex: 1; display: flex; }
.bottombar__more > summary { width: 100%; }
.sheet {
  position: fixed; left: 8px; right: 8px; bottom: calc(76px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; padding: 8px;
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--venta-radius-xl);
  box-shadow: var(--venta-shadow-overlay);
}
.sheet a, .menu__panel a, .menu__panel button {
  display: flex; align-items: center; gap: 12px; min-height: var(--venta-target);
  padding: 0 16px; border-radius: var(--venta-radius-md); border: 0; background: none;
  color: var(--md-sys-color-on-surface); text-decoration: none; font: var(--md-sys-typescale-body-medium);
  width: 100%; text-align: left; cursor: pointer;
}
.sheet a:hover, .menu__panel a:hover, .menu__panel button:hover { background: var(--md-sys-color-surface-container-low); }
.sheet svg, .menu__panel svg { width: 22px; height: 22px; fill: var(--md-sys-color-on-surface-variant); }

.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu__panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 240px;
  padding: 8px; background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--venta-radius-md);
  box-shadow: var(--venta-shadow-overlay);
}
.menu__panel form { margin: 0; }

/* ---------- Page header ---------- */

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 8px 0 24px; }
.page-head h1 { margin: 0; font: var(--md-sys-typescale-headline-large); letter-spacing: var(--venta-tracking-tight); }
.page-head p { margin: 4px 0 0; color: var(--md-sys-color-on-surface-variant); }
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section-title { margin: 32px 0 12px; font: var(--md-sys-typescale-title-large); letter-spacing: var(--venta-tracking-tight); }
.eyebrow { font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); letter-spacing: .04em; text-transform: uppercase; }

/* ---------- Buttons (extends tokens.css .btn) ---------- */

.btn { position: relative; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
/* Disabled reads as disabled in both themes (not a pale version of the color). */
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 1; cursor: not-allowed; pointer-events: none; box-shadow: none; border-color: transparent;
  background: color-mix(in srgb, var(--md-sys-color-on-surface) 10%, transparent);
  color: color-mix(in srgb, var(--md-sys-color-on-surface) 45%, transparent);
}
/* Quiet style for repeated row actions (Print, Void, Forfeit, Pay later) so
   risky or repeated actions never look as loud as taking a payment. */
.btn--quiet { background: transparent; color: var(--md-sys-color-on-surface-variant); padding: 0 12px; }
.btn--quiet:hover { background: var(--md-sys-color-surface-container-low); color: var(--md-sys-color-on-surface); }
.btn--text { background: transparent; color: var(--md-sys-color-primary); padding: 0 12px; }
.btn--text:hover { background: var(--md-sys-color-surface-container-low); }
.btn--tonal { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.btn--tonal:hover { filter: brightness(.97); }
.btn--danger { background: var(--venta-on-error-container); color: #fff; }
.btn--danger:hover { filter: brightness(.95); }
.btn--lg { min-height: var(--venta-target-lg); padding: 0 28px; font-size: 1.0625rem; }
.btn--block { width: 100%; }
.btn--icon { width: var(--venta-target); padding: 0; border-radius: var(--venta-radius-sm); background: transparent; color: var(--md-sys-color-on-surface-variant); }
.btn--icon:hover { background: var(--md-sys-color-surface-container-low); }
.btn.is-busy { color: transparent !important; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid currentColor; border-color: var(--venta-filled-label) transparent var(--venta-filled-label) transparent;
  animation: venta-spin 900ms linear infinite;
}
.btn--outlined.is-busy::after, .btn--text.is-busy::after { border-color: var(--md-sys-color-primary) transparent var(--md-sys-color-primary) transparent; }
@keyframes venta-spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
form.inline { display: inline; margin: 0; }

/* ---------- Fields (M3 outlined, real labels) ---------- */

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.field > label, .field__label { font: var(--md-sys-typescale-label-large); color: var(--md-sys-color-on-surface); }
.field__hint { font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); }
.field__error { display: flex; gap: 6px; align-items: center; font: var(--md-sys-typescale-label-medium); color: var(--venta-on-error-container); }
.field__error svg { width: 18px; height: 18px; fill: currentColor; flex: none; }
.input, .select, .textarea {
  width: 100%; min-height: var(--venta-target);
  padding: 10px 14px;
  font: 400 1rem/1.4 var(--venta-font);
  color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline);
  border-radius: var(--venta-radius-md);
  transition: border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard), box-shadow var(--md-sys-motion-duration-short);
}
.input--lg { min-height: var(--venta-target-lg); font-size: 1.375rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.textarea { min-height: 96px; resize: vertical; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--md-sys-color-on-surface-variant); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--md-sys-color-primary); box-shadow: var(--venta-focus-halo), inset 0 0 0 1px var(--md-sys-color-primary); }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--venta-on-error-container); }
.input::placeholder { color: var(--venta-text-tertiary); }
.select {
  appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 -960 960 960'%3E%3Cpath fill='%236E6E73' d='M480-360 280-560h400L480-360Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 24px;
}
.input-prefix { position: relative; }
.input-prefix > span { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--md-sys-color-on-surface-variant); pointer-events: none; font-weight: 600; }
.input-prefix > .input { padding-left: 30px; }
.form-grid { display: grid; gap: 0 16px; }
@media (min-width: 640px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } .form-grid--3 { grid-template-columns: repeat(3, 1fr); } }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
fieldset { border: 0; margin: 0 0 20px; padding: 0; }
legend { font: var(--md-sys-typescale-label-large); margin-bottom: 8px; padding: 0; }

/* ---------- Selection controls ---------- */

.check {
  display: flex; align-items: center; gap: 12px; min-height: var(--venta-target);
  cursor: pointer; font: var(--md-sys-typescale-body-medium);
}
.check input[type="checkbox"], .check input[type="radio"] {
  width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--md-sys-color-primary);
}

/* ---------- Segmented buttons (Cash | Check | Card) ---------- */

.segmented {
  display: inline-flex; width: 100%;
  border: 1px solid var(--venta-border-strong); border-radius: var(--venta-radius-md); overflow: hidden;
}
.segmented label {
  flex: 1; position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--venta-target-lg); padding: 0 12px; cursor: pointer;
  font: var(--md-sys-typescale-label-large); color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container-lowest);
}
.segmented label + label { border-left: 1px solid var(--venta-border-strong); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented svg { width: 20px; height: 20px; fill: currentColor; }
.segmented label:has(input:checked) { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.segmented label:has(input:focus-visible) { outline: var(--venta-focus-outline); outline-offset: -3px; }
.segmented .seg-check { display: none; }
.segmented label:has(input:checked) .seg-check { display: inline; }

/* ---------- Chips & badges ---------- */

.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border-radius: var(--venta-radius-sm); border: 1px solid var(--venta-border-strong);
  font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface);
  background: var(--md-sys-color-surface-container-lowest); text-decoration: none; white-space: nowrap;
}
.chip svg { width: 18px; height: 18px; fill: currentColor; }
a.chip:hover { background: var(--md-sys-color-surface-container-low); }
.chip.is-selected { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); border-color: transparent; }
.chip--station { border-color: transparent; background: var(--md-sys-color-surface-container-high); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px;
  border-radius: var(--venta-radius-full); font: 600 .75rem/1 var(--venta-font);
  background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface);
  font-variant-numeric: tabular-nums;
}
.badge--primary { background: var(--venta-filled-bg); color: var(--venta-filled-label); }

/* ---------- Cards ---------- */

.card {
  background: var(--md-sys-color-surface-container-lowest);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--venta-radius-lg);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card__head h2, .card__head h3 { margin: 0; font: var(--md-sys-typescale-title-medium); }
.card--tonal { background: var(--md-sys-color-surface-container-low); border-color: transparent; }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--venta-border-strong); }
.grid { display: grid; gap: 16px; }
@media (min-width: 640px) { .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.split { display: grid; gap: 24px; }
@media (min-width: 1024px) { .split { grid-template-columns: minmax(0, 1fr) 380px; } .split--wide { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }

/* ---------- Lists ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list__item {
  display: flex; align-items: center; gap: 16px; min-height: var(--venta-target-lg);
  padding: 10px 16px; border-bottom: 1px solid var(--md-sys-color-outline-variant);
  color: inherit; text-decoration: none;
}
.list__item:last-child { border-bottom: 0; }
a.list__item:hover, button.list__item:hover { background: var(--md-sys-color-surface-container-low); }
button.list__item { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.list__main { flex: 1; min-width: 0; }
.list__title { font: var(--md-sys-typescale-body-medium); font-weight: 500; }
.list__sub { font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); }
.list__end { flex: none; display: flex; align-items: center; gap: 8px; }
.list__lead { flex: none; display: grid; place-items: center; min-width: 48px; height: 40px; padding: 0 8px; border-radius: var(--venta-radius-sm); background: var(--md-sys-color-surface-container-high); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--venta-radius-lg); background: var(--md-sys-color-surface-container-lowest); }
.table { width: 100%; border-collapse: collapse; font: var(--md-sys-typescale-body-medium); }
.table th {
  position: sticky; top: 0; text-align: left; white-space: nowrap;
  padding: 12px 16px; font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant);
  background: var(--md-sys-color-surface-container-high); border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--md-sys-color-outline-variant); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:hover { background: var(--md-sys-color-surface-container-low); }
.table a { color: inherit; font-weight: 500; }

/* ---------- Banners ---------- */

.banner {
  display: flex; align-items: flex-start; gap: 12px; margin: 0 0 20px; padding: 14px 16px;
  border-radius: var(--venta-radius-md); font: var(--md-sys-typescale-body-medium);
}
.banner svg { width: 22px; height: 22px; fill: currentColor; flex: none; margin-top: 1px; }
.banner a { color: inherit; font-weight: 600; }
.banner--info { background: var(--venta-info-container); color: var(--venta-on-info-container); }
.banner--success { background: var(--venta-success-container); color: var(--venta-on-success-container); }
.banner--warning { background: var(--venta-warning-container); color: var(--venta-on-warning-container); }
.banner--error { background: var(--venta-error-container); color: var(--venta-on-error-container); }

/* ---------- Snackbars (≥10s, persist on hover/focus, never Undo for payments) ---------- */

.snackbars {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
  bottom: calc(88px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; width: min(560px, calc(100vw - 32px));
  pointer-events: none;
}
@media (min-width: 840px) { .snackbars { bottom: 24px; } }
.snackbar {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 8px 8px 16px;
  border-radius: var(--venta-radius-md);
  background: var(--md-sys-color-inverse-surface); color: var(--md-sys-color-inverse-on-surface);
  font: var(--md-sys-typescale-body-medium);
  box-shadow: var(--venta-shadow-overlay);
  animation: venta-rise var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized-decelerate);
}
.snackbar > svg { width: 22px; height: 22px; flex: none; fill: currentColor; }
.snackbar--success > svg { fill: #5BCB77; }
.snackbar--error > svg { fill: #FF7A70; }
.snackbar--warning > svg { fill: #E9A23B; }
.snackbar span { flex: 1; }
.snackbar__action { border: 0; background: none; color: var(--md-sys-color-inverse-primary); font: var(--md-sys-typescale-label-large); padding: 8px 12px; border-radius: var(--venta-radius-sm); cursor: pointer; }
.snackbar__close { border: 0; background: none; color: inherit; width: 40px; height: 40px; border-radius: var(--venta-radius-sm); cursor: pointer; display: grid; place-items: center; }
.snackbar__close svg { width: 20px; height: 20px; fill: currentColor; }
.snackbar.is-leaving { opacity: 0; transition: opacity 200ms var(--md-sys-motion-easing-emphasized-accelerate); }
@keyframes venta-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Dialogs (<dialog>) ---------- */

dialog.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px);
  padding: 24px; border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--venta-radius-xl);
  background: var(--md-sys-color-surface-container-lowest); color: var(--md-sys-color-on-surface);
  box-shadow: var(--venta-shadow-overlay);
}
dialog.dialog::backdrop { background: var(--md-sys-color-scrim); }
dialog.dialog[open] { animation: venta-rise var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized-decelerate); }
.dialog h2 { margin: 0 0 8px; font: var(--md-sys-typescale-headline-medium); letter-spacing: var(--venta-tracking-tight); }
.dialog p { color: var(--md-sys-color-on-surface-variant); }
.dialog__actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 24px; }

/* ---------- Progress ---------- */

.progress { height: 6px; border-radius: var(--venta-radius-full); background: var(--md-sys-color-surface-container-high); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--md-sys-color-primary); transition: width var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard); }
.progress-label { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); }

/* ---------- Empty states ---------- */

.empty { padding: 48px 24px; text-align: center; color: var(--md-sys-color-on-surface-variant); }
.empty svg { width: 48px; height: 48px; fill: var(--venta-text-tertiary); }
.empty h2, .empty h3 { margin: 12px 0 4px; font: var(--md-sys-typescale-title-large); color: var(--md-sys-color-on-surface); }
.empty p { margin: 0 auto 20px; max-width: 42ch; }

/* ---------- Stats ---------- */

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat__label { font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); }
.stat__value { font: 600 1.75rem/1.2 var(--venta-font); letter-spacing: var(--venta-tracking-tight); font-variant-numeric: tabular-nums; }
.stat__sub { font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); }

/* ---------- Money ---------- */

.amount { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount--xl { font-size: clamp(2rem, 6vw, 2.75rem); line-height: 1.1; letter-spacing: var(--venta-tracking-tight); }
.amount--due { color: var(--md-sys-color-on-surface); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 10px 0; margin: 0; }
.kv dt { color: var(--md-sys-color-on-surface-variant); }
.kv dd { margin: 0; padding-left: 16px; text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.kv .kv__total { padding-top: 10px; border-top: 1px solid var(--md-sys-color-outline-variant); font-weight: 600; color: var(--md-sys-color-on-surface); }

/* Success moment: restrained, respects reduced motion (tokens.css) */
.pop-in { animation: venta-pop var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-emphasized-decelerate); }
@keyframes venta-pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* ---------- Auth (centered card) ---------- */

body.auth, body.bare { min-height: 100vh; min-height: 100dvh; }
.auth__main { width: 100%; max-width: 480px; margin: 0 auto; padding: clamp(32px, 8vh, 80px) var(--venta-gutter) 64px; }
.auth__brand { display: flex; justify-content: center; margin-bottom: 24px; color: var(--md-sys-color-primary); border-radius: var(--venta-radius-sm); }
.auth__brand svg { width: 88px; height: auto; }
.auth-card { background: var(--md-sys-color-surface-container-lowest); border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--venta-radius-xl); padding: clamp(24px, 5vw, 36px); }
.auth-card h1 { margin: 0 0 8px; font: var(--md-sys-typescale-headline-medium); letter-spacing: var(--venta-tracking-tight); }
.auth-card > p { margin: 0 0 24px; color: var(--md-sys-color-on-surface-variant); }
.auth-foot { margin-top: 20px; text-align: center; font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); }
.code-input { letter-spacing: .3em; text-align: center; font-size: 1.5rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.secret-key { display: block; padding: 12px 16px; border-radius: var(--venta-radius-md); background: var(--md-sys-color-surface-container-low); font: 600 1.0625rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .06em; word-break: break-all; }
.qr-box { display: flex; justify-content: center; margin: 8px 0 16px; }
.qr-box svg { width: 208px; height: 208px; border-radius: var(--venta-radius-sm); }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 0 0 16px; padding: 16px; list-style: none; border-radius: var(--venta-radius-md); background: var(--md-sys-color-surface-container-low); font: 600 .9375rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Guest pages (18px base) ---------- */

body.guest { font: var(--md-sys-typescale-body-large); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.guest__main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 32px var(--venta-gutter) 48px; }
.guest__foot { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 24px; font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); }
.guest__mark { display: inline-flex; color: var(--md-sys-color-primary); }
.guest__mark svg { width: 28px; height: auto; }

/* ---------- Station lock screen / PIN pad ---------- */

.pin-people { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 20px; }
.pin-person {
  display: flex; align-items: center; justify-content: center; min-height: var(--venta-target-lg); padding: 8px 12px;
  border: 1px solid var(--venta-border-strong); border-radius: var(--venta-radius-md);
  background: var(--md-sys-color-surface-container-lowest); font: var(--md-sys-typescale-label-large); cursor: pointer;
}
.pin-person:has(input:checked) { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); border-color: transparent; }
.pin-person input { position: absolute; opacity: 0; pointer-events: none; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 16px auto 0; }
.pinpad button {
  min-height: 64px; border: 1px solid var(--md-sys-color-outline-variant); border-radius: var(--venta-radius-lg);
  background: var(--md-sys-color-surface-container-lowest); color: var(--md-sys-color-on-surface);
  font: 600 1.5rem/1 var(--venta-font); font-variant-numeric: tabular-nums; cursor: pointer;
}
.pinpad button:active { background: var(--md-sys-color-surface-container-high); }
.pinpad svg { width: 26px; height: 26px; fill: currentColor; }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 8px 0 4px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--md-sys-color-outline); }
.pin-dots span.is-filled { background: var(--md-sys-color-on-surface); border-color: var(--md-sys-color-on-surface); }

/* Idle lock overlay (app.js), keeps the page underneath intact */
.lock-overlay { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: var(--md-sys-color-surface); }
.lock-overlay[hidden] { display: none; }

/* ---------- Wizard (install / migrations) ---------- */

.wizard { display: grid; gap: 24px; width: 100%; max-width: 1040px; margin: 0 auto; padding: 32px var(--venta-gutter) 96px; }
@media (min-width: 840px) { .wizard { grid-template-columns: 240px minmax(0, 720px); justify-content: center; } }
.wizard__brand { display: flex; align-items: center; gap: 12px; color: var(--md-sys-color-primary); }
.wizard__brand svg { width: 180px; height: auto; }
.steps { display: none; list-style: none; margin: 0; padding: 0; }
@media (min-width: 840px) { .steps { display: flex; flex-direction: column; gap: 4px; } }
.steps li { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: var(--venta-radius-md); font: var(--md-sys-typescale-label-large); color: var(--md-sys-color-on-surface-variant); }
.steps li svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.steps li .steps__state { margin-left: auto; font: var(--md-sys-typescale-label-small); }
.steps li.is-done { color: var(--venta-on-success-container); }
.steps li.is-current { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.wizard__bar { display: flex; justify-content: space-between; gap: 12px; margin-top: 24px; }
@media (max-width: 639px) {
  .wizard__bar { position: sticky; bottom: 0; margin: 24px -20px -20px; padding: 12px 20px max(12px, env(safe-area-inset-bottom)); background: var(--md-sys-color-surface-container-lowest); border-top: 1px solid var(--md-sys-color-outline-variant); }
}
.req { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
.req:last-child { border-bottom: 0; }
.req > svg { width: 22px; height: 22px; flex: none; margin-top: 2px; }
.req.is-ok > svg { fill: var(--venta-success); }
.req.is-bad > svg { fill: var(--venta-error); }
.req.is-warn > svg { fill: var(--venta-warning); }
.req__main { flex: 1; min-width: 0; }
.req__state { font: var(--md-sys-typescale-label-medium); }
.req.is-ok .req__state { color: var(--venta-on-success-container); }
.req.is-bad .req__state { color: var(--venta-on-error-container); }
.req.is-warn .req__state { color: var(--venta-on-warning-container); }
.req__fix { margin-top: 8px; padding: 10px 12px; border-radius: var(--venta-radius-sm); background: var(--md-sys-color-surface-container-low); font: .875rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }
pre.code { overflow-x: auto; padding: 12px 16px; border-radius: var(--venta-radius-md); background: var(--md-sys-color-surface-container-low); font: .8125rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; }

/* ---------- Integration fixes (wave A) ---------- */

/* Cards laid out by a grid/split never inherit the stacked-card gap. */
.grid > .card + .card, .split > .card + .card { margin-top: 0; }
.split > .card { align-self: start; }
/* Let grid children shrink so wide tables scroll inside instead of widening the page. */
.split > *, .grid > * { min-width: 0; }
/* Neutral status pill (Closed, Archived, Unsold, Withdrawn). */
.status--neutral { background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface); }
/* Tab-style chips at full touch height. */
.chip--tab { min-height: var(--venta-target); padding: 0 16px; }
a.chip--station { text-decoration: none; }
/* Danger button in dark mode: dark label on the light red (white on #FF7A70 is ~2.4:1). */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn--danger { color: #1D1D1F; }
}
:root[data-theme="dark"] .btn--danger { color: #1D1D1F; }

/* ---------- Device sign-in, approval, lock screen, workers ---------- */

.device-card { text-align: center; }
.device-card .field, .device-card form { text-align: left; }
.device-card h1 { margin-bottom: 12px; }
.device-steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; text-align: left; }
.device-steps li { display: flex; align-items: center; gap: 12px; font: var(--md-sys-typescale-body-medium); }
.device-steps__n {
  display: grid; place-items: center; flex: none; width: 32px; height: 32px;
  border-radius: var(--venta-radius-full);
  background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container);
  font: 600 .9375rem/1 var(--venta-font); font-variant-numeric: tabular-nums;
}
.device-qr { display: flex; justify-content: center; margin: 4px 0 6px; }
.device-qr svg { width: min(100%, 300px); height: auto; border-radius: var(--venta-radius-md); }
.device-qr.is-faded svg { opacity: .18; }
.device-timer { margin: 0 0 20px; font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); font-variant-numeric: tabular-nums; }
.device-approved { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 8px 0 20px; color: var(--venta-on-success-container); }
.device-approved svg { width: 56px; height: 56px; fill: currentColor; }
.device-approved strong { font: var(--md-sys-typescale-title-large); color: var(--md-sys-color-on-surface); }
.device-card .banner { text-align: left; }
.device-card.is-approved .code-input { border-color: var(--md-sys-color-primary); box-shadow: var(--venta-focus-halo); }
.device-help { margin-top: 20px; text-align: left; font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); }
.device-help summary { cursor: pointer; min-height: var(--venta-target); display: flex; align-items: center; }
.device-help .secret-key { font-size: .8125rem; letter-spacing: 0; }

.device-code {
  display: block; margin: 8px 0; text-align: center;
  font: 700 clamp(3.25rem, 17vw, 6rem)/1 var(--venta-font);
  letter-spacing: .06em; font-variant-numeric: tabular-nums; color: var(--md-sys-color-on-surface);
}
.code-panel { text-align: center; max-width: 560px; margin: 0 auto; }
.code-panel .status { margin: 8px 0 4px; }
.code-panel__timer { font: var(--md-sys-typescale-title-medium); color: var(--md-sys-color-on-surface-variant); font-variant-numeric: tabular-nums; }

.scanner { max-width: 560px; margin: 0 auto; }
.scanner__view {
  position: relative; width: 100%; aspect-ratio: 1 / 1; overflow: hidden;
  border-radius: var(--venta-radius-lg); background: var(--md-sys-color-inverse-surface);
  display: grid; place-items: center;
}
.scanner__reader { position: absolute; inset: 0; }
.scanner__view video { width: 100% !important; height: 100% !important; object-fit: cover; }
.scanner__idle {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 24px; text-align: center; color: var(--md-sys-color-inverse-on-surface);
}
.scanner__idle[hidden] { display: none; }
/* A viewfinder stays dark in both themes (inverse-surface flips to light in dark mode). */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .scanner__view { background: var(--md-sys-color-surface-container-lowest); border: 1px solid var(--md-sys-color-outline-variant); }
  :root:not([data-theme="light"]) .scanner__idle { color: var(--md-sys-color-on-surface); }
}
:root[data-theme="dark"] .scanner__view { background: var(--md-sys-color-surface-container-lowest); border: 1px solid var(--md-sys-color-outline-variant); }
:root[data-theme="dark"] .scanner__idle { color: var(--md-sys-color-on-surface); }
.scanner__idle p { margin: 0; max-width: 36ch; }
.scanner__idle svg { width: 56px; height: 56px; fill: currentColor; }
.scanner__hint { margin: 12px 0 20px; text-align: center; color: var(--md-sys-color-on-surface-variant); }

.approve-wrap { max-width: var(--venta-width-reading); }
.approve-wrap > * + * { margin-top: 16px; }
.approve-panel { margin-top: 4px; }
.approve-panel[hidden] { display: none; }
.ability-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }
/* Workers table: rows stack into cards on phones so the actions stay in reach. */
@media (max-width: 639px) {
  .workers-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .workers-table, .workers-table tbody, .workers-table tr, .workers-table td { display: block; width: 100%; }
  .workers-table tr { padding: 12px 16px; border-bottom: 1px solid var(--md-sys-color-outline-variant); }
  .workers-table tr:last-child { border-bottom: 0; }
  .workers-table td { padding: 4px 0; border: 0; white-space: normal; }
  .workers-table td[data-label]::before {
    content: attr(data-label); display: inline-block; min-width: 72px;
    font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant);
  }
  .workers-table td.right { text-align: left; margin-left: -12px; }
  .workers-table tbody tr:hover { background: none; }
}
/* app.css gives .card + .card a top margin, which staggers cards inside a grid. */
.device-grid > .card + .card { margin-top: 0; }
.device-grid { margin-bottom: 8px; }
.worker-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.worker-chips .chip { min-height: 28px; padding: 0 10px; }

.lock-card { text-align: center; }
.lock-card .pinpad button { touch-action: manipulation; }
.lock-card__who { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 4px 0 12px; }
.lock-card__name { font: var(--md-sys-typescale-headline-medium); letter-spacing: var(--venta-tracking-tight); }
.lock-card__station { font: var(--md-sys-typescale-label-medium); color: var(--md-sys-color-on-surface-variant); }
.lock-card__icon { display: inline-grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 8px; border-radius: var(--venta-radius-full); background: var(--md-sys-color-surface-container-high); color: var(--md-sys-color-on-surface-variant); }
.lock-card__icon svg { width: 32px; height: 32px; fill: currentColor; }
.pin-entry { position: relative; max-width: 320px; margin: 0 auto; }
.pin-entry .input { text-align: center; letter-spacing: .4em; font-size: 1.5rem; font-weight: 600; }
.pin-entry .pin-dots { display: none; min-height: 44px; align-items: center; }
.pin-entry.is-js .pin-dots { display: flex; }
.pin-entry.is-js .pin-entry__field { position: absolute; inset: 0 0 auto 0; height: 44px; opacity: 0; }
.pin-entry.is-js:focus-within .pin-dots { outline: var(--venta-focus-outline); outline-offset: 4px; border-radius: var(--venta-radius-sm); }
.pinpad .pinpad__ok { background: var(--venta-filled-bg); color: var(--venta-filled-label); border-color: transparent; }
.pinpad button:focus-visible { outline: var(--venta-focus-outline); outline-offset: 2px; }
.lock-card .divider { margin: 24px 0 16px; }

/* ---------- Visual QA fixes ---------- */

/* Long button labels wrap on phones instead of overflowing their card. */
@media (max-width: 479px) {
  .btn:not(.btn--icon) { max-width: 100%; white-space: normal; text-align: center; line-height: 1.25; padding-top: 8px; padding-bottom: 8px; }
}
/* Big paddle numbers use normal-width digits ("112", not "1 12"). */
h1 .paddle, h1.paddle, .amount--xl.paddle { font-variant-numeric: proportional-nums; }
/* Stat cards two-up on phones, so actions aren't a long scroll away. */
@media (max-width: 639px) {
  .grid--stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .grid--stats > .card { padding: 14px; }
  .grid--stats .stat__value { font-size: 1.375rem; }
  .table th:first-child, .table td:first-child { min-width: 8rem; }
  .wizard__bar { border-radius: 0 0 calc(var(--venta-radius-lg) - 1px) calc(var(--venta-radius-lg) - 1px); }
}

/* ---------- Utilities ---------- */

.muted { color: var(--md-sys-color-on-surface-variant); }
.small { font: var(--md-sys-typescale-label-medium); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.icon { width: 24px; height: 24px; fill: currentColor; flex: none; vertical-align: middle; }
.btn .icon, .chip .icon { width: 20px; height: 20px; }
.hide-sm { display: none; }
@media (min-width: 640px) { .hide-sm { display: inline; } .show-sm { display: none; } }
[hidden] { display: none !important; }
.divider { height: 1px; margin: 20px 0; background: var(--md-sys-color-outline-variant); border: 0; }
.print-only { display: none; }
