.sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 30; display: flex; flex-direction: column; background: var(--nav); color: var(--nav-ink); padding: 22px 14px 16px; border-right: 1px solid var(--nav-border); box-shadow: var(--nav-shadow); }
.sidebar__brand { display: flex; align-items: center; gap: 11px; margin: 0 7px 18px; padding: 9px 5px 18px; border-bottom: 1px solid rgba(255,255,255,.12); color: var(--nav-ink); text-decoration: none; }
.sidebar__brand-mark, .login-brand__mark { display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 0; background: none; color: var(--accent); }
.sidebar .sidebar__brand-mark { background: none; color: var(--nav-ink); }
.sidebar__brand-copy, .login-brand div { display: flex; flex-direction: column; }
.sidebar__brand-copy strong { font-size: 18px; letter-spacing: 0; }
.sidebar__brand-copy small { margin-top: 1px; color: var(--nav-muted); font-size: 10px; }
.sidebar__brand-copy .sidebar__brand-store { overflow: hidden; max-width: 170px; color: var(--nav-ink); font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.sidebar__nav { flex: 1; overflow-y: auto; }
.sidebar__section { margin-top: 18px; }
.sidebar__section--support { margin-top: 18px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.12);}
.sidebar__section-title { display: block; padding: 0 11px 8px; color: var(--nav-muted); font-size: 10px; font-weight: 850; letter-spacing: 1px; }
.sidebar__list { list-style: none; margin: 0; padding: 0; }
.sidebar__link { display: flex; align-items: center; gap: 11px; min-height: 42px; margin-bottom: 3px; padding: 0 11px; border-radius: 4px; color: var(--nav-muted); text-decoration: none; font-size: 13px; font-weight: 600; transition: background .15s, color .15s, box-shadow .15s; }
.sidebar__link:hover { background: var(--nav-hover); color: var(--nav-ink); }
.sidebar__link.is-active { background: var(--nav-active); color: var(--ink); box-shadow: inset 3px 0 0 var(--accent); }
.sidebar__footer { display: flex; align-items: center; gap: 8px; padding: 14px 5px 0; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar__profile { min-width: 0; flex: 1; display: flex; align-items: center; gap: 9px; color: inherit; text-decoration: none; }
.sidebar__avatar { display: block; width: auto; height: auto; padding: 0; border: 0; border-radius: 0; background: none; color: var(--nav-ink); font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.sidebar__user-info { min-width: 0; display: flex; flex-direction: column; }
.sidebar__user-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.sidebar__user-info small { color: var(--nav-muted); font-size: 10px; }
.sidebar__logout { color: var(--nav-muted); }
.sidebar__footer form { margin: 0; }
.mobile-nav { display: none; }

.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--primary-soft); color: var(--primary); }
.btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 4px; background: var(--surface); color: var(--ink); text-decoration: none; font-weight: 700; cursor: pointer; transition: background .15s, border-color .15s, transform .15s; }
.btn:hover { background: var(--surface-soft); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--gold { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--gold:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--secondary { border-color: var(--line-strong); background: var(--surface-soft); color: var(--ink); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--ghost { background: transparent; }
.btn--block { width: 100%; }

.page-header { max-width: 1480px; margin: 0 auto 26px; display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-header__left { min-width: 0; }
.eyebrow, .page-header__eyebrow { display: block; margin-bottom: 7px; color: var(--accent); font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; }
.page-header__title { margin-bottom: 6px; font-size: clamp(25px, 3vw, 36px); font-weight: 850; }
.page-header__subtitle { margin: 0; max-width: 690px; color: var(--muted); font-size: 14px; }

.surface-card, .dashboard-card, .panel { min-width: 0; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-soft); }
.card-header, .panel__header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.card-header__title, .panel__header h2 { margin: 0 0 4px; font-size: 17px; font-weight: 800; }
.card-header__subtitle, .panel__header p { margin: 0; color: var(--muted); font-size: 12px; }
.card-header__actions { display: flex; gap: 8px; }
.card-header__link, .text-link { display: inline-flex; align-items: center; gap: 5px; color: var(--info); text-decoration: none; font-size: 12px; font-weight: 800; white-space: nowrap; }

.ranked-list, .alert-list { display: grid; min-width: 0; }
.ranked-list__row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; min-width: 0; padding: 11px 0; border-bottom: 1px solid var(--line); }
.ranked-list__row:last-child, .alert-list__row:last-child { border-bottom: 0; }
.ranked-list__index { display: grid; place-items: center; width: 22px; height: auto; border-radius: 0; background: none; color: var(--muted); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.ranked-list__name, .ranked-list__amount { min-width: 0; display: flex; flex-direction: column; }
.ranked-list__name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.ranked-list__name small, .ranked-list__amount small { overflow: hidden; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.ranked-list__amount { align-items: flex-end; text-align: right; font-size: 12px; }
.alert-list__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; padding: 12px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.alert-list__row > div { min-width: 0; display: flex; flex-direction: column; }
.alert-list__row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.alert-list__row small { color: var(--muted); font-size: 10px; }
.alert-list__row > .status { flex: 0 0 auto; max-width: 42%; overflow: hidden; text-overflow: ellipsis; }

.metric-strip, .dashboard__metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: 1480px; margin: 0 auto 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-soft); overflow: hidden; }
.metric, .metric-card { min-width: 0; padding: 19px; border-right: 1px solid var(--line); background: var(--surface); }
.metric:last-child, .metric-card:last-child { border-right: 0; }
.metric__label, .metric-card__label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .7px; text-transform: uppercase; }
.metric__value, .metric-card__value { display: block; margin: 0 0 3px; color: var(--ink); font-size: 25px; font-weight: 850; line-height: 1.1; }
.metric__meta, .metric-card__meta { color: var(--muted); font-size: 11px; }
.metric--warning { box-shadow: inset 0 4px 0 var(--warning); }
.metric--link { color: inherit; text-decoration: none; cursor: pointer; transition: background-color .16s ease, box-shadow .16s ease; }
.metric--link:hover, .metric--link:focus-visible { background: var(--primary-soft); box-shadow: inset 0 3px 0 var(--primary); outline: none; }
.metric--link.metric--warning:hover, .metric--link.metric--warning:focus-visible { box-shadow: inset 0 3px 0 var(--warning); }
.metric-card__header { display: contents; }
.metric-card__icon, .metric-card__body { display: contents; }

.table-wrapper { width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; scrollbar-gutter: stable; -webkit-overflow-scrolling: touch; }
.dashboard-table { width: 100%; min-width: 680px; border-collapse: collapse; }
.dashboard-table th { padding: 10px 12px; border-bottom: 1px solid var(--line-strong); color: var(--muted); font-size: 10px; font-weight: 850; letter-spacing: .65px; text-align: left; text-transform: uppercase; white-space: nowrap; }
.dashboard-table td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 13px; }
.dashboard-table tbody tr:last-child td { border-bottom: 0; }
.dashboard-table tbody tr:hover { background: var(--primary-soft); }
.dashboard-table__total, .dashboard-table__action { text-align: right !important; white-space: nowrap; }
.product-info { display: flex; flex-direction: column; gap: 2px; }
.product-info__name { font-weight: 750; }
.product-info__meta { color: var(--muted); font-size: 11px; }
.sale-link { color: var(--primary); font-weight: 850; text-decoration: none; }
.sale-total { font-weight: 850; }

.status, .badge, .stock-pill { display: inline-flex; align-items: center; width: fit-content; min-height: 23px; padding: 0 8px; border-radius: 5px; background: var(--neutral-soft); color: var(--neutral-ink); font-size: 10px; font-weight: 850; text-transform: capitalize; white-space: nowrap; }
.status--success, .badge--success { background: var(--success-soft); color: var(--success); }
.status--danger, .badge--danger, .stock-pill--critical, .stock-pill--low { background: var(--danger-soft); color: var(--danger); }
.badge--info { background: var(--info-soft); color: var(--info); }
.badge--admin { background: var(--accent-soft); color: var(--accent-strong); }
.badge--cajero, .badge--muted, .stock-pill--ok { background: var(--neutral-soft); color: var(--neutral-ink); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-row { min-width: 0; margin-bottom: 15px; }
.form-row label, .form-row > span:first-child { display: block; margin-bottom: 6px; color: var(--field-label); font-size: 12px; font-weight: 800; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus); }
input::placeholder { color: var(--placeholder); }
.form-help { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.input-with-icon { position: relative; }
.input-with-icon svg { position: absolute; top: 50%; left: 12px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-with-icon input { padding-left: 40px; }
.search-bar { display: flex; align-items: center; gap: 8px; min-width: min(100%, 360px); }
.status-filter, .inventory-filter {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: stretch;
  gap: 3px;
  min-height: 42px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  white-space: nowrap;
}
.status-filter label, .inventory-filter label { display: flex; margin: 0; }
.status-filter input, .inventory-filter input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
.status-filter span, .inventory-filter span {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-radius: 4px;
  color: var(--muted);
  font-size: .7rem;
  font-weight: 800;
  cursor: pointer;
}
.status-filter input:checked + span, .inventory-filter input:checked + span {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(23,32,25,.1);
}
.status-filter input:focus-visible + span, .inventory-filter input:focus-visible + span {
  outline: 3px solid var(--focus);
  outline-offset: 1px;
}

.module-tabs { display: flex; gap: 4px; width: fit-content; margin: -10px 0 20px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); }
.module-tabs a { min-height: 36px; display: inline-flex; align-items: center; padding: 0 13px; border-radius: 5px; color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 800; }
.module-tabs a:hover { background: var(--surface-soft); color: var(--ink); }
.module-tabs a.is-active { background: var(--primary); color: #fff; box-shadow: none; }
.is-lowstock { background: var(--danger-soft); }

.empty-state { min-height: 170px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; color: var(--muted); text-align: center; }
.empty-state strong, .empty-state__title { margin: 0; color: var(--ink); font-weight: 800; }
.empty-state p, .empty-state__text { margin: 0; font-size: 12px; }
.empty-state--compact { min-height: 100px; flex-direction: row; justify-content: flex-start; text-align: left; }

.page-size, .filter-select {
  display: flex;
  align-items: stretch;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.page-size { flex: 0 0 auto; }
.filter-select { flex: 1 1 168px; max-width: 240px; }
.page-size span, .filter-select span {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  padding: 0 10px;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
}
.page-size select, .filter-select select {
  width: 100%;
  min-width: 72px;
  max-width: none;
  min-height: 40px;
  padding: 0 28px 0 10px;
  border: 0;
  border-radius: 0;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%2364736b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
  color: var(--ink);
  font-weight: 700;
  appearance: none;
  -webkit-appearance: none;
}
.page-size select { width: auto; min-width: 74px; }
.page-size:focus-within, .filter-select:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--focus);
}
.page-size select:focus, .filter-select select:focus {
  box-shadow: none;
  outline: none;
}
.page-size select::-ms-expand, .filter-select select::-ms-expand { display: none; }
.pager-shell { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border-top: 1px solid var(--line); }
.pager-summary { margin: 0; color: var(--muted); font-size: 11px; white-space: nowrap; }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px; margin: 0; }
.pagination a, .pagination span { min-width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--ink); text-decoration: none; font-size: 11px; }
.pagination .is-current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination .is-disabled { opacity: .4; pointer-events: none; }
.pagination__ellipsis { border-color: transparent !important; background: transparent !important; }

:where(a, button, input, select, textarea, summary):focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.flash-list { position: fixed; top: 18px; right: 18px; z-index: 100; display: grid; gap: 8px; width: min(380px, calc(100vw - 36px)); }
.flash { padding: 12px 14px; border: 1px solid var(--line); border-left-width: 4px; border-radius: 6px; background: var(--surface); box-shadow: var(--shadow); font-size: 13px; }
.flash--success { border-left-color: var(--success); }.flash--danger { border-left-color: var(--danger); }.flash--info { border-left-color: var(--info); }

.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal__backdrop { position: absolute; inset: 0; background: var(--overlay); }
.modal__panel { position: relative; width: min(560px, 100%); max-height: calc(100vh - 36px); overflow-y: auto; background: var(--surface); border-radius: var(--radius); box-shadow: 0 24px 70px rgba(0,0,0,.24); }
.modal__header, .modal__footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal__footer { justify-content: flex-end; border-top: 1px solid var(--line); border-bottom: 0; }
.modal__body { padding: 18px; }
.modal__title { margin: 0; font-size: 18px; }
.modal__close { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 5px; background: transparent; cursor: pointer; }
.modal__close:hover { background: var(--surface-soft); }

@media (max-width: 1040px) {
  .metric-strip, .dashboard__metrics { grid-template-columns: repeat(2, 1fr); }
  .metric:nth-child(2), .metric-card:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2), .metric-card:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 840px) {
  input, select, textarea { font-size: 16px; }
  .icon-button, .icon-btn, .row-actions .icon-button { width: 40px; height: 40px; }
  .sidebar { inset: auto 0 0 0; width: 100%; height: calc(72px + env(safe-area-inset-bottom)); padding: 7px 10px max(7px, env(safe-area-inset-bottom)); flex-direction: row; align-items: center; border-top: 1px solid var(--line-strong); box-shadow: 0 -5px 18px rgba(23,61,51,.08); }
  .sidebar__brand, .sidebar__section-title, .sidebar__profile { display: none; }
  .sidebar__nav, .sidebar__footer { display: none; }
  .mobile-nav { position: relative; display: block; width: 100%; min-width: 0; }
  .mobile-nav__items { display: grid; gap: 3px; width: 100%; }
  .mobile-nav__items--admin { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .mobile-nav__items--staff { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mobile-nav__link, .mobile-nav__more { min-width: 0; min-height: 56px; display: flex; align-items: center; justify-content: center; gap: 3px; padding: 4px 2px; border: 0; border-radius: 6px; background: transparent; color: var(--nav-muted); text-decoration: none; cursor: pointer; flex-direction: column; }
  .mobile-nav__link span, .mobile-nav__more span { display: block; overflow: hidden; max-width: 100%; font-size: 9px; font-weight: 800; line-height: 1.1; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-nav__link.is-active, .mobile-nav__more.is-active { background: var(--nav-active); color: var(--ink); box-shadow: inset 0 -3px 0 var(--accent); }
  .mobile-nav__more[aria-expanded="true"] { background: var(--nav-hover); color: var(--nav-ink); }
  .mobile-nav__sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .mobile-nav__backdrop { position: absolute; inset: 0; background: var(--overlay); }
  .mobile-nav__panel { position: relative; width: 100%; padding: 16px 16px 14px; border: 1px solid var(--line); border-bottom: 0; border-radius: 12px 12px 0 0; background: var(--surface); color: var(--ink); box-shadow: 0 -12px 34px rgba(16,31,25,.2); }
  .mobile-nav__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .mobile-nav__header h2 { margin: 0; font-size: 18px; }
  .mobile-nav__header .page-header__eyebrow { margin-bottom: 3px; }
  .mobile-nav__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding-top: 12px; }
  .mobile-nav__option { min-width: 0; min-height: 48px; display: flex; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); color: var(--ink); text-decoration: none; font-size: 12px; font-weight: 800; }
  .mobile-nav__option:hover, .mobile-nav__option:focus-visible { border-color: var(--primary-border); background: var(--primary-soft); color: var(--primary-hover); }
  body.mobile-nav-open { overflow: hidden; }
  .page-header { align-items: flex-start; }
  .flash-list { position: static; width: 100%; margin: -4px 0 14px; }
}
@media (max-width: 640px) {
  .page-header { flex-direction: column; margin-bottom: 18px; }
  .page-header .btn, .page-header [class*="header-actions"] { width: 100%; }
  .page-header [class*="header-actions"] { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
  .metric-strip, .dashboard__metrics { grid-template-columns: 1fr 1fr; }
  .metric, .metric-card { padding: 14px; }
  .metric__value, .metric-card__value { font-size: 21px; overflow-wrap: anywhere; }
  .surface-card, .dashboard-card, .panel { padding: 16px; }
  .panel__header { flex-direction: column; }
  .module-tabs { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); overflow: visible; }
  .module-tabs a { min-width: 0; justify-content: center; padding: 0 6px; text-align: center; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
  .dashboard-table th, .dashboard-table td { padding-left: 9px; padding-right: 9px; }
  .pager-shell { align-items: stretch; flex-direction: column; padding: 14px 16px; }
  .pager-summary { text-align: center; white-space: normal; }
  .pagination { justify-content: center; }
  .pagination a, .pagination span { min-width: 42px; height: 42px; }
  .status-filter, .inventory-filter { display: grid; width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-select, .page-size { max-width: none; flex: 1 1 100%; }
  .modal { padding: 10px; }
  .modal__header, .modal__footer { flex-wrap: wrap; }
  .modal__title { font-size: 16px; }
}
