@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg: #FAFAFD;
  --surface: #FFFFFF;
  --surface-sunken: #F4F2FB;
  --border: #E7E3F5;
  --border-strong: #D8D2EF;

  --purple-900: #241A45;
  --purple-700: #4A3494;
  --purple-600: #6C4FD6;
  --purple-500: #8168E8;
  --purple-100: #EFEBFC;

  --text-primary: #1C1830;
  --text-secondary: #6B6580;
  --text-tertiary: #9C97AE;

  --tier-approve: #2F9E6E;
  --tier-approve-bg: #E7F6EF;
  --tier-review: #B8842E;
  --tier-review-bg: #FBF1DF;
  --tier-hold: #C6414F;
  --tier-hold-bg: #FBE7E9;
  --tier-decline: #8A2432;
  --tier-decline-bg: #F5DDE0;

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --shadow-card: 0 1px 2px rgba(36, 26, 69, 0.04), 0 4px 16px rgba(36, 26, 69, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 32px 40px 80px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--purple-600), var(--purple-900));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  box-shadow: var(--shadow-card);
}

.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: 0.01em; color: var(--purple-900); }
.brand-sub { font-size: 12px; color: var(--text-tertiary); font-family: var(--font-mono); }

.mode-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--purple-100);
  color: var(--purple-700);
  border: 1px solid var(--border-strong);
}

.summary-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }

.summary-chip { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px 20px; box-shadow: var(--shadow-card); }
.summary-chip .count { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1; }
.summary-chip .label { margin-top: 6px; font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }
.summary-chip.approve .count { color: var(--tier-approve); }
.summary-chip.review .count { color: var(--tier-review); }
.summary-chip.hold .count { color: var(--tier-hold); }
.summary-chip.decline .count { color: var(--tier-decline); }

.filter-tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.filter-tab { font-size: 13px; font-weight: 500; padding: 8px 14px; border-radius: 999px; color: var(--text-secondary); border: 1px solid var(--border); background: var(--surface); }
.filter-tab.active { background: var(--purple-600); color: white; border-color: var(--purple-600); }

.case-table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-card); }

.case-row {
  display: grid;
  grid-template-columns: 5px 90px 1.4fr 1fr 100px 130px 120px;
  align-items: center;
  gap: 18px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s ease;
}

.case-row:last-child { border-bottom: none; }
.case-row:not(.header-row):hover { background: var(--surface-sunken); cursor: pointer; }

.case-row.header-row { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-tertiary); font-weight: 600; padding-top: 14px; padding-bottom: 14px; }

.tier-bar { width: 5px; align-self: stretch; border-radius: 4px; background: var(--border); }
.tier-bar.auto_approve { background: var(--tier-approve); }
.tier-bar.light_review { background: var(--tier-review); }
.tier-bar.manual_hold { background: var(--tier-hold); }
.tier-bar.auto_decline { background: var(--tier-decline); }

.score-cell { font-family: var(--font-mono); font-weight: 700; font-size: 17px; }
.customer-cell .name { font-weight: 600; font-size: 14.5px; }
.customer-cell .email { font-size: 12.5px; color: var(--text-tertiary); margin-top: 2px; }
.order-cell { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-secondary); }
.amount-cell { font-family: var(--font-mono); font-size: 14px; font-weight: 500; }

.tier-badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.tier-badge.auto_approve { background: var(--tier-approve-bg); color: var(--tier-approve); }
.tier-badge.light_review { background: var(--tier-review-bg); color: var(--tier-review); }
.tier-badge.manual_hold { background: var(--tier-hold-bg); color: var(--tier-hold); }
.tier-badge.auto_decline { background: var(--tier-decline-bg); color: var(--tier-decline); }

.date-cell { font-size: 12.5px; color: var(--text-secondary); }
.empty-state { padding: 64px 20px; text-align: center; color: var(--text-tertiary); font-size: 14px; }

.detail-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; }
.back-link { font-size: 13px; color: var(--text-secondary); font-weight: 500; margin-bottom: 10px; display: inline-block; }
.detail-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; }
.detail-sub { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-tertiary); margin-top: 4px; }

.gauge-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; display: flex; align-items: center; gap: 28px; box-shadow: var(--shadow-card); margin-bottom: 24px; }
.gauge-meta { flex: 1; }
.gauge-meta .rec-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.decision-actions { display: flex; gap: 10px; align-items: center; }

.btn { font-family: var(--font-body); font-weight: 600; font-size: 13.5px; padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; }
.btn-approve { background: var(--tier-approve); color: white; }
.btn-decline { background: var(--tier-decline); color: white; }
.btn-secondary { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-primary); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.action-status { font-size: 12.5px; color: var(--text-secondary); }
.action-status.success { color: var(--tier-approve); }
.action-status.error { color: var(--tier-decline); }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-card); }
.panel h3 { font-family: var(--font-display); font-size: 14px; font-weight: 700; margin: 0 0 14px; color: var(--purple-900); }

.signal-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.signal-row:last-child { border-bottom: none; }
.signal-points { font-family: var(--font-mono); font-weight: 700; font-size: 13px; }
.signal-points.positive { color: var(--tier-approve); }
.signal-points.negative { color: var(--tier-decline); }

.info-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13.5px; border-bottom: 1px solid var(--border); }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-secondary); }
.info-value { font-weight: 500; text-align: right; }

.override-note { background: var(--purple-100); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13px; color: var(--purple-900); margin-bottom: 24px; }
