:root {
  /* --- Pro-level color palette (Vibrant HSL) --- */
  --bg: #07090f;
  /* Deep Space */
  --panel: rgba(17, 24, 39, 0.7);
  /* Glassy Panel */
  --panel-2: rgba(31, 41, 55, 0.8);
  --panel-3: rgba(55, 65, 81, 0.9);

  --muted: #9ca3af;
  --text: #f3f4f6;
  --text-dim: #9ca3af;

  --primary: #6366f1;
  /* Indigo Glow */
  --primary-alt: #4f46e5;
  --accent: #8b5cf6;
  /* Violet Accent */

  --ok: #10b981;
  /* Emerald */
  --ok-glow: rgba(16, 185, 129, 0.2);
  --warn: #f59e0b;
  /* Amber */
  --danger: #ef4444;
  /* Rose */
  --danger-glow: rgba(239, 68, 68, 0.2);

  --border: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.2);

  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --glass: blur(12px);
  --panel-spacing: 1.5rem;
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  overflow-x: hidden;
}

h1,
h2,
h3,
.brand-text strong,
.logo {
  font-family: 'Outfit', sans-serif;
  letter-spacing: -0.02em;
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  height: 100vh;
}

/* Sidebar Glassmorphism */
.sidebar {
  background: var(--panel);
  backdrop-filter: var(--glass);
  padding: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}

.sidebar__header {
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 8px;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  font-weight: 800;
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.brand-text strong {
  display: block;
  font-size: 1.2rem;
  line-height: 1;
  color: #fff;
}

.brand-text span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar__user {
  background: rgba(255, 255, 255, 0.03);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.user-email {
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  word-break: break-all;
}

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

.nav-group {
  color: var(--muted);
  font-size: 10px;
  margin: 16px 12px 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.nav-item {
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text-dim);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 500;
  font-size: 14px;
}

.form-field--spaced {
  margin-top: 1.25rem !important;
  /* Proporcional a los demás elementos */
  margin-bottom: 1.25rem !important;
  padding: 0.75rem 0 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  margin: 0 !important;
  font-size: 0.95rem;
  color: var(--text);
  padding: 0.5rem 0;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  transform: translateX(4px);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), transparent);
  border-left: 3px solid var(--primary);
  color: #fff;
  border-radius: 4px 12px 12px 4px;
}

.sidebar__footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.app-version {
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  opacity: 0.5;
  letter-spacing: 0.05em;
  font-weight: 500;
  text-transform: uppercase;
  user-select: none;
}

/* Main Area */
.main {
  padding: 32px 40px;
  overflow-y: auto;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 40px;
}

.page-head .actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.search-filters {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-width: 0;
  background: transparent;
  backdrop-filter: none;
  padding: 0;
  border-radius: 0;
  border: none;
  margin-bottom: 0;
}

.filters-row {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.search {
  position: relative;
  flex: 0 0 320px;
}

.search input[type="search"] {
  width: 100%;
  height: 48px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 14px;
  padding: 0 16px 0 44px;
  outline: none;
  transition: all 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 16px center;
  font-size: 14px;
}

.search input[type="search"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
  background-color: rgba(31, 41, 55, 1);
}

/* Filter select styling */
.filter {
  display: flex;
  align-items: center;
}

/* Estilos base para todos los inputs, selects y textareas */
.filter-select,
select,
input:not([type="checkbox"]):not([type="radio"]),
textarea {
  background-color: var(--panel) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0 16px;
  height: 48px;
  outline: none;
  font-family: inherit;
  transition: all 0.2s;
  width: 100%;
  font-size: 14px;
}

textarea {
  height: auto;
  padding-top: 12px;
  padding-bottom: 12px;
  line-height: 1.5;
  resize: vertical;
}

select option {
  background-color: rgba(17, 24, 39, 0.90);
  color: var(--text);
  padding: 12px;
  min-height: 24px;
}

/* Fix específico para input de color que suele ser más alto */
input[type="color"] {
  padding: 4px;
  cursor: pointer;
}

/* Ocultar flechas en inputs numericos de webkit/firefox */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none !important;
  appearance: none !important;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield !important;
  appearance: textfield !important;
}

.filter-select {
  min-width: 160px;
  cursor: pointer;
}

.filter-select:hover {
  border-color: rgba(124, 58, 237, .35);
}

/* Estilos específicos para selects (flecha personalizada) */
.filter-select,
select {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 16px !important;
  padding-right: 40px !important;
  cursor: pointer;
}

/* Asegurar que los inputs NO tengan la flecha de los selects */
input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not(select):not(.filter-select) {
  background-image: none !important;
}


.filter-select:focus,
select:focus,
input:focus,
textarea:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2) !important;
}

.filter-select option,
select option {
  background-color: #111827 !important;
  color: #ffffff !important;
  padding: 12px;
}

/* Dropdown arrow fix */
select {
  padding-right: 40px !important;
}

/* Multi-select styling */
.multi-select {
  position: relative;
  min-width: 200px;
  width: 100%;
  max-width: 300px;
}

.multi-select-display {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 48px;
  transition: border-color 0.15s;
}

.multi-select-display:hover {
  border-color: rgba(124, 58, 237, .35);
}

.multi-select-display.focused {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, .15);
}

.multi-select-placeholder {
  color: var(--muted);
  font-size: 14px;
}

.multi-select-tag {
  background: var(--accent);
  color: white;
  border-radius: 16px;
  padding: 4px 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  text-transform: lowercase;
}

.multi-select-tag-remove {
  cursor: pointer;
  font-weight: bold;
  margin-left: 2px;
  font-size: 14px;
  line-height: 1;
}

.multi-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(17, 24, 39, 0.90);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 4px;
  z-index: 1000;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 100%;
}

.sidebar__decoration {
  display: none;
}

.nav-item span {
  width: 20px;
  text-align: center;
}

.multi-select-dropdown.show {
  display: block;
}

.multi-select-search {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.multi-select-search input {
  width: 100%;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
  outline: none;
  font-size: 14px;
  box-sizing: border-box;
}

.multi-select-search input:focus {
  border-color: var(--accent);
}

.multi-select-options {
  max-height: 200px;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
}

.multi-select-option {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
}

.multi-select-option:hover {
  background: var(--background);
}

.multi-select-option.selected {
  background: rgba(124, 58, 237, .1);
  color: var(--accent);
}

.multi-select-option input[type="checkbox"] {
  pointer-events: none;
  margin: 0;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.multi-select-option span {
  font-size: 14px;
  line-height: 1.2;
}

/* Color filter */
.color-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.filter-label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.color-swatches {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  flex: 1;
  max-width: 100%;
  padding: 12px 14px;
  cursor: grab;
  /* Ocultar scrollbar visual para drag-to-scroll */
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, black 0%, black 92%, transparent 100%);
  mask-image: linear-gradient(to right, black 0%, black 92%, transparent 100%);
}

.color-swatches::-webkit-scrollbar {
  display: none;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.color-swatch:hover {
  transform: scale(1.15);
  border-color: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
}

.color-swatch.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

/* Mejorar visibilidad de colores claros */
.color-swatch[style*="background-color: #ffffff"],
.color-swatch[style*="background-color: #FFFFFF"],
.color-swatch[style*="background-color: white"],
.color-swatch[style*="background-color: rgb(255, 255, 255)"],
.color-swatch[style*="background-color: #f"],
.color-swatch[style*="background-color: #F"] {
  border: 1px solid rgba(255, 255, 255, 0.4) !important;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.color-swatch:not([style*="background"]) {
  width: auto;
  padding: 0 14px;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  background: var(--panel-2);
}

.color-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  min-width: 40px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  transition: all 0.2s;
}

.switch:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-hover);
}

.switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 400px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.filaments-only {
  display: flex;
}

/* File input styling */
input[type="file"] {
  padding: 8px 12px;
  height: auto;
  line-height: 1.5;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  margin-right: 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

input[type="file"]::file-selector-button:hover {
  background: var(--primary-alt);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

/* Mensaje de carga */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--muted);
  font-size: 1.1em;
  gap: 0.5rem;
}

.loading-dots {
  display: flex;
  gap: 0.25rem;
  height: 1.5rem;
  align-items: flex-end;
}

.loading-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--text);
  animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes bounce {

  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.3;
  }

  40% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

/* Skeleton Loader */
.skeleton-container {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.skeleton-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  animation: pulse 1.5s infinite ease-in-out;
}

.skeleton-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
}

.skeleton-text {
  height: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  width: 100%;
}

.skeleton-text.short {
  width: 40%;
}

.skeleton-text.medium {
  width: 70%;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 0.4;
  }

  50% {
    opacity: 0.8;
  }
}

/* Table Component */
.table {
  background: var(--panel);
  backdrop-filter: var(--glass);
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.thead {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  padding: 18px 24px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
}

.th-sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.th-sortable:hover {
  color: #fff;
}

.tr {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 12px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  transition: all 0.2s;
  cursor: pointer;
}

.tr:last-child {
  border-bottom: none;
}

.tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

.tr:active {
  transform: scale(0.995);
}

.td-right {
  text-align: right;
}

.name-cell {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Spool Wheel - Spoolman style */
/* Spool Donut - Pie chart style for inventory table */
.spool {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  position: relative;
  /* Lo que ya no queda se ve en el mismo color, tenue: un carrete vacío no pierde su identidad */
  background: conic-gradient(var(--spool-color, #ccc) calc(var(--spool-pct, 0) * 100%),
      color-mix(in srgb, var(--spool-color, #ccc) 22%, transparent) 0%);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2), var(--spool-glow, 0 0 0 0 transparent);
  flex-shrink: 0;
  transition: transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Acabado (silk, arcoíris, madera…): una capa sobre el arco del stock restante, recortada al mismo ángulo */
.spool::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background-image: var(--spool-finish-image, none);
  background-size: var(--spool-finish-size, auto);
  -webkit-mask-image: conic-gradient(#000 calc(var(--spool-pct, 0) * 100%), transparent 0);
  mask-image: conic-gradient(#000 calc(var(--spool-pct, 0) * 100%), transparent 0);
}

.spool::after {
  content: "";
  position: absolute;
  inset: 10px;
  background: var(--bg-card, #1a1a1a);
  border-radius: 50%;
  box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.5);
}

/* Animación de Destello (Glow) para actualizaciones */
@keyframes flash-green {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    transform: scale(1);
  }

  50% {
    box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    transform: scale(1.05);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    transform: scale(1);
  }
}

.spool-flash {
  animation: flash-green 1s ease-out;
  z-index: 10;
}

/* Versión sutil para el dashboard */
@keyframes flash-green-subtle {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.spool-flash-subtle {
  animation: flash-green-subtle 0.8s ease-out;
}

/* Animación de Rotación */
@keyframes rotate-spool {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.spool.is-printing {
  animation: rotate-spool 4s linear infinite;
  box-shadow:
    0 0 15px var(--spool-color, var(--primary)),
    0 0 0 2px #555;
}

.title {
  font-weight: 600;
  color: #fff;
  font-size: 15px;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

/* Badges & Chips */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text);
}

/* Una sola insignia para toda la web: base + variante (ok, aviso, peligro, info, apagada); .badge--text = sin mayúsculas */
.badge--text {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
}

.badge--ok {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--ok);
}

.badge--warn {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--warn);
}

.badge--danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.badge--info {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--link);
}

.badge--muted {
  background: transparent;
  color: var(--muted);
}

.badge--pla {
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.3);
  background: rgba(96, 165, 250, 0.08);
}

.badge--petg {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.3);
  background: rgba(52, 211, 153, 0.08);
}

.badge--abs {
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
}

.chip {
  display: inline-flex;
  padding: 6px 14px;
  border-radius: 10px;
  background: var(--ok-glow);
  color: var(--ok);
  font-weight: 600;
  font-size: 13px;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.chip--low {
  background: var(--danger-glow);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

/* --- Botón AGREGAR (Acción Principal) --- */
#addBtn {
  padding: 16px 40px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  color: white;
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  font-size: 16px;
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 24px -6px rgba(99, 102, 241, 0.7);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  letter-spacing: 0.02em;
  position: relative;
  overflow: hidden;
}

#addBtn i {
  width: 20px;
  height: 20px;
  stroke-width: 3px;
}

#addBtn:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 15px 30px -5px rgba(99, 102, 241, 0.8);
  filter: brightness(1.1);
}

#addBtn:active {
  transform: translateY(0) scale(0.98);
}

#addBtn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.2),
      transparent);
  transition: 0.5s;
}

#addBtn:hover::after {
  left: 100%;
}

.page-head .actions {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: 20px;
}

.btn {
  min-height: 44px;
  padding: 12px 24px;
  border-radius: 14px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.02em;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 4px 15px -4px rgba(99, 102, 241, 0.5);
}

.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 0 8px 20px -5px rgba(99, 102, 241, 0.4);
}

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

.btn--ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn--ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
  color: #fff;
}

.btn--sm {
  min-height: 36px;
  padding: 6px 12px;
  height: auto !important;
  font-size: 11px !important;
  border-radius: 10px !important;
}

.btn--danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  box-shadow: 0 4px 15px -4px rgba(239, 68, 68, 0.4);
}

.btn--danger:hover {
  box-shadow: 0 8px 20px -5px rgba(239, 68, 68, 0.5);
}

/* Secciones plegables (Datos técnicos, Compra y ubicación): sin márgenes propios, el espacio lo da
   la grilla del formulario, así cerradas no dejan huecos */
.tech-details {
  display: block;
}

.tech-details > summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 600;
}

/* Valores cargados junto al título, solo con la sección cerrada */
.details-hint {
  margin-left: 8px;
  color: var(--muted);
  font-weight: 400;
  font-size: 0.85em;
}

.tech-details[open] .details-hint {
  display: none;
}

.tech-details .tech-fields {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  /* abajo, el mismo aire que entre filas del formulario: así lo que sigue no queda pegado */
  padding: 8px 0 16px;
}

.form-field--full {
  grid-column: 1 / -1;
}

/* Modal Actions Consistency */
.modal .row.actions {
  display: flex;
  gap: 16px;
  margin-top: 32px;
  justify-content: flex-end;
}

.modal .btn {
  height: 44px;
}

.modal .btn--primary {
  flex: 1.5;
}

.modal .btn--danger {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  box-shadow: none;
  margin-right: auto;
  /* Empuja el botón a la izquierda si hay espacio */
}

.modal .btn--danger:hover {
  background: var(--danger);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

/* Dialogs & Cards */
.modal::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.modal {
  border: none;
  background: transparent;
  box-shadow: none;
  margin: auto;
  outline: none;
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.card {
  background: var(--panel-2);
  backdrop-filter: blur(30px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  color: var(--text);
  min-width: 440px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

.card h3 {
  margin-top: 0;
  font-size: 1.5rem;
  margin-bottom: 24px;
  color: #fff;
  font-weight: 700;
}

.row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.row.end {
  justify-content: flex-end;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.card input,
.card select,
.card textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  transition: all 0.2s;
  outline: none;
}

.card input:focus,
.card select:focus,
.card textarea:focus {
  border-color: var(--primary);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.card label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
  display: block;
}

/* Stats Cards (Nuevo) */
/* Excedente de consumo: el rollo siguió imprimiendo con el stock en 0 */
.chip--overuse {
  margin-left: 6px;
  padding: 6px 10px;
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.35);
  cursor: help;
}

.overuse-text {
  color: #f59e0b;
}

.overuse-notice {
  margin: 12px 0 4px;
  padding: 12px 14px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 12px;
  background: rgba(245, 158, 11, 0.08);
  font-size: 0.85rem;
  line-height: 1.4;
}

.overuse-notice p {
  margin: 0 0 10px;
}

.overuse-notice__row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.overuse-notice__row input {
  flex: 1 1 160px;
}

/* Mi cuenta: cabecera con la cuenta, tarjetas de filas (texto a la izquierda, control a la derecha) y salir */
.profile-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 640px;
  margin: 8px auto 0;
}

.profile-page .card {
  min-width: 0;
  padding: 0;
  border-radius: 20px;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px !important;
}

.profile-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.35);
  color: #fff;
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
}

.profile-avatar svg {
  width: 26px;
  height: 26px;
}

.profile-hero__who {
  flex: 1;
  min-width: 0;
}

.profile-hero__name,
.profile-hero__email {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-hero__name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
}

.profile-hero__email {
  margin-top: 2px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.profile-hero__version {
  flex-shrink: 0;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.profile-card__title {
  margin: 0;
  padding: 18px 24px 8px;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 16px 24px;
  border: 0;
  border-top: 1px solid var(--border);
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
}

.profile-card__title + .profile-row {
  border-top: 0;
}

.profile-page .profile-row__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

.profile-page .profile-row__text strong {
  font-weight: 600;
}

.profile-page .profile-row__text small {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

.profile-row--link {
  cursor: pointer;
  transition: background 0.2s;
}

.profile-row--link:last-child {
  border-radius: 0 0 20px 20px;
}

.profile-row--link:hover {
  background: rgba(255, 255, 255, 0.04);
}

.profile-row--link:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.profile-row--link > svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

/* Interruptor: el mismo checkbox de siempre, dibujado como llave */
.profile-switch {
  display: inline-flex;
  flex-shrink: 0;
}

.profile-switch input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 44px;
  height: 26px;
  margin: 0;
  border: 1px solid var(--border-hover);
  border-radius: 999px;
  background: var(--panel-3);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.profile-switch input::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s;
}

.profile-switch input:checked {
  border-color: var(--primary);
  background: var(--primary);
}

.profile-switch input:checked::before {
  transform: translateX(18px);
}

.profile-switch input:focus-visible,
.profile-number input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.profile-switch input:disabled,
.profile-number input:disabled {
  cursor: default;
  opacity: 0.5;
}

.profile-number {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.profile-row .profile-number input[type='number'] {
  width: 84px;
  height: 40px;
  padding: 0 12px;
  text-align: right;
}

.profile-logout {
  justify-content: center;
  width: 100%;
}

@media (max-width: 480px) {
  .profile-hero {
    flex-wrap: wrap;
    padding: 16px 18px !important;
  }

  .profile-hero__version {
    flex-basis: 100%;
    padding: 0;
    border: 0;
    text-align: center;
  }

  .profile-card__title {
    padding: 16px 18px 6px;
  }

  .profile-row {
    padding: 14px 18px;
  }
}

/* Encabezado de modal con acción secundaria (p. ej. "Compré otro igual") */
/* Modal "Compré otro igual" */
.clone-help {
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.size-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.size-chip {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.size-chip:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.size-chip.active {
  border-color: var(--primary);
  background: var(--panel-2);
  color: var(--text);
}

/* Pestañas del listado de filamentos: Activos / Agotados / Archivados */
/* Barra sobre la tabla: pestañas + "Agrupar por filamento" */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.list-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.group-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
}

.group-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

/* Vista agrupada: fila de un tipo con varios rollos y sus rollos desplegados.
   Sin flecha: el carrete del tipo (con el total) y al lado sus rollos en chiquito, superpuestos,
   cada uno con su carga; con más de 3, "+N". Desplegado, los rollos cuelgan de una línea que
   sale del carrete del tipo. */
.tr--group .title {
  font-weight: 700;
}

/* Ancho fijo del ícono: carrete (38) + 3 rollitos o "+N" de 24 encimados 6 = 92px */
.spool-stack {
  display: flex;
  /* Los rollitos apoyados sobre la base del carrete del tipo */
  align-items: flex-end;
  width: 92px;
  flex-shrink: 0;
}

/* Las filas de un solo rollo reservan el mismo ancho para que los nombres queden alineados */
.list--stacked .tr:not(.tr--group):not(.tr--child) .name-cell > .spool {
  margin-right: 54px;
}

.spool-stack .spool {
  z-index: 3;
  /* La parte vacía del carrete es translúcida: fondo opaco para tapar al de atrás */
  background-color: #141a25;
}

.spool-stack .spool-mini,
.spool-more {
  width: 24px;
  height: 24px;
  margin-left: -6px;
  box-shadow: 0 0 0 2px #141a25;
}

/* En reposo los rollitos van más juntos (4px más encimados cada uno); al pasar el mouse o con
   el tipo desplegado se abren hasta su lugar */
.spool-stack .spool-mini,
.spool-stack .spool-more {
  transform: translateX(calc(var(--i, 0) * -4px));
  transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.tr--group:hover .spool-stack .spool-mini,
.tr--group:hover .spool-stack .spool-more,
.tr--expanded .spool-stack .spool-mini,
.tr--expanded .spool-stack .spool-more {
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  .spool-stack .spool-mini,
  .spool-stack .spool-more {
    transition: none;
  }
}

.spool-stack .spool-mini:nth-child(2) { z-index: 2; }
.spool-stack .spool-mini:nth-child(3) { z-index: 1; }
.spool-stack .spool-mini:nth-child(4) { z-index: 0; }

.spool-stack .spool-mini::after {
  inset: 6px;
  box-shadow: none;
}

.spool-more {
  position: relative;
  z-index: 4;
  border-radius: 50%;
  background: var(--panel-3);
  color: var(--text);
  font-size: 10px;
  font-weight: 700;
  line-height: 24px;
  text-align: center;
  flex-shrink: 0;
}

.tr--expanded {
  position: relative;
  background: rgba(255, 255, 255, 0.04);
}

/* Línea que baja desde el carrete del tipo (centro: 24px de padding + 19px del carrete) */
.tr--expanded::after {
  content: "";
  position: absolute;
  left: 42px;
  top: calc(50% + 24px);
  bottom: 0;
  width: 2px;
  background: var(--border-hover);
}

.tr--child {
  position: relative;
  background: rgba(255, 255, 255, 0.025);
  padding-top: 10px;
  padding-bottom: 10px;
}

/* El texto del rollo queda debajo del nombre del tipo: 24 + 92 + 16 = 132 = 24 + 66 + 30 + 12 */
.tr--child .name-cell {
  padding-left: 66px;
  gap: 12px;
}

.tr--child .spool {
  width: 30px;
  height: 30px;
}

.tr--child .spool::after {
  inset: 8px;
}

.tr--child .title {
  font-size: 0.9rem;
}

/* Tramo vertical de la línea y rama hacia el carrete del rollo */
.tr--child::before,
.tr--child::after {
  content: "";
  position: absolute;
  background: var(--border-hover);
}

.tr--child::before {
  left: 42px;
  top: 0;
  bottom: 0;
  width: 2px;
}

.tr--child-last::before {
  bottom: 50%;
}

.tr--child::after {
  left: 42px;
  top: calc(50% - 1px);
  width: 46px;
  height: 2px;
}

.chip--neutral {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: var(--border);
}

.stat-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
}

.list-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.list-tab:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.list-tab.active {
  border-color: var(--primary);
  background: var(--panel-2);
  color: var(--text);
}

.list-tab__count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--panel-3);
  color: var(--text);
  font-size: 0.75rem;
  text-align: center;
}

.list-tab.active .list-tab__count {
  background: var(--primary);
}

/* Agotados pendientes de revisar */
.list-tab__count--alert,
.list-tab.active .list-tab__count--alert {
  background: #f59e0b;
  color: #111827;
  font-weight: 700;
}

/* Nota al principio de Agotados y Archivados */
.list-note {
  margin: 0 0 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

.list-note[hidden] {
  display: none;
}

.list-note strong {
  color: var(--text);
}

.list-note ul {
  margin: 6px 0;
  padding-left: 18px;
}

.depleted-actions {
  display: flex;
  gap: 6px;
}

.depleted-actions .btn {
  white-space: nowrap;
  padding: 4px 9px;
}

/* Reserva el lugar de "Le queda…" en la fila del filamento agrupado */
.depleted-actions__placeholder {
  visibility: hidden;
  pointer-events: none;
}

/* Los mensajes de confirmación respetan los saltos de línea (párrafos y listas de avisos) */
#confirm-message {
  white-space: pre-line;
}

/* El contenido del stock (chips y acciones) no ensancha su columna: así todas las filas quedan
   alineadas aunque una tenga excedente o acciones; lo que sobra ocupa el lugar libre de la izquierda */
.stock-cell {
  min-width: 0;
  flex-wrap: wrap;
  row-gap: 6px;
}

/* En Agotados la columna de stock lleva además las acciones: más ancha (encabezado y filas) */
@media (min-width: 769px) {
  .table--review .thead,
  .table--review .tr {
    grid-template-columns: 1.4fr 0.9fr 0.8fr 0.8fr 2.3fr;
  }
}

/* El stock y el excedente nunca se parten en dos líneas ni se achican al lado de las acciones */
.stock-cell .chip {
  white-space: nowrap;
  flex-shrink: 0;
}

.stats-grid {
  display: grid;
  /* Cuatro tarjetas: dos y dos, o las cuatro en fila si entran sin apretarse (nunca 3 y una sola abajo) */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

@media (min-width: 1280px) {
  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 32px 24px;
  border-radius: 24px;
  position: relative;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.stat-card:hover {
  transform: translateY(-8px);
  border-color: var(--primary);
  background: rgba(30, 41, 59, 0.8);
  box-shadow: 0 20px 40px -15px rgba(99, 102, 241, 0.4);
}

/* --- CAPA 1: FONDO ATMOSFÉRICO (Ocupa toda la card) --- */
.stat-decoration {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.2;
  /* Sutil para no distraer */
  z-index: 1;
  pointer-events: none;
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover .stat-decoration {
  opacity: 0.15;
  transform: scale(1.1);
}

.stat-decoration img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 80% center;
  /* CAMBIA ESTO: Ajusta el desenfoque general de la imagen de fondo (10% menos) */
  filter: invert(1) hue-rotate(180deg) brightness(1.4) contrast(1.2) blur(1px);
  mix-blend-mode: screen;
  /* CAMBIA ESTO: El % final del radial-gradient controla qué tan lejos llega la ilustración */
  -webkit-mask-image:
    linear-gradient(to right, transparent 5%, black 60%),
    radial-gradient(circle at center, black 30%, transparent 83%);
  mask-image:
    linear-gradient(to right, transparent 5%, black 60%),
    radial-gradient(circle at center, black 30%, transparent 83%);
  mask-composite: intersect;
  -webkit-mask-composite: source-in;
}

/* --- CAPA 2: ILUSTRACIÓN DETALLADA (Lado derecho) --- */
.stat-overlay {
  position: absolute;
  right: -25px;
  bottom: -25px;
  width: 150px;
  height: 150px;
  z-index: 2;
  opacity: 0.35;
  pointer-events: none;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.stat-card:hover .stat-overlay {
  opacity: 0.75;
  transform: scale(1.1) rotate(-5deg) translate(-10px, -10px);
}

.stat-overlay img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: invert(1) hue-rotate(180deg) brightness(1.1) contrast(1.3);
  mix-blend-mode: screen;
  /* CAMBIA ESTO: Sube el 78% si quieres que la ilustración sea más grande antes de desvanecerse */
  -webkit-mask-image: radial-gradient(circle at center, black 40%, transparent 78%);
  mask-image: radial-gradient(circle at center, black 40%, transparent 78%);
}

.stat-content {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 20px;
}

.stat-icon-mini {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.2);
  transition: all 0.3s;
}

.stat-icon-mini.danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

.stat-icon-mini.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--ok);
  border-color: rgba(16, 185, 129, 0.2);
}

.stat-card:hover .stat-icon-mini {
  transform: scale(1.1);
  background: var(--primary);
  color: white;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

.stat-card:hover .stat-icon-mini.danger {
  background: var(--danger);
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
}

.stat-card:hover .stat-icon-mini.success {
  background: var(--ok);
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
}

.stat-info h4 {
  margin: 0;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.stat-info .value {
  margin: 4px 0 0;
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  font-family: 'Outfit', sans-serif;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Modal Radio Toggles Cleanup */
.toggle-group {
  display: flex !important;
  gap: 12px;
  margin-bottom: 20px;
}

.toggle-option {
  flex: 1;
}

.toggle-label {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 12px !important;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  cursor: pointer;
}

.toggle-option input:checked+.toggle-label {
  background: var(--primary-glow, rgba(99, 102, 241, 0.1));
  border-color: var(--primary) !important;
  color: #fff;
}

.checkbox-label {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  padding: 10px 14px !important;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin: 0.75rem 0 !important;
  cursor: pointer;
  transition: all 0.2s;
}

.checkbox-label:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--primary);
}

.checkbox-label input {
  width: 18px !important;
  height: 18px !important;
  margin: 0 !important;
}

/* Color input como bloque con el color seleccionado */
.card input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  padding: 0;
  height: 44px;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
}

.card input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 10px;
}

.card input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 10px;
}

/* Estilos para el modal de login */
#login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 400px;
  max-width: 400px;
  width: 100%;
}

#login-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#login-form input[type="email"],
#login-form input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

#login-form input[type="email"]:focus,
#login-form input[type="password"]:focus {
  border-color: var(--accent);
}

/* Clase para marcar campos con error después de enviar el formulario */
#login-form.submitted input:invalid {
  border-color: var(--danger);
}

/* Clase para marcar campos con error específicamente */
#login-form .error {
  border-color: var(--danger);
}

#login-form .form-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 4px;
  display: none;
}

#login-form input:invalid+.form-error {
  display: block;
}

#login-form .row.end {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
}

/* Alta por invitación: mismo aspecto que el inicio de sesión */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(420px, calc(100vw - 48px));
}

.auth-form .form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-form input[type='text'],
.auth-form input[type='email'],
.auth-form input[type='password'] {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.auth-form input:focus {
  border-color: var(--accent);
}

.auth-form .form-error {
  color: var(--danger);
  font-size: 13px;
}

.auth-form .row.end {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 4px;
}

.auth-intro {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.auth-form .auth-terms {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.8rem;
  line-height: 1.4;
  /* los label del resto de la app van en mayúsculas chicas: este es un texto corrido */
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  color: var(--text-dim);
}

.auth-form .auth-terms input {
  flex: none;
  width: auto;
  margin-top: 2px;
}

.auth-form .auth-terms a {
  color: var(--accent);
}

.auth-switch {
  margin: 0;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.link-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

/* Botones del modal en una sola línea y con primario más ancho */
.row.actions {
  justify-content: space-between;
}

.row.actions .btn {
  flex: 1;
}

.row.actions .btn--primary {
  flex: 2;
}

/* Acciones modal Marca (mantener layout actual pero agrandar Guardar) */
.brand-actions .btn {
  flex: 1;
}

.brand-actions .btn--primary {
  flex: 2;
}

/* Utils */
.right {
  text-align: right;
}

/* Catálogo de filamentos (tipos) */
.table.types .thead,
.table.types .tr {
  grid-template-columns: 1.8fr 1fr 1.5fr 0.9fr 0.7fr 1fr;
}

.table.types .tr .subtitle {
  color: var(--muted);
}

/* Datos de compra en el modal de rollos nuevos: separado de la cantidad */
#clone-filament-form .purchase-details {
  margin-top: 1rem;
}

/* Primer paso de "Agregar rollo": elegir el filamento */
.pick-type-card {
  width: min(520px, 92vw);
}

#pick-type-search {
  width: 100%;
  margin: 0.75rem 0;
}

.pick-type-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
}

.pick-type-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.pick-type-item:hover,
.pick-type-item:focus-visible {
  background: rgba(99, 102, 241, 0.12);
  border-color: var(--primary);
  outline: none;
}

.pick-type-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.pick-type-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.pick-type-text .title {
  font-weight: 600;
}

.pick-type-text .subtitle {
  color: var(--muted);
  font-size: 0.8rem;
}

.pick-type-count {
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.pick-type-empty {
  padding: 1rem;
  color: var(--muted);
  text-align: center;
}

/* Brands table */
.table.brands .thead,
.table.brands .tr {
  grid-template-columns: 1fr 10rem;
  align-items: center;
  gap: 12px;
}

.brand-row {
  cursor: pointer;
  min-height: 50px;
  transition: background-color 0.2s ease;
}

.brand-row:hover {
  background-color: var(--panel-2);
}

.td-center {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 0;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
  color: var(--muted);
  font-style: italic;
}

.brand-cell {
  display: flex;
  align-items: center;
  min-height: 40px;
  /* Altura mínima para mantener consistencia con otras celdas */
  padding: 3px 0;
}

/* --- Auth gating: ocultar toda la UI si no hay sesión --- */
body.unauth .main {
  display: none;
}

body.unauth .sidebar__nav,
body.unauth .sidebar__footer {
  display: none;
}

/* Error de formulario (login) */
.form-error {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(239, 68, 68, .12);
  color: #fecaca;
  border: 1px solid rgba(239, 68, 68, .35);
  font-size: 13px;
}

.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  color: var(--bg);
  font-size: 11px;
  font-weight: bold;
  cursor: help;
  margin-left: 6px;
  position: relative;
  vertical-align: middle;
  margin-bottom: 2px;
}

.help-icon:hover::after,
.help-icon:focus::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  right: -10px;
  /* Alineado a la derecha con un pequeño margen */
  left: auto;
  /* Anular el centrado anterior */
  transform: none;
  /* Anular el centrado anterior */
  background: #1e293b;
  color: #f8fafc;
  padding: 8px 12px;
  border-radius: 6px;
  white-space: normal;
  max-width: 220px;
  width: max-content;
  text-align: left;
  /* Texto alineado a la izquierda para mejor lectura */
  line-height: 1.4;
  font-size: 12px;
  font-weight: normal;
  margin-bottom: 8px;
  z-index: 100;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  pointer-events: none;
  border: 1px solid var(--border);
}

/* Modificador para tooltip hacia la derecha (para iconos a la izquierda) */
.help-icon.tooltip-right:hover::after,
.help-icon.tooltip-right:focus::after {
  left: -10px;
  right: auto;
}

.help-icon:hover::before,
.help-icon:focus::before {
  content: '';
  position: absolute;
  bottom: 100%;
  right: 4px;
  /* Centrado sobre el icono (16px ancho / 2 - 4px borde = 4px aprox) */
  left: auto;
  transform: none;
  border: 4px solid transparent;
  border-top-color: #1e293b;
  margin-bottom: 0px;
  z-index: 100;
}

/* Modificador para flecha del tooltip hacia la derecha */
.help-icon.tooltip-right:hover::before,
.help-icon.tooltip-right:focus::before {
  left: 4px;
  right: auto;
}

/* --- Materials filter and badges --- */
.materials-filter {
  margin-bottom: 12px;
}

.materials-filter select {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  outline: none;
}

.materials-filter select:hover {
  border-color: var(--accent);
}


.material-row.global {
  border-left: 3px solid #10b981;
}

.material-row.user {
  border-left: 3px solid var(--accent);
}

/* Desktop Table Alignment for Materials */
@media (min-width: 769px) {

  .table.materials .thead>div:nth-child(4),
  .table.materials .tr>div:nth-child(4) {
    text-align: right;
  }
}

/* Quick action button for stock */
.stock-cell {
  display: flex !important;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.btn-quick-subtract {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  flex-shrink: 0;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateX(6px);
}

.tr:hover .btn-quick-subtract {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

/* Ocupa el lugar del botón en las filas de un tipo con varios rollos, para alinear el stock */
.btn-quick-subtract--spacer,
.tr:hover .btn-quick-subtract--spacer {
  visibility: hidden;
  pointer-events: none;
}

.btn-quick-subtract:hover {
  background: var(--primary);
  color: white;
  border-color: transparent;
  transform: scale(1.1) !important;
}


/* --- Filamentos en Uso (Dashboard Widget) --- */
#active-spools-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.5rem;
  backdrop-filter: blur(10px);
  display: none;
  /* Se muestra solo cuando hay spool activos */
}

#active-spools-container:not(:empty) {
  display: flex;
}

.active-spool-card {
  flex: 1;
  min-width: 250px;
  max-width: 400px;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.25rem;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  animation: slide-up 0.4s ease-out;
}

.active-spool-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-primary);
}

/* Carriles de una impresora con AFC en la tarjeta de impresión: grilla 2×2 a la derecha, misma altura */
.lanes-grid {
  display: grid;
  grid-template-columns: repeat(2, 20px);
  gap: 6px;
  margin-left: auto;
  align-self: center;
  flex-shrink: 0;
}

.lane-mini {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  position: relative;
  background: conic-gradient(var(--spool-color, #808080) calc(var(--spool-pct, 0) * 100%), rgba(255, 255, 255, 0.06) 0%);
}

.lane-mini::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--card-bg, #11131a);
}

.lane-mini--active {
  box-shadow: 0 0 0 2px var(--accent);
}

/* Gira solo mientras imprime, como el carrete de la tarjeta */
.lanes-grid.is-printing .lane-mini--active {
  animation: rotate-spool 4s linear infinite;
}

.lane-mini--empty {
  background: none;
  border: 1.5px dashed rgba(255, 255, 255, 0.18);
}

.lane-mini--empty::after {
  display: none;
}

.lane-mini--unknown {
  background: none;
  border: 1.5px dashed rgba(245, 158, 11, 0.6);
}

.lane-mini--unknown::after {
  content: '?';
  inset: 0;
  background: none;
  color: var(--warn);
  font: 700 11px/17px system-ui, sans-serif;
  text-align: center;
}

.active-spool-card {
  cursor: pointer;
}

.active-spool-card:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.active-spool-card__visual {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.active-spool-card__info {
  flex: 1;
  /* Sin esto el texto largo empuja la grilla de carriles fuera de la tarjeta en vez de cortarse */
  min-width: 0;
}

/* Progreso de la impresión: una línea en el borde inferior que se va completando */
.active-spool-card__progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.06);
}

.active-spool-card__progress[hidden] {
  display: none;
}

.active-spool-card__progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  transition: width 0.6s ease;
}

.active-spool-card__printer {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-primary);
  font-weight: 700;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.active-spool-card__printer::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #10b981;
  /* Green dot for "Active" */
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

.active-spool-card__name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.active-spool-card__weight {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ok);
  margin-top: 2px;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes slide-up {
  from {
    transform: translateY(10px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.btn-quick-subtract {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--danger-glow);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.2s;
  font-weight: 700;
  font-size: 18px;
}

.btn-quick-subtract:hover {
  background: var(--danger);
  color: white;
  transform: scale(1.1);
}

.stock-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.nav-item i {
  width: 20px;
  height: 20px;
}

.materials-filter {
  margin-bottom: 24px;
  max-width: 300px;
}

.btn i {
  width: 18px;
  height: 18px;
  stroke-width: 2.5px;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Animations for Real-Time Updates */
@keyframes pulse-update {
  0% {
    background-color: transparent;
  }

  50% {
    background-color: rgba(16, 185, 129, 0.2);
  }

  /* Emerald glow */
  100% {
    background-color: transparent;
  }
}

.tr-updated {
  animation: pulse-update 2s cubic-bezier(0.4, 0, 0.2, 1);
}

.stock-cell .chip.updated {
  transition: all 0.3s ease;
  transform: scale(1.1);
  box-shadow: 0 0 10px var(--ok);
}

.active-spool-card__brand {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 1px;
}

.spool-low-stock {
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.7), inset 0 0 10px rgba(239, 68, 68, 0.3) !important;
  border: 0.5px solid rgba(239, 68, 68, 0.7) !important;
}

.spool-low-stock::before {
  opacity: 1 !important;
  mix-blend-mode: normal !important;
}

/* ==========================================================================
   MOBILE RESPONSIVE DESIGN
   ========================================================================== */

/* --- Mobile Header (hidden on desktop) --- */
.mobile-header {
  display: none;
}

/* --- Mobile Bottom Nav (hidden on desktop) --- */
.mobile-nav {
  display: none;
}

@media (max-width: 768px) {

  /* === 1. LAYOUT BASE === */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 64px 1fr;
    height: 100vh;
    overflow: hidden;
  }

  .sidebar {
    display: none;
  }

  .main {
    padding: 12px;
    padding-bottom: 80px;
    overflow-x: hidden;
    max-width: 100vw;
    height: auto;
    overflow-y: auto;
    grid-row: 2;
  }

  /* === MOBILE HEADER === */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--panel);
    backdrop-filter: var(--glass);
    border-bottom: 1px solid var(--border);
    grid-row: 1;
    z-index: 100;
  }

  .mobile-header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .mobile-header__brand .logo {
    width: 32px;
    height: 32px;
    font-size: 12px;
    border-radius: 8px;
  }

  .mobile-header__brand .brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .mobile-header__brand strong {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    color: #fff;
    line-height: 1.2;
  }

  .mobile-header__brand span {
    font-size: 0.60rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.2;
  }

  /* === BOTTOM NAV === */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: var(--panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    z-index: 999;
    justify-content: space-around;
    align-items: center;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .mobile-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 12px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-nav__item i {
    width: 22px;
    height: 22px;
  }

  .mobile-nav__item.active {
    color: var(--primary);
  }

  .mobile-nav__item.active::after {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--primary);
    margin-top: 2px;
  }

  /* === 2. TOPBAR + FILTROS + FAB === */
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 16px;
  }

  .page-head .actions {
    /* Don't hide - the FAB lives here. Just make it invisible as a layout container */
    position: static;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    display: block;
  }

  .search-filters {
    gap: 10px;
    min-width: 0;
  }

  .filters-row {
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
  }

  .search {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .search input[type="search"] {
    height: 44px;
    border-radius: 12px;
    font-size: 14px;
  }

  .multi-select {
    max-width: 100%;
    min-width: 175px;
    width: 100%;
  }

  .multi-select-display {
    min-height: 42px;
    border-radius: 10px;
  }

  /* FAB - Floating Action Button */
  #addBtn {
    position: fixed;
    bottom: 80px;
    right: 20px;
    height: 56px;
    border-radius: 28px !important;
    padding: 0 16px !important;
    z-index: 998;
    font-size: 0;
    letter-spacing: 0;
    box-shadow: 0 6px 20px -4px rgba(99, 102, 241, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 56px;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), gap 0.3s ease, border-radius 0.3s ease;
  }

  #addBtn:active {
    width: 140px;
    gap: 8px;
  }

  #addBtn::after {
    content: 'Añadir';
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    width: 0;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  #addBtn:active::after {
    width: 60px;
  }

  #addBtn i {
    margin: 0;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
  }

  /* === 3. FILTRO DE COLORES === */
  .color-filter {
    min-width: 0;
    max-width: 100%;
  }

  .color-swatches {
    gap: 8px;
    padding: 8px 10px;
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .color-swatches::-webkit-scrollbar {
    display: none;
  }

  .color-swatch {
    width: 26px;
    height: 26px;
  }

  .color-swatch:not([style*="background"]) {
    padding: 0 10px;
    font-size: 11px;
    border-radius: 12px;
  }

  .color-count {
    font-size: 11px;
  }

  /* === 4. STATS CARDS → SCROLL HORIZONTAL === */
  .stats-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 4px;
    -webkit-mask-image: linear-gradient(to right, black 0%, black 88%, transparent 100%);
    mask-image: linear-gradient(to right, black 0%, black 88%, transparent 100%);
    scrollbar-width: none;
  }

  .stats-grid::-webkit-scrollbar {
    display: none;
  }

  .stat-card {
    flex: 0 0 200px;
    scroll-snap-align: start;
    padding: 20px 16px;
    border-radius: 16px;
  }

  .stat-card:hover {
    transform: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  }

  .stat-info .value {
    font-size: 22px;
  }

  .stat-icon-mini {
    width: 40px;
    height: 40px;
  }

  .stat-content {
    gap: 14px;
  }

  .stat-overlay {
    width: 120px;
    height: 120px;
    right: -20px;
    bottom: -20px;
  }

  /* === 5. TABLA FILAMENTOS → CARDS (solo para filamentos) === */
  #filaments-view .table {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    overflow: visible;
  }

  #filaments-view .thead {
    display: none;
  }

  #filaments-view .tbody {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  #filaments-view .tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto;
    gap: 4px 12px;
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    margin-bottom: 0;
  }

  #filaments-view .tr:last-child {
    border-bottom: 1px solid var(--border);
  }

  #filaments-view .tr:hover {
    background: var(--panel);
  }

  #filaments-view .tr:active {
    background: rgba(255, 255, 255, 0.05);
    transform: scale(0.99);
  }

  /* Nombre - fila única, izquierda */
  #filaments-view .name-cell {
    grid-column: 1;
    grid-row: 1;
  }

  /* Marca - oculta en mobile (ya se ve en el detalle) */
  #filaments-view .brand-cell {
    display: none;
  }

  /* Material badge - oculto (ya está en el subtítulo del nombre) */
  #filaments-view .tr>div:nth-child(3) {
    display: none;
  }

  /* Diámetro oculto */
  #filaments-view .tr>div:nth-child(4) {
    display: none;
  }

  /* Stock - misma fila, a la derecha */
  #filaments-view .stock-cell {
    grid-column: 2 !important;
    grid-row: 1 !important;
  }

  /* Vista agrupada en mobile: las filas son tarjetas separadas, así que en vez de la línea
     los rollos de un tipo van corridos a la derecha y con otro fondo */
  #filaments-view .tr--expanded::after,
  #filaments-view .tr--child::before,
  #filaments-view .tr--child::after {
    display: none;
  }

  #filaments-view .tr--child {
    margin-left: 24px;
    background: rgba(255, 255, 255, 0.025);
  }

  #filaments-view .tr--child .name-cell {
    padding-left: 0;
  }

  /* Botón restar siempre visible en touch */
  .btn-quick-subtract {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: none !important;
  }

  /* Skeleton adaptado */
  .skeleton-row {
    grid-template-columns: 1fr;
    border-radius: 16px;
    background: var(--panel);
    border: 1px solid var(--border);
    margin-bottom: 8px;
  }

  .skeleton-row>div:nth-child(n+3) {
    display: none;
  }

  /* Tablas genéricas (brands/materials) - ajustar padding pero mantener tabla */
  .table:not(#filaments-view .table) {
    border-radius: 16px;
    overflow: hidden;
  }

  .table:not(#filaments-view .table) .thead,
  .table:not(#filaments-view .table) .tr {
    padding: 12px 14px;
    gap: 8px;
  }

  /* Catálogo en mobile: nombre y stock, como la vista de rollos */
  #types-view .thead {
    display: none;
  }

  #types-view .table.types .tr {
    grid-template-columns: 1fr auto;
  }

  #types-view .tr > div:nth-child(n + 2):nth-child(-n + 5) {
    display: none;
  }

  /* === 6. MODALES → FULL-PAGE SECTIONS === */
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    max-width: 100vw;
    max-height: none;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border: none;
    border-radius: 0;
    padding: 0;
    background: var(--bg);
    z-index: 1100;
  }

  .modal::backdrop {
    background: transparent;
  }

  .card {
    min-width: unset;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: 24px 20px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
    overflow-y: auto;
    box-shadow: none;
    background: var(--bg);
    border: none;
  }

  .card h3 {
    font-size: 1.3rem;
    margin-bottom: 20px;
  }

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

  .row.actions {
    flex-direction: column-reverse;
    gap: 8px;
  }

  .row.actions .btn {
    width: 100%;
    flex: unset;
  }

  .row.actions .btn--primary {
    flex: unset;
  }

  .modal .btn--danger {
    margin-right: 0;
  }

  #login-form {
    min-width: unset;
    max-width: 100%;
  }

  /* Toggle group en modales */
  .toggle-group {
    gap: 8px;
  }

  .toggle-label {
    font-size: 13px;
    padding: 10px !important;
  }

  /* Campos técnicos a 1 columna */
  .tech-details .tech-fields {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* === 7. TABLAS SECUNDARIAS === */

  /* Brands */
  .table.brands {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
  }

  .table.brands .thead,
  .table.brands .tr {
    grid-template-columns: 1fr auto;
    padding: 12px 14px;
    gap: 12px;
    align-items: center;
  }

  /* Materials */
  .table.materials {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
  }

  .table.materials .thead>div:nth-child(2),
  .table.materials .tr>div:nth-child(2) {
    display: none;
  }

  .table.materials .thead,
  .table.materials .tr {
    grid-template-columns: 1.2fr 1fr 1fr;
    padding: 12px 14px;
    align-items: center;
  }

  /* Todas las columnas en 1 línea con ellipsis */
  .table.materials .tr>div,
  .table.materials .thead>div {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Nombre centrado verticalmente con badge */
  .table.materials .tr>div:first-child {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
  }

  /* Abreviar "Global" → "G" en mobile */
  .material-badge.global {
    font-size: 0;
    min-width: 24px;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .material-badge.global::after {
    content: 'G';
    font-size: 11px;
    font-weight: 700;
  }

  /* === SPOOLMAN INLINE VIEW (mobile only) === */
  .spoolman-inline {
    padding: 0;
  }

  .spoolman-inline__header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
  }

  .spoolman-inline__icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(99, 102, 241, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    flex-shrink: 0;
  }

  .spoolman-inline__icon i {
    width: 24px;
    height: 24px;
  }

  .spoolman-inline__header h2 {
    font-size: 1.2rem;
    color: #fff;
    margin: 0;
  }

  .spoolman-inline__header p {
    font-size: 0.85rem;
    color: var(--muted);
    margin: 2px 0 0;
  }

  .spoolman-inline__section {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
  }

  .spoolman-inline__section h4 {
    font-size: 0.95rem;
    color: #fff;
    margin: 0 0 8px;
  }

  .spoolman-inline__section p {
    font-size: 0.85rem;
    color: var(--muted);
    line-height: 1.5;
    margin: 0 0 12px;
  }

  .spoolman-inline__cmd {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .spoolman-inline__cmd input {
    font-family: monospace;
    font-size: 0.8em;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
    color: var(--text);
    width: 100%;
  }

  .spoolman-inline__code {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 10px;
    font-size: 0.85em;
    overflow-x: auto;
    border: 1px solid var(--border);
    color: var(--text);
  }

  /* === 8. DASHBOARD FILAMENTOS ACTIVOS === */
  #active-spools-container {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 12px;
    gap: 10px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    border-radius: 16px;
    margin-bottom: 16px;
  }

  #active-spools-container::-webkit-scrollbar {
    display: none;
  }

  /* Casi todo el ancho (con varias impresoras se asoma la siguiente) para que entren el texto y los carriles */
  .active-spool-card {
    min-width: 0;
    flex: 0 0 88%;
    scroll-snap-align: start;
    padding: 1rem;
    gap: 0.75rem;
    border-radius: 16px;
  }

  .active-spool-card:only-child {
    flex-basis: 100%;
  }

  /* === 9. TOUCH POLISH === */
  .stat-card:hover .stat-icon-mini {
    transform: none;
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    box-shadow: none;
  }

  .stat-card:hover .stat-icon-mini.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    box-shadow: none;
  }

  .stat-card:hover .stat-icon-mini.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--ok);
    box-shadow: none;
  }

  .stat-card:hover .stat-overlay {
    opacity: 0.35;
    transform: none;
  }

  .stat-card:hover .stat-decoration {
    opacity: 0.2;
    transform: none;
  }

  .color-swatch:hover {
    transform: none;
    box-shadow: none;
  }

  .color-swatch:active {
    transform: scale(1.15);
    border-color: #fff;
  }

  .nav-item:hover {
    transform: none;
  }

  /* Asegurar que no haya overflow horizontal */
  body {
    overflow-x: hidden;
  }
}

/* Modal de login en mobile a pantalla completa */
@media (max-width: 768px) {
  #loginModal {
    max-width: 100%;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
    padding: 0;
    background: var(--bg);
  }

  #loginModal::backdrop {
    background: var(--bg);
  }

  #loginModal .card {
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: none;
    padding: 2rem;
  }
}

/* Mobile Bottom Sheet Modal */
.bottom-sheet {
  align-items: flex-end;
}

@media (max-width: 768px) {
  .bottom-sheet {
    max-width: 100%;
    width: 100vw;
    height: auto;
    top: auto;
    bottom: 0;
    margin: 0;
    margin-top: auto;
    border-radius: 16px 16px 0 0;
  }

  .bottom-sheet .card {
    height: auto;
    border-radius: 16px 16px 0 0;
    border: none;
    padding-bottom: env(safe-area-inset-bottom, 20px);
  }
}

.more-menu-list {
  display: flex;
  flex-direction: column;
}

.more-menu-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s;
}

.more-menu-item:hover {
  background-color: var(--bg-hover);
}

.more-menu-item i {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.more-menu-item:last-child {
  border-bottom: none;
}

/* ==========================================================================
   INTEGRATIONS VIEW
   ========================================================================== */
.integrations-wrapper {
  padding: 24px;
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

.integration-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.integration-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

@media (min-width: 768px) {
  .integration-card__header {
    flex-direction: row;
    align-items: center;
  }
}

.integration-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.integration-card__header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255,255,255,0.01);
}

.integration-card__info {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  flex: 1;
}

.integration-card__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.integration-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: white;
  flex-shrink: 0;
}

.integration-card__icon i {
  width: 24px;
  height: 24px;
}

/* --- Redesigned Integrations --- */
.integrations-wrapper {
  max-width: 1000px;
  margin: 0 auto;
}

.integration-grid {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.integration-card {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.integration-card.featured {
  border: 1px solid rgba(99, 102, 241, 0.3);
  background: rgba(17, 24, 39, 0.4);
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.5);
}

.featured-icon {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.integration-title {
  margin: 0;
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
}

.integration-description {
  color: var(--text-dim);
  line-height: 1.6;
  font-size: 1rem;
  margin-bottom: 2rem;
  max-width: 800px;
}

.integration-tabs {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 2rem;
}

.integration-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section-header {
  margin-bottom: 0.5rem;
}

.section-title {
  display: flex;
  align-items: center;
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  margin: 0 0 0.5rem 0;
  color: #fff;
}

.section-desc {
  font-size: 0.85rem;
  color: var(--text-dim);
  margin: 0;
}

.integration-step {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.step-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Separa los pasos de Integraciones: la columna ya deja 1.5rem a cada lado, el margen solo suma un poco */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 0.25rem 0;
}

.integration-grid__upcoming {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.integration-card.upcoming {
  opacity: 0.7;
  border-style: dashed;
  background: rgba(255, 255, 255, 0.02);
}

.integration-card.upcoming:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.04);
}

.code-block {
  background: #000;
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  overflow-x: auto;
}

.code-block pre {
  margin: 0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.85rem;
  color: #a5b4fc;
  line-height: 1.5;
}

.copy-box {
  display: flex;
  gap: 0.75rem;
  width: 100%;
}

.modern-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4) !important;
  border: 1px solid var(--border) !important;
  border-radius: 10px !important;
  padding: 0 1rem !important;
  height: 44px !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 0.8rem !important;
  color: #e0e7ff !important;
  cursor: default;
}

.modern-input:focus {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2) !important;
}

/* OrcaSlicer: macro con botón de copiar, tokens del plugin */
.code-copy,
.orca-download {
  align-self: flex-start;
  text-decoration: none;
}

.code-copy svg,
.code-copy i {
  width: 14px;
  height: 14px;
}

.token-form {
  display: flex;
  gap: 0.75rem;
}

.token-form .modern-input {
  cursor: text;
  font-family: inherit !important;
  font-size: 0.9rem !important;
}

.token-new[hidden] {
  display: none;
}

/* Permiso de importar al generar el token (pisa el estilo general de .card label e input) */
.card .token-scope {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0 0;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
}

.card .token-scope input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  padding: 0;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.token-new {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid rgba(250, 204, 21, 0.35);
  background: rgba(250, 204, 21, 0.06);
}

.token-new__warning {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 0.85rem;
  color: #fde68a;
}

.token-new__warning svg,
.token-new__warning i {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.token-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.token-row__info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
}

.token-row__name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.token-row__meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.token-row .token-revoke {
  flex-shrink: 0;
}

.token-empty {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Impresoras con puente v2 (Integraciones → Klipper / Moonraker). Si las acciones no entran al lado del
   nombre, bajan a otra línea en vez de apretarlo */
.printer-row {
  flex-wrap: wrap;
}

.printer-row .token-row__info {
  flex: 1 1 220px;
}

.printer-row .token-row__name {
  display: flex;
  align-items: center;
  gap: 8px;
}

.printer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  flex-shrink: 0;
}

.printer-dot--online {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.printer-version {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.printer-version--ok {
  color: #10b981;
}

.printer-version--update {
  color: var(--accent);
}

.printer-version--warn {
  color: #f59e0b;
}

.printer-row__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Interruptor general: PrintWise en esta impresora. Pisa el estilo general de .card label (mayúsculas,
   bloque) e input (ancho completo) */
.card .pw-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  cursor: pointer;
}

/* El checkbox queda invisible pero enfocable: se ve la pista */
.card .pw-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
}

.pw-switch__track {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.18);
  flex-shrink: 0;
  transition: background 0.2s;
}

.pw-switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}

.pw-switch input:checked + .pw-switch__track {
  background: var(--primary);
}

.pw-switch input:checked + .pw-switch__track::after {
  transform: translateX(12px);
}

.pw-switch input:focus-visible + .pw-switch__track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Apagada: la información se atenúa y la nota explica qué deja de hacer PrintWise */
.printer-row--off .token-row__name,
.printer-row--off .token-row__meta,
.printer-row--off .printer-version {
  opacity: 0.55;
}

.printer-off-note,
.printer-setup-note {
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-dim);
}

/* Primeros pasos: una lista corta y discreta, que desaparece cuando está todo hecho */
.setup-steps {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

/* El display de arriba le gana al atributo hidden: sin esto, oculta se dibujaba como una caja vacía */
.setup-steps[hidden] {
  display: none;
}

.setup-steps__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
}

.setup-steps ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.setup-step {
  display: grid;
  grid-template-columns: 18px 1fr;
  column-gap: 0.5rem;
  align-items: start;
  font-size: 0.85rem;
  color: var(--text);
}

.setup-step svg,
.setup-step i {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--text-dim);
}

.setup-step.is-done {
  color: var(--text-dim);
}

.setup-step.is-done svg,
.setup-step.is-done i {
  color: var(--success, #22c55e);
}

/* Terminó bien: el borde lo marca con un verde apagado y el mensaje dice qué quedó andando */
.setup-steps--done {
  border-color: rgba(34, 197, 94, 0.45);
}

.setup-steps__done {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text);
}

.printer-setup-ok {
  color: var(--success, #22c55e);
  font-weight: 600;
}

.setup-step__hint {
  grid-column: 2;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-dim);
}

.printer-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

/* Ícono de información: al tocarlo abre la explicación debajo (sin tooltip, que en el celular no se ve) */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  flex-shrink: 0;
}

.info-btn:hover,
.info-btn[aria-expanded='true'] {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.info-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.info-btn svg,
.info-btn i {
  width: 15px;
  height: 15px;
}

/* Ayuda plegable de SSH: discreta, igual que las notas del resto de Integraciones */
.ssh-help {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.ssh-help > summary {
  cursor: pointer;
  width: fit-content;
}

.ssh-help__body {
  margin-top: 0.5rem;
  line-height: 1.5;
}

.ssh-help__body p {
  margin: 0 0 0.5rem;
}

.ssh-help__body ol {
  margin: 0;
  padding-left: 1.25rem;
}

.ssh-help__body li + li {
  margin-top: 0.35rem;
}

.info-help {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--text-dim);
}

.info-help[hidden] {
  display: none;
}

/* "Ajustes" despliega las opciones de la impresora: la flecha gira al abrirlas */
.settings-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.settings-toggle svg,
.settings-toggle i {
  width: 14px;
  height: 14px;
  transition: transform 0.2s;
}

.settings-toggle[aria-expanded='true'] svg {
  transform: rotate(180deg);
}

/* La del interruptor general ocupa todo el ancho de la fila */
.printer-switch-help {
  flex-basis: 100%;
}

/* Ajustes de cada impresora: cada opción con su explicación debajo */
.printer-settings {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.printer-settings[hidden] {
  display: none;
}

.printer-settings__intro {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.printer-option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  padding: 2px 0;
}

.printer-option .info-help {
  flex-basis: 100%;
  padding: 0 0 4px 26px;
}

.card .printer-option__main {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 4px 2px;
  font-size: 0.85rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  cursor: pointer;
}

.card .printer-option__main input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--primary);
}

.printer-option.is-disabled .printer-option__main {
  opacity: 0.5;
  cursor: not-allowed;
}

.printer-settings__footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.25rem;
}

.printer-legacy {
  margin-top: 0.75rem;
}

@media (max-width: 768px) {
  /* Los contenedores anidados de Integraciones sumaban unos 90 px de margen por lado: las impresoras
     y sus explicaciones quedaban en una columna angosta */
  .integrations-wrapper {
    padding: 0;
  }

  .integration-tabs {
    padding: 12px;
  }

  .printer-row {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem;
  }

  /* En columna, los anchos mínimos de la fila se volverían altos */
  .printer-row .token-row__info,
  .printer-switch-help,
  .printer-settings {
    flex: none;
  }

  .printer-row__actions {
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  .token-form {
    flex-direction: column;
  }

  /* En columna, flex: 1 de .modern-input le saca la altura */
  .token-form .modern-input {
    flex: none;
  }

  .token-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Página de términos de la beta (terminos.html) */
.legal {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
  line-height: 1.6;
  color: var(--text);
}

.legal h1 {
  font-family: 'Outfit', system-ui, sans-serif;
  font-size: 1.7rem;
  margin: 0.5rem 0;
}

.legal h2 {
  font-size: 1.1rem;
  margin: 1.8rem 0 0.4rem;
}

.legal p,
.legal li {
  color: var(--text-dim);
  font-size: 0.95rem;
}

.legal strong {
  color: var(--text);
}

.legal a {
  color: var(--accent);
}

.legal code {
  font-size: 0.85em;
}

.legal__version {
  font-size: 0.85rem;
}

.legal__back {
  margin: 0;
}

/* Importar desde Spoolman */
.import-card {
  max-width: 520px;
}

.import-steps {
  margin: 0.75rem 0 1rem;
  padding-left: 1.2rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.import-steps li + li {
  margin-top: 0.6rem;
}

.import-url {
  display: block;
  margin-top: 0.35rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.78rem;
  word-break: break-all;
  user-select: all;
}

.import-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 1.1rem;
  border: 1.5px dashed var(--border-hover);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.import-drop span {
  text-transform: none;
  letter-spacing: normal;
  font-weight: 500;
}

.import-drop:hover,
.import-drop:focus-within {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.import-file-name {
  margin: 0 0 0.6rem;
  color: var(--text-secondary);
  font-size: 0.85rem;
  word-break: break-all;
}

.import-summary,
.import-failed-list {
  margin: 0;
  padding-left: 1.1rem;
  line-height: 1.6;
  font-size: 0.92rem;
}

.import-failed-list {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.import-sample {
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.import-sample__row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.import-swatch {
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--border-hover);
  background: #888;
}

.import-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.import-bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.3s;
}

.import-live {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.import-live li {
  display: flex;
  gap: 0.6rem;
  color: var(--text-secondary);
}

.import-live li::before {
  content: '○';
  flex: none;
  width: 1.1rem;
  text-align: center;
}

.import-live li.is-active {
  color: var(--text-primary);
  font-weight: 600;
}

.import-live li.is-active::before {
  content: '●';
  color: var(--primary);
}

.import-live li.is-done::before {
  content: '✓';
  color: var(--success, #22c55e);
}

.import-from-printer {
  margin-bottom: 1rem;
}

.import-printer-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0 0.8rem;
}

.import-error {
  margin: 0.9rem 0 0;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.88rem;
}

.import-error[hidden],
#importSpoolmanModal [hidden] {
  display: none !important;
}

.empty-state__hint {
  margin: 0.8rem 0 0.6rem;
  font-style: normal;
}

.link-btn {
  background: none;
  border: 0;
  padding: 0.5rem 0;
  color: var(--primary);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.pick-type-import {
  display: block;
  margin-top: 0.5rem;
}

/* Agregar rollos: un solo cuadro, lo que ya tenés, el catálogo y el carrito */
.as-card {
  max-width: 640px;
  width: min(640px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.as-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.as-head h3 {
  margin: 0;
}

.as-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 0;
}

.as-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 12px;
}

.as-chip i,
.as-chip svg {
  width: 13px;
  height: 13px;
  color: var(--muted);
}

.as-chip__dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--border);
}


.as-chip__x {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 6px;
}

.as-palette {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px;
  scrollbar-width: none;
}

.as-palette::-webkit-scrollbar {
  display: none;
}

.as-pal,
.as-dot {
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border);
}

.as-pal {
  width: 26px;
  height: 26px;
  padding: 0;
  cursor: pointer;
}

.as-pal:hover {
  transform: scale(1.12);
  border-color: #fff;
}

.as-dot {
  width: 26px;
  height: 26px;
}

.as-body,
.as-cart {
  max-height: 40vh;
  overflow-y: auto;
}

.as-sec {
  margin: 0.6rem 0 0.2rem;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.as-hint {
  margin: 0;
  padding: 1.1rem 0.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.as-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem;
  border-radius: 10px;
}

.as-row + .as-row {
  border-top: 1px solid var(--border);
}

.as-row--off { opacity: 0.55; }
.as-row--hl {
  background: rgba(99, 102, 241, 0.12);
}

.as-row__info {
  flex: 1;
  min-width: 0;
}

.as-row__info strong {
  display: block;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.as-row__info small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}


.as-row .as-weight {
  flex: none;
  width: auto;
  max-width: 150px;
  min-width: 0;
  padding: 4px 8px;
  font-size: 0.8rem;
}

.as-fixed {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
}

.as-qty {
  display: flex;
  align-items: center;
  gap: 6px;
}

.as-qty__btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.as-qty__btn:hover {
  border-color: var(--primary);
}

.as-qty__n {
  min-width: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.as-brands {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.as-brand {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}

.as-brand:hover {
  border-color: var(--primary);
}

.as-more {
  margin: 0.4rem 0 0.2rem 0.5rem;
}

.as-credit {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
}

.as-credit a {
  color: inherit;
}

@media (max-width: 640px) {
  /* En el celular es una pantalla completa, con el botón final siempre visible abajo */
  #addSpoolsModal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .as-card {
    width: 100%;
    max-width: none;
    height: 100%;
    border-radius: 0;
  }

  .as-body {
    max-height: none;
    /* No se achica a cero en pantallas bajas (320 × 568): si falta lugar, desplaza la tarjeta entera */
    flex: 1 0 12rem;
    min-height: 12rem;
  }

  .as-card {
    overflow-y: auto;
  }

  .as-foot {
    position: sticky;
    bottom: 0;
    background: var(--panel);
    padding-top: 0.6rem;
  }

  .as-qty__btn {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}

/* Estado vacío de Rollos: tres caminos del mismo tamaño */
.start-options {
  display: grid;
  gap: 0.6rem;
  max-width: 460px;
  margin: 0.8rem auto 0;
  text-align: left;
}

.start-option {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

button.start-option:hover {
  border-color: var(--primary);
}

.start-option svg,
.start-option i {
  width: 22px;
  height: 22px;
  color: var(--primary);
  flex: none;
}

.start-option span {
  flex: 1;
}

.start-option strong {
  display: block;
  font-size: 0.92rem;
}

.start-option small {
  color: var(--muted);
  font-size: 0.78rem;
}

.start-option--soon {
  opacity: 0.6;
  cursor: default;
}

/* Aviso con acciones (Ver, Deshacer) */
.pw-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-radius: 12px;
  background: #f3f4f6;
  color: #111827;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
  font-size: 0.9rem;
  max-width: calc(100vw - 24px);
  /* Como popover (capa superior) el navegador le pone su borde y lo estira: se deja como un aviso común */
  top: auto;
  right: auto;
  margin: 0;
  border: 0;
  overflow: visible;
  width: max-content;
  height: auto;
}

.pw-toast__action {
  border: 0;
  background: transparent;
  color: #4338ca;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
}

/* Ficha del filamento: datos técnicos por impresora */
.pp-section {
  margin-top: 1rem;
  padding-top: 0.8rem;
}

.pp-title {
  margin: 0 0 0.2rem;
  font-size: 0.95rem;
}

.pp-list {
  display: grid;
  gap: 0.7rem;
}

.pp-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: var(--panel-2);
}

.pp-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}



.pp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.5rem;
}

.pp-field {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.pp-field input {
  margin-top: 3px;
}

.pp-copy {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.pp-copy select {
  flex: 1;
  min-width: 0;
}

/* Agregar rollos: rollo empezado y datos de compra */
.as-stock {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.5rem 0.5rem 2.7rem;
}

.as-stock__open {
  font-size: 0.78rem;
}

#addSpoolsModal .as-stock .as-stock__mode,
#addSpoolsModal .as-stock .as-stock__input,
#addSpoolsModal .as-stock .as-stock__tare {
  flex: none;
  padding: 4px 8px;
  font-size: 0.8rem;
}

#addSpoolsModal .as-stock .as-stock__mode {
  width: auto;
}

#addSpoolsModal .as-stock .as-stock__input {
  width: 9rem;
}

#addSpoolsModal .as-stock .as-stock__tare {
  width: 8.5rem;
}

.as-stock__close {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
}

.as-stock__result {
  flex-basis: 100%;
  font-size: 0.75rem;
  color: var(--muted);
}

.as-stock__result--err {
  color: var(--danger);
}


.as-purchase__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.as-purchase__grid label {
  font-size: 11px;
  color: var(--muted);
}

/* Ficha del rollo: cuánto queda y cómo ajustarlo */
.sheet-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0.4rem 0 0.8rem;
}

/* El panel de color y acabado que se abre al tocar la tarjeta */
.color-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}

.color-panel .clone-help {
  margin: 0;
}

.color-panel .form-field + .form-field,
.color-panel .form-field + .clone-help {
  margin-top: 0;
}

.color-panel__actions .btn {
  flex: none;
  width: auto;
}

.color-panel__row {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: var(--space-4);
}

.finish-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.color-panel__actions {
  display: flex;
  gap: var(--space-2);
}

/* La tarjeta de color de la ficha: el color con su acabado y, encima, etiqueta, acción y datos */
.sheet-hero {
  position: relative;
  min-height: 112px;
  justify-content: flex-end;
  gap: 0;
  padding: var(--space-3) var(--space-4);
  border-radius: 12px;
  overflow: hidden;
  color: #fff;
  --hero-glass: rgba(0, 0, 0, 0.35);
  --hero-line: rgba(255, 255, 255, 0.28);
  --hero-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.sheet-hero[data-tone='light'] {
  color: #111;
  --hero-glass: rgba(255, 255, 255, 0.55);
  --hero-line: rgba(0, 0, 0, 0.2);
  --hero-shadow: 0 1px 2px rgba(255, 255, 255, 0.6);
}

.sheet-hero__color {
  position: absolute;
  inset: 0;
  border: 1px solid var(--border);
  border-radius: inherit;
}

.sheet-hero--scrim::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), transparent 70%);
}

.sheet-hero .sheet-head__text {
  position: relative;
  flex: none;
}

.sheet-hero .sheet-head__text,
.sheet-hero .sheet-head__text small {
  color: inherit;
  text-shadow: var(--hero-shadow);
}

.sheet-hero .sheet-head__text small {
  opacity: 0.9;
}

.sheet-hero__tag,
.sheet-hero__action {
  position: absolute;
  top: var(--space-3);
  background: var(--hero-glass);
  border: 1px solid var(--hero-line);
  color: inherit;
  backdrop-filter: blur(4px);
}

/* La tarjeta se toca para cambiar el color y el acabado */
.sheet-hero[role='button'] {
  cursor: pointer;
}

.sheet-hero[data-editable='false'] {
  cursor: default;
}

.sheet-hero[data-editable='false'] .sheet-hero__hint {
  display: none;
}

.sheet-hero__hint {
  position: absolute;
  right: var(--space-4);
  bottom: var(--space-3);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: 6px;
  background: var(--hero-glass);
  border: 1px solid var(--hero-line);
  font-size: 0.72rem;
  pointer-events: none;
}

.sheet-hero__hint svg {
  width: 12px;
  height: 12px;
}

.sheet-hero .sheet-head__text {
  padding-right: 7.5rem;
}

.sheet-hero__tag {
  left: var(--space-4);
  padding: 2px var(--space-2);
  border-radius: 6px;
  font-size: 0.72rem;
  text-shadow: var(--hero-shadow);
}

.sheet-hero__action {
  right: var(--space-4);
}

.sheet-head__text {
  flex: 1;
  min-width: 0;
}

.sheet-head__text strong {
  display: block;
  font-size: 1.1rem;
}

.sheet-head__text small {
  color: var(--muted);
}

.stock-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  background: var(--panel-2);
  margin-bottom: 0.9rem;
}

.stock-box__now {
  font-size: 0.9rem;
  color: var(--muted);
}

.stock-box__now strong {
  font-size: 1.4rem;
  color: var(--text);
}

.stock-box__now--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.stock-box__now--row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.stock-box__bar {
  height: 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  margin: 0.4rem 0 0.7rem;
  overflow: hidden;
}

.stock-box__bar span {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.stock-box__modes {
  display: flex;
  gap: 6px;
  margin-bottom: 0.6rem;
}

.stock-mode,
.finish-pill {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}

.stock-mode.is-on,
.finish-pill.is-on {
  border-color: var(--primary);
  color: var(--text);
  background: rgba(99, 102, 241, 0.15);
}

.stock-box__tool {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
}

#editFilamentModal .stock-box__tool input {
  width: 11rem;
  flex: none;
}

.stock-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.stock-field[hidden] {
  display: none;
}

.stock-box__result {
  margin: 0.4rem 0 0;
  min-height: 1em;
  font-size: 0.78rem;
  color: var(--muted);
}

.stock-box__result--err {
  color: var(--danger);
}

/* Agregar rollos: espacios y alineación del estado inicial */
.as-intro .as-hint {
  text-align: left;
  padding: 0.6rem 0 0;
}

.as-intro .as-sec {
  margin: 1.4rem 0 0.7rem;
}

.as-purchase {
  margin-top: 1.1rem;
}

.as-credit {
  margin-top: 0.9rem;
}

/* Bienvenida de Rollos (cuenta sin ningún rollo): solo lo necesario para empezar */
body.rollos-empty .topbar,
body.rollos-empty #filaments-view .stats-grid,
body.rollos-empty #filaments-view .list-toolbar,
body.rollos-empty #filaments-view .thead,
body.rollos-empty #list-note {
  display: none;
}

body.rollos-empty #filaments-view .table {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.welcome {
  font-style: normal;
  max-width: 520px;
  margin: 2.5rem auto 0;
  text-align: left;
}

.welcome__title {
  margin: 0 0 0.4rem;
  font-size: 1.4rem;
  color: var(--text);
}

.welcome__help {
  margin: 0 0 1.2rem;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.welcome__help strong {
  color: var(--text);
}

.welcome .start-options {
  max-width: none;
  margin-top: 0;
}

.start-option--soon {
  border-style: dashed;
  background: transparent;
  opacity: 0.55;
}

/* UX-2 · El cuadro: color propio, paleta con título, seguir con otro color y mobile */
.as-palette-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  position: relative;
}

.as-palette-title {
  flex-basis: 100%;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.as-palette-wrap .as-palette {
  flex: 1;
  min-width: 0;
}

.as-pal {
  width: 30px;
  height: 30px;
}

.as-other {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 12px 2px 3px;
  border-radius: 999px;
  border: 1px dashed var(--border-hover);
  background: transparent;
  color: var(--text);
  font-size: 0.8rem;
  cursor: pointer;
}

.as-other:hover {
  border-color: var(--primary);
}

.as-other__ring {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: conic-gradient(#e53935, #fb8c00, #fdd835, #43a047, #1e88e5, #8e24aa, #e53935);
}

.as-color-input {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.as-dot-btn {
  flex: none;
  border: 0;
  background: none;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
}

.as-dot-btn .as-dot {
  display: block;
}

.as-dot-btn:hover .as-dot,
.as-dot-btn:focus-visible .as-dot {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.as-row__controls {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-left: auto;
}

.as-continue {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0.4rem 0 0.2rem 2.7rem;
  font-size: 0.82rem;
}

.as-kbd {
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  padding: 0 5px;
  font-family: inherit;
  font-size: 10px;
  color: var(--muted);
}

.as-searching {
  margin: 0.6rem 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}

@media (max-width: 640px) {
  .as-row {
    flex-wrap: wrap;
  }

  .as-row__info {
    flex: 1 1 0;
    min-width: 0;
  }

  .as-row__info strong {
    white-space: normal;
  }

  .as-row__controls {
    flex-basis: 100%;
    justify-content: flex-end;
    margin-left: 0;
  }

  .as-pal {
    width: 36px;
    height: 36px;
  }

  .as-chip__x {
    padding: 8px 10px;
  }

  .as-continue {
    margin-left: 0.5rem;
  }

  .as-stock {
    padding-left: 0.5rem;
  }
}

/* UX-3 · Accesibilidad */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Enlaces: un índigo más claro que llega a 4,5:1 sobre las superficies oscuras */
.link-btn {
  color: var(--link);
}

/* Objetivos táctiles: al menos 24 px en escritorio */
.as-chip__x {
  min-width: 24px;
  min-height: 24px;
}

.as-qty__btn {
  min-width: 28px;
  min-height: 28px;
}

/* Foco visible en los controles del cuadro y las fichas */
.as-pal:focus-visible,
.as-other:focus-visible,
.as-qty__btn:focus-visible,
.as-brand:focus-visible,
.stock-mode:focus-visible,
.finish-pill:focus-visible,
.sheet-hero:focus-visible,
.as-stock__close:focus-visible,
.as-chip__x:focus-visible,
.pw-toast__action:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.pw-toast__action {
  color: #3730a3;
}

@media (max-width: 768px) {
  /* El aviso queda por encima de la barra inferior */
  .pw-toast {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 640px) {
  .as-pal {
    width: 40px;
    height: 40px;
  }

  .as-chip__x {
    min-width: 36px;
    min-height: 36px;
  }

  .stock-mode,
  .as-other {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .spool.is-printing {
    animation: none;
  }

  .pw-toast,
  .stock-box__bar span,
  .as-pal,
  .as-pal:hover {
    transition: none;
    transform: none;
  }
}

/* UX-4 · Datos técnicos a la vista */
.calib-badge {
  margin-top: 4px;
  white-space: nowrap;
}

.as-tag {
  margin-left: 6px;
}

.material-badge {
  margin-right: 8px;
}




.tech-summary {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.9rem;
}

.tech-summary__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.tech-summary__head h4 {
  margin: 0;
  font-size: 0.9rem;
}

.tech-summary__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 0.82rem;
}

.tech-summary__list li {
  display: flex;
  gap: 0.7rem;
}

.tech-summary__name {
  flex: none;
  min-width: 6.5rem;
  color: var(--muted);
}

.tech-summary__value--none {
  color: var(--muted);
  font-style: italic;
}

.pp-empty p {
  margin: 0 0 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

/* Botón de cerrar de los modales y espacios de «Datos de compra» */
dialog .card {
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--border-hover);
}

.modal-close:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

/* El título deja lugar a la × (y al botón «Compré otro igual», que queda a su izquierda) */
dialog .card > h3,
dialog .card > .as-purchase__grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.as-purchase__grid {
  gap: 0.9rem 0.8rem;
  margin-top: 0.8rem;
}

.as-credit {
  text-align: center;
}

/* Ficha del filamento: cabecera y secciones */
.sheet-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem 0.9rem 0.9rem;
  margin: 0.8rem 0;
}

.sheet-section__title {
  margin: 0 0 0.6rem;
  font-size: 0.92rem;
}

.sheet-section__title small {
  font-weight: 400;
  color: var(--muted);
}

.sheet-section .clone-help {
  margin: 0.5rem 0 0;
}

.sheet-section .pp-section {
  margin-top: 1rem;
  padding-top: 0.8rem;
}

.pp-title {
  margin: 0 0 0.2rem;
  font-size: 0.88rem;
}

.form-field--color input[type='color'] {
  width: 100%;
  height: 40px;
  padding: 2px;
  cursor: pointer;
}


/* Ficha del filamento unificada con la del rollo */
#typeModal .stock-box__now strong {
  font-size: 1.3rem;
}

#typeModal .stock-box .link-btn {
  font-size: 0.8rem;
  padding: 0;
}

.type-tech-edit {
  margin-top: var(--space-4);
}

.type-tech-edit .clone-help {
  margin: 0 0 0.5rem;
}

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

@media (max-width: 640px) {
  #typeModal .grid--3 {
    grid-template-columns: 1fr 1fr;
  }
}

/* Tamaños de modal: tres anchos para toda la web (en celular son pantalla completa) */
:root {
  --link: #818cf8; /* enlaces y acentos de texto sobre fondos oscuros (contraste 4,9:1) */
  --modal-sm: 420px; /* avisos, confirmaciones y formularios cortos */
  --modal-md: 560px; /* formularios medianos e importaciones */
  --modal-lg: 680px; /* fichas y el cuadro de agregar */
}

@media (min-width: 769px) {
  .modal--sm .card,
  .modal--md .card,
  .modal--lg .card {
    min-width: 0;
    max-width: none;
  }

  .modal--sm .card {
    width: min(var(--modal-sm), calc(100vw - 48px));
  }

  .modal--md .card {
    width: min(var(--modal-md), calc(100vw - 48px));
  }

  .modal--lg .card {
    width: min(var(--modal-lg), calc(100vw - 48px));
  }
}

.app-version--inline {
  margin: 0 0 1.2rem;
  text-align: center;
}

/* Mobile · uniformidad: pie de acciones fijo, objetivos táctiles de 40 px y pestañas en una línea */
@media (max-width: 768px) {
  /* Las acciones de cada modal quedan siempre a la vista: lo principal arriba, el resto debajo */
  .modal .row.actions {
    position: sticky;
    bottom: calc(-24px - env(safe-area-inset-bottom, 0px));
    z-index: 3;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px -20px calc(-24px - env(safe-area-inset-bottom, 0px));
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--bg);
    border-top: 1px solid var(--border);
  }

  .modal .row.actions .btn {
    height: 44px;
    width: auto;
    flex: 1 1 0;
    min-width: 0;
    padding-left: 8px;
    padding-right: 8px;
  }

  .modal .row.actions .btn--primary {
    order: -1;
    flex: 1 1 100%;
  }

  .modal .row.actions .btn--danger {
    margin: 0;
  }

  .modal-close {
    width: 40px;
    height: 40px;
  }

  .btn--sm,
  .list-tab,
  .btn-quick-subtract,
  .tech-details > summary,
  .as-purchase > summary,
  .sheet-more > summary {
    min-height: 40px;
  }

  .btn-quick-subtract {
    min-width: 40px;
  }

  .group-toggle {
    min-height: 40px;
    align-items: center;
  }

  .group-toggle input {
    width: 20px;
    height: 20px;
  }

  .list-tabs {
    gap: 6px;
  }

  .list-tab {
    padding: 0 10px;
    font-size: 13px;
  }

  #registerModal label.checkbox-label input {
    width: 20px;
    height: 20px;
  }

  #loginModal .link-btn,
  #registerModal a,
  #registerModal .link-btn {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
  }
}

/* Encabezado común de cada vista: título, una línea que explica y la acción principal */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.page-head__title {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
}

.page-head__sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.page-head + .topbar {
  margin-top: 0;
  margin-bottom: 28px;
}

@media (max-width: 768px) {
  /* En celular el menú inferior ya dice dónde estás; queda solo el botón (flotante) */
  .page-head {
    display: block;
    margin: 0;
  }

  .page-head__text {
    display: none;
  }
}

/* Campos de formulario: el espaciado es del contenedor, no depende de dónde esté (desplegable, ficha, tarjeta) */
.tech-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.tech-fields .form-field--full {
  grid-column: 1 / -1;
}

@media (max-width: 640px) {
  .tech-fields {
    grid-template-columns: 1fr;
  }
}

/* Un campo suelto debajo de otro (fuera de una grilla) también deja aire */
.form-field + .form-field,
.form-field + .grid,
.grid + .form-field,
.tech-fields + .form-field {
  margin-top: 16px;
}

.grid > .form-field + .form-field,
.tech-fields > .form-field + .form-field,
.color-panel__row > .form-field + .form-field,
.pp-grid > .pp-field + .pp-field {
  margin-top: 0;
}

.grid + .tech-summary,
.clone-help + .tech-summary,
.grid + .stock-box {
  margin-top: 16px;
}

/* Lo marcado como oculto (hidden) se oculta siempre, aunque la clase le ponga un display */
[hidden] {
  display: none !important;
}

/* ==========================================================================
   Sistema de espaciado (reglas en docs/ux/reglas-de-interfaz.md)
   Escala de 4 px. Nadie pone márgenes sueltos: el espacio lo da el contenedor.
   ========================================================================== */
:root {
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
}

/* Pila: lo que va uno debajo del otro se separa con el mismo espacio (16 px) */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.stack > * {
  margin-top: 0;
  margin-bottom: 0;
}

.stack--sm {
  gap: var(--space-2);
}

/* Cada modal es una pila: título, bloques, separadores y acciones, todo a 16 px entre sí */
.modal .card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal .card > * {
  margin-top: 0;
  margin-bottom: 0;
}

.modal .card > h3 {
  margin-bottom: var(--space-2); /* título → contenido: 24 px en total */
}

.modal .card > .row.actions {
  margin-top: var(--space-4); /* contenido → acciones: 32 px en total */
}

/* Campo: la etiqueta y su control a 8 px, siempre */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-field > label,
.form-field > .field-head {
  margin: 0;
}

.form-field--grow {
  flex: 1;
}

/* En una fila de campos, si una etiqueta pasa a dos líneas (celular) las otras ceden el espacio: los controles quedan
   siempre alineados */
.grid > .form-field > label,
.tech-fields > .form-field > label {
  flex: 1;
}

/* Grillas de campos: 16 px entre campos, en filas y en columnas */
.grid,
.tech-fields,
.as-purchase__grid {
  gap: var(--space-4);
}

/* Entre secciones no se dibujan líneas: las separa el espacio de la pila (16 px). Una línea suelta, solo en un caso
   excepcional, con .divider */
.divider,
.modal .card > hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-2) 0;
}

details.tech-details > summary,
details.sheet-more > summary,
details.as-purchase > summary {
  margin: 0;
  padding: 0;
}

details.tech-details[open] > :not(summary),
details.sheet-more[open] > :not(summary),
details.as-purchase[open] > :not(summary) {
  margin-top: var(--space-4);
}

/* Bloques con borde dentro de una pila o de otro bloque: mismo relleno por dentro */
.stock-box,
.tech-summary,
.pp-card {
  padding: var(--space-4);
}

.stock-box,
.tech-summary {
  margin: 0;
}

.pp-section {
  margin-top: var(--space-4);
  padding-top: 0;
}

/* Textos de modal */
.modal-text {
  margin: 0;
  line-height: 1.5;
  color: var(--text);
}

.modal-text--muted {
  color: var(--text-secondary);
}

.hint-text {
  margin: 0;
  font-size: 0.8em;
  color: var(--text-secondary);
}

.modal-name {
  margin: 0;
  color: var(--primary);
  font-weight: 600;
}

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn--danger-text {
  color: var(--danger);
}

.icon-sm {
  width: 14px;
  height: 14px;
  margin-right: var(--space-1);
}

.cmd-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.cmd-input {
  flex: 1;
  font-family: monospace;
  font-size: 0.8em;
}

.code-block {
  margin: 0;
  padding: var(--space-3);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.85em;
  overflow-x: auto;
}

.form-field textarea {
  width: 100%;
  resize: vertical;
}

/* Menú inferior de celular */
.sheet-menu {
  padding: 0;
  gap: 0;
}

.sheet-menu__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5);
  border-bottom: 1px solid var(--border);
}

.sheet-menu__head h3 {
  margin: 0;
}

.sheet-menu__head .btn {
  color: var(--text-secondary);
}

/* El espacio de las grillas lo da el gap y el margen de la pila: sin relleno propio (regla 1) */
.tech-details .tech-fields,
.tech-fields {
  padding: 0;
}

/* ==========================================================================
   Mismo rol, mismo estilo: un solo estilo por función; las pantallas no lo pisan
   ========================================================================== */
:root {
  --control-h: 44px; /* campos, selectores y botones normales */
  --control-h-sm: 36px; /* botones chicos y controles compactos */
}

/* Controles: la misma altura, así los de una misma fila quedan alineados */
input:not([type='checkbox']):not([type='radio']):not([type='color']):not([type='file']):not([type='range']):not([type='hidden']),
select {
  height: var(--control-h);
}

.btn {
  min-height: var(--control-h);
}

.btn--sm {
  min-height: var(--control-h-sm);
}

/* Controles compactos del cuadro (peso, resto del rollo): chicos, pero todos iguales entre sí */
#addSpoolsModal .as-row .as-weight,
#addSpoolsModal .as-stock input,
#addSpoolsModal .as-stock select {
  height: var(--control-h-sm);
}

/* Título de sección plegable: el mismo en todos los modales */
details > summary {
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

details > summary small {
  font-size: 0.85em;
  font-weight: 400;
  color: var(--muted);
}

/* Cajas (resumen, caja de stock): su contenido es una pila, con el mismo relleno arriba y abajo; lo vacío no ocupa */
.stock-box,
.tech-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.stock-box > *,
.tech-summary > * {
  margin: 0;
}

.stock-box__bar {
  margin: 0;
}

.stock-box__result:empty {
  display: none;
}

/* «Ver los rollos» a la izquierda, como cualquier enlace dentro de una caja */
.stock-box .link-btn {
  align-self: flex-start;
}

/* La marca dentro de la tarjeta de color: se toca para editar su carrete vacío */
.hero-link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 3px;
  cursor: pointer;
  text-shadow: inherit;
}

.hero-link svg {
  width: 0.85em;
  height: 0.85em;
  vertical-align: -0.1em;
}

/* Datos técnicos: el resumen se toca para editar (sin botón intermedio) */
.tech-summary--tap {
  cursor: pointer;
}

.tech-summary--tap:hover {
  border-color: var(--border-hover);
}

.tech-summary--tap:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.tech-summary__hint {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--muted);
  font-size: 0.78rem;
}

.tech-summary__hint svg {
  width: 14px;
  height: 14px;
}

/* Datos técnicos: una tabla con la base y una fila por impresora (features/techTable.js) */
.tech-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: var(--space-4);
  background: var(--panel-2);
}

.tech-block__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.tech-block__head h4 {
  margin: 0;
  font-size: 0.9rem;
}

.tech-block__hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.78rem;
}

/* Plegado, el bloque se toca para desplegar la tabla (como el panel de color) */
.tech-block--tap {
  cursor: pointer;
}

.tech-block--tap:hover {
  border-color: var(--border-hover);
}

.tech-block--tap:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.tech-block__head + .tech-summary__list {
  margin-top: 0;
}

.tech-table {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tt-row {
  display: grid;
  grid-template-columns: minmax(6rem, 1fr) minmax(0, 1.35fr) repeat(4, minmax(0, 1fr));
  gap: var(--space-2);
  align-items: center;
}

.tt-head {
  color: var(--muted);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tt-th {
  text-align: right;
  padding-right: var(--space-2);
  white-space: nowrap;
  cursor: help;
}

.tt-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

.tt-name small {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
}

.tt-label {
  display: none; /* en celular cada campo lleva su etiqueta; en escritorio, el encabezado */
}

.tt-cell {
  position: relative;
  display: flex;
  align-items: center;
  height: var(--control-h-sm);
  padding: 0 var(--space-2);
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  font-variant-numeric: tabular-nums;
}

.tt-row--base .tt-cell {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--border-hover);
}

.tt-row--base .tt-name strong {
  font-size: 0.95rem;
}

.tt-cell input {
  flex: 1;
  min-width: 0;
  height: 100% !important; /* la regla general de controles (44 px) es más específica */
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  text-align: right;
  font-size: 0.88rem;
}

.tt-cell input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}


.tt-cell.is-own {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.12);
}

.tt-cell.is-own::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 2px;
  background: var(--primary);
}

.tt-reset {
  position: absolute;
  left: 6px;
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
}

.tt-reset:hover,
.tt-reset:focus-visible {
  color: var(--text);
}

.tt-cell:not(.is-own) .tt-reset {
  display: none;
}

.tt-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.tt-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: 0.82rem;
}

.tt-copy select {
  width: auto;
  min-width: 0;
  height: var(--control-h-sm);
  padding: 0 var(--space-3);
}

/* En celular, una tarjeta por impresora: 3 campos por fila con su etiqueta arriba, en una línea */
@media (max-width: 640px) {
  .tt-head {
    display: none;
  }

  .tt-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-radius: 12px;
  }

  .tt-name {
    grid-column: 1 / -1;
  }

  .tt-label {
    display: block;
    margin-bottom: var(--space-1);
    color: var(--muted);
    font-size: 0.7rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
  }
}

.color-panel__row--even {
  grid-template-columns: 1fr 1fr;
}

/* Tablas de lista: el stock y el botón de resta no se parten en dos líneas (solo Agotados, con más acciones, las parte) */
.table:not(.table--review) .stock-cell {
  flex-wrap: nowrap;
}

/* En celular la tabla de datos técnicos no lleva una caja dentro de otra, y copiar de una impresora a otra se apila */
@media (max-width: 640px) {
  .tech-block {
    padding: 0;
    border: 0;
    background: none;
  }

  .tt-copy select {
    flex: 1;
    min-width: 0;
  }

  .tt-copy button {
    width: 100%;
  }
}

.tt-actions {
  margin-top: var(--space-2);
}

/* En celular todo lo tocable de las fichas mide al menos 40 px (regla 13), también los paneles nuevos */
@media (max-width: 768px) {
  .btn--sm,
  .stock-mode,
  .finish-pill,
  .modal-close {
    min-height: 40px;
  }

  .stock-mode,
  .finish-pill {
    display: inline-flex;
    align-items: center;
  }

  .modal-close {
    min-width: 40px;
  }

  details > summary {
    padding-block: 9px;
  }

  .tt-cell {
    height: 42px; /* el campo de adentro mide 40 (menos el borde de 1 px a cada lado) */
  }

  .tt-reset {
    top: 0;
    bottom: 0;
    left: 0;
    width: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .tt-copy select {
    height: 40px;
  }

  .color-panel .form-field--color input[type='color'] {
    height: 40px;
  }

  /* La marca dentro de la tarjeta: el enlace es chico, así que su zona tocable se agranda sin moverlo */
  .hero-link {
    padding: 13px 6px;
    margin: -13px -6px;
  }
}

/* Un botón deshabilitado se ve deshabilitado (antes el principal seguía igual de vivo) */
.btn:disabled,
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  filter: saturate(0.6);
}

/* Restar consumo en la lista: una acción frecuente y chica, no una alarma; el rojo queda para borrar */
.btn-quick-subtract {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--muted);
}

.btn-quick-subtract:hover,
.btn-quick-subtract:active {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.35);
  color: var(--danger);
}

/* Las casillas siguen el tema oscuro y el color de la app */
input[type='checkbox'] {
  accent-color: var(--primary);
  color-scheme: dark;
}

/* Tarjetas de resumen: solo «Bajo stock» se toca (filtra la lista); las otras dos informan y no prometen nada */
.stat-card--static:hover {
  transform: none;
  border-color: var(--border);
  background: var(--panel);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.stat-card--static:hover .stat-decoration {
  opacity: 0.2;
  transform: none;
}

.stat-card--static:hover .stat-overlay {
  opacity: 0.35;
  transform: none;
}

.stat-card--static:hover .stat-icon-mini {
  transform: none;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary);
  box-shadow: none;
}

.stat-card--static:hover .stat-icon-mini.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--ok);
}

.stat-card[role='button'] {
  cursor: pointer;
}

.stat-card[role='button']:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 3px;
}

/* Aplicado: borde y tinte del color del aviso y una ✕, para no depender solo del color */
.stat-card[aria-pressed='true'] {
  border: 2px solid var(--danger);
  background: rgba(239, 68, 68, 0.08);
}

.stat-card[aria-pressed='true']::after {
  content: '✕';
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 3;
  color: var(--danger);
  font-size: 0.95rem;
}

.stat-card[aria-disabled='true'] {
  cursor: default;
}

.stat-card[aria-disabled='true']:hover {
  transform: none;
  border-color: var(--border);
  background: var(--panel);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* El filtro aplicado, junto a las pestañas: qué es, cuántos de cuántos y cómo quitarlo */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px var(--space-3);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.12);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
}

.filter-chip:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.filter-chips__count {
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 768px) {
  .filter-chip {
    min-height: 40px;
  }
}

/* Sin el campo de color (filamento existente), el nombre ocupa todo el ancho */
#type-identity[data-existing='true'] .form-field--name {
  grid-column: 1 / -1;
}

/* Las etiquetas caben en una línea (regla 16): el «?» de ayuda no baja a una segunda */
.form-field > label,
.tt-label,
.tt-th {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-field > label .help-icon {
  white-space: nowrap;
}

@media (max-width: 768px) {
  .link-btn {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }
}

/* En celular, aire al final de la pantalla: el «+» flotante no tapa los controles de la última fila */
@media (max-width: 768px) {
  .main {
    padding-bottom: 170px;
  }
}

/* Ayuda debajo de las herramientas del rollo (por ejemplo, qué es el carrete vacío) */
.stock-box__help {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.stock-box__help .link-btn {
  margin-left: var(--space-2);
  font-size: inherit;
}

/* La marca en el subtítulo de la lista: solo en celular, donde su columna está oculta */
.subtitle-brand {
  display: none;
}

@media (max-width: 768px) {
  .subtitle-brand {
    display: inline;
  }
}

/* El botón «Filtros» y la insignia: solo en celular (en escritorio los filtros se ven siempre) */
.filters-toggle {
  position: relative;
}

.filters-toggle__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

@media (min-width: 769px) {
  .filters-toggle {
    display: none !important;
  }
}

/* Cabecera de Rollos y Filamentos más baja en celular: la lista empieza arriba, y las tarjetas entran juntas (la de la última impresión, en una tira debajo) */
@media (max-width: 768px) {
  .topbar {
    gap: 8px;
    margin-bottom: 8px;
  }

  .search-filters {
    gap: 8px;
  }

  .stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 0;
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
  }

  .stat-card {
    flex: none;
    padding: 10px 10px 8px;
    border-radius: 12px;
  }

  .stat-decoration,
  .stat-overlay,
  .stat-icon-mini,
  .stat-card .stat-sub {
    display: none;
  }

  /* La última impresión: una tira de ancho completo, con el costo a la vista (va en el subtítulo) */
  #stat-last-print-card {
    grid-column: 1 / -1;
    order: 1; /* en el grupo va antes de «Bajo stock»; en celular, la tira queda debajo de las tres */
    padding: 8px 10px;
  }

  #stat-last-print-card .stat-info {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 10px;
  }

  #stat-last-print-card .stat-info .value {
    margin: 0;
  }

  #stat-last-print-card .stat-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 0 10px;
    margin: 0;
    font-size: 0.7rem;
  }

  .stat-content {
    gap: 0;
  }

  .stat-info h4 {
    font-size: 10px;
  }

  .stat-info .value {
    font-size: 18px;
  }

  .stat-card[aria-pressed='true']::after {
    top: 6px;
    right: 8px;
    font-size: 0.8rem;
  }
}

/* Mantenimiento por horas de impresión (Integraciones → ficha de cada impresora) */
.printer-maint {
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-3);
}

.printer-maint__title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.maint-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.maint-task {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.maint-task__head,
.maint-task__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.maint-task__name {
  font-weight: 600;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.maint-task__hours {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.maint-task__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.maint-task__bar {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ok);
}

.maint-task__bar::-webkit-progress-bar {
  background: rgba(255, 255, 255, 0.08);
}

.maint-task__bar::-webkit-progress-value {
  background: var(--ok);
  border-radius: 4px;
}

.maint-task__bar::-moz-progress-bar {
  background: var(--ok);
  border-radius: 4px;
}

.maint-task--soon .maint-task__bar::-webkit-progress-value {
  background: var(--warn);
}

.maint-task--soon .maint-task__bar::-moz-progress-bar {
  background: var(--warn);
}

.maint-task--due .maint-task__bar::-webkit-progress-value {
  background: var(--danger);
}

.maint-task--due .maint-task__bar::-moz-progress-bar {
  background: var(--danger);
}

.maint-form .maint-form__hours {
  flex: 0 0 11rem;
}

.maint-add {
  align-self: flex-start;
}

@media (max-width: 768px) {
  .printer-maint {
    flex: none;
  }

  .maint-form .maint-form__hours {
    flex: none;
  }

  /* En celular lo tocable mide al menos 40 px */
  .maint-task__actions .btn--sm,
  .maint-form .btn--sm,
  .maint-add {
    min-height: 40px;
  }
}

/* ==========================================================================
   VISTA COMPACTA EN ORCA (body.embed, ver utils/embed.js)
   La pestaña de OrcaSlicer tiene el ancho del panel (420 a 1400 px): se ve como el celular
   (@media 768px), sin menú lateral ni marca. Repite solo lo necesario de ese diseño.
   ========================================================================== */
body.embed .app {
  grid-template-columns: 1fr;
  grid-template-rows: 56px 1fr;
  height: 100vh;
  overflow: hidden;
}

body.embed .sidebar {
  display: none;
}

body.embed .main {
  padding: 12px;
  padding-bottom: 80px;
  height: auto;
  min-width: 0;
  max-width: 100vw;
  overflow-x: hidden;
  overflow-y: auto;
  grid-row: 2;
}

/* Sin marca: solo el botón de configuración a la derecha */
body.embed .mobile-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  grid-row: 1;
  z-index: 100;
}

body.embed .mobile-header__brand {
  display: none;
}

body.embed .mobile-nav {
  display: flex;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  z-index: 999;
  justify-content: space-around;
  align-items: center;
  padding: 0 4px;
}

body.embed .mobile-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 12px;
}

body.embed .mobile-nav__item i {
  width: 22px;
  height: 22px;
}

body.embed .mobile-nav__item.active {
  color: var(--primary);
}

body.embed .page-head {
  display: block;
  margin: 0;
}

body.embed .page-head__text {
  display: none;
}

body.embed .page-head .actions {
  position: static;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  display: block;
}

/* Botón flotante: solo el icono, se estira al tocarlo */
body.embed #addBtn {
  position: fixed;
  bottom: 80px;
  right: 20px;
  height: 56px;
  width: 56px;
  border-radius: 28px !important;
  padding: 0 16px !important;
  z-index: 998;
  font-size: 0;
  box-shadow: 0 6px 20px -4px rgba(99, 102, 241, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  overflow: hidden;
}

body.embed #addBtn i {
  margin: 0;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

body.embed .topbar {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 16px;
}

body.embed .search {
  flex: 1 1 100%;
  max-width: 100%;
}

body.embed .filters-row {
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

body.embed .multi-select {
  max-width: 100%;
  min-width: 175px;
  width: 100%;
}

/* Tarjetas de arriba: tres columnas, la última impresión es una tira de ancho completo */
body.embed .stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 0;
  overflow: visible;
  -webkit-mask-image: none;
  mask-image: none;
}

body.embed .stat-card {
  flex: none;
  padding: 10px 10px 8px;
  border-radius: 12px;
}

body.embed .stat-decoration,
body.embed .stat-overlay,
body.embed .stat-icon-mini,
body.embed .stat-card .stat-sub {
  display: none;
}

body.embed #stat-last-print-card {
  grid-column: 1 / -1;
  order: 1;
  padding: 8px 10px;
}

body.embed #stat-last-print-card .stat-info {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
}

body.embed #stat-last-print-card .stat-info .value {
  margin: 0;
}

body.embed #stat-last-print-card .stat-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 0 10px;
  margin: 0;
  font-size: 0.7rem;
}

body.embed .stat-content {
  gap: 0;
}

body.embed .stat-info h4 {
  font-size: 10px;
}

body.embed .stat-info .value {
  font-size: 18px;
}

/* Lista de Rollos en tarjetas (como en celular); mismas reglas que la de @media 768px, sección 5 */
body.embed #filaments-view .table {
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  overflow: visible;
}

body.embed #filaments-view .thead {
  display: none;
}

body.embed #filaments-view .tbody {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

body.embed #filaments-view .tr {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto;
  gap: 4px 12px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  margin-bottom: 0;
}

body.embed #filaments-view .name-cell {
  grid-column: 1;
  grid-row: 1;
}

body.embed #filaments-view .brand-cell,
body.embed #filaments-view .tr > div:nth-child(3),
body.embed #filaments-view .tr > div:nth-child(4) {
  display: none;
}

body.embed #filaments-view .stock-cell {
  grid-column: 2 !important;
  grid-row: 1 !important;
}

body.embed #filaments-view .tr--expanded::after,
body.embed #filaments-view .tr--child::before,
body.embed #filaments-view .tr--child::after {
  display: none;
}

body.embed #filaments-view .tr--child {
  margin-left: 24px;
  background: rgba(255, 255, 255, 0.025);
}

body.embed #filaments-view .tr--child .name-cell {
  padding-left: 0;
}

body.embed .btn-quick-subtract {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
}

/* Aviso «No alcanza» de la tarjeta de impresión: texto con icono, no solo color */
.active-spool-card__forecast {
  margin-top: 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  color: #f59e0b;
  cursor: help;
}

.active-spool-card__forecast svg {
  width: 12px;
  height: 12px;
  margin-right: 4px;
  vertical-align: -1px;
}

/* === Marca Spool Moon: logo y aviso «antes PrintWise» === */
.brand-mark {
  width: 42px;
  height: 42px;
  flex: none;
  display: block;
}

.mobile-header__brand .brand-mark {
  width: 32px;
  height: 32px;
}

.brand-text .old-name {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.brand-text .old-name[hidden] {
  display: none;
}

.brand-text .old-name span {
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
}

.old-name__close {
  appearance: none;
  background: none;
  border: 0;
  border-radius: 4px;
  padding: 2px 5px;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}

.old-name__close:hover {
  color: var(--text);
}

.old-name__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
