/* ==========================================================================
   SISTEMA DE RECEPCIÓN Y REGISTRO DE GALLOS - SISTEMA DE DISEÑO PRO
   MODO OSCURO & MODO CLARO ELEGANTE
   ========================================================================== */

:root {
  /* MODO OSCURO (POR DEFECTO) */
  --bg-body: #0b0f17;
  --bg-header: #111827;
  --bg-card: #161f30;
  --bg-card-subtle: #1c263c;
  --bg-input: #0c1322;
  --border-color: #24324d;
  --border-focus: #3b82f6;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --primary: #10b981;
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.35);
  
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-glow: rgba(59, 130, 246, 0.35);
  
  --color-tag-bg: #1e293b;
  --color-tag-text: #38bdf8;
  
  --cresta-tag-bg: #2d1b2e;
  --cresta-tag-text: #f472b6;
  
  --badge-no-bg: #37171d;
  --badge-no-text: #f87171;
  --badge-no-border: #991b1b;
  
  --badge-si-bg: #0d3322;
  --badge-si-text: #34d399;
  --badge-si-border: #059669;
  
  --ticket-paper: #ffffff;
  --ticket-text: #111827;
  --ticket-border: #d1d5db;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 14px 32px rgba(0, 0, 0, 0.55);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* ==========================================================================
   MODO CLARO (ELEGANTE, MODERNO Y DE ALTO CONTRASTE)
   ========================================================================== */
body.theme-light {
  --bg-body: #f1f5f9;
  --bg-header: #ffffff;
  --bg-card: #ffffff;
  --bg-card-subtle: #f8fafc;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-focus: #2563eb;
  
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #64748b;
  
  --primary: #059669;
  --primary-hover: #047857;
  --primary-glow: rgba(5, 150, 105, 0.25);
  
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-glow: rgba(37, 99, 235, 0.25);
  
  --color-tag-bg: #e0f2fe;
  --color-tag-text: #0369a1;
  
  --cresta-tag-bg: #fce7f3;
  --cresta-tag-text: #be185d;
  
  --badge-no-bg: #fee2e2;
  --badge-no-text: #dc2626;
  --badge-no-border: #fca5a5;
  
  --badge-si-bg: #dcfce7;
  --badge-si-text: #15803d;
  --badge-si-border: #86efac;
  
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.45;
  transition: background-color 0.25s ease, color 0.25s ease;
  user-select: none;
}

/* ==========================================================================
   HEADER PRINCIPAL & NAV
   ========================================================================== */
.app-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
}

.header-container {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon-box {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: var(--shadow-sm);
}

body.theme-light .brand-icon-box {
  background: linear-gradient(135deg, #f8fafc, #e2e8f0);
}

.brand-titles {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: var(--text-main);
  text-transform: uppercase;
}

.brand-jornada-sub {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Acciones en Header */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.theme-toggle-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  transform: scale(1.05);
  border-color: var(--border-focus);
}

.nav-tabs {
  display: flex;
  gap: 0.4rem;
  background: var(--bg-card-subtle);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.18s ease;
}

.nav-btn:hover {
  color: var(--text-main);
}

.nav-btn.active {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--accent-glow);
}

/* ==========================================================================
   ESTRUCTURA PRINCIPAL
   ========================================================================== */
.main-content {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   LAYOUT DEL OPERADOR: FORMULARIO + VISTA PREVIA TICKET
   ========================================================================== */
.operator-main-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 992px) {
  .operator-main-layout {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   TARJETAS SUPERIORES DE ESTADÍSTICAS (JAULA + TOTAL REGISTRADOS)
   ========================================================================== */
.stats-banner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.stat-card-box::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.stat-card-box.card-jaula::before {
  background: var(--primary);
}

.stat-card-box.card-total::before {
  background: var(--accent);
}

.stat-card-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.stat-card-value-jaula {
  font-family: var(--font-mono);
  font-size: 2.75rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
  letter-spacing: 2px;
}

.stat-card-value-total {
  font-family: var(--font-mono);
  font-size: 2.75rem;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

/* ==========================================================================
   FORMULARIO DE REGISTRO
   ========================================================================== */
.form-card-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-md);
}

.form-field-group {
  margin-bottom: 1.1rem;
  position: relative;
}

.form-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

/* Fila Gallera */
.gallera-input-wrapper {
  display: flex;
  gap: 0.6rem;
}

.btn-pill-action {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--accent);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-md);
  font-weight: 800;
  font-size: 0.8rem;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.btn-pill-action:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.gallera-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Inputs principales */
.form-input-pro {
  width: 100%;
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 0.8rem 1rem;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.18s ease;
}

.form-input-pro:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3.5px var(--accent-glow);
  background: var(--bg-card-subtle);
}

.form-input-pro.input-xl {
  font-size: 1.35rem;
  font-weight: 800;
}

/* Fila Color & Cresta */
.row-color-cresta {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1rem;
}

.input-with-badge-group {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.input-code-compact {
  width: 85px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.4rem;
  font-weight: 900;
}

.badge-preview-tag {
  flex: 1;
  background: var(--color-tag-bg);
  color: var(--color-tag-text);
  border: 1.5px solid transparent;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 0.5rem;
  transition: all 0.2s ease;
}

.badge-preview-tag.cresta-tag {
  background: var(--cresta-tag-bg);
  color: var(--cresta-tag-text);
}

/* Fila Peso & Peleado */
.row-peso-peleado {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 1rem;
  align-items: end;
}

.input-peso-pro {
  font-family: var(--font-mono);
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--primary);
  text-align: center;
  letter-spacing: 2px;
  padding: 0.55rem 0.75rem;
}

.peso-helper-card {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  margin-top: 0.4rem;
  line-height: 1.3;
}

/* Peleado Switch Buttons */
.peleado-segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  height: 54px;
}

.peleado-btn {
  background: var(--bg-input);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-dim);
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

.peleado-btn.active-no {
  background: var(--badge-no-bg);
  border-color: var(--badge-no-border);
  color: var(--badge-no-text);
}

.peleado-btn.active-si {
  background: var(--badge-si-bg);
  border-color: var(--badge-si-border);
  color: var(--badge-si-text);
}

/* Botón Gigante Registrar */
.btn-registrar-imprimir {
  width: 100%;
  margin-top: 1.25rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  border: none;
  border-radius: var(--radius-lg);
  color: #ffffff;
  padding: 1.15rem 1.5rem;
  font-size: 1.35rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 6px 20px var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  transition: all 0.18s ease;
}

.btn-registrar-imprimir:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px var(--primary-glow);
}

.btn-registrar-imprimir:active {
  transform: translateY(1px);
}

.key-hint-badge {
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.8rem;
  font-family: var(--font-mono);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.keyboard-footer-tip {
  margin-top: 0.85rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

/* ==========================================================================
   PANEL DERECHO: VISTA PREVIA DEL TICKET TÉRMICO REALISTA
   ========================================================================== */
.ticket-preview-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-heading {
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
}

/* Carcasa de Impresora Térmica */
.printer-device-mockup {
  width: 100%;
  max-width: 320px;
  background: #1e293b;
  border-radius: 20px 20px 10px 10px;
  padding: 18px 14px 10px 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5), inset 0 2px 4px rgba(255,255,255,0.1);
  border: 2px solid #334155;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Salida del papel térmico */
.paper-feed-slot {
  width: 90%;
  height: 6px;
  background: #0f172a;
  border-radius: 3px;
  margin-bottom: -3px;
  z-index: 2;
}

/* Papel del Ticket */
.thermal-paper-slip {
  width: 100%;
  background: #ffffff;
  color: #111827;
  padding: 16px 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 900;
  border-radius: 2px;
  position: relative;
}

.thermal-paper-slip .t-header {
  text-align: center;
  margin-bottom: 8px;
}

.thermal-paper-slip .t-logo-gallo {
  font-size: 32px;
  line-height: 1;
  margin-bottom: 4px;
}

.thermal-paper-slip .t-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 1px;
}

.thermal-paper-slip .t-divider {
  border-top: 1.5px dashed #000;
  margin: 6px 0;
}

.thermal-paper-slip .t-row {
  display: flex;
  justify-content: space-between;
  margin: 3px 0;
}

.thermal-paper-slip .t-jaula-box,
.thermal-paper-slip .t-peso-box {
  margin: 6px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.thermal-paper-slip .t-jaula-val,
.thermal-paper-slip .t-peso-val {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 1px;
}

.thermal-paper-slip .t-posta-line {
  margin: 12px 0 8px 0;
}

.thermal-paper-slip .t-footer {
  text-align: center;
  margin-top: 8px;
  font-size: 12px;
}

.btn-reprint-preview {
  width: 100%;
  max-width: 320px;
  margin-top: 0.85rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.18s ease;
}

.btn-reprint-preview:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ==========================================================================
   AUTOCOMPLETE DROPDOWN
   ========================================================================== */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 2px solid var(--border-focus);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: var(--shadow-lg);
  display: none;
}

.autocomplete-dropdown.show {
  display: block;
}

.autocomplete-item {
  padding: 0.75rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-main);
}

.autocomplete-item:hover, .autocomplete-item.selected {
  background: var(--accent);
  color: #ffffff;
}

/* ==========================================================================
   TABLAS Y MODALES
   ========================================================================== */
.table-responsive {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.95rem;
}

.data-table th {
  background: var(--bg-card-subtle);
  padding: 0.85rem 1.1rem;
  color: var(--text-muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
}

.data-table tr:hover {
  background: var(--bg-card-subtle);
}

.data-table .td-jaula {
  font-family: var(--font-mono);
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--primary);
}

.data-table .td-peso {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--text-main);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: var(--shadow-lg);
}

.modal-box.modal-box-wide {
  max-width: 580px;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 900;
  margin-bottom: 0.75rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Chips de selección rápida */
.quick-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 4px 0;
}

.quick-select-chip {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.15s ease;
}

.quick-select-chip:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.quick-select-chip .chip-count {
  background: rgba(0,0,0,0.3);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--primary);
}

/* Tarjetas de Memoria de Trabas */
.trabas-memory-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.65rem;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 0;
}

.memory-traba-card {
  background: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  transition: all 0.18s ease;
}

.memory-traba-card:hover {
  border-color: var(--accent);
  background: var(--bg-input);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.memory-traba-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.memory-traba-count {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-header);
  color: var(--text-main);
  border: 1.5px solid var(--border-focus);
  padding: 0.85rem 1.35rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  animation: slideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   ESTILOS DE LOGIN Y AUTENTICACIÓN
   ========================================================================== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 15, 23, 0.95);
  backdrop-filter: blur(10px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 1;
  visibility: visible;
  transition: all 0.25s ease;
}

.login-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.login-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 440px;
  width: 100%;
  padding: 2.25rem 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalScale {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.login-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 0.35rem;
  display: inline-block;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.4));
}

.login-title {
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.login-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.login-error {
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.4);
  color: #fca5a5;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.login-default-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  margin-top: 1.15rem;
  padding: 0.5rem;
  background: var(--bg-card-subtle);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border-color);
}

/* Badge de usuario en header */
.header-user-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-chip {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.user-role-tag {
  background: var(--accent);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 900;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  letter-spacing: 0.5px;
}

.user-role-tag.admin {
  background: #f59e0b;
}

.btn-logout-icon {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.15s ease;
}

.btn-logout-icon:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #ef4444;
}

/* Badges de Roles en Tabla */
.badge-role {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
}

.badge-role-admin {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-role-operador {
  background: rgba(59, 130, 246, 0.15);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* ==========================================================================
   SINCRONIZACIÓN
   ========================================================================== */
[hidden] { display: none !important; }

.sync-chip {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
}
.sync-chip[data-estado="al-dia"] { color: var(--primary); border-color: var(--primary); }
.sync-chip[data-estado="pendiente"],
.sync-chip[data-estado="sin-internet"],
.sync-chip[data-estado="sin-sesion"] { color: #f59e0b; border-color: #f59e0b; }
.sync-chip[data-estado="error"] { color: #ef4444; border-color: #ef4444; }

@media (max-width: 600px) {
  .sync-chip { font-size: 0.7rem; padding: 0.3rem 0.55rem; }
}

/* ==========================================================================
   CELULAR: el encabezado desbordaba a lo ancho (659 px en una pantalla de 375)
   ========================================================================== */
@media (max-width: 700px) {
  .header-container { flex-wrap: wrap; gap: 0.5rem; }
  .header-actions { flex-wrap: wrap; width: 100%; justify-content: flex-end; }
  .header-user-badge { flex: 1 1 auto; min-width: 0; }
  .header-user-badge .user-chip { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav-tabs { width: 100%; }
  .nav-btn { flex: 1 1 0; justify-content: center; padding: 0.45rem 0.4rem; }
  .main-content { overflow-x: hidden; }
  .stats-banner-grid { gap: 0.6rem; }
  .gallera-input-wrapper { min-width: 0; }
  .gallera-input-wrapper .form-input-pro { min-width: 0; }
  .row-color-cresta, .row-peso-peleado { grid-template-columns: 1fr; }
}
