/* ===== RESET GENERAL ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  height: 100vh;
  background-color: #f4f6f8;
  display: flex;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 260px;
  background-color: #111827;
  color: white;
  display: flex;
  flex-direction: column;
  padding: 20px;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar h1 {
  font-size: 20px;
  margin-bottom: 30px;
  color: #10b981;
}

.sidebar a {
  color: white;
  text-decoration: none;
  margin: 8px 0;
  padding: 8px;
  border-radius: 4px;
  transition: background 0.3s;
  font-size: 14px;
}

.sidebar a:hover {
  background-color: #1f2937;
}

.sidebar a.active {
  background-color: #0f766e;
}

.sidebar .section-title {
  margin-top: 15px;
  margin-bottom: 5px;
  font-size: 13px;
  color: #9ca3af;
  font-weight: bold;
}

/* ===== MAIN LAYOUT ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.header {
  background-color: #10b981;
  padding: 20px;
  color: white;
  font-size: 20px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.content {
  flex-grow: 1;
  padding: 30px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.dashboard-box {
  background-color: white;
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  height: 100%;
  max-width: 100%;
  width: 900px;
  overflow: auto;
  margin: 0 auto;
}

.dashboard-box h2 {
  color: #111827;
  margin-bottom: 10px;
}

.dashboard-box p {
  color: #4b5563;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main {
    width: 100%;
  }
}

/* ===== BOTONES ===== */
button {
  padding: 10px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.btn-verde {
  background-color: #10b981;
  color: white;
  font-size: 16px;
  font-weight: bold;
  border-radius: 8px;
  transition: background-color 0.3s ease;
}

.btn-verde:hover {
  background-color: #0f766e;
}

button.btn-azul {
  background: #3b82f6;
  color: white;
}

button.logout {
  background-color: #ef4444;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  color: white;
}

/* ===== FORMULARIOS Y PANEL DE IMPORTACIÓN ===== */
#formulario-cliente,
#formulario-producto,
#importador,
#importador-productos {
  margin-top: 20px;
  background: #f9fafb;
  padding: 20px;
  border: 1px solid #ddd;
  border-radius: 10px;
}

/* INPUTS Y TEXTAREAS */
#formulario-cliente input,
#formulario-cliente textarea,
#formulario-producto input,
#formulario-producto textarea,
#importador textarea,
#importador-productos textarea {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  text-transform: uppercase;
}

/* TEXTAREA IMPORTACIÓN */
#excel-input,
#excel-input-productos {
  height: 200px;
  font-family: monospace;
}

/* ===== INSTRUCCIONES ===== */
#instrucciones-importacion {
  background: #fef3c7;
  color: #92400e;
  padding: 15px;
  margin-top: 15px;
  border: 1px solid #facc15;
  border-radius: 8px;
  font-size: 14px;
}

#instrucciones-importacion code {
  background: #fcd34d;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}

/* ===== TABLAS ===== */
.tabla-wrapper {
  margin-top: 20px;
  background: #f9fafb;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 0;
  overflow-x: auto;
}

.tabla-wrapper table {
  width: 100%;
  min-width: 1000px;
  border-collapse: collapse;
  font-size: 14px;
  border-radius: 10px;
  overflow: hidden;
}

.tabla-wrapper th {
  background-color: #10b981;
  color: white;
  padding: 12px 16px;
  text-align: left;
  font-weight: bold;
  white-space: nowrap;
  border-bottom: 2px solid #0f766e;
}

.tabla-wrapper tbody tr:nth-child(odd) {
  background-color: #ffffff;
}

.tabla-wrapper tbody tr:nth-child(even) {
  background-color: #ecfdf5;
}

.tabla-wrapper td {
  padding: 10px 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: none;
}

/* Celdas con scroll interno */
#tabla-clientes td div,
#tabla-productos td div {
  max-height: 40px;
  overflow-y: auto;
}

/* ===== BOTONES MINI ===== */
.btn-mini {
  padding: 6px 10px;
  margin: 0 2px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.btn-mini.editar {
  background-color: #3b82f6;
  color: white;
}
.btn-mini.editar:hover {
  background-color: #2563eb;
}

.btn-mini.eliminar {
  background-color: #ef4444;
  color: white;
}
.btn-mini.eliminar:hover {
  background-color: #dc2626;
}

.btn-mini.guardar {
  background-color: #10b981;
  color: white;
}
.btn-mini.guardar:hover {
  background-color: #0f766e;
}

.btn-mini.cancelar {
  background-color: #9ca3af;
  color: white;
}
.btn-mini.cancelar:hover {
  background-color: #6b7280;
}
/* 🔧 FORMULARIO NUEVO PRODUCTO */
#formulario-producto {
  margin-top: 20px;
  background: #f9fafb;
  padding: 20px;
  border: 1px solid #ddd;
  border-radius: 10px;
}

#formulario-producto input,
#formulario-producto textarea,
#formulario-producto select {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  text-transform: uppercase;
  background: white;
}

#formulario-producto label {
  font-weight: bold;
  margin-bottom: 2px;
  font-size: 13px;
  color: #374151;
}

/* ✅ BLOQUE 1: TIPO / UNIDAD / PRODUCTOS (75%) + Imagen (25%) */
.fila-producto {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.campo-grande {
  flex: 3;
  display: flex;
  flex-direction: column;
}

.imagen-producto {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.imagen-producto input[type="file"] {
  margin-top: 5px;
}

/* ✅ BLOQUE 2: MATERIALES 1, 2, 3 (33% cada uno por fila) */
.fila-material {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.bloque-material {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 250px;
}

/* ✅ BLOQUE 3: COSTOS / GIF / HORAS / GANANCIAS en 2 columnas (50% cada una) */
.fila-doble {
  display: flex;
  gap: 30px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.columna {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 300px;
}

/* ✅ BOTÓN DE GUARDAR PRODUCTO */
#formulario-producto .btn-verde {
  margin-top: 20px;
}

.formulario-panel {
  margin-top: 20px;
  background: #f9fafb;
  padding: 20px;
  border: 1px solid #ddd;
  border-radius: 10px;
}

.campo {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}

.campo label {
  margin-bottom: 5px;
  font-weight: bold;
  color: #374151;
}

.campo input {
  padding: 8px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: white;
}

#excel-input-dme {
  width: 100%;
  height: 200px;
  font-family: monospace;
  padding: 8px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  margin-bottom: 10px;
}

.alerta-importacion {
  background: #fef3c7;
  color: #92400e;
  padding: 15px;
  margin-top: 15px;
  border: 1px solid #facc15;
  border-radius: 8px;
  font-size: 14px;
}

.codigo-ejemplo {
  background: #fcd34d;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}

.campo {
  margin-bottom: 15px;
  display: flex;
  flex-direction: column;
}

.campo label {
  margin-bottom: 5px;
  font-weight: bold;
  color: #374151;
}

.campo input,
.campo textarea {
  padding: 8px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: white;
}

.campo-textarea {
  width: 100%;
  height: 200px;
  font-family: monospace;
}

.alerta-importacion {
  background: #fef3c7;
  color: #92400e;
  padding: 15px;
  margin-top: 15px;
  border: 1px solid #facc15;
  border-radius: 8px;
  font-size: 14px;
}

.codigo-ejemplo {
  background: #fcd34d;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}

.campo-horizontal {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.campo-horizontal label {
  font-weight: bold;
  color: #374151;
  width: 100px;
  flex-shrink: 0;
}

.campo-horizontal input {
  padding: 8px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background: white;
  flex: 1;
}
  /* === KPIs: layout consistente y responsive (sin cambiar el diseño) === */
  .kpis{
    display: grid;
    grid-template-columns: repeat(5, minmax(180px, 1fr)); /* 5 iguales */
    gap: 12px;
    align-items: stretch; /* todas las tarjetas a la misma altura */
  }

  /* Breakpoints para que no se deformen en pantallas más chicas */
  @media (max-width: 1200px){ .kpis{ grid-template-columns: repeat(3, minmax(180px, 1fr)); } }
  @media (max-width: 900px){  .kpis{ grid-template-columns: repeat(2, minmax(180px, 1fr)); } }
  @media (max-width: 520px){  .kpis{ grid-template-columns: 1fr; } }

  /* Tarjeta KPI: mantener altura y tipografías consistentes */
  .kpi{
    display: flex;
    flex-direction: column;
    justify-content: center;       /* centra verticalmente el contenido */
    min-height: 110px;             /* altura fija para que no brinquen */
    padding: 14px;                 /* mismo padding en todas */
    box-sizing: border-box;        /* evita “crecimientos” raros */
  }

  .kpi .label{
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
    line-height: 1.2;
    white-space: nowrap;           /* evita dos líneas en el título */
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .kpi .value{
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    line-height: 1;
    white-space: nowrap;           /* números en una sola línea */
    overflow: hidden;              /* si se pasa, recorta */
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums; /* columnas más “cuadradas” */
  }