:root {
  --red: #c8102e;
  --red-dark: #9d0d25;
  --red-soft: #fff0f3;
  --red-border: #fecdd3;
  --ink: #0f172a;
  --ink-secondary: #334155;
  --muted: #64748b;
  --muted-light: #94a3b8;
  --line: #e2e8f0;
  --line-subtle: #f1f5f9;
  --panel: #ffffff;
  --canvas: #f8fafc;
  --success: #059669;
  --success-soft: #ecfdf5;
  --success-border: #a7f3d0;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --warn-border: #fde68a;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --danger-border: #fecaca;
  --info: #2563eb;
  --info-soft: #eff6ff;
  --brand: #c8102e;
  --brand-dark: #9d0d25;
  --brand-soft: #fff0f3;
  --brand-border: #fecdd3;
  --border: #e2e8f0;
  --border-subtle: #f1f5f9;
  --border-dark: #cbd5e1;
  --bg: #f8fafc;
  --card: #ffffff;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -4px rgba(15, 23, 42, 0.08), 0 4px 12px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 40px -8px rgba(15, 23, 42, 0.12);
  --shadow-card-hover: 0 10px 28px -4px rgba(15, 23, 42, 0.08), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* { box-sizing: border-box; }
[hidden]{display:none!important}

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

button {
  cursor: pointer;
  border: 0;
  background: transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

a {
  color: var(--red);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: 16px;
  z-index: 100;
  transform: translateY(-180%);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--line);
  transition: transform 0.15s ease;
}

.skip-link:focus {
  transform: none;
}

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

.eyebrow, #eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--muted);
}

.eyebrow-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Pantalla de acceso / login */
.access {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
  background: #fff;
}

.access-brand {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(145deg, #8a0c20 0%, #c8102e 50%, #e02444 100%);
  letter-spacing: 0.08em;
  padding: 40px;
  text-align: center;
  box-shadow: inset -10px 0 30px rgba(0, 0, 0, 0.1);
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: var(--radius-md);
  background: var(--red);
  color: #fff;
  font-weight: 900;
  font-size: 1.3rem;
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.3);
}

.access-brand .brand-mark {
  width: 80px;
  height: 80px;
  background: #fff;
  color: var(--red);
  font-size: 2.4rem;
  border-radius: var(--radius-xl);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.access-brand p {
  font-size: 2.2rem;
  font-weight: 900;
  margin: 20px 0 2px;
  letter-spacing: 0.12em;
}

.access-brand small {
  font-weight: 700;
  letter-spacing: 0.15em;
  opacity: 0.9;
  font-size: 0.85rem;
}

.access-card {
  width: min(450px, calc(100% - 48px));
  margin: auto;
  padding: 48px 40px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
}

.access-card h1 {
  font-size: 1.85rem;
  font-weight: 800;
  margin: 16px 0 8px;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.pilot-badge, .badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 12px;
  background: var(--red-soft);
  color: var(--red-dark);
  font-size: 0.76rem;
  font-weight: 800;
  border: 1px solid var(--red-border);
}

/* App Shell */
.app {
  min-height: 100vh;
  padding-left: 250px;
  display: flex;
  flex-direction: column;
}

/* Sidebar */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 250px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  padding: 24px 16px 20px;
  background: #fff;
  border-right: 1px solid var(--line);
  box-shadow: 1px 0 10px rgba(15, 23, 42, 0.02);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 10px 24px;
  border-bottom: 1px solid var(--line-subtle);
  margin-bottom: 16px;
}

.brand div {
  display: flex;
  flex-direction: column;
}

.brand strong {
  letter-spacing: 0.12em;
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--ink);
}

.brand small {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 12px 12px 4px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 2px;
}

nav button, .nav-parent-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 0;
  background: transparent;
  color: #475569;
  text-align: left;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-weight: 650;
  font-size: 0.92rem;
  min-height: 44px;
  width: 100%;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #64748b;
  transition: color 0.15s ease, transform 0.15s ease;
}

nav button:hover, nav button:focus-visible, .nav-parent-btn:hover, .nav-parent-btn:focus-visible {
  background: #f1f5f9;
  color: var(--ink);
}

nav button:hover .nav-icon, nav button:focus-visible .nav-icon, .nav-parent-btn:hover .nav-icon {
  color: var(--ink);
}

nav button[aria-current="page"], .nav-parent-btn[aria-current="page"] {
  background: var(--red-soft);
  color: var(--red);
  font-weight: 750;
  position: relative;
  box-shadow: inset 3px 0 0 var(--red);
}

nav button[aria-current="page"] .nav-icon, .nav-parent-btn[aria-current="page"] .nav-icon {
  color: var(--red);
}

.nav-parent-btn .nav-chevron {
  margin-left: auto;
  width: 14px;
  height: 14px;
  color: #94a3b8;
  flex-shrink: 0;
  transition: transform 0.2s ease, color 0.2s ease;
}

.nav-group.open .nav-parent-btn .nav-chevron {
  transform: rotate(180deg);
  color: var(--red);
}

.nav-sub-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding-left: 14px;
  margin-left: 20px;
  border-left: 2px solid var(--line-subtle);
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, margin 0.2s ease;
}

.nav-group.open .nav-sub-items {
  max-height: 280px;
  opacity: 1;
  margin-top: 2px;
  margin-bottom: 6px;
  border-color: var(--red-border);
}

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: #64748b;
  text-align: left;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-weight: 550;
  font-size: 0.82rem;
  min-height: 30px;
  width: 100%;
  cursor: pointer;
  transition: all 0.12s ease;
}

.nav-sub-item:hover {
  background: #f8fafc;
  color: var(--ink);
  transform: translateX(2px);
}

.nav-sub-item .sub-bullet {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.nav-sub-item:hover .sub-bullet {
  background: var(--ink);
}

.nav-sub-item.active {
  background: var(--red-soft);
  color: var(--red);
  font-weight: 750;
}

.nav-sub-item.active .sub-bullet {
  background: var(--red);
  transform: scale(1.3);
}

.session-card {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: auto;
  padding: 14px 10px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
  border-radius: var(--radius-md);
}

.session-card > span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: #ffe4e8;
  color: var(--red-dark);
  font-weight: 800;
  font-size: 0.95rem;
}

.session-card div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.session-card strong {
  font-size: 0.88rem;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-card small {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.logout {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--danger);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  margin-top: 8px;
  width: 100%;
}

.logout .nav-icon {
  color: var(--danger);
}

.logout:hover, .logout:focus-visible {
  background: var(--danger-soft);
  color: #991b1b;
}

/* Topbar */
.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 34px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title-wrap {
  display: flex;
  flex-direction: column;
}

.topbar h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.topbar #refresh {
  margin-left: auto;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--ink-secondary);
  transition: all 0.15s ease;
}

.icon-button:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.btn-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

#menu {
  display: none;
}

/* Main view container */
main {
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: 30px 34px 60px;
  flex: 1;
}

#view {
  animation: viewEnter 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes viewEnter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Mensajes y feedback */
.message {
  margin-bottom: 20px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-size: 0.92rem;
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: 10px;
}

.message.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: var(--danger-border);
}

.message.warning {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: var(--warn-border);
}

.message.success {
  background: var(--success-soft);
  color: var(--success);
  border-color: var(--success-border);
}

/* Layout Grids */
.grid {
  display: grid;
  gap: 22px;
}

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

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

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.card h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

/* Stat Cards (KPIs) */
.stat {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-left: 4px solid var(--red);
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.stat small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat strong {
  display: block;
  margin: 10px 0 4px;
  font-size: 1.85rem;
  font-weight: 850;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.stat span.muted {
  font-size: 0.82rem;
}

.stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stat-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

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

.stat-usd {
  border-left-color: var(--success);
}

.stat-icon-usd {
  background: var(--success-soft);
  color: var(--success);
}

.stat-pen {
  border-left-color: var(--info);
}

.stat-icon-pen {
  background: var(--info-soft);
  color: var(--info);
}

.stat-pending {
  border-left-color: var(--warn);
}

.stat-icon-pending {
  background: var(--warn-soft);
  color: var(--warn);
}

/* Acciones rápidas */
.quick-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 24px 0;
}

/* Botones */
.primary, .secondary, .danger-button, .btn, .primary-btn, .ghost-btn {
  min-height: 44px;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-weight: 700;
  font-size: 0.92rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.primary, .primary-btn, button.primary-btn {
  border: 1px solid var(--red);
  background: var(--red);
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(200, 16, 46, 0.25);
}

.primary:hover, .primary-btn:hover, button.primary-btn:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.35);
  transform: translateY(-1px);
}

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.secondary:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
  transform: translateY(-1px);
}

.ghost-btn {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-secondary);
}

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

.compact-btn {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
}

.danger-button {
  border: 1px solid var(--danger-border);
  background: #fff;
  color: var(--danger);
}

.danger-button:hover {
  background: var(--danger-soft);
}

.full {
  width: 100%;
}

/* ==========================================================================
   COMPONENTES GLOBALES DE VISTAS (KPIs, CABECERAS, FILTROS, BUSCADORES)
   ========================================================================== */

/* Cabeceras de Vistas */
.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.view-title {
  margin: 2px 0 0 0;
  font-size: 1.65rem;
  font-weight: 850;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.view-subtitle {
  margin: 4px 0 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.view-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Cuadrículas KPI Corporativas */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border-dark);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-dark);
}

.kpi-title, .kpi-label {
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: block;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 850;
  color: var(--ink);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 2px 0;
}

.kpi-card small.muted {
  font-size: 0.78rem;
  color: var(--muted);
  display: block;
}

/* Filtros de Píldoras Segmentadas */
.pills-nav, .filter-pills {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  flex-wrap: wrap;
}

.pill-btn {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pill-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.7);
}

.pill-btn.active {
  background: #ffffff;
  color: var(--red);
  font-weight: 750;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.1);
}

/* Barra de Búsqueda Integrada */
.search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 240px;
  flex: 1;
  max-width: 380px;
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.search-input-wrap input[type="search"] {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #ffffff;
  font-size: 0.88rem;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input-wrap input[type="search"]:focus {
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

/* Formularios */
label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 0.88rem;
  font-weight: 650;
  margin-bottom: 18px;
}

input, select, textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  padding: 10px 14px;
  font-size: 0.94rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 3px solid rgba(200, 16, 46, 0.18);
  outline-offset: 2px;
  border-color: var(--red);
}

input[type="radio"], input[type="checkbox"] {
  width: 18px !important;
  min-height: unset !important;
  height: 18px !important;
  accent-color: var(--red);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

:is(#new-client-form, #edit-client-form) .client-person-phone { grid-column: 1 / -1; }

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

/* Líneas de material en Nueva Venta */
.line-head {
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.line-head h3 {
  margin: 0 0 4px;
}

.line-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  transition: all 0.2s ease;
}

.line-item:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.07);
}

.line-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.btn-pick-stock {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  color: #334155;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-pick-stock:hover {
  background: #f1f5f9;
  border-color: var(--red);
  color: var(--red);
}

.stock-linked-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: 6px;
  font-size: 0.82rem;
}

.btn-unlink-stock {
  border: none;
  background: transparent;
  color: #047857;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.line-item-body {
  display: grid;
  grid-template-columns: minmax(220px, 2.2fr) repeat(4, minmax(85px, 1fr)) minmax(170px, 1.4fr);
  gap: 14px;
  align-items: end;
}

.line-item-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: #475569;
}

.line-item-body input, .line-item-body select {
  min-height: 42px;
  padding: 8px 12px;
  font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}

.line-item-body select[name="surcharge"] {
  min-width: 160px;
}

@media (max-width: 1024px) {
  .line-item-body {
    grid-template-columns: 1fr 1fr;
  }
}

/* Caja de total */
.total-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding: 20px 24px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.total-box > span {
  font-weight: 700;
  color: #475569;
  font-size: 1.05rem;
}

.total-box strong {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.total-box small {
  flex-basis: 100%;
  text-align: right;
  font-size: 0.82rem;
}

/* Tablas */
.toolbar {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.toolbar label {
  margin: 0;
  flex: 1;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 740px;
  font-size: 0.9rem;
}

th, td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-subtle);
  text-align: left;
}

th {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

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

tbody tr {
  transition: background-color 0.12s ease;
}

tbody tr:hover {
  background: #f8fafc;
}

td[data-label="Total"], td[data-label="Recibido"], td[data-label="Saldo"], td[data-label="Importe"], td[data-label="Precio"] {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.table-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--red);
  font-weight: 750;
  font-size: 0.82rem;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.table-button:hover {
  background: var(--red-soft);
  border-color: var(--red-border);
  box-shadow: var(--shadow-sm);
}

/* Empty states */
.empty {
  padding: 56px 24px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.empty-icon-wrap {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--muted);
}

.empty h2 {
  margin: 0 0 6px;
  font-size: 1.25rem;
  font-weight: 750;
  color: var(--ink);
}

.empty p {
  margin: 0 auto 20px;
  max-width: 440px;
}

/* Skeleton loader */
.skeleton {
  height: 96px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, #edf0f4 25%, #f8f9fb 50%, #edf0f4 75%);
  background-size: 200% 100%;
  animation: loading 1.4s infinite;
}

/* Status Badges */
.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: #f1f5f9;
  color: #475569;
}

.status.paid {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.status.pending {
  background: var(--warn-soft);
  color: var(--warn);
  border: 1px solid var(--warn-border);
}

.status.credit {
  background: var(--info-soft);
  color: var(--info);
  border: 1px solid var(--info-border);
}

.status.error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}

/* Formulario de cobro compacto Fase 3 */
.payment-controls-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.payment-controls-row label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.payment-controls-row select {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  font-size: 0.95rem;
}

.payment-history-compact {
  margin: 16px 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-payment-history {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.payment-history-modal,
.receipt-versions-modal {
  max-width: 720px;
  width: 90vw;
}

.btn-receipt-versions {
  font-size: 12px;
  padding: 4px 10px;
}

.payment-history-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 16px;
}

.history-summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  padding: 12px;
  background: var(--surface-subtle, #f8f9fa);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.history-summary-strip > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-summary-strip small {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.history-summary-strip strong {
  font-size: 1rem;
}

.payment-component-detail {
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}

.payment-component-detail:last-child {
  border-bottom: none;
}

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

.receipt-action-row .receipt-link {
  text-decoration: none;
  font-size: 0.85rem;
  padding: 5px 12px;
}

.receipt-reason-text {
  display: block;
  margin: 4px 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.receipt-version-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  margin: 8px 0;
  background: #ffffff;
}

.receipt-version-item.is-current {
  background: #f0fdf4;
  border-color: #86efac;
}

.receipt-version-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.receipt-version-badge {
  margin-left: 6px;
  font-size:12px;
}

.receipt-version-meta {
  margin: 6px 0;
  font-size: 13px;
}

.receipt-version-reason {
  margin: 4px 0;
  font-size: 13px;
  color: #b45309;
}

.receipt-version-actions {
  margin-top: 8px;
}

.receipt-version-actions .button {
  font-size: 12px;
  padding: 4px 10px;
}

.component-receipt-field {
  grid-column: 1 / -1;
  margin-top: 8px;
  padding: 12px;
  background: #f1f4f8;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.component-receipt-field.is-hidden {
  display: none !important;
}

.secondary-workflow-panel {
  border-top: 1px dashed var(--line);
  margin-top: 24px;
  padding-top: 16px;
  opacity: 0.95;
}

.payment-mode {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.payment-mode label {
  margin: 0;
  position: relative;
}

.payment-mode input {
  position: absolute;
  opacity: 0;
}

.payment-mode span {
  display: grid;
  place-items: center;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  font-weight: 650;
  transition: all 0.15s ease;
}

.payment-mode input:checked + span {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red);
  font-weight: 800;
  box-shadow: 0 0 0 1px var(--red);
}

.component {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  background: #fafbfc;
}

.component h3 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.component .field-grid {
  grid-template-columns: 1fr 1fr;
}

.notice {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--warn-soft);
  color: #785600;
  font-size: 0.9rem;
  border: 1px solid var(--warn-border);
}

.conversion-note {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--info-soft);
  color: var(--info);
  font-size: 0.9rem;
  border: 1px solid var(--info-border);
  font-weight: 550;
}

.history {
  margin: 26px 0;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.payment-entry {
  margin: 12px 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fcfcfd;
  box-shadow: var(--shadow-sm);
}

.payment-entry > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.payment-entry small {
  display: block;
  color: var(--muted);
  line-height: 1.6;
}

.payment-entry p {
  margin: 8px 0;
}

/* Dialog nativo modal */
dialog {
  width: min(860px, calc(100% - 32px));
  max-height: calc(100vh - 40px);
  padding: 0;
  border: 1px solid var(--border-dark);
  border-radius: 18px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.28);
  overflow: hidden;
  background: #ffffff;
}

dialog[open] {
  animation: dialogZoomIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dialogZoomIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

dialog.modal, .detail-dialog {
  border: 1px solid var(--border-dark);
  border-radius: 18px;
  box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.28);
  background: #ffffff;
  color: var(--ink);
}

dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(5px);
}

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 26px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

#dialog-body {
  padding: 24px 26px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.fact {
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.fact small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.fact strong {
  font-size: 1.05rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin-bottom: 4px;
}

.section-heading p {
  margin: 0;
}

.table-subtitle {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.82rem;
}

.payment-filters {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(130px, 1fr) minmax(150px, 1fr);
}

/* Animaciones y medios */
@keyframes loading {
  to {
    background-position: -200% 0;
  }
}

@media(max-width: 980px) {
  .grid.cols-3 {
    grid-template-columns: 1fr 1fr;
  }
  .app {
    padding-left: 0;
  }
  .sidebar {
    transform: translateX(-102%);
    box-shadow: var(--shadow-lg);
    transition: transform 0.25s ease;
  }
  .sidebar.open {
    transform: none;
  }
  #menu {
    display: grid;
  }
  .topbar {
    padding: 0 20px;
  }
  main {
    padding: 24px 20px;
  }
  .field-grid {
    grid-template-columns: 1fr;
  }
  .line-item {
    grid-template-columns: 1fr 90px 120px 44px;
  }
  .access {
    grid-template-columns: 1fr;
  }
  .access-brand {
    display: none;
  }
}

@media(max-width: 760px) {
  .grid.cols-3, .grid.cols-2 {
    grid-template-columns: 1fr;
  }
  .topbar {
    height: 70px;
  }
  .topbar h1 {
    font-size: 1.25rem;
  }
  main {
    padding: 20px 16px;
  }
  .card {
    padding: 18px;
    border-radius: var(--radius-md);
  }
  .line-item {
    grid-template-columns: 1fr 1fr;
  }
  .line-item > :first-child {
    grid-column: 1 / -1;
  }
  .line-item .icon-button {
    margin: 0;
    align-self: end;
  }
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .payment-mode {
    grid-template-columns: 1fr;
  }
  .facts {
    grid-template-columns: 1fr;
  }
  .access-card {
    padding: 32px 24px;
  }
  .form-actions {
    flex-direction: column-reverse;
  }
  .form-actions button {
    width: 100%;
  }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: #fff;
    box-shadow: var(--shadow-sm);
    margin-bottom: 16px;
  }
  table {
    display: table;
    width: 100%;
    min-width: 660px;
    border-collapse: collapse;
  }
  table thead {
    display: table-header-group;
    position: static;
    width: auto;
    height: auto;
    clip-path: none;
  }
  table tbody {
    display: table-row-group;
  }
  table tr {
    display: table-row;
    margin-bottom: 0;
    padding: 0;
    border: none;
    border-bottom: 1px solid var(--line);
    background: transparent;
    box-shadow: none;
  }
  table th {
    display: table-cell;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: #f8fafc;
    border-bottom: 2px solid var(--line);
    white-space: nowrap;
  }
  table td {
    display: table-cell;
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid var(--line-subtle);
    text-align: left;
    white-space: normal;
  }
  table td::before {
    display: none !important;
  }
  table td.row-action {
    display: table-cell;
    border-top: none;
    margin-top: 0;
    padding-top: 12px;
    text-align: right;
  }
  .section-heading {
    flex-direction: column;
  }
  .section-heading .primary {
    width: 100%;
  }
  .payment-filters {
    display: flex;
    flex-direction: column;
  }
}

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

@media print {
  .sidebar, .topbar, .quick-actions, .form-actions {
    display: none !important;
  }
  .app {
    padding: 0;
  }
  main {
    padding: 0;
  }
  .card {
    box-shadow: none;
  }
}

/* --- REDISEÑO FASE A (PROTOTIPO) --- */

.app { padding-left: 0; flex-direction: row; }
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; margin-left: 250px; }
.sidebar { justify-content: flex-start; padding: 16px 12px; }
.sidebar-top { margin-bottom: 24px; }
.brand { border-bottom: 0; padding: 8px; margin-bottom: 0; gap: 14px; }
.brand-copy { display: flex; flex-direction: column; }
.sidebar-primary { display: flex; align-items: center; justify-content: center; gap: 10px; background: var(--red); color: #fff; border-radius: var(--radius-md); padding: 14px; font-weight: 750; font-size: 0.95rem; margin: 0 8px 24px; box-shadow: 0 4px 12px rgba(200, 16, 46, 0.25); }
.sidebar-primary:hover { background: var(--red-dark); transform: translateY(-1px); }
.sidebar-primary .nav-icon { color: #fff; }
nav button[disabled] { opacity: 0.4; cursor: not-allowed; }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 8px; }
.help-card { background: var(--ink); color: #fff; padding: 16px; border-radius: var(--radius-md); display: flex; gap: 12px; align-items: flex-start; }
.help-card span { color: #fecdd3; }
.help-card div { display: flex; flex-direction: column; gap: 2px; }
.help-card strong { font-size: 0.85rem; font-weight: 750; }
.help-card small { font-size: 0.72rem; opacity: 0.8; line-height: 1.3; }
.settings-link { display: flex; align-items: center; gap: 12px; padding: 12px 14px; color: var(--muted); font-weight: 650; font-size: 0.92rem; border-radius: var(--radius-md); }
.settings-link:hover { background: #f1f5f9; color: var(--ink); }
.prototype-label { display: flex; align-items: center; gap: 8px; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.08em; color: var(--muted-light); padding: 8px 4px; margin-top: 8px; }
.prototype-label span { width: 6px; height: 6px; background: var(--red); border-radius: 50%; display: inline-block; }
.topbar { justify-content: space-between; padding: 0 34px; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.global-search { display: flex; align-items: center; background: var(--canvas); border-radius: var(--radius-lg); padding: 0 16px; height: 48px; flex: 1; max-width: 480px; gap: 12px; border: 1px solid var(--line); transition: border-color 0.2s ease, background 0.2s ease; }
.global-search:focus-within { background: #fff; border-color: var(--red-border); box-shadow: 0 0 0 4px var(--red-soft); }
.search-icon { width: 18px; height: 18px; color: var(--muted); }
.global-search input { border: 0; background: transparent; flex: 1; outline: none; font-size: 0.95rem; }
.global-search kbd { background: #fff; border: 1px solid var(--line); padding: 2px 6px; border-radius: 4px; font-size: 0.7rem; color: var(--muted); font-family: monospace; }
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.warehouse-context { display: flex; flex-direction: column; gap: 2px; min-width: 160px; color: var(--ink); font-size: 0.7rem; font-weight: 750; }
.warehouse-context select { width: 100%; min-height: 36px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink); padding: 4px 8px; font: inherit; font-size: 0.8rem; }
.warehouse-context select:focus-visible { outline: 3px solid var(--red-border); outline-offset: 2px; }
.notification-btn { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: #fff; border: 1px solid var(--line); color: var(--ink-secondary); }
.notification-btn:hover { background: var(--canvas); color: var(--ink); }
.notification-dot { position: absolute; top: 10px; right: 12px; width: 8px; height: 8px; background: var(--red); border-radius: 50%; border: 2px solid #fff; }
.role-switcher { display: flex; align-items: center; gap: 12px; }
.inventory-scope-note { margin: 0 0 14px; padding: 10px 14px; background: var(--red-soft); border: 1px solid var(--red-border); border-radius: 10px; color: var(--ink); font-size: 0.85rem; }
.inventory-result-count { margin: 4px 0 12px; color: var(--muted); font-size: 0.82rem; }
.inventory-group-control { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 0.83rem; font-weight: 650; }
.inventory-group-control input { width: 18px; height: 18px; accent-color: var(--red); }
.inventory-groups { display: grid; gap: 10px; }
.inventory-group { border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden; }
.inventory-group > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; cursor: pointer; }
.inventory-group > summary:hover, .inventory-group > summary:focus-visible { background: var(--canvas); }
.inventory-group-summary, .inventory-group-totals { display: flex; flex-direction: column; gap: 4px; }
.inventory-group-summary small, .inventory-group-totals small { color: var(--muted); line-height: 1.4; }
.inventory-group-totals { text-align: right; white-space: nowrap; }
.inventory-product-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; flex-wrap: wrap; }
.inventory-group-detail { padding: 0 12px 12px; }
.inventory-lot { border-top: 1px solid var(--line); }
.inventory-lot > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px; cursor: pointer; }
.inventory-lot-detail { padding-bottom: 12px; }
.inventory-cost-price-grid { align-items: start; }
.inventory-cost-price-grid > label { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.inventory-cost-price-grid > label > input { margin: 0; }
.inventory-cost-price-grid .field-hint { margin: 0; }
@media (max-width: 600px) {
  .inventory-lot > summary { align-items: flex-start; flex-direction: column; }
}
.price-book-panel { display: grid; gap: 16px; }
.price-book-toolbar { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; }
.price-book-toolbar label { min-width: min(100%, 260px); flex: 1 1 260px; }
.price-book-toolbar input { width: 100%; }
.price-book-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); gap: 14px; }
.price-book-card { min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px; background: #fff; }
.price-book-card[hidden] { display: none; }
.price-book-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.price-book-card h3, .price-book-card p { margin: 0; }
.price-book-card-head h3 { font-size: 1rem; }
.price-book-lot { font-size: .88rem; }
.price-book-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.price-book-values > div { border: 1px solid var(--line); border-radius: 10px; padding: 12px; min-width: 0; }
.price-book-values small, .price-book-values strong { display: block; }
.price-book-values strong { overflow-wrap: anywhere; font-size: .95rem; }
.price-pending { color: var(--muted); }
.price-book-card details p { overflow-wrap: anywhere; margin-top: 8px; }
.price-book-edit { justify-self: start; min-height: 44px; }
.price-book-pagination { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 10px; }
.price-book-pagination button { min-height: 44px; }

.sale-physical-actions { display:flex;flex-wrap:wrap;gap:10px;border-top:1px solid var(--line);padding-top:16px;margin-top:20px; }
.sale-cutting-order-status { flex-basis:100%; font-size:13px; font-weight:600; }
.location-picker-field { min-width:0;display:grid;gap:7px; }
.location-picker-field > label { margin:0; }
.location-combobox { position:relative;min-width:0; }
.location-combobox .location-search-input { width:100%;min-width:0;min-height:44px;margin:0; }
.location-search-list { position:absolute;left:0;right:0;top:calc(100% + 4px);max-height:220px;overflow:auto;z-index:40;background:white;border:1px solid #ccd5e3;border-radius:8px;box-shadow:0 8px 24px #16243b22;padding:4px; }
.location-list-above .location-search-list { top:auto;bottom:calc(100% + 4px); }
.location-search-list[hidden],.location-search-status[hidden] { display:none; }
.location-search-list button { display:block;width:100%;min-height:44px;margin:0;padding:10px;text-align:left;border:0;border-radius:5px;background:white;color:#24344b;font:inherit;font-size:13px;line-height:1.4;overflow-wrap:anywhere; }
.location-search-list button:hover,.location-search-list button[aria-selected=true] { background:#fff0f3;color:#b5092b; }
.location-search-input:focus-visible { outline:2px solid #c8102e;outline-offset:2px; }
.location-search-status { color:#7f3e14;font-size:12px;line-height:1.5; }
.sale-physical-actions button { min-height:44px; }
.cut-commercial-context { border:1px solid var(--line);border-radius:12px;background:#f8fafc;padding:18px;margin-bottom:18px; }
.cut-context-heading { display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;color:var(--muted);font-size:12px; }
.cut-mode-badge { display:inline-block;color:#174c98;background:#edf4ff;border:1px solid #d8e5f9;border-radius:6px;padding:5px 9px;font-size:12px;font-weight:700;width:fit-content; }
.cut-commercial-context h3 { margin:12px 0;font-size:17px;overflow-wrap:anywhere; }
.cut-commercial-context h3 small { display:block;color:var(--muted);font-size:12px;margin-top:4px;font-weight:400; }
.cut-commercial-context dl { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin:0; }
.cut-commercial-context dt { font-size:12px;color:var(--muted); }
.cut-commercial-context dd { margin:5px 0 0;font-size:13px;font-weight:600;overflow-wrap:anywhere; }
.cut-destination-rule { border-left:3px solid #c8102e;padding-left:12px;margin:16px 0 0;font-size:13px;line-height:1.6; }
.origin-cut-form { display:grid;gap:16px; }
.origin-cut-form [data-origin-total] { background:#f3f6fa;padding:12px;border-radius:8px;font-variant-numeric:tabular-nums; }
.origin-cut-form .cut-commercial-context { margin-bottom:0; }
@media(max-width:600px) { .cut-commercial-context dl { grid-template-columns:1fr; } .cut-commercial-context { padding:14px; } .sale-physical-actions button { flex:1 1 180px; } }
.commercial-quote-layout, .commercial-list { display: grid; gap: 16px; min-width: 0; }
.commercial-quote-intro, .commercial-list-head, .commercial-quote-section, .commercial-card-head, .commercial-card-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.commercial-quote-form { display: grid; gap: 20px; max-width: 1080px; }
.quote-composer { width:100%; max-width:1080px; }
.quote-composer-header { display:grid; grid-template-columns:minmax(0,1fr) minmax(240px,340px); align-items:start; gap:16px 24px; padding-bottom:20px; margin-bottom:20px; border-bottom:1px solid var(--line); }
.quote-composer-title { min-width:0; }
.quote-composer-header h2 { margin:0 0 8px; }
.quote-composer-header .muted { font-size:13px; margin:0; max-width:65ch; }
.quote-composer-header label { margin:0; min-width:0; }
.quote-composer-header select { width:100%; min-height:44px; }
.quote-composer-loading { grid-column:1/-1; margin:0; font-size:13px; color:var(--red); }
.commercial-quote-form.quote-composer > .quote-composer-header { margin-bottom:0; }
.cut-finished-location { margin:16px 0; padding:16px; border:1px solid var(--line); border-radius:12px; min-width:0; }
.cut-finished-location legend { font-weight:700; font-size:14px; }
.cut-finished-location .muted { font-size:12px; margin:10px 0 0; }
@media(max-width:700px) { .quote-composer-header { grid-template-columns:minmax(0,1fr); gap:16px; } }
.commercial-quote-form h2, .commercial-quote-section h3, .commercial-list h2, .commercial-list-card h3 { margin: 0; }
.commercial-quote-fields, .commercial-extra-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 12px; }
.commercial-client-field { display: flex; flex-direction: column; min-width: 0; }
.commercial-quote-fields label, .commercial-extra-grid label, .commercial-line > label, .commercial-segment label { min-width: 0; }
.commercial-quote-fields select, .commercial-extra-grid input, .commercial-line select, .commercial-segment input { width: 100%; }
.commercial-currency-note { display: grid; gap: 4px; align-content: start; }
.commercial-currency-note small { line-height: 1.4; }
.commercial-quote-section { align-items: end; border-top: 1px solid var(--line); padding-top: 16px; }
.commercial-quote-section p { margin: 5px 0 0; max-width: 70ch; }
.commercial-lines { display: grid; gap: 12px; }
.commercial-line { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.commercial-line > * { min-width: 0; max-width: 100%; }
.commercial-line .badge { white-space: normal; overflow-wrap: anywhere; }
.commercial-line .field-label-text { white-space: normal; overflow-wrap: anywhere; min-width: 0; }
.commercial-segments { min-width: 0; grid-template-columns: minmax(0, 1fr); }
.commercial-line .commercial-segment { min-width: 0; }
.commercial-line legend { padding: 0 6px; font-weight: 700; }
.commercial-segments { display: grid; gap: 10px; }
.commercial-segment { display: flex; gap: 10px; align-items: flex-end; }
.commercial-segment label { flex: 1; margin-bottom: 0 !important; }
.commercial-segment input { width: 100%; min-height: 46px; height: 46px; }
.commercial-segment button[data-remove-segment] {
  height: 46px;
  min-height: 46px;
  margin: 0;
  padding: 0 18px;
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}
.commercial-line-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.commercial-segment button, .commercial-line-actions button, .commercial-quote-intro button, .commercial-list-head button, .commercial-card-footer button, .commercial-actions button { min-height: 44px; }
.commercial-line-subtotal { margin: 0; overflow-wrap: anywhere; }
.commercial-design-option { min-width: 0; display: grid; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.commercial-design-option legend { padding: 0 6px; font-weight: 700; }
.commercial-design-toggle { display: flex; align-items: flex-start; gap: 10px; font-weight: 650; }
.commercial-design-toggle input { flex: none; width: 20px; height: 20px; margin-top: 2px; }
.commercial-design-option p { margin: 0; }
.commercial-design-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 12px; }
.commercial-design-fields label { min-width: 0; }
.commercial-design-fields input { width: 100%; }
.commercial-list-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.commercial-list-card { display: grid; gap: 10px; min-width: 0; }
.commercial-list-card p { margin: 0; }
.commercial-list-card h3 { overflow-wrap: anywhere; }
.commercial-pagination { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; }
.commercial-pagination button { min-height: 44px; }
.commercial-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.commercial-detail-lines { display: grid; gap: 10px; margin: 12px 0; }
.commercial-detail-line { display: grid; gap: 4px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-wrap: anywhere; }
.installation-detail { display: grid; gap: 18px; min-width: 0; }
.installation-detail h3, .installation-detail h4 { margin: 0 0 8px; }
.installation-milestones { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 10px; }
.installation-milestone { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.installation-milestone.done { border-color: #7bb798; background: #f2faf5; }
.installation-milestone span { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.installation-section { border-top: 1px solid var(--line); padding-top: 16px; display: grid; gap: 12px; }
.installation-section > p { margin: 0; }
.kitchen-design-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.kitchen-design-heading p { margin: 0; max-width: 70ch; }
.kitchen-design-versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.kitchen-design-versions li { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.kitchen-design-versions li > div { min-width: 0; display: grid; gap: 4px; }
.kitchen-design-versions span { color: var(--muted); overflow-wrap: anywhere; }
.kitchen-design-download { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; text-decoration: none; }
.kitchen-design-upload { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 12px; align-items: end; padding: 14px; border: 1px dashed var(--line); border-radius: 10px; }
.kitchen-design-upload label { min-width: 0; }
.kitchen-design-upload select, .kitchen-design-upload input { width: 100%; }
.kitchen-design-upload small, .kitchen-design-upload .message { grid-column: 1 / -1; }
.kitchen-design-upload button { min-height: 44px; }
.installation-stone-group { display: grid; gap: 10px; border: 1px solid var(--line); padding: 14px; border-radius: 10px; }
.installation-stone-group > p { margin: 0; }
.installation-reconcile, .installation-extra { display: grid; gap: 7px; border: 1px solid var(--line); border-radius: 10px; padding: 12px; overflow-wrap: anywhere; }
.installation-extra-form { display: grid; gap: 12px; }
.installation-assignment { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; border-radius: 9px; background: #f5f7fa; padding: 10px; }
.installation-assignment small { flex-basis: 100%; }
.installation-assignment-form, .installation-transfer-form, #installation-complete-form, #installation-conformity-form { display: grid; gap: 12px; }
.installation-piece-list { display: grid; gap: 10px; }
.installation-piece { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.installation-piece label { min-width: 0; }
.installation-piece input, .installation-piece select { width: 100%; }
.installation-piece button { grid-column: 1 / -1; justify-self: start; }
.installation-form-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.installation-section button, .installation-piece button { min-height: 44px; }
.adhesive-section { gap: 14px; }
.installation-adhesive-details > summary span { margin-inline-start:8px; }
.installation-adhesive-body { display:grid; gap:12px; }
.installation-adhesive-body > p { margin:0; }
.adhesive-list { display: grid; gap: 7px; margin: 0; padding-left: 22px; }
.adhesive-list li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; }
.adhesive-list li span { display: block; color: var(--muted); font-size: .9rem; }
.adhesive-private { display: grid; gap: 10px; }
.adhesive-private h4, .adhesive-form h4, .adhesive-action h4 { margin: 0; }
.adhesive-private-row { display: flex; justify-content: space-between; align-items: start; gap: 12px; flex-wrap: wrap; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.adhesive-private-row > div:first-child { display: grid; gap: 4px; min-width: 0; overflow-wrap: anywhere; }
.adhesive-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.adhesive-actions a { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 8px 12px; text-decoration: none; border-radius: 8px; }
.adhesive-form, .adhesive-action form { display: grid; gap: 12px; padding: 14px; background: #f8f9fb; border: 1px solid var(--line); border-radius: 10px; }
.adhesive-cost-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.adhesive-cost-fields[hidden], .adhesive-action[hidden] { display: none; }
.critical-warning { border: 1px solid #b86c1e; border-left: 4px solid #b86c1e; border-radius: 9px; background: #fff7ed; color: #693b12; padding: 12px; line-height: 1.45; }
.critical-acknowledgment { display: flex; align-items: flex-start; gap: 10px; font-weight: 600; line-height: 1.45; }
.critical-acknowledgment input { flex: none; width: 20px; height: 20px; margin-top: 2px; }
.conformity-preview { display: grid; gap: 8px; max-width: 480px; }
.conformity-preview[hidden] { display: none; }
.conformity-preview img { display: block; max-width: 100%; max-height: 320px; object-fit: contain; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
@media (max-width: 600px) {
  .installation-piece { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .installation-piece button { grid-column: 1 / -1; }
  .installation-form-actions button { flex: 1 1 100%; }
  .adhesive-cost-fields { grid-template-columns: 1fr; }
  .adhesive-actions, .adhesive-actions a, .adhesive-actions button { width: 100%; }
}
@media (max-width: 600px) {
  .commercial-segment { align-items: stretch; flex-direction: column; }
  .commercial-segment button, .commercial-segment button[data-remove-segment], .commercial-quote-section > button, .commercial-card-footer button { width: 100%; align-self: stretch; }
  .commercial-actions { display: grid; }
  .kitchen-design-download, .kitchen-design-upload button { width: 100%; }
}
.inventory-ingress-prices { border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 14px 0; }
.inventory-ingress-prices h4 { margin: 0 0 8px; }
.inventory-ingress-prices .field-grid { margin: 12px 0; }
@media (max-width: 600px) {
  .price-book-values { grid-template-columns: minmax(0, 1fr); }
  .price-book-card-head { flex-direction: column; }
  .price-book-pagination button { flex: 1 1 120px; }
}
.inventory-catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.inventory-catalog-section { min-width: 0; }
.inventory-catalog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.inventory-catalog-heading h3 { margin: 0 0 4px; }
.inventory-catalog-heading p { margin: 0; }
.inventory-catalog-heading button { min-height: 44px; flex: none; }
.inventory-catalog-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 480px; overflow-y: auto; }
.inventory-catalog-list li { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; overflow-wrap: anywhere; }
.inventory-catalog-list strong { color: var(--ink); }
.inventory-catalog-list small, .inventory-catalog-empty { color: var(--muted); line-height: 1.4; }
.inventory-catalog-empty { margin: 0; padding: 20px 8px; }
.inventory-catalog-footnote { margin-top: 14px; }
.role-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 1rem; text-transform: uppercase; }
.role-info { display: flex; flex-direction: column; }
.role-info strong { font-size: 0.9rem; font-weight: 750; color: var(--ink); line-height: 1.2; }
.role-info small { font-size:12px; color: var(--muted); font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
.mobile-only { display: none; }

@media(max-width: 980px) {
  .inventory-catalog-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main-wrapper {
    margin-left: 0 !important;
  }
  .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    width: 270px !important;
    transform: translateX(-105%) !important;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
    box-shadow: var(--shadow-lg) !important;
    z-index: 9999 !important;
  }
  .sidebar.open {
    transform: translateX(0) !important;
  }
  .mobile-only {
    display: grid !important;
  }
  #menu {
    display: grid !important;
  }
  .topbar {
    padding: 0 16px !important;
  }
  .global-search {
    max-width: 320px;
  }
  .quick-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .home-workspace {
    grid-template-columns: 1fr !important;
  }
}

@media(max-width: 640px) {
  .inventory-catalog-grid { grid-template-columns: 1fr; }
  .inventory-catalog-heading { align-items: center; }
  .warehouse-context { min-width: 120px; max-width: 145px; }
  .warehouse-context span { font-size: 0.62rem; }
  .role-info { display: none; }
  .inventory-group > summary { align-items: flex-start; flex-direction: column; gap: 8px; }
  .inventory-group-totals { flex-direction: row; gap: 8px; text-align: left; }
}

@media(max-width: 640px) {
  .global-search kbd {
    display: none !important;
  }
  .global-search {
    max-width: 180px;
  }
  .role-info {
    display: none !important;
  }
  .quick-grid {
    grid-template-columns: 1fr !important;
  }
  .cutting-meta-grid {
    grid-template-columns: 1fr !important;
  }
}
.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; }
.minimal-home { max-width: 1200px; margin: 0 auto; }
.home-welcome { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 40px; }
.home-date { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); display: block; margin-bottom: 8px; }
.home-welcome h1 { font-size: 2.2rem; font-weight: 850; letter-spacing: -0.03em; margin: 0 0 6px; color: var(--ink); }
.home-welcome p { margin: 0; color: var(--muted); font-size: 1.05rem; }
.quick-section { margin-bottom: 32px; }
.home-section-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 16px; }
.home-section-head span { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); display: block; margin-bottom: 4px; }
.home-section-head h2 { font-size: 1.25rem; font-weight: 750; margin: 0; color: var(--ink); }
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.quick-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; display: flex; align-items: center; gap: 16px; text-align: left; box-shadow: var(--shadow-sm); }
.quick-card:hover { border-color: #cbd5e1; box-shadow: var(--shadow); transform: translateY(-2px); }
.quick-card:disabled { opacity: 0.6; }
.quick-icon { width: 48px; height: 48px; border-radius: var(--radius-md); display: grid; place-items: center; flex-shrink: 0; }
.quick-red { background: var(--red-soft); color: var(--red); }
.quick-blue { background: var(--info-soft); color: var(--info); }
.quick-amber { background: var(--warn-soft); color: var(--warn); }
.quick-green { background: var(--success-soft); color: var(--success); }
.quick-card span { display: flex; flex-direction: column; flex: 1; }
.quick-card strong { font-size: 0.95rem; font-weight: 750; color: var(--ink); }
.quick-card small { font-size: 0.75rem; color: var(--muted); }
.home-workspace { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; margin-bottom: 32px; }
.home-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); display: flex; flex-direction: column; }
.home-card-head { padding: 24px 24px 16px; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1px solid var(--line-subtle); }
.count-badge { background: var(--red-soft); color: var(--red); font-weight: 800; font-size: 0.85rem; padding: 4px 12px; border-radius: 999px; }
.today-tasks button { display: flex; align-items: center; gap: 16px; width: 100%; padding: 16px 24px; border-bottom: 1px solid var(--line-subtle); text-align: left; border-radius: 0; }
.today-tasks button:last-child { border-bottom: none; }
.today-tasks button:hover { background: #f8fafc; }
.task-symbol { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: #f1f5f9; color: var(--muted); flex-shrink: 0; }
.task-symbol svg { width: 18px; height: 18px; }
.task-red { background: var(--red-soft); color: var(--red); }
.task-amber { background: var(--warn-soft); color: var(--warn); }
.task-blue { background: var(--info-soft); color: var(--info); }
.task-green { background: var(--success-soft); color: var(--success); }
.task-copy { display: flex; flex-direction: column; flex: 1; }
.task-copy strong { font-size: 0.95rem; font-weight: 650; color: var(--ink); }
.task-copy small { font-size: 0.8rem; color: var(--muted); }
.home-card-footer { padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; color: var(--red); font-weight: 700; font-size: 0.85rem; }
.home-card-footer:hover { background: var(--red-soft); border-bottom-left-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg); }
.agenda-list { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.agenda-list > div { display: flex; gap: 16px; align-items: flex-start; }
.agenda-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.dot-blue { background: var(--info); }
.dot-green { background: var(--success); }
.dot-amber { background: var(--warn); }
.dot-red { background: var(--red); }
.agenda-list span { display: flex; flex-direction: column; flex: 1; }
.agenda-list strong { font-size: 1.1rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.agenda-list small { font-size: 0.75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

/* Stock Picker & Reservation Styles */
.stock-linked-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 6px;
}
.stock-linked-badge button {
  background: transparent;
  border: none;
  color: #065f46;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
}
.btn-pick-stock {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-pick-stock:hover {
  background: #f1f5f9;
  border-color: var(--line-dark);
}
.tag-reserved-slab {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #1e293b;
}

/* Workshop & Cutting Queue Styles */
.cutting-order-card {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--border, #dce3ee);
  border-radius: 16px;
  background: #fff;
}
.cutting-order-heading, .cutting-order-toolbar, .cutting-order-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.cutting-order-identity, .cutting-item-info { min-width: 0; }
.cutting-order-heading h3 { margin: 0 0 6px; font-size: 17px; }
.cutting-order-heading p, .cutting-item-info p { margin: 0; overflow-wrap: anywhere; }
.cutting-order-heading p span, .cutting-order-toolbar, .cutting-item-info small { color: #56677f; font-size: 13px; }
.cutting-order-heading p span { display: inline-block; white-space: nowrap; }
.cutting-order-sale { display:block;font-size:12px;color:#56677f;margin-top:5px;overflow-wrap:anywhere; }
.cutting-order-progress { padding:16px 0 0; }
.cutting-order-progress > div { display:flex;justify-content:space-between;align-items:center;gap:12px;font-size:12px;color:#56677f;margin-bottom:9px; }
.cutting-order-progress strong { font-size:12px;color:#24344b;white-space:nowrap; }
.cutting-order-progress progress { display:block;appearance:none;width:100%;height:5px;border:0;border-radius:5px;overflow:hidden;background:#edf0f5;accent-color:#c8102e; }
.cutting-order-progress progress::-webkit-progress-bar { background:#edf0f5;border-radius:5px; }
.cutting-order-progress progress::-webkit-progress-value { background:#c8102e;border-radius:5px; }
.cutting-order-progress progress::-moz-progress-bar { background:#c8102e;border-radius:5px; }
.cutting-order-card .cutting-order-toolbar { display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:16px 0; }
.cutting-order-card .cutting-order-toolbar a,.cutting-order-card .cutting-order-toolbar button { min-width:0;min-height:48px;width:100%;padding:10px 8px;margin:0;display:flex;align-items:center;justify-content:center;text-align:center;font-size:13px;font-weight:600;line-height:1.35;white-space:normal; }
.cutting-order-card .cutting-order-materials { border-top:1px solid #e4e9f0;margin-top:4px; }
.cutting-order-card .cutting-order-materials summary { min-height:44px;padding:14px 0 2px;font-size:13px;color:#37485f; }
.cutting-order-card .cutting-order-heading { align-items:flex-start;gap:12px; }
.cutting-order-card .cutting-order-heading .status { flex-shrink:0;font-size:11px;padding:6px 10px; }
.cutting-order-toolbar .cutting-pdf-link { width: auto; margin: 0; white-space: nowrap; }
.cutting-order-materials summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
.cutting-order-materials summary:focus-visible { outline: 2px solid #c8102e; outline-offset: 3px; }
.cutting-order-items { border-top: 1px solid #e4e9f0; }
.cutting-order-item { padding: 16px 0; border-bottom: 1px solid #e4e9f0; }
.cutting-order-item:last-child { border-bottom: 0; padding-bottom: 0; }
.cutting-item-info strong span { font-size: 12px; font-weight: 400; color: #56677f; margin-left: 8px; }
.cutting-item-info small { display: block; margin-top: 5px; overflow-wrap: anywhere; }
.cutting-item-info .cutting-item-plan { color: #1a293f; }
.cutting-item-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; flex-shrink: 0; }
@media (max-width: 600px) {
  .cutting-order-card { padding: 16px; }
  .cutting-order-heading { align-items: flex-start; }
  .cutting-order-toolbar, .cutting-order-item { align-items: flex-start; flex-direction: column; gap: 12px; }
  .cutting-item-actions { flex-direction: row; flex-wrap: wrap; align-items: center; width: 100%; }
  .cutting-item-actions button { flex: 1; }
}
.cutting-grid {
  display: grid;
  align-items: start;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 20px;
  margin-top: 20px;
}
.cutting-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cutting-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.cutting-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--line-subtle);
  padding-bottom: 12px;
}
.cutting-card-head h3 {
  margin: 0 0 4px 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
}
.cutting-card-head p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.cutting-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  background: #f8fafc;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  border: 1px solid #e2e8f0;
}
.cutting-meta-item small {
  display: block;
  font-size:12px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 2px;
}
.cutting-meta-item strong {
  font-size: 0.92rem;
  color: var(--ink);
  font-weight: 750;
}
.cutting-dimensions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-md);
  color: var(--brand-dark);
}
.cutting-dimensions small {
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
}
.cutting-dimensions strong {
  font-size: 1.1rem;
  font-weight: 850;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.cutting-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}
.cutting-pdf-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
}
.cutting-pdf-link:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.cutting-actions button {
  flex: 1;
}

/* Remnant Input Builder */
.remnant-builder {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 16px;
}
.remnant-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr auto;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 10px;
}

/* Module Tabs */
.module-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 20px;
  width: fit-content;
}
.module-tab-btn {
  background: transparent;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.15s ease;
}
.module-tab-btn:hover {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.03);
}
.module-tab-btn.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.tab-badge {
  background: #f1f5f9;
  color: #475569;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.module-tab-btn.active .tab-badge {
  background: #fdf2f8;
  color: #9d174d;
}

/* Caballete Grid & Cards */
.caballete-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 20px;
  margin-top: 18px;
}
.caballete-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
  transition: all 0.2s ease;
}
.caballete-card:hover {
  transform: translateY(-2px);
  border-color: #cbd5e1;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}
.caballete-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.caballete-title {
  font-size: 1.15rem;
  font-weight: 850;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.01em;
}
.caballete-zone {
  font-size: 0.74rem;
  color: #64748b;
  text-transform: uppercase;
  font-weight: 750;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 4px;
}
.caballete-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  background: #f8fafc;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid #edf2f7;
}
.caballete-stat-item small {
  display: block;
  font-size:12px;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 750;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}
.caballete-stat-item strong {
  font-size: 1.1rem;
  font-weight: 850;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.btn-filter-by-loc {
  width: 100%;
  padding: 9px 14px;
  font-size: 0.84rem;
  font-weight: 700;
  border-radius: 9px;
  margin-top: auto;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: var(--ink);
  transition: all 0.15s ease;
}
.btn-filter-by-loc:hover {
  background: #f8fafc;
  border-color: var(--red);
  color: var(--red);
}

/* Rate Widget */
.rate-indicator-widget {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.rate-badge-active {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
}
.rate-badge-warning {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
}
.btn-link {
  background: none;
  border: none;
  color: var(--brand);
  text-decoration: underline;
  padding: 0;
  font-size: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn-link:hover {
  color: var(--brand-dark, #8a0c20);
}

/* Yield Bar */
.yield-container {
  margin: 14px 0;
  background: #f8fafc;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.yield-bar {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  margin-top: 6px;
}
.yield-cut {
  background: var(--brand);
}
.yield-remnant {
  background: #3b82f6;
}
.yield-legend {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--muted);
}
.yield-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 4px;
}

/* Dynamic dialogs & modal content */
.dialog-content {
  padding: 24px;
  color: var(--ink);
}
.dialog-content h3 {
  margin: 0 0 8px 0;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.dialog-content p.muted {
  margin: 0 0 16px 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}

/* Verificación física: el consentimiento debe leerse y tocarse con comodidad. */
.measure-verification-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.measure-verification-dialog .dialog-content {
  padding: clamp(18px, 4vw, 28px);
}

.measure-verification-dialog .dialog-content h2 {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: clamp(1.15rem, 3vw, 1.4rem);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.measure-verification-dialog .field-grid {
  gap: 0 16px;
}

.measure-verification-dialog .verify-measure-confirm {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 4px 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #f8fafc;
  font-size: 0.88rem;
  line-height: 1.5;
  cursor: pointer;
}

.measure-verification-dialog .verify-measure-confirm:focus-within {
  outline: 3px solid var(--red-dark);
  outline-offset: 2px;
}

.measure-verification-dialog .verify-measure-confirm input {
  margin-top: 2px;
}

.measure-verification-dialog .dialog-actions {
  flex-wrap: wrap;
  margin-top: 18px;
}

@media (max-width: 640px) {
  .measure-verification-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .measure-verification-dialog .field-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .measure-verification-dialog .dialog-actions {
    flex-direction: column-reverse;
  }

  .measure-verification-dialog .dialog-actions button {
    width: 100%;
    min-height: 44px;
  }
}

/* Tabular numerals & typography polish for numbers */
td, .fact strong, .stat strong, .caballete-stat-item strong, .agenda-list strong, #sale-total, .total-box strong, .batch-banner-input {
  font-variant-numeric: tabular-nums;
}

/* Batch slab intake banner */
.batch-banner {
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}
.batch-banner-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.batch-banner-title {
  font-weight: 800;
  color: var(--brand-dark);
  font-size: 0.95rem;
  display: block;
}
.batch-banner-desc {
  color: var(--muted);
  font-size: 0.82rem;
  display: block;
  margin-top: 2px;
}
.batch-banner-input {
  width: 80px;
  font-size: 1.15rem;
  font-weight: 800;
  text-align: center;
  padding: 6px 8px;
  border: 1.5px solid var(--brand-border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--brand-dark);
}
.batch-banner-helper {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--brand-dark);
  font-weight: 600;
}

/* Dispatch, Delivery & Custody Styles */
.dispatch-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.dispatch-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid var(--line-subtle);
  margin-bottom: 20px;
}
.dispatch-tab-btn {
  padding: 10px 18px;
  font-weight: 700;
  font-size: 0.9rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 0;
}
.dispatch-tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.dispatch-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dispatch-card:hover {
  border-color: #cbd5e1;
  box-shadow: var(--shadow);
}
.dispatch-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-subtle);
}
.dispatch-card-title {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dispatch-card-title h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.dispatch-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}
.custody-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-ready {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}
.badge-locked {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}
.badge-custody {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}
.custody-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.88rem;
}
.custody-table th {
  background: #f8fafc;
  padding: 8px 12px;
  text-align: left;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.custody-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-subtle);
}
.sig-canvas-box {
  background: #fcfdfe;
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
  position: relative;
  margin: 12px 0;
}
#sig-canvas {
  touch-action: none;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  cursor: crosshair;
  display: block;
  margin: 0 auto;
  max-width: 100%;
}
.sig-canvas-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* Printable Delivery Act Modal / Sheet */
.dispatch-act-dialog { width: min(850px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.dispatch-act-dialog .dispatch-act-sheet { max-width: 100%; padding: 24px; font-size: 12px; overflow-wrap: anywhere; }
.dispatch-act-dialog .act-brand { display:flex; align-items:center; gap:12px; min-width:0; }
.dispatch-act-logo { width:64px; height:64px; object-fit:contain; flex:none; }
.dispatch-act-dialog .act-brand h2 { font-size:17px; }
.dispatch-act-dialog .act-header { gap:16px; border-color:var(--red); margin-bottom:14px; padding-bottom:12px; }
.dispatch-act-dialog .act-info-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; margin-bottom:14px; }
.dispatch-act-dialog .act-info-block { min-width:0; }
.dispatch-act-dialog .act-info-block small,.dispatch-act-dialog .act-info-block strong,.dispatch-act-dialog .act-info-block span { display:block; }
.dispatch-act-dialog .act-info-block small { color:#64748b; font-size:10px; margin-bottom:3px; }
.dispatch-act-dialog .act-section-title { font-size:12px; margin:16px 0 7px; }
.dispatch-material-group { margin-bottom:10px; }
.dispatch-material-group h3 { font-size:12px; margin:0; padding:7px 9px; background:#f1f5f9; border:1px solid #dbe3ee; border-bottom:0; }
.dispatch-act-dialog .act-table { width:100%; border-collapse:collapse; table-layout:fixed; }
.dispatch-act-dialog .act-table th,.dispatch-act-dialog .act-table td { padding:6px 8px; border-bottom:1px solid #dbe3ee; vertical-align:top; font-size:11px; }
.dispatch-act-dialog .act-table th { background:#f8fafc; text-align:left; font-size:10px; white-space:normal; overflow-wrap:anywhere; }
dialog.dispatch-act-dialog .dispatch-act-sheet .act-table th,dialog.dispatch-act-dialog .dispatch-act-sheet .act-table td { padding:6px 8px; font-size:11px; }
dialog.dispatch-act-dialog .dispatch-act-sheet .act-table th { font-size:10px; white-space:normal; overflow-wrap:normal; }
.dispatch-act-dialog abbr { text-decoration:none; }
.dispatch-act-dialog .act-table small { display:block; font-size:9px; color:#64748b; margin-top:3px; overflow-wrap:anywhere; }
.dispatch-pieces-table th:first-child { width:53%; }
.dispatch-pieces-table th:nth-child(2) { width:32%; }
.dispatch-pieces-table td:nth-child(2) { white-space:nowrap; }
.dispatch-pieces-table th:last-child,.dispatch-pieces-table td:last-child { text-align:right; }
.dispatch-act-dialog .act-custody-table th:first-child { width:55%; }
.dispatch-act-dialog .act-custody-table th:not(:first-child),.dispatch-act-dialog .act-custody-table td:not(:first-child) { text-align:right; }
.dispatch-act-dialog .act-complete-badge,.dispatch-act-dialog .act-custody-notice { padding:8px 0; font-size:11px; }
.dispatch-act-dialog .act-signatures { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:24px; margin-top:18px; }
.dispatch-act-dialog .act-sig-box { min-width:0; }
.dispatch-act-dialog .act-sig-role { display:block; min-height:28px; font-size:9px; }
.dispatch-act-dialog .act-sig-area { height:80px; min-height:80px; display:flex; align-items:center; justify-content:center; border-bottom:1px solid #94a3b8; margin-bottom:6px; overflow:hidden; }
.dispatch-act-dialog .act-sig-preview-img { display:block; width:auto; height:auto; max-width:100%; max-height:68px; object-fit:contain; }
.dispatch-act-dialog .act-sig-area .act-dispatcher-badge { min-height:68px; max-height:68px; box-sizing:border-box; }
.dispatch-act-dialog .act-paper-evidence img { max-width:100%; max-height:200px; object-fit:contain; }
@media (max-width:600px) {
  .dispatch-act-dialog .dispatch-act-sheet { padding:14px; }
  .dispatch-act-dialog .act-header { flex-wrap:wrap; gap:10px; }
  .dispatch-act-dialog .act-code-box { text-align:left; }
  .dispatch-act-dialog .act-info-grid { grid-template-columns:1fr; gap:8px; }
  .dispatch-act-dialog .act-table th,.dispatch-act-dialog .act-table td { padding:5px 4px; font-size:10px; }
  dialog.dispatch-act-dialog .dispatch-act-sheet .act-table th,dialog.dispatch-act-dialog .dispatch-act-sheet .act-table td { padding:5px 4px; font-size:10px; }
  .dispatch-act-dialog .act-custody-table th:first-child { width:46%; }
  .dispatch-act-dialog .act-signatures { gap:12px; }
  .dispatch-act-dialog [data-close-dialog] { flex:0 0 auto; white-space:nowrap; padding-inline:14px; }
}
@media print {
  html:has(dialog.dispatch-act-dialog[open]),body:has(dialog.dispatch-act-dialog[open]) { background:#fff !important; }
  .dispatch-act-dialog .act-header,.dispatch-act-dialog .act-info-grid,.dispatch-act-dialog .act-signatures,.dispatch-act-dialog .act-table tr { break-inside:avoid; }
  .dispatch-act-dialog .act-table thead { display:table-header-group; }
  .dispatch-act-dialog .act-info-grid { grid-template-columns:repeat(3,minmax(0,1fr)); }
  .dispatch-act-dialog .act-header { flex-wrap:nowrap; }
  .dispatch-act-dialog .act-code-box { text-align:right; }
  .dispatch-act-dialog .act-table th,.dispatch-act-dialog .act-table td { font-size:9pt; }
}

.dispatch-act-sheet {
  background: #fff;
  padding: 32px;
  border-radius: var(--radius-md);
  color: #0f172a;
  max-width: 720px;
  margin: 0 auto;
}
.act-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 16px;
  margin-bottom: 20px;
}
.act-brand h2 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--brand);
}
.act-brand p {
  margin: 2px 0 0;
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 500;
}
.act-code-box {
  text-align: right;
}
.act-code-box .act-code {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
  display: block;
}
.act-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  background: #f8fafc;
  padding: 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 0.88rem;
}
.act-meta-item strong {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}
.act-sig-preview {
  max-height: 80px;
  border-bottom: 1px solid #0f172a;
  display: block;
  margin: 8px 0 4px;
}
.act-footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 36px;
  text-align: center;
}
.act-sig-slot {
  border-top: 1px solid #94a3b8;
  padding-top: 8px;
  font-size: 0.82rem;
  color: #475569;
}

@media print {
  body * {
    visibility: hidden;
  }
  .dispatch-act-sheet, .dispatch-act-sheet * {
    visibility: visible;
  }
  .dispatch-act-sheet {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    margin: 0;
    padding: 20px;
    box-shadow: none;
  }
  .no-print {
    display: none !important;
  }
}

/* Client Directory & Profile Styles */
.badge-dni {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
}
.badge-ruc {
  background: #fdf2f8;
  color: #9d174d;
  border: 1px solid #fbcfe8;
  font-size:12px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.04em;
}
.client-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.client-meta-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.client-meta-box strong {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
  font-weight: 750;
}
.client-meta-box span {
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.client-stat-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
  transition: all 0.15s ease;
}
.client-stat-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}
.client-stat-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 750;
  letter-spacing: 0.04em;
}
.client-stat-value {
  font-size: 1.35rem;
  font-weight: 850;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin: 2px 0;
}
.modal-tabs {
  display: flex;
  gap: 8px;
  background: #f1f5f9;
  padding: 5px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  margin: 16px 0 14px 0;
}
.modal-tab-btn {
  flex: 1;
  padding: 8px 16px;
  font-size: 0.86rem;
  font-weight: 700;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.modal-tab-btn:hover {
  color: var(--ink);
}
.modal-tab-btn.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.modal-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 20px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 14px;
  text-align: center;
  color: #64748b;
  font-size: 0.9rem;
}
.field-label-text {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.req {
  color: var(--red);
  font-weight: 800;
  margin-left: 2px;
}
.client-warning-banner {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 4px solid #f59e0b;
  color: #92400e;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  margin: 10px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.client-picker-box {
  background: #fcfdfe;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 16px;
}
.client-selected-badge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 8px;
}
.client-autocomplete-wrap {
  position: relative;
}
.client-autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
  max-height: 250px;
  overflow-y: auto;
  margin-top: 4px;
}
.client-autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s ease;
}
.client-autocomplete-item:hover, .client-autocomplete-item.focused {
  background: #f8fafc;
}
.client-autocomplete-item:last-child {
  border-bottom: none;
}

.line-item-search-row { display: flex; align-items: flex-end; gap: 12px; flex: 1; min-width: 0; flex-wrap: wrap; }
.stock-autocomplete-wrap { position: relative; min-width: min(100%, 280px); flex: 1; }
.stock-size-filter { margin-top: 6px; font-size: .88rem; grid-column: 1 / -1; }
#sale-form .line-item-header { align-items: flex-start; }
.stock-size-filter summary { cursor: pointer; color: var(--muted); padding: 6px 0; }
.stock-size-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 10px 0; }
.stock-size-fields label { min-width: 0; }
.stock-size-fields .stock-size-mode { grid-column: 1 / -1; }
.stock-size-fields .stock-size-rotation { display: flex; align-items: center; gap: 6px; margin: 0; }
.stock-size-fields input[type="checkbox"] { width: auto; }
.stock-autocomplete-wrap label { display: block; margin-bottom: 6px; font-size: 0.88rem; font-weight: 650; color: #334155; }
.stock-search-input { width: 100%; min-height: 44px; }
.stock-autocomplete-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 110;
  margin-top: 4px; max-height: 340px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; box-shadow: 0 10px 24px rgba(15,23,42,.16);
}
.stock-material-group { border-bottom: 1px solid #e2e8f0; }
.stock-material-group:last-child { border-bottom: none; }
.stock-group-header {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: #f8fafc; border: 0; cursor: pointer;
  text-align: left; transition: background 0.15s ease; gap: 12px;
}
.stock-group-header:hover { background: #f1f5f9; }
.stock-group-header:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.stock-group-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stock-group-title { font-size: 0.92rem; font-weight: 700; color: var(--ink); }
.stock-group-count { font-weight: 600; color: #1e40af; background: #eff6ff; padding: 1px 8px; border-radius: 999px; }
.stock-group-count.partial { color: #92400e; background: #fef3c7; }
.stock-group-action { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.stock-group-price { font-size: 0.86rem; font-weight: 700; color: var(--ink); }
.stock-group-chevron { font-size: 0.72rem; color: var(--muted); width: 14px; text-align: center; }
.stock-group-items { padding: 6px 8px 8px 14px; background: #fbfcfe; border-left: 3px solid #cbd5e1; display: grid; gap: 4px; }
.stock-autocomplete-option {
  display: grid; gap: 3px; width: 100%; min-height: 52px;
  padding: 8px 12px; border: 1px solid #e2e8f0;
  border-radius: 8px; background: #fff; color: #1e293b;
  text-align: left; cursor: pointer; white-space: normal;
  transition: all 0.12s ease;
}
.stock-autocomplete-option:hover, .stock-autocomplete-option.focused { background: #fff1f2; border-color: var(--red); }
.stock-autocomplete-option:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
.stock-autocomplete-option small { color: #475569; line-height: 1.3; }
.stock-option-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.stock-option-dims { font-size: 0.84rem; font-weight: 600; color: #475569; }
.stock-option-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.stock-option-tariff { font-weight: 600; color: #047857; }
.stock-autocomplete-status { padding: 12px; color: #475569; line-height: 1.4; }
.stock-autocomplete-status.stock-more-notice {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 0.84rem;
  color: #475569;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.stock-autocomplete-status.stock-more-notice .stock-more-icon {
  font-weight: 700;
  color: #2563eb;
  font-size: 0.95rem;
}
.line-item-header .stock-autocomplete-wrap { width: min(100%, 480px); }
@media (max-width: 640px) {
  .line-item-header > div:first-child { width: 100%; }
  .line-item-header .stock-autocomplete-wrap { width: 100%; }
  .line-item-search-row { flex-direction: column; align-items: stretch; }
  .stock-autocomplete-dropdown { max-height: min(45vh, 310px); }
}

/* Selector de tipo de receptor en Despacho */
.receiver-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.receiver-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  cursor: pointer;
  transition: all 0.18s ease;
  user-select: none;
  margin: 0;
}
.receiver-card:hover {
  border-color: #94a3b8;
  background: #f8fafc;
}
.receiver-card:has(input:checked) {
  border-color: var(--red);
  background: #fff5f5;
  box-shadow: 0 0 0 1px var(--red);
}
.receiver-card input[type="radio"] {
  margin: 0;
}
.receiver-card-body strong {
  display: block;
  font-size: 0.92rem;
  color: var(--ink);
}
.receiver-card-body small {
  display: block;
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 2px;
}

/* Canvas de firma táctil y suave */
.sig-canvas-box {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 14px;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
#sig-canvas {
  width: 100%;
  height: 140px;
  display: block;
  touch-action: none;
  cursor: crosshair;
  background: #fafafa;
  border-radius: 8px;
  border: 1px dashed #cbd5e1;
}
.sig-canvas-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  font-size: 0.8rem;
  color: #64748b;
}

/* Firma e información del Acta de Despacho */
.act-sig-preview-img {
  max-height: 75px;
  max-width: 240px;
  object-fit: contain;
  display: block;
  margin: 0 auto 6px auto;
}
.act-dispatcher-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 75px;
  padding: 8px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px dashed #e2e8f0;
}
.act-dispatcher-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
  margin-top: 2px;
}
.btn-quick-add-color {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--red);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
}
.btn-quick-add-color:hover {
  text-decoration: underline;
}

/* ==========================================================================
   MÓDULO DE CONTRATOS Y ACUERDOS DE VENTA
   ========================================================================== */
.badge-draft {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-signed {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  font-weight: 700;
  font-size:12px;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-completed {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  font-weight: 700;
  font-size:12px;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-cancelled {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
  font-weight: 700;
  font-size:12px;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ==========================================================================
   MÓDULO DE PROYECTOS Y OBRAS
   ========================================================================== */
.badge-planning {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
  font-weight: 700;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-in-progress {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  font-weight: 700;
  font-size:12px;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-installed {
  background: #ede9fe;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
  font-weight: 700;
  font-size:12px;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.badge-on-hold {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  font-weight: 700;
  font-size:12px;
  padding: 3px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.env-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  transition: border-color 0.15s ease;
}
.env-card:hover {
  border-color: #cbd5e1;
}

.contract-clause-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.contract-clause-card h4 {
  margin: 0 0 6px 0;
  font-size: 0.88rem;
  color: var(--ink);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.contract-clause-card p {
  margin: 0;
  font-size: 0.82rem;
  color: #475569;
  line-height: 1.5;
}

.contract-print-sheet {
  background: #ffffff;
  color: #0f172a;
  max-width: 820px;
  margin: 0 auto;
  padding: 32px 36px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
}
.contract-print-sheet h1, 
.contract-print-sheet h2, 
.contract-print-sheet h3, 
.contract-print-sheet h4 {
  color: #0f172a;
}
.contract-print-sheet table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 16px 0;
  font-size: 11.5px;
}
.contract-print-sheet th {
  background: #f1f5f9;
  border-top: 1px solid #cbd5e1;
  border-bottom: 2px solid #94a3b8;
  padding: 6px 10px;
  font-weight: 700;
  text-align: left;
}
.contract-print-sheet td {
  border-bottom: 1px solid #e2e8f0;
  padding: 6px 10px;
}
.contract-signature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  margin-top: 48px;
  padding-top: 24px;
}
.contract-signature-block {
  text-align: center;
  border-top: 1.5px dashed #475569;
  padding-top: 8px;
}
.contract-signature-block strong {
  display: block;
  font-size: 12.5px;
  color: #0f172a;
}
.contract-signature-block span {
  display: block;
  font-size: 11px;
  color: #64748b;
}

/* ==========================================================================
   ESTILOS PREMIUM: FINANZAS, CUADROS ESTADÍSTICOS Y CIERRE DIARIO
   ========================================================================== */
.finance-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card-premium {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
}

.stat-card-premium:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--border-dark);
}

.stat-card-premium::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--stat-accent, var(--brand));
  opacity: 0.85;
}

.stat-card-premium.accent-usd::before { --stat-accent: #059669; }
.stat-card-premium.accent-pen::before { --stat-accent: #2563eb; }
.stat-card-premium.accent-total::before { --stat-accent: #7c3aed; }
.stat-card-premium.accent-balance::before { --stat-accent: #dc2626; }
.stat-card-premium.accent-count::before { --stat-accent: #0891b2; }

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

.stat-card-head small {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--line-subtle);
  color: var(--ink-secondary);
}

.stat-card-value {
  font-size: 1.55rem;
  font-weight: 850;
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.stat-card-sub {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Gráficos y Filas Estadísticas */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

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

.chart-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 18px;
}

.chart-card-header h3 {
  margin: 0 0 4px 0;
  font-size: 1.05rem;
  font-weight: 750;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-card-header p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.chart-bars-wrap {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  height: 180px;
  padding-top: 24px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  position: relative;
}

.chart-bar-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.chart-bar-val {
  font-size: 0.75rem;
  font-weight: 750;
  color: var(--ink-secondary);
  margin-bottom: 6px;
  white-space: nowrap;
}

.chart-bar-fill {
  width: 100%;
  max-width: 38px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-dark) 100%);
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(200, 16, 46, 0.2);
  min-height: 4px;
}

.chart-bar-item:hover .chart-bar-fill {
  filter: brightness(1.15);
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.35);
}

.chart-bar-lbl {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 8px;
  text-align: center;
  white-space: nowrap;
}

.chart-legend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  padding-top: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* Distribución de Medios de Pago */
.dist-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 6px;
}

.dist-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dist-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 650;
}

.dist-track {
  height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.dist-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

.dist-fill.cash {
  background: linear-gradient(90deg, #10b981, #059669);
}

.dist-fill.transfer {
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
}

.dist-fill.usd {
  background: linear-gradient(90deg, #8b5cf6, #6d28d9);
}

.dist-fill.pen {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

/* Ranking de Materiales Más Vendidos */
.materials-ranking-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 22px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.ranking-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--canvas);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.ranking-row:hover {
  background: #ffffff;
  border-color: var(--border-dark);
  transform: translateX(3px);
  box-shadow: var(--shadow-sm);
}

.ranking-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 850;
  font-size: 0.9rem;
  background: #e2e8f0;
  color: #475569;
}

.ranking-badge.rank-1 {
  background: linear-gradient(135deg, #fef08a 0%, #eab308 100%);
  color: #713f12;
  box-shadow: 0 2px 8px rgba(234, 179, 8, 0.35);
}

.ranking-badge.rank-2 {
  background: linear-gradient(135deg, #f1f5f9 0%, #94a3b8 100%);
  color: #1e293b;
  box-shadow: 0 2px 8px rgba(148, 163, 184, 0.35);
}

.ranking-badge.rank-3 {
  background: linear-gradient(135deg, #fed7aa 0%, #f97316 100%);
  color: #7c2d12;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.35);
}

.ranking-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ranking-title {
  font-weight: 750;
  font-size: 0.95rem;
  color: var(--ink);
}

.ranking-meta {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.ranking-progress-track {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
  max-width: 320px;
}

.ranking-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #e11d48);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.ranking-stat {
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.ranking-stat-amount {
  font-size: 1.1rem;
  font-weight: 850;
  color: var(--ink);
}

.ranking-stat-share {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 2px;
}

/* ==========================================================================
   CIERRE DIARIO DE CAJA (REPORTING)
   ========================================================================== */
.daily-closing-wrapper {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.daily-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.daily-date-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.daily-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.daily-box {
  background: var(--canvas);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.daily-box-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.daily-box-val {
  font-size: 1.35rem;
  font-weight: 850;
  color: var(--ink);
  line-height: 1.2;
}

.daily-box-sub {
  font-size: 0.75rem;
  color: var(--muted);
}

/* ==========================================================================
   VISTA SWITCHER (TARJETAS VS TABLA)
   ========================================================================== */
.view-switcher-group {
  display: inline-flex;
  background: var(--line-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.btn-toggle-view {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 40px;
}

.btn-toggle-view:hover {
  color: var(--ink);
}

.btn-toggle-view.active {
  background: #ffffff;
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ==========================================================================
   TARJETAS PREMIUM DE CONTRATOS
   ========================================================================== */
.contracts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 18px;
}

.contract-card-premium {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.contract-card-premium:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-dark);
}

.contract-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.contract-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.contract-card-head > div:first-child { min-width: 0; }
.contract-card-head .contract-status-row { justify-content: flex-end; max-width: 230px; }
.contract-status-row > span { white-space: normal; }
@media (max-width: 480px) {
  .contract-card-head { flex-direction: column; }
  .contract-card-head .contract-status-row { justify-content: flex-start; max-width: 100%; }
}

.contract-card-code {
  font-size: 1.05rem;
  font-weight: 850;
  font-family: var(--font-mono, monospace);
  letter-spacing: 0.04em;
  color: var(--brand);
}

.contract-card-title {
  font-size: 0.95rem;
  font-weight: 750;
  color: var(--ink);
  margin: 4px 0 0 0;
  line-height: 1.3;
}

.contract-card-client {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--canvas);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.contract-card-client-name {
  font-weight: 750;
  color: var(--ink);
  font-size: 0.9rem;
}

.contract-card-client-doc {
  font-size: 0.78rem;
  color: var(--muted);
}

.contract-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 650;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--line-subtle);
  color: var(--ink-secondary);
}

.chip.chip-logistics {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.chip.chip-custody {
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fde68a;
}

.chip.chip-sale {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.contract-card-finance {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: space-between;
  align-items: flex-end;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.contract-card-amount {
  font-size: 1.25rem;
  font-weight: 850;
  color: var(--ink);
  line-height: 1.1;
}

.contract-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ==========================================================================
   TARJETAS PREMIUM DE PROYECTOS Y OBRAS
   ========================================================================== */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 20px;
}

.project-card-premium {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.project-card-premium:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
  border-color: var(--border-dark);
}

.project-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.project-card-code {
  font-size: 0.95rem;
  font-weight: 800;
  font-family: var(--font-mono, monospace);
  color: var(--brand);
}

.project-card-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--ink);
  margin: 4px 0 0 0;
  line-height: 1.25;
}

.project-card-location {
  font-size: 0.82rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.project-card-people {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  background: var(--canvas);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  font-size: 0.84rem;
}

.project-person-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.project-person-label {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
}

.project-person-val {
  font-weight: 700;
  color: var(--ink);
}

/* Barra de progreso de ambientes y obra */
.project-progress-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.project-progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

.project-meter-track {
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.project-meter-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #10b981, #059669);
  transition: width 0.4s ease;
}

.project-card-finance-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.project-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ==========================================================================
   HOJA DE CIERRE DIARIO PARA IMPRESIÓN (A4)
   ========================================================================== */
.daily-report-sheet {
  background: #ffffff;
  max-width: 800px;
  margin: 0 auto;
  padding: 24px;
  font-family: inherit;
  color: #0f172a;
}

.daily-report-header {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 16px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.daily-report-title {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: #0f172a;
  margin: 0 0 4px 0;
}

.daily-report-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px 0;
  font-size: 12px;
}

.daily-report-table th {
  background: #f8fafc;
  border-top: 1px solid #cbd5e1;
  border-bottom: 2px solid #64748b;
  padding: 8px 10px;
  text-align: left;
  font-weight: 750;
  color: #1e293b;
}

.daily-report-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 10px;
  color: #334155;
}

.daily-report-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  margin-top: 48px;
  padding-top: 20px;
}

.daily-report-sig-box {
  border-top: 1.5px dashed #64748b;
  padding-top: 8px;
  text-align: center;
  font-size: 11.5px;
}

@media print {
  body {
    background: #ffffff !important;
  }
  #sidebar, .topbar, .no-print, dialog::backdrop, .view-switcher-group, .module-tabs, .filter-bar, .daily-toolbar button {
    display: none !important;
  }
  dialog.modal, dialog.detail-dialog {
    position: static !important;
    inset: auto !important;
    transform: none !important;
    box-shadow: none !important;
    border: none !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
  }
  .contract-print-sheet, .daily-report-sheet {
    box-shadow: none !important;
    border: none !important;
    padding: 10mm !important;
    max-width: 100% !important;
    margin: 0 !important;
  }
}

/* ==========================================================================
   ALERTA DE STOCK Y GESTIÓN DE USUARIOS / AUDITORÍA
   ========================================================================== */

.stock-alert-banner {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  animation: fadeIn 0.2s ease;
}

.stock-crit-chip {
  transition: all 0.15s ease;
}

.stock-crit-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(245, 158, 11, 0.2);
}

.badge-stock-alert {
  animation: pulseSlow 3s infinite;
}

@keyframes pulseSlow {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.75; }
}

.user-avatar-circle {
  flex-shrink: 0;
  user-select: none;
}

/* Navegación lateral táctil y refinada */
.nav-sub-item {
  min-height: 36px;
  touch-action: manipulation;
}

@media (max-width: 768px) {
  .nav-sub-item {
    min-height: 42px;
    padding: 9px 12px 9px 34px;
    font-size: 0.9rem;
  }
}

/* Cierre visual del piloto: navegación y estados accesibles en todos los tamaños. */
:root {
  --muted-light: #64748b;
  --warn: #92400e;
}

.skip-access { left: 16px; }
.skip-app { left: 182px; }
body:has(#access:not([hidden])) .skip-app,
body:has(#app:not([hidden])) .skip-access { display: none; }

.field-hint {
  display: block;
  margin: -10px 0 16px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

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

/* main recibe foco programático al cambiar de vista; no es un control interactivo. */
#main[tabindex="-1"]:focus { outline: none; }

:where(button, input, select, textarea):disabled {
  cursor: not-allowed;
}

.nav-sub-items { visibility: hidden; }
.nav-group.open .nav-sub-items { visibility: visible; }
.nav-sub-item { min-height: 44px; }
.nav-parent-btn[aria-expanded="true"] .nav-chevron { transform: rotate(180deg); }
.sidebar-primary, .settings-link { min-height: 44px; }

.sidebar-backdrop { display: none; }

#view, .card, .home-card, .table-wrap, .toolbar, .section-heading,
.dialog-head, #dialog-body, .access-card { min-width: 0; }

.message {
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.empty {
  max-width: 100%;
  padding-block: clamp(28px, 5vw, 56px);
}

.skeleton { min-width: 0; }

.table-wrap {
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 #f1f5f9;
}

.table-wrap:focus-within { border-color: var(--red-dark); }

th, td { vertical-align: top; }
td { overflow-wrap: anywhere; }

dialog { color: var(--ink); }
#dialog-body { overscroll-behavior: contain; }

@media (max-width: 980px) {
  .sidebar {
    width: min(290px, calc(100vw - 48px)) !important;
    overflow-y: auto;
    visibility: hidden;
  }

  .sidebar.open { visibility: visible; }

  .sidebar.open + .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 9998;
    width: 100%;
    height: 100%;
    border-radius: 0;
    background: rgb(15 23 42 / 48%);
    cursor: pointer;
  }

  .main-wrapper { width: 100%; }
  main { max-width: 100%; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .home-workspace { grid-template-columns: minmax(0, 1fr) !important; }
}

@media (max-width: 820px) {
  .topbar { height: 64px; gap: 10px; }
  .topbar-actions { margin-left: auto; gap: 8px; }
  .role-switcher { gap: 8px; }
  .role-info strong { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  main { padding: 22px 18px 48px; }
  .section-heading, .toolbar { flex-wrap: wrap; }
  .field-grid, .facts { grid-template-columns: minmax(0, 1fr); }
  .table-wrap { max-width: 100%; overflow-x: auto; }
  table { min-width: 680px; }
  dialog { width: min(860px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
  #dialog-body { padding: 20px; max-height: calc(100dvh - 110px); }
}

@media (max-width: 640px) {
  .access { min-height: 100dvh; }
  .access-card { width: 100%; min-height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
  .access-card h1 { font-size: clamp(1.45rem, 7vw, 1.85rem); line-height: 1.2; }
  .topbar { padding-inline: 12px !important; }
  main { padding: 18px 14px 40px; }
  .home-welcome { margin-bottom: 24px; align-items: flex-start; flex-direction: column; gap: 6px; }
  .home-welcome h1 { font-size: clamp(1.55rem, 7vw, 2.2rem); }
  .home-workspace { gap: 14px; }
  .quick-grid { grid-template-columns: minmax(0, 1fr) !important; gap: 10px; }
  .quick-card, .home-card-head { padding: 16px; }
  .card { padding: 16px; }
  .toolbar > *, .form-actions > * { max-width: 100%; }
  .form-actions { gap: 10px; }
  .form-actions button { min-height: 44px; }
  .table-button { min-height: 40px; }
  table { min-width: 640px; }
  dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .dialog-head { padding: 14px 16px; }
  .dialog-head h2 { font-size: 1.15rem; }
  #dialog-body { padding: 16px; max-height: calc(100dvh - 86px); }
  .act-meta-grid, .act-footer-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .dispatch-act-sheet { padding: 16px; }
}

/* Vista previa del documento: comparte la hoja con la impresión real. */
.print-preview {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  overflow: auto;
}

.print-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.print-preview .print-sheet {
  width: min(100%, 210mm);
  margin: 0 auto;
  padding: clamp(16px, 3vw, 32px);
  background: #fff;
  color: #0f172a;
  overflow-wrap: anywhere;
}

.print-sheet table { width: 100%; min-width: 0; border-collapse: collapse; }
.print-sheet th, .print-sheet td { padding: 8px 10px; }
.print-sheet img { max-width: 100%; height: auto; }

.inventory-qr-preview { display: flex; align-items: center; gap: 16px; }
.inventory-qr-preview img { flex: none; background: #fff; border: 1px solid #e2e8f0; width: 128px; height: 128px; }
.inventory-qr-preview p { margin: 6px 0 0; }
.inventory-qr-error { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-basis: 100%; padding: 10px 12px; border: 1px solid #b91c1c; border-radius: 8px; background: #fef2f2; color: #7f1d1d; font-size: 13px; }
.inventory-qr-error[hidden] { display: none; }
.inventory-print-label { border: 2px solid #172033; padding: 16px; width: min(100%, 150mm); color: #172033; background: #fff; }
.inventory-print-label-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-bottom: 1px solid #cbd5e1; padding-bottom: 8px; font-size: 13px; letter-spacing: .04em; }
.inventory-print-label-head span { font-weight: 700; }
.inventory-print-label-body { display: flex; align-items: center; gap: 18px; padding: 14px 0 8px; }
.inventory-print-label-body img { flex: none; width: 170px; height: 170px; }
.inventory-print-label-data { display: grid; gap: 6px; font-size: 12px; }
.inventory-print-label-code { font-size: 22px; letter-spacing: .03em; overflow-wrap: anywhere; }
.inventory-print-label-note { margin: 8px 0 0; padding-top: 7px; border-top: 1px solid #cbd5e1; color: #475569; font-size: 10px; }
@media (max-width: 600px) {
  .inventory-qr-preview, .inventory-print-label-body { flex-direction: column; align-items: flex-start; }
}

@page { size: A4; margin: 12mm; }

@media print {
  body:has(dialog.print-preview[open]) > :not(dialog.print-preview) { display: none !important; }
  body:has(dialog.print-preview[open]) *,
  body:has(dialog.print-preview[open]) dialog.print-preview[open],
  body:has(dialog.print-preview[open]) dialog.print-preview[open] * { visibility: visible !important; }
  body:has(dialog.print-preview[open]) dialog.print-preview[open] {
    display: block !important;
    position: static !important;
    inset: auto !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
    transform: none !important;
    animation: none !important;
  }
  body:has(dialog.print-preview[open]) dialog.print-preview[open] .print-preview-toolbar,
  body:has(dialog.print-preview[open]) dialog.print-preview[open] .no-print { display: none !important; }
  body:has(dialog.print-preview[open]) dialog.print-preview[open] .print-sheet {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
    color: #000 !important;
    background: #fff !important;
    font-size: 10pt;
  }
  body:has(dialog.print-preview[open]) dialog.print-preview[open] .dispatch-act-sheet { position: static !important; }
  .print-sheet tr, .print-sheet .act-meta-grid, .print-sheet .act-footer-grid { break-inside: avoid; }
}

/* Inline style migration: generated CSP-safe rules */
:is(#app, dialog) [data-ui-style="u001"] { margin:0; }
:is(#app, dialog) [data-ui-style="u002"] { grid-template-columns: 1fr 1fr; }
:is(#app, dialog) [data-ui-style="u003"] { margin-top: 24px; }
:is(#app, dialog) [data-ui-style="u004"] { padding: 40px 24px; text-align: center; }
:is(#app, dialog) [data-ui-style="u005"] { font-size: 1rem; color: var(--ink); margin: 0 0 4px; }
:is(#app, dialog) [data-ui-style="u006"] { margin: 0; font-size: 0.85rem; }
:is(#app, dialog) [data-ui-style="u007"] { color: var(--muted-light); margin-bottom: 12px; }
:is(#app, dialog) [data-ui-style="u008"] { padding: 24px; }
:is(#app, dialog) [data-ui-style="u009"] { margin: 0 0 8px 0; color: var(--ink); }
:is(#app, dialog) [data-ui-style="u010"] { margin: 0 0 16px 0; font-size: 0.85rem; }
:is(#app, dialog) [data-ui-style="u011"] { display: flex; flex-direction: column; gap: 14px; }
:is(#app, dialog) [data-ui-style="u012"] { background:var(--bg); }
:is(#app, dialog) [data-ui-style="u013"] { margin:0; font-size:0.8rem; }
:is(#app, dialog) [data-ui-style="u014"] { margin-top: 8px; }
:is(#app, dialog) [data-ui-style="u015"] { grid-template-columns: 2fr 1fr 1fr; gap: 18px; margin-bottom: 16px; }
@media (max-width: 768px) {
  :is(#app, dialog) [data-ui-style="u015"] { grid-template-columns: minmax(0, 1fr); gap: 14px; }
}
.field-header { display: flex; justify-content: space-between; align-items: center; min-height: 26px; margin-bottom: 8px; font-size: 0.88rem; font-weight: 650; color: #334155; }
.field-header .field-label-text { font-size: 0.88rem; font-weight: 650; color: #334155; }
:is(#app, dialog) [data-ui-style="u016"] { display:flex; justify-content:space-between; align-items:center; min-height:26px; margin-bottom:8px; }
:is(#app, dialog) [data-ui-style="u017"] { font-size:0.82rem; font-weight:700; color:var(--red); }
:is(#app, dialog) [data-ui-style="u018"] { min-height:46px; }
:is(#app, dialog) [data-ui-style="u019"] { margin-bottom:8px; }
:is(#app, dialog) [data-ui-style="u020"] { margin-top:4px; }
:is(#app, dialog) [data-ui-style="u021"] { margin-top:-6px; margin-bottom:18px; }
:is(#app, dialog) [data-ui-style="u022"] { padding:14px 18px; }
:is(#app, dialog) [data-ui-style="u023"] { display:flex; align-items:center; gap:12px; }
:is(#app, dialog) [data-ui-style="u024"] { color:var(--ink); font-size:1rem; }
:is(#app, dialog) [data-ui-style="u025"] { font-size:0.84rem; margin-top:2px; }
:is(#app, dialog) [data-ui-style="u026"] { color:var(--muted); font-size:0.84rem; font-weight:700; padding:6px 12px; border:1px solid #cbd5e1; border-radius:6px; background:#fff; }
:is(#app, dialog) [data-ui-style="u027"] { margin-top:10px; }
:is(#app, dialog) [data-ui-style="u028"] { padding:12px; font-size:0.85rem; color:var(--muted); text-align:center; }
:is(#app, dialog) [data-ui-style="u029"] { font-weight:700; color:var(--red); margin-top:4px; }
:is(#app, dialog) [data-ui-style="u030"] { font-weight:700; font-size:0.88rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u031"] { text-align:right; }
:is(#app, dialog) [data-ui-style="u032"] { font-size:12px; }
:is(#app, dialog) [data-ui-style="u033"] { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
:is(#app, dialog) [data-ui-style="u034"] { width:14px; height:14px; }
:is(#app, dialog) [data-ui-style="u035"] { margin:0; border:1px solid #e2e8f0; border-radius:8px; color:var(--muted); width:34px; height:34px; display:inline-flex; align-items:center; justify-content:center; }
:is(#app, dialog) [data-ui-style="u036"] { margin-top:0; }
:is(#app, dialog) [data-ui-style="u037"] { padding: 30px; }
:is(#app, dialog) [data-ui-style="u038"] { margin-top:16px; }
:is(#app, dialog) [data-ui-style="u039"] { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 1.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; gap: 8px; }
:is(#app, dialog) [data-ui-style="u040"] { margin: 0; }
:is(#app, dialog) [data-ui-style="u041"] { display: flex; gap: 8px; }
:is(#app, dialog) [data-ui-style="u042"] { padding: 4px 12px; font-size: 0.85rem; }
:is(#app, dialog) [data-ui-style="u043"] { width:14px; height:14px; margin-right:4px; }
:is(#app, dialog) [data-ui-style="u044"] { width:40px; }
:is(#app, dialog) [data-ui-style="u045"] { color:#c8102e; }
:is(#app, dialog) [data-ui-style="u046"] { font-size:12px; color:#64748b; }
:is(#app, dialog) [data-ui-style="u047"] { color:#059669; font-weight:700; }
:is(#app, dialog) [data-ui-style="u048"] { font-size:13px; }
:is(#app, dialog) [data-ui-style="u049"] { color:#64748b; }
:is(#app, dialog) [data-ui-style="u050"] { margin-bottom:16px; }
:is(#app, dialog) [data-ui-style="u051"] { margin:0 0 6px; font-size:12px; text-transform:uppercase; color:#64748b; }
:is(#app, dialog) [data-ui-style="u052"] { font-size:12px; }
:is(#app, dialog) [data-ui-style="u053"] { margin: 8px 0 12px 0; }
:is(#app, dialog) [data-ui-style="u054"] { color:var(--brand); font-weight:700; }
:is(#app, dialog) [data-ui-style="u055"] { display:flex; justify-content:space-between; align-items:center; padding:16px 24px; border-bottom:1px solid var(--line); }
:is(#app, dialog) [data-ui-style="u056"] { margin:0; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u057"] { display:flex; gap:10px; }
:is(#app, dialog) [data-ui-style="u058"] { font-size:12px; color:#475569; line-height:1.4; }
:is(#app, dialog) [data-ui-style="u059"] { font-size:13px; font-weight:800; color:#c8102e; text-transform:uppercase; letter-spacing:0.04em; }
:is(#app, dialog) [data-ui-style="u060"] { font-size:14px; font-weight:900; margin-top:4px; }
:is(#app, dialog) [data-ui-style="u061"] { font-size:12px; color:#64748b; margin-top:2px; }
:is(#app, dialog) [data-ui-style="u062"] { display:grid; grid-template-columns: repeat(4, 1fr); gap:12px; margin-bottom:20px; }
:is(#app, dialog) [data-ui-style="u063"] { border:1px solid #cbd5e1; border-radius:6px; padding:10px; text-align:center; }
:is(#app, dialog) [data-ui-style="u064"] { font-size:12px; font-weight:700; color:#64748b; text-transform:uppercase; }
:is(#app, dialog) [data-ui-style="u065"] { font-size:16px; font-weight:900; color:#059669; margin-top:4px; }
:is(#app, dialog) [data-ui-style="u066"] { font-size:16px; font-weight:900; color:#2563eb; margin-top:4px; }
:is(#app, dialog) [data-ui-style="u067"] { font-size:16px; font-weight:900; color:#d97706; margin-top:4px; }
:is(#app, dialog) [data-ui-style="u068"] { font-size:16px; font-weight:900; color:#7c3aed; margin-top:4px; }
:is(#app, dialog) [data-ui-style="u069"] { background:#f8fafc; border:1px solid #e2e8f0; border-radius:6px; padding:10px 16px; margin-bottom:18px; display:flex; justify-content:space-between; font-size:12px; }
:is(#app, dialog) [data-ui-style="u070"] { margin:16px 0 8px 0; font-size:12.5px; text-transform:uppercase; letter-spacing:0.04em; }
:is(#app, dialog) [data-ui-style="u071"] { text-align:center; padding:24px; color:#64748b; }
:is(#app, dialog) [data-ui-style="u072"] { display:flex; justify-content:space-between; align-items:center; margin-bottom: 20px; flex-wrap:wrap; gap:12px; }
:is(#app, dialog) [data-ui-style="u073"] { text-transform:uppercase; letter-spacing:0.05em; font-size:0.75rem; font-weight:700; color:var(--red); }
:is(#app, dialog) [data-ui-style="u074"] { margin:0; font-size:1.6rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u075"] { margin:4px 0 0 0; font-size:0.88rem; }
:is(#app, dialog) [data-ui-style="u076"] { display:flex; gap:10px; align-items:center; }
:is(#app, dialog) [data-ui-style="u077"] { display:inline-flex; align-items:center; gap:6px; font-weight:600; }
:is(#app, dialog) [data-ui-style="u078"] { display:inline-flex; align-items:center; gap:6px; }
:is(#app, dialog) [data-ui-style="u079"] { color:#2563eb; }
:is(#app, dialog) [data-ui-style="u080"] { color:#7c3aed; }
:is(#app, dialog) [data-ui-style="u081"] { color:#dc2626; }
:is(#app, dialog) [data-ui-style="u082"] { color:#0891b2; }
:is(#app, dialog) [data-ui-style="u083"] { font-weight:750; color:var(--brand); font-size:0.9rem; }
:is(#app, dialog) [data-ui-style="u084"] { display:flex; justify-content:space-between; align-items:flex-start; flex-wrap:wrap; gap:12px; }
:is(#app, dialog) [data-ui-style="u085"] { margin:0 0 4px 0; font-size:1.15rem; color:var(--ink); display:flex; align-items:center; gap:8px; }
:is(#app, dialog) [data-ui-style="u086"] { margin:0; font-size:0.85rem; }
:is(#app, dialog) [data-ui-style="u087"] { background:#f1f5f9; color:#334155; font-weight:700; }
:is(#app, dialog) [data-ui-style="u088"] { font-weight:700; font-size:0.88rem; color:var(--ink); margin:0; }
:is(#app, dialog) [data-ui-style="u089"] { padding:6px 10px; font-size:0.88rem; margin-left:6px; }
:is(#app, dialog) [data-ui-style="u090"] { border-left:4px solid #10b981; }
:is(#app, dialog) [data-ui-style="u091"] { color:#059669; }
:is(#app, dialog) [data-ui-style="u092"] { border-left:4px solid #3b82f6; }
:is(#app, dialog) [data-ui-style="u093"] { border-left:4px solid #f59e0b; }
:is(#app, dialog) [data-ui-style="u094"] { color:#d97706; }
:is(#app, dialog) [data-ui-style="u095"] { border-left:4px solid #8b5cf6; }
:is(#app, dialog) [data-ui-style="u096"] { background:var(--canvas); border:1px solid var(--border); border-radius:var(--radius-sm); padding:14px 18px; margin-bottom:20px; display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:10px; }
:is(#app, dialog) [data-ui-style="u097"] { margin-left:6px; font-size:0.85rem; }
:is(#app, dialog) [data-ui-style="u098"] { font-size:1.35rem; font-weight:850; color:var(--brand); }
:is(#app, dialog) [data-ui-style="u099"] { margin-top:20px; }
:is(#app, dialog) [data-ui-style="u100"] { margin:0; font-size:1.1rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u101"] { margin:2px 0 0 0; font-size:0.82rem; }
:is(#app, dialog) [data-ui-style="u102"] { margin-bottom:20px; }
:is(#app, dialog) [data-ui-style="u103"] { background:var(--card); }
:is(#app, dialog) [data-ui-style="u104"] { background:var(--card); font-size:0.85rem; }
:is(#app, dialog) [data-ui-style="u105"] { margin:0; font-size: 1.5rem; }
:is(#app, dialog) [data-ui-style="u106"] { margin: 4px 0 0 0; }
:is(#app, dialog) [data-ui-style="u107"] { background:#fffbeb; border:1px solid #fef3c7; border-left:4px solid #f59e0b; border-radius:8px; padding:12px 16px; margin-bottom:16px; }
:is(#app, dialog) [data-ui-style="u108"] { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:10px; }
:is(#app, dialog) [data-ui-style="u109"] { display:flex; align-items:center; gap:10px; }
:is(#app, dialog) [data-ui-style="u110"] { font-size:1.3rem; }
:is(#app, dialog) [data-ui-style="u111"] { color:#92400e; font-size:0.92rem; }
:is(#app, dialog) [data-ui-style="u112"] { margin:2px 0 0; font-size:0.82rem; color:#b45309; }
:is(#app, dialog) [data-ui-style="u113"] { display:flex; gap:6px; flex-wrap:wrap; }
:is(#app, dialog) [data-ui-style="u114"] { background:#fef3c7; border:1px solid #fde68a; color:#92400e; padding:4px 9px; border-radius:12px; font-size:0.78rem; cursor:pointer; font-weight:600; display:inline-flex; align-items:center; gap:5px; }
:is(#app, dialog) [data-ui-style="u115"] { margin-bottom: 24px; }
:is(#app, dialog) [data-ui-style="u116"] { display:flex; gap: 12px; margin-bottom: 16px; flex-wrap:wrap; }
:is(#app, dialog) [data-ui-style="u117"] { flex:1; min-width:200px; }
:is(#app, dialog) [data-ui-style="u118"] { display:flex; justify-content:space-between; align-items:center; margin-bottom: 16px; flex-wrap:wrap; gap:10px; }
:is(#app, dialog) [data-ui-style="u119"] { margin:0; font-size:1.15rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u120"] { margin:2px 0 0; font-size:0.85rem; }
:is(#app, dialog) [data-ui-style="u122"] { grid-column: 1 / -1; border-top: 1px dashed var(--border); padding-top: 6px; }
:is(#app, dialog) [data-ui-style="u123"] { color:var(--brand); }
:is(#app, dialog) [data-ui-style="u124"] { width:100%; padding:6px; font-size:0.82rem; margin-top:auto; }
:is(#app, dialog) [data-ui-style="u125"] { padding: 40px 20px; }
:is(#app, dialog) [data-ui-style="u126"] { padding:4px 10px; font-size:0.8rem; }
:is(#app, dialog) [data-ui-style="u127"] { display:flex; flex-direction:column; gap:16px; }
:is(#app, dialog) [data-ui-style="u128"] { display:flex; align-items:center; gap:8px; }
:is(#app, dialog) [data-ui-style="u129"] { font-size:0.9rem; color:var(--brand-dark); font-weight:700; }
:is(#app, dialog) [data-ui-style="u130"] { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
:is(#app, dialog) [data-ui-style="u131"] { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
:is(#app, dialog) [data-ui-style="u132"] { display:flex; justify-content:space-between; align-items:center; margin-bottom:4px; }
:is(#app, dialog) [data-ui-style="u133"] { font-size:0.8rem; }
:is(#app, dialog) [data-ui-style="u134"] { background:var(--bg); border:1px solid var(--border); padding:16px; }
:is(#app, dialog) [data-ui-style="u135"] { margin:0 0 12px 0; }
:is(#app, dialog) [data-ui-style="u136"] { margin-top:10px; font-size:0.9rem; }
:is(#app, dialog) [data-ui-style="u137"] { color:var(--brand); font-size:1.1rem; }
:is(#app, dialog) [data-ui-style="u138"] { display:flex; align-items:center; gap:8px; cursor:pointer; }
:is(#app, dialog) [data-ui-style="u139"] { color:var(--brand); font-size:1.2rem; }
:is(#app, dialog) [data-ui-style="u140"] { margin-top:20px; background:var(--bg); text-align:center; padding:20px; }
:is(#app, dialog) [data-ui-style="u141"] { display:inline-block; padding:12px; background:#fff; border-radius:8px; border:2px solid var(--border); }
:is(#app, dialog) [data-ui-style="u142"] { margin:12px 0 0; font-size:0.85rem; }
:is(#app, dialog) [data-ui-style="u143"] { text-align:center; padding: 60px 20px; }
:is(#app, dialog) [data-ui-style="u144"] { color:var(--muted-light); margin-bottom:16px; }
:is(#app, dialog) [data-ui-style="u145"] { margin:0 0 6px 0; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u146"] { background:#fef3c7; color:#92400e; border-color:#fde68a; }
:is(#app, dialog) [data-ui-style="u147"] { grid-column: 1 / -1; }
:is(#app, dialog) [data-ui-style="u148"] { font-size:0.75rem; color:var(--brand-dark); }
:is(#app, dialog) [data-ui-style="u149"] { font-size:0.85rem; color:var(--muted); }
:is(#app, dialog) [data-ui-style="u150"] { min-width:260px; }
:is(#app, dialog) [data-ui-style="u151"] { background:#e0f2fe; color:#0369a1; border-color:#bae6fd; }
:is(#app, dialog) [data-ui-style="u152"] { color:#c8102e; font-size:14px; }
:is(#app, dialog) [data-ui-style="u153"] { font-size:12px; color:#64748b; }
:is(#app, dialog) [data-ui-style="u154"] { text-align:right; font-weight:700; color:#0f172a; margin-top:-8px; margin-bottom:12px; }
:is(#app, dialog) [data-ui-style="u155"] { color:#64748b; font-style:italic; }
:is(#app, dialog) [data-ui-style="u156"] { background:#f1f5f9; padding:10px; border-radius:4px; font-size:12px; margin-bottom:16px; }
:is(#app, dialog) [data-ui-style="u157"] { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 20px; }
:is(#app, dialog) [data-ui-style="u158"] { background:var(--bg); padding:16px; margin-bottom:16px; }
:is(#app, dialog) [data-ui-style="u159"] { margin:0 0 8px 0; }
:is(#app, dialog) [data-ui-style="u160"] { margin:0 0 6px 0; }
:is(#app, dialog) [data-ui-style="u161"] { background:#f8fafc; padding:16px; margin-bottom:16px; }
:is(#app, dialog) [data-ui-style="u162"] { margin-top:8px; }
:is(#app, dialog) [data-ui-style="u163"] { margin-top:8px; font-size:0.85rem; font-weight:700; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u164"] { background:#eff6ff; border:1px solid #bfdbfe; border-left:4px solid #2563eb; border-radius:8px; padding:12px 16px; margin-bottom:16px; }
:is(#app, dialog) [data-ui-style="u165"] { color:#1e40af; display:block; margin-bottom:4px; font-size:0.95rem; }
:is(#app, dialog) [data-ui-style="u166"] { color:#1e3a8a; font-size:0.875rem; }
:is(#app, dialog) [data-ui-style="u167"] { background:#f0fdf4; border:1px solid #bbf7d0; border-left:4px solid #16a34a; border-radius:8px; padding:12px 16px; margin-bottom:16px; }
:is(#app, dialog) [data-ui-style="u168"] { color:#166534; display:block; margin-bottom:4px; font-size:0.95rem; }
:is(#app, dialog) [data-ui-style="u169"] { color:#14532d; font-size:0.875rem; }
:is(#app, dialog) [data-ui-style="u170"] { grid-template-columns: 1fr 1fr; margin-bottom: 16px; }
:is(#app, dialog) [data-ui-style="u171"] { color:var(--success); font-weight:700; }
:is(#app, dialog) [data-ui-style="u172"] { display:flex; justify-content:space-between; font-size:0.82rem; font-weight:700; }
:is(#app, dialog) [data-ui-style="u173"] { background:var(--brand); }
:is(#app, dialog) [data-ui-style="u174"] { background:#3b82f6; }
:is(#app, dialog) [data-ui-style="u175"] { background:#e2e8f0; }
:is(#app, dialog) [data-ui-style="u176"] { margin-bottom:14px; display:block; }
:is(#app, dialog) [data-ui-style="u177"] { display:flex; justify-content:space-between; align-items:center; margin-bottom:12px; }
:is(#app, dialog) [data-ui-style="u178"] { margin:0; font-size:0.95rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u179"] { margin:2px 0 0; font-size:0.8rem; }
:is(#app, dialog) [data-ui-style="u180"] { font-size:0.85rem; font-weight:700; color:var(--ink); margin-top:8px; }
:is(#app, dialog) [data-ui-style="u181"] { margin-bottom:2px; }
:is(#app, dialog) [data-ui-style="u182"] { margin:0; font-size: 1.6rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u183"] { margin: 4px 0 0 0; font-size:0.88rem; }
:is(#app, dialog) [data-ui-style="u184"] { color: #2563eb; font-size: 1.6rem; }
:is(#app, dialog) [data-ui-style="u185"] { color: #059669; font-size: 1.6rem; }
:is(#app, dialog) [data-ui-style="u186"] { color: #dc2626; font-size: 1.6rem; }
:is(#app, dialog) [data-ui-style="u187"] { color: var(--ink); font-size: 1.6rem; }
:is(#app, dialog) [data-ui-style="u188"] { margin-bottom: 14px; }
:is(#app, dialog) [data-ui-style="u189"] { width: 100%; max-width: 480px; }
:is(#app, dialog) [data-ui-style="u190"] { text-align:center; }
:is(#app, dialog) [data-ui-style="u191"] { text-align:center; color:#059669; font-weight:700; }
:is(#app, dialog) [data-ui-style="u192"] { text-align:center; color:#2563eb; font-weight:800; }
:is(#app, dialog) [data-ui-style="u193"] { font-weight:700; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u194"] { font-size:0.82rem; }
:is(#app, dialog) [data-ui-style="u195"] { display:flex; justify-content:space-between; align-items:center; margin-top:14px; padding-top:10px; border-top:1px solid var(--line-subtle); flex-wrap:wrap; gap:10px; }
:is(#app, dialog) [data-ui-style="u196"] { display:inline-flex; align-items:center; gap:8px; }
:is(#app, dialog) [data-ui-style="u197"] { color:var(--brand); font-variant-numeric:tabular-nums; }
:is(#app, dialog) [data-ui-style="u198"] { font-size:0.85rem; }
:is(#app, dialog) [data-ui-style="u199"] { font-weight:600; }
:is(#app, dialog) [data-ui-style="u200"] { font-size:0.8rem; padding:4px 10px; }
:is(#app, dialog) [data-ui-style="u201"] { max-width: 680px; padding: 24px; }
:is(#app, dialog) [data-ui-style="u202"] { margin:2px 0 0; }
:is(#app, dialog) [data-ui-style="u203"] { font-size:0.85rem; font-weight:700; color:var(--ink); margin:12px 0 6px; }
:is(#app, dialog) [data-ui-style="u204"] { font-size:0.85rem; font-weight:700; color:var(--ink); margin:16px 0 8px; }
:is(#app, dialog) [data-ui-style="u205"] { margin-bottom:14px; }
:is(#app, dialog) [data-ui-style="u206"] { display:none; }
:is(#app, dialog) [data-ui-style="u207"] { color:var(--ink); font-size:0.92rem; display:block; }
:is(#app, dialog) [data-ui-style="u208"] { display:block; font-size:0.78rem; }
:is(#app, dialog) [data-ui-style="u209"] { display:grid; grid-template-columns:2fr 1fr; gap:12px; margin-bottom:12px; }
:is(#app, dialog) [data-ui-style="u210"] { font-size:0.85rem; font-weight:700; color:var(--ink); margin:14px 0 4px; }
:is(#app, dialog) [data-ui-style="u211"] { touch-action:none; width:100%; max-width:480px; background:#ffffff; }
:is(#app, dialog) [data-ui-style="u212"] { padding:2px 8px; font-size:0.75rem; }
:is(#app, dialog) [data-ui-style="u213"] { display:flex; justify-content:flex-end; gap:10px; margin-top:20px; }
:is(#app, dialog) [data-ui-style="u214"] { color:var(--danger) }
:is(#app, dialog) [data-ui-style="u215"] { text-align:center; font-weight:800; font-size:1.1rem; color:var(--brand); }
:is(#app, dialog) [data-ui-style="u216"] { font-weight:700; color:#0f172a; margin-top:4px; }
:is(#app, dialog) [data-ui-style="u217"] { background:#f8fafc; border:1px solid #e2e8f0; border-radius:6px; padding:8px 12px; margin:12px 0; font-size:0.85rem; }
:is(#app, dialog) [data-ui-style="u218"] { color:var(--ink); font-size:0.85rem; }
:is(#app, dialog) [data-ui-style="u219"] { display:flex; align-items:center; justify-content:center; }
:is(#app, dialog) [data-ui-style="u220"] { display:flex; justify-content:flex-end; gap:10px; margin-top:28px; border-top:1px solid #e2e8f0; padding-top:16px; }
:is(#app, dialog) [data-ui-style="u221"] { margin-bottom:24px; }
:is(#app, dialog) [data-ui-style="u222"] { border-top:3px solid #64748b; }
:is(#app, dialog) [data-ui-style="u223"] { display:flex; justify-content:space-between; align-items:center; }
:is(#app, dialog) [data-ui-style="u224"] { font-size:1.25rem; }
:is(#app, dialog) [data-ui-style="u225"] { border-top:3px solid #dc2626; }
:is(#app, dialog) [data-ui-style="u226"] { border-top:3px solid #d97706; }
:is(#app, dialog) [data-ui-style="u227"] { border-top:3px solid #2563eb; }
:is(#app, dialog) [data-ui-style="u228"] { display:flex; align-items:center; gap:6px; }
:is(#app, dialog) [data-ui-style="u229"] { letter-spacing:0.04em; }
:is(#app, dialog) [data-ui-style="u230"] { font-style:italic; }
:is(#app, dialog) [data-ui-style="u231"] { font-weight:700; }
:is(#app, dialog) [data-ui-style="u232"] { font-weight:700; color:#1d4ed8; }
:is(#app, dialog) [data-ui-style="u233"] { display:inline-flex; gap:6px; }
:is(#app, dialog) [data-ui-style="u234"] { margin: 0 0 6px 0; color: var(--ink); display:flex; align-items:center; gap:8px; }
:is(#app, dialog) [data-ui-style="u235"] { grid-template-columns: 140px 1fr; }
:is(#app, dialog) [data-ui-style="u236"] { margin: 0 0 6px 0; color: var(--ink); }
:is(#app, dialog) [data-ui-style="u237"] { background:var(--bg); font-weight:700; }
:is(#app, dialog) [data-ui-style="u238"] { height:120px; margin-bottom:12px; }
:is(#app, dialog) [data-ui-style="u239"] { font-size:1.15rem; font-weight:800; }
:is(#app, dialog) [data-ui-style="u240"] { font-size:0.9rem; font-weight:normal; }
:is(#app, dialog) [data-ui-style="u241"] { font-size:0.85rem; color:var(--muted); margin-top:-8px; }
:is(#app, dialog) [data-ui-style="u242"] { font-size:0.95rem; }
:is(#app, dialog) [data-ui-style="u243"] { font-size:0.9rem; font-weight:500; }
:is(#app, dialog) [data-ui-style="u244"] { color:#1d4ed8; }
:is(#app, dialog) [data-ui-style="u245"] { margin-top:6px; }
:is(#app, dialog) [data-ui-style="u246"] { margin:0; font-weight:600; color:#64748b; }
:is(#app, dialog) [data-ui-style="u247"] { border-top:3px solid #059669; }
:is(#app, dialog) [data-ui-style="u248"] { margin-bottom: 18px; display:flex; gap:12px; flex-wrap:wrap; align-items:center; justify-content:space-between; }
:is(#app, dialog) [data-ui-style="u249"] { background:var(--card); font-size:0.85rem; font-weight:600; }
:is(#app, dialog) [data-ui-style="u250"] { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
:is(#app, dialog) [data-ui-style="u251"] { padding:40px 20px; }
:is(#app, dialog) [data-ui-style="u252"] { cursor:pointer; }
:is(#app, dialog) [data-ui-style="u253"] { font-size:0.78rem; color:var(--muted); margin-top:8px; display:flex; align-items:center; gap:4px; }
:is(#app, dialog) [data-ui-style="u254"] { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
:is(#app, dialog) [data-ui-style="u255"] { display:block; font-size:12px; font-weight:700; text-transform:uppercase; }
:is(#app, dialog) [data-ui-style="u256"] { font-size:0.75rem; color:#059669; font-weight:700; display:block; }
:is(#app, dialog) [data-ui-style="u257"] { font-size:0.7rem; }
:is(#app, dialog) [data-ui-style="u258"] { font-size:0.75rem; color:#d97706; font-weight:700; display:block; }
:is(#app, dialog) [data-ui-style="u259"] { margin-top:12px; }
:is(#app, dialog) [data-ui-style="u260"] { flex:1; }
:is(#app, dialog) [data-ui-style="u261"] { letter-spacing:0.04em; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u262"] { font-weight:700; cursor:pointer; background:none; border:none; color:var(--blue); padding:0; text-decoration:underline; }
:is(#app, dialog) [data-ui-style="u263"] { max-width:200px; display:inline-block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
:is(#app, dialog) [data-ui-style="u264"] { font-weight:800; }
:is(#app, dialog) [data-ui-style="u265"] { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:16px; }
:is(#app, dialog) [data-ui-style="u266"] { margin:0 0 4px 0; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u267"] { background:#f8fafc; border:1px solid #e2e8f0; border-radius:8px; padding:12px; display:none; }
:is(#app, dialog) [data-ui-style="u268"] { font-weight:800; font-size:1.05rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u269"] { margin-top: 10px; }
:is(#app, dialog) [data-ui-style="u270"] { height:120px; }
:is(#app, dialog) [data-ui-style="u271"] { font-size:1.2rem; }
:is(#app, dialog) [data-ui-style="u272"] { padding:10px 14px; }
:is(#app, dialog) [data-ui-style="u273"] { font-weight:700; color:var(--blue); font-size:1.05rem; }
:is(#app, dialog) [data-ui-style="u274"] { background:none; border:none; color:var(--blue); font-weight:800; padding:0; cursor:pointer; text-decoration:underline; }
:is(#app, dialog) [data-ui-style="u275"] { font-weight:800; font-size:1rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u276"] { font-weight:800; font-size:1.15rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u277"] { background:#f8fafc; border:1px solid #e2e8f0; border-radius:8px; padding:12px 16px; }
:is(#app, dialog) [data-ui-style="u278"] { margin:0 0 6px 0; font-size:0.92rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u279"] { display:grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap:10px; font-size:0.85rem; }
:is(#app, dialog) [data-ui-style="u280"] { margin:0 0 6px 0; font-size:0.92rem; }
:is(#app, dialog) [data-ui-style="u281"] { text-align:right; font-weight:700; }
:is(#app, dialog) [data-ui-style="u282"] { display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:8px; }
:is(#app, dialog) [data-ui-style="u283"] { font-size:0.85rem; color:#475569; margin-top:2px; }
:is(#app, dialog) [data-ui-style="u284"] { font-size:0.85rem; padding:6px 14px; }
:is(#app, dialog) [data-ui-style="u285"] { margin-top:10px; display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px; }
:is(#app, dialog) [data-ui-style="u286"] { display:flex; gap:8px; }
:is(#app, dialog) [data-ui-style="u287"] { color:var(--red); }
:is(#app, dialog) [data-ui-style="u288"] { margin:0 0 16px 0; font-size:0.85rem; }
:is(#app, dialog) [data-ui-style="u289"] { display:flex; flex-direction:column; gap:14px; }
:is(#app, dialog) [data-ui-style="u290"] { text-align: right; }
:is(#app, dialog) [data-ui-style="u291"] { font-size: 14px; }
:is(#app, dialog) [data-ui-style="u292"] { margin: 2px 0 0; font-size:12px; color: #64748b; }
:is(#app, dialog) [data-ui-style="u293"] { margin: 2px 0 0; font-size:12px; color: #64748b; }
:is(#app, dialog) [data-ui-style="u294"] { border-top:3px solid #0284c7; }
:is(#app, dialog) [data-ui-style="u295"] { color:#0284c7; }
:is(#app, dialog) [data-ui-style="u296"] { border-top:3px solid #f59e0b; }
:is(#app, dialog) [data-ui-style="u297"] { color:#f59e0b; }
:is(#app, dialog) [data-ui-style="u298"] { margin-bottom:18px; display:flex; justify-content:space-between; align-items:center; flex-wrap:wrap; gap:12px; }
:is(#app, dialog) [data-ui-style="u299"] { color:var(--brand); text-decoration:none; }
:is(#app, dialog) [data-ui-style="u300"] { margin-top:14px; }
:is(#app, dialog) [data-ui-style="u301"] { background:#f1f5f9; color:#334155; font-size:0.75rem; }
:is(#app, dialog) [data-ui-style="u302"] { display:flex; justify-content:space-between; font-size:0.75rem; color:var(--muted); margin-top:2px; }
:is(#app, dialog) [data-ui-style="u303"] { font-size:12px; font-weight:700; text-transform:uppercase; display:block; }
:is(#app, dialog) [data-ui-style="u304"] { font-size:1.15rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u305"] { font-size:1.05rem; color:#059669; }
:is(#app, dialog) [data-ui-style="u306"] { color:var(--primary); font-family:var(--font-mono, monospace); }
:is(#app, dialog) [data-ui-style="u307"] { background:#f1f5f9; color:#475569; font-weight:700; }
:is(#app, dialog) [data-ui-style="u308"] { text-align:right; white-space:nowrap; }
:is(#app, dialog) [data-ui-style="u309"] { max-width:760px; }
:is(#app, dialog) [data-ui-style="u310"] { margin-top:-6px; margin-bottom:14px; }
:is(#app, dialog) [data-ui-style="u311"] { margin:14px 0 10px; }
:is(#app, dialog) [data-ui-style="u312"] { font-size:0.92rem; color:var(--text-main); }
:is(#app, dialog) [data-ui-style="u313"] { display:block; }
:is(#app, dialog) [data-ui-style="u314"] { display:flex; flex-direction:column; gap:8px; }
:is(#app, dialog) [data-ui-style="u315"] { display:flex; gap:8px; align-items:center; }
:is(#app, dialog) [data-ui-style="u316"] { flex:2; }
:is(#app, dialog) [data-ui-style="u317"] { flex-shrink:0; }
:is(#app, dialog) [data-ui-style="u318"] { margin-top:6px; align-self:flex-start; }
:is(#app, dialog) [data-ui-style="u319"] { margin-top:18px; }
:is(#app, dialog) [data-ui-style="u320"] { color:var(--primary); font-family:var(--font-mono, monospace); font-weight:700; }
:is(#app, dialog) [data-ui-style="u321"] { font-size:0.88rem; color:var(--muted); }
:is(#app, dialog) [data-ui-style="u322"] { margin-bottom:4px; }
:is(#app, dialog) [data-ui-style="u323"] { font-size:0.85rem; font-weight:700; color:#334155; line-height:1.3; margin-top:4px; }
:is(#app, dialog) [data-ui-style="u324"] { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; }
:is(#app, dialog) [data-ui-style="u325"] { font-size:0.88rem; }
:is(#app, dialog) [data-ui-style="u326"] { font-size:0.85rem; color:var(--muted); margin-top:2px; }
:is(#app, dialog) [data-ui-style="u327"] { display:flex; gap:6px; }
:is(#app, dialog) [data-ui-style="u328"] { color:#ef4444; }
:is(#app, dialog) [data-ui-style="u329"] { white-space:nowrap; }
:is(#app, dialog) [data-ui-style="u330"] { background:#f8fafc; border:1px solid #e2e8f0; border-radius:8px; padding:16px; }
:is(#app, dialog) [data-ui-style="u331"] { margin:0 0 12px; font-size:0.95rem; }
:is(#app, dialog) [data-ui-style="u332"] { display:flex; justify-content:space-between; }
:is(#app, dialog) [data-ui-style="u333"] { display:flex; justify-content:space-between; border-top:1px solid #e2e8f0; padding-top:8px; }
:is(#app, dialog) [data-ui-style="u334"] { padding:16px; }
:is(#app, dialog) [data-ui-style="u335"] { max-height:360px; overflow-y:auto; }
:is(#app, dialog) [data-ui-style="u336"] { color:#64748b; font-size:9pt; }
:is(#app, dialog) [data-ui-style="u337"] { font-size:9pt; }
:is(#app, dialog) [data-ui-style="u338"] { width:36px; height:36px; border-radius:50%; background:var(--brand-soft); color:var(--brand); font-weight:800; display:flex; align-items:center; justify-content:center; font-size:0.95rem; border:1px solid var(--border); }
:is(#app, dialog) [data-ui-style="u339"] { color:var(--ink); font-size:0.9rem; }
:is(#app, dialog) [data-ui-style="u340"] { font-size:0.78rem; }
:is(#app, dialog) [data-ui-style="u341"] { font-size:0.75rem; padding:2px 8px; }
:is(#app, dialog) [data-ui-style="u342"] { padding:4px 8px; font-size:0.8rem; }
:is(#app, dialog) [data-ui-style="u343"] { display:flex; justify-content:space-between; align-items:center; margin-bottom:20px; flex-wrap:wrap; gap:12px; }
:is(#app, dialog) [data-ui-style="u344"] { margin:0; font-size:1.5rem; }
:is(#app, dialog) [data-ui-style="u345"] { margin:4px 0 0 0; }
:is(#app, dialog) [data-ui-style="u346"] { display:grid; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr)); gap:14px; margin-bottom:24px; }
:is(#app, dialog) [data-ui-style="u347"] { font-size:1.6rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u348"] { font-size:0.75rem; }
:is(#app, dialog) [data-ui-style="u349"] { font-size:1.6rem; color:#059669; }
:is(#app, dialog) [data-ui-style="u350"] { font-size:1.6rem; color:#7e22ce; }
:is(#app, dialog) [data-ui-style="u351"] { font-size:1.6rem; color:var(--brand); }
:is(#app, dialog) [data-ui-style="u352"] { display:flex; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
:is(#app, dialog) [data-ui-style="u353"] { width:28px; height:28px; border-radius:50%; background:var(--brand-soft); color:var(--brand); font-size:0.75rem; font-weight:700; display:flex; align-items:center; justify-content:center; }
:is(#app, dialog) [data-ui-style="u354"] { font-size:12px; }
:is(#app, dialog) [data-ui-style="u355"] { font-size:0.75rem; font-weight:700; }
:is(#app, dialog) [data-ui-style="u356"] { font-size:0.85rem; color:var(--ink); }
:is(#app, dialog) [data-ui-style="u357"] { font-family:monospace; font-size:0.75rem; }
:is(#app, dialog) [data-ui-style="u358"] { flex:1; min-width:240px; }
:is(#app, dialog) [data-ui-style="u359"] { display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; }
:is(#app, dialog) [data-ui-style="u360"] { margin:-8px 0 16px; }
:is(#app, dialog) [data-ui-style="u361"] { color: var(--danger); background: var(--danger-soft); }

/* Estados calculados: la apariencia depende de datos, no de estilos HTML incrustados. */
.stock-crit-count { color: #fff; border-radius: 8px; padding: 1px 5px; font-size: 0.75rem; }
.stock-crit-count.is-empty { background: #b91c1c; }
.stock-crit-count.is-low { background: #92400e; }
.tab-badge.has-pieces { background: #ecfdf5; color: #065f46; font-weight: 700; }
.tab-badge.no-pieces { background: #f1f5f9; color: #475569; font-weight: 700; }
.stock-remaining { text-align: center; font-weight: 800; }
.stock-remaining.has-pieces { color: #1d4ed8; }
.stock-remaining.no-pieces { color: #64748b; }
.tone-debt { color: #b91c1c !important; }
.tone-settled { color: #047857 !important; }
.tone-neutral { color: var(--ink) !important; }
.balance-emphasis { font-weight: 800; }
.balance-state { font-weight: 800; font-size: 1rem; }
.balance-total { font-size: 1.05rem; }
.contract-sign-state { border-radius: 8px; padding: 12px 16px; }
.contract-sign-state.is-signed { background: #ecfdf5; border: 1px solid #a7f3d0; }
.contract-sign-state.is-pending { background: #fffbeb; border: 1px solid #fde68a; }

.role-badge, .audit-action {
  display: inline-block;
  border-radius: 12px;
  border: 1px solid var(--line);
  font-weight: 700;
  white-space: nowrap;
}
.role-badge { padding: 3px 8px; font-size: 0.75rem; }
.role-badge-admin { background: #f3e8ff; color: #6b21a8; border-color: #e9d5ff; }
.role-badge-manager { background: #eff6ff; color: #1d4ed8; border-color: #dbeafe; }
.role-badge-seller { background: #ecfdf5; color: #047857; border-color: #d1fae5; }
.role-badge-cutter { background: #fffbeb; color: #92400e; border-color: #fef3c7; }
.role-badge-other { background: #f1f5f9; color: #475569; }
.audit-action { padding: 2px 8px; font-size: 0.74rem; }
.audit-action-venta-creada, .audit-action-credito-aprobado { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.audit-action-pago-registrado, .audit-action-despacho-creado { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.audit-action-credito-rechazado { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.audit-action-corte-finalizado { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.audit-action-contrato-creado { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.audit-action-contrato-firmado { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.audit-action-usuario-creado, .audit-action-usuario-modificado { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.audit-action-password-restablecida { background: #fdf4ff; color: #a21caf; border-color: #f5d0fe; }
.audit-action-other { background: #f8fafc; color: #475569; border-color: #e2e8f0; }

/* Documentos de vista previa: estilos externos compartidos por pantalla y papel. */
dialog.print-preview .print-sheet {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
}
dialog.print-preview .print-sheet .header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 12px;
  margin-bottom: 16px;
}
dialog.print-preview .print-sheet .brand { padding: 0; margin: 0; border: 0; }
dialog.print-preview .print-sheet .brand h1 { margin: 0; font-size: 18px; color: var(--red); line-height: 1.2; }
dialog.print-preview .print-sheet .brand p { margin: 3px 0 0; color: #475569; font-size: 11px; }
dialog.print-preview .print-sheet .doc-meta { text-align: right; }
dialog.print-preview .print-sheet .doc-meta h2 { margin: 0; font-size: 16px; color: #0f172a; }
dialog.print-preview .print-sheet .doc-meta p { margin: 3px 0 0; color: #475569; font-size: 11px; }
dialog.print-preview .print-sheet .info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}
dialog.print-preview .print-sheet .info-item small,
dialog.print-preview .print-sheet .field small {
  display: block;
  margin-bottom: 2px;
  color: #475569;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}
dialog.print-preview .print-sheet .info-item strong,
dialog.print-preview .print-sheet .field strong { font-size: 13px; color: #0f172a; }
dialog.print-preview .print-sheet table { width: 100%; min-width: 0; margin: 8px 0 16px; font-size: 12px; }
dialog.print-preview .print-sheet th { background: #f1f5f9; color: #334155; font-size: 11px; padding: 8px 10px; }
dialog.print-preview .print-sheet td { padding: 8px 10px; }
dialog.print-preview .print-sheet .text-right { text-align: right; }
dialog.print-preview .print-sheet .text-center { text-align: center; }
dialog.print-preview .print-sheet .totals-area { display: flex; justify-content: flex-end; margin-bottom: 20px; }
dialog.print-preview .print-sheet .totals-table { width: 280px; margin: 0; }
dialog.print-preview .print-sheet .totals-table td { padding: 6px 8px; border: 0; }
dialog.print-preview .print-sheet .totals-table .total-row td { border-top: 2px solid #0f172a; color: var(--red); font-weight: 800; font-size: 14px; }
dialog.print-preview .print-sheet .totals-table .balance-row td { border-top: 1px dashed #cbd5e1; font-weight: 700; }
dialog.print-preview .print-sheet .notes-box { background: #fafaf9; border-left: 3px solid var(--red); padding: 10px 12px; font-size: 11px; margin-bottom: 24px; }
dialog.print-preview .print-sheet .signatures,
dialog.print-preview .print-sheet .signature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 40px; margin-top: 40px; padding-top: 20px; }
dialog.print-preview .print-sheet .sig-line,
dialog.print-preview .print-sheet .signature-box { border-top: 1px solid #64748b; text-align: center; padding-top: 6px; font-size: 11px; }
dialog.print-preview .print-sheet .signature-box strong,
dialog.print-preview .print-sheet .signature-box span { display: block; }
dialog.print-preview .print-sheet .section-title,
dialog.print-project .print-sheet h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; color: #334155; margin: 16px 0 6px; border-bottom: 1px solid #e2e8f0; padding-bottom: 4px; }
dialog.print-cut .print-sheet .barcode-box { text-align: center; border: 1px dashed #cbd5e1; padding: 12px; margin-top: 20px; font-family: monospace; font-size: 14px; background: #fafafa; }
dialog.print-contract .print-sheet { font-size: 11.5px; }
dialog.print-contract .print-sheet .contract-title { text-align: center; margin: 18px 0 20px; }
dialog.print-contract .print-sheet .contract-title h2 { margin: 0; font-size: 14px; text-transform: uppercase; }
dialog.print-contract .print-sheet .contract-title span { font-size: 12px; font-weight: 700; color: #475569; }
dialog.print-contract .print-sheet .clause { margin-bottom: 14px; text-align: justify; }
dialog.print-contract .print-sheet .clause-title { font-weight: 800; text-transform: uppercase; margin-bottom: 4px; }
dialog.print-contract .print-sheet .no-print-bar { display: none; }
dialog.print-project .print-sheet .box { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 6px; padding: 12px; margin-bottom: 16px; }
dialog.print-project .print-sheet .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.commercial-card-totals { display: flex; flex-direction: column; }
.commercial-card-totals strong { font-size: 1.05em; color: var(--text); }
.commercial-card-totals small { font-size: 0.85em; }
dialog.print-commercial-quote .print-sheet .commercial-quote-notes {
  background: #f8fafc;
  border-left: 3px solid var(--accent, #0284c7);
  padding: 10px 14px;
  font-size: 11px;
  margin-bottom: 24px;
  color: #334155;
  border-radius: 0 4px 4px 0;
}
dialog.print-commercial-quote .print-sheet .commercial-quote-notes ul {
  margin: 6px 0 0 16px;
  padding: 0;
}
dialog.print-commercial-quote .print-sheet .commercial-quote-notes li {
  margin-bottom: 4px;
}

@media (max-width: 640px) {
  dialog.print-preview .print-sheet .header,
  dialog.print-preview .print-sheet .info-grid,
  dialog.print-preview .print-sheet .signatures,
  dialog.print-preview .print-sheet .signature-grid { grid-template-columns: minmax(0, 1fr); flex-direction: column; }
  dialog.print-preview .print-sheet .doc-meta { text-align: left; }
}

@media print {
  dialog.print-preview .print-sheet .header { flex-direction: row; }
  dialog.print-preview .print-sheet .info-grid,
  dialog.print-preview .print-sheet .signatures,
  dialog.print-preview .print-sheet .signature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Alta guiada de catálogos reales antes del primer ingreso físico. */
.catalog-select-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 8px;
}
.catalog-select-header label { margin: 0; }
.catalog-select-header .btn-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 4px;
  text-align: right;
  white-space: nowrap;
}
.catalog-select-header + select { margin-bottom: 18px; }
.catalog-bootstrap-actions {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 18px;
}
.catalog-bootstrap-actions button { min-height: 44px; }
dialog.catalog-entry-dialog {
  width: min(520px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}
.catalog-entry-dialog .dialog-content {
  max-height: calc(100dvh - 26px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.catalog-entry-dialog .catalog-entry-message { margin-top: 12px; }
.catalog-entry-dialog .dialog-actions { flex-wrap: wrap; }
@media (max-width: 480px) {
  dialog.catalog-entry-dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .catalog-entry-dialog .dialog-content { max-height: calc(100dvh - 18px); padding: 18px 16px; }
  .catalog-entry-dialog .dialog-actions { flex-direction: column-reverse; }
  .catalog-entry-dialog .dialog-actions button,
  .catalog-bootstrap-actions button { width: 100%; }
}

/* Revisión y aprobación de condiciones contractuales. */
.contract-template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 18px; margin-top: 18px; }
.contract-template-section { min-width: 0; }
.contract-template-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.contract-template-heading h3 { margin: 0 0 4px; }
.contract-template-version { padding: 14px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.contract-template-version p, .contract-template-review p, .contract-template-preview p { white-space: pre-wrap; overflow-wrap: anywhere; }
.contract-template-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.contract-template-dialog { width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
.contract-template-dialog .dialog-content { overflow-y: auto; max-height: calc(100dvh - 32px); }
.contract-template-dialog form { display: grid; gap: 14px; }
.contract-template-dialog textarea { width: 100%; min-height: 100px; resize: vertical; }
.contract-template-review { border: 1px solid var(--line); border-radius: 10px; padding: 14px; max-height: 32vh; overflow: auto; }
.contract-template-review h3 { margin: 0 0 6px; }
.warehouse-selection-dialog { width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: 0 30px 80px #0005; }
.warehouse-selection-dialog::backdrop { background: #101828b8; }
.warehouse-selection-dialog form { display: grid; gap: 16px; }
.warehouse-selection-dialog h2 { margin: 0; }
.warehouse-selection-dialog select { width: 100%; min-height: 44px; }
.warehouse-selection-dialog button { min-height: 44px; }
.warehouse-context #warehouse-indicator { display: block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-warehouse-fields { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0; }
.user-warehouse-fields legend { padding: 0 5px; font-weight: 700; }
.user-warehouse-options { display: grid; gap: 8px; max-height: 180px; overflow-y: auto; margin-bottom: 8px; }
.user-warehouse-options label { display: flex; align-items: center; gap: 9px; min-height: 34px; }
.user-warehouse-options input { width: 18px; height: 18px; flex: 0 0 auto; }
@media (max-width: 560px) {
  .contract-template-actions button, .contract-template-dialog .dialog-actions button { flex: 1 1 100%; }
}

/* Adhesivo aportado por el cliente y control de compras */
.client-adhesive-rows { display: grid; gap: 8px; margin: 10px 0; }
.client-adhesive-row { display: grid; grid-template-columns: 2fr 1fr auto; gap: 8px; align-items: flex-end; background: #f8fafc; padding: 10px; border-radius: 8px; border: 1px solid var(--line); }
.client-adhesive-row label { margin: 0; font-size: 0.85rem; font-weight: 600; }
.client-adhesive-row input { width: 100%; }
.adhesive-confirmed-box { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 12px 16px; margin: 12px 0; }
.adhesive-confirmed-box h4 { margin: 0 0 6px; color: #166534; font-size: 0.95rem; }
.adhesive-items-list { margin: 6px 0 0; padding-left: 20px; color: #15803d; }
.adhesive-items-list li { margin-bottom: 4px; }

/* Constancia de entrega al técnico instalador */
.handover-file-badge { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 8px; padding: 8px 12px; margin-top: 6px; font-size: 0.85rem; }
.handover-file-badge a { font-size: 0.8rem; padding: 4px 8px; text-decoration: none; }
.handover-print-banner { background: #faf5ff; border: 1px solid #e9d5ff; border-radius: 10px; padding: 12px 16px; margin: 12px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.handover-print-banner p { margin: 0; color: #6b21a8; font-size: 0.9rem; }
.client-adhesive-row .btn-remove-adhesive-row.is-hidden { visibility: hidden; }
.btn-add-adhesive-row { margin-bottom: 10px; }
.btn-upload-handover { margin-top: 6px; }

/* Entrega agrupada: una acción y una constancia por evento. */
.th-operation-bar,.th-modal-header,.th-row-actions { display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.th-operation-bar h3,.th-modal-header h2 { margin:0; }
.th-operation-bar { margin-bottom:12px; }
.th-assignment-row { display:flex; align-items:center; flex-wrap:wrap; gap:6px 12px; padding:8px 10px; }
dialog.th-modal { width:min(820px,calc(100vw - 24px)); max-width:calc(100vw - 24px); }
.th-modal .dialog-content { padding:20px; }
.th-modal-header { margin-bottom:16px; }
.th-modal-header h2 { font-size:1.2rem; }
.th-preflight .th-modal-header { flex-wrap:nowrap; align-items:flex-start; }
.th-preflight .th-modal-header h2 { flex:1; min-width:0; }
.th-preflight .th-modal-header button { flex:none; }
.th-modal :is(input,textarea,select) { min-width:0; max-width:100%; }
.th-modal :is(strong,small,p,span,h3),.th-document :is(strong,small,p,span,h3) { overflow-wrap:anywhere; }
.th-selection { border:1px solid #dce4ed; border-radius:10px; padding:12px; margin:0 0 16px; min-width:0; }
.th-selection legend { font-weight:700; padding:0 5px; }
.th-select-all,.th-ready-row { display:flex; align-items:flex-start; gap:10px; }
.th-modal input[type="checkbox"] { width:18px; height:18px; flex:none; margin-top:3px; }
.th-ready-list { max-height:260px; overflow-y:auto; margin:8px 0; }
.th-ready-row { padding:9px 0; border-top:1px solid #e2e8f0; cursor:pointer; }
.th-ready-row span { min-width:0; }
.th-ready-row small,.th-history-row small { display:block; color:#64748b; line-height:1.5; font-size:.82rem; }
.th-form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.th-form-wide { grid-column:1/-1; }
.th-modal label { margin:0; }
.th-options { border-top:1px solid #e2e8f0; margin:12px 0; padding:10px 0; }
.th-options summary { cursor:pointer; font-weight:600; }
.th-options label { display:grid; gap:6px; margin-top:12px; }
.th-help { margin:12px 0; color:#64748b; font-size:.82rem; line-height:1.45; }
.th-history-row { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:12px 0; border-bottom:1px solid #e2e8f0; }
.th-history-row > div:first-child { min-width:0; }
.th-row-actions { justify-content:flex-start; margin:10px 0; }
.th-row-actions .secondary,.th-history-row .secondary { padding:8px 12px; font-size:.85rem; }
.th-detail-meta { display:grid; gap:4px; }
.th-detail-meta .badge { justify-self:start; }
.th-material-group { margin:14px 0; }
.th-material-group h3 { margin:0 0 5px; font-size:1rem; }
.th-provenance { margin:0 0 6px; font-size:.8rem; color:#64748b; }
.th-source-list { display:grid; gap:3px; padding:9px 10px; background:#f8fafc; border-radius:7px; font-size:.8rem; line-height:1.5; }
.th-source-list strong { font-size:.78rem; }
.th-modal .th-pieces,.th-document .th-pieces { width:100%; min-width:0; table-layout:fixed; border-collapse:collapse; margin-top:7px; }
.th-pieces th,.th-pieces td { padding:8px; border-bottom:1px solid #dce4ed; font-size:.83rem; overflow-wrap:anywhere; vertical-align:top; }
.th-pieces th { background:#f3f5f8; color:#475569; text-align:left; font-size:.76rem; }
.th-modal .th-pieces th,.th-document .th-pieces th { white-space:normal; letter-spacing:.02em; overflow-wrap:anywhere; }
.th-pieces th:first-child { width:50%; }
.th-pieces th:nth-child(2) { width:33%; }
.th-pieces th:last-child { width:17%; }
.th-output-code { display:inline-block; white-space:nowrap; }
.th-pieces td small { display:block; color:#64748b; margin-top:2px; }
.th-origin-codes + .th-origin-codes { margin-top:5px; }
.th-document { max-width:186mm; margin:auto; color:#14213d; font-size:10pt; }
.th-header { display:flex; justify-content:space-between; gap:20px; border-bottom:2px solid #d30932; padding-bottom:12px; }
.th-brand { display:flex; align-items:center; gap:12px; min-width:0; }
.th-brand img { flex:none; width:76px; height:76px; object-fit:contain; }
.th-brand h1 { margin:0 0 5px; font-size:14pt; }
.th-brand p,.th-doc-meta p { font-size:8pt; margin:3px 0; }
.th-doc-meta { text-align:right; min-width:145px; }
.th-doc-meta h2 { font-size:15pt; margin:0 0 5px; color:#c90830; }
.th-doc-subtitle { border-bottom:1px solid #dce4ed; padding:7px 0; font-size:9pt; }
.th-info { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px 20px; padding:12px 0; border-bottom:1px solid #dce4ed; }
.th-info .vc-field { display:grid; gap:4px; font-size:9pt; }
.th-info .vc-field > span { font-size:7pt; color:#52637e; }
.th-totals { text-align:right; font-weight:700; font-size:9pt; margin:10px 0; }
.th-notes h3 { font-size:10pt; margin:10px 0 4px; }
.th-notes p,.th-custody-note { font-size:9pt; line-height:1.4; }
.th-custody-note { border-top:1px solid #dce4ed; padding-top:10px; }
.th-signatures { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:30px; margin-top:18px; font-size:8pt; }
.th-signatures > div { display:grid; gap:4px; }
.th-signature-space { height:35px; border-bottom:1px solid #64748b; }
.th-footer { display:flex; justify-content:space-between; gap:15px; border-top:1px solid #dce4ed; padding-top:9px; margin-top:16px; font-size:7pt; color:#52637e; }
@media(max-width:540px) {
  .th-modal .dialog-content { padding:14px; }
  .th-form-grid { grid-template-columns:1fr; }
  .th-history-row { align-items:flex-start; flex-wrap:wrap; }
  .th-pieces th,.th-pieces td { padding:6px 4px; font-size:.75rem; }
  .th-header { flex-wrap:wrap; gap:10px; }
  .th-doc-meta { text-align:left; }
  .th-info { grid-template-columns:1fr; }
  .th-brand h1 { font-size:12pt; }
  .th-signatures { gap:16px; font-size:7pt; }
  .th-footer { flex-wrap:wrap; }
}
@media print {
  html:has(dialog.print-technician-event[open]),body:has(dialog.print-technician-event[open]) { background:#fff !important; }
  .th-document .th-header { flex-wrap:nowrap; }
  .th-document .th-doc-meta { text-align:right; }
  .th-document .th-info { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .th-document .th-pieces th,.th-document .th-pieces td { font-size:9pt; padding:7px; }
  .th-document :is(.th-header,.th-info,.th-pieces tr,.th-signatures,.th-footer) { break-inside:avoid; }
  .th-document .th-pieces thead { display:table-header-group; }
  .th-document h3 { break-after:avoid; }
}
.sketchcut-banner { background: #eff6ff; border-color: #93c5fd; margin-bottom: 14px; }
.sketchcut-banner strong { color: #1e40af; }
.sketchcut-banner p { color: #1d4ed8; margin: 2px 0 0; }
.banner-spaced { margin-bottom: 14px; }

/* FASE 1: Catálogo comercial y resumen de 3 bloques */
.commercial-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 16px 0 8px;
}
.commercial-summary-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px;
  border-radius: 12px;
  border: 1px solid var(--line, #e2e8f0);
  background: var(--surface, #ffffff);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.commercial-summary-card.total-card {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.commercial-summary-card.advance-card {
  border-color: #bfdbfe;
  background: #f0f7ff;
}
.commercial-summary-card.balance-card {
  border-color: #d1fae5;
  background: #f0fdf4;
}
.commercial-summary-card .card-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}
.commercial-summary-card.advance-card .card-label {
  color: #1e40af;
}
.commercial-summary-card.balance-card .card-label {
  color: #065f46;
}
.commercial-summary-card .card-amount {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--ink, #0f172a);
  font-variant-numeric: tabular-nums;
}
.commercial-summary-card .card-subtext {
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.35;
}
.commercial-summary-card .card-help {
  font-size: 0.8rem;
  color: #64748b;
}
.commercial-preview-footnote {
  font-size: 0.85rem;
  margin: 4px 0 12px;
}
.commercial-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}
.stone-tariff-badge-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.stone-tariff-badge-wrap .badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}
.stone-tariff-badge-wrap .tariff-active {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}
.stone-tariff-badge-wrap .tariff-missing {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.stone-tariff-badge-wrap .tariff-hint {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.stone-badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 8px 0;
}
.stone-availability-badge-wrap .badge,
.stone-tariff-badge-wrap .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
}
.availability-in-stock {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.availability-out-stock {
  background: #f8fafc;
  color: #64748b;
  border: 1px dashed #cbd5e1;
}
.commercial-variant-search-wrap {
  margin-bottom: 12px;
}
.commercial-variant-search-wrap label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.autocomplete-input-wrap {
  position: relative;
  width: 100%;
}
.commercial-variant-search-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.92rem;
  border: 1.5px solid var(--line, #cbd5e1);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink, #0f172a);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}
.commercial-variant-search-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.commercial-variant-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  max-height: 260px;
  overflow-y: auto;
  z-index: 50;
  padding: 4px;
}
.commercial-variant-option {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: background-color 0.12s ease;
  border-bottom: 1px solid #f1f5f9;
}
.commercial-variant-option:last-child {
  border-bottom: none;
}
.commercial-variant-option:hover,
.commercial-variant-option.is-selected,
.commercial-variant-option.highlighted,
.commercial-variant-option[aria-selected="true"] {
  background-color: #f0f7ff;
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}
.commercial-variant-option-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.commercial-variant-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: #1e293b;
}
.commercial-variant-tariff {
  font-weight: 700;
  font-size: 0.88rem;
  color: #15803d;
  white-space: nowrap;
}
.commercial-variant-tariff.no-tariff {
  color: #b91c1c;
  font-weight: 600;
  font-size: 0.82rem;
}
.commercial-variant-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #64748b;
}
.commercial-variant-stock {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #2563eb;
  font-weight: 500;
}
.commercial-variant-stock.no-stock {
  color: #64748b;
}
.commercial-variant-notice {
  font-size: 0.76rem;
  color: #94a3b8;
  font-style: italic;
}
.commercial-variant-empty {
  padding: 12px;
  text-align: center;
  color: #64748b;
  font-size: 0.88rem;
}
.version-pill {
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 700;
  border: 1px solid #bae6fd;
}
.quote-versions-trail {
  font-size: 0.8rem;
  margin-top: 4px;
}
.quote-versions-trail .ver-current {
  font-weight: 700;
  color: var(--ink, #0f172a);
}
.quote-versions-trail .ver-past {
  color: #94a3b8;
}
.version-history-box {
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 10px;
  background: #f8fafc;
  padding: 14px;
  margin: 12px 0;
  display: grid;
  gap: 8px;
}
.version-history-box h4 {
  margin: 0;
  font-size: 0.95rem;
  color: #334155;
}
.version-history-list {
  display: grid;
  gap: 6px;
}
.version-history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  font-size: 0.85rem;
}
.version-history-item.is-current {
  border-color: #93c5fd;
  background: #eff6ff;
  font-weight: 600;
}
.version-history-btn {
  padding: 2px 8px;
  font-size: 0.8rem;
}

/* FASE 2: Preparación física y modalidad comercial */
.line-item-commercial-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 14px;
  align-items: end;
  margin-top: 4px;
}

.commercial-mode-field,
.processing-mode-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 220px;
}

.commercial-mode-field select,
.processing-mode-field select {
  min-height: 42px;
  width: 100%;
}

@media (max-width: 768px) {
  .line-item-commercial-row {
    grid-template-columns: 1fr;
  }
}

/* FASE 2: Historial de corte y Ficha de corte PDF */
.history-pdf-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
}

.btn-download-cut-pdf {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: 6px;
  border: 1px solid var(--line, #cbd5e1);
  background: #f8fafc;
  color: var(--ink, #1e293b);
  width: fit-content;
}

.btn-download-cut-pdf:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}

.cutting-record-pdf-card {
  margin-top: 14px;
}

.cutting-record-pdf-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  margin-top: 6px;
}

/* Entregables comerciales A4: aislados de tablas operativas y otras constancias. */
.vc-document { color: #172033; font: 12px/1.45 Arial, sans-serif; overflow-wrap: anywhere; }
.vc-document p { margin: 4px 0; }
.vc-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 22px; padding-bottom: 14px; border-bottom: 3px solid #cc1033; }
.vc-brand { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.vc-document .vc-logo { width: 72px; height: 72px; object-fit: contain; flex: none; }
.vc-brand h1 { font-size: 16px; margin: 0 0 5px; letter-spacing: .02em; line-height: 1.25; }
.vc-brand p { font-size: 11px; color: #475569; }
.vc-document-meta { width: 220px; max-width: 36%; text-align: right; flex: none; }
.vc-document-meta h2 { font-size: 22px; margin: 0 0 4px; color: #a51230; line-height: 1.2; }
.vc-document-code { display: block; font-size: 15px; font-variant-numeric: tabular-nums; }
.vc-document-meta p { font-size: 11px; }
.vc-document-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 11px 0; }
.vc-modality { min-width: 0; font-size: 13px; font-weight: 700; }
.vc-document .vc-project-title { margin: 3px 0 0; color: #475569; font-size: 11px; font-weight: 400; }
.vc-document-status { max-width: 45%; flex: none; font-size: 8px; font-weight: 700; letter-spacing: .045em; text-align: right; color: #526075; padding: 3px 0; }
.vc-document-draft .vc-document-status { color: #8a4b0d; }
.vc-document-cancelled .vc-document-status { color: #a51230; border-bottom: 1px solid currentColor; }
.vc-client-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 10px 24px; padding: 12px 0; margin-bottom: 15px; border-top: 1px solid #dfe5ed; border-bottom: 1px solid #dfe5ed; }
.vc-field span, .vc-field strong { display: block; }
.vc-field span { color: #526075; font-size: 10px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 3px; }
.vc-field strong { font-size: 12px; font-weight: 600; }
dialog.print-preview .print-sheet .vc-items { table-layout: fixed; border-collapse: collapse; margin: 0 0 20px; width: 100%; min-width: 0; }
dialog.print-preview .print-sheet .vc-items th { background: #f1f3f6; color: #172033; padding: 9px 7px; font-size: 10px; font-weight: 700; text-transform: uppercase; border-bottom: 2px solid #adb7c5; }
dialog.print-preview .print-sheet .vc-items td { padding: 10px 7px; border-bottom: 1px solid #dfe5ed; vertical-align: top; font-size: 11px; }
.vc-col-index { width: 4%; } .vc-col-description { width: 38%; } .vc-col-unit { width: 9%; } .vc-col-quantity { width: 12%; } .vc-col-price { width: 17%; } .vc-col-total { width: 20%; }
.vc-items small { display: block; margin-top: 4px; color: #526075; font-size: 10px; }
.vc-items .vc-number { white-space: nowrap; overflow-wrap: normal; }
.vc-items .vc-source-price { white-space: normal; }
.vc-number { text-align: right; font-variant-numeric: tabular-nums; }
.vc-center { text-align: center; }
.vc-economic { display: grid; grid-template-columns: 1fr 1.1fr; gap: 28px; margin: 14px 0 18px; }
.vc-document h3 { font-size: 12px; margin: 0 0 7px; color: #172033; }
.vc-payment-notes p { font-size: 11px; color: #475569; }
.vc-payment-plan { margin: 4px 0 8px; }
.vc-payment-plan .vc-total-row { font-size: 10px; gap: 10px; padding: 5px 0; }
.vc-totals { border-top: 2px solid #a51230; }
.vc-totals h3 { margin: 8px 0 2px; font-size: 10px; color: #526075; }
.vc-total-row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 8px 0; border-bottom: 1px solid #e4e8ee; font-size: 11px; }
.vc-total-row strong { text-align: right; flex: none; white-space: nowrap; overflow-wrap: normal; }
.vc-grand-total { font-size: 16px; color: #a51230; }
.vc-balance { font-weight: 700; }
.vc-conditions { border-top: 1px solid #dfe5ed; padding-top: 14px; margin-top: 12px; }
.vc-conditions p { white-space: pre-wrap; font-size: 11px; margin: 6px 0 10px; }
.vc-template-reference { color: #526075; }
.vc-document .vc-warranty-heading { margin: 10px 0 4px; }
.vc-warranty-block { margin-top:14px; }
.vc-warranty-block p { white-space:pre-wrap; font-size:11px; }
.vc-delivery { margin-top: 14px; }
.vc-warning { border-left: 3px solid #9b530e; background: #fffbeb; padding: 9px 12px; font-size: 11px; margin: 8px 0 14px !important; }
.vc-signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 45px; margin-top: 24px; }
.vc-signature-space { height: 48px; border-bottom: 1px solid #64748b; margin-bottom: 8px; }
.vc-signature { text-align: center; font-size: 11px; }
.vc-signature strong, .vc-signature span { display: block; margin-top: 3px; }
.vc-signature-note { margin: 18px 0 !important; font-size: 10px; color: #526075; }
.vc-footer { display: flex; justify-content: space-between; gap: 16px; border-top: 1px solid #dfe5ed; padding-top: 10px; margin-top: 24px; font-size: 9px; color: #526075; }
@media screen and (max-width: 640px) {
  .vc-header { flex-direction: column; gap: 14px; }
  .vc-document-meta { text-align: left; width: auto; max-width: none; }
  .vc-document-heading { flex-direction: column; gap: 4px; }
  .vc-document-status { max-width: none; text-align: left; }
  .vc-client-grid, .vc-economic { grid-template-columns: 1fr; }
  .vc-signatures { gap: 18px; }
  .vc-document .vc-logo { width: 72px; height: 72px; }
  .vc-brand h1 { font-size: 14px; }
  .vc-table-scroll { overflow-x: auto; }
  dialog.print-preview .print-sheet .vc-items { min-width: 620px; }
  dialog.print-preview .print-sheet .vc-items th, dialog.print-preview .print-sheet .vc-items td { font-size: 11px; padding: 8px; }
}
@media print {
  html:has(.vc-document) { background: #fff !important; }
  body:has(.vc-document) { background: #fff !important; }
  dialog.print-preview:has(.vc-document) { position: static !important; inset: auto !important; display: block !important; width: 100% !important; max-width: none !important; max-height: none !important; margin: 0 !important; padding: 0 !important; border: 0 !important; box-shadow: none !important; overflow: visible !important; background: #fff !important; }
  dialog.print-preview:has(.vc-document)::backdrop { display: none !important; background: transparent !important; }
  body:has(.vc-document) { page:valri-commercial; }
  .vc-document { width: 100%; font-size: 9pt; }
  .vc-header { padding-bottom: 8px; }
  .vc-document-heading { padding: 8px 0; }
  .vc-document .vc-logo { width: 72px; height: 72px; }
  .vc-client-grid { padding: 7px 0; gap: 9px 22px; margin-bottom: 8px; }
  dialog.print-preview .print-sheet .vc-items td { padding: 5px 7px; }
  dialog.print-preview .print-sheet .vc-items th { font-size: 9px; letter-spacing: 0; white-space: nowrap; }
  .vc-economic { gap: 24px; margin: 8px 0 10px; }
  .vc-total-row { padding: 5px 0; }
  .vc-payment-plan .vc-total-row { padding: 4px 0; }
  .vc-grand-total { font-size: 15px; }
  .vc-signatures { margin-top: 12px; }
  .vc-signature-space { height: 34px; }
  .vc-signature-note { margin: 10px 0 !important; }
  .vc-footer { font-size:8px; }
  .vc-contract-closing { break-inside: avoid; page-break-inside: avoid; }
  .vc-conditions { padding-top: 8px; margin-top: 8px; }
  .vc-conditions p { margin: 3px 0 5px; }
  .vc-conditions h3, .vc-delivery h3 { margin-bottom: 5px; }
  .vc-delivery { margin-top: 6px; }
  dialog.print-preview .print-sheet .vc-items { margin-bottom: 8px; }
  .vc-table-scroll { overflow: visible; }
  .vc-header, .vc-document-heading, .vc-client-grid, .vc-economic, .vc-signatures, .vc-delivery { break-inside: avoid; page-break-inside: avoid; }
  .vc-items { overflow: visible; }
  .vc-items thead { display: table-header-group; }
  .vc-items tbody { break-inside: auto; }
  .vc-items tr { break-inside: avoid; page-break-inside: avoid; }
  .vc-conditions { break-inside: auto; }
  .vc-conditions h3 { break-after: avoid; }
  .vc-conditions p { orphans: 3; widows: 3; }
  .vc-warranty-block { margin-top:8px; }
  .vc-warranty-block p { margin:3px 0 5px; orphans:3; widows:3; }
  .vc-document-meta, .vc-document-status, .vc-grand-total, .vc-items th { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
@page valri-commercial {
  size:A4;
  margin:12mm 12mm 18mm;
  @bottom-right { content:"Página " counter(page) " / " counter(pages); font:8px Arial,sans-serif; color:#526075; }
}

/* Simplificación del formulario contractual - Documento 69 */
.contract-consultation-summary {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: var(--radius-sm, 8px);
  padding: 12px;
  margin-bottom: 14px;
}
.contract-consultation-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.contract-consultation-kpi-grid .kpi-card {
  padding: 10px;
  border-radius: 8px;
}
.contract-items-container {
  border-top: 1px solid var(--border, #e2e8f0);
  padding-top: 10px;
}
.contract-items-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.contract-items-scroll {
  max-height: 120px;
  overflow-y: auto;
  padding-right: 4px;
}
.contract-preview-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-light, rgba(0, 0, 0, 0.05));
  font-size: 0.84rem;
}
.contract-preview-item-row > div:first-child {
  padding-right: 8px;
}
.contract-rule-notice {
  margin-top: 10px;
  margin-bottom: 0;
  padding: 8px 12px;
  font-size: 0.82rem;
  line-height: 1.4;
}
.contract-additional-options {
  margin: 12px 0;
  padding: 8px 12px;
  border: 1px dashed var(--border, #cbd5e1);
  border-radius: var(--radius-sm, 8px);
  background: var(--surface-muted, #f8fafc);
}
.contract-additional-options summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text, #1e293b);
}
.contract-template-preview-box {
  margin-top: 8px;
}
.contract-template-preview-box .notice {
  font-size: 0.84rem;
  line-height: 1.45;
}
.contract-template-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.contract-amount-highlight {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent, #0284c7);
}
.contract-paid-highlight {
  color: var(--success, #16a34a);
  font-weight: 600;
}
.contract-balance-highlight {
  font-weight: 600;
}
.contract-balance-debt {
  color: var(--warning-dark, #b45309);
}
.contract-balance-paid {
  color: var(--success, #16a34a);
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.btn-text-action {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent, #0284c7);
  cursor: pointer;
  text-decoration: underline;
}

.btn-text-action:hover {
  color: var(--accent-hover, #0369a1);
}
/* Detalle operativo compacto y recibo: estilos aislados, sin reglas globales. */
.installation-payments-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.installation-payments-heading h3 { margin:0 0 4px; }
.installation-payments-heading .payment-history-compact { margin:0; padding:0; border:0; }
.sale-incidence-actions button { min-height:44px; }
.installation-advance-progress { display:grid; gap:6px; margin-block:4px 8px; }
.installation-advance-progress label { margin:0; font-weight:650; }
.installation-advance-progress progress { width:100%; height:9px; accent-color:var(--brand); }
.installation-advance-progress > div { display:flex; flex-wrap:wrap; gap:4px 16px; justify-content:space-between; }
.installation-adhesive-details > summary { padding:10px 0; cursor:pointer; }
.conformity-signature-canvas { width:100%; max-width:600px; height:130px; touch-action:none; border:1px dashed #aab3c2; border-radius:8px; }
.installation-detail > .notice { display:none; }
.vr-receipt { box-sizing:border-box; width:80mm; max-width:100%; margin:0 auto; padding:4mm; color:#172033; font:11px/1.4 Arial,sans-serif; background:#fff; overflow-wrap:anywhere; }
.vr-header { display:flex; flex-direction:column; align-items:stretch; gap:12px; border-bottom:1px dashed #64748b; padding-bottom:12px; text-align:center; }
.vr-brand { display:flex; flex-direction:column; gap:8px; align-items:center; min-width:0; }
.vr-brand > div { min-width:0; overflow-wrap:anywhere; }
.vr-brand img { width:48px; height:48px; object-fit:contain; flex-shrink:0; }
.vr-brand h1 { font-size:13px; margin:0 0 4px; }
.vr-header p { margin:2px 0; font-size:10px; }
.vr-meta { text-align:center; font-variant-numeric:tabular-nums; }
.vr-meta h2 { font-size:14px; margin:0 0 4px; }
.vr-client { display:grid; grid-template-columns:1fr 1fr; gap:10px; padding:12px 0; }
.vr-client div:first-child { grid-column:1/-1; }
.vr-client small,.vr-client strong { display:block; }
.vr-client small { font-size:11px; color:#536176; }
.print-preview .print-sheet .vr-components { width:100%; min-width:0; margin:0; border-collapse:collapse; table-layout:fixed; font-size:11px; }
.print-preview .print-sheet .vr-components th,.print-preview .print-sheet .vr-components td { padding:8px 2px; text-align:left; border-bottom:1px solid #dbe0e7; background:#fff; overflow-wrap:anywhere; }
.print-preview .print-sheet .vr-components th { font-size:10px; color:#334155; }
.print-preview .print-sheet .vr-components th:last-child,.print-preview .print-sheet .vr-components td:last-child { text-align:right; width:44%; }
.vr-components small { display:block; font-size:10px; color:#536176; }
.vr-totals { margin:12px 0 0; border-top:1px dashed #64748b; }
.vr-totals div { display:flex; justify-content:space-between; align-items:baseline; gap:8px; padding:6px 0; }
.vr-totals strong { white-space:nowrap; overflow-wrap:normal; font-variant-numeric:tabular-nums; }
.vr-totals .vr-received,.vr-totals .vr-balance { font-size:13px; font-weight:700; }
.vr-totals .vr-credited,.vr-totals .vr-debt-balance { font-size:10px; color:#334155; }
.vr-rate,.vr-footer,.vr-conversion-note { font-size:10px; color:#334155; margin:10px 0 0; }
.vr-footer { padding-top:12px; border-top:1px solid #dbe0e7; }
.receipt-print-help { margin:0; padding:12px 20px; font-size:12px; background:#f1f3f6; color:#334155; }
.print-receipt .print-sheet { width:auto; padding:16px; background:#f1f3f6; }
@media screen { .vr-receipt.vr-print-measure { position:fixed; left:-10000px; top:0; width:80mm; max-width:none; padding:4mm; visibility:hidden; } }
@page valri-receipt { size:80mm 200mm; margin:4mm; }

/* Resúmenes contractuales compactos: estado legal y autorización de obra permanecen separados. */
.contracts-summary-grid.kpi-grid { grid-template-columns:repeat(4,minmax(0,1fr)); gap:10px; margin-bottom:18px; }
.contracts-summary-grid .kpi-card { padding:12px 16px; border-radius:12px; min-width:0; }
.contracts-summary-grid .kpi-card small,
.contracts-summary-grid .kpi-card > div:first-child > span:last-child { display:none; }
.contracts-summary-grid .kpi-label { font-size:12px; text-transform:none; letter-spacing:0; }
.contracts-summary-grid .kpi-value { font-size:24px; margin:3px 0 0; line-height:1.2; }
.contract-detail-overview { border:1px solid var(--border); border-radius:14px; padding:16px; background:#fff; }
.contract-detail-context { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.contract-detail-context > div { min-width:0; }
.contract-detail-context small { display:block; margin-top:4px; }
.contract-detail-links { display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:8px 14px; }
.contract-detail-links button { margin:0; }
.contract-economic-caption { font-size:12px; color:var(--muted); margin:16px 0 8px; }
.contract-economic-summary { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; padding-top:12px; border-top:1px solid var(--border); }
.contract-economic-summary > div { min-width:0; }
.contract-economic-summary span { display:block; font-size:12px; color:var(--muted); margin-bottom:4px; }
.contract-economic-summary strong { display:block; font-size:20px; font-variant-numeric:tabular-nums; white-space:nowrap; overflow-wrap:normal; }
.contract-economic-summary > div:first-child strong { color:var(--red); }
.contract-scope-table { max-width:100%; overflow-x:auto; }
.contract-scope-table td:nth-last-child(-n+2) { white-space:nowrap; overflow-wrap:normal; font-variant-numeric:tabular-nums; }
.contract-scope-table td small { white-space:normal; }
@media(max-width:750px) {
  .contracts-summary-grid.kpi-grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; }
  .contracts-summary-grid .kpi-card { padding:10px 12px; }
  .contract-detail-context { flex-direction:column; gap:12px; }
  .contract-detail-links { justify-content:flex-start; }
  .contract-economic-summary { grid-template-columns:1fr; gap:0; }
  .contract-economic-summary > div { display:flex; align-items:baseline; justify-content:space-between; gap:12px; padding:7px 0; }
  .contract-economic-summary span { margin:0; }
  .contract-economic-summary strong { font-size:18px; }
}
@media print {
  body:has(dialog.print-receipt[open]), dialog.print-receipt[open] { page:valri-receipt; }
  .vr-receipt { width:72mm; max-width:72mm; padding:0; color:#000; font-size:11px; }
  .vr-receipt * { color:#000; }
  .vr-header,.vr-client,.vr-totals,.vr-footer { break-inside:avoid; }
  .vr-components tr { break-inside:avoid; }
}
@media print {
  html:has(.vr-receipt), body:has(.vr-receipt), dialog.print-preview:has(.vr-receipt), dialog.print-preview:has(.vr-receipt) .print-sheet { background:#fff !important; }
  dialog.print-preview:has(.vr-receipt)::backdrop { background:transparent !important; }
}

/* Ingreso compacto: datos compartidos y revisión física por unidad. */
dialog #add-item-form.inventory-ingress-form { display:grid; gap:12px; min-width:0; }
dialog #add-item-form > .field-grid,
.inventory-common-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px 16px; }
.inventory-ingress-form > .field-grid { align-items:end; }
.inventory-ingress-form .field-grid { margin:0; }
.inventory-ingress-form label,
.inventory-common-grid label { min-width:0; margin:0; gap:6px; }
.inventory-ingress-form input,
.inventory-ingress-form select,
.inventory-common-grid input,
.inventory-common-grid select { width:100%; min-width:0; min-height:44px; margin:0; }
.inventory-ingress-caption { margin:0; font-size:13px; }
.inventory-ingress-form .catalog-bootstrap-actions { margin:0; }
.inventory-ingress-form .catalog-bootstrap-actions button { min-height:44px; }
.inventory-ingress-form .catalog-select-header,
.inventory-ingress-form [data-ui-style="u132"] { display:flex; align-items:center; justify-content:space-between; gap:8px; flex-wrap:wrap; }
dialog #add-item-form .catalog-select-header,
dialog #add-item-form [data-ui-style="u132"] { margin:0 0 6px; }
.inventory-ingress-form .btn-link { min-height:44px; padding:6px 4px; }
.inventory-unit-section { border:1px solid var(--border); border-radius:14px; background:#f8fafc; padding:14px; min-width:0; }
.inventory-unit-heading { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:12px; }
.inventory-unit-heading h4 { margin:0; font-size:15px; }
.inventory-unit-heading button { min-height:44px; }
.inventory-unit-list { display:grid; gap:10px; max-height:340px; overflow-y:auto; padding:2px; scrollbar-gutter:stable; }
.inventory-unit-row { background:#fff; border:1px solid var(--border); border-radius:10px; padding:12px; min-width:0; }
.inventory-unit-row-title { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:10px; }
.inventory-unit-row-title strong { font-size:13px; }
.inventory-unit-row-title output { font-weight:700; font-size:14px; color:var(--red); white-space:nowrap; font-variant-numeric:tabular-nums; }
.inventory-unit-measures { display:grid; grid-template-columns:auto minmax(0,1fr) auto minmax(0,1fr); align-items:center; gap:8px; }
.inventory-unit-measures label { margin:0; font-size:12px; }
.inventory-unit-measures input { margin:0; }
.inventory-unit-row-foot { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:10px; flex-wrap:wrap; }
.inventory-unit-verified { display:flex; align-items:center; gap:8px; margin:0; min-height:44px; font-size:12px; cursor:pointer; }
.inventory-ingress-form .inventory-unit-verified input { width:18px; min-height:18px; margin:0; flex:none; }
.inventory-unit-actions { display:flex; gap:8px; }
.inventory-unit-actions button { min-height:44px; padding:7px 12px; font-size:12px; }
.inventory-units-total { display:flex; align-items:center; min-height:36px; margin-top:8px; font-size:13px; font-weight:600; font-variant-numeric:tabular-nums; }
.inventory-unit-feedback { margin:0; font-size:12px; color:var(--muted); }
.inventory-unit-feedback:empty { display:none; }

.inventory-measure-mode-switch { display:flex; gap:12px; flex-wrap:wrap; align-items:center; }
.inventory-mode-label { display:inline-flex; align-items:center; gap:6px; font-size:13px; font-weight:600; cursor:pointer; min-height:36px; margin:0; }
.inventory-mode-label input { width:16px; height:16px; min-height:16px; margin:0; }

.inventory-compact-measures { display:grid; gap:12px; }
.inventory-compact-grid { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:12px; }
.inventory-compact-grid label { margin:0; font-size:12px; font-weight:600; display:grid; gap:4px; }
.inventory-compact-grid input { margin:0; width:100%; min-height:44px; }

.inventory-compact-verify-row { background:#fff; border:1px solid var(--border); border-radius:10px; padding:10px 12px; display:grid; gap:4px; }
.inventory-compact-verify-row small { font-size:12px; line-height:1.4; color:var(--muted); }

.inventory-exceptions-panel { background:#fff; border:1px solid var(--border); border-radius:10px; padding:12px; display:grid; gap:10px; }
.inventory-exceptions-header { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; }
.inventory-exceptions-header strong { font-size:13px; }
.inventory-exceptions-header p { margin:2px 0 0; font-size:11px; }
.inventory-exceptions-list { display:grid; gap:8px; max-height:260px; overflow-y:auto; }
.inventory-exception-row { display:grid; grid-template-columns:auto minmax(0,1fr) minmax(0,1fr) auto auto; align-items:center; gap:8px; padding:8px 10px; border:1px solid #e2e8f0; border-radius:8px; background:#f8fafc; }
.inventory-exception-row label { font-size:12px; margin:0; }
.inventory-exception-row input[type="number"] { min-height:38px; width:100%; margin:0; }
.inventory-exception-row select { min-height:38px; margin:0; }
.inventory-exception-row button { min-height:38px; padding:4px 10px; }

/* Diálogo de registro y corrección de tarifas de inventario */
.item-price-dialog { width:min(720px, calc(100vw - 24px)); }
.price-distinction-grid { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:10px; margin:14px 0; }
.price-type-card { border:1px solid var(--border); border-radius:10px; padding:10px; background:#fff; display:grid; gap:4px; }
.price-type-card.price-type-cost { background:#fbfcfe; border-color:#cbd5e1; }
.price-type-title { font-size:12px; font-weight:700; color:var(--ink); text-transform:uppercase; letter-spacing:0.04em; }
.price-type-unit { font-size:11px; color:var(--red); font-weight:600; }
.price-type-card p { margin:0; font-size:11px; line-height:1.35; color:var(--muted); }
.price-type-card small { font-size:12px; color:#64748b; line-height:1.3; }

.availability-explanation-box { border:1px solid #e2e8f0; border-radius:10px; padding:12px; background:#f8fafc; margin:12px 0; display:grid; gap:8px; }
.availability-explanation-box strong { font-size:13px; color:var(--ink); }
.availability-explanation-box ul { margin:0; padding-left:18px; font-size:12px; color:#334155; line-height:1.45; }
.availability-explanation-box li { margin-bottom:4px; }
.availability-explanation-box .notice-warning { border-left:4px solid #f59e0b; background:#fffbeb; color:#92400e; padding:8px 12px; border-radius:6px; font-size:11.5px; line-height:1.4; margin:4px 0 0; }

.price-scope-selector { border:1px solid var(--border); border-radius:10px; padding:12px; margin:14px 0; display:grid; gap:10px; background:#fff; }
.scope-radio-label { display:flex; align-items:flex-start; gap:8px; font-size:13px; cursor:pointer; margin:0; line-height:1.4; }
.scope-radio-label input { flex:none; width:18px; height:18px; margin-top:2px; }
.price-scope-breakdown { background:#f8fafc; border:1px solid #e2e8f0; border-radius:8px; padding:10px; margin-top:4px; display:grid; gap:8px; }
.scope-summary-row { display:grid; gap:4px; }
.badge-success { display:inline-block; font-size:12px; font-weight:700; color:#15803d; text-transform:uppercase; }
.badge-warning { display:inline-block; font-size:12px; font-weight:700; color:#b45309; text-transform:uppercase; }

.inventory-individual-toolbar { margin-bottom:12px; }
.inventory-exception-area { display:block; font-size:12px; color:var(--muted); margin-top:4px; }
.link-edit-price { font-size:12px; margin-top:2px; display:block; }
.item-price-loading-skeleton { height:140px; margin:16px 0; }
.availability-ready-notice { color:var(--green, #10b981); font-weight:600; }
.badge-margin-inline { margin-left:6px; }
.price-reason-label { margin-top:12px; }
.scope-summary-block { margin-bottom:6px; }
.scope-empty-muted { margin:4px 0; }
.price-type-card label { margin:0; font-size:12px; font-weight:600; }
.price-type-value { font-size:15px; font-weight:700; margin:4px 0; }
.price-type-help { font-size:11px; color:var(--muted); margin:0; line-height:1.35; }
.scope-options { display:grid; gap:8px; margin:8px 0; }
.scope-options label { display:flex; align-items:center; gap:8px; cursor:pointer; font-size:13px; margin:0; }
.scope-items-preview { font-size:12px; color:var(--ink); line-height:1.4; word-break:break-all; }
.scope-excluded-preview { font-size:12px; color:#b45309; margin-top:6px; }
.scope-excluded-preview ul { margin:4px 0 0 16px; padding:0; }
.availability-pending-list { margin:6px 0 6px 18px; padding:0; font-size:12px; color:#b45309; }

@media(max-width:650px) {
  .price-distinction-grid { grid-template-columns:1fr; }
  .inventory-compact-grid { grid-template-columns:1fr; }
  .inventory-exception-row { grid-template-columns:1fr 1fr; gap:6px; }
  .inventory-exception-row select { grid-column:1/-1; }
  .inventory-exception-row label.exception-verify { grid-column:1; }
  .inventory-exception-row button { grid-column:2; justify-self:end; }
}

.inventory-location-dialog { max-width:540px; }
.inventory-location-dialog .dialog-actions { flex-wrap:wrap; }
.inventory-stock-table-wrap { max-width:100%; overflow-x:auto; }
.inventory-stock-table { min-width:1060px; table-layout:auto; }
.inventory-stock-table td { word-break:normal; overflow-wrap:normal; }
.inventory-stock-table td:nth-child(5),
.inventory-stock-table td:last-child,
.inventory-stock-table td:last-child button { white-space:nowrap; overflow-wrap:normal; word-break:normal; }
.inventory-stock-table td:nth-child(5) { font-variant-numeric:tabular-nums; }
.inventory-stock-table td:last-child button { min-width:60px; min-height:44px; }
.inventory-price-options { border:1px solid var(--border); border-radius:12px; padding:0 14px; }
.inventory-price-options summary { min-height:48px; padding:14px 0; cursor:pointer; font-size:14px; font-weight:600; }
.inventory-price-options[open] .inventory-common-grid { padding-top:8px; }
.inventory-price-options p { font-size:12px; margin:12px 0; }
.inventory-item-provenance { display:flex; flex-wrap:wrap; gap:8px 20px; font-size:13px; margin:16px 0; color:var(--muted); }
.inventory-catalog-edit { min-height:44px; margin-top:4px; padding:6px 8px; justify-self:start; }
.inventory-catalog-section .inventory-catalog-list { max-height:280px; overflow-y:auto; padding-right:6px; }
.inventory-catalog-section .inventory-catalog-list li { position:relative; padding-right:72px; min-height:54px; }
.inventory-catalog-section .inventory-catalog-edit { position:absolute; right:4px; top:4px; }
.catalog-entry-dialog .inventory-common-grid { margin:0; }
.catalog-entry-dialog .catalog-entry-form { min-width:0; }
.catalog-entry-dialog button { min-height:44px; }
.catalog-entry-dialog:has(.inventory-common-grid) { width:min(620px,calc(100vw - 24px)); }
.inventory-ingress-form button:focus-visible,
.inventory-ingress-form input:focus-visible,
.inventory-ingress-form select:focus-visible,
.inventory-price-options summary:focus-visible { outline:2px solid var(--red); outline-offset:3px; }
@media(max-width:600px) {
  dialog #add-item-form > .field-grid,
  .inventory-common-grid { grid-template-columns:1fr; gap:12px; }
  .inventory-unit-section { padding:10px; }
  .inventory-unit-row { padding:10px; }
  .inventory-unit-measures { grid-template-columns:1fr 1fr; gap:6px 10px; }
  .inventory-unit-measures label:nth-of-type(1) { grid-column:1; grid-row:1; }
  .inventory-unit-measures input:nth-of-type(1) { grid-column:1; grid-row:2; }
  .inventory-unit-measures label:nth-of-type(2) { grid-column:2; grid-row:1; }
  .inventory-unit-measures input:nth-of-type(2) { grid-column:2; grid-row:2; }
  .inventory-unit-row-foot { gap:4px; }
  .inventory-unit-actions { margin-left:auto; }
  .inventory-unit-list { max-height:390px; }
  .inventory-unit-heading { flex-wrap:wrap; gap:8px; }
}

/* La fila comercial debe adaptarse al ancho útil después del menú lateral. */
#sale-form .line-item-body {
  grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr));
  min-width:0;
}
#sale-form .line-item-body > label:first-child { grid-column:span 2; }
#sale-form .line-item-body label,
#sale-form .line-item-commercial-row label { min-width:0; }
#sale-form .line-item-body input,
#sale-form .line-item-body select,
#sale-form .line-item-commercial-row select { min-width:0; max-width:100%; min-height:44px; }
#sale-form .line-item-commercial-row { grid-template-columns:repeat(2,minmax(0,1fr)); min-width:0; }
@media(max-width:600px) {
  #sale-form .line-item-body > label:first-child { grid-column:1/-1; }
  #sale-form .line-item-commercial-row { grid-template-columns:minmax(0,1fr); }
}
.sketchcut-pieces-dialog { width: min(880px, calc(100vw - 24px)); }
.sketchcut-pieces-heading, .sketchcut-pieces-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.sketchcut-pieces-heading h2 { margin: 0; }
.sketchcut-pieces-toolbar { margin-top: 12px; }
.sketchcut-pieces-list { display: grid; gap: 10px; max-height: 45vh; overflow-y: auto; padding: 2px; }
.sketchcut-piece-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.5fr) auto; align-items: end; gap: 10px; padding: 10px; border: 1px solid #dce3ec; border-radius: 10px; }
.sketchcut-piece-row label { min-width: 0; margin: 0; gap: 5px; }
.sketchcut-piece-row input { min-width: 0; width: 100%; min-height: 44px; margin: 0; }
.sketchcut-piece-row button, .sketchcut-pieces-heading button, .sketchcut-pieces-dialog form > button { min-height: 44px; }
.sketchcut-piece-row.sketchcut-piece-readonly { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.sketchcut-piece-readonly small { grid-column: 1 / -1; overflow-wrap: anywhere; }
.sketchcut-review-check { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.sketchcut-review-check input { width: 20px; min-width: 20px; margin: 0; }
.cut-version-list li { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.cut-plan-picker { margin-top: 12px; }
.cut-plan-selection { display: grid; grid-template-columns: minmax(0, 1fr) 80px; gap: 10px; align-items: center; margin: 8px 0; }
.cut-plan-selection input { min-width: 0; width: 100%; margin: 0; }
.cut-physical-review { display: flex; gap: 10px; align-items: center; margin: 12px 0; }
.cut-physical-review input { flex: 0 0 20px; width: 20px; min-width: 20px; margin: 0; }
.cut-piece-origin { grid-column: 1 / -1; overflow-wrap: anywhere; }
#finish-cut-form .client-piece-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
#finish-cut-form .client-piece-row label, #finish-cut-form .client-piece-row input { min-width: 0; }
#finish-cut-form .cut-finish-intro { margin: 0 0 10px; }
#finish-cut-form .banner { padding: 10px 12px; margin: 10px 0; }
.cut-finish-context, .cut-finish-notes { margin: 10px 0; }
.cut-finish-context summary, .cut-finish-notes summary { cursor: pointer; min-height: 36px; align-content: center; font-weight: 600; }
#finish-cut-form .cut-finish-yield { margin: 10px 0; padding: 10px; }
#finish-cut-form .client-piece-row { margin: 6px 0; padding: 10px; }
@media(max-width:600px) {
  #finish-cut-form .facts { grid-template-columns: minmax(0,1fr); }
  #finish-cut-form .cut-output-header { flex-wrap: wrap; gap: 8px; }
  #finish-cut-form .remnant-builder { padding: 10px; }
}
@media (max-width: 600px) {
  .sketchcut-piece-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sketchcut-piece-row label:nth-child(4) { grid-column: 1 / -1; }
  .sketchcut-piece-row button { justify-self: start; }
}
.origin-cut-form, .physical-order-actions { display: grid; gap: 12px; }
.physical-order-selector { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.physical-order-selector select { min-width: 0; }
.origin-cut-form label, .order-physical-row label { margin: 0; display: grid; gap: 4px; }
.origin-cut-form .sketchcut-review-check { display: flex; }
.order-physical-row input { height: 42px; padding: 8px; }
.origin-remnant-row { padding: 12px; margin-bottom: 10px; border: 1px solid #dce3ec; border-radius: 10px; display: grid; gap: 10px; }
.origin-measures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.order-physical-list { display: grid; gap: 10px; max-height: 48vh; overflow: auto; padding: 2px; }
.order-physical-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; border: 1px solid #dce3ec; border-radius: 10px; padding: 10px; }
.order-physical-row input { min-width: 0; width: 100%; }
.origin-cut-form [hidden], #order-physical-form [hidden] { display: none !important; }
@media (max-width: 600px) { .order-physical-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.inventory-lot-label-action { margin: 8px 0; font-size: 13px; }

/* Approved Modernize direction, scoped to Stock. Other modules and dialogs
   retain their current workflows and styles in this first integration. */
.inventory-modern-stock { border: 1px solid var(--line); border-radius: 8px; box-shadow: none; padding: 0; overflow: hidden; }
#app .inventory-modern-stock .filter-bar { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); padding: 16px 18px; gap: 10px; margin: 0; }
#app .inventory-modern-stock .filter-bar input[type="search"], #app .inventory-modern-stock .filter-bar select { width: 100%; min-width: 0; }
#app .inventory-modern-stock .inventory-group-control { grid-column: 1 / -1; }
.inventory-modern-stock .inventory-group-control { font-size: 12px; font-weight: 500; }
.inventory-modern-stock .inventory-result-count { padding: 0 18px 12px; margin: 0; font-size: 12px; color: var(--muted); }
.inventory-modern-products { border-top: 1px solid var(--line); }
.inventory-modern-product { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.inventory-modern-product:last-child { border-bottom: 0; }
.inventory-modern-product > summary { display: grid; grid-template-columns: minmax(190px, 2fr) minmax(75px, .7fr) minmax(95px, .8fr) minmax(105px, 1fr) minmax(105px, 1fr) auto; gap: 16px; min-height: 90px; padding: 16px 18px; list-style: none; }
.inventory-modern-product > summary::-webkit-details-marker { display: none; }
.inventory-modern-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.inventory-modern-identity strong { font-size: 14px; line-height: 1.4; }
.inventory-modern-identity small { font-size: 12px; }
.inventory-material-thumbnail { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #f5f6f8; color: #a0a8b4; }
.inventory-material-thumbnail img { width: 100%; height: 100%; object-fit: cover; }
.inventory-modern-quantity, .inventory-modern-area, .inventory-modern-price { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.inventory-modern-product small { color: var(--muted); font-size:12px; line-height: 1.4; }
.inventory-modern-quantity strong, .inventory-modern-area strong, .inventory-modern-price strong { font-size: 13px; font-weight: 650; }
.inventory-modern-product .inventory-product-actions { gap: 10px; }
.inventory-modern-product .compact-btn { font-size: 12px; min-height: 36px; padding: 7px 10px; white-space: nowrap; }
.inventory-expand-mark { font-size: 20px; color: var(--muted); }
.inventory-modern-product[open] > summary .inventory-expand-mark { transform: rotate(180deg); }
.inventory-modern-product > .inventory-group-detail { padding: 12px 18px 18px; background: #fafbfd; }
.inventory-modern-product .inventory-lot { border: 1px solid var(--line); border-radius: 6px; background: white; margin-bottom: 8px; overflow: hidden; }
.inventory-modern-product .inventory-lot > summary { padding: 12px 14px; }
.inventory-modern-product .inventory-lot-detail { padding: 0 12px 12px; }
.inventory-modern-product .inventory-stock-table { font-size: 13px; }
.inventory-modern-product .inventory-stock-table th, .inventory-modern-product .inventory-stock-table td { padding: 10px; }
@media (max-width: 1300px) {
  .inventory-modern-product > summary { grid-template-columns: minmax(170px, 2fr) minmax(65px, .7fr) minmax(80px, .8fr) minmax(85px, 1fr) minmax(85px, 1fr) auto; gap: 10px; padding-inline: 14px; }
  .inventory-modern-product .compact-btn { white-space: normal; max-width: 82px; }
}
@media (max-width: 900px) {
  .inventory-modern-product > summary { grid-template-columns: 1fr 1fr auto; gap: 14px; }
  .inventory-modern-identity { grid-column: 1 / 3; }
  .inventory-modern-product .inventory-product-actions { grid-column: 3; grid-row: 1; }
  .inventory-modern-product .inventory-modern-quantity, .inventory-modern-product .inventory-modern-area { grid-row: 2; }
  .inventory-modern-price { grid-row: 3; }
  .inventory-modern-product > .inventory-group-detail { padding: 10px; }
  .inventory-modern-product .inventory-group-totals { flex-direction: column; align-items: flex-end; }
}
@media (max-width: 500px) {
  #app .inventory-modern-stock .filter-bar { padding: 12px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  #app .inventory-modern-stock .filter-bar input[type="search"] { grid-column: 1 / -1; }
  .inventory-modern-product > summary { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 68px; padding: 14px 12px; gap: 12px 8px; }
  .inventory-modern-identity { gap: 8px; }
  .inventory-material-thumbnail { width: 34px; height: 34px; flex-basis: 34px; }
  .inventory-modern-identity strong { font-size: 13px; }
  .inventory-modern-product .compact-btn { min-height: 44px; padding: 5px; font-size:12px; }
  .inventory-modern-product .inventory-product-actions { gap: 4px; }
  .inventory-modern-product .inventory-modern-area, .inventory-modern-price:nth-of-type(5) { grid-column: 2 / 4; }
  .inventory-modern-product .inventory-lot > summary { flex-direction: row; }
}
.print-inventory-labels .print-sheet { width: min(100%, 148mm); padding: 0; }
.inventory-label-pages { display: grid; gap: 16px; }
.inventory-a5-label { box-sizing: border-box; min-height: 194mm; padding: 7mm; background: #fff; color: #111827; border: 1px solid #64748b; display: flex; flex-direction: column; align-items: stretch; gap: 4mm; overflow-wrap: anywhere; }
.inventory-a5-brand { display: flex; align-items: center; gap: 4mm; padding-bottom: 3mm; border-bottom: 2px solid #c8102e; }
.inventory-a5-brand img { width: 20mm; height: 20mm; object-fit: contain; }
.inventory-a5-brand div { display: grid; gap: 2mm; }
.inventory-a5-brand strong { font-size: 16px; }
.inventory-a5-brand span { font-size: 13px; }
.inventory-a5-code { margin: 0; font: 800 32px Arial,sans-serif; text-align: center; letter-spacing: 1px; }
.inventory-a5-product { margin: 0; font-size: 20px; font-weight: 700; text-align: center; }
.inventory-a5-variant { margin: 0; font-size: 15px; text-align: center; }
.inventory-a5-measures { display: grid; gap: 2mm; text-align: center; padding: 3mm 0; border-block: 1px solid #e2e8f0; }
.inventory-a5-measures strong { font-size: 22px; }
.inventory-a5-measures span { font-size: 14px; }
.inventory-a5-measures small { font-size: 11px; }
.print-sheet .inventory-a5-qr { width: 52mm; height: 52mm; max-width: 100%; object-fit: contain; align-self: center; }
.inventory-a5-provenance { display: grid; gap: 2mm; margin: 0; font-size: 13px; }
.inventory-a5-provenance div { display: grid; grid-template-columns: 21mm minmax(0, 1fr); gap: 2mm; }
.inventory-a5-provenance dt { color: #475569; }
.inventory-a5-provenance dd { margin: 0; font-weight: 600; }
.inventory-a5-label footer { margin-top: auto; padding-top: 2mm; border-top: 1px solid #cbd5e1; text-align: center; font-size: 10px; color: #475569; }
@media (max-width: 600px) { .inventory-a5-label { min-height: 0; padding: 16px; gap: 12px; } .inventory-a5-product { font-size: 17px; } .inventory-a5-code { font-size: 27px; } }
@page valri-label-a5 { size: 148mm 210mm; margin: 8mm; }
@media print {
  body:has(dialog.print-inventory-labels[open]) { page: valri-label-a5; }
  body:has(dialog.print-inventory-labels[open]) dialog.print-inventory-labels[open] .print-sheet { padding: 0 !important; }
  .inventory-label-pages { display: block; }
  .inventory-a5-label { width: 132mm; min-height: 190mm; padding: 6mm; gap: 2mm; margin: 0; line-height: 1.15; break-inside: avoid; break-after: page; page: valri-label-a5; }
  .inventory-a5-measures { padding: 2mm 0; }
  .print-sheet .inventory-a5-qr { width: 44mm; height: 44mm; flex-shrink: 0; }
  .inventory-a5-label:last-child { break-after: auto; }
  .inventory-a5-brand { break-inside: avoid; }
}
/* Recepción técnica en pantalla: evidencia de custodia, no firma contractual. */
.th-screen-signature { min-width: 0; padding: 12px; border: 1px solid #dce3ee; border-radius: 10px; }
.th-screen-signature canvas { display: block; width: 100%; height: 130px; margin: 8px 0; background: #fff; border: 1px solid #dce3ee; border-radius: 8px; touch-action: none; }
.th-screen-signature > label { display: flex; align-items: flex-start; gap: 8px; margin-top: 10px; }
.th-screen-signature > label input { width: auto; flex: 0 0 auto; }

/* El área ampliada usa un borrador; cancelar conserva la firma anterior. */
:is(#sig-canvas,#conformity-signature,.th-screen-signature canvas).signature-pad-preview {
  display:block; width:100%; max-width:640px; height:auto; aspect-ratio:8 / 3;
  background:#fff; border:1px solid #cbd5e1; border-radius:8px; touch-action:none;
}
.signature-open-button { min-height:44px; margin-top:10px; }
.sig-canvas-actions { flex-wrap:wrap; gap:10px; }
dialog.signature-editor-dialog {
  width:min(960px,calc(100vw - 24px)); height:min(680px,calc(100dvh - 24px)); max-width:none; max-height:none;
  padding:20px; border:1px solid var(--line); border-radius:18px; overflow:hidden;
}
dialog.signature-editor-dialog[open] { display:flex; flex-direction:column; gap:14px; }
.signature-editor-dialog header { flex:none; }
.signature-editor-dialog h2 { font-size:1.2rem; margin:0 0 4px; }
.signature-editor-dialog header p { margin:0; color:var(--muted); font-size:.9rem; }
.signature-editor-surface { flex:1; min-height:80px; min-width:0; overflow:hidden; background:#fff; border:2px dashed #94a3b8; border-radius:12px; }
.signature-editor-surface canvas { display:block; width:100%; height:100%; touch-action:none; cursor:crosshair; }
.signature-editor-actions { display:flex; justify-content:flex-end; gap:10px; flex-wrap:wrap; flex:none; }
.signature-editor-actions button { min-height:44px; }
@media screen {
  .dispatch-act-dialog .dispatch-act-toolbar { position:sticky; top:0; z-index:2; background:#fff; padding:12px 16px; margin:0; border-bottom:1px solid var(--line); display:flex; justify-content:flex-end; flex-wrap:wrap; gap:10px; }
  .dispatch-act-toolbar button { min-height:44px; }
}
@media screen and (max-width:600px) {
  dialog.signature-editor-dialog { width:100vw; height:100dvh; max-height:100dvh; margin:0; border:0; border-radius:0; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .signature-editor-actions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
  .signature-editor-actions button { padding-inline:8px; white-space:normal; }
  .dispatch-act-dialog .act-brand { display:grid; grid-template-columns:44px minmax(0,1fr); align-items:start; gap:10px; }
  .dispatch-act-dialog .dispatch-act-logo { width:44px; height:44px; }
  .dispatch-act-dialog .act-brand h2 { font-size:15px; }
  .dispatch-act-dialog .act-info-block { padding-block:6px; }
}
@media print { dialog.signature-editor-dialog { display:none !important; } }

.sale-incidence-actions { display:flex; margin:0 0 12px; }

/* Integración Decolecta: Consultas DNI / RUC y estado */
.doc-search-label {
  display: flex;
  flex-direction: column;
}
.doc-search-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.doc-search-input-group {
  display: flex;
  gap: 6px;
  align-items: center;
}
.doc-search-input-group input {
  flex: 1 1 auto;
  min-width: 0;
}
.btn-doc-lookup {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 12px;
  min-height: 38px;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  flex: 0 0 auto;
  cursor: pointer;
  border-radius: var(--radius-sm, 6px);
}
.doc-lookup-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm, 4px);
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  word-break: break-word;
}
.doc-lookup-status.is-loading {
  background: #f1f5f9;
  color: #475569;
}
.doc-lookup-status.is-ok {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}
.doc-lookup-status.is-warn {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}
.doc-lookup-status.is-error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* Controles de vista (Tarjetas / Tabla): alto táctil en pantallas pequeñas o táctiles. */
@media (max-width: 768px), (pointer: coarse) {
  .btn-toggle-view { min-height: 44px; }
}
/* Texto auxiliar: tamaño fijo de 12 px, nunca por debajo. */
small { font-size: 12px; }
