:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --high: #dc2626;
  --high-bg: #fef2f2;
  --medium: #d97706;
  --medium-bg: #fffbeb;
  --low: #2563eb;
  --low-bg: #eff6ff;
  --info: #475569;
  --info-bg: #f1f5f9;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px; }
.container.narrow { max-width: 760px; }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header .brand { font-weight: 700; font-size: 17px; color: var(--primary-dark); text-decoration: none; }
header nav a { color: var(--muted); text-decoration: none; margin-left: 18px; font-size: 14px; }
header nav a:hover { color: var(--primary); }

h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 18px; margin: 22px 0 10px; }
.subtitle { color: var(--muted); margin: 0 0 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 22px;
  box-shadow: var(--shadow);
}

label { display: block; font-weight: 600; margin: 12px 0 4px; font-size: 14px; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: white;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
textarea { min-height: 70px; resize: vertical; }
.help { color: var(--muted); font-size: 13px; margin-top: 4px; }

button, .btn {
  background: var(--primary);
  color: white;
  border: 0;
  padding: 10px 18px;
  border-radius: 6px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--primary-dark); }
button:disabled { background: #94a3b8; cursor: not-allowed; }
button.secondary, .btn.secondary { background: white; color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: #f1f5f9; }
button.ghost { background: transparent; color: var(--primary); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.spacer { flex: 1; }

/* Progreso */
.progress {
  display: flex;
  gap: 6px;
  margin: 18px 0 22px;
}
.progress .step {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
}
.progress .step.done { background: var(--primary); }
.progress .step.current { background: var(--primary-light); border: 1px solid var(--primary); }

/* Wizard de niveles */
.dim-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.dim-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  color: white;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.3px;
}
.dim-name { font-size: 18px; font-weight: 700; }
.dim-subtitle { color: var(--muted); margin: 0 0 16px; font-size: 14px; }

.levels { display: grid; gap: 8px; }
.level {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 14px;
  cursor: pointer;
  background: white;
  transition: all 0.12s ease;
}
.level:hover { border-color: var(--primary); background: #fafbff; }
.level.selected { border-color: var(--primary); background: var(--primary-light); }
.level .lvl-num {
  display: inline-block;
  width: 26px; height: 26px;
  line-height: 26px;
  text-align: center;
  border-radius: 50%;
  background: var(--info-bg);
  font-weight: 700;
  font-size: 13px;
  margin-right: 10px;
}
.level.selected .lvl-num { background: var(--primary); color: white; }
.level .lvl-title { font-weight: 600; display: inline-block; }
.level .lvl-desc { color: var(--muted); margin: 4px 0 0 36px; font-size: 13.5px; }

/* Resultados */
.results-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 800px) {
  .results-grid { grid-template-columns: 1fr; }
}

.dim-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.dim-row:last-child { border-bottom: 0; }
.dim-row .lvl-big { font-size: 20px; font-weight: 800; min-width: 30px; text-align: right; }
.dim-row .meta { flex: 1; }
.dim-row .meta .name { font-weight: 600; }
.dim-row .meta .ttl { color: var(--muted); font-size: 13.5px; }

/* Recomendaciones */
.rec {
  border-left: 4px solid var(--info);
  background: var(--info-bg);
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  margin: 8px 0;
}
.rec.high   { border-color: var(--high);   background: var(--high-bg); }
.rec.medium { border-color: var(--medium); background: var(--medium-bg); }
.rec.low    { border-color: var(--low);    background: var(--low-bg); }
.rec b { display: block; margin-bottom: 4px; }
.rec .sev {
  display: inline-block; font-size: 11px; padding: 1px 6px;
  border-radius: 3px; background: rgba(0,0,0,0.06); margin-right: 6px;
  text-transform: uppercase; letter-spacing: 0.5px;
  font-weight: 700;
}

/* Asesor IA */
#advice-out {
  background: #fafbff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  white-space: pre-wrap;
  min-height: 120px;
  font-size: 14px;
  line-height: 1.6;
}
#advice-out h2, #advice-out h3 { font-size: 15px; margin-top: 14px; margin-bottom: 6px; color: var(--primary-dark); }

.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #0f172a;
  color: white;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 0.95; }

.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--high); font-weight: 600; }
