:root {
  --bg: #f7f7f5;
  --card-bg: #ffffff;
  --border: #ddd;
  --text: #1a1a1a;
  --muted: #666;
  --accent: #2a5d8a;
  --warn-bg: #fff6e0;
  --warn-border: #e8c766;
  --error: #b3261e;
  --success: #1a7d3c;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.5rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; text-decoration: none; color: var(--text); }
.brand-logo { display: block; }
.topbar nav a { margin-left: 1.2rem; text-decoration: none; color: var(--accent); padding-bottom: 0.3rem; border-bottom: 2px solid transparent; }
.topbar nav a.active { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }

.disclaimer {
  margin: 1rem 1.5rem;
  padding: 0.75rem 1rem;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 6px;
  font-size: 0.9rem;
}

main { max-width: 900px; margin: 0 auto; padding: 0 1.5rem 3rem; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card.narrow { max-width: 480px; }
.card.wide { max-width: 900px; }
.card.inset { background: #fafafa; }

h1 { margin-top: 0; font-size: 1.4rem; }
h2 { font-size: 1.1rem; margin-top: 1.5rem; }

.muted { color: var(--muted); }
.muted.small { font-size: 0.85rem; }
.error { color: var(--error); }
.success { color: var(--success); }
.hidden { display: none; }

form { display: flex; flex-direction: column; gap: 0.4rem; margin-top: 0.5rem; }
label { font-size: 0.85rem; font-weight: 600; margin-top: 0.6rem; }
input, select, textarea, button {
  font: inherit;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 5px;
}
button {
  margin-top: 1rem;
  background: var(--accent);
  color: white;
  border: none;
  cursor: pointer;
  padding: 0.6rem 1rem;
  font-weight: 600;
}
button:hover { opacity: 0.9; }

.dropzone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 1.5rem 1rem;
  text-align: center;
  background: #fafafa;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone.dragover {
  border-color: var(--accent);
  background: #eef4f9;
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  border: none;
}
.dropzone-prompt { color: var(--muted); font-size: 0.9rem; pointer-events: none; }
.dropzone-browse { color: var(--accent); text-decoration: underline; }
.dropzone-filename { margin-top: 0.4rem; font-weight: 600; font-size: 0.9rem; pointer-events: none; }

.upload-progress { margin-top: 0.75rem; }
.upload-progress-track { background: #eee; border-radius: 4px; height: 10px; overflow: hidden; }
.upload-progress-fill { background: var(--accent); height: 100%; width: 0%; transition: width 0.15s; }
#upload-progress-label { margin: 0.35rem 0 0; text-align: center; }

table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
th, td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: center; font-size: 0.9rem; }
th { background: #f0f0ee; }
td:first-child, th:first-child { text-align: left; }

.status-box { padding: 1rem; border-radius: 6px; background: #f0f0ee; margin-bottom: 1rem; }
.status-box.failed { background: #fbe9e7; color: var(--error); }

.ad-chance {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.explanation {
  color: var(--text);
  line-height: 1.6;
  margin: 0.5rem 0 1rem;
}

.prob-bar-row { display: flex; align-items: center; gap: 0.6rem; margin: 0.3rem 0; }
.prob-bar-label { width: 60px; font-size: 0.85rem; }
.prob-bar-track { flex: 1; background: #eee; border-radius: 4px; height: 14px; overflow: hidden; }
.prob-bar-fill { background: var(--accent); height: 100%; }
.prob-bar-value { width: 50px; text-align: right; font-size: 0.85rem; }

.low-confidence-banner {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.heatmap-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-top: 1rem; }
.heatmap-row img { max-width: 220px; border: 1px solid var(--border); border-radius: 6px; }

footer {
  max-width: 900px;
  margin: 2rem auto 0;
  padding: 0 1.5rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.tabs { display: flex; gap: 1rem; margin: 0.5rem 0 1.25rem; border-bottom: 1px solid var(--border); }
.tabs a {
  text-decoration: none;
  color: var(--muted);
  padding: 0.4rem 0.2rem;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
}
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.row-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.row-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }
.row-actions form { margin: 0; }
.btn-approve, .btn-reject {
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.85rem;
}
.btn-approve { background: var(--success); color: #fff; }
.btn-reject { background: transparent; color: var(--error); border-color: var(--error); }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 10px;
  margin-left: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-pending { background: var(--warn-bg); color: #8a6a00; border: 1px solid var(--warn-border); }
.badge-approved { background: #e6f4ea; color: var(--success); border: 1px solid #b8dfc4; }
.badge-rejected { background: #fbe9e7; color: var(--error); border: 1px solid #f0c4bf; }

.risk-curve { display: flex; gap: 0.5rem; align-items: flex-end; height: 90px; margin-top: 0.75rem; }
.risk-curve-bar { display: flex; flex-direction: column; align-items: center; flex: 1; gap: 0.3rem; }
.risk-curve-bar .bar-track { width: 100%; height: 60px; background: #eee; border-radius: 4px; display: flex; align-items: flex-end; overflow: hidden; }
.risk-curve-bar .bar-fill { width: 100%; background: var(--accent); }
.risk-curve-bar .bar-label { font-size: 0.75rem; color: var(--muted); }

.hero { max-width: 900px; margin: 1.5rem auto 2rem; text-align: left; }
.hero h1 { font-size: 1.9rem; margin: 0 0 0.75rem; line-height: 1.25; }
.hero-sub { color: var(--muted); font-size: 1.05rem; max-width: 680px; margin: 0 0 1.25rem; }

.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.button-link {
  display: inline-block;
  padding: 0.6rem 1.1rem;
  border-radius: 6px;
  border: 1px solid var(--accent);
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}
.button-link.primary { background: var(--accent); color: #fff; }
.button-link:hover { opacity: 0.9; }

.stat-grid { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; }
.stat-tile {
  flex: 1 1 180px;
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.82rem; color: var(--muted); margin-top: 0.3rem; line-height: 1.35; }
