:root {
  --azul: #1D4ED8;
  --azul-d: #1E3A8A;
  --gris-bg: #F8FAFC;
  --gris-borde: #E2E8F0;
  --rojo: #DC2626;
  --rojo-bg: #FEE2E2;
  --verde: #059669;
  --texto: #1F2937;
  --texto-sec: #6B7280;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  background: var(--gris-bg);
  color: var(--texto);
}

header {
  background: var(--azul-d);
  color: white;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: #93C5FD;
  font-weight: 600;
}
h1 { margin: 2px 0 0; font-size: 20px; }
.ultima-actualizacion { margin: 0; font-size: 11px; color: #93C5FD; }

.menu-tabs {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--gris-borde);
  background: white;
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 4px;
  margin-right: 24px;
  font-size: 13px;
  font-weight: 600;
  color: var(--texto-sec);
  cursor: pointer;
}
.tab-btn:hover { color: var(--texto); }
.tab-btn.activo { color: var(--azul-d); border-bottom-color: var(--azul); }

main { max-width: 1100px; margin: 0 auto; padding: 24px 28px 60px; }

.resumen { display: flex; gap: 16px; margin-bottom: 28px; }
.stat {
  flex: 1;
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 12px;
  padding: 16px 18px;
}
.stat-label { margin: 0; font-size: 12px; color: var(--texto-sec); font-weight: 600; }
.stat-value { margin: 4px 0 0; font-size: 28px; font-weight: 700; color: var(--azul-d); }
.stat-danger .stat-value { color: var(--rojo); }

h2 { font-size: 15px; color: var(--texto-sec); text-transform: uppercase; letter-spacing: 0.03em; margin: 0 0 12px; }

.maquinas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}
.maquina-card {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.maquina-card:hover { box-shadow: 0 2px 10px rgba(0,0,0,0.08); }
.maquina-card.activa { border-color: var(--azul); box-shadow: 0 0 0 2px rgba(29,78,216,0.15); }
.maquina-card.no-maquina { border-style: dashed; background: #FAFAF9; }
.maquina-nombre { font-weight: 700; font-size: 15px; margin: 0 0 6px; }
.maquina-meta { font-size: 12px; color: var(--texto-sec); margin: 2px 0; }
.maquina-backlog { font-size: 22px; font-weight: 700; margin: 8px 0 2px; }
.maquina-atrasadas { font-size: 12px; font-weight: 600; color: var(--rojo); }

.hidden { display: none; }

.table-wrap {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 12px;
  overflow: hidden;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: var(--azul-d); color: white; }
th, td { padding: 9px 12px; text-align: left; white-space: nowrap; }
tbody tr:nth-child(even) { background: #F9FAFB; }
tbody tr:hover { background: #EFF6FF; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge-en_proceso { background: #DBEAFE; color: #1E40AF; }
.badge-programada { background: #FEF9C3; color: #854D0E; }
.badge-atrasada { background: var(--rojo-bg); color: var(--rojo); margin-left: 6px; }

.nota { font-size: 12px; color: var(--texto-sec); line-height: 1.5; margin: 0 0 8px; max-width: 760px; white-space: normal; }
.nota-warn { font-size: 12px; color: #92400E; background: #FEF3C7; border: 1px solid #FDE68A; border-radius: 8px; padding: 8px 12px; margin: 0 0 16px; max-width: 760px; white-space: normal; }
.nota-warn:empty { display: none; }
td.faltante-positivo { color: var(--rojo); font-weight: 700; }
td.sospechoso { color: #92400E; }
#materiales-tabla td, #compra-tercerizacion-tabla td { white-space: normal; }

.filtro-productos {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 24px;
}
.filtro-input-wrap { display: flex; gap: 8px; align-items: center; }
#filtro-producto-input {
  flex: 1;
  max-width: 420px;
  padding: 8px 12px;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  font-size: 13px;
}
#filtro-producto-input:focus { outline: none; border-color: var(--azul); }
.btn-limpiar {
  background: none;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--texto-sec);
  cursor: pointer;
}
.btn-limpiar:hover { background: var(--gris-bg); color: var(--texto); }
.filtro-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.filtro-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #DBEAFE;
  color: #1E40AF;
  border-radius: 999px;
  padding: 4px 6px 4px 12px;
  font-size: 12px;
  font-weight: 600;
}
.filtro-chip button {
  background: rgba(30,64,175,0.12);
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  line-height: 1;
  color: #1E40AF;
  cursor: pointer;
  font-size: 12px;
}
.filtro-chip button:hover { background: rgba(30,64,175,0.25); }
#filtro-resumen { margin-top: 8px; margin-bottom: 0; }

footer { max-width: 1100px; margin: 0 auto; padding: 0 28px 40px; }
footer p { font-size: 11px; color: var(--texto-sec); text-align: center; }
