/* =========================================================================
   Don Topo POS — v5 Components
   Controles, datos, overlays compartidos. Completo sin v3/app.css.
   Requiere tokens + foundation. Dirección: editorial light POS, denso, afilado.
   ========================================================================= */

/* =========================================================================
   BOTONES
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  min-height: var(--touch);
  padding: 0 var(--space-3);
  border-radius: var(--r-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.86rem;
  font-weight: 700;
  width: 100%;
  box-shadow: none;
  text-decoration: none;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    opacity var(--dur) var(--ease),
    transform var(--dur) var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex: none;
}

.btn:active {
  transform: scale(0.985);
  opacity: 0.92;
}

.btn:disabled,
.btn.is-busy,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}

@media (hover: hover) {
  .btn:hover:not(:disabled):not(.is-busy) {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
  }
}

.btn.ghost {
  background: var(--surface-2);
  color: var(--ink-soft);
  border-color: var(--line-strong);
}

@media (hover: hover) {
  .btn.ghost:hover:not(:disabled) {
    border-color: var(--muted);
    color: var(--ink);
    background: var(--surface);
  }
}

.btn.ghost:active {
  background: var(--surface-3);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

@media (hover: hover) {
  .btn.danger:hover:not(:disabled) {
    filter: brightness(0.94);
  }
}

.btn.sm {
  min-height: 34px;
  width: auto;
  padding: 0 var(--space-2);
  font-size: 0.78rem;
  gap: 4px;
}

.btn.sm svg {
  width: 14px;
  height: 14px;
}

/* Icon button */
.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  box-shadow: none;
  position: relative;
  flex: none;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    opacity var(--dur) var(--ease);
}

.iconbtn svg {
  width: 20px;
  height: 20px;
}

.iconbtn:active {
  opacity: 0.88;
  background: var(--surface-2);
}

@media (hover: hover) {
  .iconbtn:hover {
    border-color: var(--line-strong);
    color: var(--ink);
    background: var(--surface-2);
  }
}

/* Desktop: una sola campana (topnav). .iconbtn no debe reaparecer la del appbar. */
@media (min-width: 1024px) {
  .appbar .appbar-bell {
    display: none !important;
  }
}

.iconbtn .dot {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.iconbtn.sm {
  width: 32px;
  height: 32px;
  min-width: 32px;
}

.iconbtn.sm svg {
  width: 17px;
  height: 17px;
}

.iconbtn.danger {
  color: var(--danger);
}

@media (hover: hover) {
  .iconbtn.danger:hover {
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
    background: var(--danger-soft);
  }
}

.iconbtn.is-disabled,
.iconbtn:disabled {
  opacity: 0.35;
  pointer-events: none;
  cursor: not-allowed;
}

label.iconbtn {
  cursor: pointer;
}

.iconbtn.is-pressed,
.btn.is-pressed,
button.is-pressed,
.chip.is-pressed {
  transform: scale(0.96);
  opacity: 0.88;
}

/* =========================================================================
   FORMULARIOS
   ========================================================================= */

.field {
  display: grid;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}

.field > label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.input,
select,
textarea,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}

textarea,
.field textarea {
  min-height: 84px;
  resize: vertical;
  padding-top: 10px;
}

.input:focus,
select:focus,
textarea:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  background: var(--surface);
}

.input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.85;
}

.input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--surface-2);
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 480px) {
  .row2 {
    grid-template-columns: 1fr;
  }
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.88rem;
  margin: 4px 0 12px;
  cursor: pointer;
  user-select: none;
}

.check input {
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--accent);
}

/* Search */
.search {
  position: relative;
}

.search > svg,
.search > .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

.search input,
.search .input {
  padding-left: 40px;
  padding-right: 36px;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

@media (hover: hover) {
  .search-clear:hover {
    background: var(--surface-2);
    color: var(--ink);
  }
}

.search-hotkey {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  pointer-events: none;
}

@media (min-width: 1024px) and (hover: hover) {
  .search-hotkey {
    display: inline-flex;
  }
  .search:focus-within .search-hotkey {
    display: none;
  }
}

/* =========================================================================
   CHIPS / PILLS
   ========================================================================= */

.chips {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  white-space: nowrap;
  flex: none;
  padding: 6px 10px;
  min-height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 650;
  cursor: pointer;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.chip.is-active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.chip-accent {
  background: var(--gold-soft);
  border-color: color-mix(in srgb, var(--gold) 32%, var(--line));
  color: var(--gold-strong);
  font-weight: 750;
}

@media (hover: hover) {
  .chip:hover:not(.is-active) {
    border-color: var(--muted);
    color: var(--ink);
  }

  .chip-accent:hover:not(.is-active) {
    border-color: var(--gold);
    color: var(--gold-strong);
    background: color-mix(in srgb, var(--gold-soft) 70%, var(--surface));
  }
}

.chip:active {
  opacity: 0.9;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: var(--r-sm);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid var(--line);
  color: var(--ink-soft);
  background: var(--surface-2);
  line-height: 1.2;
}

.pill.ok {
  color: var(--ok);
  background: var(--ok-soft);
  border-color: transparent;
}

.pill.warn {
  color: var(--warn);
  background: var(--warn-soft);
  border-color: transparent;
}

.pill.danger {
  color: var(--danger);
  background: var(--danger-soft);
  border-color: transparent;
}

/* =========================================================================
   CARDS / MÉTRICAS / HERO
   ========================================================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--space-3);
  box-shadow: none;
}

.card + .card {
  margin-top: var(--space-2);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.card-head h3 {
  font-size: 0.95rem;
}

.card-head a {
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}

.card-head a:hover {
  text-decoration: underline;
}

/* Hero editorial oscuro (opcional) */
.hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: var(--accent-ink);
  border: none;
  border-radius: var(--r);
  padding: var(--space-4);
  box-shadow: none;
}

.hero::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 48px 32px;
  border-color: transparent transparent transparent var(--gold);
  opacity: 0.9;
  pointer-events: none;
}

.hero .eyebrow {
  color: rgba(255, 255, 255, 0.78);
  position: relative;
}

.hero .big {
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0;
  position: relative;
  font-variant-numeric: tabular-nums;
}

.hero p {
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.84rem;
  position: relative;
}

.hero .hero-foot {
  display: flex;
  gap: 14px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  position: relative;
  flex-wrap: wrap;
}

.hero .hero-foot div span {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.7rem;
}

.hero .hero-foot div strong {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.hero .delta.up { color: #d8f7e6; }
.hero .delta.down { color: #ffdcd3; }

/* Metrics */
.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

.metrics > * {
  min-width: 0;
}

.metrics.cols3 {
  grid-template-columns: repeat(3, 1fr);
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
  box-shadow: none;
}

.metric span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.metric strong {
  display: block;
  font-size: 1.15rem;
  margin: 2px 0 1px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.metric strong.v-pos { color: var(--ok); }
.metric strong.v-warn { color: var(--warn); }
.metric strong.v-crit { color: var(--danger); }

.metric small {
  color: var(--muted);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: var(--space-4);
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 10px 12px;
  box-shadow: none;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.stat strong {
  display: block;
  font-size: 1.05rem;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.stat.is-warn strong { color: var(--warn); }
.stat.is-danger strong { color: var(--danger); }
.stat.is-ok strong { color: var(--ok); }

@media (min-width: 768px) {
  .metrics.cols3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .stat-row {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* =========================================================================
   TABLAS
   ========================================================================= */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tr:last-child td {
  border-bottom: none;
}

td.truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Paginación */
.paged {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.paged > .table-wrap,
.paged > .list {
  max-height: min(58dvh, 560px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.paged > .table-wrap table {
  margin: 0;
}

.paged > .table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--line);
}

.paged > .pager {
  flex: none;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.pager-info {
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 44px;
  text-align: center;
}

.pager-btn,
.pager-num {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

@media (hover: hover) {
  .pager-btn:hover:not(:disabled),
  .pager-num:hover:not(.is-active) {
    background: var(--surface-2);
    border-color: var(--muted);
  }
}

.pager-nums {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
}

.pager-num.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.pager-ellipsis {
  color: var(--muted);
  padding: 0 2px;
  font-weight: 700;
}

.pager-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.pager-size {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.pager-size-sel {
  min-height: 34px;
  padding: 0 28px 0 10px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 24px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  background: transparent;
}

/* Tablas → cards en móvil */
@media (max-width: 720px) {
  table.cards thead {
    display: none;
  }

  table.cards,
  table.cards tbody,
  table.cards tr,
  table.cards td {
    display: block;
    width: 100%;
  }

  table.cards tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    box-shadow: none;
    padding: 9px 11px;
    margin-bottom: 6px;
  }

  table.cards tr:last-child {
    margin-bottom: 2px;
  }

  table.cards td {
    border: none;
    padding: 4px 0;
    white-space: normal;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 14px;
    text-align: right;
  }

  table.cards td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    text-align: left;
  }

  table.cards td.truncate {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
  }

  table.cards td.is-actions {
    justify-content: flex-end;
    padding-top: 8px;
  }

  table.cards td.is-actions::before {
    display: none;
  }

  table.cards .table-empty td {
    justify-content: center;
  }

  .table-wrap:has(table.cards) {
    overflow-x: visible;
    margin: 0;
  }
}

/* =========================================================================
   LISTAS / BARRAS
   ========================================================================= */

.list {
  display: grid;
  gap: var(--space-2);
}

.item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: none;
}

.item .i-name {
  font-weight: 600;
}

.item .i-meta {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.item .i-right {
  text-align: right;
  display: grid;
  gap: 4px;
  justify-items: end;
}

.item .i-amount {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-family: var(--display);
}

.item.has-thumb {
  grid-template-columns: auto 1fr auto;
}

a.item.is-link {
  color: inherit;
  text-decoration: none;
}

@media (hover: hover) {
  a.item.is-link:hover {
    background: var(--surface-2);
  }
}

.bar {
  height: 7px;
  border-radius: var(--r-xs);
  background: var(--line);
  overflow: hidden;
  margin-top: 6px;
  max-width: 160px;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
}

.item.is-low .bar > span { background: var(--warn); }
.item.is-empty .bar > span { background: var(--danger); }

.bar-wide {
  max-width: none;
  height: 10px;
  margin-top: 12px;
}

/* =========================================================================
   PERIOD TABS
   ========================================================================= */

.period-tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  margin-bottom: var(--space-3);
}

.period-tabs::-webkit-scrollbar {
  display: none;
}

.period-tab {
  white-space: nowrap;
  flex: none;
  padding: 7px 12px;
  min-height: 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background var(--dur) var(--ease),
    color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.period-tab.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

@media (hover: hover) {
  .period-tab:hover:not(.is-active) {
    border-color: var(--muted);
    color: var(--ink);
  }
}

.period-tab:active {
  opacity: 0.92;
}

/* Scope marker for view panels (Anulaciones / tabs). Keeps card layout. */
.tabs-scope {
  min-width: 0;
}

.tabs-scope.hide {
  display: none !important;
}

/* =========================================================================
   MODALES
   ========================================================================= */

.modal-wrap {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), visibility var(--dur) var(--ease);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-wrap.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal {
  width: min(400px, 100%);
  max-height: calc(100dvh - 32px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--space-4);
  box-shadow: var(--shadow-lift);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: auto;
}

.modal-lg {
  width: min(560px, 100%);
}

.modal h3 {
  font-size: 1.02rem;
  margin-bottom: 6px;
}

.modal p {
  margin-bottom: 14px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex: none;
}

.modal-head h3 {
  margin: 0;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: none;
}

.modal-actions.actions-single {
  grid-template-columns: 1fr;
}

.modal form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.modal form .modal-actions {
  margin-top: 18px;
}

.modal > .paged {
  flex: 1 1 auto;
  min-height: 0;
}

.modal > .paged > .table-wrap,
.modal > .paged > .list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.modal > .table-wrap,
.modal > .list,
.modal > .empty {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.modal > .search {
  flex: none;
  margin-bottom: 12px;
}

.modal .table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
}

/* —— Confirmación (Taller Blanco / nivel login) —— */
#confirm-modal {
  z-index: calc(var(--z-modal) + 8);
  background: rgba(20, 19, 15, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
}

#confirm-modal .confirm-card,
#confirm-modal .modal.confirm-card {
  position: relative;
  width: min(400px, 100%);
  padding: 26px 24px 22px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  box-shadow:
    0 1px 2px rgba(20, 19, 15, 0.05),
    0 28px 60px -24px rgba(20, 19, 15, 0.45);
  overflow: hidden;
}

#confirm-modal .confirm-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  height: 3px;
  background: var(--gold);
}

#confirm-modal .confirm-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

#confirm-modal .confirm-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 2px;
  background: var(--surface-2, #f7f6f2);
  color: var(--ink);
  font-family: var(--display);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: -0.03em;
}

#confirm-modal .confirm-kicker {
  margin: 0;
  color: var(--gold-strong, #9a7209);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#confirm-modal #confirm-title {
  margin: 0 0 8px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 850;
  letter-spacing: -0.035em;
  line-height: 1.15;
}

#confirm-modal #confirm-msg {
  margin: 0 0 22px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.45;
}

#confirm-modal .confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}

#confirm-modal .confirm-actions .btn {
  min-height: 44px;
  border-radius: 2px;
  font-weight: 750;
  gap: 8px;
}

#confirm-modal #confirm-yes.confirm-yes-ink,
#confirm-modal #confirm-yes:not(.danger) {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

#confirm-modal #confirm-yes.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

#confirm-modal .confirm-kbd {
  display: inline-grid;
  place-items: center;
  min-width: 2.1em;
  padding: 2px 5px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.12);
  color: inherit;
  font-family: var(--font);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  line-height: 1.2;
}

#confirm-modal #confirm-no .confirm-kbd {
  border-color: var(--line);
  background: var(--surface-2, #f7f6f2);
  color: var(--muted);
}

/* —— Detalle de pedido (#modal-order) —— */
#modal-order {
  z-index: var(--z-keypad);
}

#modal-order .modal {
  width: min(560px, 100%);
}

#modal-order .modal-head {
  align-items: flex-start;
}

#modal-order #order-title {
  margin: 0 0 2px;
  font-size: 1.05rem;
}

#modal-order #order-meta {
  display: block;
  font-size: 0.78rem;
}

#modal-order #order-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--space-2);
}

#modal-order #order-cancel-hint {
  flex: none;
  margin: 0 0 var(--space-3);
}

#modal-order.is-readonly #order-cancel-hint {
  display: none;
}

#modal-order.is-readonly .modal {
  position: relative;
  width: min(440px, 100%);
  max-height: min(88dvh, 720px);
  padding: 0;
  border: 1px solid #e4e2d8;
  border-radius: 2px;
  background: #fffef9;
  box-shadow:
    0 1px 0 rgba(20, 19, 15, 0.04),
    0 22px 56px rgba(20, 19, 15, 0.12);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#modal-order.is-readonly .modal-head {
  display: none !important;
}

#modal-order.is-readonly #order-body {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#modal-order.is-readonly .modal-actions,
#modal-order.is-readonly .modal-actions.actions-single {
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 0;
  padding: 12px 18px 14px;
  border-top: 1px solid #e4e2d8;
  background: #fff;
}

#modal-order.is-readonly .modal-actions .btn {
  width: 100%;
  min-height: 40px;
  margin: 0;
  border-radius: 2px;
  font-weight: 750;
}

#modal-order.is-readonly .order-copy,
#modal-order.is-readonly #order-copy {
  width: 100%;
  margin: 0;
  flex: none;
}

#modal-order .modal-actions {
  margin-top: 0;
}

/* Ticket readonly — claro, scroll de ítems */
#modal-order.is-readonly .order-ticket {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 0;
  border-radius: 0;
  background: #fffef9;
  overflow: hidden;
}

#modal-order.is-readonly .order-ticket-top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 14px 18px;
  border-bottom: 1px solid #e4e2d8;
  background:
    linear-gradient(90deg, #c8922e 0 3px, transparent 3px),
    #fff;
}

#modal-order.is-readonly .order-ticket-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#modal-order.is-readonly .order-ticket-mark {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid #e4e2d8;
  border-radius: 2px;
  background: #fff8e8;
  color: #8a6414;
  font-family: var(--display, Georgia, serif);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

#modal-order.is-readonly .order-ticket-brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

#modal-order.is-readonly .order-ticket-brand-copy strong {
  color: #14130f;
  font-family: var(--display, Georgia, serif);
  font-size: 1.1rem;
  font-weight: 850;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

#modal-order.is-readonly .order-ticket-brand-copy span {
  color: #73736b;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#modal-order.is-readonly .order-ticket-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  margin: 0;
  padding: 0;
  border: 1px solid #e4e2d8;
  border-radius: 2px;
  background: #fff;
  color: #5c5a52;
  cursor: pointer;
  flex: none;
}

#modal-order.is-readonly .order-ticket-close svg {
  width: 15px;
  height: 15px;
  display: block;
}

#modal-order.is-readonly .order-ticket-close:hover {
  border-color: #c8922e;
  color: #14130f;
  background: #fffef2;
}

#modal-order.is-readonly .order-ticket-idrow {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 14px 18px 4px;
  background: #fffef9;
}

#modal-order.is-readonly .order-ticket-id {
  color: #14130f;
  font-family: var(--display, Georgia, serif);
  font-size: 1.45rem;
  font-weight: 850;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

#modal-order.is-readonly .order-ticket-pay {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #14130f;
  font-size: 0.8rem;
  font-weight: 780;
  letter-spacing: -0.01em;
}

#modal-order.is-readonly .order-ticket-pay::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c8922e;
}

#modal-order.is-readonly .order-ticket-pay.is-efectivo::before { background: #19704a; }
#modal-order.is-readonly .order-ticket-pay.is-transferencia::before { background: #315f85; }
#modal-order.is-readonly .order-ticket-pay.is-mixto::before { background: #a85f0a; }

#modal-order.is-readonly .order-ticket-sub {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  margin: 0;
  padding: 0 18px 12px;
  border-bottom: 1px dashed #ddd9cc;
  background: #fffef9;
}

#modal-order.is-readonly .order-ticket-when {
  margin: 0;
  color: #73736b;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
}

#modal-order.is-readonly .order-ticket-count {
  color: #8a6414;
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: -0.01em;
}

#modal-order.is-readonly .order-ticket-lines {
  flex: 1 1 auto;
  min-height: 0;
  display: block;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 4px 0;
  background: #fff;
  scrollbar-width: thin;
  scrollbar-color: #d4cfc0 transparent;
}

#modal-order.is-readonly .order-ticket-lines::-webkit-scrollbar {
  width: 8px;
}

#modal-order.is-readonly .order-ticket-lines::-webkit-scrollbar-thumb {
  background: #d4cfc0;
  border-radius: 4px;
}

#modal-order.is-readonly .order-ticket-empty {
  padding: 28px 18px;
  color: #73736b;
  font-size: 0.88rem;
  font-weight: 600;
}

#modal-order.is-readonly .order-ticket-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px;
  margin: 0;
  padding: 12px 18px;
  border: 0;
  border-bottom: 1px solid #f0ede4;
  border-radius: 0;
  background: transparent;
}

#modal-order.is-readonly .order-ticket-line:last-child {
  border-bottom: 0;
}

#modal-order.is-readonly .order-ticket-line-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}

#modal-order.is-readonly .order-ticket-line-main strong {
  color: #14130f;
  font-size: 0.92rem;
  font-weight: 750;
  letter-spacing: -0.02em;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

#modal-order.is-readonly .order-ticket-line-main span {
  color: #73736b;
  font-size: 0.74rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

#modal-order.is-readonly .order-ticket-line-amt {
  color: #14130f;
  font-family: var(--display, Georgia, serif);
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}

#modal-order.is-readonly .order-ticket-foot {
  flex: none;
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-top: 1px solid #e4e2d8;
  box-shadow: inset 0 3px 0 #c8922e;
  background: #f7f4eb;
  color: #14130f;
}

#modal-order.is-readonly .order-ticket-foot > div {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 14px 18px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#modal-order.is-readonly .order-ticket-foot > div + div {
  border-left: 1px solid #e4e2d8;
}

#modal-order.is-readonly .order-ticket-foot span {
  display: block;
  margin: 0;
  color: #73736b;
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#modal-order.is-readonly .order-ticket-foot strong {
  color: #14130f;
  font-family: var(--display, Georgia, serif);
  font-size: 1.28rem;
  font-weight: 850;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

#modal-order.is-readonly .order-ticket-profit strong {
  color: #8a6414;
}

.order-copy,
#order-copy {
  width: auto;
  flex: none;
  align-self: center;
}

#modal-order:not(.is-readonly) .modal-head .order-copy,
#modal-order:not(.is-readonly) .modal-head #order-copy {
  margin-left: auto;
  margin-right: 4px;
}

.order-lines {
  display: grid;
  gap: 8px;
}

.order-line {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.order-line-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.order-line-main {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.order-line-main strong {
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-line-main .muted {
  font-size: 0.76rem;
}

.order-line-side {
  text-align: right;
  flex-shrink: 0;
  display: grid;
  gap: 1px;
}

.order-line-side .muted {
  font-size: 0.68rem;
}

.order-profit {
  color: var(--ok);
  font-size: 0.95rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.order-line-link {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
}

@media (hover: hover) {
  .order-line-link:hover {
    text-decoration: underline;
    color: var(--gold-strong);
  }
}

.order-foot {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.order-foot > div {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

.order-foot span {
  display: block;
  font-size: 0.72rem;
  margin-bottom: 2px;
  color: var(--muted);
  font-weight: 600;
}

.order-foot strong {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--display);
}

@media (max-width: 420px) {
  .order-foot {
    grid-template-columns: 1fr;
  }
}

/* =========================================================================
   ALERTAS (campana) — popover, no cajón pesado
   ========================================================================= */

.alerts-panel {
  position: fixed;
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  background: #fffef9;
  border: 1px solid var(--line);
  border-radius: 2px;
  box-shadow:
    0 1px 2px rgba(20, 19, 15, 0.04),
    0 22px 48px -20px rgba(20, 19, 15, 0.32);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition:
    opacity 160ms var(--ease),
    transform 180ms var(--ease);
}

.alerts-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Móvil: hoja inferior compacta */
@media (max-width: 1023px) {
  .alerts-panel {
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    top: auto;
    width: auto;
    max-height: min(72dvh, 520px);
    transform: translateY(12px);
  }

  .alerts-panel.open {
    transform: translateY(0);
  }
}

/* Desktop: anclado bajo la campana */
@media (min-width: 1024px) {
  .alerts-panel {
    top: calc(var(--topnav-h, 56px) + 8px);
    right: clamp(14px, 2.2vw, 32px);
    bottom: auto;
    width: min(360px, calc(100vw - 28px));
    max-height: min(70vh, 480px);
  }

  .alerts-panel::before {
    content: "";
    position: absolute;
    right: 18px;
    top: -6px;
    width: 10px;
    height: 10px;
    background: #fffef9;
    border-left: 1px solid var(--line);
    border-top: 1px solid var(--line);
    transform: rotate(45deg);
  }
}

.alerts-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.alerts-head-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.alerts-head-copy strong {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.alerts-head-copy small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

.alerts-body {
  padding: 10px;
  overflow-y: auto;
  display: grid;
  gap: 8px;
  flex: 1 1 auto;
  min-height: 0;
}

.alert-empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 28px 16px;
  text-align: center;
}

.alert-empty-ico {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-bottom: 4px;
  border: 1px solid color-mix(in srgb, var(--ok) 28%, var(--line));
  border-radius: 2px;
  background: color-mix(in srgb, var(--ok-soft) 70%, #fff);
  color: var(--ok);
}

.alert-empty-ico svg {
  width: 20px;
  height: 20px;
}

.alert-empty strong {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.alert-empty p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 550;
  max-width: 22ch;
}

.alert-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}

a.alert-item {
  cursor: pointer;
}

@media (hover: hover) {
  a.alert-item:hover {
    border-color: color-mix(in srgb, var(--ink) 16%, var(--line));
    background: var(--surface-2);
    text-decoration: none;
  }
}

.alert-item-ico {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--surface-2);
  color: var(--ink);
  flex: none;
}

.alert-item-ico svg {
  width: 17px;
  height: 17px;
}

.alert-item-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding-top: 1px;
}

.alert-item-copy strong {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.alert-item-copy em {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 550;
  line-height: 1.35;
}

.alert-item-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  color: var(--ink);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.alert-item-cta::after {
  content: "→";
  opacity: 0.55;
}

.alert-item.is-warn .alert-item-ico {
  border-color: color-mix(in srgb, var(--warn) 30%, var(--line));
  background: color-mix(in srgb, var(--warn-soft) 75%, #fff);
  color: color-mix(in srgb, var(--warn) 85%, var(--ink));
}

.alert-item.is-danger .alert-item-ico {
  border-color: color-mix(in srgb, var(--danger) 28%, var(--line));
  background: color-mix(in srgb, var(--danger-soft) 70%, #fff);
  color: color-mix(in srgb, var(--danger) 80%, var(--ink));
}

.alert-item.is-info .alert-item-ico {
  border-color: color-mix(in srgb, var(--info) 28%, var(--line));
  background: color-mix(in srgb, var(--info-soft, var(--surface-2)) 70%, #fff);
}

.iconbtn.has-alerts {
  border-color: color-mix(in srgb, var(--warn) 32%, var(--line));
  background: color-mix(in srgb, var(--warn-soft) 55%, #fff);
  color: color-mix(in srgb, var(--warn) 70%, var(--ink));
}

.iconbtn.has-alerts .dot {
  background: var(--warn);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  .alerts-panel {
    transition: none;
  }
}

/* =========================================================================
   MORE SHEET (móvil)
   ========================================================================= */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-backdrop);
  background: var(--scrim);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-slow) var(--ease);
  touch-action: none;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* Bloqueo de scroll del fondo con overlay / ticket abierto */
html.is-scroll-locked,
html.is-scroll-locked body {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.more-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-drawer);
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 8px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-lift);
  transform: translateY(100%);
  transition: transform var(--dur-enter) var(--ease);
  max-height: 80dvh;
  overflow-y: auto;
}

.more-sheet.open {
  transform: translateY(0);
}

.sheet-grip {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  margin: 4px auto 10px;
}

.more-user {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #fffef9;
}

.more-user .av {
  width: 40px;
  height: 40px;
  border-left: 3px solid var(--gold);
}

.more-user strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.more-user small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
}

.more-label {
  margin: 14px 2px 6px;
  color: var(--gold-strong, #9a7209);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.more-label:first-of-type {
  margin-top: 4px;
}

.more-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-top: 6px;
}

.more-logout {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.more-logout .btn {
  width: 100%;
  justify-content: center;
  gap: 8px;
}

.more-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.more-link svg {
  width: 22px;
  height: 22px;
  color: var(--ink);
}

@media (hover: hover) {
  .more-link:hover {
    background: var(--surface-2);
    border-color: var(--line-strong);
    color: var(--ink);
    text-decoration: none;
  }
}

.more-link:active {
  opacity: 0.9;
}

/* =========================================================================
   KEYPAD
   ========================================================================= */

.keypad-wrap {
  position: fixed;
  inset: 0;
  z-index: var(--z-keypad);
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}

.keypad-wrap.open {
  opacity: 1;
  pointer-events: auto;
}

.keypad {
  width: min(400px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  padding: var(--space-3);
  box-shadow: var(--shadow-lift);
}

.keypad-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.keypad-head strong {
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.keypad-display {
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  text-align: right;
  font-size: 1.85rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--space-2);
  background: var(--bg);
  color: var(--ink);
  letter-spacing: -0.03em;
  font-family: var(--display);
}

.keypad-info {
  min-height: 20px;
  margin: -2px 2px 8px;
  text-align: right;
  font-weight: 700;
  font-size: 0.82rem;
}

.keypad-info.is-ok { color: var(--ok); }
.keypad-info.is-short { color: var(--danger); }

.keypad.shake {
  animation: kpShake 0.3s var(--ease);
}

@keyframes kpShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

.keypad-chips {
  display: flex;
  gap: 6px;
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.keypad-chips button {
  flex: 1;
  min-width: 62px;
  min-height: var(--touch);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.keypad-chips button:active {
  border-color: var(--accent);
  color: var(--accent);
}

.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: var(--space-3);
}

.keypad-grid button {
  min-height: 54px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.keypad-grid button:active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.keypad-grid button.act {
  color: var(--danger);
}

.keypad-alt {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 0 0 var(--space-2);
}

.keypad-alt.hide {
  display: none;
}

.keypad-alt button {
  border: 1px dashed var(--line-strong);
  background: transparent;
  color: var(--muted);
  border-radius: var(--r-sm);
  padding: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

.keypad-alt button:active {
  color: var(--ink);
  border-color: var(--ink-soft);
}

#keypad-ok,
.keypad-ok {
  width: 100%;
}

/* =========================================================================
   TOAST — arriba al centro (zona del mast), animación corta y nítida
   ========================================================================= */

.toast {
  position: fixed;
  left: 50%;
  right: auto;
  top: calc(12px + env(safe-area-inset-top, 0px));
  bottom: auto;
  z-index: var(--z-toast);
  width: min(360px, calc(100vw - 28px));
  margin: 0;
  padding: 10px 14px;
  border-radius: 2px;
  background: #fffef9;
  color: var(--ink);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  box-shadow:
    0 1px 2px rgba(20, 19, 15, 0.04),
    0 12px 24px -14px rgba(20, 19, 15, 0.22);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.3;
  opacity: 0;
  transform: translate(-50%, -6px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 120ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 120ms cubic-bezier(0.22, 1, 0.36, 1);
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
  pointer-events: auto;
}

.toast.error {
  border-top-color: var(--danger);
  background: #fff8f6;
}

.toast.success {
  border-top-color: var(--ok, #2f7a4f);
}

.toast.warn {
  border-top-color: var(--warn, #b8860b);
  background: #fffbf2;
}

.toast svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.toast > span {
  flex: 1;
  min-width: 0;
}

.toast-undo {
  margin: 0;
  flex: none;
}

.toast-undo-btn {
  border: 1px solid var(--line);
  background: var(--surface-2, #f7f6f2);
  color: var(--ink);
  font-weight: 750;
  font-size: 0.76rem;
  padding: 6px 10px;
  border-radius: 2px;
  cursor: pointer;
}

@media (hover: hover) {
  .toast-undo-btn:hover {
    border-color: var(--ink);
  }
}

.toast-x {
  background: none;
  border: none;
  color: var(--muted);
  opacity: 0.9;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  margin-left: 4px;
  flex: none;
}

@media (hover: hover) {
  .toast-x:hover {
    color: var(--ink);
    opacity: 1;
  }
}

/* Escritorio: bajo el topnav, centrado en el hueco del mast */
@media (min-width: 1024px) {
  .toast {
    top: calc(var(--topnav-h, 56px) + 10px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: opacity 70ms linear;
    transform: translate(-50%, 0) scale(1);
  }
}

/* =========================================================================
   BUSY OVERLAY
   ========================================================================= */

#busy-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-busy);
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
}

#busy-overlay .busy-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 12px 16px;
  box-shadow: var(--shadow-lift);
  font-weight: 700;
  font-size: 0.88rem;
}

#busy-overlay .busy-spin {
  width: 22px;
  height: 22px;
  flex: none;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: busySpin 0.7s linear infinite;
}

@keyframes busySpin {
  to { transform: rotate(360deg); }
}

/* =========================================================================
   THUMBS / FOTOS
   ========================================================================= */

.thumb {
  display: block;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  flex: none;
  border-radius: var(--r-sm);
  background-color: var(--surface-3);
}

.thumb-mono {
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: 0.01em;
  background: var(--surface-3);
  color: var(--ink-soft);
}

.thumb-mono svg {
  width: 58%;
  height: 58%;
}

.tile-thumb {
  width: 100%;
  height: 52px;
  border-radius: var(--r-sm);
  font-size: 1rem;
  margin-bottom: 3px;
}

.prod-photo {
  width: 58px;
  height: 58px;
  border-radius: var(--r);
  font-size: 1.05rem;
}

.i-thumb {
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  font-size: 0.8rem;
}

.i-thumb.thumb-mono svg {
  width: 56%;
  height: 56%;
}

/* =========================================================================
   HINTS / BANNERS
   ========================================================================= */

.hint {
  font-size: 0.78rem;
  margin: 8px 0 2px;
  color: var(--muted);
  line-height: 1.4;
}

.hint.muted {
  color: var(--muted);
}

.soft-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  border-color: var(--accent-soft) !important;
  background: var(--accent-soft) !important;
  font-size: 0.86rem;
}

.soft-banner a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* =========================================================================
   LINKS GENÉRICOS / BACK
   ========================================================================= */

.link-btn {
  background: none;
  border: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

@media (hover: hover) {
  .link-btn:hover {
    color: var(--gold-strong);
    border-bottom-color: color-mix(in srgb, var(--gold) 45%, transparent);
    text-decoration: none;
  }
}

.link-btn:active {
  opacity: 0.85;
}

.back-link {
  color: var(--ink);
  font-weight: 700;
  font-size: 0.9rem;
}

.back-link:hover {
  text-decoration: underline;
  color: var(--gold-strong);
}

/* =========================================================================
   CART FAB (shell-adjacent, usado en chrome)
   ========================================================================= */

.cart-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tabbar-h) + 12px);
  z-index: var(--z-fab);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--r);
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 700;
  box-shadow: var(--shadow);
  transform: translateY(180%);
  transition: transform var(--dur-enter) var(--ease);
}

.cart-fab.show {
  transform: translateY(0);
}

.cart-fab svg {
  width: 20px;
  height: 20px;
}

.cart-fab .cf-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.22);
  display: inline-grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.cart-fab .cf-total {
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--display);
}

@media (min-width: 1024px) {
  .cart-fab {
    display: none;
  }
}

/* —— Staff duty segments (caja / vender / claim) —— */
.staff-seg {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  min-height: 44px;
  height: 44px;
  border: 1px solid var(--line-strong, var(--line));
  border-radius: 2px;
  background: var(--wash, #f4f1ea);
  overflow: hidden;
  box-sizing: border-box;
}

.staff-seg.is-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.staff-seg button {
  min-height: 0;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  border-right: 1px solid var(--line, rgba(20, 19, 15, 0.12));
  background: transparent;
  color: var(--muted, #6b655c);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 760;
  cursor: pointer;
  box-shadow: none;
}

.staff-seg button:last-child {
  border-right: 0;
}

.staff-seg button.is-active {
  background: #fff;
  color: var(--ink, #14130f);
  font-weight: 820;
}

.staff-duty-field {
  margin: 0;
}

.staff-duty-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 740;
}

.staff-duty-form {
  display: grid;
  gap: 12px;
  padding: 4px 0 0;
}

.staff-duty-modal .modal-actions {
  margin-top: 4px;
}
