:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-soft: #1c2230;
  --border: #2a3140;
  --text: #e6edf3;
  --muted: #8b98a9;
  --accent: #f7931a;
  --accent-2: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

h1 { font-size: 19px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 13px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 22px; border-bottom: 1px solid var(--border); background: var(--bg-card);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 38px; height: 38px; border-radius: 9px; background: var(--accent);
  color: #1a1200; display: grid; place-items: center; font-size: 22px; font-weight: 700;
}
.sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

main { max-width: 1280px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
#results { display: flex; flex-direction: column; gap: 18px; }
footer { max-width: 1280px; margin: 0 auto; padding: 8px 20px 32px; }

.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.card-actions { display: flex; gap: 8px; }

/* ---------- controles ---------- */
.btn {
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--text);
  padding: 8px 14px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: filter .12s, opacity .12s;
}
.btn:hover:not(:disabled) { filter: brightness(1.25); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a1200; font-weight: 600; padding: 10px 22px; }
.btn-secondary { background: var(--accent-2); border-color: var(--accent-2); color: #04101f; font-weight: 600; }
.btn-ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }

.pill { padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill-muted { background: var(--bg-soft); color: var(--muted); border: 1px solid var(--border); }
.pill-ok { background: rgba(63,185,80,.15); color: var(--green); border: 1px solid rgba(63,185,80,.4); }
.pill-bad { background: rgba(248,81,73,.15); color: var(--red); border: 1px solid rgba(248,81,73,.4); }

.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; }
.field > span { color: var(--muted); }
.field input, .field select {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: 6px; font-size: 13px; font-family: inherit;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent-2); }
.field .hint { color: var(--muted); font-size: 11px; line-height: 1.35; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  padding: 7px 14px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--bg-soft); cursor: pointer; font-size: 13px; color: var(--muted);
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #1a1200; font-weight: 600; }

.mode-switch { display: flex; gap: 16px; font-size: 13px; color: var(--muted); }
.mode-switch label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

.config-layout { display: grid; grid-template-columns: 1.35fr 1fr; gap: 22px; }
.config-col { min-width: 0; }
.params { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin: 12px 0; }

.run-row { display: flex; align-items: center; gap: 18px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

.progress { display: flex; align-items: center; gap: 12px; flex: 1; margin-top: 10px; }
.progress-bar { flex: 1; height: 7px; background: var(--bg-soft); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.progress-label { font-size: 12px; color: var(--muted); min-width: 260px; }

.error { margin-top: 12px; padding: 11px 14px; border-radius: 7px; background: rgba(248,81,73,.12); border: 1px solid rgba(248,81,73,.4); color: #ffb3ae; font-size: 13px; }

/* ---------- datos ---------- */
.data-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 12px; }
.data-box { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 13px 15px; }
.data-box h4 { margin: 0 0 9px; font-size: 13px; display: flex; justify-content: space-between; align-items: center; }
.data-box dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 12px; }
.data-box dt { color: var(--muted); }
.data-box dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.gaps { margin-top: 14px; font-size: 12px; }
.gaps summary { cursor: pointer; color: var(--muted); }

/* ---------- metricas ---------- */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.metric { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; }
.metric .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.metric .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 3px; }
.metric .n { color: var(--muted); font-size: 11px; margin-top: 2px; }

.friction { margin-top: 14px; background: var(--bg-soft); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.friction h4 { margin: 0 0 10px; font-size: 13px; }
.fbar { height: 22px; border-radius: 5px; overflow: hidden; display: flex; background: var(--bg); border: 1px solid var(--border); }
.fbar div { height: 100%; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: #04101f; white-space: nowrap; overflow: hidden; }
.flegend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 9px; font-size: 12px; }
.flegend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }

/* ---------- charts ---------- */
.chart-wrap { position: relative; height: 340px; }
.chart-wrap.chart-small { height: 150px; margin-top: 10px; }

/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; margin-top: 10px; }
.table-wrap.tall { max-height: 520px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--bg-card); color: var(--muted); font-weight: 600; text-align: right; z-index: 1; }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover { background: var(--bg-soft); }
td.num { font-variant-numeric: tabular-nums; }

.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; margin-bottom: 6px; }
.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin-top: 12px; }

.tag { padding: 2px 7px; border-radius: 4px; font-size: 11px; background: var(--bg-soft); border: 1px solid var(--border); }

@media (max-width: 900px) {
  .config-layout { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
