:root {
  color-scheme: light only;
  --canvas: #ffffff;
  --bg-snow: #f7f8fa;
  --cloud-gray: #eaeaf1;
  --border-fog: #dfdfe9;
  --muted-ash: #9e9fb7;
  --stone-gray: #6d6e87;
  --dark-charcoal: #484960;
  --midnight-ink: #181822;
  --deep-plum: #260048;
  --vanta-purple: #5e05c4;
  --royal-violet: #8f47d5;
  --misty-lavender: #ddd6ff;
  --sky-lavender: #cdd2f8;
  --soft-pink: #fbd9eb;
  --logo-gradient: linear-gradient(135deg, #d068b8 0%, #8f47d5 50%, #5e05c4 100%);
  --teal-accent: #4ec5d4;
  --green-pos: #1a8a3f;
  --amber: #d97706;
  --amber-bg: rgba(217, 119, 6, 0.10);
  --red-neg: #c8302c;
  --shadow-sm: 0 1px 2px rgba(24, 24, 34, 0.04);
  --shadow-md: 0 4px 16px rgba(24, 24, 34, 0.06);
  --shadow-lg: 0 12px 40px rgba(24, 24, 34, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { background: var(--bg-snow); overflow-x: hidden; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color: var(--midnight-ink);
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: -0.015em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
em {
  font-family: 'Playfair Display', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.025em;
  color: var(--vanta-purple);
}

/* ===== APP SHELL ===== */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  background: var(--canvas);
  border-right: 1px solid var(--border-fog);
  padding: 28px 20px 24px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  display: block;
  padding: 0 8px 28px;
  border-bottom: 1px solid var(--border-fog);
  margin-bottom: 24px;
}
.sidebar .brand img { height: 32px; width: auto; display: block; }
.sidebar nav { flex: 1; }
.sidebar .group-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-ash);
  padding: 0 12px 10px;
}
.sidebar ul { list-style: none; }
.sidebar li { margin-bottom: 2px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--dark-charcoal);
  text-decoration: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.sidebar nav a:hover { background: var(--bg-snow); color: var(--vanta-purple); }
.sidebar nav a.active {
  background: var(--misty-lavender);
  color: var(--deep-plum);
  font-weight: 600;
}
.sidebar nav a.active .ico { color: var(--vanta-purple); }
.sidebar .ico {
  font-size: 12px;
  color: var(--muted-ash);
  width: 16px;
  text-align: center;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-snow);
  border-radius: 10px;
  margin-top: 20px;
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--logo-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--midnight-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 11px;
  color: var(--stone-gray);
  text-transform: capitalize;
}
.user-card .logout {
  color: var(--muted-ash);
  text-decoration: none;
  font-size: 16px;
  padding: 4px;
  border-radius: 6px;
}
.user-card .logout:hover { color: var(--vanta-purple); background: white; }

/* ===== MAIN ===== */
main {
  padding: 36px 48px;
  max-width: 1400px;
  width: 100%;
}
.flash {
  padding: 12px 16px;
  background: var(--soft-pink);
  border: 1px solid #f0a5cc;
  color: #8a1747;
  border-radius: 10px;
  margin-bottom: 20px;
  font-size: 14px;
}

/* ===== PAGE HEAD ===== */
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 32px;
}
.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-ash);
  margin-bottom: 8px;
}
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { color: var(--vanta-purple); }
.page-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 38px;
  font-weight: 500;
  color: var(--deep-plum);
  letter-spacing: -0.025em;
  line-height: 1.1;
  margin-bottom: 6px;
}
.page-title em {
  font-style: italic;
  background: var(--logo-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.page-sub {
  font-size: 15px;
  color: var(--stone-gray);
  font-weight: 400;
}
.page-actions { display: flex; gap: 12px; align-items: center; }
.sync-indicator {
  font-size: 12px;
  color: var(--muted-ash);
  padding: 6px 12px;
  background: var(--canvas);
  border: 1px solid var(--border-fog);
  border-radius: 100px;
  font-family: 'JetBrains Mono', monospace;
}
/* ===== KPI GRID ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.kpi-card {
  background: var(--canvas);
  border: 1px solid var(--border-fog);
  border-radius: 14px;
  padding: 20px;
  transition: all 0.2s;
}
.kpi-card:hover { box-shadow: var(--shadow-md); border-color: var(--cloud-gray); }
.kpi-card.kpi-hero {
  background: linear-gradient(135deg, var(--misty-lavender) 0%, var(--canvas) 100%);
  border-color: var(--sky-lavender);
}
.kpi-card.kpi-warn {
  background: linear-gradient(135deg, var(--soft-pink) 0%, var(--canvas) 100%);
  border-color: #f0c6dc;
}
.kpi-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--stone-gray);
  margin-bottom: 8px;
}
.kpi-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 28px;
  font-weight: 500;
  color: var(--deep-plum);
  letter-spacing: -0.025em;
  margin-bottom: 6px;
  line-height: 1.1;
}
.kpi-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--stone-gray);
}
.kpi-meta .dot {
  width: 6px; height: 6px;
  background: var(--vanta-purple);
  border-radius: 50%;
}
.kpi-meta .dot.positive { background: var(--green-pos); }
.kpi-meta .dot.negative { background: var(--red-neg); }

/* ===== ROW & CARD ===== */
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.card {
  background: var(--canvas);
  border: 1px solid var(--border-fog);
  border-radius: 14px;
  padding: 24px;
  overflow: hidden;
}
.card.card-flush { padding: 0; }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 0;
}
.card.card-flush .card-head { padding: 24px 24px 18px; margin-bottom: 0; }
.card-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 20px;
  font-weight: 500;
  color: var(--deep-plum);
  letter-spacing: -0.02em;
}
.card-link {
  font-size: 13px;
  color: var(--vanta-purple);
  text-decoration: none;
  font-weight: 500;
}
.card-link:hover { color: var(--royal-violet); }
.card-meta {
  font-size: 12px;
  color: var(--stone-gray);
  font-family: 'JetBrains Mono', monospace;
}

/* ===== DATA TABLE ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-ash);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-fog);
  background: var(--bg-snow);
}
.card.card-flush .data-table thead th:first-child { padding-left: 24px; }
.card.card-flush .data-table thead th:last-child { padding-right: 24px; }
.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-fog);
  vertical-align: top;
}
.card.card-flush .data-table tbody td:first-child { padding-left: 24px; }
.card.card-flush .data-table tbody td:last-child { padding-right: 24px; }
.data-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
.data-table tbody tr:hover { background: var(--bg-snow); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.deal-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--midnight-ink);
}
.deal-order {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--muted-ash);
  margin-top: 2px;
}
.merchant-name {
  font-weight: 500;
  color: var(--midnight-ink);
}
.merchant-contact {
  font-size: 12px;
  color: var(--stone-gray);
  margin-top: 2px;
}
.freq {
  font-size: 11px;
  color: var(--stone-gray);
  margin-top: 2px;
  text-transform: capitalize;
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  white-space: nowrap;
}
.badge-large { padding: 8px 18px; font-size: 14px; }
.badge-active { background: rgba(26, 138, 63, 0.10); color: var(--green-pos); }
.badge-paid_off { background: var(--misty-lavender); color: var(--deep-plum); }
.badge-defaulted { background: rgba(200, 48, 44, 0.10); color: var(--red-neg); }
.badge-adjustment { background: var(--sky-lavender); color: var(--deep-plum); }

/* ===== FILTER CHIPS ===== */
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.chip {
  padding: 8px 16px;
  background: var(--canvas);
  border: 1px solid var(--border-fog);
  border-radius: 100px;
  font-size: 13px;
  font-weight: 500;
  color: var(--dark-charcoal);
  text-decoration: none;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--vanta-purple); color: var(--vanta-purple); }
.chip.active {
  background: var(--vanta-purple);
  border-color: var(--vanta-purple);
  color: white;
}

/* ===== ACTIVITY & TX LIST ===== */
.activity-list, .tx-list {
  list-style: none;
}
.activity-list li, .tx-list li {
  display: grid;
  grid-template-columns: 70px 32px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-fog);
}
.activity-list li:last-child, .tx-list li:last-child { border-bottom: none; }
.activity-date, .tx-date {
  font-size: 12px;
  color: var(--stone-gray);
  font-family: 'JetBrains Mono', monospace;
}
.activity-icon, .tx-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.activity-icon.positive, .tx-icon.positive {
  background: rgba(26, 138, 63, 0.12);
  color: var(--green-pos);
}
.activity-icon.negative, .tx-icon.negative {
  background: rgba(200, 48, 44, 0.12);
  color: var(--red-neg);
}
.activity-icon.neutral, .tx-icon.neutral {
  background: var(--cloud-gray);
  color: var(--stone-gray);
}
.activity-body, .tx-body { min-width: 0; }
.activity-title, .tx-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--midnight-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-meta, .tx-meta {
  font-size: 11px;
  color: var(--stone-gray);
  margin-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}
.activity-amount, .tx-amount {
  font-size: 14px;
  font-weight: 600;
  color: var(--midnight-ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tx-list-wrap { max-height: 480px; overflow-y: auto; }

/* ===== STAT LIST ===== */
.stat-list { list-style: none; }
.stat-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-fog);
}
.stat-list li:last-child { border-bottom: none; }
.stat-label { font-size: 14px; color: var(--stone-gray); }
.stat-value {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--deep-plum);
}
.stat-warn { color: var(--red-neg); }

/* ===== EMPTY STATE ===== */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--stone-gray);
}
.empty-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(26, 138, 63, 0.10);
  color: var(--green-pos);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 16px;
}
.empty p { font-size: 16px; }

/* ===== CHART ===== */
.chart-wrap { position: relative; height: 280px; }
.chart-tall { height: 360px; }

/* ===== LOGIN ===== */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 24px;
}
.login-bg {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, var(--misty-lavender) 0%, rgba(221, 214, 255, 0.3) 60%, var(--canvas) 100%);
  z-index: -1;
}
.login-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center top, rgba(143, 71, 213, 0.18), transparent 60%);
}
.login-card {
  background: var(--canvas);
  border: 1px solid var(--border-fog);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  display: block;
  margin-bottom: 28px;
  text-align: center;
}
.login-brand img { height: 44px; }
.login-title {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 32px;
  font-weight: 500;
  color: var(--deep-plum);
  letter-spacing: -0.025em;
  text-align: center;
  margin-bottom: 6px;
}
.login-title em {
  font-style: italic;
  background: var(--logo-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.login-sub {
  text-align: center;
  color: var(--stone-gray);
  font-size: 14px;
  margin-bottom: 28px;
}
.login-error {
  background: var(--soft-pink);
  border: 1px solid #f0a5cc;
  color: #8a1747;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 20px;
  text-align: center;
}
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; }
.login-form span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--stone-gray);
}
.login-form input {
  padding: 12px 14px;
  border: 1px solid var(--border-fog);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--midnight-ink);
  background: var(--bg-snow);
  transition: all 0.15s;
}
.login-form input:focus {
  outline: none;
  border-color: var(--vanta-purple);
  background: var(--canvas);
  box-shadow: 0 0 0 3px rgba(94, 5, 196, 0.08);
}
.login-form button {
  padding: 14px;
  background: var(--vanta-purple);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  margin-top: 8px;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.login-form button:hover { background: #4d04a3; transform: translateY(-1px); }
.login-form .arrow { transition: transform 0.2s; }
.login-form button:hover .arrow { transform: translateX(2px); }
.login-foot {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--muted-ash);
  display: flex;
  justify-content: center;
  gap: 8px;
}
.login-foot .dot { color: var(--cloud-gray); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px) {
  .row { grid-template-columns: 1fr; }
  main { padding: 28px 32px; }
}
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  main { padding: 20px; }
  .page-title { font-size: 28px; }
  .kpi-value { font-size: 24px; }
}

/* Amber state for Behind / NSF Risk */
.badge-behind { background: var(--amber-bg); color: var(--amber); }
.badge-nsf { background: var(--amber-bg); color: var(--amber); font-weight: 600; }

/* ===== % PAID BAR ===== */
.pct-cell { min-width: 110px; }
.pct-wrap { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.pct-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--midnight-ink);
  font-variant-numeric: tabular-nums;
}
.pct-bar {
  width: 90px;
  height: 4px;
  background: var(--cloud-gray);
  border-radius: 100px;
  overflow: hidden;
}
.pct-fill {
  height: 100%;
  background: var(--royal-violet);
  border-radius: 100px;
  transition: width 0.3s;
}
.pct-fill.eligible {
  background: var(--logo-gradient);
}

/* ===== MODIFIED BADGE ===== */
.badge-modified {
  background: var(--sky-lavender);
  color: var(--deep-plum);
  font-style: italic;
  font-family: 'Playfair Display', Georgia, serif;
  margin-left: 4px;
}

/* ===== SEARCH ===== */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--canvas);
  border: 1px solid var(--border-fog);
  border-radius: 100px;
  padding: 0 14px;
  transition: all 0.15s;
  min-width: 280px;
}
.search-wrap:focus-within {
  border-color: var(--vanta-purple);
  box-shadow: 0 0 0 3px rgba(94, 5, 196, 0.08);
}
.search-icon {
  color: var(--muted-ash);
  font-size: 16px;
  margin-right: 8px;
  flex-shrink: 0;
}
.search-wrap input {
  flex: 1;
  border: none;
  outline: none;
  padding: 9px 0;
  font-family: inherit;
  font-size: 14px;
  color: var(--midnight-ink);
  background: transparent;
  min-width: 0;
}
.search-wrap input::placeholder { color: var(--muted-ash); }
#search-clear {
  display: none;
  background: var(--cloud-gray);
  color: var(--stone-gray);
  border: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
}
#search-clear:hover { background: var(--vanta-purple); color: white; }
.empty-cell {
  text-align: center !important;
  padding: 60px 20px !important;
  color: var(--stone-gray);
  font-size: 15px;
}

/* ===== MERCURY-STYLE CHART CARD ===== */
.chart-card { padding: 28px; }
.card-head-rich {
  margin-bottom: 24px;
  align-items: flex-start;
}
.card-title-eyebrow {
  font-size: 13px;
  font-weight: 500;
  color: var(--stone-gray);
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.chart-hero-value {
  font-family: 'Inter', sans-serif;
  font-size: 36px;
  font-weight: 600;
  color: var(--midnight-ink);
  letter-spacing: -0.025em;
  line-height: 1;
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}
.chart-hero-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--stone-gray);
  flex-wrap: wrap;
}
.chart-hero-divider {
  color: var(--cloud-gray);
}
.chart-hero-positive {
  color: var(--green-pos);
  font-weight: 500;
}
.chart-hero-pending {
  color: var(--stone-gray);
  font-weight: 500;
}
