:root {
  --bg: #0b1220;
  --panel: rgba(255,255,255,0.04);
  --panel2: rgba(255,255,255,0.03);
  --border: rgba(255,255,255,0.10);
  --text: #e5e7eb;
  --muted: rgba(229,231,235,0.78);
  --accent: #6d28d9;
  --red: #ef4444;
  --green: #22c55e;
  --gray: #a3a3a3;

  /* Hint to the browser that native form controls should use a dark theme. */
  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  background: var(--bg);
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica, Arial;
  background: transparent;
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  isolation: isolate;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: radial-gradient(900px 500px at 20% 0%, rgba(109,40,217,.30), transparent 60%), var(--bg);
}

code { color: #d1d5db; }

.app {
  display: grid;
  grid-template-columns: 360px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 18px;
}

.main {
  padding: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 14px;
  margin-bottom: 14px;
}

.header-card {
  background: linear-gradient(135deg, rgba(109,40,217,.35), rgba(17,27,46,.90));
}

h1 { margin: 0 0 6px 0; font-size: 1.65rem; line-height: 1.15; }
h2 { margin: 0 0 12px 0; font-size: 1.05rem; }

p { margin: 0; color: var(--muted); }

.label {
  display: block;
  margin: 10px 0 6px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio { font-size: 0.92rem; color: var(--text); opacity: 0.95; }

select, input[type="file"] {
  width: 100%;
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);

  /* Darker background for better contrast with white text */
  background: rgba(0,0,0,0.55);
  color: var(--text);
}

/* Some browsers keep <option> colors independent from <select>. */
select option {
  background: var(--bg);
  color: var(--text);
}

input[type="range"] { width: 100%; }

button {
  cursor: pointer;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

button.primary {
  width: 100%;
  margin-top: 12px;
  border-color: rgba(109,40,217,0.5);
  background: rgba(109,40,217,0.28);
}

button.primary:disabled { opacity: 0.5; cursor: not-allowed; }

.status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9rem;
}

.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
}

.bullets { margin: 0; padding-left: 18px; color: var(--muted); }
.bullets li { margin: 6px 0; }

.hidden { display: none !important; }

.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.kpi {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 12px;
}

.kpiLabel { color: var(--muted); font-size: 0.86rem; }
.kpiValue { font-size: 1.28rem; font-weight: 700; margin-top: 4px; }

.tabs {
  display: flex;
  gap: 8px;
  margin: 10px 0 12px;
}

.tab {
  background: rgba(255,255,255,0.04);
}

.tab.active {
  border-color: rgba(109,40,217,0.5);
  background: rgba(109,40,217,0.22);
}

.grid2 {
  display: grid;
  grid-template-columns: 2fr 1.35fr;
  gap: 14px;
}

.plot { width: 100%; height: 360px; }
.plot.small { height: 220px; }

.tableWrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th, .table td {
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: 10px 10px;
  vertical-align: top;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.table th {
  text-align: left;
  position: sticky;
  top: 0;
  background: rgba(11,18,32,0.92);
  cursor: pointer;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
}
.badge.pos { background: rgba(34,197,94,0.14); color: var(--green); border: 1px solid rgba(34,197,94,0.35); }
.badge.neu { background: rgba(163,163,163,0.12); color: var(--gray); border: 1px solid rgba(163,163,163,0.35); }
.badge.neg { background: rgba(239,68,68,0.14); color: var(--red); border: 1px solid rgba(239,68,68,0.35); }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2 { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .sidebar,
  .main {
    padding: 12px;
  }

  h1 {
    font-size: 1.35rem;
  }

  /* Prevent iOS Safari from zooming when focusing form controls. */
  select,
  input[type="file"],
  button {
    font-size: 16px;
  }

  .kpis {
    grid-template-columns: 1fr;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .plot {
    height: 290px;
  }

  .plot.small {
    height: 200px;
  }

  .table th,
  .table td {
    padding: 9px 9px;
    font-size: 0.88rem;
  }
}
