:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #5b6472;
  --line: #dfe3e8;
  --accent: #1d4ed8;
  --accent-text: #ffffff;
  --ok: #0f7b43;
  --ok-bg: #e3f5ea;
  --wait: #8a5a00;
  --wait-bg: #fdf1d6;
  --error: #b42318;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #181c22;
    --text: #e8eaed;
    --muted: #9aa4b2;
    --line: #2a3038;
    --accent: #6ea0ff;
    --accent-text: #0b1220;
    --ok: #6fdc9c;
    --ok-bg: #123322;
    --wait: #f1c35b;
    --wait-bg: #3a2c0a;
    --error: #ff8a7a;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0; }
p { margin: 0; }
code { font: 0.9em ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }
small { font-size: 0.85rem; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
#nav { display: flex; align-items: center; gap: 16px; }
main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 64px; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.muted { color: var(--muted); }
.error { color: var(--error); }
.warning { background: var(--wait-bg); color: var(--wait); padding: 10px 12px; border-radius: var(--radius); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
details.card { display: block; }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: 14px; }
.narrow { max-width: 420px; margin: 48px auto 0; }
.columns { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.columns > section { display: flex; flex-direction: column; gap: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.site { text-decoration: none; color: inherit; gap: 6px; }
.site:hover { border-color: var(--accent); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.8rem; background: var(--line); width: fit-content; margin-left: 6px; }
.badge.ok { background: var(--ok-bg); color: var(--ok); margin-left: 0; }
.badge.wait { background: var(--wait-bg); color: var(--wait); }
.site .badge { margin-left: 0; }

.field { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.field small { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], select {
  font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; min-width: 0;
}
button, .button {
  font: inherit; cursor: pointer; border-radius: 6px; padding: 8px 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  text-decoration: none; display: inline-block; white-space: nowrap;
}
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
button:disabled { opacity: 0.6; cursor: default; }
button.danger { border-color: var(--error); color: var(--error); }
progress { width: 100%; height: 10px; accent-color: var(--accent); }
.card details > summary { cursor: pointer; color: var(--muted); }
.card details[open] > summary { margin-bottom: 10px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.copy { display: flex; gap: 8px; align-items: flex-start; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; }
.copy code { flex: 1; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs button.active { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.waiting { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--wait); animation: pulso 1.2s ease-in-out infinite; }
@keyframes pulso { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
td:not(:first-child), thead th:not(:first-child) { font-variant-numeric: tabular-nums; }
table.compact th, table.compact td { padding: 5px 6px; font-size: 0.85rem; }
table.compact code { display: block; max-width: 190px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.compact tbody tr:hover { background: var(--bg); }
ul.plain { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

textarea { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; resize: vertical; }
.chat { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; }
.bubble { padding: 8px 12px; border-radius: 12px; max-width: 90%; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); }
.bubble.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); }
.bubble.note { align-self: stretch; max-width: none; background: var(--wait-bg); color: var(--wait); }
details.card p + p { margin-top: 10px; }

ol.recs { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 18px; }
ol.recs li > strong { font-size: 1.02rem; }
ol.recs li p { margin-top: 6px; }
.badge.impact-alto { background: var(--ok-bg); color: var(--ok); }
.badge.impact-medio { background: var(--wait-bg); color: var(--wait); }
.row input[type="text"] { flex: 1 1 260px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; }
.stat strong { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.85rem; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 7px 12px; }
.segmented input:checked + span { background: var(--accent); color: var(--accent-text); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

.map { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; align-items: start; }
.compare section { display: flex; flex-direction: column; gap: 8px; }
.frame { position: relative; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.frame img { display: block; width: 100%; height: 100%; }
.frame .layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.frame.no-photo { background: repeating-linear-gradient(0deg, #f3f4f6 0 39px, #e5e7eb 39px 40px); }
.frame.no-photo p { position: absolute; top: 12px; left: 12px; right: 12px; color: #374151; background: rgba(255,255,255,0.9); padding: 8px 10px; border-radius: 6px; }

@media (max-width: 860px) {
  .columns, .map, .compare { grid-template-columns: minmax(0, 1fr); }
  table { display: block; overflow-x: auto; }
}
