:root {
  --bg: #0f1419;
  --bg-soft: #161c24;
  --card: #1a212b;
  --card-2: #222b37;
  --border: #2c3744;
  --text: #e6edf3;
  --text-dim: #9aa7b5;
  --accent: #4f9cf9;
  --accent-2: #2ea043;
  --danger: #f85149;
  --warn: #d29922;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, #1b2735 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 25, 0.7);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: 0.2px; }
.subtitle { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }
.logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7b5cff);
  font-weight: 700; font-size: 15px; letter-spacing: -0.5px;
}

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.pill--ok .dot { background: var(--accent-2); box-shadow: 0 0 8px var(--accent-2); }
.pill--ok { color: var(--accent-2); border-color: rgba(46, 160, 67, 0.4); }
.pill--bad .dot { background: var(--danger); }
.pill--bad { color: var(--danger); border-color: rgba(248, 81, 73, 0.4); }
.pill--loading .dot { background: var(--warn); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ---------- layout ---------- */
.layout {
  max-width: 1180px; margin: 28px auto; padding: 0 24px;
  display: grid; grid-template-columns: 380px 1fr; gap: 22px;
  align-items: start;
}
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card h2 { margin: 0; font-size: 15px; letter-spacing: 0.3px; }
.form-card { padding: 22px; }
.form-card h2 { margin-bottom: 18px; }

/* ---------- form ---------- */
form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.field .opt { font-weight: 400; color: var(--text-dim); }
.field small { font-size: 11px; color: var(--text-dim); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input, select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 156, 249, 0.18); }
input::placeholder { color: #5b6875; }

.btn-primary {
  margin-top: 6px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 16px;
  background: linear-gradient(135deg, var(--accent), #6a5cff);
  color: white; font-weight: 600; font-size: 14px;
  border: none; border-radius: 9px; cursor: pointer;
  transition: transform 0.05s, opacity 0.15s;
}
.btn-primary:hover { opacity: 0.94; }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-error {
  margin-top: 4px; padding: 10px 12px; border-radius: 8px;
  background: rgba(248, 81, 73, 0.12); border: 1px solid rgba(248, 81, 73, 0.4);
  color: #ffb4ab; font-size: 12.5px;
}

/* ---------- results ---------- */
.results-card { padding: 22px; min-height: 420px; }
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; color: var(--text-dim); padding: 70px 20px; gap: 10px;
}
.empty-icon { font-size: 42px; opacity: 0.8; }
.empty-state p { max-width: 360px; font-size: 13.5px; line-height: 1.5; margin: 0; }

.results-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.meta { display: flex; gap: 8px; }
.chip {
  font-size: 11.5px; padding: 4px 10px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--border); color: var(--text-dim);
}

.stat-row {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
  margin-bottom: 20px;
}
@media (max-width: 720px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 10px; text-align: center; display: flex; flex-direction: column; gap: 5px;
}
.stat--hero { background: linear-gradient(160deg, rgba(79,156,249,0.18), rgba(123,92,255,0.12)); border-color: rgba(79,156,249,0.45); }
.stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-dim); }
.stat-value { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value--lg { font-size: 22px; color: var(--accent); }

.prob-block {
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin-bottom: 20px;
}
.prob-label { font-size: 12.5px; color: var(--text-dim); margin-bottom: 8px; }
.prob-bar { height: 10px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.prob-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 6px; transition: width 0.6s ease;
}
.prob-value { font-size: 18px; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; }

.chart-block h3 { font-size: 13px; color: var(--text-dim); margin: 0 0 10px; font-weight: 600; }
#histogram { width: 100%; height: auto; display: block; border-radius: 8px; background: var(--bg-soft); }

.footer {
  text-align: center; padding: 26px; color: var(--text-dim); font-size: 12px;
}
.footer a { color: var(--accent); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
