/**
 * Tablero de hábitos con mapa de calor y matriz de enfoque
 * Hoja de estilos principal con diseño adaptativo, tema claro/oscuro
 * y componentes ergonómicos de alta productividad.
 */

:root {
  --bg-app: #0d1117;
  --bg-card: #161b22;
  --bg-card-hover: #1c2128;
  --bg-surface: #21262d;
  --border-subtle: #30363d;
  --border-focus: #58a6ff;
  --text-main: #f0f6fc;
  --text-muted: #8b949e;
  --accent-green: #238636;
  --accent-green-bright: #39d353;
  --accent-blue: #388bfd;
  --accent-purple: #8957e5;
  --accent-orange: #d29922;
  --accent-red: #f85149;
  --accent-cyan: #39c5bb;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238b949e' 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");
}

[data-theme="light"] {
  --bg-app: #f6f8fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f3f4f6;
  --bg-surface: #eaeef2;
  --border-subtle: #d0d7de;
  --border-focus: #0969da;
  --text-main: #1f2328;
  --text-muted: #656d76;
  --accent-green: #1a7f37;
  --accent-green-bright: #2da44e;
  --accent-blue: #0969da;
  --accent-purple: #8250df;
  --accent-orange: #bf8700;
  --accent-red: #cf222e;
  --accent-cyan: #059669;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23656d76' 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");
}

/* Reset y base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.25;
}

.mono-num {
  font-family: 'JetBrains Mono', monospace;
  font-feature-settings: 'tnum' 1;
}

/* Layout de la herramienta */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Barra lateral de publicidad (Desktop >= 1536px) */
.tool-ad-sidebar {
  width: 300px;
  flex-shrink: 0;
}

.ad-sticky-box {
  position: sticky;
  top: 80px;
}

/* 1. SECCIÓN DE MÉTRICAS (GRID) */
.metricas-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.metrica-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.metrica-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
}

.metrica-icono {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metrica-icono.fuego {
  background: rgba(248, 81, 73, 0.15);
  color: var(--accent-red);
}

.metrica-icono.trofeo {
  background: rgba(210, 153, 34, 0.15);
  color: var(--accent-orange);
}

.metrica-icono.diana {
  background: rgba(35, 134, 54, 0.15);
  color: var(--accent-green-bright);
}

.metrica-icono.calendario {
  background: rgba(56, 139, 253, 0.15);
  color: var(--accent-blue);
}

.metrica-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.metrica-etiqueta {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: none;
}

.metrica-valor {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
}

/* 2. PANEL DIVIDIDO: CHECK-IN Y MAPA DE CALOR */
.panel-habitos-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 1.5rem;
}

.card-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  gap: 0.75rem;
}

.panel-titulo-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-titulo {
  font-size: 1.15rem;
  font-weight: 700;
}

/* Controles de fecha en Check-in */
.checkin-date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.6rem;
  margin-bottom: 1rem;
}

.nav-dias-botones {
  display: flex;
  gap: 0.25rem;
}

.btn-fecha-quick {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: 28px;
  transition: all 0.15s ease;
}

.btn-fecha-quick:hover {
  background: var(--border-subtle);
}

.btn-fecha-nav {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-fecha-nav:hover {
  color: var(--text-main);
  background: var(--border-subtle);
}

.input-fecha-selector {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  padding: 0.2rem 0.4rem;
  cursor: pointer;
  outline: none;
}

/* Barra de progreso diario */
.checkin-progreso-box {
  margin-bottom: 1.25rem;
}

.checkin-progreso-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.progreso-track {
  width: 100%;
  height: 8px;
  background: var(--bg-surface);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.progreso-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981, #39d353);
  border-radius: 4px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Lista de hábitos en Check-in */
.checkin-lista {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
  max-height: 440px;
  padding-right: 0.25rem;
}

.checkin-habito-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.75rem;
  transition: all 0.2s ease;
}

.checkin-habito-item:hover {
  border-color: var(--habito-color, var(--border-focus));
  background: var(--bg-card-hover);
}

.checkin-habito-item.completado {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.4);
}

.btn-check-habito {
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  text-align: left;
  flex: 1;
  min-width: 0;
  min-height: 40px;
}

.check-box-circulo {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: transparent;
  transition: all 0.2s ease;
}

.check-box-circulo.activo {
  background-color: var(--habito-color, #10b981);
  border-color: var(--habito-color, #10b981);
  color: #ffffff;
  transform: scale(1.05);
}

.habito-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex: 1;
}

.habito-icono-box {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.habito-textos {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.habito-nombre {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.habito-cat-badge {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.habito-acciones-menu {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.btn-habito-editar,
.btn-habito-eliminar {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-habito-editar:hover {
  color: var(--accent-blue);
  background: var(--bg-card);
}

.btn-habito-eliminar:hover {
  color: var(--accent-red);
  background: var(--bg-card);
}

/* 3. SECCIÓN MAPA DE CALOR ESTILO GITHUB */
.heatmap-controles {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.select-heatmap {
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.4rem 2.25rem 0.4rem 0.75rem;
  font-size: 0.825rem;
  height: 38px;
  min-width: 140px;
  max-width: 100%;
  appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 14px;
  cursor: pointer;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}

.select-heatmap option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.heatmap-canvas-container {
  width: 100%;
  overflow-x: auto;
  padding: 0.75rem 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.heatmap-canvas-container::-webkit-scrollbar {
  height: 6px;
}

.heatmap-canvas-container::-webkit-scrollbar-thumb {
  background-color: var(--border-subtle);
  border-radius: 3px;
}

#heatmap-canvas {
  display: block;
  cursor: pointer;
}

/* Leyenda del Heatmap */
.heatmap-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.heatmap-leyenda {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.leyenda-bloque {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  display: inline-block;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .leyenda-bloque {
  border: 1px solid rgba(27, 31, 35, 0.06);
}

.lvl-0 { background: #161b22; }
.lvl-1 { background: #0e4429; }
.lvl-2 { background: #006d32; }
.lvl-3 { background: #26a641; }
.lvl-4 { background: #39d353; }

[data-theme="light"] .lvl-0 { background: #ebedf0; }
[data-theme="light"] .lvl-1 { background: #9be9a8; }
[data-theme="light"] .lvl-2 { background: #40c463; }
[data-theme="light"] .lvl-3 { background: #30a14e; }
[data-theme="light"] .lvl-4 { background: #216e39; }

/* Tooltip interactivo flotante */
.heatmap-tooltip {
  position: fixed;
  z-index: 1000;
  background: rgba(13, 17, 23, 0.95);
  backdrop-filter: blur(8px);
  color: #f0f6fc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  box-shadow: var(--shadow-md);
  max-width: 280px;
}

[data-theme="light"] .heatmap-tooltip {
  background: rgba(255, 255, 255, 0.96);
  color: #1f2328;
  border-color: #d0d7de;
}

.heatmap-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.tooltip-fecha {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.tooltip-detalle {
  color: var(--text-muted);
}

/* 4. SECCIÓN MATRIZ DE EISENHOWER */
.matriz-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.matriz-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.matriz-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.matriz-cuadrante {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.matriz-cuadrante.q1 { border-top: 4px solid var(--accent-red); }
.matriz-cuadrante.q2 { border-top: 4px solid var(--accent-blue); }
.matriz-cuadrante.q3 { border-top: 4px solid var(--accent-orange); }
.matriz-cuadrante.q4 { border-top: 4px solid var(--accent-purple); }

.cuadrante-top {
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.cuadrante-tag {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.cuadrante-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.q1 .cuadrante-badge { background: rgba(248, 81, 73, 0.2); color: var(--accent-red); }
.q2 .cuadrante-badge { background: rgba(56, 139, 253, 0.2); color: var(--accent-blue); }
.q3 .cuadrante-badge { background: rgba(210, 153, 34, 0.2); color: var(--accent-orange); }
.q4 .cuadrante-badge { background: rgba(137, 87, 229, 0.2); color: var(--accent-purple); }

.cuadrante-titulo {
  font-size: 0.95rem;
  font-weight: 700;
}

.matriz-badge-count {
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  color: var(--text-muted);
}

/* Input rápido de tarea dentro del cuadrante */
.input-tarea-rapida-box {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-card);
  padding: 0.4rem 0.75rem;
  gap: 0.5rem;
}

.input-tarea-rapida {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.85rem;
  height: 38px;
  outline: none;
}

.input-tarea-rapida::placeholder {
  color: var(--text-muted);
}

.btn-add-tarea-rapida {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-add-tarea-rapida:hover {
  color: var(--accent-green-bright);
  background: var(--bg-surface);
}

/* Cuerpo del cuadrante (zona de drop) */
.matriz-cuadrante-body {
  padding: 0.75rem;
  min-height: 180px;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: background-color 0.2s ease;
}

.matriz-cuadrante-body.drag-over {
  background-color: rgba(56, 139, 253, 0.08);
  border: 2px dashed var(--accent-blue);
}

.cuadrante-vacio {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 120px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

/* Tarjeta de Tarea */
.tarea-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: grab;
  transition: all 0.15s ease;
}

.tarea-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.tarea-card.dragging {
  opacity: 0.4;
  cursor: grabbing;
}

.tarea-card.completada {
  opacity: 0.6;
  background: var(--bg-card);
}

.tarea-card.completada .tarea-texto {
  text-decoration: line-through;
  color: var(--text-muted);
}

.tarea-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  display: flex;
  align-items: center;
}

.tarea-checkbox-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.tarea-checkbox {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.tarea-custom-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.tarea-checkbox:checked ~ .tarea-custom-check {
  background: var(--accent-green-bright);
  border-color: var(--accent-green-bright);
}

.tarea-checkbox:checked ~ .tarea-custom-check::after {
  content: '';
  width: 4px;
  height: 8px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}

.tarea-texto {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tarea-acciones {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.btn-tarea-accion {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-tarea-accion:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

/* 5. BARRA INFERIOR DE ACCIONES Y UTILIDADES */
.barra-utilidades {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
  box-shadow: var(--shadow-sm);
}

.utilidades-grupo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Botones estándar */
.btn-principal {
  background-color: var(--accent-green);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  min-height: 40px;
  transition: all 0.15s ease;
}

.btn-principal:hover {
  background-color: var(--accent-green-bright);
}

.btn-secundario {
  background-color: var(--bg-surface);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  min-height: 40px;
  transition: all 0.15s ease;
}

.btn-secundario:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-focus);
}

.btn-peligro {
  background-color: transparent;
  color: var(--accent-red);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  min-height: 40px;
  transition: all 0.15s ease;
}

.btn-peligro:hover {
  background-color: rgba(248, 81, 73, 0.1);
  border-color: var(--accent-red);
}

/* 6. MODALES ACCESIBLES */
.modal-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal-container.activo {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-box {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.75rem;
}

.modal-header h3 {
  font-size: 1.2rem;
}

.btn-modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.btn-modal-close:hover {
  color: var(--text-main);
}

.form-grupo {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
}

.form-input {
  width: 100%;
  height: 42px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0 0.85rem;
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
}

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

/* Selector de iconos en el modal */
.iconos-selector-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.5rem;
}

.btn-icono-opcion {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icono-opcion:hover {
  color: var(--text-main);
  border-color: var(--border-focus);
}

.btn-icono-opcion.seleccionado {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--accent-green-bright);
  color: var(--accent-green-bright);
}

/* Selector de cuadrante móvil en modal */
.cuadrantes-selector-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
}

.btn-cuadrante-opcion {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 46px;
  transition: all 0.15s ease;
}

.btn-cuadrante-opcion:hover,
.btn-cuadrante-opcion.activo {
  border-color: var(--border-focus);
  background: var(--bg-card-hover);
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

/* Oculto / Utilitarios */
.oculto {
  display: none !important;
}

/* =========================================================================
   7. SECCIÓN DIDÁCTICA Y GUÍA SEO CANÓNICA
   ========================================================================= */

.seo-guide-section {
  margin-top: 2.5rem;
  margin-bottom: 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 3vw, 2.25rem);
  box-shadow: var(--shadow-sm);
  box-sizing: border-box;
  width: 100%;
}

.tool-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.tool-breadcrumbs a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.tool-breadcrumbs a:hover {
  color: var(--accent-blue);
}

.tool-breadcrumbs .separator {
  opacity: 0.5;
}

.tool-breadcrumbs .current {
  color: var(--text-main);
  font-weight: 600;
}

.seo-guide-header {
  margin-bottom: 1.75rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 1.25rem;
}

.seo-authority-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(57, 211, 83, 0.12);
  color: var(--accent-green-bright);
  border: 1px solid rgba(57, 211, 83, 0.25);
  font-size: 0.775rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  margin-bottom: 0.85rem;
}

[data-theme="light"] .seo-authority-badge {
  background: rgba(26, 127, 55, 0.1);
  color: var(--accent-green);
  border-color: rgba(26, 127, 55, 0.25);
}

.seo-guide-title {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.65rem;
  line-height: 1.3;
}

.seo-guide-subtitle {
  font-size: clamp(0.92rem, 1.5vw, 1rem);
  color: var(--text-muted);
  line-height: 1.65;
  max-width: 950px;
}

/* Cuadrícula didáctica de tarjetas */
.seo-guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.seo-guide-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.seo-guide-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-2px);
}

.guide-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(56, 139, 253, 0.12);
  border: 1px solid rgba(56, 139, 253, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  margin-bottom: 0.85rem;
  user-select: none;
  flex-shrink: 0;
}

.guide-card-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.65rem;
  line-height: 1.35;
}

.guide-card-text {
  font-size: 0.885rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 0.75rem;
}

.guide-card-text:last-of-type {
  margin-bottom: 0;
}

.guide-card-text strong {
  color: var(--text-main);
  font-weight: 600;
}

/* Tabla comparativa de cuadrantes */
.seo-table-section {
  margin-bottom: 2rem;
}

.seo-section-inner-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1rem;
}

.guide-table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  margin-bottom: 1rem;
  scrollbar-width: thin;
}

.guide-specs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.guide-specs-table th {
  background: var(--bg-card);
  color: var(--text-main);
  padding: 0.85rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.guide-specs-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-muted);
  line-height: 1.5;
  vertical-align: middle;
}

.guide-specs-table tr:last-child td {
  border-bottom: none;
}

.guide-specs-table tr:hover td {
  background: var(--bg-card-hover);
}

/* Acordeón interactivo FAQ */
.seo-faq-wrapper {
  margin-top: 2rem;
  border-top: 1px solid var(--border-subtle);
  padding-top: 1.75rem;
}

.seo-faq-section-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1.25rem;
}

.seo-faq-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.seo-faq-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.seo-faq-item[open] {
  border-color: var(--border-focus);
}

.seo-faq-question {
  padding: 1rem 1.25rem;
  font-family: 'Outfit', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  user-select: none;
  min-height: 44px;
  list-style: none;
}

.seo-faq-question::-webkit-details-marker {
  display: none;
}

.seo-faq-icon {
  color: var(--text-muted);
  transition: transform 0.25s ease, color 0.2s ease;
  flex-shrink: 0;
}

.seo-faq-item[open] .seo-faq-icon {
  transform: rotate(180deg);
  color: var(--accent-green-bright);
}

.seo-faq-answer {
  padding: 0 1.25rem 1.15rem 1.25rem;
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .seo-faq-answer {
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.seo-faq-answer p {
  margin-top: 0.65rem;
}

.seo-faq-answer p:first-child {
  margin-top: 0.5rem;
}

.seo-faq-answer strong {
  color: var(--text-main);
}

/* =========================================================================
   RESPONSIVIDAD Y OPTIMIZACIÓN MÓVIL
   ========================================================================= */

@media (max-width: 1024px) {
  .metricas-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

@media (max-width: 768px) {
  .tool-layout {
    margin: 1rem auto 2rem;
    padding: 0 0.75rem;
  }

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

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

  .barra-utilidades {
    flex-direction: column;
    align-items: stretch;
  }

  .utilidades-grupo {
    width: 100%;
    flex-direction: column;
  }

  .utilidades-grupo button {
    width: 100%;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions button {
    width: 100%;
  }

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

  .seo-guide-section {
    padding: 1.15rem;
  }

  .seo-faq-question {
    padding: 0.85rem 1rem;
    font-size: 0.92rem;
  }

  .seo-faq-answer {
    padding: 0 1rem 1rem 1rem;
    font-size: 0.875rem;
  }
}

