/* AML statistics dashboard — self-contained, no dependencies. Matches the onboarding wizard's
   refined compliance-tool aesthetic: deep-slate surfaces, indigo/teal accents, CSS custom props. */
:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --panel-muted: #f8fafc;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #94a3b8;
  --line: #e2e8f0;
  --indigo: #4f46e5;
  --indigo-dark: #4338ca;
  --teal: #0d9488;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 220px, #eef2f7 220px, #eef2f7 100%);
  min-height: 100vh;
}

.shell { max-width: 1100px; margin: 0 auto; padding: 24px 20px 64px; }

/* ---- topbar ---- */
.topbar { display: flex; flex-direction: column; gap: 18px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  background: rgba(255, 255, 255, .1); color: #a5b4fc;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 1.05rem; letter-spacing: .2px; }
.brand-sub { font-size: .8rem; color: #cbd5e1; }

.config-bar {
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 16px; align-items: end;
  background: var(--panel); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .8rem; font-weight: 600; color: var(--ink-soft); }
.field input {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel-muted); color: var(--ink); outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15); }
.hint { font-size: .72rem; color: var(--ink-faint); }
.input-affix { position: relative; display: flex; }
.input-affix input { flex: 1; padding-right: 64px; }
.affix-btn {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: none; background: transparent; color: var(--indigo); font: inherit; font-size: .78rem;
  font-weight: 600; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.affix-btn:hover { background: rgba(79, 70, 229, .08); }
.config-action { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

.btn {
  display: inline-flex; align-items: center; gap: 8px; font: inherit; font-weight: 600;
  border: none; border-radius: 9px; padding: 10px 20px; cursor: pointer; transition: background .15s, transform .05s;
}
.btn.primary { background: var(--indigo); color: #fff; }
.btn.primary:hover { background: var(--indigo-dark); }
.btn.primary:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.spinner {
  width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- content ---- */
.banner { border-radius: 10px; padding: 12px 16px; margin-bottom: 18px; font-size: .9rem; }
.banner.error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

.placeholder {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  background: var(--panel); border-radius: var(--radius); padding: 56px 24px; box-shadow: var(--shadow); color: var(--ink-soft);
}
.placeholder svg { color: var(--indigo); }
.placeholder h1 { margin: 6px 0 0; font-size: 1.3rem; color: var(--ink); }
.placeholder p { margin: 0; max-width: 460px; }

.section { background: var(--panel); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.section-title { margin: 0 0 16px; font-size: 1.05rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.card { background: var(--panel-muted); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.card-label { font-size: .78rem; color: var(--ink-soft); font-weight: 600; }
.card-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.5px; }
.card-sub { font-size: .74rem; color: var(--ink-faint); }

.breakdowns { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-top: 20px; }
.breakdown-title { margin: 0 0 10px; font-size: .82rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .4px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 90px 1fr 56px; align-items: center; gap: 10px; font-size: .85rem; }
.bar-label { color: var(--ink-soft); }
.bar-track { background: #eef2f7; border-radius: 6px; height: 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--indigo); border-radius: 6px; min-width: 2px; }
.bar-fill.is-good { background: var(--good); }
.bar-fill.is-warn { background: var(--warn); }
.bar-fill.is-bad { background: var(--bad); }
.bar-count { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.muted { color: var(--ink-faint); font-size: .85rem; margin: 0; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.data-table thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-soft); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tfoot th, .data-table tfoot td { font-weight: 700; border-bottom: none; border-top: 2px solid var(--line); }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: .85rem; }

@media (max-width: 720px) {
  .config-bar { grid-template-columns: 1fr; }
  .breakdowns { grid-template-columns: 1fr; }
}
