:root {
  --navy-950: #0b1524;
  --navy-900: #0f1e33;
  --navy-800: #16283f;
  --navy-700: #1f3557;
  --navy-100: #e7ecf4;
  --gold-500: #c9a24b;
  --gold-400: #d9b968;
  --teal-500: #2f8f83;
  --green-600: #2e8b57;
  --red-600: #c94b4b;
  --ink-900: #10151f;
  --ink-600: #4b5566;
  --ink-400: #8a93a3;
  --paper-0: #ffffff;
  --paper-50: #f6f7fa;
  --paper-100: #eef0f4;
  --border: #e2e5eb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 21, 31, 0.04), 0 8px 24px rgba(16, 21, 31, 0.06);
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper-50);
  color: var(--ink-900);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

/* ---------- Top bar ---------- */
.topbar {
  background: linear-gradient(135deg, var(--navy-950), var(--navy-800));
  color: var(--navy-100);
  padding: 28px 0;
  margin-bottom: 32px;
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 4px;
}

.brand-subtitle {
  font-size: 14px;
  color: #aab8cc;
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(201, 162, 75, 0.15);
  border: 1px solid rgba(201, 162, 75, 0.4);
  color: var(--gold-400);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 4px 10px;
}

.lang-btn {
  background: none;
  border: none;
  color: #aab8cc;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
}
.lang-btn:hover { color: var(--navy-100); }
.lang-btn.active { color: var(--gold-400); }

.lang-sep {
  color: rgba(255, 255, 255, 0.25);
  font-size: 12px;
}

.back-link {
  color: #aab8cc;
  text-decoration: none;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}
.back-link:hover { color: var(--navy-100); }

/* ---------- Section headings ---------- */
h2.section-title {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-600);
  margin: 40px 0 16px;
}
h2.section-title:first-of-type { margin-top: 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--paper-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.total-card {
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.total-label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-400);
  margin: 0 0 6px;
}

.total-value {
  font-size: 40px;
  font-weight: 700;
  color: var(--navy-900);
  margin: 0;
  font-variant-numeric: tabular-nums;
}

.bu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.bu-card {
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--paper-0);
}

.bu-name {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-400);
  margin: 0 0 8px;
}

.bu-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy-900);
  margin: 0 0 10px;
  font-variant-numeric: tabular-nums;
}

.bu-bar-track {
  height: 6px;
  border-radius: 999px;
  background: var(--paper-100);
  overflow: hidden;
}
.bu-bar-fill { height: 100%; border-radius: 999px; }
.bu-bank .bu-bar-fill { background: var(--teal-500); }
.bu-securities .bu-bar-fill { background: var(--gold-500); }
.bu-insurance .bu-bar-fill { background: var(--navy-700); }

.bu-pct {
  font-size: 12px;
  color: var(--ink-400);
  margin-top: 6px;
}

/* ---------- Table ---------- */
table.customer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.customer-table thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-400);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.customer-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.customer-table tbody tr:last-child td { border-bottom: none; }

.customer-row {
  cursor: pointer;
  transition: background 0.12s ease;
}
.customer-row:hover { background: var(--paper-50); }

.cust-name {
  font-weight: 600;
  color: var(--navy-900);
}

.segment-pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--paper-100);
  color: var(--ink-600);
}

.risk-pill.risk-Low { color: var(--green-600); }
.risk-pill.risk-Medium { color: var(--gold-500); }
.risk-pill.risk-High { color: var(--red-600); }
.risk-pill { font-weight: 600; font-size: 13px; }

.amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.chev { color: var(--ink-400); text-align: right; width: 24px; }

.opp-table .opp-signal {
  font-variant-numeric: tabular-nums;
  color: var(--ink-600);
  white-space: nowrap;
}
.opp-table .opp-note { color: var(--ink-600); font-size: 13px; }

.how-built-list li strong { color: var(--navy-900); }

.insight-list {
  list-style: none;
  margin: 0;
  padding: 20px 24px;
  font-size: 14px;
  color: var(--ink-600);
}
.insight-list li { padding: 6px 0; }
.insight-list li:not(:last-child) { border-bottom: 1px dashed var(--border); }

/* ---------- Data & SQL ---------- */
details.sql-block {
  background: var(--paper-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  margin-bottom: 32px;
}

details.sql-block summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  color: var(--navy-900);
  list-style: none;
}
details.sql-block summary::-webkit-details-marker { display: none; }
details.sql-block summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--gold-500);
  transition: transform 0.15s ease;
}
details.sql-block[open] summary::before { transform: rotate(90deg); }

.erd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  color: var(--ink-600);
  background: var(--paper-50);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 16px 0 24px;
  white-space: pre;
  overflow-x: auto;
}

.query-block { margin-top: 20px; }
.query-block:first-of-type { margin-top: 20px; }
.query-title { font-weight: 600; font-size: 14px; color: var(--navy-900); margin: 0 0 4px; }
.query-desc { font-size: 13px; color: var(--ink-600); margin: 0 0 8px; }

pre.sql {
  background: var(--navy-950);
  color: #d6e2f0;
  padding: 14px 18px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin: 0;
}
.sql .kw { color: #7fb0ff; }
.sql .fn { color: #d9b968; }
.sql .cm { color: #7f8ba3; }

/* ---------- Detail page ---------- */
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.detail-name { font-size: 26px; font-weight: 700; color: var(--navy-900); margin: 0 0 6px; }
.detail-meta { font-size: 14px; color: var(--ink-600); }
.detail-meta .risk-pill { margin-left: 8px; }

.breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-row .amt { font-weight: 600; }

.txn-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.txn-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-400); padding: 10px 12px; border-bottom: 1px solid var(--border);
}
.txn-table td { padding: 12px; border-bottom: 1px solid var(--border); }
.txn-table tr:last-child td { border-bottom: none; }
.txn-currency { color: var(--ink-400); font-size: 12px; margin-left: 4px; }

.insight-box {
  padding: 20px 24px;
  border-left: 3px solid var(--gold-500);
}
.insight-box .kicker {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--gold-500); margin: 0 0 8px;
}
.insight-box p { margin: 0; font-size: 14px; color: var(--ink-900); }
.insight-box.followup { border-left-color: var(--teal-500); }
.insight-box.followup .kicker { color: var(--teal-500); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ---------- Footer / disclaimer ---------- */
.disclaimer {
  margin-top: 48px;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--paper-100);
  color: var(--ink-400);
  font-size: 12.5px;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .bu-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .total-value { font-size: 32px; }
  .customer-table thead { display: none; }
  .customer-table, .customer-table tbody, .customer-table tr, .customer-table td { display: block; width: 100%; }
  .customer-table tr { padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .customer-table td { border-bottom: none; padding: 3px 0; }
  .amt { text-align: left; }
  .chev { display: none; }
  .txn-table thead { display: none; }
  .txn-table, .txn-table tbody, .txn-table tr, .txn-table td { display: block; width: 100%; }
  .txn-table tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .txn-table td { border-bottom: none; padding: 2px 0; }
}
