:root {
  --bg: #f4efe5;
  --surface: #fffdf8;
  --surface-2: #f7f2e8;
  --ink: #26263a;
  --muted: #6b6b80;
  --line: #e2dccd;
  --accent: #35356b;
  --accent-ink: #ffffff;
  --gold: #a87a1e;
  --danger: #b3261e;
  --danger-bg: #fbeceb;
  --warn-bg: #fbf3df;
  --warn-line: #e6d3a1;
  --fire: #d4452a;
  --earth: #4a8647;
  --air: #bf8f12;
  --water: #2c6cb0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(38, 38, 58, .06), 0 8px 24px rgba(38, 38, 58, .06);
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --sym: 'Noto Sans Symbols 2', 'Segoe UI Symbol', 'Apple Symbols', 'DejaVu Sans', sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f19;
    --surface: #171726;
    --surface-2: #1e1e30;
    --ink: #ecebf5;
    --muted: #9d9db6;
    --line: #2c2c44;
    --accent: #b9b9ff;
    --accent-ink: #14142a;
    --gold: #e6b93c;
    --danger: #ff8a82;
    --danger-bg: #3a1e22;
    --warn-bg: #2f2915;
    --warn-line: #5b4d20;
    --fire: #ff7a5c;
    --earth: #7fc47a;
    --air: #e6b93c;
    --water: #6aa8ee;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -48px; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: 8px; z-index: 10; }
.skip:focus { top: 8px; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* Encabezado */
.top { border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; justify-content: space-between; padding-block: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 600 22px/1 var(--serif); letter-spacing: -.01em; }
.brand-mark { font-family: var(--sym); font-size: 24px; color: var(--gold); }
.top-note { margin: 0; font-size: 13px; color: var(--muted); }

/* Hero */
.hero { padding: 44px 0 28px; max-width: 760px; }
h1 { margin: 0 0 14px; font: 400 clamp(32px, 5.4vw, 52px)/1.08 var(--serif); letter-spacing: -.02em; text-wrap: balance; }
h1 em { font-style: italic; color: var(--accent); }
.lede { margin: 0; font-size: 18px; color: var(--muted); max-width: 62ch; text-wrap: pretty; }

/* Disposición */
.layout { display: grid; gap: 28px; align-items: start; padding-bottom: 56px; }
@media (min-width: 940px) {
  .layout { grid-template-columns: 360px minmax(0, 1fr); gap: 36px; }
  /* El panel queda a la vista mientras se baja por la carta. Si es más alto que la pantalla (ventana baja,
     lista de ciudades abierta), se desplaza por dentro para que el botón siempre sea alcanzable. */
  .panel { position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow-y: auto; }
}

/* Panel / formulario */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.panel-title { margin: 0 0 16px; font: 600 20px/1.2 var(--serif); }
.field { margin-bottom: 14px; min-width: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.opt { color: var(--muted); font-weight: 400; }
input[type="text"], input[type="date"], input[type="time"], input[type="number"], select {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
}
input::placeholder { color: var(--muted); opacity: .7; }
input:disabled { opacity: .5; cursor: not-allowed; }
input[aria-invalid="true"] { border-color: var(--danger); }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: -4px 0 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.fine { margin: 12px 0 0; font-size: 12.5px; color: var(--muted); }

.candidates { margin: 10px 0 0; padding: 0; border: 0; display: grid; gap: 6px; }
.cand { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); cursor: pointer; font-size: 14px; font-weight: 400; margin: 0; }
.cand:has(input:checked) { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.cand input { margin-top: 3px; accent-color: var(--accent); }

.adv { margin: 4px 0 16px; border-top: 1px solid var(--line); padding-top: 12px; }
.adv summary { cursor: pointer; font-size: 14px; font-weight: 500; color: var(--accent); }
.adv[open] summary { margin-bottom: 12px; }

.btn { min-height: 44px; padding: 10px 18px; font: 600 15px/1 var(--sans); border-radius: 10px; border: 1px solid transparent; cursor: pointer; transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease; }
.btn:active { transform: translateY(1px); }
.btn-primary { width: 100%; background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn-primary[disabled] { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { min-height: 38px; padding: 8px 14px; font-size: 14px; }

.error { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--danger-bg); color: var(--danger); font-size: 14px; }

/* Resultado */
.result { min-width: 0; outline: none; }
.result > * + * { margin-top: 20px; }
.badge-ex { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--warn-bg); border: 1px solid var(--warn-line); font-size: 13px; }
.res-head h2 { margin: 6px 0 4px; font: 400 clamp(24px, 3.4vw, 32px)/1.15 var(--serif); letter-spacing: -.01em; }
.res-head p { margin: 0; color: var(--muted); font-size: 15px; }

.notices { display: grid; gap: 8px; }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); border: 1px solid var(--warn-line); font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.big3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.big3 .c { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.big3 .c:last-child:nth-child(odd) { grid-column: 1 / -1; }
@media (min-width: 640px) { .big3 .c:last-child:nth-child(odd) { grid-column: auto; } }
.big3 .k { font-size: 12.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.big3 .v { margin-top: 4px; font: 400 22px/1.2 var(--serif); }
.big3 .v small { display: block; margin-top: 2px; font: 400 13px/1.3 var(--sans); color: var(--muted); }
.g { font-family: var(--sym); color: var(--gold); margin-right: 6px; }
.g.fire { color: var(--fire); } .g.earth { color: var(--earth); } .g.air { color: var(--air); } .g.water { color: var(--water); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 12px; font: 600 18px/1.2 var(--serif); }
.wheel-wrap { max-width: 720px; margin-inline: auto; }
.wheel-wrap svg { display: block; width: 100%; height: auto; border-radius: 12px; }
.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; justify-content: center; }

.tbl-wrap { overflow-x: auto; margin-inline: -4px; padding-inline: 4px; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; }
.rx { color: var(--danger); font-size: 12.5px; font-weight: 600; }
.dim { color: var(--muted); }

.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 76px 1fr 22px; gap: 10px; align-items: center; font-size: 14px; }
.bar .track { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar .fill { height: 100%; border-radius: 999px; background: var(--c, var(--accent)); width: calc(var(--n) * 10%); transition: width .5s cubic-bezier(.2, .7, .2, 1); }
.two { display: grid; gap: 20px; }
@media (min-width: 640px) { .two { grid-template-columns: 1fr 1fr; } }
.sub { margin: 0 0 8px; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.btn-inline { width: auto; }
.tr-controls { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; margin: 8px 0 16px; }
.tr-controls .field { margin: 0; min-width: 150px; }
.tr-controls .check { margin: 0 0 10px; }
ul.tr-list { gap: 8px; }
ul.tr-list li { font-size: 14.5px; }
.tr-list .when { display: inline-block; min-width: 92px; font-variant-numeric: tabular-nums; color: var(--muted); }
.ess { display: grid; gap: 14px; margin-bottom: 8px; }
.ess-item .sub { margin: 0 0 4px; }
.ess-item p { margin: 0 0 6px; max-width: 68ch; text-wrap: pretty; }
ul.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
ul.plain li { font-size: 15px; }
ul.plain .dim { font-size: 14px; }
tr[data-id], tr[data-a] { transition: background-color .12s ease; }
tr[data-id]:hover, tr[data-a]:hover { background: var(--surface-2); }
.report { margin-top: 4px; max-width: 68ch; }
.report h4 { margin: 22px 0 6px; font: 600 18px/1.25 var(--serif); color: var(--accent); }
.report h4:first-child { margin-top: 4px; }
.report p { margin: 0 0 12px; text-wrap: pretty; }
.report ul { margin: 0 0 12px; padding-left: 20px; }
.report li { margin-bottom: 4px; }
.report .note { color: var(--muted); font-size: 14px; padding: 8px 12px; border-left: 3px solid var(--warn-line); background: var(--warn-bg); border-radius: 0 8px 8px 0; }
.upsell { border-style: dashed; background: transparent; box-shadow: none; }
.upsell p { margin: 0; color: var(--muted); max-width: 60ch; }

.foot { border-top: 1px solid var(--line); padding: 28px 0 44px; color: var(--muted); font-size: 14px; }
.foot p { margin: 0 0 8px; max-width: 80ch; }

.fade-in { animation: rise .35s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .fade-in { animation: none; } .bar .fill, .btn { transition: none; } }

@media (max-width: 520px) {
  .hero { padding-top: 28px; }
  .panel { padding: 18px; }
  .top-note { display: none; }
}

@media print {
  body { background: #fff; color: #000; }
  .top, .panel, .tools, .upsell, .skip, .notices { display: none !important; }
  .layout { display: block; }
  .card, .big3 .c { box-shadow: none; break-inside: avoid; }
}
