/* Components built on tokens.css. Compact, mobile-first. */

/* --- Base elements ------------------------------------------------------------------------- */
[hidden] { display: none !important; }
h2 { font-size: var(--text-md); margin: 0 0 var(--space-2); }
.section-title { margin: var(--space-6) 0 var(--space-2); }
.muted { color: var(--color-text-muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.is-negative { color: var(--color-danger); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* --- Alerts -------------------------------------------------------------------------------- */
.alert { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3); border: 1px solid var(--color-border); border-left-width: 4px; border-radius: var(--radius-md); background: var(--color-surface); }
.alert--success { border-left-color: var(--color-accent-strong); }
.alert--error { border-left-color: var(--color-danger); }
.alert--info { border-left-color: var(--color-primary); }
.alert__close { margin-left: auto; padding: 0 var(--space-1); font-size: var(--text-lg); line-height: 1.2; color: var(--color-text-muted); background: none; border: 0; cursor: pointer; }

/* --- Cards, stats -------------------------------------------------------------------------- */
.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-4); }
.card--narrow { max-width: 26rem; }
.card > :first-child { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); margin-bottom: var(--space-4); }
.stat { display: flex; flex-direction: column; padding: var(--space-2) var(--space-3); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.stat__label { color: var(--color-text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; }
.stat__value { font-size: var(--text-lg); font-weight: 700; font-variant-numeric: tabular-nums; }
.stat--accent { border-color: var(--color-accent); }
.stat--accent .stat__value { color: var(--color-success); }
@media (min-width: 40rem) { .stats { grid-template-columns: repeat(4, 1fr); } }

/* --- Forms and buttons --------------------------------------------------------------------- */
.field { margin-bottom: var(--space-3); }
.field label { display: block; margin-bottom: var(--space-1); font-size: var(--text-sm); font-weight: 600; }
.field input, .field select { width: 100%; min-height: var(--control-h); padding: var(--space-1) var(--space-3); font: inherit; color: inherit; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); }
.field input[readonly] { background: var(--color-bg); color: var(--color-text-muted); }
.field--error input, .field--error select { border-color: var(--color-danger); }
.field__error { margin: var(--space-1) 0 0; color: var(--color-danger); font-size: var(--text-sm); }
.field__help { margin: var(--space-1) 0 0; color: var(--color-text-muted); font-size: var(--text-xs); }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-3); }
.toolbar input[type="search"], .inline-form input { flex: 1 1 12rem; min-height: var(--control-h); padding: var(--space-1) var(--space-3); font: inherit; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin: 0; }
.page-header__actions .inline-form input { flex: 0 0 auto; }
.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: var(--control-h); padding: var(--space-1) var(--space-4); font: inherit; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer; color: #fff; background: var(--color-primary); border: 1px solid var(--color-primary); border-radius: var(--radius-md); }
.button:hover { background: var(--color-primary-hover); }
.button:disabled { opacity: 0.5; cursor: not-allowed; }
.button--ghost { color: var(--color-text); background: var(--color-surface); border-color: var(--color-border-strong); }
.button--ghost:hover { background: var(--color-bg); }
.button--sm { min-height: 1.625rem; padding: 0 var(--space-3); font-size: var(--text-xs); }
@media (pointer: coarse) { .button--sm { min-height: 2.25rem; } }
.button--block { display: flex; width: 100%; }
.is-disabled { opacity: 0.4; pointer-events: none; }

.badge { display: inline-block; padding: 0 var(--space-2); font-size: var(--text-xs); font-weight: 600; border-radius: 999px; background: var(--color-border); color: var(--color-text); }
.badge--success { background: #d3f9d8; color: #1b5e20; }
.badge--warning { background: #fff3bf; color: var(--color-warning); }

/* --- Tables (cards on small screens, real tables from 48rem) ------------------------------- */
.table { width: 100%; border-collapse: collapse; }
.table thead { display: none; }
.table tr { display: block; padding: var(--space-2) var(--space-3); margin-bottom: var(--space-2); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.table td { display: flex; justify-content: space-between; gap: var(--space-3); padding: 0.125rem 0; }
.table td[data-label]::before { content: attr(data-label); font-weight: 600; color: var(--color-text-muted); }
.table__actions { padding-top: var(--space-2) !important; }
.table__actions .actions, .table__actions form { margin: 0; }
.table tfoot td { font-weight: 700; }
.is-voided td { color: var(--color-text-muted); text-decoration: line-through; }
.is-voided td.table__actions, .is-voided .badge { text-decoration: none; }
.is-empty td { color: var(--color-text-muted); }
@media (min-width: 48rem) {
  .table { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); overflow: hidden; }
  .table thead { display: table-header-group; }
  .table th { padding: var(--space-2) var(--space-3); font-size: var(--text-xs); font-weight: 600; text-align: left; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); background: var(--color-bg); border-bottom: 1px solid var(--color-border); }
  .table tr { display: table-row; padding: 0; margin: 0; border: 0; border-radius: 0; background: transparent; }
  .table tbody tr:hover { background: var(--color-primary-soft); }
  .table td { display: table-cell; padding: var(--space-2) var(--space-3); vertical-align: middle; border-bottom: 1px solid var(--color-border); }
  .table tbody tr:last-child td { border-bottom: 0; }
  .table td[data-label]::before { content: none; }
  .table th.num, .table td.num { text-align: right; }
  .table tfoot td { border-top: 2px solid var(--color-border-strong); background: var(--color-bg); }
  .table__actions .actions { justify-content: flex-end; flex-wrap: nowrap; }
}

/* --- Inventory ----------------------------------------------------------------------------- */
.category { margin-bottom: var(--space-4); }
.category__title { margin: 0 0 var(--space-2); padding: var(--space-1) var(--space-3); text-transform: uppercase; letter-spacing: 0.05em; font-size: var(--text-xs); font-weight: 700; color: var(--color-text-muted); background: var(--color-border); border-radius: var(--radius-sm); }
@media (min-width: 48rem) {
  /* Same column widths in every category so the sheet-like blocks line up. */
  .category .table { table-layout: fixed; }
  .category .table th.num, .category .table td.num { width: 6.75rem; }
  .category .table th.col-entry { width: 13.5rem; }
  .category .table th.col-actions { width: 10.5rem; }
}
.product-cell { display: flex; flex-direction: column; min-width: 0; }
.product-meta { display: block; font-size: var(--text-xs); }
.product-meta a { color: var(--color-text-muted); }
.product-meta a:hover { color: var(--color-primary); }
.stock-form { display: flex; gap: var(--space-1); align-items: center; margin: 0; }
.stock-form input[name="quantity"] { flex: 1 1 0; min-width: 0; width: 5.5rem; min-height: 1.75rem; padding: 0 var(--space-2); font: inherit; text-align: right; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); }
.stock-form.is-saving { opacity: 0.6; pointer-events: none; }
.arrival { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.arrival label { color: var(--color-text-muted); white-space: nowrap; }
.arrival input { min-height: var(--control-h); padding: 0 var(--space-2); font: inherit; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); }
.arrival__note { padding: 0 var(--space-2); font-size: var(--text-xs); font-weight: 600; color: var(--color-warning); background: #fff3bf; border-radius: 999px; }
.arrival.is-past input { border-color: var(--color-warning); background: #fffbe6; }
.inline-form--rename input { min-width: 0; }

/* --- Point of sale ------------------------------------------------------------------------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); margin-bottom: var(--space-6); align-items: start; }
.pos__catalog { display: grid; gap: var(--space-2); min-width: 0; }
.pos__filters { display: grid; gap: var(--space-2); }
.pos__filters .toolbar { margin: 0; }
.pos__filters input[type="search"] { font-size: var(--text-md); }

.chips { display: flex; gap: var(--space-1); overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; min-height: 1.75rem; padding: 0 var(--space-3); font: inherit; font-size: var(--text-sm); color: var(--color-text); cursor: pointer; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: 999px; }
.chip:hover { border-color: var(--color-primary); }
.chip[aria-pressed="true"] { color: #fff; background: var(--color-primary); border-color: var(--color-primary); }
.chip__count { margin-left: var(--space-1); opacity: 0.7; font-size: var(--text-xs); }
@media (pointer: coarse) { .chip { min-height: 2.25rem; } }

/* The catalog scrolls inside its own box, so the page height does not depend on how many products there are. */
/* On phones and tablets the products flow with the page: a scroll box of their own would trap the
   finger and the cart below could never be reached. The box exists only in the two-column layout. */
.pos__scroll:focus-visible { outline-offset: -2px; }
.tile-group__title { padding: var(--space-1) 0; background: var(--color-bg); display: flex; align-items: baseline; gap: var(--space-2); margin: 0; font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }
.tile-group__count { font-weight: 500; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.75rem, 1fr)); gap: var(--space-1) var(--space-2); padding-top: var(--space-1); }
.tile { position: relative; display: flex; flex-direction: column; gap: 0.125rem; min-height: 3rem; padding: 0.3125rem 0.4375rem; font: inherit; color: inherit; text-align: left; cursor: pointer; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); transition: transform 0.08s, border-color 0.08s, box-shadow 0.08s; }
.tile:hover:not(:disabled) { border-color: var(--color-primary); box-shadow: var(--shadow-sm); }
.tile:active:not(:disabled) { transform: scale(0.97); }
.tile:disabled { cursor: not-allowed; opacity: 0.5; }
.tile--pulse { animation: tile-pulse 0.35s ease-out; }
@keyframes tile-pulse { 40% { background: var(--color-primary-soft); border-color: var(--color-primary); } }
.tile__name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-size: var(--text-xs); font-weight: 600; line-height: 1.2; }
.tile__meta { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; column-gap: var(--space-1); margin-top: auto; }
.tile__price { white-space: nowrap; font-size: var(--text-sm); font-weight: 700; color: var(--color-primary); font-variant-numeric: tabular-nums; }
.tile__stock { font-size: 0.6875rem; color: var(--color-text-muted); white-space: nowrap; }
.tile__count { position: absolute; top: -0.4rem; right: -0.4rem; min-width: 1.35rem; padding: 0 var(--space-1); text-align: center; font-size: var(--text-xs); font-weight: 700; line-height: 1.35rem; color: #fff; background: var(--color-accent-strong); border-radius: 999px; }
@media (pointer: coarse) { .tile { min-height: 4.25rem; } }

/* Only the list of lines scrolls; the total and the Liquidar button are never pushed out of view. */
.pos__panel { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); }
.pos__panel > * { flex: none; }
.pos__panel > .cart-lines { flex: 0 1 auto; min-height: 0; max-height: 40vh; max-height: 40dvh; overflow-y: auto; overscroll-behavior: contain; margin-right: calc(var(--space-1) * -1); padding-right: var(--space-1); scrollbar-width: thin; }
.pos__panel h2 { margin: 0; }
.pos__empty { margin: 0; padding: var(--space-3); text-align: center; border: 1px dashed var(--color-border-strong); border-radius: var(--radius-md); }
.cart-lines { list-style: none; margin: 0; padding: 0; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 var(--space-2); padding: var(--space-2) 0; border-bottom: 1px solid var(--color-border); }
.cart-line form { margin: 0; }
.cart-line.is-updated { animation: line-flash 0.6s ease-out; }
@keyframes line-flash { 0% { background: var(--color-primary-soft); } }
.cart-line__row { display: grid; grid-template-columns: auto 1fr; grid-template-areas: "name name" "stepper subtotal"; align-items: center; gap: var(--space-1) var(--space-2); }
.cart-line__row .stepper { grid-area: stepper; }
.cart-line__name { grid-area: name; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; font-weight: 600; font-size: var(--text-sm); line-height: 1.25; }
.cart-line__subtotal { grid-area: subtotal; text-align: right; font-variant-numeric: tabular-nums; }
.cart-line__remove .button { min-width: 1.625rem; padding: 0; color: var(--color-text-muted); }
.cart-line__more { margin-top: var(--space-1); font-size: var(--text-xs); }
.cart-line__more summary { cursor: pointer; color: var(--color-text-muted); list-style-position: inside; }
.cart-line__more summary:hover { color: var(--color-primary); }
.cart-line__fields { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-top: var(--space-1); }
.cart-line__fields input, .cart-line__fields select { min-height: 1.75rem; padding: 0 var(--space-2); font: inherit; font-size: var(--text-sm); background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); }
.cart-line__fields input { width: 6.5rem; text-align: right; }
.stepper { display: inline-flex; align-items: stretch; }
.stepper__btn { width: 1.75rem; min-height: 1.75rem; font: inherit; font-size: var(--text-md); line-height: 1; color: var(--color-text); cursor: pointer; background: var(--color-bg); border: 1px solid var(--color-border-strong); }
.stepper__btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.stepper__btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.stepper__btn:hover { background: var(--color-border); }
.stepper input { width: 2.5rem; min-height: 1.75rem; padding: 0; font: inherit; text-align: center; border: 1px solid var(--color-border-strong); border-inline: 0; border-radius: 0; background: var(--color-surface); }
@media (pointer: coarse) {
  .stepper__btn, .stepper input { min-height: 2.5rem; }
  .stepper__btn { width: 2.5rem; }
  .cart-line__remove .button { min-width: 2.5rem; }
}

.pos__total { display: flex; flex-direction: column; gap: var(--space-1); margin-top: var(--space-1); padding-top: var(--space-2); border-top: 1px solid var(--color-border); }
.pos__total form { margin: 0; }
.pos__amount { font-size: var(--text-2xl); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; color: var(--color-primary); }
.pos__checkout { margin-top: var(--space-2); min-height: 2.75rem; font-size: var(--text-md); background: var(--color-accent-strong); border-color: var(--color-accent-strong); }
.pos__checkout:hover:not(:disabled) { background: var(--color-accent-strong-hover); }
.pos__bar { position: fixed; inset: auto var(--space-3) var(--space-3); z-index: 8; display: flex; justify-content: space-between; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); color: #fff; background: var(--color-primary); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.pos__bar[hidden] { display: none; }
.pos__bar form { margin: 0; }
.pos__bar-summary { display: flex; flex-direction: column; color: inherit; text-decoration: none; line-height: 1.2; }
.pos__bar-summary strong { font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.pos__bar-checkout { min-height: 2.5rem; padding-inline: var(--space-5); background: var(--color-accent-strong); border-color: #fff; }
@media (min-width: 64rem) {
  .pos__scroll { max-height: calc(100vh - var(--header-h) - 9.5rem); max-height: calc(100dvh - var(--header-h) - 9.5rem); min-height: 14rem; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--space-1) var(--space-2) 0; scrollbar-width: thin; }
  .pos { grid-template-columns: minmax(0, 1fr) 22rem; }
  .pos__cart { position: sticky; top: calc(var(--header-h) + var(--space-3)); }
  /* The panel starts below the header and the page title (~8.5rem down), so its height is the screen minus that:
     the total and Liquidar are on screen from the first paint, before any scrolling. */
  .pos__panel { max-height: calc(100vh - 8.5rem); max-height: calc(100dvh - 8.5rem); }
  .pos__panel > .cart-lines { max-height: none; flex: 1 1 auto; min-height: 5rem; }
  .pos__bar { display: none; }
}

/* --- Month navigation and sales calendar --------------------------------------------------- */
.month-nav { display: flex; align-items: center; gap: var(--space-1); }
.month-nav__label { min-width: 8.5rem; text-align: center; }
.level-0 { --heat: transparent; }
.level-1 { --heat: #e6fcf5; }
.level-2 { --heat: #c3fae8; }
.level-3 { --heat: #96f2d7; }
.level-4 { --heat: #63e6be; }
.calendar { display: none; }
.calendar-list { list-style: none; margin: 0 0 var(--space-3); padding: 0; display: grid; gap: var(--space-1); }
.calendar-list__item { display: grid; grid-template-columns: 1fr auto; gap: 0 var(--space-3); padding: var(--space-2) var(--space-3); color: inherit; text-decoration: none; background: var(--heat, transparent); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.calendar-list__date { font-weight: 700; }
.calendar-list__units { grid-column: 1; color: var(--color-text-muted); font-size: var(--text-xs); }
.calendar-list__amounts { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; align-items: flex-end; font-variant-numeric: tabular-nums; }
.calendar-legend { margin-top: var(--space-2); font-size: var(--text-xs); }
@media (min-width: 48rem) {
  .calendar-list { display: none; }
  .calendar { display: table; width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: var(--space-1); }
  .calendar th { padding: var(--space-1); font-size: var(--text-xs); color: var(--color-text-muted); text-align: center; }
  .calendar__day { height: 5.5rem; padding: 0; vertical-align: top; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
  .calendar__day[class*="level-"]:not(.level-0) { background: var(--heat); }
  .calendar__day.is-outside { background: transparent; border-style: dashed; opacity: 0.4; }
  .calendar__day.is-today { outline: 2px solid var(--color-primary); outline-offset: -2px; }
  .calendar__day > .calendar__number { display: block; padding: var(--space-1) var(--space-2); color: var(--color-text-muted); }
  .calendar__link { display: flex; flex-direction: column; height: 100%; padding: var(--space-1) var(--space-2); color: inherit; text-decoration: none; font-variant-numeric: tabular-nums; border-radius: var(--radius-md); }
  .calendar__link:hover { box-shadow: var(--shadow-md); }
  .calendar__number { font-weight: 700; }
  .calendar__units { font-size: var(--text-xs); color: var(--color-text-muted); }
  .calendar__revenue { font-size: var(--text-xs); }
  .calendar__profit { margin-top: auto; font-weight: 700; color: var(--color-success); }
  .calendar__profit.is-negative { color: var(--color-danger); }
}

/* Low-stock alerts */
.badge--low { background: #ffe8cc; color: #8f3b00; }
.nav-count { display: inline-block; min-width: 1.15rem; margin-left: var(--space-1); padding: 0 0.3rem; font-size: var(--text-xs); font-weight: 700; line-height: 1.15rem; text-align: center; color: #fff; background: #d9480f; border-radius: 999px; }
.nav-count[hidden] { display: none; }
.stats:has(.stat--link) { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 40rem) { .stats:has(.stat--link) { grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); } }
.stat--link { color: inherit; text-decoration: none; }
.stat--link:hover { border-color: var(--color-primary); }
.stat--warning { border-color: #d9480f; background: #fff4e6; }
.stat--warning .stat__value { color: #b13a09; }
.stat--warning.is-calm { border-color: var(--color-border); background: var(--color-surface); }
.stat--warning.is-calm .stat__value { color: var(--color-text); }
.button.is-active { color: #fff; background: var(--color-primary); border-color: var(--color-primary); }
.tile__stock.is-low { color: #b13a09; font-weight: 700; }

/* Activity trail (administrator) */
.audit-filters { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 var(--space-3); align-items: end; margin-bottom: var(--space-3); }
.audit-filters .field { margin-bottom: var(--space-2); }
.audit-filters .field select { width: 100%; min-height: var(--control-h); padding: 0 var(--space-2); font: inherit; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); }
.audit-filters__check { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); font-size: var(--text-sm); }
.audit-filters .actions { grid-column: 1 / -1; }
@media (min-width: 64rem) { .audit-filters { grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto; } .audit-filters .actions { grid-column: auto; margin-bottom: var(--space-2); } }
.badge--review { background: #ffe3e3; color: #a61e1e; }
.is-review > td:first-child { box-shadow: inset 3px 0 0 #d9480f; }
.audit-details { margin-top: var(--space-1); font-size: var(--text-xs); }
.audit-details summary { cursor: pointer; color: var(--color-text-muted); }
.audit-details ul { margin: var(--space-1) 0 0; padding-left: var(--space-4); }
.pager { display: flex; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-3); }
.audit-table td { vertical-align: top; }

/* Tabs (sales: "Vender" / "Ventas del día") */
.tabs { display: flex; gap: var(--space-1); margin-bottom: var(--space-3); border-bottom: 1px solid var(--color-border); }
.tabs__tab { flex: 1; margin-bottom: -1px; padding: var(--space-2) var(--space-3); font-weight: 600; text-align: center; text-decoration: none; color: var(--color-text-muted); border-bottom: 3px solid transparent; }
.tabs__tab:hover { color: var(--color-text); }
.tabs__tab[aria-current="page"] { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tabs__count { margin-left: var(--space-2); padding: 0 var(--space-2); font-size: var(--text-xs); font-weight: 700; color: var(--color-text); background: var(--color-border); border-radius: 999px; }
.tabs__tab[aria-current="page"] .tabs__count { color: #fff; background: var(--color-primary); }
@media (min-width: 48rem) { .tabs__tab { flex: 0 0 auto; min-width: 9rem; } }
.section-title--first { margin-top: 0; }
.sales-table td.sale-break { display: none; } /* only the phone layout uses it */

/* Phones: lists become two compact lines per row instead of one line per field. */
@media (max-width: 47.99rem) {
  .sales-table tr, .inventory-table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-3); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-1); }
  .sales-table td, .inventory-table td { display: block; padding: 0; }
  .sales-table td[data-label]::before { content: none; }
  .sales-table .sale-time { order: 1; min-width: 2.5rem; font-size: var(--text-xs); color: var(--color-text-muted); }
  .sales-table .sale-product { order: 2; flex: 1 1 0; min-width: 0; font-weight: 600; }
  .sales-table .sale-price { order: 3; font-weight: 700; }
  .sales-table td.sale-break { order: 4; display: block; flex-basis: 100%; height: 0; }
  .sales-table .sale-meta, .sales-table .sale-cost, .sales-table .sale-profit { order: 5; font-size: var(--text-xs); color: var(--color-text-muted); }
  .sales-table td.sale-cost[data-label]::before { content: "Costo "; }
  .sales-table td.sale-profit[data-label]::before { content: "Utilidad "; }
  .sales-table .table__actions { order: 6; margin-left: auto; padding: 0 !important; }
  .sales-table tfoot td[data-label]::before { content: attr(data-label) " "; font-weight: 400; color: var(--color-text-muted); font-size: var(--text-xs); }

  .inventory-table td[data-label]::before { content: attr(data-label) " "; font-weight: 400; color: var(--color-text-muted); font-size: var(--text-xs); }
  .inventory-table .p-name { flex: 1 1 100%; font-weight: 600; }
  .inventory-table td.p-name[data-label]::before, .inventory-table td.col-entry[data-label]::before { content: none; }
  .inventory-table .p-name .badge { font-weight: 600; }
  .inventory-table .col-entry, .inventory-table .table__actions { flex: 1 1 100%; margin-top: var(--space-1); }
  .inventory-table .stock-form { max-width: 16rem; }
  .inventory-table .table__actions { padding: 0 !important; }
  .inventory-table tfoot td:first-child { font-weight: 700; }

}

/* Touch screens: targets stay comfortable but not oversized. */
@media (pointer: coarse) {
  .button--sm { min-height: 2rem; }
  .chip { min-height: 2rem; }
  .tile { min-height: 3.75rem; }
  .stepper__btn, .stepper input { min-height: 2.25rem; }
  .stepper__btn { width: 2.25rem; }
  .cart-line__remove .button { min-width: 2.25rem; }
}

/* Payment method chooser (register) and breakdown (reports) */
.pay { margin: var(--space-1) 0 0; padding: 0; border: 0; }
.pay legend { padding: 0; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }
.pay__options { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }
.pay__option { position: relative; flex: 1 1 auto; }
.pay__option input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.pay__option span { display: block; padding: var(--space-1) var(--space-3); font-size: var(--text-sm); font-weight: 600; text-align: center; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); }
.pay__option input:checked + span { color: #fff; background: var(--color-primary); border-color: var(--color-primary); }
.pay__option input:focus-visible + span { outline: 2px solid var(--color-primary); outline-offset: 2px; }
@media (pointer: coarse) { .pay__option span { padding-block: var(--space-2); } }
.pos__bar-pay { font-size: var(--text-xs); opacity: 0.9; }
.pos__bar-summary { gap: 0; }

.payments { margin: 0 0 var(--space-4); }
.payments__title { margin: 0 0 var(--space-1); font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); }
.payments__list { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.payment { display: grid; gap: 0; padding: var(--space-2) var(--space-3); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.payment__name { font-size: var(--text-sm); font-weight: 600; }
.payment__amount { font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.payment__units { font-size: var(--text-xs); color: var(--color-text-muted); }

/* Sales of the day grouped by ticket */
.ticket { border-top: 2px solid var(--color-border-strong); }
.ticket:target .ticket__head th { box-shadow: inset 4px 0 0 var(--color-primary); background: #e1e1fb; }
.ticket.is-voided .ticket__title strong, .ticket.is-voided .ticket__total { text-decoration: line-through; color: var(--color-text-muted); }
.ticket__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1) var(--space-3); }
.ticket__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--space-2); }
.ticket__meta { font-size: var(--text-xs); font-weight: 400; color: var(--color-text-muted); }
.ticket__end { display: flex; align-items: center; gap: var(--space-2); }
.ticket__end form { margin: 0; }
.ticket-search input { width: 8rem; flex: 0 0 auto; }
@media (min-width: 48rem) {
  .sales-table .ticket__head th { font-size: var(--text-base); font-weight: 400; text-transform: none; letter-spacing: normal; color: var(--color-text); background: var(--color-primary-soft); border-bottom: 1px solid var(--color-border); }
  .sales-table .sale-row td { padding-block: var(--space-1); }
}
@media (max-width: 47.99rem) {
  .sales-table .ticket__head { margin-bottom: 0; padding: var(--space-2) var(--space-3); background: var(--color-primary-soft); border-radius: var(--radius-md) var(--radius-md) 0 0; }
  .sales-table .ticket__head th { display: block; width: 100%; padding: 0; font-weight: 400; text-align: left; text-transform: none; letter-spacing: normal; }
  .sales-table .sale-row { margin-bottom: 0; border-radius: 0; border-top: 0; }
  .sales-table tbody.ticket { display: block; margin-bottom: var(--space-2); }
  .sales-table tbody.ticket > tr:last-child { border-radius: 0 0 var(--radius-md) var(--radius-md); }
}

/* Collapsible sales: one line per sale, click to unfold (the script marks the title as a button) */
.ticket-controls { display: flex; gap: var(--space-2); justify-content: flex-end; margin-bottom: var(--space-2); }
.ticket-controls[hidden] { display: none; }
.ticket__title[aria-expanded] { cursor: pointer; user-select: none; }
.ticket__title[aria-expanded]::before { content: "▸"; display: inline-block; width: 1em; color: var(--color-text-muted); transition: transform 0.12s; }
.ticket__title[aria-expanded="true"]::before { transform: rotate(90deg); }
.ticket__title:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: var(--radius-sm); }
.ticket__preview { flex-basis: 100%; padding-left: 1em; font-size: var(--text-xs); color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket:has([data-ticket-toggle][aria-expanded="true"]) .ticket__preview { display: none; }
.ticket__bar { min-width: 0; }
.ticket__title { min-width: 0; flex: 1 1 14rem; }
@media (min-width: 48rem) { .ticket__title { max-width: 36rem; } }
/* Voiding a whole sale needs the detail on screen first: its button only shows when unfolded. */
.ticket:has([data-ticket-toggle][aria-expanded="false"]) .ticket__end form { display: none; }

/* Sales table: fixed columns and a neutral palette (no lilac) ---------------------------------- */
.sales-table {
  --sales-line: #e4e4e7;
  --sales-line-strong: #d4d4d8;
  --sales-head: #f4f4f5;
  --sales-hover: #fafafa;
  --sales-text-muted: #71717a;
}
@media (min-width: 48rem) {
  /* Columns have one width declared in <colgroup>, so unfolding a sale never moves them. */
  .sales-table { table-layout: fixed; border-color: var(--sales-line); }
  .sales-table col.c-money { width: 8.5rem; }
  .sales-table col.c-kind { width: 9rem; }
  .sales-table col.c-action { width: 6.5rem; }
  /* Employees: a labelled column on the right keeps the sale's total apart from Precio and Tipo. */
  .sales-table col.c-total { width: 14rem; }
  .sales-table td, .sales-table th { overflow-wrap: anywhere; }
  .sales-table thead th { background: #fff; border-bottom: 1px solid var(--sales-line-strong); color: var(--sales-text-muted); }
  .sales-table tbody tr:hover { background: transparent; }
  .sales-table .sale-row:hover { background: var(--sales-hover); }
  .sales-table td { border-bottom-color: var(--sales-line); }
  .sales-table tfoot td { background: var(--sales-head); border-top-color: var(--sales-line-strong); }
  .sales-table .ticket__head th { background: var(--sales-head); border-bottom: 1px solid var(--sales-line); }
}
.ticket { border-top-color: var(--sales-line-strong); }
.sales-table .ticket { border-top: 1px solid var(--sales-line-strong); }
.sales-table .ticket:target .ticket__head th { background: #e4e4e7; box-shadow: inset 4px 0 0 #52525b; }
.sales-table .ticket__meta, .sales-table .ticket__preview { color: var(--sales-text-muted); }
.sales-table .ticket__title[aria-expanded]::before { color: var(--sales-text-muted); }
.sales-table .badge { background: #e4e4e7; color: #52525b; }
.sales-table .button--ghost { border-color: var(--sales-line-strong); }
@media (max-width: 47.99rem) {
  .sales-table .ticket__head { background: var(--sales-head); }
  .sales-table tr { border-color: var(--sales-line); }
}


@media (min-width: 64rem) {
  .tile-group__title { position: sticky; top: 0; z-index: 1; }
}
/* Products indented under their sale (the sale's name stays flush left) */
@media (min-width: 48rem) {
  .sales-table .sale-row .sale-product { padding-left: 3.25rem; }
}
@media (max-width: 47.99rem) {
  .sales-table .sale-row { padding-left: calc(var(--space-3) + 1.75rem); }
}

/* Phones and tablets: the sale in progress is a sheet over the page (opened from the bottom bar) -- */
.pos__panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.pos__close { display: none; }
@media (max-width: 63.99rem) {
  /* No inner scroll on the list of lines: the sheet scrolls as a whole (nested scrolls trap the finger). */
  .pos__panel > .cart-lines { max-height: none; overflow: visible; }
  html.js .pos__cart { display: none; }
  /* The sheet: title on top, the lines in the middle (the only part that scrolls) and the total,
     payment method and Liquidar pinned at the bottom, so they are never hidden. */
  html.js .pos__cart.is-open { display: flex; flex-direction: column; position: fixed; inset: 0; z-index: 16; overflow: hidden; padding: 0; background: var(--color-bg); }
  html.js .pos__cart.is-open .pos__close { display: inline-flex; }
  html.js .pos__cart.is-open .pos__panel { flex: 1 1 auto; min-height: 0; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
  html.js .pos__cart.is-open .pos__panel > .cart-lines { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  body.sheet-open { overflow: hidden; }
  /* The floating bar is only for the product list; the open sheet has its own Liquidar. */
  body.sheet-open .pos__bar { display: none; }
  .pos__bar-open { text-decoration: underline; }
  /* Search and categories stay in reach while going down a long list. */
  .pos__filters { position: sticky; top: var(--header-offset, var(--header-h)); z-index: 6; padding: var(--space-2) 0; background: var(--color-bg); }
}
@media (max-width: 47.99rem) {
  .sales-table td.sale-spacer { display: none; }
}

/* Administrator dashboard ------------------------------------------------------------------- */
.dash-section { margin-bottom: var(--space-4); }
.dash-title { margin: 0 0 var(--space-2); font-size: var(--text-md); }
.dash-title span, .panel__title span { font-size: var(--text-xs); font-weight: 500; color: var(--color-text-muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: var(--space-2); }
.kpi { display: flex; flex-direction: column; gap: 0.125rem; padding: var(--space-3); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.kpi--accent { border-color: #b8b8d8; }
.kpi__label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }
.kpi__value { font-size: var(--text-xl); font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi__note { font-size: var(--text-xs); color: var(--color-text-muted); }
.delta { font-size: var(--text-xs); font-weight: 700; white-space: nowrap; }
.delta--up { color: var(--color-success); }
.delta--down { color: var(--color-danger); }
.delta--flat, .delta--none { color: var(--color-text-muted); }
.delta__versus { font-weight: 400; color: var(--color-text-muted); }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
@media (min-width: 48rem) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .panel--wide { grid-column: 1 / -1; } }
@media (min-width: 80rem) { .dash-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } .panel--wide { grid-column: span 2; } }
.panel { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); min-width: 0; }
.panel__title { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-2); margin: 0; font-size: var(--text-base); }
.panel__link { margin-left: auto; font-size: var(--text-xs); font-weight: 600; }
.panel__foot { margin: 0; font-size: var(--text-xs); color: var(--color-text-muted); }
.panel__empty { margin: 0; padding: var(--space-3) 0; text-align: center; }

.chart { display: flex; flex: 1 1 auto; flex-direction: column; }
.chart__svg { display: block; flex: 1 1 auto; width: 100%; min-height: 8rem; }
.chart__bar { fill: #a8a8dc; }
.chart__bar:hover { fill: var(--color-primary); }
.chart__bar.is-today { fill: var(--color-primary); }
.chart__grid { stroke: var(--color-border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart__labels { display: grid; grid-template-columns: repeat(14, 1fr); margin-top: var(--space-1); font-size: 0.6875rem; text-align: center; color: var(--color-text-muted); }
.chart__labels .is-today { font-weight: 700; color: var(--color-primary); }

.shares { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.shares__row { display: flex; justify-content: space-between; gap: var(--space-2); font-size: var(--text-sm); }
.shares__row strong { font-variant-numeric: tabular-nums; }
.shares__bar { width: 100%; height: 0.5rem; appearance: none; border: 0; border-radius: 999px; background: var(--color-border); overflow: hidden; }
.shares__bar::-webkit-progress-bar { background: var(--color-border); }
.shares__bar::-webkit-progress-value { background: var(--color-primary); border-radius: 999px; }
.shares__bar::-moz-progress-bar { background: var(--color-primary); }
.shares__note { font-size: var(--text-xs); color: var(--color-text-muted); }

.alerts { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.alerts__item { padding: var(--space-2) var(--space-3); border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.alerts__item.is-warn { background: #fff4e6; border-color: #f0b27a; }
.alerts__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); font-size: var(--text-sm); }
.alerts__head strong { font-size: var(--text-lg); font-variant-numeric: tabular-nums; }
.alerts__head a { color: inherit; text-decoration: none; }
.alerts__sub { font-size: var(--text-xs); color: var(--color-text-muted); }
.alerts__list { margin: var(--space-1) 0 0; padding: 0; list-style: none; font-size: var(--text-xs); }
.alerts__list li { display: flex; justify-content: space-between; gap: var(--space-2); padding: 0.125rem 0; }
.alerts__stock { color: #b13a09; font-weight: 600; white-space: nowrap; }

.mini { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.mini th { padding: 0 var(--space-1) var(--space-1); font-size: var(--text-xs); font-weight: 600; text-align: left; text-transform: uppercase; letter-spacing: 0.03em; color: var(--color-text-muted); }
.mini td { padding: var(--space-1); border-top: 1px solid var(--color-border); }
.mini th.num, .mini td.num { text-align: right; white-space: nowrap; }
.is-alert { color: var(--color-danger); font-weight: 700; }
.is-good { color: var(--color-success); }

.facts { display: grid; gap: 0; margin: 0; }
.facts > div { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-1) 0; border-top: 1px solid var(--color-border); font-size: var(--text-sm); }
.facts > div:first-child { border-top: 0; }
.facts dt { color: var(--color-text-muted); }
.facts dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.feed { display: grid; margin: 0; padding: 0; list-style: none; }
.feed__item { display: grid; grid-template-columns: 5.5rem 11rem minmax(0, 1fr); gap: var(--space-2); padding: var(--space-1) 0; border-top: 1px solid var(--color-border); font-size: var(--text-sm); }
.feed__item:first-child { border-top: 0; }
.feed__time { color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.feed__who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed__item.is-review { box-shadow: inset 3px 0 0 #d9480f; padding-left: var(--space-2); }
@media (max-width: 47.99rem) {
  .feed__item { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .feed__time { font-size: var(--text-xs); }
}

.badge--web { background: #dbe4ff; color: #2b3a8c; }
