*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --border: #e2e2df;
  --border-focus: #a8a8a3;
  --text: #1a1a18;
  --text-muted: #78786e;
  --accent: #F97048;
  --accent-light: #FEF1EC;
  --teal: #00C9B1;
  --teal-light: #E6FAF8;
  --success: #16a34a;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', sans-serif;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}

.logo-dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; }
.logo-img { height: 44px; width: auto; display: block; }

nav { display: flex; gap: 4px; }

nav a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}

nav a:hover { background: var(--bg); color: var(--text); }
nav a.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }

main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 620px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.18);
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-size: 16px; font-weight: 500; }

.badge {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: 4px;
}

form { padding: 26px 28px; display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 5px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

select {
  width: 100%;
  height: 42px;
  padding: 0 32px 0 12px;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2378786e' 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");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(249,112,72,0.12); }
select.filled { background-color: #FEF8F5; border-color: #f9bfaa; color: var(--text); }

#dia { font-family: var(--mono); font-size: 13px; }
#dia option:disabled { color: #bbb; }

hr { border: none; border-top: 1px solid var(--border); }

.fixed-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.fixed-chip {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 4px;
}

.card-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.hint { font-size: 13px; color: var(--text-muted); }

button[type="submit"] {
  height: 40px;
  padding: 0 20px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: opacity 0.15s;
}

button[type="submit"]:hover { opacity: 0.88; }
button[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; }

.status-bar {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  padding: 8px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); }
.status-dot.loading { background: #f59e0b; animation: pulse 1s infinite; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 24px; right: 24px;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 6px;
  color: #fff;
  background: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 999;
}

#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { background: var(--success); }
#toast.error { background: #dc2626; }

/* ── Chips de mes ── */
.mes-chips { display: flex; gap: 6px; }

.mes-chip {
  font-family: var(--mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.mes-chip:hover { border-color: var(--accent); color: var(--accent); }
.mes-chip.disabled, .mes-chip:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.mes-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Responsive móvil ── */
@media (max-width: 480px) {
  header { padding: 0 16px; }

  main { padding: 16px 12px; }

  .card { border-radius: 6px; }

  form { padding: 18px 16px; gap: 14px; }

  .card-header,
  .card-footer,
  .status-bar { padding-left: 16px; padding-right: 16px; }

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

  .card-footer { flex-direction: column; align-items: stretch; gap: 10px; }

  button[type="submit"] { width: 100%; justify-content: center; }

  .picker-panel { max-height: 80vh; }

  .modal-footer { flex-direction: column-reverse; }

  .btn-primary,
  .btn-secondary { width: 100%; text-align: center; height: 44px; }
}

/* ── Dashboard ── */
.dash-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 32px 24px;
  width: 100%;
}

.dash-top {
  width: 100%;
  max-width: 1200px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.dash-tabs { display: flex; gap: 6px; }

.dash-tab {
  padding: 8px 18px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
}

.dash-tab:hover { border-color: var(--accent); color: var(--accent); }
.dash-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.dash-section { width: 100%; max-width: 1200px; display: flex; flex-direction: column; gap: 16px; }
.dash-section .card { max-width: 100%; }

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat-row-3 { grid-template-columns: repeat(3, 1fr); }
.stat-row-5 { grid-template-columns: repeat(5, 1fr); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
}

.stat-label { font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-family: var(--mono); font-size: 26px; font-weight: 500; margin-top: 6px; }
.stat-value.accent { color: var(--accent); }
.stat-value.teal   { color: var(--teal); }

.stat-card.teal-card { border-color: var(--teal); background: var(--teal-light); }

.progress-bar-wrap { width: 100%; max-width: 960px; }
.progress-bar-track { width: 100%; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.4s ease; width: 0%; }
.progress-bar-fill.over { background: #dc2626; }

.badge.teal { background: var(--teal-light); border-color: var(--teal); color: #00a898; }

.semaforo { font-size: 16px; }

/* ── Mini progress bar en tabla ── */
.mini-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 100px;
}

.mini-bar-track {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.mini-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.mini-bar-fill.pendiente   { background: #d1d5db; }
.mini-bar-fill.progreso    { background: var(--teal); }
.mini-bar-fill.completado  { background: var(--teal); }
.mini-bar-fill.advertencia { background: #f59e0b; }
.mini-bar-fill.excedido    { background: #f87171; }

.mini-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.mini-label.pendiente   { color: #9ca3af; }
.mini-label.progreso    { color: var(--teal); }
.mini-label.completado  { color: var(--teal); }
.mini-label.advertencia { color: #d97706; }
.mini-label.excedido    { color: #ef4444; }

/* Filas alternas (zebra) suave sobre fondo blanco */
#horas-body tr:nth-child(even),
#mensual-body tr:nth-child(even) { background: #f0faf9; }
#horas-body tr:hover,
#mensual-body tr:hover { background: #e6f7f5; }

/* La fila excedida mantiene prioridad */
#horas-body tr.fila-excedida { background: #fff8f8; }
#horas-body tr.fila-excedida:hover { background: #fee2e2; }

/* Control presupuestal */
#control-body tr.fila-advertencia { background: #fffbeb; }
#control-body tr.fila-advertencia:hover { background: #fef3c7; }
#control-body tr.fila-excedida { background: #fff8f8; }
#control-body tr.fila-excedida:hover { background: #fee2e2; }

.obs-chip {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  border-radius: 4px;
  padding: 1px 5px;
  margin: 1px 2px;
}
.obs-exc { color: #dc2626; background: #fef2f2; border: 1px solid #fecaca; }
.obs-sin { color: #d97706; background: #fffbeb; border: 1px solid #fde68a; }

/* Separador entre actividades asignadas y no asignadas */
#horas-body tr.fila-separador td {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9ca3af;
  background: #f9fafb;
  border-top: 2px solid #e5e7eb;
  border-bottom: 1px solid #e5e7eb;
}

/* Día: mostrar solo número en desktop, solo texto completo en móvil */
.dia-full { display: none; }
.dia-num  { display: inline; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { text-align: left; font-size: 11px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 10px 14px; border-bottom: 1px solid var(--border); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
tr:last-child td { border-bottom: none; }

@media (max-width: 600px) {
  header { padding: 0 16px; }
  .logo { font-size: 12px; }
  .dash-main { padding: 20px 14px; }
  .stat-row,
  .stat-row-3 { grid-template-columns: repeat(2, 1fr); gap: 10px; }

  /* Día completo en móvil */
  .dia-num  { display: none; }
  .dia-full { display: inline; font-weight: 600; color: var(--accent); font-size: 14px; }

  /* Columna Código: ocultar en móvil (la descripción ya lo identifica) */
  .cod-col { display: none; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 22px; }
  .dash-top { flex-direction: column; align-items: stretch; }
  .dash-tabs { justify-content: stretch; }
  .dash-tab { flex: 1; text-align: center; padding: 10px 12px; }

  /* ── Tablas → tarjetas apiladas ── */
  .card > div[style*="overflow-x"] { overflow-x: visible; }

  table thead { display: none; }

  table tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 4px 14px;
    margin-bottom: 12px;
  }
  table tbody tr:last-child { margin-bottom: 0; }

  table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 14px;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    text-align: right;
  }
  table tbody tr td:last-child { border-bottom: none; }

  table tbody td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: left;
    flex-shrink: 0;
  }

  /* Celda título: ocupa todo el ancho, sin etiqueta */
  table tbody td.celda-titulo {
    display: block;
    text-align: left;
    padding: 10px 0 8px;
    border-bottom: 2px solid var(--border);
    font-size: 14px;
  }
  table tbody td.celda-titulo::before { content: none; }

  /* Barra de progreso alineada a la derecha dentro de la tarjeta */
  table tbody td .mini-progress { min-width: 130px; align-items: flex-end; }

  /* Filas vacías / mensajes con colspan */
  table tbody td[colspan] { display: block; text-align: center; }
  table tbody td[colspan]::before { content: none; }
}

/* ── Actividad trigger (looks like a select) ── */
.select-trigger {
  width: 100%;
  height: 42px;
  padding: 0 32px 0 12px;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  user-select: none;
}

.select-trigger:hover,
.select-trigger:focus { border-color: var(--border-focus); }

.select-trigger.filled { color: var(--text); background-color: #FEF8F5; border-color: #f9bfaa; }
.select-trigger:not(.filled) { color: var(--text-muted); }

.select-trigger svg { flex-shrink: 0; }

/* ── Picker overlay (full screen backdrop) ── */
.picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.picker-overlay[hidden] { display: none; }

.picker-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 620px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.picker-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.picker-header input { display: none; }

.picker-close {
  width: 34px;
  height: 34px;
  border: none;
  background: var(--bg);
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.picker-close:hover { background: var(--border); }

.picker-list {
  list-style: none;
  overflow-y: auto;
  padding: 6px 0;
}

.picker-list li {
  padding: 14px 20px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.1s;
}

.picker-list li:hover { background: var(--bg); }
.picker-list li.selected { background: var(--accent-light); color: var(--accent); font-weight: 500; }

/* ── Modal de confirmación ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
}

.modal-header {
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 18px; font-weight: 600; }

.modal-body { padding: 22px 28px; display: flex; flex-direction: column; gap: 14px; }

.conf-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.conf-actividad-row { align-items: flex-start; }
.conf-actividad-row .conf-value { text-align: right; max-width: 70%; }

.conf-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.conf-value { font-size: 17px; font-weight: 500; }

#conf-nombre {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 10px;
  border-radius: 5px;
  box-shadow: 0 1px 4px rgba(249,112,72,0.2);
}

.modal-footer {
  padding: 18px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.btn-secondary {
  height: 44px;
  padding: 0 22px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover { background: var(--border); }

.btn-eliminar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-eliminar:hover { background: #fee2e2; border-color: #ef4444; }
.btn-eliminar:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  height: 44px;
  padding: 0 26px;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Resumen de equipo ── */
.equipo-resumen {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 8px 4px;
  margin-left: 1.5rem;
  margin-right: 1.5rem;
}

.equipo-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px 28px;
  flex: 1;
}

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

.eq-stat-num {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 500;
  line-height: 1;
}

.eq-stat-lbl {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.equipo-donut {
  position: relative;
  width: 170px;
  height: 170px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .equipo-resumen { flex-direction: column; gap: 24px; }
  .equipo-donut { width: 150px; height: 150px; }
  .eq-stat-num { font-size: 26px; }
}

/* ── Indicador de conexión (footer) ── */
.conn-status {
  position: fixed;
  bottom: 14px;
  right: 14px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
  transition: opacity 0.3s;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.conn-status.loading { color: var(--text-muted); }
.conn-status.loading .conn-dot { background: #f59e0b; animation: conn-pulse 1s ease-in-out infinite; }

.conn-status.ok { color: #00a898; }
.conn-status.ok .conn-dot { background: var(--teal); }

.conn-status.error { color: #dc2626; }
.conn-status.error .conn-dot { background: #dc2626; }

@keyframes conn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@media (max-width: 600px) {
  .conn-status { bottom: 10px; right: 10px; left: 10px; justify-content: center; }
}

/* ── Matriz de participación del equipo ── */
.matriz-wrap { overflow-x: auto; padding: 0 4px 16px; }

.matriz-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.matriz-table thead tr {
  background: var(--bg);
}

.matriz-table th {
  padding: 10px 8px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.matriz-table th.matriz-nombre { text-align: left; padding-left: 20px; min-width: 170px; }
.matriz-table th.matriz-sec    { min-width: 48px; cursor: default; }
.matriz-table th.matriz-total  { color: var(--text); min-width: 56px; }

/* Celdas */
.matriz-nombre-cel {
  padding: 9px 10px 9px 20px;
  font-weight: 500;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.matriz-cel {
  padding: 8px 6px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  border-radius: 4px;
}

.matriz-cel-total {
  padding: 9px 12px;
  text-align: center;
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

/* Fila alterna */
.fila-par .matriz-nombre-cel,
.fila-par .matriz-cel,
.fila-par .matriz-cel-total { background-color: #fafafa; }

/* Intensidad por días (debe ir después de "Fila alterna" para ganarle en especificidad) */
.matriz-cel.cel-bajo   { background: #E6FAF8; color: #00857a; }
.matriz-cel.cel-medio  { background: #BDEEF8; color: #00657a; }
.matriz-cel.cel-alto   { background: #F97048; color: #fff; }

/* Fila de totales */
.fila-totales .matriz-nombre-cel {
  font-weight: 700;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg);
  border-top: 2px solid var(--border);
}
.fila-totales .matriz-cel { background: var(--bg); border-top: 2px solid var(--border); }
.fila-totales .matriz-cel-footer { background: var(--bg); border-top: 2px solid var(--border); color: var(--teal); }

/* Leyenda */
.matriz-leyenda {
  display: flex;
  gap: 20px;
  padding: 14px 20px 4px;
  font-size: 12px;
  color: var(--text-muted);
}
.ley-item { display: flex; align-items: center; gap: 6px; }
.ley-dot {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  display: inline-block;
}
.ley-dot.cel-bajo   { background: #E6FAF8; border: 1px solid #00C9B1; }
.ley-dot.cel-medio  { background: #BDEEF8; border: 1px solid #0097b2; }
.ley-dot.cel-alto   { background: #F97048; border: none; }

@media (max-width: 600px) {
  .matriz-table th.matriz-sec { min-width: 38px; font-size: 10px; }
  .matriz-nombre-cel { font-size: 12px; min-width: 120px; }
  .matriz-leyenda { flex-wrap: wrap; gap: 12px; }
}

/* ── Pantalla PIN ── */
.pin-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.pin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.pin-logo {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  letter-spacing: 0.03em;
}

.pin-title {
  font-size: 17px;
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.pin-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.pin-container {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 1.75rem 0 0.75rem;
}

.pin-input {
  width: 52px;
  height: 60px;
  text-align: center;
  font-size: 22px;
  font-family: var(--mono);
  font-weight: 500;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  -webkit-text-security: disc;
}

.pin-input:focus { border-color: var(--accent); }
.pin-input.filled { border-color: var(--teal); background: var(--teal-light); }

.pin-error {
  color: #dc2626;
  font-size: 13px;
  min-height: 18px;
  margin-top: 0.25rem;
}

.pin-attempts {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 0.2rem;
  min-height: 16px;
}

.pin-blocked-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 1.25rem;
  margin-top: 1.5rem;
}

.pin-loading {
  padding: 1.5rem 0;
  color: var(--text-muted);
  font-size: 14px;
}

@media (max-width: 400px) {
  .pin-input { width: 44px; height: 52px; font-size: 18px; }
  .pin-container { gap: 7px; }
}

/* ══════════════════════════════════════════════
   RESPONSIVE — TABLET  (max 900px)
   ══════════════════════════════════════════════ */
@media (max-width: 900px) {
  .stat-row-5 { grid-template-columns: repeat(3, 1fr); }
  .dash-main { padding: 24px 18px; }
}

/* ══════════════════════════════════════════════
   RESPONSIVE — TABLET  (max 768px)
   ══════════════════════════════════════════════ */
@media (max-width: 768px) {
  header { padding: 0 16px; height: 56px; }
  .logo-img { height: 34px; }
  nav a { padding: 5px 9px; font-size: 12px; }

  main { padding: 20px 14px; align-items: flex-start; }
  .card { max-width: 100%; border-radius: 8px; }
  form { padding: 20px 18px; gap: 16px; }
  .card-header, .card-footer, .status-bar { padding-left: 18px; padding-right: 18px; }

  .dash-main { padding: 20px 14px; gap: 16px; }
  .dash-top { flex-direction: column; align-items: stretch; gap: 12px; }
  .dash-tabs { justify-content: stretch; }
  .dash-tab { flex: 1; text-align: center; font-size: 13px; padding: 9px 10px; }
  .stat-row, .stat-row-3 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-row-5 { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 10px; }

  .picker-overlay { padding: 16px 12px; }
  .picker-panel { max-height: 80vh; }
  .modal-overlay { padding: 16px 12px; }
  .modal { border-radius: 10px; }
  .modal-header { padding: 18px 20px; }
  .modal-body { padding: 18px 20px; }
  .modal-footer { padding: 14px 20px; }

  .equipo-resumen { margin-left: 1rem; margin-right: 1rem; gap: 20px; }
}

/* ══════════════════════════════════════════════
   RESPONSIVE — MÓVIL  (max 600px) — refuerza reglas existentes
   ══════════════════════════════════════════════ */
@media (max-width: 600px) {
  .stat-row-5 { grid-template-columns: repeat(2, 1fr); }
  .mes-chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .mes-chip { flex-shrink: 0; }

  /* Sub-tabs de Equipo: labels largos, mejor scroll horizontal que estirado */
  #equipo-subtabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  #equipo-subtabs .dash-tab { flex: none; white-space: nowrap; }
}

/* ══════════════════════════════════════════════
   RESPONSIVE — MÓVIL PEQUEÑO  (max 480px)
   ══════════════════════════════════════════════ */
@media (max-width: 480px) {
  header { height: 52px; }
  .logo-img { height: 30px; }
  nav { gap: 2px; }
  nav a { font-size: 11px; padding: 5px 8px; }

  main { padding: 12px 8px; }
  .card { border-radius: 6px; box-shadow: 0 2px 10px rgba(0,0,0,0.12); }
  form { padding: 16px 14px; gap: 14px; }
  .card-header { padding: 14px 16px; }
  .card-footer { padding: 12px 16px; flex-direction: column; align-items: stretch; gap: 10px; }
  .card-title { font-size: 15px; }
  .field-row { grid-template-columns: 1fr; }
  button[type="submit"] { width: 100%; height: 44px; }
  .hint { font-size: 12px; }
  .status-bar { padding: 8px 16px; font-size: 11px; }

  .select-trigger { font-size: 14px; }

  /* Picker: centrado en pantalla */
  .picker-overlay { padding: 12px; align-items: center; justify-content: center; }
  .picker-panel { max-height: 86vh; border-radius: 12px; width: calc(100vw - 24px); }
  .picker-list li { padding: 13px 16px; font-size: 14px; }

  /* Modal confirmación: centrado en pantalla */
  .modal-overlay { padding: 12px; align-items: center; justify-content: center; }
  .modal { border-radius: 12px; width: calc(100vw - 24px); max-width: 100%; }
  .modal-header { padding: 16px 18px; }
  .modal-body { padding: 16px 18px; gap: 12px; }
  .modal-footer { padding: 12px 18px; flex-direction: column-reverse; gap: 10px; }
  .btn-primary, .btn-secondary { width: 100%; text-align: center; height: 48px; justify-content: center; }
  .conf-value { font-size: 15px; }
  .modal-title { font-size: 16px; }

  .dash-main { padding: 14px 10px; gap: 14px; }
  .stat-row, .stat-row-3, .stat-row-5 { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 12px 14px; }
  .stat-value { font-size: 20px; }

  .equipo-resumen { flex-direction: column; gap: 20px; margin: 0 0.75rem; }
  .equipo-stats { gap: 14px 20px; }
  .eq-stat-num { font-size: 24px; }
  .equipo-donut { width: 140px; height: 140px; }

  /* Toast centrado en pantalla */
  #toast {
    bottom: auto; top: 50%; left: 50%;
    transform: translateX(-50%) translateY(calc(-50% + 8px));
    right: auto;
    width: max-content; max-width: calc(100vw - 32px);
    text-align: center;
  }
  #toast.show { transform: translateX(-50%) translateY(-50%); }

  .conn-status { bottom: 8px; right: 8px; left: 8px; font-size: 11px; padding: 6px 12px; }

  table tbody td { padding: 8px 0; font-size: 13px; }
  table tbody td::before { font-size: 10px; }
  .mini-progress { min-width: 110px; }
  .mini-label { font-size: 10px; }
  .mini-bar-track { height: 5px; }

  .matriz-table th { font-size: 9px; padding: 8px 4px; }
  .matriz-nombre-cel { font-size: 11px; padding-left: 10px; min-width: 100px; }
  .matriz-cel, .matriz-cel-total { font-size: 11px; padding: 6px 3px; }
  .matriz-leyenda { padding: 10px 12px 4px; font-size: 11px; }

  .pin-card { padding: 2rem 1.25rem; border-radius: 12px; }
}
