:root {
  color-scheme: dark;
  --bg: #07110f;
  --panel: #101a18;
  --panel-2: #172320;
  --line: rgba(135, 220, 190, 0.22);
  --text: #eef8f2;
  --muted: #9eb6aa;
  --cyan: #42e6c2;
  --cyan-2: #9af0d9;
  --navy: #081512;
  --amber: #f2c86d;
  --danger: #ff6b6b;
  --ok: #66e3b4;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #081310 0%, #07110f 46%, #0a1713 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button, input, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 15, 0.9);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand img, .site-footer img, .brand-logo { display: block; height: 2.4rem; width: auto; }
.top-actions { display: flex; align-items: center; gap: .7rem; }
.top-actions a, .top-actions button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--text);
  border-radius: 8px;
  padding: .55rem .75rem;
  cursor: pointer;
}

main { width: min(1280px, calc(100% - 2rem)); margin: 0 auto; }
.hero {
  min-height: 30vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 2rem;
  padding: clamp(2rem, 7vw, 5rem) 0 2rem;
  border-bottom: 1px solid rgba(135, 220, 190, 0.12);
  margin-bottom: 1rem;
}
.hero.compact { min-height: auto; }
.eyebrow {
  margin: 0 0 .7rem;
  color: var(--cyan-2);
  text-transform: uppercase;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
}
h1 {
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 6.4rem);
  line-height: .9;
  letter-spacing: 0;
}
.lead {
  color: var(--muted);
  max-width: 58rem;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.55;
}
.hero-signal {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  min-width: 18rem;
  background: linear-gradient(135deg, rgba(16, 26, 24, .92), rgba(34, 38, 24, .72));
  box-shadow: var(--shadow);
}
.hero-signal span { display: block; color: var(--muted); font-size: .84rem; }
.hero-signal strong { display: block; margin-top: .35rem; color: var(--amber); }

.workspace {
  display: grid;
  grid-template-columns: minmax(18rem, 24rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  padding-bottom: 3rem;
}
.tool-panel, .result-card, .table-card, .metric-card {
  background: rgba(16, 26, 24, .94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.tool-panel { padding: 1rem; position: sticky; top: 5.5rem; }
.mode-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; margin-bottom: 1rem; }
.mode-tab {
  min-height: 2.8rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255,255,255,.03);
  cursor: pointer;
}
.mode-tab.active { color: var(--navy); background: var(--cyan); border-color: var(--cyan); font-weight: 800; }

.work-form { display: grid; gap: 1rem; }
fieldset { border: 1px solid var(--line); border-radius: 8px; padding: .8rem; }
legend, label { color: var(--text); font-weight: 700; }
.input-choice { display: inline-flex; align-items: center; gap: .35rem; margin-right: .75rem; font-weight: 600; color: var(--muted); }
.source-box { display: grid; gap: .55rem; }
input[type=file], input[type=password], textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .04);
  color: var(--text);
  padding: .85rem;
}
textarea { resize: vertical; min-height: 13rem; }
.hint { margin: 0; color: var(--muted); font-size: .86rem; line-height: 1.45; }
.primary-btn, .login-form button {
  border: 0;
  border-radius: 8px;
  min-height: 3rem;
  padding: .85rem 1rem;
  background: var(--cyan);
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
}
.primary-btn:disabled { opacity: .65; cursor: progress; }
.status-line { min-height: 1.4rem; margin: 0; color: var(--cyan-2); }
.error-box {
  margin: 0;
  border: 1px solid rgba(255, 107, 107, .38);
  border-radius: 8px;
  padding: .75rem;
  color: #ffd7d7;
  background: rgba(255, 107, 107, .08);
  line-height: 1.45;
  overflow-wrap: anywhere;
}
.form-error { min-height: 1.3rem; color: var(--danger); }
.hidden { display: none !important; }

.results-panel { min-width: 0; }
.empty-state {
  min-height: 32rem;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 2rem;
  color: var(--muted);
  background: rgba(255, 255, 255, .015);
}
.empty-state img { width: 5rem; margin-bottom: 1rem; }
.empty-state h2 { color: var(--text); margin: 0; }
.results { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: stretch; }
.results-nav {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .5rem;
  position: sticky;
  top: 5.2rem;
  z-index: 3;
  padding: .45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 17, 15, .92);
  backdrop-filter: blur(12px);
}
.results-nav a {
  display: grid;
  place-items: center;
  min-height: 2.4rem;
  border: 1px solid rgba(135, 220, 190, .18);
  border-radius: 8px;
  color: var(--cyan-2);
  background: rgba(255, 255, 255, .035);
  font-size: .84rem;
  font-weight: 800;
  text-align: center;
}
.result-card { min-width: 0; padding: 1rem; }
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .7rem; }
.result-head h2 { margin: 0; font-size: 1.1rem; }
.copy-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.04);
  color: var(--cyan-2);
  padding: .45rem .65rem;
  cursor: pointer;
}
pre, .markdown {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.62;
  color: #dcecf4;
  margin: 0;
  max-height: clamp(22rem, 48vh, 34rem);
  overflow: auto;
}
.markdown h2, .markdown h3 { color: var(--cyan-2); margin: 1rem 0 .45rem; }
.markdown p { margin: .55rem 0; }

.processing-panel {
  min-height: 32rem;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1.25rem;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2rem;
  background:
    radial-gradient(circle at center, rgba(66, 230, 194, .12), transparent 38%),
    rgba(16, 26, 24, .72);
  box-shadow: var(--shadow);
}
.processing-panel h2 { margin: 0; font-size: 1.3rem; }
.processing-panel p { max-width: 34rem; margin: 0; color: var(--muted); line-height: 1.55; }
.processing-orbit {
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 50%;
  border: 4px solid rgba(154, 240, 217, .22);
  border-top-color: var(--cyan);
  border-right-color: var(--amber);
  animation: humolitik-spin .9s linear infinite;
  box-shadow: 0 0 2rem rgba(66, 230, 194, .16);
}
.is-busy .primary-btn { position: relative; overflow: hidden; }
.is-busy .primary-btn::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: .22rem;
  background: linear-gradient(90deg, transparent, var(--amber), transparent);
  animation: humolitik-scan 1.2s ease-in-out infinite;
}
@keyframes humolitik-spin { to { transform: rotate(360deg); } }
@keyframes humolitik-scan {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.site-footer {
  width: min(1280px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
}
.footer-brand { display: flex; align-items: center; gap: 1rem; }
.malvinas-link {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .25rem;
  color: var(--muted);
  text-decoration: none;
  font-size: .68rem;
  letter-spacing: .08em;
  transition: color .15s ease;
}
.malvinas-link:hover { color: var(--cyan-2); }
.malvinas-link strong { font-size: .68rem; font-weight: 700; color: #dcecf4; }
.malvinas-map {
  width: 5.5rem;
  height: 3.4rem;
  fill: #75aadb;
  stroke: #d7f0ff;
  stroke-width: 1.45;
  filter: drop-shadow(0 0 .6rem rgba(73, 215, 255, .18));
  transition: transform .15s ease;
}
.malvinas-link:hover .malvinas-map { transform: translateY(-1px); }

.login-page { display: grid; place-items: center; padding: 1rem; }
.login-shell { width: min(32rem, 100%); }
.login-shell .brand-logo { margin: 0 auto 1rem; height: 3rem; }
.login-malvinas { align-items: center; margin: 1rem auto 0; }
.login-panel {
  background: rgba(13, 32, 48, .92);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.4rem;
  box-shadow: var(--shadow);
}
.login-panel h1 { font-size: 3.2rem; }
.login-form { display: grid; gap: .7rem; margin-top: 1rem; }

.stats-page { padding-bottom: 3rem; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: .8rem;
  margin-bottom: 1rem;
}
.metric-card { padding: 1rem; }
.metric-card span, .metric-card small { color: var(--muted); display: block; }
.metric-card strong { display: block; font-size: 2rem; color: var(--cyan); }
.table-card { overflow: auto; }
table { width: 100%; border-collapse: collapse; min-width: 62rem; }
th, td { padding: .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--cyan-2); font-size: .82rem; text-transform: uppercase; }
td { color: #dcecf4; font-size: .88rem; }

@media (max-width: 860px) {
  main { width: min(100% - 1rem, 1280px); }
  .topbar { position: static; align-items: flex-start; }
  .brand img { height: 2rem; }
  .hero, .workspace { grid-template-columns: 1fr; }
  .hero { min-height: auto; padding-top: 2rem; }
  .hero-signal { min-width: 0; }
  .tool-panel { position: static; }
  .results { grid-template-columns: 1fr; }
  .results-nav { grid-template-columns: 1fr 1fr; position: static; }
  .site-footer, .footer-brand { flex-direction: column; align-items: flex-start; }
  .malvinas-link { align-items: flex-start; }
}
