/* ---------- tokens ---------- */
:root {
  --bg: #FAFAF7;
  --card: #FFFFFF;
  --border: #ECECE6;
  --border-strong: #E2E2DC;
  --text: #1A1A19;
  --text-2: #5B5B57;
  --text-3: #8A8A85;
  --muted-bg: #F4F4F0;

  --good: #2FA84F;
  --good-bg: #E6F4EA;
  --good-text: #1F7A3A;

  --watch: #F0B429;
  --watch-bg: #FFF4D6;
  --watch-text: #8A5A0B;

  --risk: #E04A3F;
  --risk-bg: #FCE3E1;
  --risk-text: #A33126;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 0 rgba(0,0,0,0.02);

  --rail-w: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 100vh;
}

/* ---------- left rail ---------- */
.rail {
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
}
.logo {
  width: 32px; height: 32px;
  background: #111;
  color: #fff;
  border-radius: 8px;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 18px;
}
.rail-nav, .rail-bottom {
  display: flex; flex-direction: column; gap: 4px;
}
.rail-btn {
  width: 32px; height: 32px;
  border: none; background: transparent;
  border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-2);
  padding: 0;
}
.rail-btn svg { width: 18px; height: 18px; }
.rail-btn.is-active { background: var(--muted-bg); color: var(--text); }

/* ---------- main ---------- */
.main {
  padding: 0 24px 32px;
  min-width: 0;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tabs { display: flex; gap: 22px; height: 100%; align-items: center; }
.tab {
  font-size: 13px;
  color: var(--text-2);
  height: 100%;
  display: flex;
  align-items: center;
  position: relative;
  cursor: pointer;
}
.tab:first-child { font-size: 16px; font-weight: 600; color: var(--text); }
.tab.is-active {
  color: var(--text);
  font-weight: 600;
}
.tab.is-active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: #111;
}
.period {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2);
  font-size: 12.5px;
}
.period svg { width: 14px; height: 14px; }

/* ---------- KPI strip ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px 12px;
  box-shadow: var(--shadow);
}
.kpi-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 500;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.kpi-value-good { color: var(--good-text); }
.kpi-suffix { font-size: 13px; color: var(--text-3); font-weight: 500; }
.kpi-delta {
  font-size: 11.5px;
  margin-top: 6px;
  color: var(--text-3);
}
.delta-up { color: var(--good-text); }
.delta-down { color: var(--risk-text); }
.delta-flat { color: var(--text-3); }

/* ---------- body grid ---------- */
.body-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 348px;
  gap: 14px;
  margin-bottom: 14px;
}

/* ---------- generic card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 16px 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 2px;
}
.card-sub {
  font-size: 11.5px;
  color: var(--text-3);
  margin: 0;
}
.card-title-row {
  display: flex; align-items: center; gap: 6px;
}
.card-title-sm {
  font-size: 13px;
  font-weight: 600;
  margin: 0;
}
.card-icon { width: 14px; height: 14px; color: var(--text-2); }
.see-all {
  font-size: 11.5px;
  color: var(--text-3);
  cursor: pointer;
}

/* ---------- chart card ---------- */
.chart-card { display: flex; flex-direction: column; }
.chart-legend {
  display: flex; gap: 12px;
  margin: 0; padding: 0;
  list-style: none;
  font-size: 11.5px;
  color: var(--text-2);
}
.chart-legend li { display: inline-flex; align-items: center; gap: 5px; }
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 2px;
}
.dot-good  { background: var(--good); }
.dot-watch { background: var(--watch); }
.dot-risk  { background: var(--risk); }
.chart-wrap {
  padding: 4px 12px 14px;
  height: 260px;
}

/* ---------- right column ---------- */
.side-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.side-card { padding-bottom: 16px; }
.side-card .card-header { padding: 16px 18px 12px; }

.donut-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 4px 18px 14px;
}
.donut-wrap {
  position: relative;
  width: 104px; height: 104px;
  flex-shrink: 0;
}
.donut-wrap canvas { width: 104px !important; height: 104px !important; }
.donut-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  pointer-events: none;
}
.donut-num { font-size: 22px; font-weight: 700; line-height: 1; color: var(--text); }
.donut-lbl { font-size: 10.5px; color: var(--text-3); margin-top: 3px; }

.legend-list {
  list-style: none;
  margin: 0; padding: 0;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}
.legend-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 8px;
  color: var(--text);
}
.legend-list li.li-risk  { background: #FCE9E6; }
.legend-list li.li-watch { background: #FFF3D6; }
.legend-list li.li-good  { background: #E6F4E6; }
.legend-list .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legend-list b {
  color: var(--text);
  font-weight: 700;
  font-size: 14px;
  min-width: 18px;
  display: inline-block;
}
.legend-list .lbl { color: var(--text-2); }

/* ---------- sub-section (biggest accounts) ---------- */
.sub-section {
  border-top: 1px solid var(--border);
  padding: 10px 16px 4px;
}
.sub-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 8px;
}
.account-mini {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 8px;
}
.account-mini li {
  display: grid;
  grid-template-columns: 22px 1fr auto auto;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.acc-name { font-weight: 500; }
.acc-amount { color: var(--text-2); font-size: 11.5px; }

/* ---------- avatar ---------- */
.avatar {
  width: 22px; height: 22px;
  border-radius: 6px;
  display: grid; place-items: center;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.avatar-lg {
  width: 28px; height: 28px;
  border-radius: 7px;
  font-size: 10.5px;
}

/* ---------- pills ---------- */
.pill {
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill-good  { background: var(--good-bg); color: var(--good-text); }
.pill-watch { background: var(--watch-bg); color: var(--watch-text); }
.pill-risk  { background: var(--risk-bg); color: var(--risk-text); }

/* ---------- card footer note ---------- */
.card-footer-note {
  margin: 6px 16px 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-2);
}
.card-footer-note b { color: var(--text); font-weight: 600; }

/* ---------- table ---------- */
.table-card { overflow: hidden; }
.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.table-title { font-size: 13px; }
.t-strong { font-weight: 600; }
.t-muted { color: var(--text-3); margin-left: 4px; }
.table-actions {
  display: flex; gap: 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--card);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 11.5px;
  color: var(--text);
  font-weight: 500;
}
.btn svg { width: 13px; height: 13px; color: var(--text-2); }

.clients {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.clients thead th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-3);
  text-transform: uppercase;
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.clients tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.clients tbody tr:last-child td { border-bottom: none; }

.ta-center { text-align: center; }
.ta-right  { text-align: right; }

.name-cell {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: center;
}
.name-main { font-weight: 600; font-size: 12.5px; }
.name-sub  { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.status-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
}
.s-good  { background: var(--good); }
.s-watch { background: var(--watch); }
.s-risk  { background: var(--risk); }
.s-open  {
  background: transparent;
  border: 1.5px solid var(--border-strong);
}

.amount { font-variant-numeric: tabular-nums; color: var(--text); }
.dash { color: var(--text-3); }

.table-footer {
  padding: 12px 16px;
  font-size: 11.5px;
  color: var(--text-3);
  border-top: 1px solid var(--border);
}
.link { color: var(--text); font-weight: 500; text-decoration: underline; text-underline-offset: 2px; }
