/* =========================================================
   Praça — Design tokens + base styles
   Stripe/Linear-inspired clean, with subtle neutral palette
   and yellow accent. Both light and dark themes supported.
   ========================================================= */

:root {
  /* Type — defaults; can be swapped via tweaks */
  --font-sans: 'Geist', 'Geist Sans', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'JetBrains Mono', monospace;
  --font-display: var(--font-sans);

  /* Type scale */
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 26px;
  --fs-3xl: 34px;
  --fs-4xl: 48px;

  /* Density — overridden in [data-density] selectors below */
  --d-row: 40px;
  --d-pad-card: 20px;
  --d-pad-cell: 12px 14px;
  --d-gap: 16px;
  --d-section-gap: 28px;

  /* Radii */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-xl: 14px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
}

/* ---------- Light theme ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  --bg: #FBFAF7;            /* warm off-white */
  --bg-elev: #FFFFFF;
  --bg-sunk: #F4F2EC;
  --surface: #FFFFFF;
  --surface-hover: #F7F5F0;
  --border: #ECE9E0;
  --border-strong: #D9D5C8;
  --divider: #F0EDE3;

  --text: #15140E;
  --text-2: #44423A;
  --text-3: #7A7768;
  --text-4: #ACA89A;

  --accent: #F2C200;          /* warm yellow */
  --accent-ink: #1A1500;
  --accent-soft: #FFF4B8;
  --accent-line: #E6B800;

  --positive: #0E8A4A;
  --positive-soft: #DDF4E5;
  --negative: #C8312A;
  --negative-soft: #FBE2E0;

  /* Asset class palette — muted, varied hues */
  --c1: #2B6CB0;   /* gov bonds */
  --c2: #C7522A;   /* equities */
  --c3: #6A4F9C;   /* debentures */
  --c4: #2F855A;   /* foreign */
  --c5: #B59410;   /* swaps */
  --c6: #4A5568;   /* fund quotas */
  --c7: #B2495E;   /* CDB/RDB */
  --c8: #8E8270;   /* cash & others */
  --c9: #0E7C86;   /* derivatives */

  --shadow-sm: 0 1px 2px rgba(20,18,8,.04);
  --shadow-md: 0 4px 18px rgba(20,18,8,.05), 0 1px 2px rgba(20,18,8,.04);
  --shadow-lg: 0 24px 60px rgba(20,18,8,.10), 0 2px 6px rgba(20,18,8,.05);
}

/* ---------- Dark theme ---------- */
[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0C0D0A;
  --bg-elev: #131410;
  --bg-sunk: #08090A;
  --surface: #15171A;
  --surface-hover: #1B1E22;
  --border: #25282B;
  --border-strong: #353A3F;
  --divider: #1E2125;

  --text: #F4F1E8;
  --text-2: #C7C3B6;
  --text-3: #8C8A82;
  --text-4: #5A584F;

  --accent: #FFD60A;
  --accent-ink: #15140E;
  --accent-soft: #2A2400;
  --accent-line: #FFE45C;

  --positive: #2ED186;
  --positive-soft: #08311C;
  --negative: #FF6B62;
  --negative-soft: #311010;

  --c1: #6BA4E5;
  --c2: #EA8C5E;
  --c3: #B196E0;
  --c4: #6FCC9B;
  --c5: #E5C148;
  --c6: #8FA0B3;
  --c7: #E0879D;
  --c8: #C8BCA6;
  --c9: #38BDC8;   /* derivatives */

  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 18px rgba(0,0,0,.4);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.55);
}

/* ---------- Density variants ---------- */
[data-density="compact"] {
  --d-row: 32px;
  --d-pad-card: 14px;
  --d-pad-cell: 7px 10px;
  --d-gap: 12px;
  --d-section-gap: 20px;
  --fs-base: 12px;
  --fs-md: 13px;
}
[data-density="comfortable"] {
  --d-row: 40px;
  --d-pad-card: 20px;
  --d-pad-cell: 11px 14px;
  --d-gap: 16px;
  --d-section-gap: 28px;
}
[data-density="spacious"] {
  --d-row: 52px;
  --d-pad-card: 28px;
  --d-pad-cell: 16px 18px;
  --d-gap: 22px;
  --d-section-gap: 40px;
  --fs-base: 14px;
  --fs-md: 15px;
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: -0.005em;
  min-height: 100vh;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font: inherit; color: inherit; }

::selection { background: var(--accent); color: var(--accent-ink); }

.mono { font-family: var(--font-mono); font-feature-settings: 'tnum', 'zero', 'ss03'; letter-spacing: -0.01em; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- App layout shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w, 230px) 1fr;
  min-height: 100vh;
  transition: grid-template-columns .25s var(--ease);
}
.app[data-sidebar="collapsed"] { --sidebar-w: 64px; }

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in oklab, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
}

.page {
  padding: 28px 32px 80px;
  max-width: 1480px;
  width: 100%;
}

/* ---------- Sidebar ---------- */
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-brand {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-mark {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar-brand .brand-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.sidebar-brand .brand-suffix {
  font-size: 10.5px;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-left: auto;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.nav {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.nav-group-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-4);
  padding: 14px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s var(--ease), color .12s var(--ease);
  white-space: nowrap;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active {
  background: var(--surface-hover);
  color: var(--text);
}
.nav-item.active .nav-item-dot { background: var(--accent); }
.nav-item-icon {
  width: 16px; height: 16px;
  display: grid; place-items: center;
  color: var(--text-3);
  flex-shrink: 0;
}
.nav-item.active .nav-item-icon { color: var(--text); }
.nav-kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-4);
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--c3), var(--c1));
  display: grid; place-items: center;
  color: white;
  font-weight: 600;
  font-size: 11px;
  flex-shrink: 0;
}

.app[data-sidebar="collapsed"] .nav-item-label,
.app[data-sidebar="collapsed"] .nav-kbd,
.app[data-sidebar="collapsed"] .nav-group-label,
.app[data-sidebar="collapsed"] .brand-name,
.app[data-sidebar="collapsed"] .brand-suffix,
.app[data-sidebar="collapsed"] .user-meta { display: none; }
.app[data-sidebar="collapsed"] .nav-item { justify-content: center; }
.app[data-sidebar="collapsed"] .sidebar-brand { justify-content: center; padding: 0; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--d-pad-card);
}
.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head > div:first-child { min-width: 0; flex: 1; }
.card-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-head .row, .card-head .seg { flex-shrink: 0; }
.card-link { flex-shrink: 0; white-space: nowrap; }
.card-sub {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
}
.card-link {
  font-size: 11.5px;
  color: var(--text-3);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.card-link:hover { color: var(--text); }

/* Flush card: body content (e.g. tables) goes edge-to-edge, but the header
   keeps the normal card padding so the title never touches the border. */
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-head { padding: var(--d-pad-card) var(--d-pad-card) 0; }

/* ---------- Expandable chart cards + modal ---------- */
.btn.icon-only { padding: 6px; min-width: 0; }
/* The whole card is the click target (open the expanded popup). Interactive controls
   inside the header stop propagation so they keep working. */
.chart-card { cursor: zoom-in; transition: border-color .12s ease, box-shadow .12s ease; }
.chart-card:hover { border-color: var(--text-4); box-shadow: var(--shadow-sm, 0 2px 10px rgba(20,18,8,.06)); }
.chart-card .seg button, .chart-card .btn { cursor: pointer; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(12, 12, 16, 0.46);
  backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  padding: clamp(12px, 4vw, 44px);
  animation: modal-fade .14s ease;
}
.modal-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: min(1200px, 95vw); max-height: 90vh;
  display: flex; flex-direction: column;
  padding: 22px 24px;
  animation: modal-pop .16s cubic-bezier(.2,.8,.3,1);
}
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.modal-body { margin-top: 18px; overflow: auto; flex: 1; min-height: 0; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: scale(.985) translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- KPI / Stat ---------- */
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-label {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.25;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.stat-value .unit {
  font-size: 12px;
  color: var(--text-3);
  margin-left: 4px;
  font-weight: 400;
}
.stat-foot {
  font-size: 11.5px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-foot > * { white-space: nowrap; }
.delta { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
.delta.pos { color: var(--positive); }
.delta.neg { color: var(--negative); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-2);
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.badge.dot::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.badge.pos { color: var(--positive); background: var(--positive-soft); border-color: transparent; }
.badge.neg { color: var(--negative); background: var(--negative-soft); border-color: transparent; }
.badge.accent { color: var(--accent-ink); background: var(--accent); border-color: transparent; font-weight: 600; }
.badge.outline { background: transparent; }

/* ---------- Table ---------- */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}
.tbl th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
}
.tbl td {
  padding: var(--d-pad-cell);
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr:hover td { background: var(--surface-hover); }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl .rank { color: var(--text-4); font-family: var(--font-mono); width: 24px; }
.tbl .ellipsis { max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 500;
  transition: background .12s, color .12s, border-color .12s;
}
.btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent-line); }
.btn.primary:hover { background: var(--accent-line); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-hover); }
.btn.sm { padding: 5px 9px; font-size: 11.5px; }
.btn.icon { padding: 6px; }

.input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 25%, transparent);
}
.input input {
  border: 0; outline: 0; background: transparent;
  flex: 1; min-width: 0;
  font-size: 13px;
}
.input input::placeholder { color: var(--text-4); }
.input .kbd-hint {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-4);
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  margin-left: auto;
}

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex;
  background: var(--bg-sunk);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 2px;
  gap: 1px;
}
.seg button {
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: 5px;
  color: var(--text-3);
  font-weight: 500;
  transition: all .12s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ---------- Page header ---------- */
.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--divider);
}
.page-head .eyebrow {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.btn { white-space: nowrap; }
.page-head h1 {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.1;
  color: var(--text);
}
.page-head .lede {
  margin-top: 8px;
  color: var(--text-3);
  font-size: 13px;
  max-width: 64ch;
  line-height: 1.45;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ---------- Grids ---------- */
.grid-12 { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--d-gap); }
.col-3 { grid-column: span 3; }
.col-4 { grid-column: span 4; }
.col-5 { grid-column: span 5; }
.col-6 { grid-column: span 6; }
.col-7 { grid-column: span 7; }
.col-8 { grid-column: span 8; }
.col-9 { grid-column: span 9; }
.col-12 { grid-column: span 12; }

.section { margin-top: var(--d-section-gap); }
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-head h2 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--text);
}
.section-head p { margin: 0; color: var(--text-3); font-size: 12px; }

/* ---------- Hero KPI strip ---------- */
.kpi-strip {
  display: grid;
  grid-template-columns: 1.7fr repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--surface);
}
.kpi-strip .kpi {
  padding: 20px 20px;
  border-right: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.kpi-strip .kpi .stat-label {
  min-height: 26px;
  align-items: flex-start;
}
.kpi-strip .kpi .stat-foot {
  margin-top: auto;
}
.kpi-strip .kpi:last-child { border-right: 0; }
.kpi-strip .kpi.lead {
  background: linear-gradient(180deg, color-mix(in oklab, var(--accent) 14%, var(--surface)), var(--surface));
}
.kpi-strip .kpi.lead .stat-value { font-size: 36px; }
.kpi-strip .kpi .stat-value { font-size: 22px; }

/* ---------- Donut / asset composition ---------- */
.asset-bar {
  display: flex;
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-sunk);
  margin: 10px 0 18px;
}
.asset-bar .seg-fill {
  height: 100%;
  transition: opacity .15s;
}
.asset-bar .seg-fill:hover { opacity: 0.85; }

.asset-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
}
.asset-legend .row {
  display: grid;
  grid-template-columns: 12px 1fr auto auto;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--divider);
}
.asset-legend .row:last-child { border-bottom: 0; }
.asset-legend .dot { width: 9px; height: 9px; border-radius: 2px; }
.asset-legend .pct { color: var(--text-3); font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.asset-legend .val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 500; }

/* ---------- Chart container ---------- */
.chart-wrap {
  width: 100%;
  position: relative;
}
.chart-wrap svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--divider); stroke-width: 1; }
.chart-axis { fill: var(--text-4); font-size: 10px; font-family: var(--font-mono); }
.chart-line { fill: none; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-area { opacity: 0.12; }
.chart-bar-pos { fill: var(--positive); }
.chart-bar-neg { fill: var(--negative); }
.chart-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }

/* ---------- Divider / soft section ---------- */
.hr { height: 1px; background: var(--divider); border: 0; margin: 0; }

/* ---------- Empty / hint ---------- */
.hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-3);
}

/* ---------- Pill toggle / chip ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
}
.chip:hover { background: var(--surface-hover); color: var(--text); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- Crosshair tooltip ---------- */
.tip {
  pointer-events: none;
  position: absolute;
  background: var(--text);
  color: var(--bg);
  font-size: 11px;
  padding: 6px 9px;
  border-radius: 5px;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  z-index: 4;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-4); }

/* ---------- Utilities ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.muted { color: var(--text-3); }
.muted-2 { color: var(--text-4); }
.small { font-size: 11.5px; }
.bold { font-weight: 600; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.numeric { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Registry grid (Dados cadastrais) — minmax(0,1fr) so long values never force overflow */
.reg-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--divider);
}
.reg-grid .reg-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  min-width: 0;
  border-bottom: 1px solid var(--divider);
  border-right: 1px solid var(--divider);
}
.reg-grid .reg-cell:nth-child(3n) { border-right: none; }
.reg-grid .reg-val { overflow-wrap: anywhere; }

/* Clickable gestora links — navigate to all funds of that gestora */
.gestor-link { cursor: pointer; transition: color .12s; }
.gestor-link:hover { color: var(--accent-ink, var(--text)); text-decoration: underline; text-underline-offset: 2px; }

/* Disabled buttons + "em breve" nav items */
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.nav-item:disabled, .nav-item.soon { opacity: 0.5; cursor: not-allowed; }
.nav-item.soon:hover { background: transparent; color: var(--text-2); }
.nav-soon {
  margin-left: auto; font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-4); background: var(--bg-sunk); border-radius: 999px; padding: 2px 6px;
}

/* ============================================================
   Responsive — the app was desktop-only (no breakpoints).
   ============================================================ */

/* Small desktops / large laptops */
@media (max-width: 1240px) {
  .page { padding: 24px 22px 72px; }
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
  .kpi-strip .kpi.lead { grid-column: 1 / -1; border-right: 0; }
  .kpi-strip .kpi.lead .stat-value { font-size: 30px; }
}

/* Laptops / tablets — stack the multi-column sections */
@media (max-width: 1024px) {
  .grid-12 > [class*="col-"] { grid-column: 1 / -1 !important; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-actions { flex-wrap: wrap; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .asset-legend { grid-template-columns: 1fr; }
  /* wide tables scroll horizontally instead of clipping */
  .tbl-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl-scroll > .tbl { min-width: 720px; }
}

/* Narrow tablets */
@media (max-width: 820px) {
  .kpi-strip { grid-template-columns: 1fr 1fr; }
  .topbar { padding: 0 14px; }
  .reg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reg-grid .reg-cell:nth-child(3n) { border-right: 1px solid var(--divider); }
  .reg-grid .reg-cell:nth-child(2n) { border-right: none; }
}

/* Phones — drop the fixed sidebar, single column */
@media (max-width: 680px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .kpi-strip { grid-template-columns: 1fr; }
  .kpi-strip .kpi { border-right: 0; }
  .page { padding: 16px 14px 56px; }
  .page-head h1 { font-size: 22px; }
  .topbar .badge.dot { display: none; }
  .reg-grid { grid-template-columns: 1fr; }
  .reg-grid .reg-cell, .reg-grid .reg-cell:nth-child(3n) { border-right: none; }
  /* let card headers drop their controls below the title instead of overflowing */
  .card-head { flex-wrap: wrap; }
  .card-head > :last-child { flex-basis: 100%; }
  .card-head .row { flex-wrap: wrap; }
}

/* ---------------- Gestora page ---------------- */
.gestora-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 12px; }
.gestora-card { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface); cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
.gestora-card:hover { border-color: var(--accent-line); box-shadow: 0 4px 14px rgba(20,18,8,.07); transform: translateY(-1px); }
.gestora-card-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--divider); font-size: 11px; color: var(--text-3); }
.gestora-card.inactive { opacity: .6; }
.gestora-card.inactive:hover { opacity: .85; }

/* ---------------- AI chat ---------------- */
.chat-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  display: flex; align-items: center; gap: 8px; padding: 11px 16px;
  border: none; border-radius: 999px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg);
}
.chat-fab:hover { filter: brightness(1.03); }
.chat-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100vw;
  z-index: 60; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px; border-bottom: 1px solid var(--divider); }
.chat-orb { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex-shrink: 0; }
.chat-orb.lg { width: 44px; height: 44px; border-radius: 12px; }
.chat-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.chat-msg { max-width: 88%; font-size: 13px; line-height: 1.5; }
.chat-msg.user { align-self: flex-end; background: var(--text); color: var(--surface); padding: 9px 13px; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; }
.chat-ai-row { display: flex; gap: 10px; align-items: flex-start; max-width: 96%; }
.chat-ai-bubble { background: var(--bg-sunk); border: 1px solid var(--divider); padding: 10px 13px; border-radius: 4px 14px 14px 14px; font-size: 13px; line-height: 1.55; min-width: 0; }
.chat-trace { margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--divider); font-size: 10.5px; color: var(--text-4); }
.chat-refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chat-ref { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 11.5px; cursor: pointer; }
.chat-ref:hover { border-color: var(--accent-line); background: var(--surface-hover); color: var(--text); }
.chat-welcome { text-align: center; padding: 26px 16px; display: flex; flex-direction: column; align-items: center; }
.chat-sugg-list { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; width: 100%; }
.chat-sugg { text-align: left; padding: 10px 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text-2); font-size: 12.5px; cursor: pointer; }
.chat-sugg:hover { background: var(--surface-hover); border-color: var(--accent-line); }
.chat-input-bar { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--divider); }
.chat-input-bar textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; font: inherit; font-size: 13px; background: var(--surface); color: var(--text); max-height: 140px; }
.chat-input-bar textarea:focus { outline: none; border-color: var(--accent-line); }
.chat-send { width: 36px; height: 36px; flex-shrink: 0; border: none; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; }
.chat-send:disabled { opacity: .4; cursor: default; }
.chat-disc { padding: 0 14px 12px; font-size: 10px; color: var(--text-4); text-align: center; }
.chat-typing { display: inline-flex; gap: 4px; align-items: center; }
.chat-typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--text-4); animation: chatblink 1.2s infinite both; }
.chat-typing span:nth-child(2) { animation-delay: .2s; } .chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chatblink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
/* markdown inside assistant bubbles */
.chat-md > :first-child { margin-top: 0; } .chat-md > :last-child { margin-bottom: 0; }
.chat-md p { margin: 7px 0; } .chat-md ul, .chat-md ol { margin: 7px 0; padding-left: 18px; }
.chat-md li { margin: 2px 0; }
.chat-md table { border-collapse: collapse; width: 100%; margin: 9px 0; font-size: 11.5px; }
.chat-md th, .chat-md td { border: 1px solid var(--divider); padding: 4px 8px; text-align: left; }
.chat-md th { background: var(--surface); font-weight: 600; }
.chat-md code { font-family: var(--font-mono); font-size: 11.5px; background: var(--surface); padding: 1px 4px; border-radius: 4px; }
.chat-md a { color: var(--accent-line); }
@media (max-width: 680px) { .chat-panel { width: 100vw; } }
