/* SAFECO OS · consola de trabajo, móvil primero. */
:root {
  color-scheme: light;
  --ink: #14263a;
  --ink-soft: #40576a;
  --muted: #5c6f7a;
  --canvas: #f7f7f3;
  --paper: #ffffff;
  --paper-warm: #f1f3ed;
  --sidebar: #102737;
  --sidebar-soft: #17394a;
  --jade: #168473;
  --jade-dark: #0c6659;
  --jade-pale: #e4f3ee;
  --line: #dce4e1;
  --line-strong: #c9d5d1;
  --warning: #805000;
  --warning-bg: #fff3d8;
  --danger: #a43637;
  --danger-bg: #fff0ee;
  --success: #17654d;
  --success-bg: #e4f4ea;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 2px 8px rgb(16 39 55 / 4%), 0 10px 28px rgb(16 39 55 / 3%);
  --shadow-raised: 0 16px 50px rgb(16 39 55 / 16%);
  --focus: #08796a;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 0;
  min-height: 100%;
  background: var(--canvas);
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

body, button, input, select, textarea {
  font-family: inherit;
}

button, input, select, textarea {
  font-size: 16px;
}

button, select {
  cursor: pointer;
}

button:disabled, input:disabled, select:disabled, textarea:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
}

button, a, input, select, textarea, [tabindex] {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.sidebar :focus-visible,
.bottom-nav :focus-visible {
  outline-color: #85e4cc;
}

a {
  color: var(--jade-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--jade);
}

img, svg {
  max-width: 100%;
}

svg {
  display: inline-block;
  flex: none;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  stroke-width: 1.8;
}

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

h1, h2, h3 {
  line-height: 1.2;
}

#app {
  min-height: 100vh;
}

/* Estructura y navegación. */
.app-shell {
  min-height: 100vh;
}

.sidebar {
  display: none;
}

.main {
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 60px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: rgb(255 255 255 / 96%);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.breadcrumb > :last-child {
  overflow: hidden;
  color: var(--ink);
  font-weight: 700;
  text-overflow: ellipsis;
}

.bread-link {
  display: inline-flex;
  align-items: center;
  min-width: 44px;
  min-height: 44px;
  color: var(--ink-soft);
  font-weight: 600;
  text-decoration: none;
}

.bread-link:hover {
  color: var(--jade-dark);
  text-decoration: underline;
}

.topbar-right {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.icon-btn,
.close {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}

.icon-btn:hover, .close:hover {
  border-color: var(--line);
  background: var(--paper-warm);
  color: var(--ink);
}

.mobile-brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: .06em;
  text-decoration: none;
}

.mobile-brand .brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
}

.mobile-only {
  display: initial;
}

.desktop-only {
  display: none !important;
}

.bottom-nav {
  position: fixed;
  z-index: 40;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  min-height: 68px;
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 -6px 22px rgb(16 39 55 / 5%);
}

.bottom-nav a,
.bottom-nav button,
.bottom-nav .nav-item {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 44px;
  min-height: 56px;
  padding: 5px 2px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #526a77;
  font-size: 10px;
  font-weight: 650;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.bottom-nav svg,
.bottom-nav .nav-icon {
  width: 20px;
  height: 20px;
}

.bottom-nav .active,
.bottom-nav [aria-current="page"] {
  background: var(--jade-pale);
  color: #075e50;
}

.bottom-nav .nav-count {
  position: absolute;
  margin: -28px 0 0 26px;
}

.content {
  width: 100%;
  max-width: 1500px;
  min-width: 0;
  margin: 0 auto;
  padding: 24px 16px calc(96px + env(safe-area-inset-bottom, 0px));
}

.demo-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid #ead8ae;
  background: #fff7e5;
  color: #694700;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}

.demo-banner svg {
  width: 18px;
  height: 18px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.page-header > div:first-child {
  min-width: 0;
}

.eyebrow,
.section-label {
  display: block;
  margin: 0 0 8px;
  color: var(--jade-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .11em;
  line-height: 1.3;
  text-transform: uppercase;
}

.page-title,
.view-title {
  margin: 0;
  color: var(--ink);
  font-size: clamp(25px, 5vw, 34px);
  font-weight: 750;
  letter-spacing: -.035em;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.page-subtitle {
  max-width: 64ch;
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
}

/* Marca y navegación lateral en escritorio. */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 20%);
  border-radius: 9px;
  background-color: var(--jade);
  background-image: repeating-linear-gradient(90deg, transparent 0 7px, rgb(255 255 255 / 13%) 7px 8px), repeating-linear-gradient(0deg, transparent 0 7px, rgb(255 255 255 / 13%) 7px 8px);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
}

.brand-mark svg {
  width: 23px;
  height: 23px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  color: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .08em;
  line-height: 1.2;
}

.brand-text small {
  margin-top: 3px;
  color: #b3c8cc;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
}

.nav-section {
  margin-top: 30px;
}

.nav-section > .section-label,
.nav-section > small,
.nav-section > h2,
.nav-section > h3 {
  display: block;
  margin: 0 0 9px;
  padding: 0 12px;
  color: #a9bec3;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .11em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: inherit;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
}

.nav-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.nav-icon svg {
  width: 19px;
  height: 19px;
}

.nav-label {
  flex: 1;
  min-width: 0;
}

.nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  min-height: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #e5f3ee;
  color: #075e50;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 24px;
}

.avatar,
.customer-avatar,
.client-initials {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid #d6e7e0;
  border-radius: 12px;
  background: #e6f1eb;
  color: #155f52;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .02em;
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 14px 4px 0;
  border-top: 1px solid rgb(255 255 255 / 13%);
  color: #f6fbfa;
  font-size: 13px;
}

.sidebar-profile .avatar {
  border-color: #427063;
  background: #235348;
  color: #e7f9f1;
}

.sidebar-profile small {
  display: block;
  color: #b6c9cb;
  font-size: 11px;
}

/* Acciones, etiquetas y estados. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--jade);
  color: #fff;
  font-size: 13px;
  font-weight: 750;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, box-shadow 150ms ease, color 150ms ease;
}

.btn:hover {
  background: var(--jade-dark);
  color: #fff;
}

.btn:active {
  box-shadow: inset 0 2px 4px rgb(0 0 0 / 12%);
}

.btn svg {
  width: 17px;
  height: 17px;
}

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

.btn.primary:hover, .btn-primary:hover {
  border-color: var(--jade-dark);
  background: var(--jade-dark);
}

.btn.secondary, .btn-secondary {
  border-color: #c8e0d8;
  background: var(--jade-pale);
  color: #0a5d50;
}

.btn.secondary:hover, .btn-secondary:hover {
  border-color: #9bc9bb;
  background: #d2ebe2;
  color: #064d43;
}

.btn.outline, .btn-outline {
  border-color: var(--line-strong);
  background: #fff;
  color: var(--ink);
}

.btn.outline:hover, .btn-outline:hover {
  border-color: #8da69d;
  background: #f3f7f4;
  color: var(--ink);
}

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

.btn.ghost:hover, .btn-ghost:hover {
  background: #eaf0ed;
  color: var(--ink);
}

.btn.danger, .btn-danger {
  border-color: #a43637;
  background: #a43637;
  color: #fff;
}

.btn.danger:hover, .btn-danger:hover {
  border-color: #812b2d;
  background: #812b2d;
}

.btn.small, .btn-small {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 12px;
}

.btn:disabled, .btn.disabled, .btn[aria-disabled="true"],
.icon-btn:disabled, .icon-btn.disabled {
  border-color: #d9e0dd;
  background: #edf0ee;
  color: #687b78;
  box-shadow: none;
  cursor: not-allowed;
}

.status-pill,
.badge,
.tag,
.chip,
.offline-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: #edf2f0;
  color: #365348;
  font-size: 11px;
  font-weight: 750;
  line-height: 1.35;
  white-space: normal;
}

.status-pill {
  min-height: 28px;
  border-color: #cfe7dd;
  background: var(--jade-pale);
  color: #0c6253;
}

.badge-dot,
.dot {
  display: inline-block;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.tag {
  border-color: #e2e8e5;
  background: #f5f7f5;
  color: #4a5e68;
  font-weight: 650;
}

.offline-label {
  border-color: #ead5a7;
  background: var(--warning-bg);
  color: #754b00;
}

.status-pill.success, .badge.success, .tag.success, .chip.success {
  border-color: #cce7d5;
  background: var(--success-bg);
  color: var(--success);
}

.status-pill.warning, .badge.warning, .tag.warning, .chip.warning {
  border-color: #efd9a9;
  background: var(--warning-bg);
  color: var(--warning);
}

.status-pill.danger, .badge.danger, .tag.danger, .chip.danger {
  border-color: #efceca;
  background: var(--danger-bg);
  color: var(--danger);
}

.dot.success, .badge-dot.success { background: #238164; }
.dot.warning, .badge-dot.warning { background: #b07809; }
.dot.danger, .badge-dot.danger { background: #bf4a49; }

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--jade-dark);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.text-link:hover {
  color: #084e44;
  text-decoration: underline;
}

.text-link svg, .right-arrow svg {
  width: 16px;
  height: 16px;
}

/* Resumen y paneles. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}

.stat-card,
.panel,
.feature-card,
.history-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.stat-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  min-height: 140px;
  padding: 16px;
}

.stat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-bottom: 5px;
  border-radius: 10px;
  background: #e8f3ee;
  color: var(--jade-dark);
}

.stat-icon svg {
  width: 18px;
  height: 18px;
}

.stat-value {
  color: var(--ink);
  font-size: 27px;
  font-weight: 750;
  letter-spacing: -.04em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: #324b5a;
  font-size: 12px;
  font-weight: 700;
}

.stat-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.grid-main-aside {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 16px;
}

.panel {
  overflow: hidden;
  padding: 18px;
}

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 16px;
}

.panel-header > div:first-child {
  min-width: 0;
}

.panel-title {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -.015em;
}

.panel-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.feature-card {
  padding: 20px;
  border-color: #cfe4db;
  background: #eff7f2;
}

.feature-card .section-label {
  color: var(--jade-dark);
}

.feature-card h2, .feature-card h3 {
  margin-bottom: 8px;
  letter-spacing: -.02em;
}

.feature-card p {
  color: #405b57;
  font-size: 13px;
}

.customer-row,
.activity-row,
.system-row,
.sync-item,
.line-row,
.calendar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 13px 0;
  border-bottom: 1px solid #edf1ee;
}

.customer-row:last-child,
.activity-row:last-child,
.system-row:last-child,
.sync-item:last-child,
.line-row:last-child,
.calendar-row:last-child {
  border-bottom: 0;
}

a.customer-row, button.customer-row {
  width: 100%;
  min-height: 60px;
  border-right: 0;
  border-left: 0;
  border-top: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  text-decoration: none;
}

a.customer-row:hover, button.customer-row:hover {
  color: var(--jade-dark);
}

.customer-info,
.product-info,
.color-info,
.line-meta {
  flex: 1;
  min-width: 0;
}

.customer-name,
.product-name {
  display: block;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.customer-detail,
.customer-meta,
.line-meta,
.color-code {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.customer-meta {
  flex: none;
  text-align: right;
}

.right-arrow {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  color: #718583;
}

.activity-row,
.sync-item {
  align-items: flex-start;
  font-size: 13px;
}

.activity-row .dot,
.sync-item .dot {
  margin-top: 6px;
}

.system-row {
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: 13px;
}

.empty,
.empty-state {
  padding: 32px 16px;
  color: var(--ink-soft);
  text-align: center;
}

.empty svg,
.empty-state svg {
  width: 28px;
  height: 28px;
  margin-bottom: 10px;
  color: #82958e;
}

.empty p:last-child,
.empty-state p:last-child {
  margin-bottom: 0;
}

.progress-track {
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4ece7;
}

.progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--jade);
  transition: width 150ms ease;
}

.progress-fill.warning { background: #a66d08; }
.progress-fill.danger { background: var(--danger); }
.progress-fill.success { background: #238164; }

.storage-indicator {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.storage-indicator .progress-track {
  flex: 1 1 100px;
}

/* Búsqueda, catálogo y pedido. */
.search-wrap {
  position: relative;
  min-width: 0;
}

.input,
.field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.field select,
.field textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #bdcbc5;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  line-height: 1.4;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.input::placeholder,
.field input::placeholder,
.field textarea::placeholder {
  color: #778a91;
  opacity: 1;
}

.input:hover,
.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #91aaa1;
}

.input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--jade-dark);
}

.input:disabled,
.field input:disabled,
.field select:disabled,
.field textarea:disabled {
  border-color: #dce4e0;
  background: #f0f3f1;
  color: #657971;
}

.input[aria-invalid="true"],
.field [aria-invalid="true"] {
  border-color: var(--danger);
}

.search-icon {
  position: absolute;
  top: 50%;
  left: 13px;
  display: inline-flex;
  width: 19px;
  height: 19px;
  color: #60777e;
  pointer-events: none;
  transform: translateY(-50%);
}

.search-icon svg {
  width: 19px;
  height: 19px;
}

.search-wrap .input,
.search-wrap input {
  padding-left: 42px;
}

.product-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: 76px;
  padding: 12px 0;
  border-bottom: 1px solid #edf1ee;
}

.product-row:last-child {
  border-bottom: 0;
}

.product-row.disabled {
  color: #687b78;
}

.product-thumb,
.image-preview {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  overflow: hidden;
  border: 1px solid #dce5df;
  border-radius: 9px;
  background: #eff3ed;
  color: #6b8279;
}

.product-thumb img,
.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-code {
  display: block;
  margin-bottom: 3px;
  color: var(--jade-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.product-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
}

.product-action {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.order-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
}

.qty,
.qty-input {
  font-variant-numeric: tabular-nums;
}

.qty {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 44px;
  color: var(--ink);
  font-weight: 750;
}

.qty-step {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--paper);
  color: var(--jade-dark);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
}

.qty-step:hover:not(:disabled) { background: var(--jade-pale); }
.qty-step:disabled { background: #edf0ee; color: #687b78; }

.qty-input {
  width: clamp(76px, calc(var(--quantity-width, 1ch) + 14px), calc(100vw - 132px));
  min-width: 76px;
  min-height: 44px;
  padding: 8px 4px;
  border: 1px solid #bdcbc5;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.qty-input:focus {
  border-color: var(--jade-dark);
}

.totals {
  display: grid;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.totals > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

/* Diálogo, variantes y formularios. */
.modal-backdrop {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(9 26 37 / 58%);
}

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow: hidden;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  background: #fff;
  box-shadow: var(--shadow-raised);
}

.modal-header,
.modal-footer {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
}

.modal-header {
  border-bottom: 1px solid var(--line);
}

.modal-title {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -.02em;
}

.modal-body {
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  overscroll-behavior: contain;
}

.modal-footer {
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
}

.variant-heading {
  margin: 22px 0 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.variant-heading:first-child {
  margin-top: 0;
}

.color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 9px 0;
  border-bottom: 1px solid #edf1ee;
}

.color-row:last-child {
  border-bottom: 0;
}

.color-swatch {
  display: inline-block;
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid rgb(20 38 58 / 22%);
  border-radius: 9px;
  background-color: #e8e5db;
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 35%);
}

.color-info {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.color-code {
  display: block;
  font-weight: 500;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.field textarea {
  min-height: 100px;
  resize: vertical;
}

.field small,
.field .subtle {
  font-size: 12px;
  font-weight: 400;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.checkbox-row input[type="checkbox"],
.checkbox-row input[type="radio"] {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--jade-dark);
}

.toggle {
  position: relative;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 52px;
  min-width: 52px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  appearance: none;
  cursor: pointer;
  vertical-align: middle;
}

.toggle::before {
  position: absolute;
  width: 42px;
  height: 24px;
  border: 1px solid #869995;
  border-radius: 999px;
  background: #a7b7b1;
  content: "";
  transition: background-color 150ms ease;
}

.toggle::after {
  position: absolute;
  left: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(0 0 0 / 20%);
  content: "";
  transition: transform 150ms ease;
}

.toggle.active::before,
.toggle[aria-checked="true"]::before,
.toggle[aria-pressed="true"]::before,
.toggle:checked::before {
  border-color: var(--jade-dark);
  background: var(--jade-dark);
}

.toggle.active::after,
.toggle[aria-checked="true"]::after,
.toggle[aria-pressed="true"]::after,
.toggle:checked::after {
  transform: translateX(18px);
}

.toggle:disabled,
.toggle.disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* Datos, filtros y mensajes. */
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  text-align: left;
}

.data-table th,
.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #e8eeea;
  vertical-align: middle;
}

.data-table th {
  background: #f5f7f4;
  color: #516970;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  color: var(--ink);
  font-size: 13px;
}

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

.data-table tbody tr:hover {
  background: #f8fbf8;
}

.pagination,
.filter-row,
.tabs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.pagination {
  justify-content: flex-end;
  margin-top: 16px;
  color: var(--ink-soft);
  font-size: 12px;
}

.pagination button,
.pagination a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
}

.filter-row {
  margin-bottom: 16px;
}

.filter-row .search-wrap {
  flex: 1 1 220px;
}

.chip {
  min-width: 44px;
  min-height: 44px;
  padding: 8px 14px;
  border-color: var(--line-strong);
  background: #fff;
  color: var(--ink-soft);
  cursor: pointer;
}

.chip:hover,
.chip.active,
.chip[aria-pressed="true"] {
  border-color: #8fc2b3;
  background: var(--jade-pale);
  color: #075e50;
}

.tabs {
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

.tab {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.tab:hover,
.tab.active,
.tab[aria-selected="true"],
.tab[aria-current="page"] {
  border-bottom-color: var(--jade);
  color: var(--jade-dark);
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  border: 1px solid #d5e4e1;
  border-radius: 9px;
  background: #f0f6f4;
  color: #345650;
  font-size: 13px;
  line-height: 1.5;
}

.notice svg {
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.notice-warn, .notice.warning {
  border-color: #ecd39a;
  background: var(--warning-bg);
  color: #704800;
}

.notice-error, .notice.danger {
  border-color: #efc9c5;
  background: var(--danger-bg);
  color: #8c2e30;
}

.notice-success, .notice.success {
  border-color: #c4e4d0;
  background: var(--success-bg);
  color: #175d47;
}

.notice-neutral {
  border-color: #d5e4e1;
  background: #f0f6f4;
  color: #345650;
}

.spinner {
  display: inline-block;
  flex: none;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: safeco-spin 800ms linear infinite;
}

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

.history-card {
  margin-bottom: 12px;
  padding: 16px;
}

.client-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow);
}

.client-initials {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  font-size: 17px;
}

.client-hero h1, .client-hero h2 {
  margin-bottom: 4px;
  letter-spacing: -.025em;
}

.client-hero p {
  margin-bottom: 0;
  color: var(--ink-soft);
}

.fab {
  position: fixed;
  z-index: 30;
  right: 18px;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 52px;
  min-height: 52px;
  padding: 12px 16px;
  border: 1px solid var(--jade-dark);
  border-radius: 999px;
  background: var(--jade-dark);
  color: #fff;
  box-shadow: 0 8px 24px rgb(12 102 89 / 25%);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.fab:hover {
  background: #084e44;
  color: #fff;
}

.image-preview {
  width: 100%;
  height: auto;
  min-height: 120px;
  aspect-ratio: 4 / 3;
}

.text-right { text-align: right; }
.subtle { color: var(--muted); }

@media (min-width: 600px) {
  .content {
    padding-right: 24px;
    padding-left: 24px;
  }

  .topbar {
    padding-right: 24px;
    padding-left: 24px;
  }

  .stat-grid {
    gap: 14px;
  }

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

@media (min-width: 900px) {
  .app-shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    align-items: start;
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    width: 248px;
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding: 24px 16px 18px;
    background: var(--sidebar);
    color: #d9e7e6;
  }

  .sidebar .brand {
    padding: 0 7px 4px;
  }

  .sidebar .nav-item {
    width: 100%;
    margin: 2px 0;
    background: transparent;
    color: #c4d7d8;
    font-size: 13px;
  }

  .sidebar .nav-item:hover {
    background: rgb(255 255 255 / 7%);
    color: #fff;
  }

  .sidebar .nav-item.active,
  .sidebar .nav-item[aria-current="page"] {
    border-color: rgb(119 211 187 / 16%);
    background: #1d4b49;
    color: #fff;
  }

  .sidebar .nav-item.active .nav-icon,
  .sidebar .nav-item[aria-current="page"] .nav-icon {
    color: #9ee6cf;
  }

  .sidebar .nav-count {
    background: #345a59;
    color: #e1f6ed;
  }

  .topbar {
    min-height: 68px;
    padding: 10px 32px;
  }

  .content {
    padding: 32px 32px 48px;
  }

  .demo-banner {
    padding-right: 32px;
    padding-left: 32px;
  }

  .bottom-nav,
  .mobile-only,
  .mobile-brand {
    display: none !important;
  }

  .desktop-only {
    display: initial !important;
  }

  .stat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 24px;
  }

  .stat-card {
    min-height: 155px;
    padding: 20px;
  }

  .grid-main-aside {
    grid-template-columns: minmax(0, 1.6fr) minmax(260px, 1fr);
    gap: 20px;
  }

  .panel {
    padding: 22px;
  }

  .page-header {
    margin-bottom: 28px;
  }

  .modal-backdrop {
    align-items: center;
    padding: 24px;
  }

  .modal {
    max-height: min(85vh, 850px);
    max-height: min(85dvh, 850px);
    border: 1px solid var(--line);
    border-radius: 16px;
  }

  .modal-footer {
    padding-bottom: 16px;
  }

  .fab {
    right: 28px;
    bottom: 28px;
  }
}

@media (min-width: 1300px) {
  .content {
    padding-right: 42px;
    padding-left: 42px;
  }
}

@media (max-width: 380px) {
  .content { padding-right: 12px; padding-left: 12px; }
  .topbar { padding-right: 12px; padding-left: 12px; }
  .stat-card { padding: 13px; }
  .customer-meta { font-size: 11px; }
  .modal-header, .modal-body, .modal-footer { padding-right: 16px; padding-left: 16px; }
}

/* En anchos extremos el título de página ya está en el contenido. */
@media (max-width: 359px) {
  .topbar { gap: 6px; }
  .breadcrumb { overflow: visible; }
  .breadcrumb > strong, .topbar-right .top-avatar, .topbar-right .header-divider { display: none; }
  .topbar-right { gap: 2px; }
  .topbar .status-pill { padding-inline: 6px; font-size: 10px; }
}

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

@media (forced-colors: active) {
  .btn, .tag, .badge, .status-pill, .chip, .color-swatch, .toggle::before {
    border: 1px solid ButtonText;
  }
  .tab.active, .nav-item.active, .bottom-nav .active {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}

/* Ajustes de lectura para las vistas conectadas a los datos de SAFECO OS. */
button.product-row, button.history-card { width: 100%; border: 0; border-bottom: 1px solid #edf1ee; background: transparent; color: inherit; text-align: left; }
button.product-row:hover:not(:disabled), button.history-card:hover { background: #f7faf8; }
.product-row .product-tags { margin-top: 0; }
.product-row .product-code { margin: 3px 0 0; color: #687b78; font-weight: 600; }
.product-row .product-action { color: var(--jade-dark); }
.system-row > span:nth-child(2), .sync-item > span:nth-child(2), .history-main { flex: 1; min-width: 0; }
.system-row b, .system-row small, .sync-item b, .sync-item small, .history-main b, .history-main small, .line-meta b, .line-meta small, .color-info b, .color-info small, .modal-product b, .modal-product small, .review-client b, .review-client small, .client-hero b, .client-hero small, .guide-step strong, .guide-step small { display: block; }
.system-row small, .sync-item small, .history-main small, .line-meta small, .color-info small, .modal-product small, .review-client small, .client-hero small, .guide-step small { margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 450; line-height: 1.4; }
.modal-product, .review-client, .client-hero { display: flex; align-items: center; gap: 12px; padding: 4px 0 16px; }
.modal-product > span:nth-child(2), .review-client > span:nth-child(2), .client-hero > span:nth-child(2) { flex: 1; }
.modal-instruction { margin: 4px 0 14px; color: var(--ink-soft); font-size: 13px; }
.variant-heading { display: flex; justify-content: space-between; gap: 10px; padding-top: 13px; }
.variant-heading small { color: var(--muted); font-weight: 500; }
.color-row .color-info { flex: 1 1 52px; min-width: 52px; padding-right: 0; }
.color-row .color-swatch, .product-thumb:not(:has(img)) { background-image: repeating-linear-gradient(40deg, transparent 0 2px, rgb(255 255 255 / 12%) 2px 3px), repeating-linear-gradient(130deg, transparent 0 3px, rgb(0 0 0 / 3%) 3px 4px); background-size: auto; }
.color-row .qty { white-space: nowrap; }
.capture-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.capture-top > div, .client-chip { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.client-chip { padding: 8px 11px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.client-chip-icon { display: inline-flex; color: var(--jade-dark); }
.client-chip > span:last-child { color: var(--muted); font-size: 12px; }
.line-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; border: 1px solid #c8d1ca; }
.line-qty { white-space: nowrap; font-weight: 750; }
.line-qty small { font-weight: 400; }
.totals { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 18px; font-size: 12px; }
.order-note label { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 10px; font-weight: 800; letter-spacing: .05em; }
.order-note label span { color: var(--muted); font-weight: 500; }
.order-note textarea { width: 100%; resize: vertical; margin-bottom: 12px; }
.readonly-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.btn.full { width: 100%; justify-content: center; }
.order-protect, .panel-footnote { display: flex; align-items: flex-start; gap: 6px; color: var(--muted); font-size: 11px; }
.panel-footnote { padding-top: 15px; }
.summary-badge { min-width: 28px; height: 28px; display: inline-grid; place-items: center; background: #eef4f0; border-radius: 50%; font-weight: 750; }
.empty-order { text-align: center; padding: 25px 8px; color: var(--muted); }
.empty-order span, .empty-order b { display: block; }
.empty-order b { color: var(--ink-soft); margin: 7px 0 2px; }
.empty-order p { margin: 0; font-size: 12px; }
button.history-card { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 14px 0; }
.history-icon, .guide-icon { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: var(--jade-dark); background: #e9f3ee; flex: none; }
.table-product { display: flex; align-items: center; gap: 10px; }
.table-product b, .table-product small { display: block; }
.table-product small { color: var(--muted); margin-top: 3px; }
.table-product .product-thumb { width: 42px; height: 42px; }
.guide-panel > p { color: var(--muted); font-size: 13px; }
.guide-icon { margin-bottom: 16px; }
.guide-step { display: flex; gap: 12px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid #edf1ee; }
.guide-step > b { color: var(--jade-dark); font-size: 11px; }
.guide-step > span { flex: 1; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 18px; }
.review-notes { padding: 12px 0; }
.review-notes p { color: var(--ink-soft); margin: 4px 0 0; font-size: 13px; }
#toast-root { position: fixed; z-index: 120; right: 20px; bottom: 22px; display: grid; gap: 8px; max-width: min(390px, calc(100vw - 32px)); }
.toast { padding: 12px 15px; border: 1px solid var(--line); border-radius: 9px; background: white; box-shadow: var(--shadow-raised); color: var(--ink); font-size: 13px; }
.toast.warning { border-color: #e4c887; background: #fff9ea; }
.toast.danger { border-color: #e7b1aa; background: #fff1ef; }
@media (max-width: 700px) { .capture-top { align-items: flex-start; flex-direction: column; } #toast-root { bottom: 86px; left: 16px; right: 16px; } }
.startup { min-height: 100vh; display:flex; flex-direction:column; gap: 12px; align-items:center; justify-content:center; padding:24px; text-align:center; color:var(--ink); }
.startup p { max-width: 340px; color:var(--muted); font-size:13px; }
.capture-tabs { margin: 4px 0 18px; }
.sequence-field { margin: 18px 0 8px; }
.sequence-suggestions { display:flex; flex-wrap:wrap; gap:6px; }
.sequence-suggestions button { min-height:44px; border-color:#cfe1d9; color:var(--jade-dark); background:#f5faf7; }
.sequence-examples { display:flex; flex-wrap:wrap; gap:8px; margin:14px 0; font-size:12px; }
.sequence-examples b { flex-basis:100%; color:var(--ink-soft); }
.sequence-examples span { padding:5px 8px; background:#f1f5f2; border-radius:5px; color:#31554b; font-family:ui-monospace,monospace; }

/* Reflujo de la UI existente: los datos externos pueden contener palabras largas. */
.page-subtitle, .panel-subtitle, .product-code, .client-chip, .client-hero,
.modal-title, .modal-product, .review-client, .review-notes, .system-row,
.sync-item, .history-main, .line-meta, .color-info, .notice, .toast,
.sequence-suggestions button, .sequence-examples span {
  overflow-wrap: anywhere;
}

.capture-top > div, .client-chip, .client-chip > b, .client-chip > span,
.modal-header > div, .modal-product > span:nth-child(2),
.review-client > span:nth-child(2), .client-hero > span:nth-child(2),
.system-row > span:nth-child(2), .sync-item > span:nth-child(2) {
  min-width: 0;
  max-width: 100%;
}

/* No dejar que los textos de estado o los controles de cantidad queden recortados. */
.system-row, .sync-item, .modal-product, .review-client, .color-row,
.variant-heading, .totals {
  flex-wrap: wrap;
}
.color-row .qty { max-width: 100%; }
.modal-header > div { flex: 1 1 0; }

/* Las cajas de los botones son objetivos medibles, no solo el texto visible. */
.demo-banner { flex-wrap: wrap; }
.demo-banner > span { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.demo-banner > button, .feature-link, .sequence-suggestions button {
  min-width: 44px;
  min-height: 44px;
}
.sequence-suggestions button { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
/* El diálogo completo puede desplazarse si su título, pie o teclado ocupan
   gran parte del viewport; ninguna sección queda aprisionada fuera del scroll. */
.modal {
  display: block;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.modal-body { overflow: visible; }
@media (max-height: 480px) {
  .modal {
    max-height: calc(100vh - 8px);
    max-height: calc(100dvh - 8px);
  }
}
@media (max-width: 359px) {
  .topbar { flex-wrap: wrap; }
  .breadcrumb { flex: 0 0 auto; }
  .topbar-right { flex: 1 1 auto; }
}

/* Los avisos actuales solo informan (no contienen acciones): no interceptan
   las pulsaciones de los controles que quedan detrás durante su aparición. */
#toast-root { pointer-events: none; }

/* V2: demostración e instrumentos, sin convertirlos en autorización. */
.metrics-panel { margin-top: 1.25rem; padding: 1.5rem; }
.metrics-panel form { display: grid; gap: .8rem; max-width: 48rem; }
.metrics-panel button, .demo-confirm-color { min-height: 44px; }
.demo-confirm-color { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; }
.demo-confirm-color input { width: 22px; height: 22px; }
[aria-invalid="true"] { outline: 2px solid #a52323; outline-offset: 2px; }

/* Les avis masqués ne doivent pas occuper d'espace ni être lus à tort. */
[data-update-notice][hidden] { display: none; }
[data-update-notice]:not([hidden]) { margin: 12px 20px 0; }
@media (max-width: 480px) { [data-update-notice]:not([hidden]) { margin: 10px 12px 0; } }

/* Propuesta para cargar DESPUÉS de public/styles.css. La propia barra es el
   contenedor: su ancho disponible refleja también el zoom CSS de la página. */
.bottom-nav {
  container-type: inline-size;
  flex-wrap: wrap;
}
.bottom-nav .nav-label {
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  font-size: 11px;
  line-height: 1.2;
}

/* En anchos estrechos, tres destinos en la primera fila y dos en la segunda.
   Se mantiene el texto completo, iconos y objetivos de al menos 44 CSS px. */
@container (max-width: 335px) {
  .bottom-nav .nav-item {
    flex: 1 0 33.333%;
    flex-direction: column;
    gap: 1px;
    min-height: 44px;
    padding: 2px 0;
  }
  .bottom-nav .nav-icon,
  .bottom-nav svg {
    width: 16px;
    height: 16px;
  }
  .bottom-nav .nav-label {
    flex: 0 1 auto;
    max-width: 100%;
  }
}

@media (max-width: 899px) {
  /* La barra de dos filas ocupa 97 px más la zona segura: dejarle espacio. */
  .content { padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }
  .fab { bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }

  /* Mantener una columna si dos tarjetas de catálogo no caben con un ancho
     suficiente; conservar dos columnas cuando sí caben. */
  .listing-stats {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, max(130px, calc((100% - 20px) / 2))), 1fr));
  }
}
@media (max-width: 700px) {
  #toast-root { bottom: calc(112px + env(safe-area-inset-bottom, 0px)); }
}

/* Espace commercial : actions essentielles, états utiles et reflujo sans recorte. */
.sidebar nav { margin-top: 0; }
.topbar { min-height: 50px; }
.demo-banner { align-items: center; padding-block: 8px; }
.demo-banner > span { flex: 1 1 0; }
.utility-status {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 18px;
  padding: 8px 16px 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.utility-status > span { min-width: 0; }
.utility-status [hidden] { display: none; }
.offline-warning { margin: 10px 0; }
.offline-warning[hidden] { display: none !important; }
.recovery-notice { margin: 12px 16px 0; }
.recovery-notice > div { min-width: 0; }
.recovery-notice p { margin: 5px 0 0; }
.recovery-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.modal-body .recovery-notice { margin: 16px 0 0; }
.page-header { margin-bottom: 18px; }
.page-title { font-size: clamp(24px, 4vw, 31px); }
.page-subtitle { margin-top: 5px; }
.panel { overflow: visible; }
.panel-header { margin-bottom: 12px; }
.search-wrap > svg {
  position: absolute;
  top: 50%;
  left: 13px;
  width: 19px;
  height: 19px;
  color: #60777e;
  pointer-events: none;
  transform: translateY(-50%);
}
.empty-compact { margin: 8px 0 0; color: var(--muted); }
.client-notes { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.client-notes p { margin: 4px 0 0; overflow-wrap: anywhere; }
.tabs { flex-wrap: wrap; overflow: visible; }
.capture-top { flex-wrap: wrap; }
.line-row { flex-wrap: wrap; }
.line-meta { flex: 1 1 100px; }
.line-qty { white-space: normal; overflow-wrap: anywhere; }
button.history-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 20px;
  gap: 4px 12px;
}
.history-card .history-icon { grid-column: 1; grid-row: 1 / span 2; }
.history-card .history-main { grid-column: 2; grid-row: 1; }
.history-card .tag { grid-column: 2; grid-row: 2; justify-self: start; text-align: left; }
.history-card .right-arrow { grid-column: 3; grid-row: 1 / span 2; }
.history-card .history-main small { overflow-wrap: anywhere; }
.bottom-nav { flex-wrap: nowrap; }
.bottom-nav .nav-item { flex: 1 1 0; min-width: 44px; min-height: 56px; padding: 5px 2px; }
.bottom-nav .nav-label { flex: 0 1 auto; overflow-wrap: normal; }
html { scroll-padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 899px) {
  .content { padding-bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  #toast-root { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
}
@media (min-width: 900px) {
  .utility-status { padding-inline: 32px; }
  .recovery-notice { margin-inline: 32px; }
  .modal-body .recovery-notice { margin-inline: 0; }
  .content { padding-top: 24px; }
}

.local-risk { margin: -8px 0 16px; color: var(--ink-soft); font-size: 12px; overflow-wrap: anywhere; }

/* Hiérarchie commerciale : la recherche et la saisie restent au premier plan. */
.device-menu { position: relative; flex: none; }
.device-menu > summary,
.technical-details > summary,
.sequence-help > summary {
  min-height: 44px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.device-menu > summary { display: flex; align-items: center; padding: 8px; list-style: none; }
.device-menu > summary::-webkit-details-marker { display: none; }
.device-menu > summary::after { content: '⌄'; margin-left: 6px; }
.device-menu > summary:hover, .technical-details > summary:hover, .sequence-help > summary:hover { color: var(--jade-dark); }
.device-menu-content {
  position: absolute;
  z-index: 2;
  top: 100%;
  right: 0;
  width: max-content;
  max-width: min(280px, calc(100vw - 32px));
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  box-shadow: var(--shadow-raised);
}
.device-menu:not([open]) .device-menu-content { display: none; }
.device-menu-content .btn { width: 100%; justify-content: flex-start; text-align: left; }
.technical-details { margin-top: 18px; border-top: 1px solid var(--line); }
.technical-details > summary, .sequence-help > summary { padding: 12px 0; }
.technical-details .metrics-panel { box-shadow: none; }
.sequence-help { margin-top: 8px; }
.sequence-help .sequence-examples { margin-top: 0; }
@media (max-width: 380px) {
  .device-menu > summary { font-size: 11px; }
}

/* Aviso secundario: el detalle se abre solo cuando se necesita. */
.update-compact { margin: 0 12px; color: var(--ink-soft); font-size: .75rem; }
.update-compact summary { width: fit-content; min-height: 40px; padding: 10px 4px; cursor: pointer; font-weight: 600; }
.update-compact p { max-width: 40rem; margin: 2px 4px 8px; line-height: 1.4; }
.update-compact[hidden] { display: none !important; }

/* États commerciaux : une seule commande compacte, sans bandeau permanent. */
.page-header > .page-heading { flex: 1 1 240px; min-width: 0; }
.heading-line { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.heading-line > .page-title { min-width: 0; }
.customer-panel .page-title { font-size: clamp(20px, 5.5vw, 26px); }
.customer-panel .page-header { margin-bottom: 12px; }
.compact-status { position: relative; flex: none; }
.compact-status > summary { display: flex; align-items: center; justify-content: center; gap: 2px; min-width: 44px; min-height: 44px; padding: 4px; border-radius: 8px; color: var(--ink-soft); cursor: pointer; list-style: none; }
.compact-status > summary::-webkit-details-marker { display: none; }
.compact-status > summary::marker { content: ''; }
.compact-status > summary::after { content: '⌄'; color: var(--ink-soft); font-size: 13px; line-height: 1; }
.compact-status[open] > summary::after { content: '⌃'; }
.compact-status > summary:hover { background: #f1f5f2; }
.status-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 17px; height: 20px; }
.status-icon[hidden] { display: inline-flex !important; visibility: hidden; }
[data-network-offline][hidden] { display: none !important; }
.status-offline[data-state="ready"] { color: #116c51; }
.status-offline[data-state="unverified"] { color: #765100; }
.status-offline[data-state="unavailable"] { color: #a52323; }
.status-update { color: #0c6659; }
.status-icon b { position: absolute; right: 0; bottom: 0; min-width: 10px; border-radius: 5px; background: #fff; font-size: 10px; font-weight: 800; line-height: 11px; text-align: center; }
.compact-status-detail { position: absolute; z-index: 20; top: 100%; right: 0; width: min(320px, calc(100vw - 48px)); padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: var(--shadow-raised); color: var(--ink); font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.compact-status-detail p { margin: 0 0 8px; }
.compact-status-detail p:last-child { margin-bottom: 0; }
.compact-status-detail [hidden] { display: none !important; }

/* Páginas del selector de productos: acciones táctiles sin desbordar. */
.product-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 0 4px;
  color: var(--ink-soft);
  font-size: 13px;
}

/* Selector de cantidades: conservar identificación y seguridad sin filas duplicadas. */
.modal-product-code { display:inline-block; margin-left:.35rem; font-size:.72rem; font-weight:600; color:var(--muted); overflow-wrap:anywhere; }
.compact-storage { margin:0 0 4px; font-size:.75rem; }

/* Liste commerciale : ouverture et actions de brouillon sont des boutons distincts. */
.commercial-order { display: flex; flex-wrap: wrap; align-items: center; gap: 0 12px; min-width: 0; border-bottom: 1px solid #edf1ee; }
.commercial-order:last-child { border-bottom: 0; }
.commercial-order-open { display: flex; flex: 1 1 260px; align-items: center; gap: 12px; min-width: 0; min-height: 72px; padding: 14px 0; border: 0; background: transparent; color: inherit; text-align: left; }
.commercial-order-open:hover { background: #f7faf8; }
.commercial-order-status { display: inline-flex; flex: none; align-items: center; gap: 5px; }
.order-draft, .order-checks, .order-alert { display: inline-flex; align-items: center; }
.order-draft, .order-checks { color: #656565; }
.order-checks { gap: 1px; }
.order-alert { color: #a52323; }
.commercial-order-actions { display: flex; flex-wrap: wrap; gap: 8px; max-width: 100%; margin-left: auto; padding: 0 0 8px; }
.commercial-order-actions .btn { min-height: 44px; }

.customer-search-row { display: flex; align-items: flex-start; gap: 8px; min-width: 0; }
.customer-search-row .dashboard-search { flex: 1 1 120px; min-width: 0; }
.customer-add { flex: 0 0 auto; min-height: 44px; white-space: nowrap; }
@media (max-width: 280px) { .customer-search-row { flex-wrap: wrap; } }

/* Chat contextuel : les actions sont des frères, jamais des boutons imbriqués. */
.customer-row-wrap, .product-row-wrap {
  display: flex;
  align-items: center;
  min-width: 0;
  border-bottom: 1px solid #edf1ee;
}
.customer-row-wrap:last-child, .product-row-wrap:last-child { border-bottom: 0; }
.customer-row-wrap .customer-row, .product-row-wrap .product-row {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  border-bottom: 0;
}
.chat-icon { flex: 0 0 44px; color: var(--jade-dark); }
.orders-shortcut { color: var(--ink-soft); }
.color-details { display: flex; flex: 1 1 130px; align-items: center; gap: 10px; min-width: 0; }
.color-details .color-info { min-width: 0; overflow-wrap: anywhere; }
.variant-heading { align-items: center; }
.variant-heading > span { min-width: 0; overflow-wrap: anywhere; }
.chat-backdrop { z-index: 110; }
.chat-context { margin: 16px 0; }
.chat-context > div { display: grid; grid-template-columns: minmax(0, 120px) minmax(0, 1fr); gap: 4px 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.chat-context dt { color: var(--muted); font-weight: 700; }
.chat-context dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.chat-verification { color: var(--ink-soft); font-size: 13px; }
.chat-modal .field { margin-bottom: 6px; }
.chat-page p { color: var(--ink-soft); }
.product-progress { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; min-width: 0; }
.product-progress .compact-storage { margin: 0; }
.product-progress .next-product { margin-left: auto; max-width: 100%; }
@media (max-width: 380px) {
  .chat-context > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .product-row-wrap .product-row { gap: 6px; }
  .product-row-wrap .product-action { min-width: 30px; }
}

@media (max-width: 899px) {
  #product-list, #modal-product-list { container: product-results / inline-size; }
  @container product-results (max-width: 262px) {
    .product-row-wrap { align-items: flex-start; }
    .product-row-wrap > .product-row { flex-wrap: wrap; gap: 6px; }
    .product-row-wrap > .product-row .product-info { flex: 0 0 100%; min-width: 0; order: 1; }
    .product-row-wrap > .product-row .product-action { margin-left: auto; }
    .product-row-wrap > .chat-icon { flex: 0 0 44px; width: 44px; min-width: 44px; height: 44px; min-height: 44px; margin-top: 12px; }
  }
}

/* Profil discret : cible tactile, options secondaires dans le dialogue. */
.profile-avatar { display:inline-flex; flex:none; align-items:center; justify-content:center; width:30px; height:30px; border:1px solid #d6e7e0; border-radius:50%; background:#e6f1eb; color:#155f52; }
.bottom-nav .profile-trigger { flex:0 0 56px; min-width:44px; min-height:56px; }
.bottom-nav .profile-trigger:focus-visible { outline-color:#075e50; outline-offset:-3px; }
.profile-label { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.sidebar .profile-trigger { display:flex; align-items:center; gap:10px; width:100%; min-height:48px; padding:6px 8px; border:0; border-radius:8px; background:transparent; color:#f6fbfa; font-weight:700; text-align:left; }
.sidebar .profile-trigger:hover { background:var(--sidebar-soft); }
.profile-identity { display:flex; align-items:center; gap:12px; min-width:0; margin-bottom:20px; }
.profile-identity .profile-avatar { width:44px; height:44px; }
.profile-identity p { margin:3px 0 0; color:var(--ink-soft); font-size:13px; }
.profile-actions { display:grid; gap:8px; }
.profile-actions .btn { justify-content:flex-start; min-height:44px; width:100%; white-space:normal; text-align:left; }
[data-profile-create-notice] { margin:12px 0 0; }
[data-profile-dialog] [hidden] { display:none !important; }
.profile-technical { margin-top:18px; border-top:1px solid var(--line); color:var(--ink-soft); font-size:13px; }
.profile-technical > summary { min-height:44px; padding:12px 0; font-weight:700; cursor:pointer; }
.profile-technical p { margin:0 0 9px; line-height:1.4; overflow-wrap:anywhere; }
