:root {
  --bg0: #0f1412;
  --bg1: #171e1b;
  --bg2: #1f2924;
  --line: #2c3a33;
  --text: #e8efe9;
  --muted: #8fa097;
  --accent: #d4a017;
  --accent-dim: #a67c0f;
  --good: #3dba7a;
  --danger: #e36a5d;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg0);
}

.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(212,160,23,.18), transparent 60%),
    radial-gradient(700px 400px at 100% 0%, rgba(61,186,122,.08), transparent 55%),
    linear-gradient(180deg, #121916, var(--bg0) 40%);
  z-index: -1;
}

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  background: rgba(15,20,18,.72);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; gap: .9rem; align-items: center; }
.brand strong { display: block; font-size: 1.05rem; letter-spacing: .01em; }
.brand p { margin: .15rem 0 0; color: var(--muted); font-size: .85rem; }
.mark {
  width: 2.4rem; height: 2.4rem;
  display: grid; place-items: center;
  border-radius: .55rem;
  background: linear-gradient(145deg, var(--accent), var(--accent-dim));
  color: #1a1404;
  font-family: var(--mono);
  font-weight: 700;
}

.health {
  font-family: var(--mono);
  font-size: .78rem;
  padding: .35rem .7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}
.health.ok { color: var(--good); border-color: rgba(61,186,122,.35); }
.health.err { color: var(--danger); border-color: rgba(227,106,93,.35); }

main {
  width: min(1280px, calc(100% - 2rem));
  margin: 1.25rem auto 2.5rem;
  display: grid;
  gap: 1rem;
}

.panel {
  background: rgba(23,30,27,.92);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  box-shadow: 0 16px 40px rgba(0,0,0,.22);
}

form {
  display: grid;
  grid-template-columns: 1.3fr 1.3fr 7.5rem 10rem auto;
  gap: .75rem;
  align-items: end;
}
.sub { color: var(--muted); font-size: .75rem; margin-top: .15rem; }
.empty-li { color: var(--muted); cursor: default !important; }

label { display: grid; gap: .35rem; position: relative; }
label.grow { min-width: 0; }
label span {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
}

input, select, button {
  font: inherit;
  border-radius: .65rem;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  padding: .72rem .8rem;
}

input:focus, select:focus {
  outline: 2px solid rgba(212,160,23,.35);
  border-color: var(--accent);
}

button {
  background: linear-gradient(180deg, #e0b12a, var(--accent-dim));
  color: #1a1404;
  font-weight: 700;
  border: none;
  cursor: pointer;
  min-height: 2.75rem;
  padding-inline: 1.2rem;
}
button:hover { filter: brightness(1.05); }
button:disabled { opacity: .6; cursor: wait; }

.table-sub {
  margin: -.25rem 0 .65rem;
  color: var(--muted);
  font-size: .84rem;
}
code {
  font-family: var(--mono);
  font-size: .85em;
  color: var(--accent);
}

.config-head h2 { margin: 0 0 .2rem; font-size: 1rem; }
.config-head p { margin: 0 0 .85rem; color: var(--muted); font-size: .84rem; }
.crit-group { display: flex; gap: .65rem; flex-wrap: wrap; }
.crit-inline {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
}
.crit-inline-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 600;
  margin-right: .15rem;
}
.crit-status {
  margin: .35rem 0 0 !important;
  color: var(--accent) !important;
  font-family: var(--mono);
  font-size: .85rem !important;
}
.crit {
  min-width: 8.5rem;
  padding: .7rem 1rem;
  border-radius: .7rem;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.crit.selected {
  border-color: rgba(212,160,23,.55);
  background: linear-gradient(180deg, #e0b12a, var(--accent-dim));
  color: #1a1404;
}
.crit.inactive {
  opacity: .45;
  filter: grayscale(.15);
}
.crit:hover { filter: brightness(1.05); }
.crit-note {
  grid-column: 1 / -1;
  margin: .25rem 0 0;
  padding: .55rem .75rem;
  border-radius: .5rem;
  background: rgba(212,160,23,.12);
  border: 1px solid rgba(212,160,23,.35);
  color: var(--accent);
  font-size: .9rem;
}

.suggestions {
  position: absolute;
  top: calc(100% + .25rem);
  left: 0; right: 0;
  margin: 0; padding: .3rem;
  list-style: none;
  background: #121816;
  border: 1px solid var(--line);
  border-radius: .65rem;
  max-height: 240px;
  overflow: auto;
  z-index: 30;
}
.suggestions li {
  padding: .55rem .65rem;
  border-radius: .45rem;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: .5rem;
}
.suggestions li:hover, .suggestions li.active { background: var(--bg2); }
.suggestions small { color: var(--muted); font-family: var(--mono); }

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .8rem;
}
.summary .span-2 { grid-column: span 2; }
.summary .hl { color: var(--good); }
.summary small {
  display: block;
  margin-top: .35rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 400;
  white-space: normal;
}
.iata-card strong {
  font-family: var(--mono);
  font-size: 1.6rem;
  letter-spacing: .06em;
  color: var(--accent);
}
.iata-card small {
  display: block;
  margin-top: .35rem;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 400;
  white-space: normal;
}
td .iata, strong.iata {
  font-family: var(--mono);
  letter-spacing: .04em;
  color: var(--accent);
}
.badge {
  font-family: var(--mono);
  font-size: .78rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .2rem .55rem;
}
.summary div {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: .75rem;
  padding: .85rem 1rem;
}
.summary span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .35rem;
}
.summary strong {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
}

.table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: .75rem;
}
.table-head h2 { margin: 0; font-size: 1rem; }
#filtro { width: min(280px, 100%); }

.scroll { overflow: auto; max-height: 62vh; border-radius: .7rem; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .7rem .75rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th {
  position: sticky; top: 0;
  background: #141b18;
  color: var(--muted);
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  z-index: 1;
}
tbody tr:hover { background: rgba(212,160,23,.06); }
tbody tr.best {
  background: rgba(61,186,122,.12);
}
tbody tr.best td.total { color: var(--good); font-weight: 700; }
td.total, td.money { font-family: var(--mono); }
td.obs { white-space: normal; max-width: 240px; color: var(--muted); font-size: .82rem; }
.empty td { text-align: center; color: var(--muted); padding: 2rem 1rem; }

@media (max-width: 980px) {
  form { grid-template-columns: 1fr 1fr; }
  form button { grid-column: 1 / -1; }
  .summary { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  form { grid-template-columns: 1fr; }
  .top { flex-direction: column; align-items: flex-start; }
}
