:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page-plane: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --diverging-pos: #2a78d6;
  --diverging-neg: #e34948;
  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--page-plane);
  color: var(--text-primary);
}

a { color: inherit; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}

.topbar .brand { font-weight: 600; font-size: 16px; }

.topbar nav { display: flex; gap: 18px; }

.topbar nav a {
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 14px;
  padding: 6px 2px;
  border-bottom: 2px solid transparent;
}

.topbar nav a.active {
  color: var(--text-primary);
  border-bottom-color: var(--diverging-pos);
  font-weight: 600;
}

.topbar form { margin: 0; }

.topbar button.link-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  font-family: var(--font-sans);
}

main { max-width: 1180px; margin: 0 auto; padding: 24px; }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.card + .card { margin-top: 20px; }

.card h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 14px 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.filters-row {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filters-row label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.filters-row input, .filters-row select {
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 7px 10px;
  border: 1px solid var(--baseline);
  border-radius: 6px;
  background: var(--surface-1);
  color: var(--text-primary);
}

.filters-row button {
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 8px 16px;
  border: 1px solid var(--diverging-pos);
  background: var(--diverging-pos);
  color: #fff;
  border-radius: 6px;
  cursor: pointer;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}

.stat-tile .label { font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }

.stat-tile .value {
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: proportional-nums;
}

.stat-tile .delta { font-size: 13px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.stat-tile .delta.good { color: var(--good); }
.stat-tile .delta.critical { color: var(--critical); }

.business-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.business-tile {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.business-tile::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--tile-color, var(--text-muted));
}

.business-tile .biz-name { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.business-tile .biz-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); margin-top: 2px; }
.business-tile .biz-row .amt { font-variant-numeric: tabular-nums; color: var(--text-primary); }
.business-tile .biz-row .amt.net-good { color: var(--good); }
.business-tile .biz-row .amt.net-critical { color: var(--critical); }

.alert-banner {
  background: #fff8e6;
  border: 1px solid var(--warning);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

table.txn-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.txn-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
}
table.txn-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}
table.txn-table td.desc { font-variant-numeric: normal; max-width: 340px; }
table.txn-table td.amt-debit { color: var(--critical); text-align: right; }
table.txn-table td.amt-credit { color: var(--good); text-align: right; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--page-plane);
  border: 1px solid var(--border);
}

.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot-color, var(--text-muted)); }

.dup-row { opacity: 0.5; }

.login-wrap {
  max-width: 360px;
  margin: 12vh auto;
}

.login-wrap input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  border: 1px solid var(--baseline);
  border-radius: 6px;
  margin-bottom: 12px;
}

.login-wrap button {
  width: 100%;
  padding: 10px 12px;
  background: var(--diverging-pos);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.error-text { color: var(--critical); font-size: 13px; margin-bottom: 10px; }

.chart-wrap { position: relative; height: 320px; }
.chart-wrap.short { height: 260px; }

.pager { display: flex; gap: 10px; align-items: center; font-size: 13px; margin-top: 14px; }
.pager a { color: var(--diverging-pos); text-decoration: none; }

select.inline-select {
  font-family: var(--font-sans);
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--baseline);
  border-radius: 5px;
}
