/* ============================================================
   Fraud Detector — red / amber, "alert" aesthetic on near-white
   ============================================================ */
:root {
  --bg:           #FAFAF9;
  --bg-soft:      #FEF2F2;
  --bg-elevated:  #FFFFFF;
  --fg:           #18120E;
  --fg-soft:      #3A2418;
  --muted:        #78635A;
  --border:       #F0E0D8;
  --border-strong:#E6CBC0;

  --brand:        #DC2626;
  --brand-strong: #B91C1C;
  --brand-soft:   #FEE2E2;
  --accent:       #F59E0B;
  --accent-soft:  #FEF3C7;

  --tp: #16A34A;   /* caught fraud      */
  --fp: #F59E0B;   /* false alarm       */
  --tn: #94A3B8;   /* true negative     */
  --fn: #DC2626;   /* missed fraud      */

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(24,18,14,0.06);
  --shadow-md: 0 8px 24px rgba(24,18,14,0.08), 0 2px 6px rgba(24,18,14,0.04);
  --shadow-alert: 0 8px 24px rgba(220,38,38,0.18);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --container: 1180px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  color: var(--fg); background: var(--bg);
  font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; transition: color 120ms, border-color 120ms; }
a:hover { color: var(--brand); }

h1, h2, h3 { font-family: var(--font-sans); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 0.5em; color: var(--fg); }
h1 { font-size: clamp(2rem, 4vw + 1rem, 3.3rem); line-height: 1.06; }
h2 { font-size: clamp(1.4rem, 1.6vw + 1rem, 2.1rem); line-height: 1.15; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 1em 0; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }

.container { max-width: var(--container); margin: 0 auto; padding: 0 1.25rem; }
.row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.site-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(250,250,249,0.92);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header .row { padding: 0.85rem 0; justify-content: space-between; }
.brand { display: flex; align-items: center; gap: 0.7rem; color: var(--brand); }
.brand .mark {
  width: 42px; height: 42px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center;
}
.brand .wordmark { line-height: 1.1; display: flex; flex-direction: column; }
.brand .wordmark span { font-weight: 800; font-size: 1.1rem; letter-spacing: -0.01em; }
.brand .wordmark small { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.15em; color: var(--muted); font-weight: 600; }
.nav { display: flex; gap: 1.3rem; }
.nav a { color: var(--muted); font-weight: 500; font-size: 0.93rem; }
.nav a:hover { color: var(--brand); }

.hero { padding: 4rem 0 3.5rem; text-align: center; }
.hero .eyebrow {
  display: inline-block; padding: 0.35em 0.95em;
  border: 1px solid var(--brand-soft); border-radius: 999px;
  background: rgba(220,38,38,0.06); color: var(--brand);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.16em;
  margin-bottom: 1.25rem;
}
.hero h1 .accent {
  background: linear-gradient(120deg, var(--brand) 0%, var(--accent) 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .lede { max-width: 64ch; margin: 0 auto 1.5rem; color: var(--muted); font-size: 1.05rem; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; gap: 0.5em;
  padding: 0.6em 1.25em;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: 0.92rem;
  cursor: pointer; transition: all 120ms;
}
.btn:active { transform: translateY(1px); }
.btn-primary  { background: var(--brand); color: #fff; border-color: var(--brand); box-shadow: var(--shadow-sm); }
.btn-primary:hover  { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-secondary { background: #fff; color: var(--fg); border-color: var(--border-strong); }
.btn-secondary:hover { border-color: var(--brand); color: var(--brand); }

.section { padding: 3.5rem 0; }
.section-muted { background: var(--bg-soft); }
.section-head { margin-bottom: 1.5rem; }
.section-head .eyebrow {
  display: inline-block; color: var(--brand);
  font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.14em;
  margin-bottom: 0.45rem;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* ===== Threshold + metrics ===== */
.dash { display: flex; flex-direction: column; gap: 1.25rem; }

.threshold { padding: 1.25rem; }
.threshold .lbl {
  font-size: 0.78rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted);
}
#thr-val { font-size: 1.1rem; font-weight: 800; color: var(--brand); }
#threshold {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 8px; border-radius: 999px;
  background: linear-gradient(90deg, var(--tn) 0%, var(--fp) 50%, var(--brand) 100%);
  outline: none;
}
#threshold::-webkit-slider-thumb,
#threshold::-moz-range-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 999px;
  background: #fff; border: 3px solid var(--brand); cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.metric-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.85rem;
}
@media (max-width: 800px) { .metric-grid { grid-template-columns: repeat(2, 1fr); } }
.metric {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-top: 4px solid var(--mc, var(--brand));
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: 0.2rem;
}
.metric .lbl { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; }
.metric .val { font-size: 1.85rem; font-weight: 900; font-family: var(--font-mono); color: var(--mc, var(--brand)); }
.metric .sub { font-size: 0.78rem; }
.mtr-prec { --mc: var(--brand); }
.mtr-rec  { --mc: var(--accent); }
.mtr-f1   { --mc: var(--tp); }
.mtr-acc  { --mc: var(--tn); }

/* ===== Charts area ===== */
.charts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}
.chart-wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .charts { grid-template-columns: 1fr; } }
.chart-card { padding: 1.25rem; }
.chart-card h3 { margin: 0 0 0.25rem; }
canvas { width: 100%; height: auto; display: block; }
.auc { font-size: 0.9rem; color: var(--muted); margin-top: 0.5rem; text-align: right; }

/* Confusion matrix grid (4 cells + row/col headers) */
.cm {
  display: grid;
  grid-template-columns: 60px 1fr 1fr;
  grid-template-rows: 28px 60px 1fr 1fr;
  grid-template-areas:
    "...  cl   cl"
    "...  ch1  ch2"
    "rh1  tn   fp"
    "rh2  fn   tp";
  gap: 6px;
  align-items: stretch;
  position: relative;
}
.cm .cm-label {
  font-size: 0.7rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.12em;
  display: flex; align-items: center; justify-content: center;
}
.cm .cm-label.cl { grid-area: cl; }
.cm .cm-hh, .cm .cm-rh {
  font-size: 0.85rem; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
}
.cm-cell {
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.9rem;
  display: flex; flex-direction: column; gap: 0.15rem; justify-content: center;
  background: var(--bg-soft);
  border-left: 4px solid var(--cc, var(--brand));
}
.cm-cell.tn { --cc: var(--tn); }
.cm-cell.fp { --cc: var(--fp); }
.cm-cell.fn { --cc: var(--fn); background: rgba(220,38,38,0.06); }
.cm-cell.tp { --cc: var(--tp); background: rgba(22,163,74,0.06); }
.cm-cell strong { font-size: 1.6rem; font-family: var(--font-mono); font-weight: 900; color: var(--cc); }
.cm-cell span { font-size: 0.74rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ===== Stream ===== */
.stream-card { padding: 1.25rem; }
.stream {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 0.4rem;
  max-height: 360px; overflow-y: auto;
}
.stream li {
  display: grid;
  grid-template-columns: 64px 1fr 1fr 80px 80px 90px;
  gap: 0.6rem; align-items: center;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--cc, var(--tn));
  background: var(--bg-soft);
  font-size: 0.86rem;
  animation: stream-in 220ms ease;
}
.stream li.flagged       { --cc: var(--brand); background: rgba(220,38,38,0.05); }
.stream li.flagged.tp    { --cc: var(--tp); }
.stream li.flagged.fp    { --cc: var(--fp); }
.stream li.cleared.fn    { --cc: var(--fn); background: rgba(220,38,38,0.04); }
@keyframes stream-in {
  from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); }
}
.stream .time  { font-family: var(--font-mono); color: var(--muted); font-size: 0.78rem; }
.stream .amount { font-family: var(--font-mono); font-weight: 700; text-align: right; }
.stream .score { font-family: var(--font-mono); font-size: 0.82rem; text-align: right; }
.stream .badge {
  font-size: 0.7rem; font-weight: 700;
  padding: 0.2em 0.55em; border-radius: 999px;
  text-align: center;
  background: var(--bg-elevated); color: var(--muted); border: 1px solid var(--border);
}
.stream li.flagged .badge.tp { background: rgba(22,163,74,0.12); color: var(--tp); border-color: rgba(22,163,74,0.3); }
.stream li.flagged .badge.fp { background: rgba(245,158,11,0.15); color: var(--fp); border-color: rgba(245,158,11,0.3); }
.stream li.cleared .badge.fn { background: rgba(220,38,38,0.12); color: var(--fn); border-color: rgba(220,38,38,0.3); }
.stream li.cleared .badge.tn { background: var(--bg-elevated); color: var(--muted); }

/* Footer */
.site-footer { background: var(--bg-soft); border-top: 1px solid var(--border); }
.site-footer .legal { padding: 1rem 0 1.5rem; font-size: 0.8rem; color: var(--muted); border-top: 1px solid var(--border); }
.footlist { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.footlist li a { display: block; padding: 0.2rem 0; color: var(--muted); font-size: 0.9rem; }
.footlist li a:hover { color: var(--brand); }
