/*
 * Design-system components (architecture 11 §5.3, audit 04 §4). Colours, radii, motion only through tokens.
 * Breakpoints: 720px (sheet → dialog, bottom bar → top navigation row), 1010px (status line, tables). No sidebar (ADR-0021).
 */

/* ================================================================ icons */
.avb-icon {
  flex: none;
}

/* ================================================================ buttons */
.avb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--avb-space-2);
  min-height: var(--avb-control-md);
  padding: 0 var(--avb-space-4);
  border: 1px solid transparent;
  border-radius: var(--avb-radius-control);
  font-size: var(--avb-text-md);
  font-weight: var(--avb-weight-bold);
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition:
    transform var(--avb-duration-press) var(--avb-ease-standard),
    filter var(--avb-duration-fast) var(--avb-ease-standard),
    background-color var(--avb-duration-fast) var(--avb-ease-standard);
  user-select: none;
}

.avb-btn:active:not(:disabled) {
  transform: scale(var(--avb-press-scale));
}

.avb-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

.avb-btn.is-loading:disabled {
  opacity: 0.85;
}

.avb-btn--primary {
  background: var(--avb-button);
  color: var(--avb-button-text);
  box-shadow: var(--avb-button-shadow);
}

.avb-btn--primary:hover:not(:disabled) {
  filter: brightness(1.07);
}

.avb-btn--secondary {
  background: var(--avb-surface-2);
  border-color: var(--avb-border);
  color: var(--avb-text);
}

.avb-btn--secondary:hover:not(:disabled) {
  background: var(--avb-surface-3);
}

.avb-btn--danger {
  background: var(--avb-danger-soft);
  color: var(--avb-danger);
}

.avb-btn--danger:hover:not(:disabled) {
  filter: brightness(1.04) saturate(1.2);
}

.avb-btn--ghost {
  background: transparent;
  color: var(--avb-accent-text);
}

.avb-btn--ghost:hover:not(:disabled) {
  background: var(--avb-accent-soft);
}

.avb-btn--sm {
  min-height: var(--avb-control-sm);
  padding: 0 var(--avb-space-3h);
  border-radius: var(--avb-radius-md);
  font-size: var(--avb-text-button-sm);
}

.avb-btn--full {
  display: flex;
  width: 100%;
}

.avb-btn__text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.avb-iconbtn {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--avb-control-sm);
  height: var(--avb-control-sm);
  padding: 0;
  border: 0;
  border-radius: var(--avb-radius-round);
  background: transparent;
  color: var(--avb-text-2);
  transition:
    transform var(--avb-duration-press) var(--avb-ease-standard),
    background-color var(--avb-duration-fast) var(--avb-ease-standard);
}

.avb-iconbtn--soft {
  background: var(--avb-surface-2);
  box-shadow: inset 0 0 0 1px var(--avb-border);
}

.avb-iconbtn:hover:not(:disabled) {
  background: var(--avb-surface-3);
}

.avb-iconbtn:active:not(:disabled) {
  transform: scale(var(--avb-press-scale-icon));
}

.avb-iconbtn[aria-pressed='true'] {
  background: var(--avb-accent-soft);
  color: var(--avb-accent-text);
}

.avb-iconbtn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ================================================================ fields */
.avb-field {
  display: flex;
  flex-direction: column;
  gap: var(--avb-space-1h);
  min-width: 0;
}

.avb-field__label {
  font-size: var(--avb-text-sm);
  font-weight: var(--avb-weight-label);
  color: var(--avb-text-2);
}

.avb-field__req {
  color: var(--avb-danger);
}

.avb-field__control {
  position: relative;
  display: flex;
  align-items: center;
}

.avb-input {
  width: 100%;
  min-height: var(--avb-control-field);
  padding: 11px 13px;
  border: 1px solid var(--avb-border-input);
  border-radius: var(--avb-radius-control);
  background: var(--avb-field);
  color: var(--avb-text);
  font-size: var(--avb-text-field);
  font-weight: var(--avb-weight-regular);
  outline: none;
  transition:
    border-color var(--avb-duration-fast) var(--avb-ease-standard),
    box-shadow var(--avb-duration-fast) var(--avb-ease-standard);
  appearance: none;
}

.avb-input::placeholder {
  color: var(--avb-text-muted);
  opacity: 1;
}

.avb-input:focus,
.avb-input:focus-visible {
  border-color: var(--avb-border-focus);
  box-shadow: 0 0 0 4px var(--avb-accent-soft);
  outline: none;
}

.avb-input:disabled,
.avb-input[readonly] {
  opacity: 0.7;
}

.avb-field.has-error .avb-input {
  border-color: var(--avb-danger);
}

.avb-field.has-error .avb-input:focus {
  box-shadow: 0 0 0 4px var(--avb-danger-soft);
}

.avb-field__control:has(.avb-field__suffix) .avb-input {
  padding-right: 64px;
}

.avb-field__control:has(.avb-field__action) .avb-input {
  padding-right: 52px;
}

.avb-input--money {
  text-align: right;
  font-weight: var(--avb-weight-bold);
}

.avb-field__suffix {
  position: absolute;
  right: 13px;
  color: var(--avb-text-muted);
  font-size: var(--avb-text-md);
  font-weight: var(--avb-weight-strong);
  pointer-events: none;
}

.avb-field__action {
  position: absolute;
  right: 4px;
  display: flex;
}

.avb-field__toggle {
  display: grid;
  place-items: center;
  width: var(--avb-control-sm);
  height: 38px;
  border: 0;
  border-radius: var(--avb-radius-md);
  background: transparent;
  color: var(--avb-text-muted);
}

.avb-field__toggle:hover {
  color: var(--avb-text);
  background: var(--avb-surface-3);
}

.avb-select {
  padding-right: 44px;
  cursor: pointer;
}

.avb-select option {
  background: var(--avb-menu);
  color: var(--avb-text);
}

.avb-select__chevron {
  position: absolute;
  right: 14px;
  color: var(--avb-text-muted);
  pointer-events: none;
}

.avb-field__hint {
  font-size: var(--avb-text-sm);
  color: var(--avb-text-muted);
}

.avb-field__error {
  display: flex;
  align-items: flex-start;
  gap: var(--avb-space-1h);
  font-size: var(--avb-text-sm);
  font-weight: var(--avb-weight-label);
  color: var(--avb-danger);
}

.avb-field__error .avb-icon {
  margin-top: 1px;
}

/* ================================================================ segmented control */
.avb-seg {
  display: inline-flex;
  gap: var(--avb-space-0);
  max-width: 100%;
  padding: var(--avb-space-0);
  border-radius: var(--avb-radius-sm);
  background: var(--avb-surface-3);
  overflow-x: auto;
  scrollbar-width: none;
}

.avb-seg--full {
  display: flex;
}

.avb-seg--full .avb-seg__btn {
  flex: 1;
}

.avb-seg__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--avb-space-1h);
  min-height: var(--avb-control-sm);
  padding: 0 var(--avb-space-3h);
  border: 0;
  border-radius: var(--avb-radius-xs);
  background: transparent;
  color: var(--avb-text-muted);
  font-size: var(--avb-text-button-sm);
  font-weight: var(--avb-weight-label);
  white-space: nowrap;
  transition:
    background-color var(--avb-duration-base) var(--avb-ease-standard),
    color var(--avb-duration-base) var(--avb-ease-standard);
}

.avb-seg__btn:hover {
  color: var(--avb-text);
}

.avb-seg__btn[aria-pressed='true'] {
  background: var(--avb-surface-sheet);
  color: var(--avb-text);
  font-weight: var(--avb-weight-bold);
  box-shadow: var(--avb-shadow-segment);
}

/* ================================================================ cards, KPI, page head */
.avb-card {
  border: 1px solid var(--avb-border);
  border-radius: var(--avb-radius-card);
  background: var(--avb-surface);
  box-shadow: var(--avb-shadow-1);
  -webkit-backdrop-filter: var(--avb-blur-card);
  backdrop-filter: var(--avb-blur-card);
  min-width: 0;
}

.avb-card--pad-md {
  padding: var(--avb-space-4) var(--avb-space-4);
}

.avb-card--pad-lg {
  padding: var(--avb-space-5) var(--avb-space-5);
}

@media (min-width: 720px) {
  .avb-card--pad-lg {
    padding: var(--avb-space-6);
  }
}

.avb-card--pad-none {
  padding: 0;
  overflow: hidden;
}

.avb-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--avb-space-3);
  margin-bottom: var(--avb-space-3h);
}

.avb-card__titles {
  min-width: 0;
}

.avb-card__title {
  font-size: var(--avb-text-lg);
  font-weight: var(--avb-weight-strong);
  letter-spacing: var(--avb-tracking-tight);
  line-height: 1.3;
}

.avb-card__subtitle {
  margin-top: var(--avb-space-0);
  color: var(--avb-text-muted);
  font-size: var(--avb-text-sm);
}

.avb-card__actions {
  display: flex;
  gap: var(--avb-space-2);
  flex: none;
}

.avb-kpi {
  padding: 15px var(--avb-space-4);
  border: 1px solid var(--avb-border);
  border-radius: var(--avb-radius-card);
  background: var(--avb-surface);
  box-shadow: var(--avb-shadow-1);
  -webkit-backdrop-filter: var(--avb-blur-card);
  backdrop-filter: var(--avb-blur-card);
  min-width: 0;
  container-type: inline-size;
}

.avb-kpi__label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--avb-text-muted);
}

.avb-kpi__value {
  margin-top: var(--avb-space-1);
  font-family: var(--avb-font-display);
  /* shrinks with the tile so a grouped amount never breaks inside a number (reference: fit-to-width) */
  font-size: min(var(--avb-text-kpi), 10.5cqi);
  font-weight: var(--avb-weight-bold);
  letter-spacing: -0.03em;
  line-height: 1.2;
  background: var(--avb-figure);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  overflow-wrap: break-word;
}

.avb-kpi--success .avb-kpi__value {
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--avb-success);
}

.avb-kpi--danger .avb-kpi__value {
  background: none;
  -webkit-text-fill-color: currentColor;
  color: var(--avb-danger);
}

.avb-kpi__note {
  margin-top: var(--avb-space-0);
  font-size: var(--avb-text-sm);
  color: var(--avb-text-muted);
}

.avb-pagehead {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--avb-space-3);
  margin-bottom: var(--avb-space-4);
}

.avb-pagehead__titles {
  display: flex;
  flex-direction: column;
  gap: var(--avb-space-1);
  min-width: 0;
}

.avb-pagehead__count {
  display: inline-block;
  vertical-align: middle;
  padding: var(--avb-space-0) var(--avb-space-2h);
  border-radius: var(--avb-radius-sm);
  background: var(--avb-surface-3);
  color: var(--avb-text-muted);
  font-size: var(--avb-text-sm);
  font-weight: var(--avb-weight-bold);
  letter-spacing: 0;
}

@media (max-width: 719.98px) {
  .avb-pagehead__actions {
    width: 100%;
  }
  .avb-pagehead__actions .avb-btn {
    width: 100%;
  }
}

/* ================================================================ list and table */
.avb-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--avb-border);
  border-radius: var(--avb-radius-panel);
  background: var(--avb-surface);
  box-shadow: var(--avb-shadow-1);
  -webkit-backdrop-filter: var(--avb-blur-card);
  backdrop-filter: var(--avb-blur-card);
  overflow: hidden;
}

.avb-list--loading {
  padding: var(--avb-space-4);
}

.avb-list__item + .avb-list__item {
  border-top: 1px solid var(--avb-border);
}

.avb-row {
  display: flex;
  align-items: center;
  gap: var(--avb-space-3);
  width: 100%;
  min-height: 56px;
  padding: 13px var(--avb-space-4);
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.avb-row--action {
  transition: background-color var(--avb-duration-fast) var(--avb-ease-standard);
}

.avb-row--action:hover {
  background: var(--avb-surface-2);
}

.avb-row--action:focus-visible {
  outline-offset: -3px;
}

.avb-row[aria-current='true'] {
  background: var(--avb-accent-soft);
}

.avb-row__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: var(--avb-radius-md);
  background: var(--avb-accent-soft);
  color: var(--avb-accent-text);
}

.avb-row__main {
  display: flex;
  flex-direction: column;
  gap: var(--avb-space-0);
  flex: 1;
  min-width: 0;
}

.avb-row__title {
  font-size: var(--avb-text-row);
  font-weight: var(--avb-weight-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avb-row__subtitle {
  color: var(--avb-text-2);
  font-size: var(--avb-text-nav);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avb-row__meta {
  color: var(--avb-text-muted);
  font-size: var(--avb-text-sm);
}

.avb-row__trailing {
  flex: none;
  font-size: var(--avb-text-md);
  font-weight: var(--avb-weight-bold);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.avb-row__chevron {
  flex: none;
  color: var(--avb-text-muted);
}

.avb-table-wrap {
  border: 1px solid var(--avb-border);
  border-radius: var(--avb-radius-panel);
  background: var(--avb-surface);
  box-shadow: var(--avb-shadow-1);
  -webkit-backdrop-filter: var(--avb-blur-card);
  backdrop-filter: var(--avb-blur-card);
  overflow-x: auto;
}

.avb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--avb-text-md);
}

.avb-table th {
  padding: var(--avb-space-3) var(--avb-space-4);
  border-bottom: 1px solid var(--avb-border-strong);
  color: var(--avb-text-muted);
  font-size: var(--avb-text-sm);
  font-weight: var(--avb-weight-label);
  text-align: left;
  white-space: nowrap;
}

.avb-table td {
  padding: 13px var(--avb-space-4);
  border-bottom: 1px solid var(--avb-border);
  vertical-align: middle;
}

.avb-table tbody tr:last-child td {
  border-bottom: 0;
}

.avb-table .is-end {
  text-align: right;
}

.avb-table tr.is-action {
  cursor: pointer;
  transition: background-color var(--avb-duration-fast) var(--avb-ease-standard);
}

.avb-table tr.is-action:hover {
  background: var(--avb-surface-2);
}

.avb-table tr.is-action:focus-visible {
  outline-offset: -3px;
}

/* ================================================================ sheet / dialog (native <dialog>) */
.avb-sheet,
.avb-confirm {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--avb-text);
  overflow: hidden;
}

.avb-sheet::backdrop,
.avb-confirm::backdrop {
  background: transparent;
}

.avb-sheet[open],
.avb-confirm[open] {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.avb-sheet__scrim {
  position: absolute;
  inset: 0;
  background: var(--avb-scrim);
  animation: avb-fade var(--avb-duration-base) var(--avb-ease-standard) both;
}

.avb-sheet__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 620px;
  max-height: calc(100dvh - var(--avb-safe-top) - 24px);
  border-radius: var(--avb-radius-sheet) var(--avb-radius-sheet) 0 0;
  background: var(--avb-surface-sheet);
  box-shadow: var(--avb-shadow-3);
  animation: avb-sheet-up var(--avb-duration-sheet) var(--avb-ease-out) both;
}

.avb-sheet--wide .avb-sheet__panel {
  max-width: 980px;
}

.avb-sheet__handle {
  flex: none;
  width: 40px;
  height: 5px;
  margin: var(--avb-space-2) auto 0;
  border-radius: 3px;
  background: var(--avb-border-strong);
}

.avb-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--avb-space-3);
  padding: var(--avb-space-2h) var(--avb-space-5) var(--avb-space-2);
}

.avb-sheet__title {
  font-size: var(--avb-text-xl);
  font-weight: var(--avb-weight-strong);
  letter-spacing: var(--avb-tracking-tight);
  line-height: 1.3;
}

.avb-sheet__body {
  flex: 1;
  min-height: 0;
  padding: var(--avb-space-2) var(--avb-space-5) var(--avb-space-5);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.avb-sheet__foot {
  position: sticky;
  bottom: 0;
  z-index: var(--avb-z-sticky);
  display: flex;
  flex-wrap: wrap;
  gap: var(--avb-space-2h);
  justify-content: flex-end;
  padding: var(--avb-space-3) var(--avb-space-5) calc(var(--avb-space-3) + var(--avb-safe-bottom));
  border-top: 1px solid var(--avb-border);
  background: var(--avb-surface-sheet);
}

@media (max-width: 719.98px) {
  .avb-sheet__foot .avb-btn {
    flex: 1;
  }
}

@media (min-width: 720px) {
  .avb-sheet[open] {
    align-items: center;
    padding: var(--avb-space-6);
  }
  .avb-sheet__panel {
    max-height: min(88dvh, 900px);
    border-radius: var(--avb-radius-panel);
    animation-name: avb-dialog-in;
    animation-duration: var(--avb-duration-dialog);
  }
  .avb-sheet__handle {
    display: none;
  }
  .avb-sheet__head {
    padding: var(--avb-space-5) var(--avb-space-5) var(--avb-space-2);
  }
  .avb-sheet__foot {
    border-radius: 0 0 var(--avb-radius-panel) var(--avb-radius-panel);
    padding-bottom: var(--avb-space-3);
  }
}

.avb-confirm[open] {
  align-items: center;
  padding: var(--avb-space-4);
}

.avb-confirm__panel {
  position: relative;
  width: min(380px, 100%);
  padding: var(--avb-space-5);
  border-radius: var(--avb-radius-panel);
  background: var(--avb-surface-sheet);
  box-shadow: var(--avb-shadow-3);
  text-align: center;
  animation: avb-confirm-in 250ms var(--avb-ease-out) both;
}

.avb-confirm__title {
  font-size: var(--avb-text-lg);
  font-weight: 600;
  line-height: 1.4;
}

.avb-confirm__text {
  margin-top: var(--avb-space-2);
  color: var(--avb-text-muted);
}

.avb-confirm__actions {
  display: flex;
  flex-direction: column;
  gap: var(--avb-space-2);
  margin-top: var(--avb-space-5);
}

.avb-confirm__actions .avb-btn {
  min-height: var(--avb-control-lg);
}

@keyframes avb-fade {
  from {
    opacity: 0;
  }
}

@keyframes avb-sheet-up {
  from {
    transform: translateY(100%);
  }
}

@keyframes avb-dialog-in {
  from {
    opacity: 0;
    transform: translateY(2%) scale(0.97);
  }
}

@keyframes avb-confirm-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}

/* ================================================================ toast */
.avb-toast-host,
.avb-toast-host[popover] {
  position: fixed;
  inset: auto;
  top: calc(var(--avb-safe-top) + var(--avb-space-3));
  left: 50%;
  z-index: var(--avb-z-toast);
  width: max-content;
  max-width: min(420px, 100% - 24px);
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--avb-text);
  overflow: visible;
  transform: translateX(-50%);
  pointer-events: none;
}

.avb-toast {
  display: flex;
  align-items: center;
  gap: var(--avb-space-2h);
  padding: var(--avb-space-3) var(--avb-space-4);
  border: 1px solid var(--avb-glass-border);
  border-radius: var(--avb-radius-control);
  background: var(--avb-glass);
  box-shadow: var(--avb-shadow-2);
  -webkit-backdrop-filter: var(--avb-blur-glass);
  backdrop-filter: var(--avb-blur-glass);
  font-size: var(--avb-text-toast);
  font-weight: 550;
  pointer-events: auto;
  animation: avb-toast-in 300ms var(--avb-ease-out) both;
}

.avb-toast--success .avb-icon {
  color: var(--avb-success);
}

.avb-toast--info .avb-icon {
  color: var(--avb-accent-text);
}

.avb-toast--error {
  color: var(--avb-danger);
}

@keyframes avb-toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ================================================================ banner */
.avb-banner {
  display: flex;
  align-items: flex-start;
  gap: var(--avb-space-3);
  padding: var(--avb-space-3) var(--avb-space-3h);
  border-radius: var(--avb-radius-md);
  font-size: var(--avb-text-nav);
}

.avb-banner--info {
  background: var(--avb-info-soft);
  color: var(--avb-info);
}

.avb-banner--success {
  background: var(--avb-success-soft);
  color: var(--avb-success);
}

.avb-banner--warning {
  background: var(--avb-warning-soft);
  color: var(--avb-warning);
}

.avb-banner--danger {
  background: var(--avb-danger-soft);
  color: var(--avb-danger);
}

.avb-banner__icon {
  flex: none;
  margin-top: 1px;
}

.avb-banner__body {
  flex: 1;
  min-width: 0;
}

.avb-banner__title {
  font-weight: var(--avb-weight-bold);
}

.avb-banner__text {
  color: var(--avb-text-2);
}

.avb-banner__action {
  flex: none;
  align-self: center;
}

.avb-banner__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  margin: -4px -6px -4px 0;
  border: 0;
  border-radius: var(--avb-radius-round);
  background: transparent;
  color: inherit;
}

.avb-banner__close:hover {
  background: var(--avb-surface-3);
}

/* ================================================================ badges and status pill */
.avb-badge,
.avb-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--avb-radius-pill);
  font-size: var(--avb-text-xs);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.avb-badge--neutral,
.avb-pill--neutral {
  background: var(--avb-surface-3);
  color: var(--avb-text-2);
}

.avb-badge--accent,
.avb-pill--accent {
  background: var(--avb-accent-soft);
  color: var(--avb-accent-text);
}

.avb-badge--success,
.avb-pill--success {
  background: var(--avb-success-soft);
  color: var(--avb-success);
}

.avb-badge--warning,
.avb-pill--warning {
  background: var(--avb-warning-soft);
  color: var(--avb-warning);
}

.avb-badge--danger,
.avb-pill--danger {
  background: var(--avb-danger-soft);
  color: var(--avb-danger);
}

.avb-badge--info,
.avb-pill--info {
  background: var(--avb-info-soft);
  color: var(--avb-info);
}

.avb-badge__dot,
.avb-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: var(--avb-radius-round);
  background: currentColor;
}

.avb-pill {
  padding: 5px 11px;
  border: 1px solid var(--avb-border);
}

/* ================================================================ empty state */
.avb-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--avb-space-2);
  padding: var(--avb-space-6) var(--avb-space-5);
  border: 1px solid var(--avb-border);
  border-radius: var(--avb-radius-card);
  background: var(--avb-surface);
  box-shadow: var(--avb-shadow-1);
  -webkit-backdrop-filter: var(--avb-blur-card);
  backdrop-filter: var(--avb-blur-card);
  text-align: center;
}

.avb-empty__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: var(--avb-space-1);
  border-radius: var(--avb-radius-card);
  background: var(--avb-accent-soft);
  color: var(--avb-accent-text);
}

.avb-empty__title {
  font-size: var(--avb-text-lg);
  font-weight: var(--avb-weight-strong);
}

.avb-empty__text {
  max-width: 44ch;
  color: var(--avb-text-muted);
  font-size: var(--avb-text-nav);
}

.avb-empty__action {
  margin-top: var(--avb-space-2);
}

/* ================================================================ spinner, skeleton */
.avb-spinner-wrap {
  display: inline-flex;
}

.avb-spinner {
  display: inline-block;
  flex: none;
  width: 22px;
  height: 22px;
  border: 2.5px solid var(--avb-surface-3);
  border-top-color: var(--avb-accent);
  border-radius: var(--avb-radius-round);
  animation: avb-spin var(--avb-duration-spin) linear infinite;
}

.avb-spinner--sm {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.avb-btn--primary .avb-spinner {
  border-color: var(--avb-surface-3);
  border-top-color: var(--avb-button-text);
}

.avb-spinner--lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
}

.avb-page-loader {
  display: grid;
  place-items: center;
  min-height: 40vh;
}

@keyframes avb-spin {
  to {
    transform: rotate(360deg);
  }
}

.avb-skeleton-group {
  display: flex;
  flex-direction: column;
  gap: var(--avb-space-2h);
}

.avb-skeleton {
  height: 14px;
  border-radius: var(--avb-radius-xs);
  background: linear-gradient(90deg, var(--avb-surface-3), var(--avb-surface-2), var(--avb-surface-3));
  background-size: 200% 100%;
  animation: avb-shimmer 1.4s ease-in-out infinite;
}

.avb-skeleton:last-child {
  width: 62%;
}

.avb-skeleton--block {
  height: 96px;
  border-radius: var(--avb-radius-card);
}

@keyframes avb-shimmer {
  from {
    background-position: 100% 0;
  }
  to {
    background-position: -100% 0;
  }
}

/* ================================================================ brand, switcher */
.avb-brand {
  display: flex;
  align-items: center;
  gap: var(--avb-space-2h);
  min-width: 0;
}

.avb-brand__mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: var(--avb-radius-md);
  background: var(--avb-button);
  color: var(--avb-button-text);
  box-shadow: var(--avb-button-shadow);
  font-family: var(--avb-font-display);
  font-size: var(--avb-text-h2);
  font-weight: var(--avb-weight-heavy);
}

.avb-brand__text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.avb-brand__title {
  font-family: var(--avb-font-display);
  font-size: var(--avb-text-brand);
  font-weight: var(--avb-weight-heavy);
  letter-spacing: var(--avb-tracking-tight);
  line-height: 1.05;
  white-space: nowrap;
}

.avb-brand__sub {
  margin-top: 3px;
  color: var(--avb-text-muted);
  font-size: 10px;
  font-weight: var(--avb-weight-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}

.avb-switcher {
  display: flex;
  align-items: center;
  gap: var(--avb-space-2h);
  width: 100%;
  min-height: var(--avb-control-lg);
  padding: var(--avb-space-1h) var(--avb-space-2h);
  border: 1px solid var(--avb-border);
  border-radius: var(--avb-radius-control);
  background: var(--avb-surface-2);
  color: var(--avb-text);
  text-align: left;
  transition: background-color var(--avb-duration-fast) var(--avb-ease-standard);
}

.avb-switcher:hover:not(:disabled) {
  background: var(--avb-surface-3);
}

.avb-switcher:disabled {
  cursor: default;
}

.avb-switcher__icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--avb-radius-sm);
  background: var(--avb-accent-soft);
  color: var(--avb-accent-text);
}

.avb-switcher__text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.avb-switcher__label {
  color: var(--avb-text-muted);
  font-size: 11px;
  font-weight: var(--avb-weight-label);
  line-height: 1.2;
}

.avb-switcher__value {
  font-size: var(--avb-text-nav);
  font-weight: var(--avb-weight-bold);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avb-switcher__chevron {
  flex: none;
  color: var(--avb-text-muted);
}

.avb-switcher--compact {
  width: auto;
  max-width: 100%;
  min-height: var(--avb-control-sm);
  padding: var(--avb-space-1) var(--avb-space-2h) var(--avb-space-1) var(--avb-space-1);
  border-radius: var(--avb-radius-pill);
}

.avb-switcher--compact .avb-switcher__label {
  display: none;
}

.avb-switcher--compact .avb-switcher__icon {
  width: 30px;
  height: 30px;
  border-radius: var(--avb-radius-round);
}

/* ================================================================ app shell (ADR-0021: no sidebar) */
/* phone (< 720px): sticky header, content, fixed glass bottom bar with "More" */
.avb-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--avb-nav-bar-height) + var(--avb-safe-bottom) + var(--avb-space-4));
}

.avb-shell__top {
  position: sticky;
  top: 0;
  z-index: var(--avb-z-header);
  border-bottom: 1px solid var(--avb-border);
  background: var(--avb-header);
  -webkit-backdrop-filter: var(--avb-blur-header);
  backdrop-filter: var(--avb-blur-header);
}

.avb-shell__header {
  display: flex;
  align-items: center;
  gap: var(--avb-space-2h);
  max-width: var(--avb-content-max);
  margin-inline: auto;
  padding: calc(var(--avb-safe-top) + var(--avb-space-2h)) calc(var(--avb-gutter) + var(--avb-safe-right)) var(--avb-space-2h)
    calc(var(--avb-gutter) + var(--avb-safe-left));
}

.avb-shell__header-brand {
  flex: none;
}

.avb-shell__header-brand .avb-brand__sub {
  display: none;
}

.avb-shell__header-switcher {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: var(--avb-space-2);
}

.avb-shell__actions {
  display: flex;
  align-items: center;
  gap: var(--avb-space-2);
  margin-left: auto;
  flex: none;
}

/* phone bottom bar */
.avb-shell__bottom {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: var(--avb-z-nav);
  padding: var(--avb-space-1h) calc(var(--avb-space-1h) + var(--avb-safe-right)) calc(var(--avb-space-1h) + var(--avb-safe-bottom))
    calc(var(--avb-space-1h) + var(--avb-safe-left));
  border-top: 1px solid var(--avb-glass-border);
  background: var(--avb-glass);
  -webkit-backdrop-filter: var(--avb-blur-glass);
  backdrop-filter: var(--avb-blur-glass);
}

.avb-nav {
  display: flex;
  margin: 0;
  padding: 0;
  list-style: none;
}

.avb-nav__item {
  flex: 1;
  min-width: 0;
}

.avb-nav__link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: none;
  color: var(--avb-text-muted);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  transition:
    color var(--avb-duration-base) var(--avb-ease-standard),
    background-color var(--avb-duration-base) var(--avb-ease-standard);
}

.avb-nav__link--bottom {
  flex-direction: column;
  gap: 3px;
  width: 100%;
  min-height: var(--avb-control-lg);
  padding: var(--avb-space-1) var(--avb-space-0);
  border-radius: var(--avb-radius-md);
  font-size: var(--avb-text-2xs);
  font-weight: 560;
}

.avb-nav__label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avb-nav__link--bottom[aria-current='page'] {
  color: var(--avb-accent-text);
  font-weight: var(--avb-weight-bold);
}

/* not colour-only: a short indicator bar marks the active item (audit 04 §7.6) */
.avb-nav__link--bottom[aria-current='page']::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 22px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--avb-accent);
  transform: translateX(-50%);
}

.avb-nav__badge {
  position: absolute;
  top: 2px;
  left: calc(50% + 6px);
  min-width: 18px;
  padding: 0 5px;
  border-radius: var(--avb-radius-pill);
  background: var(--avb-danger);
  color: var(--avb-surface-sheet);
  font-size: 10.5px;
  font-weight: var(--avb-weight-bold);
  line-height: 18px;
  text-align: center;
}

.avb-shell__main {
  flex: 1;
  width: 100%;
  max-width: var(--avb-content-max);
  margin-inline: auto;
  padding: var(--avb-space-4) calc(var(--avb-gutter) + var(--avb-safe-right)) var(--avb-space-6) calc(var(--avb-gutter) + var(--avb-safe-left));
  outline: none;
  animation: avb-view-in var(--avb-duration-screen) var(--avb-ease-out) both;
}

.avb-shell__banners {
  display: flex;
  flex-direction: column;
  gap: var(--avb-space-2);
  margin-bottom: var(--avb-space-4);
}

.avb-shell__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--avb-space-2) var(--avb-space-5);
  width: 100%;
  max-width: var(--avb-content-max);
  margin-inline: auto;
  padding: var(--avb-space-3) calc(var(--avb-gutter) + var(--avb-safe-right)) calc(var(--avb-space-3) + var(--avb-safe-bottom))
    calc(var(--avb-gutter) + var(--avb-safe-left));
  border-top: 1px solid var(--avb-border);
  color: var(--avb-text-muted);
  font-size: var(--avb-text-sm);
}

@media (max-width: 400px) {
  .avb-nav__link--bottom {
    font-size: 9.5px;
  }
  .avb-shell__header-brand .avb-brand__text {
    display: none;
  }
}

/* tablet and desktop (>= 720px): header row, then a horizontal row of navigation pills */
@media (min-width: 720px) {
  .avb-shell {
    padding-bottom: 0;
  }
  .avb-shell__header-brand .avb-brand__sub {
    display: block;
  }
  .avb-shell__header-switcher {
    flex: 0 1 auto;
  }
  .avb-shell__header-switcher .avb-switcher {
    width: auto;
    min-width: 0;
    max-width: 280px;
  }
  .avb-shell__nav {
    max-width: var(--avb-content-max);
    margin-inline: auto;
    padding: 0 calc(var(--avb-gutter) + var(--avb-safe-right)) var(--avb-space-2h) calc(var(--avb-gutter) + var(--avb-safe-left));
    overflow-x: auto;
    scrollbar-width: none;
  }
  .avb-shell__nav::-webkit-scrollbar {
    display: none;
  }
  .avb-nav {
    gap: var(--avb-space-1);
  }
  .avb-nav__item {
    flex: none;
  }
  .avb-nav__link--top {
    gap: var(--avb-space-2);
    min-height: var(--avb-control-sm);
    padding: 0 var(--avb-space-3h);
    border-radius: var(--avb-radius-md);
    font-size: var(--avb-text-nav);
    font-weight: var(--avb-weight-label);
    white-space: nowrap;
  }
  .avb-nav__link--top:hover {
    background: var(--avb-surface-3);
    color: var(--avb-text);
  }
  /* active: solid accent pill with white text (contrast 4.7:1) and a heavier weight — not colour-only */
  .avb-nav__link--top[aria-current='page'] {
    background: var(--avb-nav-active);
    color: var(--avb-nav-active-text);
    font-weight: var(--avb-weight-bold);
    box-shadow: var(--avb-button-shadow);
  }
  .avb-nav__link--top .avb-nav__badge {
    position: static;
  }
}

@media (min-width: 1010px) {
  .avb-shell__header {
    gap: var(--avb-space-4);
    padding-top: calc(var(--avb-safe-top) + var(--avb-space-3));
    padding-bottom: var(--avb-space-3);
  }
  .avb-shell__main {
    padding-top: var(--avb-space-5);
  }
}

/* ---------------------------------------------------------------- barcodes and labels (architecture 17) */

.avb-barcode {
  display: block;
  width: 100%;
  background: var(--avb-label-paper);
}

.avb-barcode rect {
  fill: var(--avb-label-ink);
}

.avb-label {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  overflow: hidden;
  padding: 2mm 2.5mm 1.5mm;
  background: var(--avb-label-paper);
  color: var(--avb-label-ink);
  font-family: var(--avb-font-body);
  break-inside: avoid;
}

.avb-label__name {
  display: -webkit-box;
  overflow: hidden;
  font-size: 9pt;
  font-weight: var(--avb-weight-bold);
  line-height: 1.15;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.avb-label__bars {
  flex: 1;
  min-height: 0;
  margin: 1mm 0 0.5mm;
}

.avb-label__code {
  font-family: var(--avb-font-mono);
  font-size: 8pt;
  letter-spacing: 0.08em;
  text-align: center;
}

.avb-label--58x40 {
  width: 58mm;
  height: 40mm;
}

.avb-label--40x30 {
  width: 40mm;
  height: 30mm;
}

.avb-label--30x20 {
  width: 30mm;
  height: 20mm;
  padding: 1mm 1.5mm;
}

.avb-label--30x20 .avb-label__name {
  font-size: 6.5pt;
  -webkit-line-clamp: 1;
}

.avb-label--30x20 .avb-label__code {
  font-size: 6pt;
}

.avb-print-root {
  display: none;
}

@page label58 {
  size: 58mm 40mm;
  margin: 0;
}

@page label40 {
  size: 40mm 30mm;
  margin: 0;
}

@page label30 {
  size: 30mm 20mm;
  margin: 0;
}

@media print {
  html.avb-printing body > :not(.avb-print-root) {
    display: none !important;
  }

  html.avb-printing .avb-print-root {
    display: block;
  }

  .avb-print-root .avb-label {
    break-after: page;
  }

  .avb-print-root .avb-label--58x40 {
    page: label58;
  }

  .avb-print-root .avb-label--40x30 {
    page: label40;
  }

  .avb-print-root .avb-label--30x20 {
    page: label30;
  }
}

/* ---------------------------------------------------------------- sales receipts (architecture 17 §10) */

.avb-receipt {
  box-sizing: border-box;
  padding: 3mm 3mm 4mm;
  background: var(--avb-label-paper);
  color: var(--avb-label-ink);
  font-family: var(--avb-font-mono);
  font-size: 9pt;
  line-height: 1.3;
}

.avb-receipt--80 {
  width: 80mm;
}

.avb-receipt--58 {
  width: 58mm;
  padding: 2mm 2mm 3mm;
  font-size: 7.5pt;
}

.avb-receipt__head,
.avb-receipt__meta,
.avb-receipt__lines {
  border-bottom: 1px dashed var(--avb-label-ink);
}

.avb-receipt__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5mm;
  padding-bottom: 2mm;
  text-align: center;
}

.avb-receipt__biz {
  font-size: 1.2em;
}

.avb-receipt__meta {
  display: flex;
  flex-direction: column;
  gap: 0.5mm;
  padding: 2mm 0;
}

.avb-receipt__ref {
  font-weight: var(--avb-weight-bold);
}

.avb-receipt__lines {
  margin: 0;
  padding: 2mm 0;
  list-style: none;
}

.avb-receipt__line + .avb-receipt__line {
  margin-top: 1.5mm;
}

.avb-receipt__name {
  display: block;
  overflow-wrap: anywhere;
}

.avb-receipt__calc,
.avb-receipt__row {
  display: flex;
  justify-content: space-between;
  gap: 2mm;
}

.avb-receipt__sum,
.avb-receipt__row dd {
  white-space: nowrap;
}

.avb-receipt__totals {
  margin: 0;
  padding: 2mm 0 0;
}

.avb-receipt__row dt,
.avb-receipt__row dd {
  margin: 0;
}

.avb-receipt__row--strong {
  font-size: 1.15em;
  font-weight: var(--avb-weight-bold);
}

.avb-receipt__code {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1mm;
  padding-top: 3mm;
}

.avb-receipt__code .avb-barcode {
  width: 70%;
  height: 11mm;
}

.avb-receipt__thanks {
  margin: 2mm 0 0;
  text-align: center;
}

.avb-receipt-stage {
  display: flex;
  justify-content: center;
  overflow-x: auto;
  padding: var(--avb-space-3);
  border: 1px dashed var(--avb-border-strong);
  border-radius: var(--avb-radius-card);
  background: var(--avb-surface-2);
}

.avb-receipt-stage .avb-receipt {
  flex: none;
  box-shadow: var(--avb-shadow-1);
}

.avb-print-root.avb-print-root--measure {
  display: block;
  position: absolute;
  top: 0;
  left: -10000px;
  visibility: hidden;
}

/* a roll has no page height: receipt.js sets the receipt's own length; this is the fallback */
@page receipt58 {
  size: 58mm 297mm;
  margin: 0;
}

@page receipt80 {
  size: 80mm 297mm;
  margin: 0;
}

@media print {
  .avb-print-root .avb-receipt--58 {
    page: receipt58;
  }

  .avb-print-root .avb-receipt--80 {
    page: receipt80;
  }
}

.avb-camera {
  position: relative;
  overflow: hidden;
  border-radius: var(--avb-radius-panel);
  background: var(--avb-label-ink);
  aspect-ratio: 4 / 3;
}

.avb-camera video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avb-camera__aim {
  position: absolute;
  inset: 38% 8%;
  border: 2px solid var(--avb-accent);
  border-radius: var(--avb-radius-sm);
  box-shadow: 0 0 0 999px var(--avb-scrim);
  pointer-events: none;
}

/* ---------------------------------------------------------------- attachments (receipts, invoices) */
.avb-attach {
  display: grid;
  gap: var(--avb-space-3);
}

.avb-attach__list {
  display: grid;
  gap: var(--avb-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.avb-attach__item {
  display: flex;
  align-items: center;
  gap: var(--avb-space-3);
  min-width: 0;
  padding: var(--avb-space-2);
  border: 1px solid var(--avb-border);
  border-radius: var(--avb-radius-md);
  background: var(--avb-surface);
}

.avb-attach__item.is-queued { border-style: dashed; }

.avb-attach__thumb {
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: var(--avb-radius-sm);
  background: var(--avb-surface-2);
  object-fit: cover;
}

.avb-attach__thumb--icon {
  display: grid;
  place-items: center;
  color: var(--avb-text-muted);
}

.avb-attach__name {
  display: grid;
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--avb-text);
  font-size: var(--avb-text-sm);
  text-decoration: none;
}

a.avb-attach__name:hover { text-decoration: underline; }

.avb-attach__zone {
  display: grid;
  justify-items: center;
  gap: var(--avb-space-2);
  padding: var(--avb-space-4) var(--avb-space-3);
  border: 1px dashed var(--avb-border-strong);
  border-radius: var(--avb-radius-md);
  background: var(--avb-surface-2);
  color: var(--avb-text-muted);
  text-align: center;
}

.avb-attach__zone.is-over {
  border-color: var(--avb-border-focus);
  background: var(--avb-accent-soft);
}

.avb-attach__zone.is-disabled { opacity: 0.6; }

.avb-attach__zone-text { font-size: var(--avb-text-sm); }

/* the camera button is for phones and tablets; desktops pick or drop */
@media (hover: hover) and (pointer: fine) {
  .avb-attach__camera { display: none; }
}

.avb-attach__errors {
  margin: 0;
  padding: var(--avb-space-2) var(--avb-space-3);
  border-radius: var(--avb-radius-sm);
  background: var(--avb-danger-soft);
  color: var(--avb-danger);
  font-size: var(--avb-text-sm);
  list-style: none;
}
