:root {
  color-scheme: light;
  --h-paper: 200 43% 98%;
  --h-surface: 0 0% 100%;
  --h-surface-2: 150 45% 95%;
  --h-ink: 221 38% 15%;
  --h-muted: 220 13% 46%;
  --h-soft: 217 24% 27%;
  --h-line: 221 38% 15%;
  --h-field: 210 40% 99%;
  --h-blue: 216 74% 47%;
  --h-blue-2: 215 100% 59%;
  --h-green: 158 71% 30%;
  --h-red: 3 61% 48%;
  --h-gold: 39 72% 49%;
  --paper: hsl(var(--h-paper));
  --surface: hsl(var(--h-surface));
  --surface-2: hsl(var(--h-surface-2));
  --ink: hsl(var(--h-ink));
  --muted: hsl(var(--h-muted));
  --soft: hsl(var(--h-soft));
  --line: hsl(var(--h-line) / 0.14);
  --blue: hsl(var(--h-blue));
  --blue-2: hsl(var(--h-blue-2));
  --red: hsl(var(--h-red));
  --green: hsl(var(--h-green));
  --gold: hsl(var(--h-gold));
  --field: hsl(var(--h-field));
  --primary-gradient: linear-gradient(135deg, hsl(var(--h-blue)), hsl(219 82% 38%));
  --success-gradient: linear-gradient(135deg, hsl(151 73% 46%), hsl(var(--h-green)));
  --warning-gradient: linear-gradient(135deg, hsl(28 88% 62%), hsl(43 88% 62%));
  --shadow: 0 20px 46px hsl(221 38% 15% / 0.10);
  --shadow-elevated: 0 26px 72px hsl(221 38% 15% / 0.18);
  --radius: 8px;
  --motion-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --motion-fast: 170ms;
  --motion-mid: 360ms;
  --motion-slow: 640ms;
}

/* Ajuste administrativo de ventas: todo queda contenido en su modal. */
.sale-adjust-button {
  border-color: rgba(31, 102, 209, 0.34) !important;
  color: #174ea6 !important;
  background: #f5f9ff !important;
}

.sale-correction-overlay {
  z-index: 1080;
  padding: 12px;
}

.sale-correction-modal {
  width: min(1180px, 100%);
  max-height: calc(100dvh - 24px);
  border-radius: 8px;
}

.sale-correction-header {
  align-items: flex-start;
  padding: 15px 20px;
}

.sale-correction-header > div {
  display: grid;
  gap: 3px;
}

.sale-correction-header small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sale-correction-stepbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.sale-correction-stepbar span {
  padding: 10px 16px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 900;
}

.sale-correction-stepbar span.active {
  border-bottom-color: var(--green);
  color: var(--green);
  background: rgba(22, 131, 90, 0.06);
}

.sale-correction-stepbar span.complete {
  color: #174ea6;
}

.sale-correction-body {
  gap: 14px;
  padding: 16px 20px;
}

.sale-correction-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.sale-correction-section {
  display: grid;
  align-content: start;
  gap: 11px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.sale-correction-section:nth-child(2),
.sale-correction-reason-section {
  grid-column: 1 / -1;
}

.sale-correction-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.sale-correction-section-title span {
  display: inline-grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.sale-correction-section label,
.sale-correction-payment-shortcuts label,
.sale-correction-payment-grid label {
  min-width: 0;
  margin: 0;
}

.sale-correction-section input,
.sale-correction-section select,
.sale-correction-section textarea {
  width: 100%;
}

.sale-correction-search-results {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.sale-correction-items-wrap {
  max-height: 330px;
}

.sale-correction-items-table {
  min-width: 760px;
}

.sale-correction-items-table td {
  vertical-align: middle;
}

.sale-correction-items-table td:first-child {
  min-width: 260px;
}

.sale-correction-items-table input {
  min-width: 100px;
}

.sale-correction-totals,
.sale-correction-payment-balance {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.sale-correction-totals span,
.sale-correction-payment-balance span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.sale-correction-totals span:last-child {
  border-color: rgba(22, 131, 90, 0.32);
  color: var(--green);
}

.sale-correction-payment-shortcuts {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) repeat(3, auto);
  gap: 8px;
  align-items: end;
}

.sale-correction-payment-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.sale-correction-payment-balance.warning span:last-child {
  border-color: rgba(245, 158, 11, 0.36);
  background: #fffbeb;
  color: #92400e;
}

.sale-correction-payment-balance.ok span:last-child {
  border-color: rgba(22, 131, 90, 0.3);
  background: #f0fdf7;
  color: #0f5132;
}

.sale-correction-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
}

.sale-correction-checks .check-row,
.sale-correction-reason-section label {
  flex: 1 1 240px;
}

.sale-correction-error {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid rgba(199, 51, 47, 0.36);
  border-radius: 6px;
  background: #fff5f5;
  color: #8f1f1b;
}

.sale-correction-error span,
.sale-correction-error small {
  overflow-wrap: anywhere;
}

.sale-correction-history {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.sale-correction-history summary {
  padding: 11px 13px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.sale-correction-history-list {
  display: grid;
  gap: 8px;
  max-height: 230px;
  margin: 0;
  padding: 0 13px 13px 42px;
  overflow-y: auto;
}

.sale-correction-history-list li {
  padding: 9px 11px;
  border-left: 3px solid rgba(31, 102, 209, 0.44);
  background: var(--surface-2);
}

.sale-correction-history-list span,
.sale-correction-history-list small {
  display: block;
  margin-top: 3px;
}

.sale-correction-history-list small,
.sale-correction-history-empty {
  color: var(--muted);
  font-size: 12px;
}

.sale-correction-history-empty {
  padding: 0 13px 13px;
}

.sale-correction-impact-warning {
  display: grid;
  gap: 4px;
  padding: 13px 15px;
  border: 1px solid rgba(245, 158, 11, 0.38);
  border-radius: 6px;
  background: #fffbeb;
  color: #784300;
}

.sale-correction-before-after {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.sale-correction-before-after section {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.sale-correction-before-after section:last-child {
  border-color: rgba(22, 131, 90, 0.34);
  background: rgba(22, 131, 90, 0.07);
}

.sale-correction-before-after small {
  color: var(--muted);
  font-weight: 900;
}

.sale-correction-before-after strong {
  color: var(--ink);
  font-size: 24px;
}

.sale-correction-before-after section:last-child strong {
  color: var(--green);
}

.sale-correction-change-list {
  display: grid;
  gap: 7px;
}

.sale-correction-change-list h4 {
  margin: 2px 0 4px;
}

.sale-correction-change-list > div {
  display: grid;
  grid-template-columns: minmax(120px, 0.6fr) minmax(0, 1fr) 22px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
}

.sale-correction-change-list span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--soft);
}

.sale-correction-change-list b {
  color: var(--green);
  text-align: center;
}

.sale-correction-final-reason {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-left: 4px solid var(--green);
  background: var(--surface-2);
}

.sale-correction-final-reason small {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.sale-correction-final-check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 12px 14px;
  border: 1px solid rgba(22, 131, 90, 0.3);
  border-radius: 6px;
  background: #f0fdf7;
  font-weight: 800;
}

.sale-correction-final-check input {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

@media (max-width: 900px) {
  .sale-correction-grid,
  .sale-correction-before-after {
    grid-template-columns: minmax(0, 1fr);
  }

  .sale-correction-section:nth-child(2),
  .sale-correction-reason-section {
    grid-column: auto;
  }

  .sale-correction-payment-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sale-correction-payment-shortcuts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sale-correction-payment-shortcuts label {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .sale-correction-overlay {
    place-items: stretch;
    padding: 0;
  }

  .sale-correction-modal {
    width: 100%;
    max-height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .sale-correction-header,
  .sale-correction-body,
  .sale-correction-footer {
    padding-left: 12px;
    padding-right: 12px;
  }

  .sale-correction-section {
    padding: 11px;
  }

  .sale-correction-payment-grid,
  .sale-correction-payment-shortcuts {
    grid-template-columns: minmax(0, 1fr);
  }

  .sale-correction-payment-shortcuts label {
    grid-column: auto;
  }

  .sale-correction-payment-shortcuts .btn,
  .sale-correction-footer .btn {
    width: 100%;
  }

  .sale-correction-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .sale-correction-change-list > div {
    grid-template-columns: minmax(0, 1fr);
  }

  .sale-correction-change-list b {
    text-align: left;
    transform: rotate(90deg);
    transform-origin: left center;
  }
}

/* Diligencias independientes de una venta: no alteran caja ni inventario. */
.quick-delivery-panel {
  margin-bottom: 16px;
  overflow: clip;
  border-color: hsl(var(--h-blue) / 0.24);
  box-shadow: 0 14px 38px hsl(var(--h-blue) / 0.09);
}

.quick-delivery-panel > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.quick-delivery-panel > summary::-webkit-details-marker {
  display: none;
}

.quick-delivery-panel > summary > span:first-child {
  display: grid;
  gap: 3px;
}

.quick-delivery-panel > summary strong {
  color: var(--ink);
  font-family: "Outfit", system-ui, sans-serif;
  font-size: 18px;
}

.quick-delivery-panel > summary small,
.quick-delivery-actions > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.quick-delivery-badge {
  flex: none;
  padding: 7px 10px;
  border: 1px solid hsl(var(--h-blue) / 0.24);
  border-radius: 999px;
  color: var(--blue);
  background: hsl(var(--h-blue) / 0.07);
  font-size: 12px;
  font-weight: 800;
}

.quick-delivery-form {
  display: grid;
  gap: 14px;
  padding: 0 18px 18px;
  border-top: 1px solid var(--line);
}

.quick-delivery-callout {
  display: grid;
  gap: 3px;
  margin-top: 14px;
  padding: 12px 14px;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  color: var(--soft);
  background: hsl(var(--h-green) / 0.07);
}

.quick-delivery-callout span {
  color: var(--muted);
  font-size: 12px;
}

.quick-delivery-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-delivery-grid.optional-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quick-delivery-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.quick-delivery-actions .btn {
  min-width: 190px;
}

@media (max-width: 760px) {
  .quick-delivery-panel > summary,
  .quick-delivery-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .quick-delivery-grid,
  .quick-delivery-grid.optional-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .quick-delivery-actions .btn {
    width: 100%;
    min-width: 0;
  }
}

body {
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(22, 131, 90, 0.08) 0 1px, transparent 1px 28px),
    linear-gradient(45deg, rgba(31, 102, 209, 0.055) 0 1px, transparent 1px 34px),
    linear-gradient(180deg, #ffffff 0%, var(--paper) 48%, #eef4f8 100%);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

body::before {
  background:
    radial-gradient(circle at 12% 8%, rgba(22, 131, 90, 0.14), transparent 28%),
    radial-gradient(circle at 88% 16%, rgba(31, 102, 209, 0.10), transparent 32%),
    linear-gradient(rgba(23, 32, 51, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 51, 0.025) 1px, transparent 1px);
  background-size: auto, auto, 54px 54px, 54px 54px;
  mask-image: linear-gradient(180deg, #000 0%, #000 72%, transparent 100%);
}

body::after {
  background: linear-gradient(90deg, var(--green), var(--blue-2), #f2b84b, var(--red));
  background-size: 260% 100%;
  box-shadow: 0 0 18px rgba(22, 131, 90, 0.22);
}

.app-shell {
  padding-top: env(safe-area-inset-top);
}

.login-panel,
.panel,
.metric,
.module-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.98)),
    var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.login-panel {
  border-top-color: var(--green);
}

.module-tab {
  color: var(--ink);
  background: #ffffff;
}

.module-tab.active,
.module-tab:hover {
  border-color: rgba(22, 131, 90, 0.28);
  background: rgba(22, 131, 90, 0.08);
}

.brand-logo {
  background: #111827;
  box-shadow: 0 12px 28px rgba(19, 32, 53, 0.16);
}

.topbar {
  background: rgba(255, 255, 255, 0.92);
  border-bottom-color: var(--line);
  box-shadow: 0 10px 30px rgba(19, 32, 53, 0.08);
}

.sidebar {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px);
}

.nav-item,
.btn,
.module-card,
.metric,
.panel,
.smart-result {
  transition:
    transform var(--motion-mid) var(--motion-ease),
    box-shadow var(--motion-mid) var(--motion-ease),
    border-color var(--motion-mid) var(--motion-ease),
    background var(--motion-mid) var(--motion-ease),
    opacity var(--motion-mid) var(--motion-ease);
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(22, 131, 90, 0.26);
  color: var(--ink);
  background: rgba(22, 131, 90, 0.10);
}

.btn {
  color: var(--ink);
  background: #eef2f6;
}

.btn.primary {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

.btn.danger {
  border-color: #f2b8b5;
  background: #fff5f5;
  color: #991b1b;
}

.btn.danger.stock-out-btn {
  border-color: #b91c1c;
  background: #dc2626;
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 12px 26px rgba(220, 38, 38, 0.18);
}

.btn.danger.stock-out-btn:hover {
  background: #b91c1c;
  box-shadow: 0 16px 34px rgba(220, 38, 38, 0.24);
}

.btn.label-action-btn {
  width: 100%;
  margin-top: 12px;
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(15, 118, 110, 0.18);
}

.btn.label-action-btn:hover {
  background: #115e59;
  box-shadow: 0 16px 34px rgba(15, 118, 110, 0.24);
}

.btn.ghost {
  background: #ffffff;
  color: var(--soft);
  border-color: var(--line);
}

.copyable-code {
  display: inline;
  color: var(--green);
  font-weight: 900;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: copy;
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.smart-result .copyable-code,
.quick-product .copyable-code {
  position: relative;
  z-index: 2;
}

.panel,
.table-wrap,
td,
th,
.scan-card,
.smart-results,
.quick-search-results,
.sale-items,
.sale-history-panel,
.wholesale-history-panel,
.cash-table,
.product-tag-row {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

input,
select,
textarea {
  color: var(--ink);
  background: var(--field);
  border-left-color: rgba(22, 131, 90, 0.62);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 131, 90, 0.13);
}

.view.active > * {
  animation: motionFadeUp 520ms var(--motion-ease) both;
}

.view.active > *:nth-child(2) {
  animation-delay: 45ms;
}

.view.active > *:nth-child(3) {
  animation-delay: 90ms;
}

.metric,
.module-card,
.panel {
  will-change: transform;
}

.module-card:hover,
.metric:hover,
.panel:hover {
  border-color: rgba(22, 131, 90, 0.28);
  transform: translate3d(0, -2px, 0);
}

.module-card strong,
.metric strong,
.scan-card span {
  color: var(--green);
}

.product-photo,
.empty-state,
.scan-card,
.count-box,
.sale-product-box,
.totals-box {
  background: #f8fbff;
}

.empty-state {
  color: var(--muted);
}

.scan-panel {
  color: #ffffff;
  background: #111827;
}

.scanner-status {
  color: #ffffff;
  background: rgba(17, 24, 39, 0.72);
  backdrop-filter: blur(10px);
}

.payment-method-grid {
  align-items: end;
}

.sale-routing-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 10px;
  width: min(100%, 430px);
}

.sale-routing-controls label {
  min-width: 0;
}

.sale-tax-included-note {
  padding: 11px 13px;
  border: 1px solid rgba(22, 131, 90, 0.22);
  border-radius: 8px;
  background: rgba(22, 131, 90, 0.07);
  color: var(--ink);
  line-height: 1.4;
}

.payment-note {
  min-height: 52px;
  padding: 14px 16px;
  color: var(--soft);
  background: rgba(22, 131, 90, 0.08);
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: var(--radius);
  font-weight: 700;
  line-height: 1.35;
}

.payment-split {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 14px;
  background: rgba(22, 131, 90, 0.055);
  border: 1px solid rgba(22, 131, 90, 0.16);
  border-radius: var(--radius);
}

.payment-split.single-payment {
  grid-template-columns: minmax(0, 1fr);
}

.payment-amount-grid {
  width: 100%;
}

.cashea-breakdown-box {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 251, 235, 0.86);
}

.cashea-breakdown-box div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.cashea-breakdown-box span {
  color: #92400e;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.cashea-breakdown-box strong {
  color: var(--text);
  font-family: var(--display-font);
  font-size: 1.05rem;
}

.delivery-change-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.28);
  border-radius: var(--radius);
}

.delivery-change-box small {
  color: #92400e;
  font-weight: 800;
}

.delivery-change-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, 0.32);
  border-radius: 8px;
  background: rgba(255, 251, 235, 0.86);
}

.delivery-change-summary span {
  color: var(--soft);
  font-weight: 900;
}

.delivery-change-summary strong {
  color: #92400e;
  font-family: var(--display-font);
  font-size: 1.15rem;
}

.delivery-change-summary small {
  grid-column: 1 / -1;
}

.delivery-alert-summary {
  border-color: rgba(220, 38, 38, 0.34);
  background: rgba(254, 242, 242, 0.92);
}

.delivery-alert-summary strong {
  color: #b91c1c;
}

.pending-payment {
  color: var(--red);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.table-actions {
  justify-content: flex-end;
}

.import-panel + .import-panel {
  margin-top: 18px;
}

.scan-confirm {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #ffffff;
  background: rgba(22, 131, 90, 0.92);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, -10px, 0) scale(0.96);
  transition:
    opacity 220ms var(--motion-ease),
    transform 220ms var(--motion-ease);
}

.scan-confirm.show {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.scan-confirm small {
  margin-left: auto;
  overflow: hidden;
  max-width: 46%;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.check-icon {
  position: relative;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #ffffff;
}

.check-icon::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  width: 9px;
  height: 14px;
  border-right: 3px solid var(--green);
  border-bottom: 3px solid var(--green);
  transform: rotate(42deg);
}

.sales-layout {
  display: grid;
  grid-template-columns: minmax(520px, 0.9fr) minmax(520px, 1.1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.sales-layout > * {
  min-width: 0;
}

.sale-product-box {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.16);
  border-radius: 8px;
}

.scan-smart-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(31, 102, 209, 0.16);
  border-radius: 8px;
  background: rgba(31, 102, 209, 0.04);
}

.compact-grid {
  grid-template-columns: 1.2fr 0.7fr 0.9fr auto;
  align-items: end;
}

.sale-history-head {
  align-items: start;
}

.sale-history-filters {
  display: grid;
  grid-template-columns: minmax(130px, 0.75fr) minmax(130px, 0.75fr) minmax(220px, 1.5fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.sale-history-filters > *,
.sale-history-filters input,
.sale-history-filters .btn {
  min-width: 0;
  width: 100%;
}

.sale-history-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.sale-history-summary span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(31, 102, 209, 0.06);
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.sale-history-daily {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(22, 131, 90, 0.08), rgba(31, 102, 209, 0.04));
}

.sale-history-daily > strong {
  color: var(--text);
  font-family: "Outfit", "Inter", system-ui, sans-serif;
  font-size: 14px;
}

.sale-history-daily > div {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.sale-history-daily span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(22, 131, 90, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.sale-history-daily b {
  color: var(--soft);
  font-size: 12px;
  text-transform: uppercase;
}

.sale-history-daily em {
  color: var(--green);
  font-family: "Outfit", "Inter", system-ui, sans-serif;
  font-size: 20px;
  font-style: normal;
  font-weight: 900;
}

.sale-history-daily small {
  color: var(--muted);
  font-weight: 800;
}

.warning-text {
  color: #9a5b00 !important;
  background: rgba(245, 158, 11, 0.12) !important;
  border-color: rgba(245, 158, 11, 0.28) !important;
}

.danger-text {
  color: var(--red) !important;
}

.negative-stock {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid #efaaa4;
  border-radius: 4px;
  background: #fff1f0;
  color: #b42318 !important;
  font-weight: 900 !important;
  line-height: 1.25;
  white-space: nowrap;
}

.success-text {
  color: var(--green) !important;
}

.cashea-filter-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.cashea-calculator-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  border-color: rgba(22, 131, 90, 0.22);
  background:
    linear-gradient(135deg, rgba(22, 131, 90, 0.08), rgba(31, 102, 209, 0.05)),
    var(--panel);
}

.cashea-calculator-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 180px) minmax(180px, 1fr);
  gap: 12px;
}

.cashea-calculator-results {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
}

.cashea-calculator-results div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.cashea-calculator-results span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.cashea-calculator-results strong {
  color: var(--ink);
  font-family: "Outfit", "Inter", system-ui, sans-serif;
  font-size: clamp(18px, 2vw, 26px);
  font-weight: 900;
  line-height: 1.05;
}

.cashea-calculator-results .highlight {
  border-color: rgba(22, 131, 90, 0.24);
  background: rgba(236, 253, 245, 0.92);
}

.cashea-calculator-results .highlight strong {
  color: var(--green);
}

.cashea-settlement-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
  border-color: rgba(17, 75, 176, 0.18);
  background:
    linear-gradient(135deg, rgba(31, 102, 209, 0.08), rgba(22, 131, 90, 0.06)),
    var(--panel);
}

.cashea-settlement-toggle {
  justify-self: end;
  align-items: center;
  margin: 0;
}

.cashea-settlement-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.cashea-settlement-results {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.cashea-settlement-results div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.06);
}

.cashea-settlement-results span,
.cashea-settlement-results small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.cashea-settlement-results strong {
  color: var(--ink);
  font-family: "Outfit", "Inter", system-ui, sans-serif;
  font-size: clamp(18px, 1.8vw, 26px);
  font-weight: 900;
  line-height: 1.05;
}

.cashea-settlement-results .warning {
  border-color: rgba(245, 158, 11, 0.25);
  background: rgba(255, 251, 235, 0.92);
}

.cashea-settlement-results .danger {
  border-color: rgba(220, 38, 38, 0.24);
  background: rgba(254, 242, 242, 0.92);
}

.cashea-settlement-results .danger strong {
  color: var(--red);
}

.cashea-settlement-results .success {
  border-color: rgba(22, 131, 90, 0.24);
  background: rgba(236, 253, 245, 0.95);
}

.cashea-settlement-results .success strong {
  color: var(--green);
}

.cashea-formula-box {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 14px;
  border: 1px dashed rgba(22, 131, 90, 0.26);
  border-radius: 8px;
  background: rgba(236, 253, 245, 0.78);
  color: var(--ink);
  font-weight: 800;
}

.cashea-formula-box span {
  color: var(--muted);
}

.cashea-metrics .metric strong {
  overflow-wrap: anywhere;
}

.cashea-report-table td {
  vertical-align: top;
}

.cashea-report-table td small {
  display: block;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.cashea-inline-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 8px;
  min-width: min(620px, 72vw);
}

.cashea-inline-fields label {
  gap: 4px;
  min-width: 0;
  font-size: 11px;
}

.cashea-inline-fields input,
.cashea-inline-fields select,
.cashea-inline-fields textarea {
  min-width: 0;
  padding: 8px 9px;
  font-size: 13px;
}

.cashea-notes-field {
  grid-column: 1 / -1;
}

@media (max-width: 1500px) {
  .sales-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 760px) {
  .cashea-breakdown-box,
  .cashea-inline-fields {
    grid-template-columns: 1fr;
  }

  .cashea-inline-fields {
    min-width: 0;
  }

  .cashea-calculator-grid,
  .cashea-calculator-results,
  .cashea-settlement-grid,
  .cashea-settlement-results {
    grid-template-columns: 1fr;
  }

  .cashea-settlement-toggle {
    justify-self: start;
  }
}

@media (max-width: 1180px) {
  .sale-history-filters,
  .compact-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .sale-history-search,
  .sale-history-filters .btn {
    grid-column: 1 / -1;
  }
}

.smart-results {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
}

.smart-result {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  color: var(--ink);
  background: #ffffff;
  text-align: left;
}

.smart-result:hover {
  border-color: rgba(22, 131, 90, 0.28);
  transform: translate3d(0, -1px, 0);
}

.smart-result .product-photo {
  width: 44px;
  height: 44px;
}

.smart-result span,
.smart-result em {
  min-width: 0;
  color: var(--muted);
  font-style: normal;
  line-height: 1.25;
  overflow-wrap: break-word;
  word-break: normal;
}

.smart-result em {
  grid-column: 2;
  display: block;
  margin-top: -4px;
}

.smart-result strong {
  display: block;
  color: var(--ink);
}

.sale-items {
  display: grid;
  gap: 10px;
}

.totals-box {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.totals-box span {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--soft);
}

.totals-box .grand-total {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.quick-create {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.16);
  border-radius: 8px;
  background: #f8fbff;
}

.label-print-button {
  margin-top: 12px;
}

.label-scanner-panel {
  min-height: 260px;
  overflow: hidden;
}

.label-scanner-panel .scan-video,
.label-scanner-panel .quagga-viewport {
  min-height: 220px;
}

.preview-label {
  border: 1px dashed rgba(23, 32, 51, 0.22);
  box-shadow: 0 14px 28px rgba(19, 32, 53, 0.10);
  transform-origin: top left;
}

.print-label {
  width: 60mm;
  height: 30mm;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto 9mm;
  gap: 1mm;
  padding: 2mm 2.4mm 1.8mm;
  overflow: hidden;
  color: #111827;
  background: #ffffff;
  font-family: Arial, "Helvetica Neue", sans-serif;
}

.label-brand {
  font-size: 7.4px;
  font-weight: 900;
  letter-spacing: 0.2px;
}

.label-desc {
  min-height: 0;
  overflow: hidden;
  font-size: 11.8px;
  font-weight: 900;
  line-height: 1.04;
  text-transform: uppercase;
}

.label-code {
  overflow: hidden;
  font-size: 10.6px;
  font-weight: 900;
  line-height: 1.06;
  letter-spacing: 0.15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label-barcode {
  width: 100%;
  height: 11mm;
  display: block;
  fill: #111827;
}

.focus-flash {
  animation: focusFlash 900ms var(--motion-ease) both;
}

#printRoot {
  display: none;
}

@keyframes focusFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 131, 90, 0.0), var(--shadow);
  }
  35% {
    box-shadow: 0 0 0 5px rgba(22, 131, 90, 0.18), var(--shadow);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(22, 131, 90, 0.0), var(--shadow);
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding-top: 0;
  }

  .topbar {
    position: sticky;
    top: 0;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: rgba(255, 255, 255, 0.96);
  }

  .sidebar {
    background: #ffffff;
  }

  .sales-layout,
  .compact-grid {
    grid-template-columns: 1fr;
  }

  .preview-label {
    max-width: 100%;
  }

  tr {
    background: #ffffff;
  }

  td:nth-child(3)::before,
  td:nth-child(4)::before,
  td:nth-child(5)::before,
  td:nth-child(6)::before {
    content: none;
  }

  td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--muted);
    font-weight: 900;
  }

  td[data-label="Foto"]::before,
  td[data-label="Accion"]::before {
    content: "";
  }

  td:nth-child(n + 3) {
    color: var(--soft);
  }

  .smart-result {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .smart-result em {
    grid-column: 2;
  }

  .scan-confirm {
    left: 12px;
    right: 12px;
  }

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

  .bulk-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .bulk-footer .btn {
    width: 100%;
  }

  .bulk-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .bulk-table {
    min-width: 760px;
  }

  #products .table-wrap {
    overflow-x: visible;
  }

  #products tr,
  #movements tr,
  #sales tr {
    max-width: 100%;
  }

  .preview-label {
    width: 60mm;
    max-width: min(100%, 60mm);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

.bcv-rate-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #b7e4d1;
  border-radius: 8px;
  background: #f0fdf7;
  color: #0f5132;
  font-weight: 800;
}

.duplicate-product-warning {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid #f2b8b5;
  border-radius: 8px;
  background: #fff5f5;
  color: #7f1d1d;
}

.duplicate-product-warning .product-photo {
  width: 58px;
  height: 58px;
}

.duplicate-product-warning div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.duplicate-product-warning span,
.duplicate-product-warning small {
  color: #991b1b;
  overflow-wrap: anywhere;
}

.sale-form-section {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(248, 251, 255, 0.84);
}

.form-step-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.form-step-title span {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 999px;
  background: var(--green);
  color: #ffffff;
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid #b7e4d1;
  border-radius: 999px;
  background: #f0fdf7;
  color: #0f5132;
  font-weight: 900;
}

.status-pill.danger {
  border-color: #f2b8b5;
  background: #fff5f5;
  color: #991b1b;
}

.status-pill.warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.status-pill.info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.sale-return-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #b7e4d1;
  border-radius: var(--radius);
  background: #f8fffb;
}

.sale-return-table input {
  min-width: 92px;
}

.bcv-rate-line .btn {
  width: auto;
}

.cash-table td.num span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

@media print {
  @page {
    size: 80mm auto;
    margin: 2mm;
  }

  html,
  body {
    width: 80mm;
    min-height: 0;
    color: #111827;
    background: #ffffff !important;
  }

  body::before,
  body::after,
  #loginScreen,
  #appShell {
    display: none !important;
  }

  #printRoot {
    display: block !important;
  }

  .print-ticket {
    width: 76mm;
    margin: 0 auto;
    padding-top: 1mm;
    color: #111827;
    background: #ffffff;
    font-family: Arial, "Helvetica Neue", sans-serif;
    font-size: 11px;
    line-height: 1.22;
  }

  .ticket-heading {
    display: grid;
    gap: 3px;
    margin-bottom: 8px;
    text-align: right;
  }

  .ticket-heading strong {
    font-size: 15px;
  }

  .ticket-status {
    font-weight: 900;
    color: #991b1b;
  }

  .ticket-client {
    display: grid;
    gap: 2px;
    margin-bottom: 6px;
  }

  .ticket-row,
  .ticket-item,
  .ticket-totals span {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22mm;
    gap: 6px;
    align-items: start;
  }

  .ticket-head {
    padding: 3px 0;
    border-top: 1px solid #111827;
    border-bottom: 1px solid #111827;
    text-decoration: underline;
  }

  .ticket-lines {
    display: grid;
    gap: 4px;
    padding: 5px 0 6px;
    border-bottom: 1px solid #111827;
  }

  .ticket-item span,
  .ticket-item small {
    display: block;
  }

  .ticket-item > strong,
  .ticket-totals strong {
    text-align: right;
  }

  .ticket-totals {
    display: grid;
    gap: 3px;
    padding-top: 6px;
    font-weight: 700;
  }

  .ticket-grand {
    font-size: 16px;
    font-weight: 900;
  }

  .ticket-notice {
    margin-top: 7px;
    padding-top: 5px;
    border-top: 1px solid #111827;
    color: #111827;
    font-size: 8px;
    line-height: 1.18;
    font-weight: 700;
    text-align: center;
  }
}

.sale-history-items {
  display: grid;
  gap: 5px;
  min-width: 0;
  max-width: 520px;
  margin-top: 8px;
}

.sale-history-items span {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 7px;
  align-items: baseline;
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid rgba(22, 131, 90, 0.14);
  border-radius: 8px;
  background: rgba(22, 131, 90, 0.055);
}

.sale-history-items strong {
  color: var(--green);
  font-size: 12px;
  white-space: nowrap;
}

.sale-history-items em {
  min-width: 0;
  color: var(--soft);
  font-size: 12px;
  font-style: normal;
  line-height: 1.25;
  overflow-wrap: break-word;
  word-break: normal;
}

.sale-history-items small,
.sale-history-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sale-history-items span small {
  grid-column: 2;
}

.sale-history-items .sale-history-price,
.sale-total-note {
  display: block;
  margin-top: 2px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}

@media (max-width: 860px) {
  .sale-history-items {
    max-width: 100%;
  }

  .sale-history-items span {
    grid-template-columns: minmax(0, 1fr);
  }

  .sale-history-items strong {
    white-space: normal;
  }

  .sale-history-items span small {
    grid-column: 1;
  }
}

/* Final iPhone/Android guardrails: keep absolutely last. */
@media (max-width: 860px) {
  html,
  body,
  .app-shell,
  .workspace,
  .content,
  .view,
  .panel {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .content {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .section-head,
  .bulk-footer,
  .cash-month-head,
  .topbar-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
    justify-content: stretch !important;
  }

  .section-head > *,
  .bulk-footer > *,
  .topbar-actions > *,
  .cash-month-head > * {
    width: 100%;
    min-width: 0;
  }

  .sales-layout,
  .split-layout,
  .scanner-grid,
  .form-grid,
  .compact-grid,
  .bulk-actions,
  .metrics-grid,
  .cash-metrics {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  label,
  input,
  select,
  textarea,
  button,
  .btn,
  .empty-state,
  .bulk-summary,
  .sale-product-box,
  .totals-box {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  input,
  select,
  textarea,
  .btn {
    width: 100%;
  }

  input[type="file"] {
    display: block;
    overflow: hidden;
    font-size: 13px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  input[type="file"]::file-selector-button,
  input[type="file"]::-webkit-file-upload-button {
    max-width: 58%;
    margin-right: 8px;
    white-space: nowrap;
  }

  .table-wrap,
  .bulk-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  table,
  tbody,
  .bulk-table,
  .cash-table,
  .sale-items-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  thead {
    display: none !important;
  }

  tbody {
    display: grid !important;
    gap: 10px;
  }

  tr {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
  }

  td {
    grid-column: 1 / -1 !important;
    width: 100%;
    min-width: 0 !important;
    border: 0;
    padding: 4px 0;
    text-align: left !important;
    overflow-wrap: anywhere;
  }

  td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--muted);
    font-weight: 900;
  }

  td input,
  td select,
  td textarea,
  .inline-pay,
  .supplier-pay {
    width: 100%;
    min-width: 0;
  }

  .inline-pay,
  .supplier-pay {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .quick-search-panel {
    place-items: stretch;
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
  }

  .quick-product {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .quick-product em,
  .quick-product b {
    grid-column: 2;
  }
}

/* Final iPhone/Android guardrails: keep absolutely last. */
@media (max-width: 860px) {
  html,
  body,
  .app-shell,
  .workspace,
  .content,
  .view,
  .panel {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .content {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .section-head,
  .bulk-footer,
  .cash-month-head,
  .topbar-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
    justify-content: stretch !important;
  }

  .section-head > *,
  .bulk-footer > *,
  .topbar-actions > *,
  .cash-month-head > * {
    width: 100%;
    min-width: 0;
  }

  .sales-layout,
  .split-layout,
  .scanner-grid,
  .form-grid,
  .compact-grid,
  .bulk-actions,
  .metrics-grid,
  .cash-metrics {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  label,
  input,
  select,
  textarea,
  button,
  .btn,
  .empty-state,
  .bulk-summary,
  .sale-product-box,
  .totals-box {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  input,
  select,
  textarea,
  .btn {
    width: 100%;
  }

  input[type="file"] {
    display: block;
    overflow: hidden;
    font-size: 13px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  input[type="file"]::file-selector-button,
  input[type="file"]::-webkit-file-upload-button {
    max-width: 58%;
    margin-right: 8px;
    white-space: nowrap;
  }

  .table-wrap,
  .bulk-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  table,
  tbody,
  .bulk-table,
  .cash-table,
  .sale-items-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  thead {
    display: none !important;
  }

  tbody {
    display: grid !important;
    gap: 10px;
  }

  tr {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
  }

  td {
    grid-column: 1 / -1 !important;
    width: 100%;
    min-width: 0 !important;
    border: 0;
    padding: 4px 0;
    text-align: left !important;
    overflow-wrap: anywhere;
  }

  td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--muted);
    font-weight: 900;
  }

  td input,
  td select,
  td textarea,
  .inline-pay,
  .supplier-pay {
    width: 100%;
    min-width: 0;
  }

  .inline-pay,
  .supplier-pay {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .quick-search-panel {
    place-items: stretch;
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
  }

  .quick-product {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .quick-product em,
  .quick-product b {
    grid-column: 2;
  }
}

.quick-search-panel {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: start center;
  padding: calc(18px + env(safe-area-inset-top)) 14px 18px;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(12px);
}

.quick-search-card {
  width: min(720px, 100%);
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.24);
}

.quick-search-card input {
  width: 100%;
}

.quick-search-results {
  display: grid;
  gap: 8px;
  max-height: min(70vh, 620px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.quick-product {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  background: #ffffff;
  text-align: left;
}

.quick-product span,
.quick-product small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.quick-product small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 800;
}

.quick-product em,
.quick-product b {
  white-space: nowrap;
  font-style: normal;
}

.quick-product em {
  color: var(--green);
  font-weight: 900;
}

/* Final iPhone/Android guardrails: every module must stay inside the screen. */
@media (max-width: 860px) {
  html,
  body,
  .app-shell,
  .workspace,
  .content,
  .view,
  .panel {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .content {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }

  .section-head,
  .bulk-footer,
  .cash-month-head,
  .topbar-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
    justify-content: stretch !important;
  }

  .section-head > *,
  .bulk-footer > *,
  .topbar-actions > *,
  .cash-month-head > * {
    width: 100%;
    min-width: 0;
  }

  .sales-layout,
  .split-layout,
  .scanner-grid,
  .form-grid,
  .compact-grid,
  .bulk-actions,
  .metrics-grid,
  .cash-metrics {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  label,
  input,
  select,
  textarea,
  button,
  .btn,
  .empty-state,
  .bulk-summary,
  .sale-product-box,
  .totals-box {
    max-width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  input,
  select,
  textarea,
  .btn {
    width: 100%;
  }

  input[type="file"] {
    display: block;
    overflow: hidden;
    font-size: 13px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  input[type="file"]::file-selector-button,
  input[type="file"]::-webkit-file-upload-button {
    max-width: 58%;
    margin-right: 8px;
    white-space: nowrap;
  }

  .table-wrap,
  .bulk-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  table,
  tbody,
  .bulk-table,
  .cash-table,
  .sale-items-table {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  thead {
    display: none !important;
  }

  tbody {
    display: grid !important;
    gap: 10px;
  }

  tr {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
  }

  td {
    grid-column: 1 / -1 !important;
    width: 100%;
    min-width: 0 !important;
    border: 0;
    padding: 4px 0;
    text-align: left !important;
    overflow-wrap: anywhere;
  }

  td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--muted);
    font-weight: 900;
  }

  td input,
  td select,
  td textarea,
  .inline-pay,
  .supplier-pay {
    width: 100%;
    min-width: 0;
  }

  .inline-pay,
  .supplier-pay {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }

  .quick-search-panel {
    place-items: stretch;
    padding: calc(10px + env(safe-area-inset-top)) 10px calc(10px + env(safe-area-inset-bottom));
  }

  .quick-product {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .quick-product em,
  .quick-product b {
    grid-column: 2;
  }
}

/* BASE mobile/print overrides: keep last so iPhone and Android do not crop document tools. */
@media (max-width: 860px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .view,
  .panel,
  .table-wrap,
  .bulk-table-wrap,
  .sales-layout,
  .split-layout,
  .scanner-grid,
  .form-grid,
  .bulk-actions,
  .cash-tabs {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  .bulk-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
    align-items: stretch !important;
  }

  .bulk-actions > label,
  .bulk-actions > .btn,
  .bulk-actions input[type="file"],
  .bulk-actions textarea {
    width: 100% !important;
    min-width: 0 !important;
  }

  .bulk-actions input[type="file"] {
    display: block;
    overflow: hidden;
    padding: 10px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .bulk-actions input[type="file"]::file-selector-button,
  .bulk-actions input[type="file"]::-webkit-file-upload-button {
    max-width: 58%;
    margin-right: 8px;
    border: 0;
    border-radius: 999px;
    padding: 8px 12px;
    background: #eef2f6;
    font-weight: 900;
  }

  .bulk-footer,
  .cash-month-head {
    display: grid !important;
    grid-template-columns: 1fr !important;
    justify-content: stretch !important;
  }

  .bulk-footer .btn,
  .cash-month-head input {
    width: 100%;
  }

  .cash-tabs {
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .cash-tab {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

.preview-label,
.print-label {
  border: 0.35mm solid #111827 !important;
}

@media print {
  #printRoot[data-print-mode="label"] .print-label {
    width: 60mm !important;
    height: 30mm !important;
    border: 0.35mm solid #111827 !important;
    padding: 3mm 3.2mm 2.7mm !important;
    box-shadow: none !important;
  }
}

/* Caja mensual y etiquetas: reglas finales para ganar sobre bloques antiguos. */
.cash-month-head {
  margin-bottom: 14px;
}

.cash-month-head input {
  max-width: 190px;
}

.cash-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 14px;
  scrollbar-width: thin;
}

.cash-tab {
  flex: 0 0 auto;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--soft);
  background: #ffffff;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 180ms var(--motion-ease),
    border-color 180ms var(--motion-ease),
    background 180ms var(--motion-ease);
}

.cash-tab.active,
.cash-tab:hover {
  color: var(--green);
  border-color: rgba(22, 131, 90, 0.42);
  background: #edfdf4;
  transform: translateY(-1px);
}

.control-list,
.cash-list-grid {
  display: grid;
  gap: 10px;
}

.control-list span,
.cash-list-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fbff;
}

.control-list strong {
  display: block;
  color: var(--ink);
}

.cash-list-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cash-list-grid > div {
  display: grid;
  align-content: start;
}

.cash-list-grid strong {
  margin-bottom: 8px;
}

.cash-list-grid span {
  padding: 5px 0;
  color: var(--soft);
  font-weight: 800;
}

.user-admin-panel {
  margin-top: 18px;
}

.user-admin-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 14px;
}

.user-admin-summary > div {
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 10px;
  padding: 12px;
  background: #f4fbf7;
}

.user-admin-summary span {
  display: block;
  color: var(--soft);
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
}

.user-admin-summary strong {
  display: block;
  color: var(--green);
  font-family: "Outfit", sans-serif;
  font-size: 28px;
  line-height: 1.1;
}

.user-admin-error {
  margin: 8px 0 12px;
}

.user-create-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 0.9fr minmax(260px, 1.4fr) auto;
  gap: 12px;
  align-items: end;
  margin: 14px 0 18px;
}

.user-admin-list {
  display: grid;
  gap: 12px;
}

.user-admin-card {
  display: grid;
  grid-template-columns: minmax(190px, 1.3fr) minmax(150px, 0.9fr) minmax(130px, 0.7fr) minmax(150px, 0.8fr) minmax(260px, 1.3fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  background: #f8fbff;
}

.user-admin-main {
  display: grid;
  gap: 3px;
  align-self: center;
}

.user-admin-main strong {
  color: var(--ink);
  font-size: 16px;
}

.user-admin-main span,
.user-admin-main small {
  color: var(--soft);
  font-weight: 800;
}

.user-admin-actions {
  display: grid;
  gap: 8px;
  align-self: end;
}

.user-actions-picker {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #ffffff;
}

.user-actions-picker summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 900;
  list-style: none;
}

.user-actions-picker summary::-webkit-details-marker {
  display: none;
}

.permission-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.btn.tiny {
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 12px;
}

.user-permissions-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  max-height: 280px;
  overflow: auto;
  padding-top: 10px;
}

.user-action-check {
  min-height: 34px;
  padding: 8px;
  border: 1px solid rgba(14, 22, 36, 0.08);
  border-radius: 8px;
  background: #f8fbff;
}

.user-action-check span {
  color: var(--ink);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .user-create-grid,
  .user-admin-card {
    grid-template-columns: 1fr 1fr;
  }

  .user-admin-main {
    grid-column: 1 / -1;
  }

  .user-actions-picker {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .user-admin-summary {
    grid-template-columns: 1fr;
  }

  .user-create-grid,
  .user-admin-card {
    grid-template-columns: 1fr;
  }

  .user-permissions-grid {
    grid-template-columns: 1fr;
  }
}

.cash-expected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 8px;
  padding: 12px;
  color: var(--soft);
  background: #f4fbf7;
  font-weight: 900;
}

.cash-expected strong {
  color: var(--green);
  font-size: 20px;
}

.driver-expected {
  background: #fff8ed;
  border-color: rgba(242, 184, 75, 0.34);
}

.driver-expected strong {
  color: #a15c06;
}

.driver-expected.received {
  background: #f4fbf7;
  border-color: rgba(22, 131, 90, 0.22);
}

.driver-expected.received strong {
  color: var(--green);
}

.row-warning {
  background: rgba(242, 184, 75, 0.12);
}

.driver-cash-table .btn {
  white-space: nowrap;
}

.inline-pay {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.compact-metrics {
  margin-bottom: 14px;
}

.cash-table td span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.print-label {
  position: relative;
  border: 0.35mm solid #111827 !important;
  padding: 3mm 3.2mm 2.7mm !important;
  box-shadow: inset 0 0 0 0.25mm #ffffff;
}

.preview-label {
  border-style: solid !important;
  border-color: #111827 !important;
}

@media (max-width: 860px) {
  .cash-month-head {
    display: grid;
    align-items: stretch;
  }

  .cash-month-head input {
    max-width: none;
    width: 100%;
  }

  .cash-list-grid {
    grid-template-columns: 1fr;
  }

  .inline-pay {
    grid-template-columns: 1fr;
  }

  .cash-daily-wrap .cash-table {
    min-width: 960px;
  }
}

body {
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(22, 131, 90, 0.075) 0 1px, transparent 1px 30px),
    linear-gradient(45deg, rgba(31, 102, 209, 0.055) 0 1px, transparent 1px 36px),
    linear-gradient(180deg, #ffffff 0%, #f7fafc 50%, #edf4f8 100%);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

h1,
h2,
h3,
.metric strong,
.module-card strong,
.brand-lockup small {
  font-family: Outfit, Inter, sans-serif;
}

.topbar,
.sidebar,
.panel,
.metric,
.login-panel,
.quick-search-card,
.confirm-modal {
  background: rgba(255, 255, 255, 0.75) !important;
  border: 1px solid rgba(255, 255, 255, 0.42) !important;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.72) !important;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.topbar {
  top: 10px;
  margin: 10px auto 0;
  width: min(calc(100% - 24px), 1480px);
  border-radius: 14px;
}

.sidebar {
  margin: 12px;
  border-radius: 14px;
}

.view.active {
  animation: viewSlideIn 300ms var(--motion-ease) both;
}

.metric {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 8px;
}

.metric svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--green);
}

.metric-products {
  box-shadow: 0 8px 30px rgba(31, 102, 209, 0.14), var(--shadow) !important;
}

.metric-units,
.metric.cash-main {
  box-shadow: 0 8px 30px rgba(36, 196, 126, 0.17), var(--shadow) !important;
}

.metric-low,
.metric.pending {
  box-shadow: 0 8px 30px rgba(200, 51, 46, 0.14), var(--shadow) !important;
}

.metric-low svg,
.metric.pending svg {
  color: var(--red);
}

.metric-photo {
  box-shadow: 0 8px 30px rgba(216, 155, 34, 0.18), var(--shadow) !important;
}

.metric-photo svg {
  color: var(--gold);
}

.metric:hover,
.module-card:hover,
.panel:hover {
  transform: translateY(-4px) scale(1.005);
  box-shadow: 0 28px 70px rgba(19, 32, 53, 0.16), inset 0 1px 0 rgba(255,255,255,.74) !important;
}

.btn.primary,
.btn.success {
  background: var(--success-gradient) !important;
  border-color: rgba(18, 128, 84, 0.42) !important;
  color: #ffffff !important;
}

.btn.primary::after,
.btn.success::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.28), transparent);
  transform: translateX(-120%);
  transition: transform 420ms var(--motion-ease);
}

.btn:hover::after {
  transform: translateX(120%);
}

.btn,
.nav-item,
.module-card,
.metric,
tr,
.smart-result,
.quick-product {
  position: relative;
  overflow: hidden;
  transition: all 0.2s var(--motion-ease) !important;
}

input,
select,
textarea {
  border: 1px solid rgba(23, 32, 51, 0.12) !important;
  border-left: 4px solid rgba(22, 131, 90, 0.46) !important;
  background: var(--field) !important;
  color: var(--ink) !important;
}

input:focus,
select:focus,
textarea:focus {
  background: #ffffff !important;
  border-color: var(--green) !important;
  box-shadow: 0 0 0 4px rgba(22, 131, 90, 0.18) !important;
}

.stock-cell {
  display: grid;
  gap: 4px;
  min-width: 150px;
}

.stock-cell strong {
  color: var(--ink);
}

.stock-cell small {
  color: var(--muted);
  font-weight: 800;
}

.location-stock-pair {
  display: grid;
  grid-template-columns: minmax(140px, 1fr);
  gap: 6px;
  min-width: 140px;
  font-variant-numeric: tabular-nums;
}

.location-stock-pair > span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid rgba(22, 131, 90, 0.25);
  border-radius: 6px;
  background: rgba(22, 131, 90, 0.07);
  text-align: left;
}

.location-stock-pair > span.total {
  border-color: rgba(15, 23, 42, 0.32);
  background: #eef2f7;
}

.location-stock-pair small {
  color: var(--soft);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
  white-space: normal;
}

.location-stock-pair strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.1;
}

.location-stock-pair > span.negative {
  border-color: #f1b7b7;
  background: #fff2f2;
}

.location-stock-pair > span.negative strong {
  color: #b42318;
}

.stock-meter {
  display: block;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf5;
}

.stock-meter::after {
  content: "";
  display: block;
  width: var(--stock-width, 6%);
  height: 100%;
  border-radius: inherit;
  background: var(--success-gradient);
}

.stock-cell.warning .stock-meter::after {
  background: var(--warning-gradient);
}

.stock-cell.danger .stock-meter::after {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  animation: pulseStock 1.2s ease-in-out infinite;
}

.stock-cell.neutral .stock-meter::after {
  background: linear-gradient(135deg, #94a3b8, #64748b);
}

@media (max-width: 640px) {
  .stock-cell,
  .location-stock-pair {
    width: 100%;
    min-width: 0;
  }

  .location-stock-pair {
    grid-template-columns: minmax(0, 1fr);
  }
}

.product-photo-wrap {
  position: relative;
  display: inline-block;
}

.product-photo-wrap:hover .product-photo {
  transform: scale(1.85) translateY(-6px);
  box-shadow: 0 22px 54px rgba(17, 24, 39, 0.24);
  z-index: 8;
}

.product-photo-wrap:hover::after {
  content: attr(data-price) " · " attr(data-location);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 9;
  width: max-content;
  max-width: 220px;
  transform: translateX(-50%);
  border: 1px solid rgba(23, 32, 51, 0.12);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 18px 40px rgba(17, 24, 39, 0.18);
  font-size: 12px;
  font-weight: 900;
}

.smart-result mark,
.quick-product mark {
  border-radius: 4px;
  padding: 0 2px;
  background: rgba(36, 196, 126, 0.18);
  color: inherit;
  font-weight: 900;
}

.category-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-top: 4px;
  border: 1px solid rgba(31, 102, 209, 0.18);
  border-radius: 999px;
  padding: 2px 8px;
  color: #114bb0;
  background: rgba(31, 102, 209, 0.08);
  font-size: 11px;
  font-weight: 900;
}

.product-tag-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.row-actions {
  display: grid;
  gap: 8px;
  min-width: 170px;
}

.quick-category-label {
  display: grid;
  gap: 4px;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.quick-category-label::before {
  content: "Categoria";
}

.category-badge + .model-badge {
  margin-left: 6px;
}

.category-quick-select {
  min-width: 160px;
  max-width: 220px;
  min-height: 38px;
  padding: 8px 28px 8px 10px;
  font-size: 12px;
  font-weight: 800;
}

.model-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: min(100%, 420px);
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid rgba(22, 131, 90, 0.2);
  border-radius: 999px;
  padding: 2px 8px;
  color: #116144;
  background: rgba(22, 131, 90, 0.08);
  font-size: 11px;
  font-weight: 900;
}

.check-row input[type="checkbox"] {
  appearance: none;
  position: relative;
  width: 48px !important;
  min-width: 48px;
  height: 28px;
  border: 0 !important;
  border-radius: 999px;
  padding: 0 !important;
  background: #cbd5e1 !important;
  box-shadow: inset 0 2px 6px rgba(15, 23, 42, 0.16);
  transition: all 200ms var(--motion-ease);
}

.check-row input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.22);
  transition: transform 220ms var(--motion-ease);
}

.check-row input[type="checkbox"]:checked {
  background: var(--success-gradient) !important;
}

.check-row input[type="checkbox"]:checked::before {
  transform: translateX(20px);
}

.shimmer,
.shimmer-ready,
.empty-state:has(+ .shimmer-target) {
  background: linear-gradient(90deg, #f0f3f6 25%, #e1e5eb 50%, #f0f3f6 75%) !important;
  background-size: 200% 100% !important;
  animation: shimmerEffect 1.5s infinite;
}

.ripple {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.42);
  transform: translate(-50%, -50%) scale(0);
  animation: rippleEffect 520ms var(--motion-ease);
}

.draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
}

.draft-autosave {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 999px;
  background: rgba(22, 131, 90, 0.08);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.draft-menu {
  position: relative;
}

.draft-menu summary {
  list-style: none;
}

.draft-list {
  position: absolute;
  right: 0;
  z-index: 20;
  display: grid;
  gap: 8px;
  width: min(420px, 86vw);
  margin-top: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 24px 54px rgba(17, 24, 39, 0.18);
}

.draft-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.draft-item > button:first-child {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  background: #f8fbff;
  text-align: left;
}

.cost-history {
  display: grid;
  gap: 6px;
  border: 1px solid rgba(31,102,209,.14);
  border-radius: 8px;
  padding: 10px;
  background: rgba(31,102,209,.05);
}

.money-pair {
  display: grid;
  gap: 2px;
}

.money-pair strong {
  color: var(--green);
  font-size: clamp(24px, 3vw, 34px);
}

.money-pair small {
  color: var(--muted);
  font-weight: 900;
}

.print-a4 {
  color: #111827;
  background: #ffffff;
  font-family: Inter, Arial, sans-serif;
}

@keyframes viewSlideIn {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pulseStock {
  0%, 100% { opacity: 1; }
  50% { opacity: .48; }
}

@keyframes shimmerEffect {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

@keyframes rippleEffect {
  to { transform: translate(-50%, -50%) scale(18); opacity: 0; }
}

@media print {
  @page a4 {
    size: letter;
    margin: 14mm;
  }

  #printRoot[data-print-mode="a4"] {
    display: block !important;
    width: 100%;
  }

  #printRoot[data-print-mode="a4"] .print-a4 {
    page: a4;
    width: 100%;
    font-size: 12px;
  }

  .print-a4 header,
  .print-a4 footer {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 18px;
  }

  .print-a4 header img {
    width: 170px;
  }

  .print-a4 table {
    display: table !important;
    width: 100% !important;
    border-collapse: collapse;
  }

  .print-a4 thead {
    display: table-header-group !important;
  }

  .print-a4 tbody {
    display: table-row-group !important;
  }

  .print-a4 tr {
    display: table-row !important;
    padding: 0;
    border: 0;
  }

  .print-a4 th,
  .print-a4 td {
    display: table-cell !important;
    border-bottom: 1px solid #d0d5dd;
    padding: 8px;
    text-align: left !important;
  }

  .print-a4 footer {
    margin-top: 18px;
    margin-bottom: 8px;
    font-size: 20px;
    font-weight: 900;
  }

  .print-a4 .a4-notice {
    margin: 10px 0 0;
    padding-top: 8px;
    border-top: 1px solid #d0d5dd;
    color: #667085;
    font-size: 10px;
    font-weight: 700;
    text-align: center;
  }
}

@media (max-width: 860px) {
  .topbar {
    top: 0;
    width: 100%;
    margin: 0;
    border-radius: 0;
  }

  .sidebar {
    margin: 0;
    border-radius: 0;
  }

  .draft-actions {
    display: grid;
    justify-content: stretch;
  }

  .draft-list {
    position: static;
    width: 100%;
  }
}

@media print {
  @page label {
    size: 60mm 30mm;
    margin: 0;
  }

  #printRoot[data-print-mode="label"] {
    width: 60mm !important;
  }

  #printRoot[data-print-mode="label"] .print-label {
    page: label;
    width: 60mm !important;
    height: 30mm !important;
    border: 0.35mm solid #111827 !important;
    break-after: page;
    page-break-after: always;
  }
}

/* Final mobile fixes for document/list import controls. Keep this at the end so it wins over older theme blocks. */
@media (max-width: 860px) {
  .bulk-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 12px !important;
    align-items: stretch !important;
  }

  .bulk-actions > label,
  .bulk-actions > .btn {
    width: 100%;
    min-width: 0;
  }

  .bulk-actions textarea {
    min-height: 112px;
    resize: vertical;
  }

  .bulk-actions input[type="file"] {
    display: block;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    padding: 10px;
    font-size: 14px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .bulk-actions input[type="file"]::file-selector-button,
  .bulk-actions input[type="file"]::-webkit-file-upload-button {
    max-width: 62%;
    margin-right: 8px;
    border: 0;
    border-radius: 999px;
    padding: 8px 12px;
    color: var(--ink);
    background: #eef2f6;
    font-weight: 900;
  }

  .bulk-footer {
    justify-content: stretch;
  }

  .bulk-footer .btn {
    width: 100%;
  }
}

@media print {
  @page ticket {
    size: 80mm auto;
    margin: 4mm;
  }

  @page label {
    size: 60mm 30mm;
    margin: 0;
  }

  html,
  body {
    width: auto;
    min-height: 0;
    background: #ffffff !important;
  }

  #printRoot[data-print-mode="ticket"] {
    width: 80mm;
  }

  #printRoot[data-print-mode="label"] {
    width: 60mm;
  }

  .print-ticket {
    page: ticket;
  }

  .print-label {
    page: label;
    width: 60mm;
    height: 30mm;
    box-shadow: none;
    border: 0;
    break-after: page;
    page-break-after: always;
  }
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  min-height: 100%;
  margin: 0;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(26, 86, 232, 0.10) 0 1px, transparent 1px 26px),
    linear-gradient(45deg, rgba(232, 37, 26, 0.07) 0 1px, transparent 1px 32px),
    linear-gradient(180deg, #070b14 0%, var(--paper) 38%, #080d18 100%);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 16%, rgba(26, 86, 232, 0.22), transparent 28%),
    radial-gradient(circle at 88% 20%, rgba(232, 37, 26, 0.16), transparent 30%),
    linear-gradient(rgba(240, 244, 255, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(240, 244, 255, 0.018) 1px, transparent 1px);
  background-size: auto, auto, 52px 52px, 52px 52px;
  mask-image: linear-gradient(180deg, #000 0%, #000 72%, transparent 100%);
}

body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 60;
  pointer-events: none;
  background: linear-gradient(90deg, var(--red), var(--blue-2), var(--green), var(--red));
  background-size: 260% 100%;
  box-shadow: 0 0 24px rgba(47, 125, 255, 0.4);
  animation: motionTopScan 5.2s linear infinite;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-panel,
.panel,
.metric {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(240, 244, 255, 0.05), transparent 38%),
    rgba(15, 25, 41, 0.94);
  box-shadow: var(--shadow);
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 26px;
  border-top: 4px solid var(--blue);
  animation: motionPanelIn var(--motion-slow) var(--motion-ease) both;
}

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

.module-tab {
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  transition:
    transform var(--motion-fast) ease,
    border-color var(--motion-fast) ease,
    background var(--motion-fast) ease;
}

.module-tab span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.module-tab strong {
  display: block;
  margin-top: 6px;
  font-size: 15px;
  line-height: 1.15;
}

.module-tab:hover {
  transform: translateY(-2px);
  border-color: rgba(47, 125, 255, 0.46);
  background: rgba(26, 86, 232, 0.18);
}

.module-tab.active {
  border-color: rgba(31, 102, 209, 0.35);
  background: rgba(31, 102, 209, 0.09);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  display: block;
  width: min(190px, 52vw);
  height: auto;
  max-height: 72px;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.brand-logo.compact {
  width: 148px;
  max-height: 54px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--red);
  border-radius: 4px;
  color: var(--ink);
  background: #111a2c;
  font-weight: 900;
}

.brand-mark span {
  color: var(--red);
}

.brand-lockup small,
.muted,
.view-title span,
.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.login-panel h1,
.view-title h2 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1;
}

.stacked-form {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  min-width: 18px;
  height: 18px;
  padding: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid rgba(47, 125, 255, 0.62);
  border-radius: 6px;
  padding: 12px;
  color: var(--ink);
  background: var(--field);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(31, 102, 209, 0.14);
}

.btn {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--ink);
  background: #2a3a55;
  font-weight: 900;
  transition:
    transform var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease,
    background var(--motion-fast) ease,
    border-color var(--motion-fast) ease;
}

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

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

.btn.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--soft);
}

.btn.small {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 12px;
}

.btn:active {
  transform: translateY(0) scale(0.98);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.form-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  background: rgba(7, 11, 20, 0.94);
  backdrop-filter: blur(14px);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-bcv-calculator {
  flex: 0 1 620px;
  max-width: 640px;
  min-width: 340px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas:
    "label values"
    "rate rate";
  align-items: center;
  gap: 5px 10px;
  padding: 8px 10px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(238, 249, 244, 0.96));
  box-shadow: 0 12px 30px rgba(19, 32, 53, 0.08);
}

.topbar-bcv-row {
  grid-area: values;
  display: grid;
  grid-template-columns: minmax(92px, 120px) minmax(126px, 1fr) minmax(92px, 120px) minmax(126px, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-bcv-calculator label {
  grid-area: label;
  color: var(--soft);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.topbar-bcv-calculator small {
  grid-area: rate;
  justify-self: end;
  max-width: 100%;
  color: var(--soft);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.15;
  text-align: right;
  text-transform: uppercase;
  white-space: normal;
}

.topbar-bcv-input {
  display: flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid rgba(22, 131, 90, 0.2);
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
}

.topbar-bcv-input span {
  padding: 0 7px;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
}

.topbar-bcv-input input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 6px 8px;
  border: 0 !important;
  border-left: 1px solid rgba(22, 131, 90, 0.16) !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.topbar-bcv-input input:focus {
  box-shadow: inset 0 0 0 2px rgba(22, 131, 90, 0.18) !important;
}

.topbar-bcv-calculator strong {
  min-width: 0;
  color: var(--green);
  font-family: "Outfit", "Inter", system-ui, sans-serif;
  font-size: clamp(14px, 1vw, 17px);
  font-weight: 900;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 1420px) {
  .topbar-bcv-calculator {
    flex-basis: 360px;
    max-width: 420px;
    grid-template-columns: 1fr;
    grid-template-areas:
      "label"
      "values"
      "rate";
  }

  .topbar-bcv-row {
    grid-template-columns: minmax(0, 1fr) minmax(110px, 1fr);
    gap: 6px 8px;
  }

  .topbar-bcv-calculator strong {
    text-align: left;
  }

  .topbar-bcv-calculator small {
    justify-self: start;
    text-align: left;
  }
}

.app-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid rgba(22, 131, 90, 0.22);
  border-radius: 999px;
  background: rgba(22, 131, 90, 0.08);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.app-status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(22, 131, 90, 0.12);
}

.app-status-pill.offline {
  border-color: rgba(245, 158, 11, 0.32);
  background: rgba(245, 158, 11, 0.12);
  color: #a16207;
}

.app-status-pill.update-ready {
  border-color: rgba(31, 102, 209, 0.28);
  background: rgba(31, 102, 209, 0.1);
  color: var(--blue);
  cursor: pointer;
}

.app-status-pill.applying-update {
  border-color: rgba(31, 102, 209, 0.28);
  background: rgba(31, 102, 209, 0.12);
  color: var(--blue);
  cursor: wait;
}

.workspace {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  min-height: calc(100vh - 68px);
}

.sidebar {
  position: sticky;
  top: 68px;
  align-self: start;
  height: calc(100vh - 68px);
  padding: 14px;
  border-right: 1px solid var(--line);
  background: rgba(11, 17, 32, 0.76);
}

.nav-item {
  width: 100%;
  min-height: 42px;
  margin-bottom: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 900;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(31, 102, 209, 0.24);
  color: var(--ink);
  background: rgba(26, 86, 232, 0.18);
  transform: translateX(2px);
}

.content {
  min-width: 0;
  padding: 22px;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
  min-width: 0;
  animation: motionViewIn var(--motion-mid) var(--motion-ease) both;
}

.view-title {
  display: grid;
  gap: 5px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.module-card {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: left;
  transition:
    transform var(--motion-mid) var(--motion-ease),
    border-color var(--motion-mid) ease,
    box-shadow var(--motion-mid) ease;
}

.module-card:hover,
.metric:hover,
.panel:hover {
  border-color: rgba(47, 125, 255, 0.36);
  transform: translateY(-2px);
}

.module-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.module-card strong {
  font-size: 22px;
}

.metric {
  padding: 16px;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 32px;
}

.cash-metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.28;
}

.metric.cash-main {
  border-color: rgba(22, 131, 90, 0.34);
  background: linear-gradient(180deg, #effaf4, #ffffff);
}

.metric.pending {
  border-color: rgba(200, 51, 46, 0.28);
  background: linear-gradient(180deg, #fff5f5, #ffffff);
}

.metric.pending strong {
  color: var(--red);
}

.panel {
  min-width: 0;
  max-width: 100%;
  padding: 16px;
}

.inventory-valuation-panel {
  border-color: rgba(22, 131, 90, 0.22);
}

.valuation-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.valuation-result {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: var(--radius);
  background: rgba(22, 131, 90, 0.07);
}

.valuation-result span,
.valuation-result small,
.valuation-result em {
  color: var(--muted);
  font-weight: 800;
}

.valuation-result strong {
  color: var(--green);
  font-family: "Outfit", "Segoe UI", sans-serif;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1;
}

.valuation-result em {
  font-size: 12px;
  font-style: normal;
}

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

.search-head {
  align-items: end;
}

.section-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.search-head input {
  max-width: 360px;
}

.section-actions input {
  min-width: 220px;
}

.section-actions select {
  min-width: 190px;
  max-width: 260px;
}

@media (min-width: 761px) and (max-width: 1450px) {
  #products .search-head {
    align-items: stretch;
    flex-wrap: wrap;
  }

  #products .search-head .section-actions {
    display: grid;
    flex: 1 1 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  #products .search-head input,
  #products .search-head select {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
}

.sync-message {
  margin: 0 0 12px;
  padding: 10px 12px;
  color: var(--soft);
  background: rgba(22, 131, 90, 0.08);
  border: 1px solid rgba(22, 131, 90, 0.16);
  border-radius: var(--radius);
  font-weight: 800;
}

.ml-photo-import-panel {
  margin: 0 0 16px;
}

.ml-photo-import-stats,
.ml-photo-import-accounts,
.ml-photo-import-samples {
  display: grid;
  gap: 8px;
}

.ml-photo-import-stats {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  margin-top: 12px;
}

.ml-photo-import-stats span,
.ml-photo-import-accounts span {
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 8px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.74);
  font-weight: 800;
}

.ml-photo-import-stats strong {
  display: block;
  color: var(--ink);
  font-family: Outfit, Inter, sans-serif;
  font-size: 22px;
  line-height: 1;
}

.ml-photo-import-accounts {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  margin-top: 10px;
}

.ml-photo-import-samples {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  margin-top: 12px;
}

.ml-photo-import-samples a {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 4px 10px;
  align-items: center;
  min-height: 66px;
  padding: 8px;
  border: 1px solid rgba(31, 102, 209, 0.16);
  border-radius: 8px;
  color: var(--soft);
  background: rgba(31, 102, 209, 0.06);
  text-decoration: none;
}

.ml-photo-import-samples img,
.ml-photo-import-samples a > span {
  grid-row: 1 / 3;
  width: 48px;
  height: 48px;
  border-radius: 7px;
  object-fit: cover;
  background: rgba(15, 23, 42, 0.08);
}

.ml-photo-import-samples a > span {
  display: grid;
  place-items: center;
  color: var(--green);
  font-weight: 900;
}

.ml-photo-import-samples strong,
.ml-photo-import-samples small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ml-photo-import-samples strong {
  color: var(--ink);
}

.ml-photo-import-samples small {
  color: var(--muted);
}

.product-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
}

.product-subtab {
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.8);
  font-family: Outfit, Inter, sans-serif;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.product-subtab.active,
.product-subtab:hover {
  color: var(--green);
  border-color: rgba(22, 131, 90, 0.34);
  background: rgba(22, 131, 90, 0.1);
  box-shadow: 0 14px 30px rgba(22, 131, 90, 0.12);
  transform: translateY(-1px);
}

.quotation-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
  align-items: start;
  min-height: calc(100dvh - 170px);
}

.quotation-search-mode-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.quotation-search-mode-switch > button {
  display: grid;
  gap: 3px;
  min-height: 64px;
  padding: 11px 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  font: inherit;
  font-weight: 900;
  text-align: left;
  cursor: pointer;
}

.quotation-search-mode-switch > button small {
  color: var(--soft);
  font-size: 11px;
  font-weight: 800;
}

.quotation-search-mode-switch > button.active {
  border-color: var(--green);
  color: #fff;
  background: linear-gradient(135deg, var(--green), #126e4d);
  box-shadow: 0 12px 28px rgba(22, 131, 90, 0.2);
}

.quotation-search-mode-switch > button.active small {
  color: rgba(255, 255, 255, 0.82);
}

.quotation-vehicle-flow {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.quotation-vehicle-models {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 9px;
}

.quotation-vehicle-card {
  display: grid;
  grid-template-rows: 82px auto;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.11);
  border-radius: 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.quotation-vehicle-card:hover,
.quotation-vehicle-card.active {
  border-color: var(--green);
  box-shadow: 0 13px 30px rgba(22, 131, 90, 0.17);
  transform: translateY(-1px);
}

.quotation-vehicle-card.active {
  outline: 2px solid rgba(22, 131, 90, 0.18);
}

.quotation-vehicle-image {
  display: block;
  width: 100%;
  height: 82px;
  object-fit: cover;
  background: linear-gradient(145deg, #edf5f1, #e6ecf5);
}

.quotation-vehicle-image.empty {
  display: grid;
  place-items: center;
  color: var(--green);
  font-weight: 900;
}

.quotation-vehicle-card > span {
  display: grid;
  gap: 1px;
  padding: 8px 10px 10px;
}

.quotation-vehicle-card strong {
  color: var(--green);
  font-family: Outfit, Inter, sans-serif;
  font-size: 16px;
}

.quotation-vehicle-card small,
.quotation-vehicle-card em {
  overflow: hidden;
  color: var(--soft);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quotation-vehicle-specs {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(170px, 0.8fr) minmax(220px, 1.3fr);
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 10px;
  background: rgba(22, 131, 90, 0.055);
}

.quotation-vehicle-specs label {
  gap: 5px;
  margin: 0;
  color: var(--soft);
  font-size: 12px;
  font-weight: 900;
}

.quotation-vehicle-specs select {
  width: 100%;
  min-height: 46px;
  margin: 0;
}

.quotation-vehicle-selected {
  display: grid;
  align-content: center;
  min-height: 46px;
  padding: 7px 11px;
  border-radius: 8px;
  background: #fff;
}

.quotation-vehicle-selected span {
  color: var(--soft);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.quotation-vehicle-selected strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.quotation-vehicle-filters {
  display: grid;
  grid-template-columns: minmax(230px, 1.5fr) minmax(150px, 0.9fr) minmax(104px, 0.55fr) minmax(104px, 0.55fr);
  gap: 9px;
}

.quotation-vehicle-filters > input,
.quotation-vehicle-filters > select {
  width: 100%;
  min-height: 46px;
  margin: 0;
}

#quotationVehicleSort {
  grid-column: span 2;
}

.quotation-view-switch {
  display: grid;
  grid-column: span 2;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  padding: 4px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.04);
}

.quotation-view-switch button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  color: var(--soft);
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.quotation-view-switch button.active {
  color: #fff;
  background: var(--green);
}

.quotation-search-panel,
.quotation-basket-panel {
  min-width: 0;
  max-height: calc(100dvh - 122px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.quotation-search-input {
  width: 100%;
  min-height: 52px;
  font-size: 16px;
  font-weight: 800;
}

.quotation-filter-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.8fr) minmax(160px, 0.8fr) minmax(220px, 1.4fr);
  gap: 10px;
  margin-bottom: 12px;
  align-items: stretch;
}

.quotation-filter-row select,
.quotation-filter-row input {
  width: 100%;
  min-height: 52px;
  margin: 0;
  font-size: 15px;
}

.quotation-model-filter {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.16);
  border-radius: 8px;
  background: rgba(22, 131, 90, 0.06);
}

.quotation-model-filter strong,
.quotation-model-filter span {
  display: block;
}

.quotation-model-filter strong {
  color: var(--ink);
  font-family: Outfit, Inter, sans-serif;
  font-size: 15px;
}

.quotation-model-filter span {
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.quotation-model-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quotation-model-chip {
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 999px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.84);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.quotation-model-chip.active,
.quotation-model-chip:hover {
  color: #ffffff;
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 10px 22px rgba(22, 131, 90, 0.18);
}

.quotation-rate-line {
  margin-bottom: 14px;
}

.quotation-results {
  display: grid;
  gap: 10px;
  max-height: clamp(360px, calc(100dvh - 360px), 760px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
}

.quotation-result-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) minmax(120px, auto) 48px;
  gap: 12px;
  align-items: center;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.05);
}

.quotation-card-actions {
  display: grid;
  justify-items: center;
  gap: 6px;
}

.fitment-verified-badge {
  display: inline-flex !important;
  width: fit-content;
  margin-top: 6px !important;
  padding: 4px 7px;
  border-radius: 999px;
  color: #0b6d49 !important;
  background: rgba(22, 131, 90, 0.12);
  font-size: 10px !important;
  font-weight: 900 !important;
}

.quotation-result-card.verified-fitment {
  border-color: rgba(22, 131, 90, 0.24);
}

.fitment-suggested-badge {
  display: inline-flex !important;
  width: fit-content;
  margin-top: 6px !important;
  padding: 4px 7px;
  border-radius: 999px;
  color: #8a4b08 !important;
  background: rgba(245, 158, 11, 0.16);
  font-size: 10px !important;
  font-weight: 900 !important;
}

.fitment-suggested-note {
  display: block !important;
  margin-top: 4px !important;
  color: #854d0e !important;
  font-weight: 700;
}

.quotation-result-card.suggested-fitment {
  border-color: rgba(245, 158, 11, 0.32);
  background: linear-gradient(180deg, rgba(255, 251, 235, 0.92), rgba(255, 255, 255, 0.98));
}

.vehicle-match-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.vehicle-match-summary span {
  padding: 7px 10px;
  border: 1px solid rgba(15, 23, 42, 0.09);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.quick-search-more {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}

.vehicle-results.grid-view {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: stretch;
}

.vehicle-results.grid-view .quotation-result-card {
  grid-template-columns: 76px minmax(0, 1fr);
  align-content: start;
}

.vehicle-results.grid-view .quotation-price-box {
  grid-column: 1 / 2;
  justify-items: start;
}

.vehicle-results.grid-view .quotation-card-actions {
  grid-column: 2 / 3;
  grid-template-columns: 1fr 46px;
  justify-items: stretch;
  align-items: center;
}

.quotation-product-overlay {
  position: fixed;
  z-index: 2500;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 18, 31, 0.62);
  backdrop-filter: blur(5px);
}

.quotation-product-modal {
  width: min(760px, 100%);
  max-height: min(88dvh, 760px);
  padding: 20px;
  overflow-y: auto;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
}

.quotation-product-detail-grid {
  display: grid;
  grid-template-columns: minmax(210px, 0.8fr) minmax(260px, 1.2fr);
  gap: 18px;
}

.quotation-product-gallery {
  display: grid;
  place-items: center;
  min-height: 230px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 12px;
  background: #f7faf9;
}

.quotation-product-gallery .product-photo-wrap,
.quotation-product-gallery .product-photo {
  width: 100%;
  height: 100%;
  max-height: 360px;
  object-fit: contain;
}

.quotation-product-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quotation-product-facts > span {
  display: grid;
  align-content: center;
  gap: 3px;
  min-width: 0;
  padding: 11px;
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.045);
}

.quotation-product-facts small {
  color: var(--soft);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.quotation-product-facts strong {
  overflow-wrap: anywhere;
}

.quotation-fitment-proof {
  display: grid;
  gap: 5px;
  margin-top: 15px;
  padding: 13px;
  border: 1px solid rgba(22, 131, 90, 0.2);
  border-radius: 10px;
  background: rgba(22, 131, 90, 0.06);
}

.quotation-fitment-proof small {
  color: var(--soft);
  font-weight: 800;
}

.quotation-product-modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 15px;
}

.quotation-fitment-admin {
  margin-top: 16px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.025);
}

.quotation-fitment-admin > summary {
  padding: 13px 15px;
  color: var(--ink);
  font-weight: 900;
  cursor: pointer;
}

.quotation-fitment-admin-body {
  display: grid;
  gap: 12px;
  padding: 0 15px 15px;
}

.quotation-fitment-admin textarea {
  width: 100%;
  min-height: 110px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.vehicle-fitment-review-table td > small {
  display: block;
  max-width: 220px;
  color: var(--soft);
  overflow-wrap: anywhere;
}

.quotation-result-card h4 {
  margin: 3px 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.quotation-result-card p,
.quotation-result-card small {
  display: block;
  margin: 0;
  color: var(--soft);
  font-weight: 800;
}

.quotation-price-box {
  display: grid;
  justify-items: end;
  gap: 3px;
  font-variant-numeric: tabular-nums;
}

.quotation-price-box span {
  color: var(--soft);
  font-size: 12px;
  font-weight: 900;
}

.quotation-price-box strong {
  color: var(--green);
  font-family: Outfit, Inter, sans-serif;
  font-size: 17px;
}

.quotation-price-box em {
  color: var(--ink);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
}

.quotation-bcv-label {
  display: inline-block;
  color: var(--green);
  font-weight: 900;
}

.quotation-add-btn {
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0 !important;
  border-radius: 999px !important;
  font-size: 24px;
  line-height: 1;
}

.quotation-basket-panel {
  position: sticky;
  top: 88px;
}

.quotation-basket-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.quotation-basket-item {
  display: grid;
  grid-template-columns: minmax(68px, 0.7fr) minmax(86px, 0.9fr) minmax(82px, auto);
  gap: 9px;
  align-items: end;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.14);
  border-radius: 8px;
  background: rgba(22, 131, 90, 0.055);
}

.quotation-edit-fields {
  display: grid;
  grid-column: 1 / -1;
  gap: 8px;
  min-width: 0;
}

.quotation-edit-fields label {
  margin: 0;
  gap: 5px;
  color: var(--soft);
  font-size: 12px;
  font-weight: 900;
}

.quotation-edit-fields input {
  min-height: 38px;
  font-size: 13px;
  font-weight: 800;
}

.quotation-edit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.quotation-basket-item strong,
.quotation-basket-item span,
.quotation-basket-item small {
  display: block;
  overflow-wrap: anywhere;
}

.quotation-basket-item span,
.quotation-basket-item small {
  color: var(--soft);
  font-weight: 800;
}

.quotation-basket-item label {
  gap: 5px;
  margin: 0;
  color: var(--soft);
  font-size: 12px;
  font-weight: 900;
}

.quotation-basket-item input {
  min-height: 40px;
  text-align: center;
  width: 100%;
}

.quotation-basket-item > .btn {
  width: 100%;
  justify-content: center;
  align-self: end;
  min-height: 40px;
  padding-inline: 10px;
}

.quotation-total-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(22, 131, 90, 0.08), rgba(31, 102, 209, 0.06));
}

.quotation-total-card span {
  color: var(--soft);
  font-weight: 900;
}

.quotation-total-card strong {
  color: var(--green);
  font-family: Outfit, Inter, sans-serif;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.quotation-copy-button {
  width: 100%;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  min-height: 52px;
}

.sale-order-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.sale-order-admin-panel {
  grid-column: 1 / -1;
}

.sale-order-product-box {
  display: grid;
  gap: 12px;
  margin: 14px 0;
  padding: 14px;
  border: 1px solid rgba(22, 131, 90, 0.16);
  border-radius: 8px;
  background: rgba(22, 131, 90, 0.045);
}

.sale-order-results {
  max-height: 420px;
}

.sale-order-add-grid {
  grid-template-columns: minmax(140px, 1fr) minmax(92px, 0.5fr) minmax(110px, 0.55fr) auto;
  align-items: end;
}

.sale-order-basket-panel {
  position: sticky;
  top: 88px;
}

.sale-order-item-list,
.sale-order-admin-list {
  display: grid;
  gap: 10px;
}

.sale-order-item,
.sale-order-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.sale-order-item span,
.sale-order-card p,
.sale-order-card small {
  display: block;
  color: var(--soft);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.sale-order-submit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.sale-order-submit-row strong {
  display: block;
  color: var(--green);
  font-family: Outfit, Inter, sans-serif;
  font-size: 24px;
}

.success-note {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 8px;
  color: var(--green);
  background: rgba(22, 131, 90, 0.08);
  font-weight: 900;
}

.danger-outline {
  color: #b42318 !important;
  border-color: rgba(180, 35, 24, 0.35) !important;
}

.whatsapp-badge {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #ffffff;
  background: #22c55e;
  font-family: Outfit, Inter, sans-serif;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(34, 197, 94, 0.24);
}

.split-layout,
.scanner-grid {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.split-layout > *,
.scanner-grid > * {
  min-width: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.private-list-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.private-list-pagination > div {
  display: flex;
  gap: 8px;
}

@media (max-width: 640px) {
  .private-list-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .private-list-pagination > div,
  .private-list-pagination .btn {
    flex: 1;
  }
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

td span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

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

.product-photo {
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: var(--field);
}

.product-photo.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 18px;
  color: var(--muted);
  background: var(--field);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 6px;
  color: #fff;
  background: var(--green);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast[data-type="error"] {
  background: var(--red);
}

.scan-panel {
  position: relative;
  overflow: hidden;
  min-height: 420px;
  display: grid;
  align-content: end;
  background: #111827;
}

.scan-panel video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.quagga-viewport {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

.scan-panel.quagga-mode > video {
  display: none;
}

.scan-panel.quagga-mode .quagga-viewport {
  display: block;
}

.quagga-viewport video,
.quagga-viewport canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
}

.scan-line {
  position: absolute;
  left: 12%;
  right: 12%;
  top: 50%;
  height: 2px;
  background: var(--red);
  box-shadow: 0 0 22px rgba(199, 51, 47, 0.5);
}

.scanner-status,
.scanner-actions {
  position: relative;
  z-index: 2;
}

.scanner-status {
  margin: 0 0 12px;
  padding: 9px 10px;
  border-radius: 6px;
  color: #fff;
  background: rgba(0, 0, 0, 0.52);
  font-weight: 900;
}

.scanner-actions {
  display: flex;
  gap: 10px;
}

.scan-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}

.scan-card .product-photo {
  width: 74px;
  height: 74px;
}

.scan-card span {
  color: var(--blue);
  font-weight: 900;
}

.scan-card p {
  margin: 4px 0 8px;
  color: var(--muted);
}

.count-box {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(47, 125, 255, 0.32);
  border-radius: 6px;
  background: rgba(26, 86, 232, 0.1);
}

.scan-stock-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.scan-stock-actions > .btn {
  width: 100%;
}

.product-meta-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.2);
  border-radius: 8px;
  background: #f6fbf8;
}

.product-meta-box label {
  margin: 0;
}

.photo-capture-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 8px;
  background: #f4fbf7;
  color: var(--soft);
  font-weight: 900;
}

.photo-review-inline {
  display: grid;
  grid-template-columns: 96px auto;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed rgba(22, 131, 90, 0.35);
  border-radius: 8px;
  background: #fff;
}

.photo-review-inline.hidden {
  display: none;
}

.photo-review-inline img {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.product-photo-review-frame {
  display: grid;
  place-items: center;
  min-height: 280px;
  padding: 16px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 12px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.03);
}

.product-photo-review-frame img {
  display: block;
  width: min(100%, 360px);
  max-height: 46vh;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 35px rgba(15, 23, 42, 0.16);
}

@keyframes motionFadeUp {
  from {
    opacity: 0;
    transform: translate3d(0, 12px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes motionPanelIn {
  from {
    opacity: 0;
    transform: translate3d(0, 18px, 0) scale(.985);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes motionViewIn {
  from {
    opacity: 0;
    transform: translate3d(0, 10px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes motionTopScan {
  from { background-position: 0% 50%; }
  to { background-position: 260% 50%; }
}

@media (max-width: 860px) {
  body {
    overflow-x: hidden;
  }

  .login-panel {
    padding: 20px;
  }

  .module-switch {
    grid-template-columns: 1fr;
  }

  .workspace {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .sidebar {
    position: static;
    top: 0;
    z-index: 18;
    height: auto;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-item {
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    margin-bottom: 0;
  }

  .content {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    padding: 16px 12px calc(26px + env(safe-area-inset-bottom));
  }

  .metrics-grid,
  .module-grid,
  .split-layout,
  .scanner-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .sale-routing-controls {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .section-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .section-actions input,
  .section-actions select,
  .section-actions .btn {
    width: 100%;
    max-width: none;
    min-width: 0;
  }

  .search-head input {
    width: 100%;
    max-width: none;
  }

  .panel {
    padding: 14px;
    overflow: hidden;
  }

  .stacked-form,
  .form-grid,
  label,
  input,
  select,
  textarea,
  .btn {
    max-width: 100%;
  }

  .stacked-form > .btn,
  .count-box > .btn {
    width: 100%;
  }

  .scan-stock-actions {
    grid-template-columns: 1fr;
  }

  .scan-stock-actions > .btn {
    width: 100%;
  }

  .product-meta-box {
    grid-template-columns: 1fr;
  }

  .product-meta-box .btn {
    width: 100%;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    padding: 12px 14px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-actions .btn {
    min-height: 38px;
    padding: 8px 11px;
  }

  .brand-logo.compact {
    width: 104px;
    max-height: 40px;
  }

  .view-title h2 {
    font-size: 30px;
    line-height: 1.05;
  }

  .table-wrap {
    overflow-x: visible;
  }

  table,
  tbody {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 10px;
  }

  tr {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 7px 10px;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(19, 32, 57, 0.72);
  }

  td {
    min-width: 0;
    border: 0;
    padding: 0;
    overflow-wrap: anywhere;
  }

  td:first-child {
    grid-row: span 5;
  }

  td:nth-child(2) strong {
    font-size: 16px;
  }

  td:nth-child(3)::before {
    content: "Marca: ";
    color: var(--muted);
    font-weight: 900;
  }

  td:nth-child(4)::before {
    content: "Stock: ";
    color: var(--muted);
    font-weight: 900;
  }

  td:nth-child(5)::before {
    content: "Precio: ";
    color: var(--muted);
    font-weight: 900;
  }

  td:nth-child(n + 3) {
    grid-column: 2;
    color: var(--soft);
    font-size: 13px;
    text-align: left;
  }

  td:last-child {
    grid-column: 1 / -1;
    padding-top: 8px;
  }

  td:last-child .btn {
    width: 100%;
  }

  .scan-panel {
    min-height: min(64vh, 460px);
  }

  .scanner-actions {
    flex-wrap: wrap;
  }

  .brand-lockup small,
  #sessionLabel {
    display: none;
  }
}

body {
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(22, 131, 90, 0.08) 0 1px, transparent 1px 28px),
    linear-gradient(45deg, rgba(31, 102, 209, 0.055) 0 1px, transparent 1px 34px),
    linear-gradient(180deg, #ffffff 0%, var(--paper) 48%, #eef4f8 100%);
  font-family: "Segoe UI", Roboto, Arial, sans-serif;
}

body::before {
  background:
    radial-gradient(circle at 12% 8%, rgba(22, 131, 90, 0.14), transparent 28%),
    radial-gradient(circle at 88% 16%, rgba(31, 102, 209, 0.10), transparent 32%),
    linear-gradient(rgba(23, 32, 51, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 51, 0.025) 1px, transparent 1px);
  background-size: auto, auto, 54px 54px, 54px 54px;
}

body::after {
  background: linear-gradient(90deg, var(--green), var(--blue-2), #f2b84b, var(--red));
  background-size: 260% 100%;
  box-shadow: 0 0 18px rgba(22, 131, 90, 0.22);
}

.app-shell {
  padding-top: env(safe-area-inset-top);
}

.login-panel,
.panel,
.metric,
.module-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.98)),
    var(--surface);
  border-color: var(--line);
  box-shadow: var(--shadow);
}

.login-panel {
  border-top-color: var(--green);
}

.topbar {
  background: rgba(255, 255, 255, 0.94);
  border-bottom-color: var(--line);
  box-shadow: 0 10px 30px rgba(19, 32, 53, 0.08);
}

.sidebar {
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(14px);
}

.module-tab,
.btn.ghost {
  color: var(--ink);
  background: #ffffff;
}

.module-tab.active,
.module-tab:hover,
.nav-item:hover,
.nav-item.active {
  border-color: rgba(22, 131, 90, 0.28);
  color: var(--ink);
  background: rgba(22, 131, 90, 0.10);
}

.btn {
  color: var(--ink);
  background: #eef2f6;
  transition:
    transform var(--motion-mid) var(--motion-ease),
    box-shadow var(--motion-mid) var(--motion-ease),
    border-color var(--motion-mid) var(--motion-ease),
    background var(--motion-mid) var(--motion-ease),
    opacity var(--motion-mid) var(--motion-ease);
}

.btn.primary {
  border-color: var(--green);
  color: #ffffff;
  background: var(--green);
}

input,
select,
textarea {
  color: var(--ink);
  background: var(--field);
  border-left-color: rgba(22, 131, 90, 0.62);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 131, 90, 0.13);
}

.nav-item,
.module-card,
.metric,
.panel,
.smart-result {
  transition:
    transform var(--motion-mid) var(--motion-ease),
    box-shadow var(--motion-mid) var(--motion-ease),
    border-color var(--motion-mid) var(--motion-ease),
    background var(--motion-mid) var(--motion-ease),
    opacity var(--motion-mid) var(--motion-ease);
}

.view.active > * {
  animation: motionFadeUp 520ms var(--motion-ease) both;
}

.view.active > *:nth-child(2) {
  animation-delay: 45ms;
}

.view.active > *:nth-child(3) {
  animation-delay: 90ms;
}

.module-card:hover,
.metric:hover,
.panel:hover,
.smart-result:hover {
  border-color: rgba(22, 131, 90, 0.28);
  transform: translate3d(0, -2px, 0);
}

.module-card strong,
.metric strong,
.scan-card span {
  color: var(--green);
}

.brand-logo {
  background: #111827;
  box-shadow: 0 12px 28px rgba(19, 32, 53, 0.16);
}

.product-photo,
.empty-state,
.scan-card,
.count-box,
.sale-product-box,
.totals-box {
  background: #f8fbff;
}

.scan-panel {
  color: #ffffff;
  background: #111827;
}

.scanner-status {
  color: #ffffff;
  background: rgba(17, 24, 39, 0.72);
  backdrop-filter: blur(10px);
}

.scan-confirm {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #ffffff;
  background: rgba(22, 131, 90, 0.92);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(0, -10px, 0) scale(0.96);
  transition:
    opacity 220ms var(--motion-ease),
    transform 220ms var(--motion-ease);
}

.scan-confirm.show {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.scan-confirm small {
  margin-left: auto;
  overflow: hidden;
  max-width: 46%;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 900;
}

.check-icon {
  position: relative;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #ffffff;
}

.check-icon::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  width: 9px;
  height: 14px;
  border-right: 3px solid var(--green);
  border-bottom: 3px solid var(--green);
  transform: rotate(42deg);
}

.sales-layout {
  display: grid;
  grid-template-columns: minmax(320px, 520px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.sale-product-box {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.16);
  border-radius: 8px;
}

.compact-grid {
  grid-template-columns: 1.2fr 0.7fr 0.9fr auto;
  align-items: end;
}

.smart-results {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.smart-result {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  color: var(--ink);
  background: #ffffff;
  text-align: left;
  transition: transform 160ms var(--motion-ease), border-color 160ms var(--motion-ease), box-shadow 160ms var(--motion-ease);
}

.smart-result:hover {
  transform: translateY(-1px);
  border-color: rgba(22, 131, 90, 0.32);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.smart-result .product-photo {
  width: 44px;
  height: 44px;
}

.smart-result span,
.smart-result em {
  min-width: 0;
  color: var(--muted);
  font-style: normal;
  line-height: 1.25;
  overflow-wrap: break-word;
  word-break: normal;
}

.smart-result em {
  grid-column: 2;
  display: block;
  margin-top: -4px;
}

.smart-result strong {
  display: block;
  color: var(--ink);
}

.totals-box {
  display: grid;
  gap: 7px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.totals-box span {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--soft);
}

.totals-box .grand-total {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
}

.bulk-actions {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.bulk-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 8px;
  background: #f4fbf7;
}

.bulk-summary span,
.row-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bulk-table-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.bulk-table {
  min-width: 820px;
}

.bulk-table input,
.bulk-table select {
  min-height: 38px;
  padding: 8px 10px;
}

.bulk-table td {
  vertical-align: top;
}

.bulk-table td[data-label="Producto"] {
  min-width: 220px;
}

.bulk-table td[data-label="Coincidencia"] {
  min-width: 240px;
}

.bulk-table td[data-label="Accion"] {
  width: 88px;
}

.row-error {
  background: rgba(200, 51, 46, 0.08);
}

.compact-state {
  padding: 12px;
}

.bulk-footer {
  display: flex;
  justify-content: flex-end;
}

.print-label {
  grid-template-rows: auto minmax(0, 1fr) auto 8.8mm;
  gap: 0.8mm;
  padding: 3mm 3.2mm 2.8mm;
}

.label-barcode {
  height: 8.8mm;
}

.label-desc {
  font-size: 11.8px;
}

.label-code {
  font-size: 10.8px;
}

.focus-flash {
  animation: focusFlash 900ms var(--motion-ease) both;
}

#printRoot {
  display: none;
}

@keyframes focusFlash {
  0% {
    box-shadow: 0 0 0 0 rgba(22, 131, 90, 0), var(--shadow);
  }
  35% {
    box-shadow: 0 0 0 5px rgba(22, 131, 90, 0.18), var(--shadow);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(22, 131, 90, 0), var(--shadow);
  }
}

@media (max-width: 860px) {
  .app-shell {
    padding-top: 0;
  }

  .topbar {
    position: sticky;
    top: 0;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: rgba(255, 255, 255, 0.96);
  }

  .sidebar {
    background: #ffffff;
  }

  .sales-layout,
  .compact-grid {
    grid-template-columns: 1fr;
  }

  .payment-split {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
  }

  .payment-note {
    min-height: 0;
  }

  .table-actions {
    justify-content: stretch;
  }

  .table-actions .btn {
    flex: 1 1 120px;
  }

  tr {
    background: #ffffff;
  }

  td:nth-child(3)::before,
  td:nth-child(4)::before,
  td:nth-child(5)::before,
  td:nth-child(6)::before {
    content: none;
  }

  td[data-label]::before {
    content: attr(data-label) ": ";
    color: var(--muted);
    font-weight: 900;
  }

  td[data-label="Foto"]::before,
  td[data-label="Accion"]::before {
    content: "";
  }

  td:nth-child(n + 3) {
    color: var(--soft);
  }

  .smart-result {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .smart-result em {
    grid-column: 2;
  }

  .scan-confirm {
    left: 12px;
    right: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

@media print {
  @page {
    size: 80mm auto;
    margin: 4mm;
  }

  html,
  body {
    width: 80mm;
    min-height: 0;
    color: #111827;
    background: #ffffff !important;
  }

  body::before,
  body::after,
  #loginScreen,
  #appShell {
    display: none !important;
  }

  #printRoot {
    display: block !important;
  }

  .print-ticket {
    width: 72mm;
    color: #111827;
    background: #ffffff;
    font-family: Arial, "Helvetica Neue", sans-serif;
    font-size: 11px;
    line-height: 1.22;
  }

  .ticket-heading {
    display: grid;
    gap: 3px;
    margin-bottom: 12px;
    text-align: right;
  }

  .ticket-heading strong {
    font-size: 15px;
  }

  .ticket-client {
    display: grid;
    gap: 2px;
    margin-bottom: 8px;
  }

  .ticket-row,
  .ticket-item,
  .ticket-totals span {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 22mm;
    gap: 6px;
    align-items: start;
  }

  .ticket-head {
    padding: 3px 0;
    border-top: 1px solid #111827;
    border-bottom: 1px solid #111827;
    text-decoration: underline;
  }

  .ticket-lines {
    display: grid;
    gap: 5px;
    padding: 6px 0 8px;
    border-bottom: 1px solid #111827;
  }

  .ticket-item span,
  .ticket-item small {
    display: block;
  }

  .ticket-item > strong,
  .ticket-totals strong {
    text-align: right;
  }

  .ticket-totals {
    display: grid;
    gap: 3px;
    padding-top: 6px;
    font-weight: 700;
  }

  .ticket-grand {
    font-size: 16px;
    font-weight: 900;
  }

  .ticket-notice {
    margin-top: 7px;
    padding-top: 5px;
    border-top: 1px solid #111827;
    color: #111827;
    font-size: 8px;
    line-height: 1.18;
    font-weight: 700;
    text-align: center;
  }
}

/* Sales step-by-step wizard and confirmation modal */
.sale-steps-indicator {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  background: var(--surface);
  padding: 14px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.step-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity var(--motion-fast) var(--motion-ease), transform var(--motion-fast) var(--motion-ease);
}
.step-indicator.active {
  opacity: 1;
  transform: translateY(-1px);
}
.step-indicator.completed {
  opacity: 0.85;
}
.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  transition: all var(--motion-fast) var(--motion-ease);
}
.step-indicator.active .step-number {
  background: var(--green);
  color: #ffffff;
}
.step-indicator.completed .step-number {
  background: var(--surface-2);
  color: var(--green);
  border: 2px solid var(--green);
  font-size: 0;
}
.step-indicator.completed .step-number::after {
  content: "✓";
  font-size: 15px;
  line-height: 1;
}
.step-label {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  transition: color var(--motion-fast) var(--motion-ease);
}
.step-indicator.active .step-label {
  color: var(--green);
}
.step-indicator.completed .step-label {
  color: var(--ink);
}
.step-connector {
  flex: 1;
  height: 2px;
  background: var(--line);
  margin: 0 16px;
  transition: background var(--motion-mid) var(--motion-ease);
}
.step-indicator.completed + .step-connector {
  background: var(--green);
}

.step-content {
  display: none;
}
.step-content.active {
  display: block;
  animation: stepFadeIn 300ms cubic-bezier(0.16, 1, 0.3, 1) both;
  will-change: opacity, transform;
}

@keyframes stepFadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.sale-recovery-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid rgba(22, 131, 90, 0.22);
  border-radius: var(--radius);
  background: rgba(236, 253, 245, 0.9);
  box-shadow: 0 12px 28px rgba(16, 185, 129, 0.12);
}

.sale-recovery-banner strong {
  display: block;
  color: var(--green);
  font-weight: 900;
}

.sale-recovery-banner span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 700;
}

.sale-recovery-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}
.step-actions .btn {
  margin: 0;
}

/* Shake animation for validation feedback */
.shake-animation {
  animation: shakeEffect 0.4s var(--motion-ease) both;
}
.validation-danger {
  border-color: rgba(239, 68, 68, 0.8) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}
@keyframes shakeEffect {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* Confirmation Modal */
.confirm-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(11, 17, 32, 0.45);
  backdrop-filter: blur(8px);
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--motion-mid) var(--motion-ease);
}
.confirm-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.confirm-modal-card {
  width: min(720px, 100%);
  max-height: min(90vh, 800px);
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid var(--line);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--motion-mid) var(--motion-ease);
}
.confirm-modal-overlay.active .confirm-modal-card {
  transform: scale(1) translateY(0);
}
.confirm-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.confirm-modal-header h3 {
  margin: 0;
  color: var(--green);
  font-size: 18px;
  font-weight: 900;
}
.confirm-modal-close {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  margin: 0;
  transition: color var(--motion-fast) var(--motion-ease);
}
.confirm-modal-close:hover {
  color: var(--red);
}
.confirm-modal-body {
  padding: 24px;
  overflow-y: auto;
  display: grid;
  gap: 20px;
  -webkit-overflow-scrolling: touch;
}
.confirm-section {
  display: grid;
  gap: 10px;
}
.confirm-section-title {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.8px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}
.confirm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.confirm-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.confirm-field label {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  margin: 0;
}
.confirm-field span {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.confirm-item-desc {
  display: block;
  font-size: 12px;
  color: var(--muted);
  font-weight: normal;
  margin-top: 2px;
}
.compact-confirm-table {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.compact-confirm-table table {
  margin: 0;
  width: 100%;
}
.compact-confirm-table th,
.compact-confirm-table td {
  padding: 8px 12px;
}
.confirm-totals-summary {
  display: grid;
  justify-content: end;
  gap: 6px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
}
.confirm-totals-row {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  font-size: 13px;
  color: var(--soft);
}
.confirm-totals-row.grand-total-row {
  font-size: 16px;
  color: var(--green);
  font-weight: 900;
}
.confirm-payment-split-details {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px 14px;
  border: 1px solid var(--line);
}
.confirm-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
}
.confirm-modal-footer .btn {
  margin: 0;
  min-width: 130px;
}

.receiving-confirm-modal,
.supplier-debt-edit-modal {
  width: min(760px, 100%);
}

.receiving-document-summary,
.supplier-debt-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.receiving-document-summary > div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.receiving-document-summary span,
.confirm-total-row span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.receiving-document-summary strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.confirm-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(22, 131, 90, 0.24);
  border-radius: var(--radius);
  background: rgba(22, 131, 90, 0.08);
}

.confirm-total-row strong {
  color: var(--green);
  font-size: 20px;
}

.receiving-confirm-warning {
  padding: 12px 14px;
  border: 1px solid rgba(242, 153, 74, 0.38);
  border-radius: var(--radius);
  background: rgba(242, 153, 74, 0.1);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.confirm-delay-btn {
  opacity: 0.82;
  cursor: wait;
}

.mini-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  border-radius: 999px;
  vertical-align: -2px;
  animation: spin 0.8s linear infinite;
}

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

@media (max-width: 860px) {
  .sale-recovery-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .sale-recovery-actions,
  .sale-recovery-actions .btn {
    width: 100%;
  }

  .sale-steps-indicator {
    padding: 10px 12px;
  }
  .step-label {
    display: none;
  }
  .step-connector {
    margin: 0 8px;
  }
  .confirm-modal-card {
    max-height: 95vh;
  }
  .confirm-modal-body {
    padding: 16px;
  }
  .receiving-document-summary,
  .supplier-debt-edit-grid {
    grid-template-columns: 1fr;
  }
  .confirm-total-row {
    align-items: flex-start;
    flex-direction: column;
  }
  .confirm-modal-footer {
    padding: 12px 16px;
  }
}

/* Ventas: guardrail final para PC Windows, zoom alto y pantallas medianas. */
.sales-layout {
  grid-template-columns: minmax(520px, 0.92fr) minmax(520px, 1.08fr);
}

.sales-layout > * {
  min-width: 0;
}

.sale-history-head {
  align-items: start;
}

.sale-history-filters {
  display: grid;
  grid-template-columns: minmax(130px, 0.75fr) minmax(130px, 0.75fr) minmax(240px, 1.5fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.sale-history-filters > *,
.sale-history-filters input,
.sale-history-filters .btn {
  min-width: 0;
  width: 100%;
}

.sale-history-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.sale-history-summary span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(31, 102, 209, 0.06);
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.sale-history-daily {
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(22, 131, 90, 0.08), rgba(31, 102, 209, 0.04));
}

.sale-history-daily > strong {
  color: var(--text);
  font-family: "Outfit", "Inter", system-ui, sans-serif;
  font-size: 14px;
}

.sale-history-daily > div {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.sale-history-daily span {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(22, 131, 90, 0.16);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.sale-history-daily b {
  color: var(--soft);
  font-size: 12px;
  text-transform: uppercase;
}

.sale-history-daily em {
  color: var(--green);
  font-family: "Outfit", "Inter", system-ui, sans-serif;
  font-size: 20px;
  font-style: normal;
  font-weight: 900;
}

.sale-history-daily small {
  color: var(--muted);
  font-weight: 800;
}

.warning-text {
  color: #9a5b00 !important;
  background: rgba(245, 158, 11, 0.12) !important;
  border-color: rgba(245, 158, 11, 0.28) !important;
}

.sales-history-table {
  min-width: 960px;
}

.sales-history-table td {
  vertical-align: top;
}

.sales-history-table td[data-label="Cliente"] {
  min-width: 230px;
}

.sales-history-table td[data-label="Accion"] {
  min-width: 190px;
}

.sales-history-table .table-actions {
  justify-content: flex-start;
}

.sales-history-list {
  display: grid;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.sales-history-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}

.sales-history-main {
  display: grid;
  grid-template-columns: 52px minmax(220px, 1.35fr) minmax(210px, 1fr) minmax(120px, auto);
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.sales-history-number small,
.sales-history-meta b {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.sales-history-number strong {
  color: var(--ink);
  font-size: 18px;
  font-family: Outfit, Inter, sans-serif;
}

.sales-history-client,
.sales-history-meta,
.sales-history-state {
  min-width: 0;
}

.sales-history-client > strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-weight: 900;
  overflow-wrap: anywhere;
}

.sales-history-meta {
  display: grid;
  gap: 7px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 800;
}

.sales-history-meta span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sales-history-state {
  display: grid;
  justify-items: start;
  align-content: start;
  gap: 8px;
}

.sales-history-actions {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 170px;
}

.sales-history-actions .btn {
  width: 100%;
  min-height: 38px;
  justify-content: center;
  white-space: normal;
}

.sales-history-actions .primary-action {
  order: -1;
  box-shadow: 0 10px 24px rgba(22, 131, 90, 0.18);
}

@media (max-width: 1500px) {
  .sales-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1180px) {
  .sale-history-filters,
  .compact-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .sale-history-search,
  .sale-history-filters .btn {
    grid-column: 1 / -1;
  }

  .sales-history-card,
  .sales-history-main {
    grid-template-columns: minmax(0, 1fr);
  }

  .sales-history-actions {
    display: flex;
    flex-wrap: wrap;
    min-width: 0;
  }

  .sales-history-actions .btn {
    width: auto;
    flex: 1 1 150px;
  }
}

@media (max-width: 860px) {
  .sale-history-filters,
  .compact-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .sales-history-table {
    min-width: 0;
  }

  .sales-history-card {
    padding: 10px;
  }

  .sales-history-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .sales-history-actions .btn {
    width: 100%;
    flex-basis: auto;
  }
}

/* Final visual authority for inventory premium mode. */
body {
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif !important;
  color: var(--ink) !important;
  background:
    linear-gradient(135deg, rgba(22, 131, 90, 0.075) 0 1px, transparent 1px 30px),
    linear-gradient(45deg, rgba(31, 102, 209, 0.055) 0 1px, transparent 1px 36px),
    linear-gradient(180deg, #ffffff 0%, #f7fafc 50%, #edf4f8 100%) !important;
}

h1,
h2,
h3,
.metric strong,
.module-card strong,
.brand-lockup small {
  font-family: Outfit, Inter, sans-serif !important;
}

.topbar,
.sidebar,
.panel,
.metric,
.login-panel,
.quick-search-card,
.confirm-modal {
  background: rgba(255, 255, 255, 0.76) !important;
  border-color: rgba(255, 255, 255, 0.44) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
}

/* BASE visual polish: compact mobile chrome + wider sales workspace */
@media (min-width: 1181px) and (max-width: 1500px) {
  .sales-layout {
    grid-template-columns: minmax(500px, 0.95fr) minmax(500px, 1.05fr) !important;
  }
}

@media (max-width: 860px) {
  .topbar {
    position: sticky !important;
    top: 0 !important;
    z-index: 40 !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px !important;
    min-height: 0 !important;
    padding: calc(7px + env(safe-area-inset-top)) 10px 8px !important;
    border-radius: 0 !important;
    background: rgba(255, 255, 255, 0.96) !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08) !important;
  }

  .topbar .brand-lockup {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    min-height: 34px !important;
  }

  .topbar .brand-logo.compact {
    width: 92px !important;
    max-height: 34px !important;
    object-fit: contain !important;
  }

  .topbar .brand-lockup small {
    font-size: 12px !important;
  }

  .topbar-actions {
    display: flex !important;
    grid-template-columns: none !important;
    gap: 7px !important;
    align-items: center !important;
    justify-content: flex-start !important;
    overflow-x: auto !important;
    padding-bottom: 2px !important;
    scrollbar-width: none !important;
  }

  .topbar-actions::-webkit-scrollbar,
  .sidebar::-webkit-scrollbar,
  .cash-tabs::-webkit-scrollbar {
    display: none !important;
  }

  .topbar-actions > *,
  .topbar-actions .btn {
    flex: 0 0 auto !important;
    width: auto !important;
    min-height: 36px !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
  }

  #sessionLabel {
    display: none !important;
  }

  .sidebar {
    position: sticky !important;
    top: 84px !important;
    z-index: 30 !important;
    padding: 8px 10px !important;
    gap: 7px !important;
    scroll-snap-type: x proximity !important;
    background: rgba(255, 255, 255, 0.96) !important;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06) !important;
  }

  .nav-item,
  .cash-tab {
    scroll-snap-align: center !important;
    min-height: 38px !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
  }

  .content {
    padding-top: 12px !important;
  }

  .view-title {
    margin-bottom: 12px !important;
  }

  .view-title h2 {
    font-size: 28px !important;
  }
}

/* Premium interaction layer: native dark mode, touch feedback, scanner guide and skeleton loaders. */
.card,
.product-card,
.metric,
.module-card,
.panel {
  transition:
    transform var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-fast) var(--motion-ease),
    border-color var(--motion-fast) var(--motion-ease),
    background-color var(--motion-fast) var(--motion-ease);
}

.card:hover,
.product-card:hover,
.metric:hover,
.module-card:hover {
  transform: translate3d(0, -5px, 18px) rotateX(1deg);
  box-shadow: var(--shadow-elevated);
}

.btn,
button,
input,
select,
textarea {
  transition:
    transform var(--motion-fast) var(--motion-ease),
    border-color var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-fast) var(--motion-ease),
    background-color var(--motion-fast) var(--motion-ease);
}

.btn:active,
button:active {
  transform: scale(0.96);
}

input:active,
select:active,
textarea:active {
  transform: scale(0.99);
}

input,
select,
textarea {
  background: var(--field);
  color: var(--ink);
  border-color: var(--line);
}

input:focus,
select:focus,
textarea:focus {
  background: var(--surface);
  border-color: var(--green);
  box-shadow: 0 0 0 4px hsl(var(--h-green) / 0.16);
}

@media (max-width: 900px), (pointer: coarse) {
  .topbar,
  .sidebar,
  .panel,
  .metric,
  .login-panel,
  .quick-search-card,
  .confirm-modal {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  .card:hover,
  .product-card:hover,
  .metric:hover,
  .module-card:hover,
  .panel:hover {
    transform: none !important;
  }

  .btn,
  button,
  input,
  select,
  textarea,
  .panel,
  .metric,
  .nav-item,
  .product-subtab,
  .quotation-result-card,
  .quotation-basket-item {
    transition-duration: 120ms !important;
  }
}

.scanner-target-box,
.scanner-overlay-laser {
  pointer-events: none;
}

.scanner-target-box {
  position: absolute;
  z-index: 3;
  left: 6%;
  right: 6%;
  top: 20%;
  bottom: 20%;
  border: 2px solid hsl(var(--h-green) / 0.88);
  border-radius: 18px;
  box-shadow:
    0 0 0 999px rgba(2, 6, 23, 0.34),
    inset 0 0 28px hsl(var(--h-green) / 0.14),
    0 18px 44px rgba(0, 0, 0, 0.22);
}

.scanner-target-box::before,
.scanner-target-box::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 34px;
  border-color: #fff;
  border-style: solid;
  filter: drop-shadow(0 0 8px hsl(var(--h-green) / 0.7));
}

.scanner-target-box::before {
  left: -2px;
  top: -2px;
  border-width: 4px 0 0 4px;
  border-radius: 16px 0 0 0;
}

.scanner-target-box::after {
  right: -2px;
  bottom: -2px;
  border-width: 0 4px 4px 0;
  border-radius: 0 0 16px 0;
}

.scanner-overlay-laser {
  position: absolute;
  z-index: 4;
  left: 10%;
  right: 10%;
  top: 50%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, #ff3030 18%, #fff 50%, #ff3030 82%, transparent);
  box-shadow:
    0 0 12px rgba(255, 48, 48, 0.92),
    0 0 28px rgba(255, 48, 48, 0.52);
  animation: scannerLaserSweep 1.45s ease-in-out infinite alternate;
}

.scanner-status,
.scanner-actions,
.scan-confirm {
  z-index: 5;
}

.scanner-actions {
  position: relative;
}

.scan-line {
  opacity: 0;
}

@keyframes scannerLaserSweep {
  from { transform: translate3d(0, -72px, 0); }
  to { transform: translate3d(0, 72px, 0); }
}

.skeleton-table,
.skeleton-list {
  display: grid;
  gap: 12px;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 72px minmax(120px, 1.5fr) minmax(90px, 1fr) minmax(80px, 0.8fr);
  gap: 14px;
  align-items: center;
  min-height: 58px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: hsl(var(--h-surface) / 0.72);
}

.skeleton-list .skeleton-row {
  grid-template-columns: 52px 1fr 120px;
}

.skeleton-bar {
  display: block;
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, hsl(var(--h-muted) / 0.12), hsl(var(--h-muted) / 0.24), hsl(var(--h-muted) / 0.12));
  background-size: 220% 100%;
  animation: shimmerEffect 1.2s linear infinite;
}

.skeleton-bar.thumb {
  width: 52px;
  height: 42px;
  border-radius: 10px;
}

.skeleton-bar.short { width: 58%; }
.skeleton-bar.tiny { width: 34%; }

.loading-products-state {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px dashed hsl(var(--h-green) / 0.34);
  border-radius: var(--radius);
  background: hsl(var(--h-green) / 0.06);
}

.loading-products-state > strong,
.loading-products-inline {
  color: var(--green);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
}

/* BASE restore: visual authority for the original light inventory palette. */
:root {
  color-scheme: light;
}

html {
  background: #f8fafc !important;
}

body {
  color: var(--ink) !important;
  background:
    linear-gradient(135deg, rgba(22, 131, 90, 0.08) 0 1px, transparent 1px 28px),
    linear-gradient(45deg, rgba(31, 102, 209, 0.055) 0 1px, transparent 1px 34px),
    linear-gradient(180deg, #ffffff 0%, var(--paper) 48%, #eef4f8 100%) !important;
}

body::before {
  background:
    radial-gradient(circle at 12% 8%, rgba(22, 131, 90, 0.14), transparent 28%),
    radial-gradient(circle at 88% 16%, rgba(31, 102, 209, 0.10), transparent 32%),
    linear-gradient(rgba(23, 32, 51, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 32, 51, 0.025) 1px, transparent 1px) !important;
  background-size: auto, auto, 54px 54px, 54px 54px !important;
}

body::after {
  background: linear-gradient(90deg, var(--green), var(--blue-2), #f2b84b, var(--red)) !important;
  box-shadow: 0 0 18px rgba(22, 131, 90, 0.22) !important;
}

.topbar {
  background: rgba(255, 255, 255, 0.94) !important;
  border-color: var(--line) !important;
  box-shadow: 0 10px 30px rgba(19, 32, 53, 0.08) !important;
}

.sidebar {
  background: rgba(255, 255, 255, 0.74) !important;
  border-color: var(--line) !important;
  box-shadow: none !important;
}

.login-panel,
.panel,
.metric,
.module-card,
.quick-search-card,
.confirm-modal,
.table-wrap,
.bulk-table-wrap,
.sale-product-box,
.totals-box {
  color: var(--ink) !important;
  border-color: var(--line) !important;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.98)),
    var(--surface) !important;
  box-shadow: var(--shadow) !important;
}

.login-panel {
  border-top-color: var(--green) !important;
}

.module-tab,
.btn.ghost,
.smart-result,
.quick-product,
.search-panel,
.empty-state,
.product-photo,
tr {
  color: var(--ink) !important;
  background: #ffffff !important;
  border-color: var(--line) !important;
}

.nav-item {
  color: var(--soft) !important;
  background: transparent !important;
}

.module-tab.active,
.module-tab:hover,
.nav-item:hover,
.nav-item.active {
  color: var(--ink) !important;
  border-color: rgba(22, 131, 90, 0.28) !important;
  background: rgba(22, 131, 90, 0.10) !important;
}

.btn {
  color: var(--ink) !important;
  background: #eef2f6 !important;
  border-color: var(--line) !important;
}

.btn.primary,
.btn.success {
  color: #ffffff !important;
  background: var(--green) !important;
  border-color: var(--green) !important;
}

.btn.primary::after,
.btn.success::after {
  display: none !important;
}

input,
select,
textarea {
  color: var(--ink) !important;
  background: var(--field) !important;
  border-color: var(--line) !important;
  border-left-color: rgba(22, 131, 90, 0.62) !important;
}

input:focus,
select:focus,
textarea:focus {
  background: #ffffff !important;
  border-color: var(--green) !important;
  box-shadow: 0 0 0 3px rgba(22, 131, 90, 0.13) !important;
}

.scan-panel {
  color: #ffffff !important;
  background: #111827 !important;
}

.scanner-status {
  color: #ffffff !important;
  background: rgba(17, 24, 39, 0.72) !important;
}

.supplier-ledger-layout {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.supplier-ledger-sidebar {
  display: grid;
  gap: 10px;
  position: sticky;
  top: 88px;
}

.supplier-search-panel {
  margin-bottom: 14px;
}

.supplier-search-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(22, 131, 90, 0.18);
  border-radius: 8px;
  background: rgba(240, 253, 244, 0.86);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.05);
}

.supplier-search-box label {
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--soft);
  text-transform: uppercase;
}

.supplier-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.supplier-search-row-wide {
  margin-top: 10px;
}

.supplier-search-row input {
  width: 100%;
  min-width: 0;
}

.supplier-search-box small {
  color: var(--soft);
  font-weight: 800;
}

.supplier-list-title {
  display: block;
  padding: 0 2px 2px;
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.supplier-suggestion-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding: 8px;
  border: 1px solid rgba(22, 131, 90, 0.16);
  border-radius: 8px;
  background: rgba(240, 253, 244, 0.72);
}

.supplier-suggestion-list.empty {
  color: var(--soft);
  font-weight: 800;
}

.supplier-suggestion {
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.supplier-suggestion:hover,
.supplier-suggestion.active {
  border-color: rgba(22, 131, 90, 0.42);
  box-shadow: 0 10px 22px rgba(22, 131, 90, 0.11);
  transform: translateY(-1px);
}

.supplier-suggestion small {
  color: var(--soft);
  font-weight: 800;
}

.supplier-ledger-button {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  padding: 14px;
  text-align: left;
  color: var(--ink);
  display: grid;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.supplier-ledger-button:hover,
.supplier-ledger-button.active {
  border-color: rgba(22, 131, 90, 0.42);
  box-shadow: 0 12px 30px rgba(22, 131, 90, 0.12);
  transform: translateY(-2px);
}

.supplier-ledger-button span,
.supplier-ledger-button small {
  color: var(--soft);
}

.supplier-ledger-main {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.supplier-account-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.supplier-account-metrics span {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(246, 248, 251, 0.9);
  color: var(--soft);
}

.supplier-account-metrics strong {
  display: block;
  color: var(--green);
  font-size: 18px;
}

.supplier-payment-form {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(4, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.supplier-payment-form .btn {
  min-height: 44px;
}

.supplier-debt-cards {
  display: grid;
  gap: 12px;
}

.supplier-debt-card {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(180px, 0.8fr) minmax(180px, 0.7fr);
  gap: 14px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.94);
}

.supplier-debt-card h4 {
  margin: 8px 0 4px;
  font-size: 18px;
}

.supplier-debt-card p {
  margin: 0 0 6px;
  color: var(--ink);
}

.supplier-debt-money {
  display: grid;
  gap: 6px;
}

.supplier-debt-money span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--soft);
}

.supplier-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: start;
}

.supplier-attachment-thumb {
  width: 76px;
  min-height: 82px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  padding: 5px;
  background: #fff;
  text-decoration: none;
  color: var(--ink);
  display: grid;
  gap: 4px;
  place-items: center;
}

.supplier-attachment-thumb img {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
}

.supplier-attachment-thumb span {
  display: grid;
  place-items: center;
  width: 64px;
  height: 48px;
  border-radius: 6px;
  background: rgba(22, 131, 90, 0.12);
  color: var(--green);
  font-weight: 900;
}

.supplier-attachment-thumb small {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.supplier-upload-button {
  position: relative;
  overflow: hidden;
  align-self: start;
}

.supplier-upload-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.supplier-register-layout {
  margin-top: 8px;
}

@media (max-width: 900px) {
  .sale-order-layout {
    grid-template-columns: 1fr;
  }

  .sale-order-basket-panel {
    position: static;
  }

  .sale-order-add-grid,
  .sale-order-item,
  .sale-order-card {
    grid-template-columns: 1fr;
  }

  .sale-order-submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .quotation-search-panel {
    display: grid;
    max-height: none;
    overflow: visible;
  }

  .quotation-layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .quotation-basket-panel {
    max-height: none;
    overflow: visible;
  }

  .quotation-results {
    max-height: none;
    min-height: 0;
    overflow: visible;
    touch-action: auto;
    padding-right: 3px;
  }

  .quotation-filter-row {
    grid-template-columns: 1fr;
  }

  .quotation-search-mode-switch,
  .quotation-vehicle-specs,
  .quotation-vehicle-filters,
  .quotation-product-detail-grid {
    grid-template-columns: 1fr;
  }

  .quotation-vehicle-models {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(138px, 44vw);
    grid-template-columns: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding: 2px 2px 9px;
  }

  .quotation-vehicle-card {
    scroll-snap-align: start;
  }

  #quotationVehicleSort,
  .quotation-view-switch {
    grid-column: auto;
  }

  .quotation-basket-panel {
    position: static;
  }

  .quotation-result-card {
    grid-template-columns: 54px minmax(0, 1fr) minmax(44px, auto);
  }

  .quotation-price-box {
    grid-column: 2 / -1;
    justify-items: start;
    grid-template-columns: repeat(3, auto);
    gap: 8px;
  }

  .quotation-card-actions {
    grid-row: 1 / span 2;
    grid-column: 3;
  }

  .vehicle-results.grid-view {
    grid-template-columns: 1fr;
  }

  .vehicle-results.grid-view .quotation-result-card {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .quotation-product-modal {
    max-height: 92dvh;
    padding: 15px;
  }

  .quotation-product-gallery {
    min-height: 180px;
  }

  .quotation-product-facts {
    grid-template-columns: 1fr 1fr;
  }

  .quotation-basket-item {
    grid-template-columns: 1fr;
  }

  .quotation-edit-row {
    grid-template-columns: 1fr;
  }

  .supplier-ledger-layout {
    grid-template-columns: 1fr;
  }

  .supplier-ledger-sidebar {
    position: static;
    grid-auto-flow: row;
    grid-auto-columns: initial;
    max-height: 430px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 4px;
  }

  .supplier-search-box {
    min-width: 0;
  }

  .supplier-payment-form,
  .supplier-debt-card,
  .supplier-account-metrics {
    grid-template-columns: 1fr;
  }
}

/* Reglas finales de impresion: etiquetas 60x30 sin papel extra. */
@media print {
  @page label {
    size: 60mm 30mm;
    margin: 0;
  }

  #printRoot[data-print-mode="label"],
  #printRoot[data-print-mode="label"] .label-print-sheet {
    display: block !important;
    width: 60mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  #printRoot[data-print-mode="label"] .print-label {
    page: label;
    width: 60mm !important;
    height: 30mm !important;
    margin: 0 !important;
    padding: 3mm 3.2mm 2.8mm !important;
    border: 0.35mm solid #111827 !important;
    box-shadow: none !important;
    overflow: hidden !important;
    break-after: page;
    page-break-after: always;
  }

  #printRoot[data-print-mode="label"] .print-label:last-child {
    break-after: auto;
    page-break-after: auto;
  }
}

/* Final sales history guard: actions must never overlap status or totals. */
.sales-history-card {
  grid-template-columns: minmax(0, 1fr) !important;
  align-items: start !important;
  overflow: visible !important;
}

.sales-history-main {
  width: 100% !important;
  min-width: 0 !important;
}

.sales-history-actions {
  position: relative !important;
  z-index: 1 !important;
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr)) !important;
  width: 100% !important;
  min-width: 0 !important;
  margin-top: 4px !important;
}

.sales-history-actions .btn {
  width: 100% !important;
  min-width: 0 !important;
}

.sales-history-state {
  min-width: 0 !important;
  padding-bottom: 2px !important;
}

/* Modulo ventas al mayor */
.wholesale-layout {
  align-items: start;
}

.wholesale-total-box {
  border-color: rgba(22, 131, 90, 0.24);
  background: linear-gradient(135deg, rgba(22, 131, 90, 0.08), rgba(31, 102, 209, 0.06));
}

.wholesale-history-panel {
  min-width: 0;
}

.wholesale-table td span,
.wholesale-table small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.wholesale-table .table-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.wholesale-users-panel .user-mini-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.wholesale-users-panel .user-mini-list article {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.wholesale-users-panel .user-mini-list span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 760px) {
  .valuation-form {
    grid-template-columns: 1fr;
  }

  .wholesale-table .table-actions {
    grid-template-columns: 1fr;
  }

  .wholesale-layout .panel {
    min-width: 0;
  }
}

/* Calculadora rapida BCV en barra superior */
.topbar-bcv-calculator {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(235, 249, 243, 0.96)) !important;
  border-color: rgba(22, 131, 90, 0.18) !important;
}

@media (max-width: 1100px) {
  .topbar-bcv-calculator {
    flex: 1 1 100%;
    max-width: none;
    width: 100%;
  }
}

@media (max-width: 620px) {
  .topbar-bcv-calculator {
    grid-template-columns: 1fr;
    min-width: 0;
    padding: 9px;
  }

  .topbar-bcv-calculator label,
  .topbar-bcv-calculator small {
    font-size: 10px;
  }

  .topbar-bcv-input,
  .topbar-bcv-calculator strong {
    grid-column: span 1;
  }

  .topbar-bcv-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .topbar-bcv-calculator strong {
    font-size: 16px;
    text-align: left;
  }
}

/* Campos numericos manuales: oculta las flechas de subir/bajar. */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

.purchase-orders-layout,
.purchase-orders-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  width: 100%;
}

.purchase-orders-layout > *,
.purchase-orders-stack > *,
.purchase-order-create-panel,
.purchase-order-active-panel {
  min-width: 0;
  width: 100%;
}

.purchase-orders-layout .section-head,
.purchase-orders-stack .section-head {
  gap: 12px;
}

.purchase-orders-layout .section-head .btn,
.purchase-orders-stack .section-head .btn {
  flex-shrink: 0;
}

.purchase-orders-layout .bulk-table-wrap,
.purchase-orders-stack .bulk-table-wrap {
  max-height: none;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.purchase-orders-layout .bulk-table,
.purchase-orders-stack .bulk-table {
  min-width: 720px;
  width: 100%;
  table-layout: fixed;
}

.purchase-orders-layout .bulk-table th:nth-child(1),
.purchase-orders-layout .bulk-table td:nth-child(1),
.purchase-orders-stack .bulk-table th:nth-child(1),
.purchase-orders-stack .bulk-table td:nth-child(1) {
  width: 68px;
}

.purchase-orders-layout .bulk-table th:nth-child(2),
.purchase-orders-layout .bulk-table td:nth-child(2),
.purchase-orders-stack .bulk-table th:nth-child(2),
.purchase-orders-stack .bulk-table td:nth-child(2) {
  width: 44%;
}

.purchase-orders-layout .bulk-table th:nth-child(3),
.purchase-orders-layout .bulk-table td:nth-child(3),
.purchase-orders-stack .bulk-table th:nth-child(3),
.purchase-orders-stack .bulk-table td:nth-child(3) {
  width: 130px;
}

.purchase-orders-layout .bulk-table th:nth-child(4),
.purchase-orders-layout .bulk-table td:nth-child(4),
.purchase-orders-stack .bulk-table th:nth-child(4),
.purchase-orders-stack .bulk-table td:nth-child(4) {
  width: 116px;
}

.purchase-orders-layout .bulk-table th:nth-child(7),
.purchase-orders-layout .bulk-table td:nth-child(7),
.purchase-orders-stack .bulk-table th:nth-child(5),
.purchase-orders-stack .bulk-table td:nth-child(5) {
  width: 220px;
}

.purchase-orders-layout .bulk-table td,
.purchase-orders-stack .bulk-table td {
  overflow-wrap: anywhere;
}

.purchase-orders-layout .bulk-table input,
.purchase-orders-stack .bulk-table input {
  width: 100%;
}

.purchase-result-count {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 8px;
  padding: 10px 12px;
  border: 1px solid rgba(22, 131, 90, 0.16);
  border-radius: 10px;
  background: rgba(22, 131, 90, 0.06);
  color: var(--ink);
}

.purchase-result-count strong {
  font-family: Outfit, Inter, sans-serif;
  font-size: 15px;
}

.purchase-result-count span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchase-load-more {
  display: block;
  min-width: min(100%, 320px);
  margin: 12px auto 0;
}

.purchase-page-status {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.purchase-weekly-panel {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(22, 131, 90, 0.24);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(22, 131, 90, 0.08), rgba(255, 255, 255, 0.88) 46%),
    #ffffff;
  box-shadow: 0 12px 30px rgba(22, 131, 90, 0.08);
}

.purchase-weekly-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.purchase-weekly-head > div {
  min-width: 0;
}

.purchase-weekly-kicker {
  display: block;
  margin-bottom: 3px;
  color: #16835a;
  font-size: 11px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.purchase-weekly-head h4 {
  margin: 0;
  color: var(--ink);
  font-family: Outfit, Inter, sans-serif;
  font-size: clamp(19px, 2vw, 24px);
}

.purchase-weekly-head p {
  max-width: 820px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.purchase-weekly-controls {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(150px, 190px) minmax(190px, auto) minmax(220px, auto);
  align-items: end;
  gap: 10px;
}

.purchase-weekly-controls label {
  min-width: 0;
  margin: 0;
}

.purchase-weekly-controls input,
.purchase-weekly-controls .btn {
  width: 100%;
  min-height: 44px;
}

.purchase-weekly-table-wrap {
  border: 1px solid rgba(22, 131, 90, 0.14);
  border-radius: 10px;
}

.purchase-orders-stack .purchase-weekly-table {
  min-width: 860px;
}

.purchase-orders-stack .purchase-weekly-table th:nth-child(1),
.purchase-orders-stack .purchase-weekly-table td:nth-child(1) {
  width: 64px;
}

.purchase-orders-stack .purchase-weekly-table th:nth-child(2),
.purchase-orders-stack .purchase-weekly-table td:nth-child(2) {
  width: 34%;
}

.purchase-orders-stack .purchase-weekly-table th:nth-child(3),
.purchase-orders-stack .purchase-weekly-table td:nth-child(3) {
  width: 100px;
}

.purchase-orders-stack .purchase-weekly-table th:nth-child(4),
.purchase-orders-stack .purchase-weekly-table td:nth-child(4) {
  width: 130px;
}

.purchase-orders-stack .purchase-weekly-table th:nth-child(5),
.purchase-orders-stack .purchase-weekly-table td:nth-child(5) {
  width: 120px;
}

.purchase-orders-stack .purchase-weekly-table th:nth-child(6),
.purchase-orders-stack .purchase-weekly-table td:nth-child(6) {
  width: 190px;
}

.purchase-limit-warning {
  padding: 10px 12px;
  border: 1px solid rgba(194, 109, 14, 0.28);
  border-radius: 9px;
  background: rgba(245, 158, 11, 0.1);
  color: #8a4b08;
  font-size: 13px;
  font-weight: 850;
}

.purchase-weekly-footnote {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.purchase-order-list {
  display: grid;
  gap: 12px;
}

.purchase-order-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
}

.purchase-order-card strong,
.purchase-order-card span,
.purchase-order-card small {
  display: block;
}

.purchase-order-card small {
  color: var(--muted);
}

@media (max-width: 900px) {
  .purchase-orders-layout,
  .purchase-orders-stack {
    grid-template-columns: 1fr;
  }

  .purchase-orders-layout .bulk-table,
  .purchase-orders-stack .bulk-table {
    min-width: 680px;
  }

  .purchase-result-count {
    align-items: flex-start;
    flex-direction: column;
  }

  .purchase-weekly-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .purchase-weekly-panel {
    padding: 14px;
  }

  .purchase-weekly-head {
    flex-direction: column;
  }

  .purchase-weekly-controls {
    grid-template-columns: minmax(0, 1fr);
  }
}

.system-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.system-hero strong {
  display: block;
  font-family: Outfit, Inter, sans-serif;
  font-size: 22px;
  color: var(--ink);
}

.system-hero p {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.system-actions {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
}

.system-metrics,
.system-report-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.system-metric strong {
  display: block;
  margin-top: 4px;
  font-family: Outfit, Inter, sans-serif;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
  color: var(--green);
}

.system-tabs {
  margin: 16px 0;
}

.system-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.55fr);
  gap: 14px;
  align-items: start;
}

.weekly-report-actions {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
}

.weekly-report-actions label {
  min-width: 150px;
}

.weekly-report-grid {
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
}

.weekly-table-wrap {
  max-height: 620px;
  overflow: auto;
}

@media (max-width: 900px) {
  .weekly-report-actions,
  .weekly-report-grid {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
}

.system-grid > .panel:only-child,
.system-grid > .panel:first-child:nth-last-child(3),
.system-grid > .panel:first-child:nth-last-child(4) {
  min-width: 0;
}

.system-alert-grid {
  display: grid;
  gap: 10px;
}

.system-alert-card {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
}

.system-alert-card.warning {
  border-color: rgba(245, 158, 11, 0.36);
  background: rgba(255, 251, 235, 0.9);
}

.system-alert-card.danger {
  border-color: rgba(220, 38, 38, 0.34);
  background: rgba(254, 242, 242, 0.92);
}

.system-alert-card.info {
  border-color: rgba(37, 99, 235, 0.24);
  background: rgba(239, 246, 255, 0.9);
}

.system-alert-card strong {
  color: var(--ink);
}

.system-alert-card span,
.system-alert-card small,
.system-test-summary small {
  color: var(--muted);
  font-weight: 800;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.compact-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.8fr) minmax(140px, 1fr) minmax(120px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.72);
}

.compact-row strong {
  color: var(--ink);
}

.compact-row span {
  color: var(--green);
  font-weight: 900;
}

.compact-row small {
  color: var(--muted);
  font-weight: 800;
}

.compact-table table {
  min-width: 680px;
}

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

.status-pill.success {
  border-color: rgba(22, 131, 90, 0.28);
  background: rgba(22, 131, 90, 0.08);
  color: var(--green);
}

.status-pill.danger {
  border-color: rgba(220, 38, 38, 0.28);
  background: rgba(254, 242, 242, 0.92);
  color: #b91c1c;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 18px;
  padding: 14px 0;
}

.skeleton-bar {
  display: block;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef2f6 25%, #dde5ee 50%, #eef2f6 75%);
  background-size: 200% 100%;
  animation: shimmerEffect 1.2s linear infinite;
}

.skeleton-bar.wide {
  height: 22px;
}

@media (max-width: 1000px) {
  .system-grid,
  .system-hero {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .compact-row {
    grid-template-columns: 1fr;
  }
}

/* Barra BCV estable para Windows, PC y telefono. */
.topbar {
  flex-wrap: wrap;
}

.topbar .brand-lockup {
  flex: 0 0 auto;
  order: 1;
}

.topbar-actions {
  flex: 0 0 auto;
  order: 3;
}

.topbar-bcv-calculator {
  order: 2;
  flex: 1 1 560px !important;
  width: auto !important;
  min-width: min(100%, 440px) !important;
  max-width: 720px !important;
  display: grid !important;
  grid-template-columns: 1fr !important;
  grid-template-areas: none !important;
  gap: 8px !important;
  padding: 10px 12px !important;
  overflow: hidden;
}

.topbar-bcv-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.topbar-bcv-head label,
.topbar-bcv-head small {
  grid-area: auto !important;
  min-width: 0;
  margin: 0;
  line-height: 1.2;
}

.topbar-bcv-head small {
  color: #0f6b49 !important;
  text-align: right !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap !important;
}

.topbar-bcv-calculator.is-loading .topbar-bcv-head small {
  color: #8a6418 !important;
}

.topbar-bcv-row {
  grid-area: auto !important;
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px !important;
  min-width: 0;
}

.topbar-bcv-card {
  display: grid;
  grid-template-columns: minmax(118px, 0.78fr) minmax(120px, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.topbar-bcv-card .topbar-bcv-input {
  min-width: 0;
}

.topbar-bcv-card strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1480px) {
  .topbar .brand-lockup {
    order: 1;
  }

  .topbar-actions {
    order: 2;
  }

  .topbar-bcv-calculator {
    order: 3;
    flex-basis: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
  }
}

@media (max-width: 760px) {
  .topbar-bcv-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .topbar-bcv-head small {
    text-align: left !important;
    white-space: normal !important;
  }

  .topbar-bcv-row,
  .topbar-bcv-card {
    grid-template-columns: 1fr !important;
  }

  .topbar-bcv-card {
    padding: 8px;
    border: 1px solid rgba(22, 131, 90, 0.14);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.62);
  }

  .topbar-bcv-card strong {
    text-align: left;
  }
}

.whatsapp-crm-panel {
  display: grid;
  gap: 12px;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(255, 255, 255, 0.96)),
    #fff;
}

.whatsapp-crm-layout {
  display: grid;
  grid-template-columns: minmax(292px, 352px) minmax(460px, 1fr) minmax(342px, 430px);
  gap: 12px;
  align-items: stretch;
  min-height: min(680px, calc(100vh - 210px));
}

.whatsapp-crm-sidebar,
.whatsapp-chat-column,
.whatsapp-workspace {
  min-width: 0;
  overflow: hidden;
}

.whatsapp-crm-sidebar,
.whatsapp-chat-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.whatsapp-workspace {
  display: grid;
  align-content: start;
  gap: 10px;
  max-height: min(720px, calc(100vh - 210px));
  overflow: auto;
  padding-right: 2px;
}

.whatsapp-pane-head,
.whatsapp-tool-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
}

.whatsapp-pane-head {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.whatsapp-pane-head span,
.whatsapp-tool-head span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.whatsapp-manual-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.64);
}

.whatsapp-manual-form input {
  min-width: 0;
  width: 100%;
}

.whatsapp-manual-form input:first-of-type {
  grid-column: 1 / -1;
}

.whatsapp-manual-form button {
  min-width: 76px;
}

.whatsapp-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(41, 98, 255, 0.1);
  color: #1d4ed8;
  font-size: 0.74rem;
  font-weight: 900;
  white-space: nowrap;
}

.whatsapp-status-pill.success {
  background: rgba(22, 131, 90, 0.12);
  color: #14764f;
}

.whatsapp-status-pill.warning {
  background: rgba(190, 126, 0, 0.14);
  color: #925f00;
}

.whatsapp-status-pill.danger {
  background: rgba(190, 18, 60, 0.12);
  color: #a31038;
}

.whatsapp-channel-pill {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: #334155;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.whatsapp-channel-pill.instagram {
  background: rgba(219, 39, 119, 0.12);
  color: #be185d;
}

.whatsapp-channel-pill.facebook {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.whatsapp-channel-pill.whatsapp {
  background: rgba(22, 131, 90, 0.12);
  color: #14764f;
}

.whatsapp-quality-panel {
  display: grid;
  grid-template-columns: repeat(6, minmax(104px, 1fr));
  gap: 8px;
}

.whatsapp-pipeline-bar {
  display: grid;
  grid-template-columns: repeat(7, minmax(112px, 1fr));
  gap: 8px;
}

.whatsapp-pipeline-step {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}

.whatsapp-pipeline-step::before {
  content: "";
  position: absolute;
  inset: auto 10px 0;
  height: 3px;
  border-radius: 999px 999px 0 0;
  background: rgba(41, 98, 255, 0.32);
}

.whatsapp-pipeline-step.success::before {
  background: rgba(22, 131, 90, 0.42);
}

.whatsapp-pipeline-step.warning::before {
  background: rgba(190, 126, 0, 0.44);
}

.whatsapp-pipeline-step.danger::before {
  background: rgba(190, 18, 60, 0.42);
}

.whatsapp-pipeline-step.active,
.whatsapp-pipeline-step:hover {
  border-color: rgba(41, 98, 255, 0.24);
  background: rgba(248, 250, 252, 0.98);
  transform: translateY(-1px);
}

.whatsapp-pipeline-step span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 950;
}

.whatsapp-pipeline-step strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.whatsapp-pipeline-step em {
  min-width: 28px;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 950;
  text-align: right;
}

.whatsapp-quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.whatsapp-quick-filter {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
}

.whatsapp-quick-filter.active,
.whatsapp-quick-filter:hover {
  border-color: rgba(22, 131, 90, 0.28);
  background: rgba(22, 131, 90, 0.08);
  color: var(--green);
}

.whatsapp-quality-chip {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.8);
}

.whatsapp-quality-chip strong {
  font-size: 1.05rem;
  line-height: 1;
}

.whatsapp-quality-chip small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.whatsapp-quality-chip.success {
  border-color: rgba(22, 131, 90, 0.22);
}

.whatsapp-quality-chip.warning {
  border-color: rgba(190, 126, 0, 0.26);
}

.whatsapp-quality-chip.danger {
  border-color: rgba(190, 18, 60, 0.26);
}

.whatsapp-thread-list {
  display: grid;
  align-content: start;
  max-height: min(680px, calc(100vh - 230px));
  overflow: auto;
}

.whatsapp-thread {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  width: 100%;
  padding: 12px 12px 12px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.whatsapp-thread::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px 0;
  width: 4px;
  border-radius: 0 999px 999px 0;
  background: rgba(41, 98, 255, 0.34);
}

.whatsapp-thread.status-cotizar::before,
.whatsapp-thread.status-cotizacion_enviada::before,
.whatsapp-thread.status-aprobado_venta::before {
  background: rgba(22, 131, 90, 0.5);
}

.whatsapp-thread.status-faltan_datos::before,
.whatsapp-thread.status-esperando_cliente::before {
  background: rgba(190, 126, 0, 0.55);
}

.whatsapp-thread.status-perdido::before {
  background: rgba(190, 18, 60, 0.5);
}

.whatsapp-thread.active,
.whatsapp-thread:hover {
  background: rgba(248, 250, 252, 0.96);
}

.whatsapp-thread.active {
  box-shadow: inset 0 0 0 1px rgba(41, 98, 255, 0.12);
}

.whatsapp-thread.unread {
  background: rgba(239, 246, 255, 0.74);
}

.whatsapp-thread span,
.whatsapp-thread small {
  min-width: 0;
}

.whatsapp-thread strong,
.whatsapp-thread small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.whatsapp-thread strong.whatsapp-thread-title {
  display: flex;
  gap: 6px;
  align-items: center;
}

.whatsapp-thread-title .whatsapp-channel-pill {
  max-width: 92px;
}

.whatsapp-thread small,
.whatsapp-thread em {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
}

.whatsapp-thread.unread .whatsapp-thread-preview {
  color: var(--ink);
  font-weight: 900;
}

.whatsapp-thread-meta {
  margin-top: 3px;
  font-size: 0.74rem !important;
}

.whatsapp-thread-tags {
  display: flex !important;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 5px;
  white-space: normal !important;
}

.whatsapp-thread-tags span {
  display: inline-flex;
  max-width: 100%;
  min-height: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.whatsapp-thread b {
  min-width: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  font-size: 0.78rem;
  text-align: center;
}

.whatsapp-thread-side {
  display: grid;
  gap: 6px;
  justify-items: end;
  align-content: start;
}

.whatsapp-chat-column {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr) auto;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(255, 255, 255, 0.84)),
    #fff;
}

.whatsapp-conversation-head,
.whatsapp-reply-form {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.whatsapp-conversation-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.whatsapp-conversation-summary + div:not(.whatsapp-thread-actions) {
  display: none;
}

.whatsapp-conversation-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.whatsapp-contact-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.08);
  color: #334155;
  font-size: 0.82rem;
  font-weight: 950;
}

.whatsapp-contact-avatar.instagram {
  background: rgba(219, 39, 119, 0.12);
  color: #be185d;
}

.whatsapp-contact-avatar.facebook {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.whatsapp-contact-avatar.whatsapp {
  background: rgba(22, 131, 90, 0.12);
  color: #14764f;
}

.whatsapp-conversation-summary div {
  min-width: 0;
}

.whatsapp-conversation-summary strong,
.whatsapp-conversation-summary small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.whatsapp-conversation-head h3 {
  margin: 0;
}

.whatsapp-conversation-head small {
  color: var(--muted);
  font-weight: 800;
}

.whatsapp-thread-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.whatsapp-thread-actions select,
#whatsappStatusFilter {
  min-height: 40px;
}

.whatsapp-meta-form,
.whatsapp-history-panel,
.whatsapp-requests-panel,
.whatsapp-tasks-panel,
.whatsapp-activity-panel,
.whatsapp-attachments-panel,
.whatsapp-quote-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.045);
}

.whatsapp-tool-head {
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.86);
}

.whatsapp-tool-head strong {
  letter-spacing: 0;
  font-size: 0.92rem;
}

.whatsapp-meta-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
}

.whatsapp-meta-form label,
.whatsapp-quote-item label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.whatsapp-meta-form input,
.whatsapp-meta-form textarea,
.whatsapp-quote-search,
.whatsapp-quote-item input {
  width: 100%;
  min-width: 0;
}

.whatsapp-meta-actions,
.whatsapp-request-actions,
.whatsapp-attachment-form,
.whatsapp-quote-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.whatsapp-linked-customer,
.whatsapp-customer-result,
.whatsapp-duplicate-item,
.whatsapp-request,
.whatsapp-task-list article,
.whatsapp-quote-result,
.whatsapp-quote-item,
.whatsapp-attachment,
.whatsapp-quote-total {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.whatsapp-linked-customer {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
}

.whatsapp-linked-customer span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.whatsapp-duplicate-panel {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.whatsapp-duplicate-panel > strong {
  font-size: 0.84rem;
}

.whatsapp-duplicate-item {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 8px 10px;
  color: var(--ink);
  text-align: left;
}

.whatsapp-duplicate-item:not(.passive) {
  cursor: pointer;
}

.whatsapp-duplicate-item small,
.whatsapp-duplicate-panel > small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.whatsapp-intake-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 10px;
  padding: 10px;
  border: 1px solid rgba(37, 99, 235, 0.16);
  border-radius: 8px;
  background: rgba(239, 246, 255, 0.64);
}

.whatsapp-intake-summary span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.whatsapp-intake-summary strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.whatsapp-history-grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 10px;
}

.whatsapp-history-grid span,
.whatsapp-last-quote span,
.whatsapp-quote-context {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.whatsapp-history-grid strong,
.whatsapp-last-quote p {
  min-width: 0;
  overflow-wrap: anywhere;
}

.whatsapp-last-quote {
  display: grid;
  gap: 5px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.whatsapp-last-quote p {
  max-height: 110px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  color: var(--ink);
  font-size: 0.84rem;
}

.whatsapp-request-list,
.whatsapp-task-list,
.whatsapp-activity-list,
.whatsapp-customer-history {
  display: grid;
  gap: 8px;
}

.whatsapp-request {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  padding: 10px;
}

.whatsapp-request.active {
  border-color: rgba(22, 131, 90, 0.36);
  background: rgba(22, 131, 90, 0.07);
}

.whatsapp-request strong,
.whatsapp-request span,
.whatsapp-request small,
.whatsapp-customer-history strong,
.whatsapp-customer-history small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.whatsapp-request span,
.whatsapp-request small,
.whatsapp-customer-history > span,
.whatsapp-customer-history small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.whatsapp-request-buttons {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.whatsapp-customer-history {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.whatsapp-customer-history article {
  display: grid;
  gap: 3px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.whatsapp-customer-history article:last-child {
  border-bottom: 0;
}

.whatsapp-task-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.whatsapp-task-form button,
.whatsapp-task-form input[name="responsible_user_name"] {
  grid-column: 1 / -1;
}

.whatsapp-task-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
}

.whatsapp-task-list article.done {
  opacity: 0.66;
}

.whatsapp-task-list strong,
.whatsapp-task-list small,
.whatsapp-activity-list strong,
.whatsapp-activity-list span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.whatsapp-task-list small,
.whatsapp-activity-list time,
.whatsapp-activity-list span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
}

.whatsapp-activity-list article {
  display: grid;
  gap: 3px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.whatsapp-activity-list article:last-child {
  border-bottom: 0;
}

.whatsapp-attachment-form {
  justify-content: stretch;
}

.whatsapp-attachment-form select,
.whatsapp-attachment-form input {
  min-width: 0;
  flex: 1 1 150px;
}

.whatsapp-attachment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

.whatsapp-attachment {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 8px;
  color: var(--ink);
  text-decoration: none;
}

.whatsapp-attachment img,
.whatsapp-attachment > span {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.08);
  object-fit: cover;
}

.whatsapp-attachment > span {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.whatsapp-attachment strong,
.whatsapp-attachment small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.whatsapp-attachment small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.whatsapp-quote-context {
  padding: 8px 10px;
  border: 1px dashed rgba(22, 131, 90, 0.24);
  border-radius: 8px;
  background: rgba(22, 131, 90, 0.06);
}

.whatsapp-customer-results,
.whatsapp-quote-results,
.whatsapp-quote-basket {
  display: grid;
  gap: 8px;
}

.whatsapp-customer-result {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 9px 10px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.whatsapp-customer-result:hover,
.whatsapp-quote-result:hover {
  border-color: rgba(22, 131, 90, 0.28);
  background: rgba(22, 131, 90, 0.06);
}

.whatsapp-customer-result small,
.whatsapp-quote-result small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.whatsapp-quote-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
}

.whatsapp-quote-result div,
.whatsapp-quote-edit,
.whatsapp-quote-edit div {
  min-width: 0;
}

.whatsapp-quote-result span,
.whatsapp-quote-result small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.whatsapp-quote-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 76px 92px auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
}

.whatsapp-quote-edit {
  display: grid;
  gap: 6px;
}

.whatsapp-quote-edit div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.8fr);
  gap: 6px;
}

.whatsapp-quote-total {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: center;
  padding: 10px;
}

.whatsapp-quote-total span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.whatsapp-quote-total strong {
  text-align: right;
}

.whatsapp-message-list {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 14px;
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.6), rgba(241, 245, 249, 0.34)),
    #fff;
}

.whatsapp-message {
  width: min(76%, 680px);
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 8px 2px;
  background: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.whatsapp-message.outbound {
  justify-self: end;
  border-color: rgba(22, 131, 90, 0.22);
  background: rgba(22, 131, 90, 0.08);
  border-radius: 8px 8px 2px 8px;
}

.whatsapp-message p {
  margin: 0 0 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.whatsapp-message footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.whatsapp-reply-form {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.whatsapp-reply-form textarea {
  flex: 1 1 auto;
  min-width: 0;
  resize: vertical;
}

@media (max-width: 1180px) {
  .whatsapp-crm-layout {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  }

  .whatsapp-quality-panel {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .whatsapp-pipeline-bar {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
  }

  .whatsapp-workspace {
    grid-column: 2;
    max-height: none;
  }
}

@media (max-width: 900px) {
  .whatsapp-crm-layout {
    grid-template-columns: 1fr;
  }

  .whatsapp-workspace {
    max-height: none;
    overflow: visible;
  }

  .whatsapp-thread-list {
    max-height: 280px;
  }

  .whatsapp-quality-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .whatsapp-pipeline-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
  }

  .whatsapp-pipeline-step {
    flex: 0 0 178px;
    scroll-snap-align: start;
  }

  .whatsapp-conversation-head,
  .whatsapp-reply-form {
    align-items: stretch;
    flex-direction: column;
  }

  .whatsapp-conversation-summary {
    grid-template-columns: auto minmax(0, 1fr);
    width: 100%;
  }

  .whatsapp-conversation-summary .whatsapp-status-pill {
    grid-column: 2;
    justify-self: start;
  }

  .whatsapp-meta-grid,
  .whatsapp-quote-item,
  .whatsapp-quote-edit div {
    grid-template-columns: 1fr;
  }

  .whatsapp-quote-result {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .whatsapp-quote-result .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .whatsapp-thread-actions,
  .whatsapp-reply-form .btn,
  .whatsapp-manual-form button {
    width: 100%;
  }

  .whatsapp-manual-form {
    grid-template-columns: 1fr;
  }

  .whatsapp-message {
    width: 100%;
  }
}

/* Abonos distribuidos y notas de credito de clientes. */
.supplier-allocation-help,
.supplier-allocation-result {
  grid-column: 1 / -1;
  border: 1px solid rgba(22, 131, 90, 0.2);
  border-radius: 8px;
  background: rgba(22, 131, 90, 0.06);
  padding: 11px 13px;
}

.supplier-allocation-help {
  display: grid;
  gap: 3px;
}

.supplier-allocation-help strong,
.supplier-allocation-result strong {
  color: var(--green);
}

.supplier-allocation-help span,
.supplier-allocation-result small {
  color: var(--soft);
  font-size: 0.82rem;
  line-height: 1.4;
}

.compact-head {
  margin-bottom: 8px;
}

.compact-head > div {
  display: grid;
  gap: 2px;
}

.supplier-allocation-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px;
}

.supplier-allocation-list > span {
  display: grid;
  gap: 2px;
  min-width: 0;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.86);
  padding: 9px 10px;
}

.supplier-allocation-list em {
  color: var(--ink);
  font-style: normal;
  font-weight: 800;
}

.customer-credit-layout {
  align-items: start;
}

.customer-credit-guide ol {
  display: grid;
  gap: 12px;
  margin: 0;
  padding-left: 22px;
  color: var(--soft);
}

.customer-credit-guide li::marker {
  color: var(--green);
  font-weight: 900;
}

.customer-credit-warning,
.return-settlement-note,
.customer-credit-sale-summary {
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  background: rgba(246, 248, 251, 0.92);
  color: var(--soft);
  padding: 11px 13px;
}

.customer-credit-warning {
  margin-top: 18px;
  border-color: rgba(245, 158, 11, 0.28);
  background: rgba(245, 158, 11, 0.08);
  color: #854d0e;
  font-weight: 750;
}

.customer-credit-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(170px, 0.35fr) auto;
  gap: 10px;
  margin-bottom: 14px;
}

.customer-credit-table td > small,
.customer-credit-table td > strong {
  display: block;
}

.customer-credit-table td > small {
  margin-top: 3px;
  color: var(--soft);
}

.customer-credit-sale-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 12px;
  align-items: center;
  margin-top: 10px;
}

.customer-credit-sale-summary.has-credit,
.return-settlement-note.credit {
  border-color: rgba(22, 131, 90, 0.28);
  background: rgba(22, 131, 90, 0.07);
}

.customer-credit-sale-summary > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.customer-credit-sale-summary strong {
  color: var(--green);
  font-size: 1.05rem;
}

.customer-credit-sale-summary small {
  color: var(--soft);
}

.customer-credit-sale-summary .btn {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.return-settlement-note {
  margin: 10px 0 14px;
  font-weight: 750;
}

.confirm-payment-split-details {
  display: grid;
  gap: 7px;
  margin-top: 10px;
  color: var(--soft);
  font-size: 0.82rem;
}

.confirm-payment-split-details > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.confirm-payment-split-details span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  padding: 6px 9px;
}

.confirm-payment-split-details span small {
  color: var(--green);
  font-weight: 800;
}

@media (max-width: 760px) {
  .customer-credit-filters,
  .customer-credit-sale-summary {
    grid-template-columns: 1fr;
  }

  .customer-credit-sale-summary .btn {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
  }

  .customer-credit-sale-summary > div {
    align-items: flex-start;
    flex-direction: column;
  }

  .supplier-allocation-list {
    grid-template-columns: 1fr;
  }
}

/* Anticipos a motorizados: salida de caja separada del efectivo de ventas. */
.driver-advance-section {
  min-width: 0;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.driver-advance-head {
  align-items: end;
  margin-bottom: 12px;
}

.driver-advance-head > div {
  display: grid;
  gap: 3px;
}

.driver-advance-head h3 {
  margin: 0;
}

.driver-advance-kicker {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.driver-advance-boundary {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid rgba(31, 102, 209, 0.24);
  border-radius: 8px;
  padding: 7px 10px;
  color: #174f9f;
  background: rgba(31, 102, 209, 0.08);
  font-size: 12px;
  font-weight: 900;
}

.driver-advance-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.72fr) minmax(560px, 1.28fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.driver-advance-layout > * {
  min-width: 0;
}

.driver-advance-form {
  border-top: 4px solid #1f66d1 !important;
}

.driver-advance-pending-panel {
  border-top: 4px solid #d69720 !important;
}

.driver-advance-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  padding: 10px;
  background: rgba(246, 248, 251, 0.92);
}

.driver-advance-preview > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  border-left: 3px solid rgba(31, 102, 209, 0.4);
  padding: 8px 9px;
  background: #ffffff;
}

.driver-advance-preview > div.pending {
  border-left-color: #d69720;
  background: #fff9ed;
}

.driver-advance-preview span,
.driver-advance-preview small {
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.driver-advance-preview strong {
  color: var(--ink);
  font-size: 18px;
  overflow-wrap: anywhere;
}

.driver-advance-preview .pending strong {
  color: #91570b;
}

.driver-advance-preview > small {
  grid-column: 1 / -1;
  padding: 0 3px;
}

.driver-advance-preview.invalid {
  border-color: rgba(180, 35, 24, 0.3);
  background: rgba(180, 35, 24, 0.06);
}

.driver-advance-preview.invalid > small,
.driver-advance-preview.invalid .pending strong {
  color: #b42318;
}

.driver-advance-table {
  min-width: 940px;
}

.driver-advance-table td > strong,
.driver-advance-table td > small {
  display: block;
}

.driver-advance-table td > small {
  margin-top: 3px;
  color: var(--soft);
  font-size: 12px;
}

.driver-advance-pending strong {
  color: #91570b;
}

.driver-advance-return {
  display: grid;
  grid-template-columns: minmax(82px, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  min-width: 250px;
}

.driver-advance-return input,
.driver-advance-return .btn {
  min-width: 0;
  min-height: 38px;
}

.driver-advance-error {
  border-color: rgba(180, 35, 24, 0.24);
  color: #b42318;
  background: rgba(180, 35, 24, 0.06);
}

.cash-entry-unified {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.cash-entry-unified-head {
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.74);
}

.cash-entry-unified-head h3,
.cash-entry-unified-head p {
  margin: 0;
}

.cash-entry-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  min-width: min(100%, 360px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: var(--surface-muted, #f4f7fa);
}

.cash-entry-mode {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--soft);
  background: transparent;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.cash-entry-mode.active {
  border-color: rgba(22, 131, 90, 0.28);
  color: var(--green);
  background: #ffffff;
  box-shadow: 0 5px 16px rgba(15, 23, 42, 0.08);
}

.cash-entry-layout > * {
  min-width: 0;
}

.cash-closing-advances {
  margin-top: 14px;
}

.cash-expected.advance-pending strong {
  color: #91570b;
}

.sale-delivery-status-grid {
  align-items: stretch;
}

.delivery-assignment-note {
  display: grid;
  align-content: center;
  gap: 3px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-left: 4px solid #8b98aa;
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--soft);
  background: rgba(246, 248, 251, 0.9);
}

.delivery-assignment-note.active {
  border-left-color: #1f66d1;
  color: var(--ink);
  background: rgba(31, 102, 209, 0.07);
}

.delivery-assignment-note small {
  color: var(--soft);
}

.sale-delivery-final-check {
  border: 1px solid rgba(31, 102, 209, 0.24);
  border-top: 4px solid #1f66d1;
  border-radius: 8px;
  padding: 16px;
  background: rgba(31, 102, 209, 0.045);
}

.sale-delivery-final-check > p {
  margin: 0 0 12px;
  color: var(--soft);
}

.sale-delivery-final-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 8px;
}

.sale-delivery-final-summary > div {
  display: grid;
  gap: 3px;
  min-width: 0;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 7px;
  padding: 9px 10px;
  background: #ffffff;
}

.sale-delivery-final-summary span {
  color: var(--soft);
  font-size: 12px;
  font-weight: 800;
}

.sale-delivery-final-summary strong {
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .driver-advance-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 860px) {
  .driver-advance-section {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .driver-advance-boundary {
    justify-content: center;
    width: 100%;
  }

  .driver-advance-layout,
  .driver-advance-preview {
    grid-template-columns: minmax(0, 1fr) !important;
    width: 100%;
  }

  .driver-advance-preview > small {
    grid-column: 1;
  }

  .driver-advance-table {
    min-width: 0;
  }

  .driver-advance-return {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    width: 100%;
  }

  .driver-advance-return input {
    grid-column: 1 / -1;
    width: 100%;
  }

  .cash-entry-unified-head {
    align-items: stretch;
  }

  .cash-entry-switch,
  .sale-delivery-final-summary {
    grid-template-columns: minmax(0, 1fr);
    width: 100%;
  }
}

/* Autoridad final para que las reglas genericas de modal no reduzcan el editor. */
.confirm-modal-overlay.sale-correction-overlay {
  z-index: 1080;
  padding: 12px;
}

.confirm-modal-card.sale-correction-modal {
  width: min(1180px, 100%);
  max-height: calc(100dvh - 24px);
  border-radius: 8px;
}

.confirm-modal-header.sale-correction-header {
  align-items: flex-start;
  padding: 15px 20px;
}

.confirm-modal-body.sale-correction-body {
  gap: 14px;
  padding: 16px 20px;
}

@media (max-width: 600px) {
  .confirm-modal-overlay.sale-correction-overlay {
    place-items: stretch;
    padding: 0;
  }

  .confirm-modal-card.sale-correction-modal {
    width: 100%;
    max-height: 100dvh;
    min-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .confirm-modal-header.sale-correction-header,
  .confirm-modal-body.sale-correction-body,
  .confirm-modal-footer.sale-correction-footer {
    padding-left: 12px;
    padding-right: 12px;
  }

  .confirm-modal-footer.sale-correction-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Lector de etiquetas: autoridad final para Windows, web y movil. */
.bulk-actions.label-bulk-actions {
  grid-template-columns: minmax(300px, 360px) minmax(320px, 1fr) auto;
  align-items: end;
}

.label-bulk-actions > label,
.bulk-upload-field {
  min-width: 0;
  align-self: start;
}

.bulk-field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--soft);
  font-size: 13px;
  font-weight: 900;
}

.bulk-upload-control {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-left: 4px solid rgba(22, 131, 90, 0.62);
  border-radius: 7px;
  background: var(--field);
  cursor: pointer;
}

.bulk-actions input.bulk-upload-input {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

.bulk-upload-button {
  padding: 8px 12px;
  border-radius: 6px;
  background: #eef2f6;
  color: var(--ink);
  font-weight: 900;
  white-space: nowrap;
}

.bulk-upload-name {
  min-width: 0;
  overflow: hidden;
  color: var(--soft);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bulk-upload-input:focus-visible + .bulk-upload-control {
  outline: 3px solid rgba(22, 131, 90, 0.18);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .bulk-actions.label-bulk-actions {
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: stretch !important;
  }

  .bulk-upload-field {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .bulk-upload-control {
    grid-template-columns: minmax(0, 1fr);
  }

  .bulk-upload-button,
  .bulk-upload-name {
    text-align: center;
  }
}

/* The BCV calculator makes the mobile header variable-height; keep navigation in normal flow. */
@media (max-width: 860px) {
  .sidebar {
    position: static !important;
    top: auto !important;
  }

  .content {
    padding-top: 16px !important;
  }
}
.embedded-operation-view {
  padding: 0 !important;
  overflow: hidden;
}

.embedded-operation-frame {
  display: block;
  width: 100%;
  min-height: calc(100dvh - 96px);
  border: 0;
  background: #f6f8fa;
}
