:root {
  --navy: #0f2342;
  --navy2: #1b3a6b;
  --accent: #c8a96e;
  --accent2: #e8c98a;
  --light: #f5f3ee;
  --white: #ffffff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e2ddd6;
  --ok: #1e8a5a;
  --warn: #c98a12;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(15, 35, 66, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--light);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--navy2); }
img, svg { max-width: 100%; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 1.25rem; }
[hidden] { display: none !important; }

/* Cabecera de cada demo */
.demo-top {
  background: linear-gradient(135deg, var(--c1, var(--navy)), var(--c2, var(--navy2)));
  color: #fff;
  padding: 1.1rem 0 1.4rem;
  position: relative;
  overflow: hidden;
}
.demo-top::after {
  content: ''; position: absolute; right: -80px; top: -80px;
  width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}
.demo-top-in { position: relative; z-index: 1; display: grid; gap: 0.8rem; }
.volver {
  color: rgba(255, 255, 255, 0.85); text-decoration: none; font-size: 0.85rem; font-weight: 600;
  width: fit-content; padding: 0.3rem 0.8rem; border-radius: 100px; background: rgba(255, 255, 255, 0.12);
  transition: background 0.2s;
}
.volver:hover { background: rgba(255, 255, 255, 0.24); color: #fff; }
.demo-tit { display: flex; gap: 1rem; align-items: center; }
.demo-ico {
  font-size: 2rem; width: 58px; height: 58px; flex-shrink: 0; border-radius: 16px;
  display: grid; place-items: center; background: rgba(255, 255, 255, 0.14);
}
.demo-tit h1 { font-family: 'Playfair Display', serif; font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.15; }
.demo-tit p { opacity: 0.85; font-size: 0.92rem; max-width: 760px; }
.demo-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.demo-tags span {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; padding: 0.22rem 0.65rem;
  border-radius: 100px; background: rgba(255, 255, 255, 0.16); border: 1px solid rgba(255, 255, 255, 0.22);
}

.demo-tags .vistas { display: inline-flex; align-items: center; gap: 0.3rem; background: rgba(0, 0, 0, 0.18); border-color: transparent; margin-left: auto; }

.demo-main { flex: 1; padding-top: 1.6rem; padding-bottom: 2.5rem; }
.demo-pie { text-align: center; padding: 1.4rem 0; font-size: 0.85rem; color: var(--muted); border-top: 1px solid var(--border); background: #fff; }
.demo-pie a { color: var(--navy2); font-weight: 600; text-decoration: none; }
.demo-pie a:hover { text-decoration: underline; }

/* Bloques */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; border: 1px solid rgba(226, 221, 214, 0.6); }
.card h2, .card h3 { font-family: 'Playfair Display', serif; color: var(--navy); }
.card h2 { font-size: 1.25rem; margin-bottom: 0.8rem; }
.card h3 { font-size: 1.05rem; margin-bottom: 0.6rem; }
.grid { display: grid; gap: 1.1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fila { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.entre { justify-content: space-between; }
.mt { margin-top: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.nota {
  font-size: 0.82rem; color: var(--navy2); background: #edf2fb; border-left: 3px solid var(--navy2);
  padding: 0.6rem 0.85rem; border-radius: 8px;
}

/* Indicadores */
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.15rem; border-top: 3px solid var(--accent); }
.kpi small { display: block; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.kpi strong { display: block; font-size: 1.55rem; color: var(--navy); font-weight: 700; line-height: 1.25; margin-top: 0.15rem; }
.kpi span { font-size: 0.78rem; color: var(--muted); }
.kpi.ok { border-top-color: var(--ok); }
.kpi.warn { border-top-color: var(--warn); }
.kpi.danger { border-top-color: var(--danger); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: 600 0.86rem 'DM Sans', sans-serif; padding: 0.6rem 1.05rem; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer; text-decoration: none;
  background: var(--navy); color: #fff; transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}
.btn:hover { background: var(--navy2); box-shadow: 0 4px 14px rgba(15, 35, 66, 0.2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn-accent { background: var(--accent); color: var(--navy); }
.btn-accent:hover { background: var(--accent2); }
.btn-light { background: #fff; color: var(--navy); border-color: var(--border); }
.btn-light:hover { background: var(--light); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a93226; }
.btn-ok { background: var(--ok); }
.btn-ok:hover { background: #17724a; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.78rem; border-radius: 8px; }
.btn-icon { padding: 0.35rem 0.55rem; }
.btn-block { width: 100%; }

/* Formularios */
.campo { display: grid; gap: 0.3rem; }
.campo label, .etq { font-size: 0.78rem; font-weight: 600; color: var(--navy); }
input, select, textarea {
  font: 400 0.9rem 'DM Sans', sans-serif; color: var(--text);
  padding: 0.6rem 0.75rem; border: 1px solid var(--border); border-radius: 10px; background: #fff; width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy2); box-shadow: 0 0 0 3px rgba(27, 58, 107, 0.12); }
input[type="checkbox"], input[type="radio"], input[type="color"] { width: auto; }
textarea { resize: vertical; min-height: 80px; }
.error-campo { color: var(--danger); font-size: 0.76rem; }

/* Tablas */
.tabla-wrap { overflow-x: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
.tabla th {
  text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
  padding: 0.65rem 0.75rem; border-bottom: 2px solid var(--border); white-space: nowrap;
}
.tabla td { padding: 0.65rem 0.75rem; border-bottom: 1px solid #f0ece6; vertical-align: middle; }
.tabla tbody tr:hover { background: #faf8f4; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }
.vacio { text-align: center; color: var(--muted); padding: 2rem 1rem !important; }

/* Etiquetas */
.badge { display: inline-block; font-size: 0.72rem; font-weight: 700; padding: 0.18rem 0.6rem; border-radius: 100px; background: #edf2fb; color: var(--navy2); white-space: nowrap; }
.badge.ok { background: #e3f4ec; color: var(--ok); }
.badge.warn { background: #fdf2dc; color: #9a6a0c; }
.badge.danger { background: #fbe5e2; color: var(--danger); }
.badge.gold { background: #f6ecd8; color: #7a5c1e; }

/* Chips de filtro */
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  font: 600 0.8rem 'DM Sans', sans-serif; padding: 0.4rem 0.9rem; border-radius: 100px; cursor: pointer;
  border: 1px solid var(--border); background: #fff; color: var(--navy); transition: all 0.2s;
}
.chip:hover { border-color: var(--navy2); }
.chip.activo { background: var(--navy); border-color: var(--navy); color: #fff; }

/* Ventana modal */
.modal {
  position: fixed; inset: 0; z-index: 1000; background: rgba(15, 35, 66, 0.55);
  display: grid; place-items: center; padding: 1rem; animation: aparecer 0.2s ease;
}
.modal-box {
  background: #fff; border-radius: 18px; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
  padding: 1.4rem; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3); animation: subir 0.25s ease;
}
.modal-box h2 { font-family: 'Playfair Display', serif; color: var(--navy); font-size: 1.3rem; margin-bottom: 1rem; }
.modal-acciones { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.2rem; flex-wrap: wrap; }

/* Aviso flotante */
#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 20px); z-index: 2000; opacity: 0; pointer-events: none;
  background: var(--navy); color: #fff; padding: 0.7rem 1.2rem; border-radius: 12px; font-size: 0.88rem; font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25); transition: transform 0.3s ease, opacity 0.3s ease; max-width: calc(100% - 2rem); text-align: center;
}
#toast.visible { transform: translate(-50%, 0); opacity: 1; }
#toast.ok { background: var(--ok); }
#toast.error { background: var(--danger); }

/* Gráfico de dona */
.dona { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.dona svg { width: 180px; height: 180px; flex-shrink: 0; }
.dona svg circle { transition: stroke-width 0.2s; }
.dona svg circle:hover { stroke-width: 34; }
.leyenda { display: grid; gap: 0.35rem; font-size: 0.82rem; min-width: 160px; }
.leyenda div { display: flex; align-items: center; gap: 0.5rem; }
.leyenda i { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.leyenda b { margin-left: auto; font-variant-numeric: tabular-nums; }

.cargando { display: inline-block; width: 18px; height: 18px; border: 2px solid rgba(15, 35, 66, 0.2); border-top-color: var(--navy); border-radius: 50%; animation: girar 0.7s linear infinite; }

@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }
@keyframes subir { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes girar { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .demo-ico { width: 48px; height: 48px; font-size: 1.6rem; }
  .card { padding: 1rem; }
}
