:root {
  --bg: #f4f0e6;
  --surface: #fbf8f0;
  --surface-2: #ffffff;
  --surface-sink: #efe9d9;

  --ink: #15120f;
  --ink-2: #3a342e;
  --mute: #7c7367;
  --mute-2: #a49a8c;

  --rule: #e3dbc6;
  --rule-soft: #eee6d2;
  --rule-strong: #cfc5ab;

  --accent: #0E3B2E;
  --accent-2: #1d5a47;
  --accent-weak: #d3e1d9;

  --gold: #FFD300;
  --gold-2: #e6bd00;
  --gold-weak: #fff3b0;

  --warm: #7a4a1f;
  --warm-2: #9a6430;
  --warm-weak: #ead9bf;

  --pos: #2e6a40;
  --neg: #8b2a23;

  --radius: 6px;
  --radius-lg: 10px;

  --font-display: "Fraunces", ui-serif, Georgia, serif;
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

html {
  box-sizing: border-box;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

*, *:before, *:after { box-sizing: inherit; }
body { margin: 0; }

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-feature-settings: "ss01", "ss02";
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 0;
}

h1 { font-size: 1.45rem; line-height: 1.15; }
h2 { font-size: 1.35rem; line-height: 1.2; letter-spacing: -0.015em; }
h3 {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
  margin: 1.25rem 0 0.6rem;
}

p { margin: 0.4rem 0; }
strong { font-weight: 600; }

/* ── Shell: brandmark + topbar + sidenav + main ──────── */
.shell {
  --sidenav-w: 220px;
  --topbar-h: 4.6rem;
  display: grid;
  grid-template-columns: var(--sidenav-w) minmax(0, 1fr);
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
  transition: grid-template-columns 260ms cubic-bezier(0.2, 0, 0, 1);
}

body[data-nav-collapsed="true"] .shell {
  --sidenav-w: 72px;
}

.brandmark {
  align-items: flex-start;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  display: flex;
  grid-column: 1;
  grid-row: 1;
  justify-content: center;
  padding: 0 0.65rem;
  position: sticky;
  text-decoration: none;
  top: 0;
  z-index: 6;
}
.brandmark:hover { text-decoration: none; }

.brandmark img {
  display: block;
  height: auto;
  max-height: 100%;
  max-width: 100%;
  width: auto;
}

body[data-nav-collapsed="true"] .brandmark {
  padding: 0 0.35rem;
}

.apptopbar {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  display: flex;
  grid-column: 2;
  grid-row: 1;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 clamp(1.25rem, 3vw, 2rem);
  position: sticky;
  top: 0;
  z-index: 5;
}

.apptopbar__title h1 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 500;
  letter-spacing: -0.015em;
  line-height: 1.1;
}

.apptopbar__title p {
  color: var(--mute);
  font-size: 0.85rem;
  letter-spacing: 0.01em;
  margin: 0.25rem 0 0;
}

.auth-user {
  align-items: center;
  display: flex;
  gap: 0.75rem;
  margin-left: auto;
}

.auth-user__identity {
  display: grid;
  gap: 0.05rem;
  justify-items: end;
}

.auth-user__identity span {
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 500;
}

.auth-user__identity small {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.auth-user__logout {
  white-space: nowrap;
}

.sidenav {
  align-self: start;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  grid-column: 1;
  grid-row: 2;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
  padding: 1.25rem 0.85rem 0.85rem;
  position: sticky;
  top: var(--topbar-h);
}

.sidenav__nav {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 0.1rem;
  min-height: 0;
}

.sidenav__item {
  align-items: center;
  border-radius: 4px;
  color: var(--ink-2);
  display: flex;
  gap: 0.85rem;
  padding: 0.5rem 0.6rem;
  transition: background-color 120ms ease, color 120ms ease;
  white-space: nowrap;
}

.sidenav__item:hover {
  background: var(--surface-sink);
  color: var(--ink);
  text-decoration: none;
}

.sidenav__item.is-active {
  background: var(--accent);
  color: var(--surface);
}

.sidenav__index {
  color: var(--accent);
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-style: italic;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  text-align: center;
  width: 1.8rem;
}

.sidenav__item.is-active .sidenav__index { color: var(--gold); }
.sidenav__item:hover .sidenav__index { color: var(--accent-2); }
.sidenav__item.is-active:hover .sidenav__index { color: var(--gold); }

.sidenav__label {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  overflow: hidden;
  text-transform: uppercase;
  transition: opacity 160ms ease;
}

.sidenav__toggle {
  align-items: center;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--mute);
  cursor: pointer;
  display: flex;
  flex: 0 0 auto;
  font-family: var(--font-sans);
  font-size: 0.66rem;
  font-weight: 500;
  gap: 0.6rem;
  letter-spacing: 0.16em;
  margin-top: auto;
  padding: 0.5rem 0.6rem;
  text-transform: uppercase;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
  width: 100%;
}

.sidenav__toggle:hover {
  background: var(--surface-sink);
  border-color: var(--rule-strong);
  color: var(--ink);
}

.sidenav__toggle-glyph {
  display: inline-block;
  flex: 0 0 auto;
  font-family: var(--font-display);
  font-size: 1.1rem;
  line-height: 1;
  text-align: center;
  transition: transform 260ms cubic-bezier(0.2, 0, 0, 1);
  width: 1.4rem;
}

body[data-nav-collapsed="true"] .sidenav__toggle-glyph {
  transform: rotate(180deg);
}

/* Collapsed — hide labels, center icons */
body[data-nav-collapsed="true"] .sidenav {
  padding-left: 0.6rem;
  padding-right: 0.6rem;
}

body[data-nav-collapsed="true"] .sidenav__brand-text,
body[data-nav-collapsed="true"] .sidenav__label,
body[data-nav-collapsed="true"] .sidenav__toggle-label {
  opacity: 0;
  pointer-events: none;
  width: 0;
}

body[data-nav-collapsed="true"] .sidenav__brand,
body[data-nav-collapsed="true"] .sidenav__item,
body[data-nav-collapsed="true"] .sidenav__toggle {
  gap: 0;
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

/* ── Layout ──────────────────────────────────────────── */
.page {
  grid-column: 2;
  grid-row: 2;
  margin: 0 auto;
  max-width: 1400px;
  padding: 1.75rem 2rem 4rem;
  width: 100%;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  padding: 1.25rem 1.5rem 1.4rem;
}

.panel > h2:first-child,
.panel > .section-header:first-child h2 {
  margin-bottom: 0.2rem;
}

.panel h2 + .muted {
  margin-bottom: 1rem;
}

.section-header {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.split-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
}

.muted { color: var(--mute); font-size: 0.88rem; }
.mono { font-family: var(--font-mono); }

.notes {
  margin: 0.6rem 0;
  padding-left: 1.2rem;
}
.notes li { margin: 0.2rem 0; color: var(--ink-2); }

/* ── Metric cards ────────────────────────────────────── */
.metrics {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-bottom: 1rem;
}
.metrics.compact { margin-top: 0.75rem; }

.metric-card {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.8rem 0.95rem 0.9rem;
}

.metric-label {
  color: var(--mute);
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
}

.metric-card strong {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  line-height: 1.15;
}

.metric-card p { font-size: 0.83rem; margin: 0.3rem 0 0; }

/* ── Forms ───────────────────────────────────────────── */
.form-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.form-grid label { display: block; }

.form-grid span {
  color: var(--mute);
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
}

.form-grid input,
.form-grid select {
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.65rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  width: 100%;
}

.form-grid input:focus,
.form-grid select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 62, 68, 0.12);
  outline: none;
}

.form-grid .wide { grid-column: span 2; }

.multi-combo {
  position: relative;
}

.multi-combo__control {
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  cursor: text;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  min-height: calc(1.9rem + 0.6rem);
  padding: 0.28rem 0.35rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.multi-combo.is-open .multi-combo__control,
.multi-combo__control:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 62, 68, 0.12);
}

.multi-combo__chips {
  display: contents;
}

.multi-combo__chip {
  align-items: center;
  background: var(--accent);
  border-radius: 999px;
  color: var(--surface);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 500;
  gap: 0.25rem;
  letter-spacing: 0.01em;
  padding: 0.18rem 0.35rem 0.18rem 0.6rem;
}

.multi-combo__chip-label { white-space: nowrap; }

.multi-combo__chip-remove {
  background: transparent;
  border: 0;
  color: var(--surface);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.78;
  padding: 0 0.2rem;
  transition: opacity 100ms ease;
}
.multi-combo__chip-remove:hover { opacity: 1; }

.multi-combo__search {
  background: transparent;
  border: 0;
  color: var(--ink);
  flex: 1;
  font: inherit;
  font-size: 0.9rem;
  min-width: 120px;
  outline: none;
  padding: 0.25rem 0.2rem;
}

.multi-combo__panel {
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  display: none;
  left: 0;
  list-style: none;
  margin: 4px 0 0;
  max-height: 280px;
  overflow-y: auto;
  padding: 0.25rem 0;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
}

.multi-combo.is-open .multi-combo__panel { display: block; }

.multi-combo__opt {
  align-items: center;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-size: 0.86rem;
  gap: 0.5rem;
  justify-content: space-between;
  padding: 0.38rem 0.7rem;
}

.multi-combo__opt:hover,
.multi-combo__opt.is-active {
  background: var(--surface-sink);
}

.multi-combo__opt.is-selected {
  color: var(--accent);
  font-weight: 600;
}

.multi-combo__opt-check {
  color: var(--accent);
  font-weight: 700;
  visibility: hidden;
}

.multi-combo__opt.is-selected .multi-combo__opt-check {
  visibility: visible;
}

.actions {
  align-self: end;
  display: flex;
  gap: 0.5rem;
}

.actions button,
.button {
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  color: var(--surface);
  cursor: pointer;
  display: inline-block;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.55rem 1rem;
  text-decoration: none;
  transition: background-color 120ms ease, transform 60ms ease;
}

.actions button:hover,
.button:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
  text-decoration: none;
}

.actions button:active,
.button:active { transform: translateY(1px); }

.actions a.button { line-height: 1.2; }

.button--ghost {
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  color: var(--ink);
}
.button--ghost:hover {
  background: var(--surface-sink);
  border-color: var(--rule-strong);
  color: var(--ink);
}

/* ── Authentication ─────────────────────────────────── */
.auth-page {
  align-items: center;
  display: flex;
  min-height: 100vh;
  justify-content: center;
  padding: 1.5rem;
}

.auth-panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(35, 32, 26, 0.08);
  display: grid;
  gap: 1.1rem;
  max-width: 420px;
  padding: 1.5rem;
  width: 100%;
}

.auth-panel__mark {
  height: 3.4rem;
  object-fit: contain;
  width: 3.4rem;
}

.auth-panel h1 {
  font-size: 1.7rem;
}

.auth-form {
  display: grid;
  gap: 0.8rem;
}

.auth-form label {
  display: grid;
  gap: 0.35rem;
}

.auth-form span {
  color: var(--mute);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-form input {
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  padding: 0.65rem 0.75rem;
  width: 100%;
}

.auth-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 62, 68, 0.12);
  outline: none;
}

.auth-message {
  color: var(--mute);
  font-size: 0.88rem;
}

.auth-message--error {
  color: var(--neg);
}

.auth-dev-link {
  font-size: 0.88rem;
  margin: 0;
}

.admin-invite-form {
  align-items: end;
  margin-top: 0.9rem;
}

.admin-invite-form .actions {
  align-self: end;
}

/* ── Agent chat ─────────────────────────────────────── */
.page--agent {
  max-width: none;
  padding: 0;
}

.agent-chat {
  --chat-max-width: 920px;
  --chat-bubble-radius: 18px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h, 4.6rem));
  min-height: 36rem;
  position: relative;
}

.agent-chat__floating-actions {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  position: absolute;
  right: clamp(1rem, 3vw, 1.75rem);
  top: 1rem;
  z-index: 3;
}

.agent-chat__header {
  align-items: center;
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex: 0 0 auto;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.85rem clamp(1rem, 3vw, 2rem);
}

.agent-config {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ink);
  cursor: default;
  display: grid;
  font: inherit;
  gap: 0.1rem;
  min-width: 0;
  padding: 0;
  text-align: left;
}

.agent-config span {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.agent-chat__actions {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 0.45rem;
}

.agent-icon-button,
.agent-attach-button,
.agent-send {
  align-items: center;
  appearance: none;
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  height: 2.55rem;
  justify-content: center;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 60ms ease;
  width: 2.55rem;
}

.agent-icon-button svg,
.agent-attach-button svg,
.agent-send svg {
  fill: none;
  height: 1.2rem;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 1.2rem;
}

.agent-icon-button:hover,
.agent-attach-button:hover,
.agent-send:hover {
  background: var(--surface-sink);
  color: var(--ink);
}

.agent-icon-button:active,
.agent-attach-button:active,
.agent-send:active {
  transform: translateY(1px);
}

.agent-icon-button:disabled,
.agent-attach-button:disabled,
.agent-send:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.agent-status {
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.45rem 0.65rem;
  white-space: nowrap;
}

.agent-status.is-ready {
  background: #e8efe9;
  border-color: #bad0bf;
  color: var(--pos);
}

.agent-status.is-running {
  background: var(--accent-weak);
  border-color: #b8cacb;
  color: var(--accent);
}

.agent-status.is-blocked {
  background: #f1ded9;
  border-color: #d9b7af;
  color: var(--neg);
}

.agent-chat__main {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  position: relative;
}

.agent-empty {
  align-items: center;
  color: var(--mute);
  display: flex;
  flex: 1;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.agent-empty h2 {
  color: var(--ink-2);
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  letter-spacing: 0;
}

.agent-thread {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
  margin: 0 auto;
  max-width: var(--chat-max-width);
  padding: 1.25rem clamp(1rem, 3vw, 1.9rem) 2rem;
  width: 100%;
}

.agent-thread.is-streaming::after {
  content: "";
  display: block;
  flex: 0 0 16vh;
  min-height: 5rem;
}

.agent-turn {
  animation: agent-fade-up 180ms ease-out;
  display: flex;
  min-width: 0;
}

@keyframes agent-fade-up {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.agent-turn--user {
  justify-content: flex-end;
}

.agent-turn--assistant,
.agent-turn--system {
  justify-content: flex-start;
}

.agent-turn__body {
  color: var(--ink-2);
  font-size: 0.96rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.agent-turn--user .agent-turn__body {
  background: rgba(31, 62, 68, 0.14);
  border-radius: var(--chat-bubble-radius);
  border-top-right-radius: 8px;
  color: var(--ink);
  max-width: min(85%, 44rem);
  padding: 0.78rem 0.95rem;
}

.agent-turn--assistant .agent-turn__body {
  max-width: min(100%, 52rem);
}

.agent-turn--assistant.is-streaming .agent-turn__body {
  animation: agent-answer-soften 220ms ease-out;
}

@keyframes agent-answer-soften {
  from { opacity: 0.65; }
  to { opacity: 1; }
}

.agent-turn--system {
  justify-content: center;
}

.agent-turn--system .agent-turn__body,
.agent-auth-warning {
  background: var(--surface-sink);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  max-width: min(48rem, calc(100% - 2rem));
  padding: 0.55rem 0.7rem;
}

.agent-auth-warning {
  flex: 0 0 auto;
  margin: 0 auto 0.75rem;
}

.agent-working {
  background: rgba(239, 233, 217, 0.62);
  border: 1px solid var(--rule);
  border-radius: 0.95rem;
  color: var(--ink-2);
  max-width: min(100%, 36rem);
  overflow: hidden;
}

.agent-working__summary {
  align-items: center;
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: grid;
  font: inherit;
  gap: 0.55rem;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  min-height: 2.7rem;
  padding: 0.58rem 0.72rem;
  text-align: left;
  width: 100%;
}

.agent-working__summary span:not(.agent-breathing-dot) {
  font-size: 0.86rem;
  font-weight: 500;
}

.agent-working__summary small {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-breathing-dot {
  animation: agent-breathe 1.6s ease-in-out infinite;
  background: var(--accent-2);
  border-radius: 999px;
  box-shadow: 0 0 0 0 rgba(46, 90, 99, 0.26);
  height: 0.52rem;
  width: 0.52rem;
}

.agent-working:not(.is-active) .agent-breathing-dot {
  animation: none;
  box-shadow: none;
  opacity: 0.45;
  transform: scale(0.86);
}

@keyframes agent-breathe {
  0%, 100% {
    opacity: 0.55;
    transform: scale(0.86);
    box-shadow: 0 0 0 0 rgba(46, 90, 99, 0.22);
  }
  45% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 0 8px rgba(46, 90, 99, 0);
  }
}

.agent-chevron {
  fill: none;
  height: 1rem;
  stroke: var(--mute);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 140ms ease;
  width: 1rem;
}

.agent-chevron.is-open {
  transform: rotate(180deg);
}

.agent-working__body {
  animation: agent-fade-up 160ms ease-out;
  border-top: 1px solid var(--rule);
  padding: 0.65rem 0.72rem 0.75rem;
}

.agent-working__muted {
  color: var(--mute);
  font-size: 0.82rem;
}

.agent-tool-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.agent-tool-pill {
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.28rem 0.5rem;
}

.agent-thinking {
  align-items: center;
  background: var(--surface-sink);
  border: 1px solid var(--rule);
  border-radius: 999px;
  display: inline-flex;
  gap: 0.28rem;
  padding: 0.58rem 0.72rem;
}

.agent-thinking span {
  animation: agent-thinking-pulse 1.2s ease-in-out infinite;
  background: var(--accent-2);
  border-radius: 999px;
  display: block;
  height: 0.34rem;
  opacity: 0.35;
  width: 0.34rem;
}

.agent-thinking span:nth-child(2) { animation-delay: 140ms; }
.agent-thinking span:nth-child(3) { animation-delay: 280ms; }

@keyframes agent-thinking-pulse {
  0%, 70%, 100% { opacity: 0.28; transform: translateY(0); }
  35% { opacity: 0.95; transform: translateY(-2px); }
}

.agent-cursor {
  animation: agent-cursor-blink 1s steps(2, start) infinite;
  border-right: 2px solid var(--accent);
  display: inline-block;
  height: 1em;
  margin-left: 2px;
  transform: translateY(0.12em);
}

@keyframes agent-cursor-blink {
  50% { opacity: 0; }
}

.agent-composer {
  border-top: 1px solid var(--rule);
  flex: 0 0 auto;
  padding: 0.85rem clamp(1rem, 3vw, 2rem) 1rem;
}

.agent-composer__box {
  align-items: stretch;
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  border-radius: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.58rem;
  margin: 0 auto;
  max-width: var(--chat-max-width);
  padding: 0.65rem;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.agent-composer__box:focus-within {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(46, 90, 99, 0.12);
}

.agent-composer.is-dragging .agent-composer__box {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46, 90, 99, 0.16);
}

.agent-composer__row {
  align-items: flex-end;
  display: flex;
  gap: 0.65rem;
  width: 100%;
}

.agent-file-input {
  display: none;
}

.agent-composer textarea {
  background: transparent;
  border: 0;
  color: var(--ink);
  flex: 1 1 auto;
  font: inherit;
  line-height: 1.5;
  max-height: 11rem;
  min-height: 2rem;
  min-width: 0;
  outline: none;
  overflow-y: auto;
  padding: 0.25rem 0;
  resize: none;
}

.agent-composer textarea::placeholder {
  color: var(--mute);
}

.agent-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.agent-attachment-preview {
  align-items: center;
  background: rgba(239, 233, 217, 0.9);
  border: 1px solid var(--rule);
  border-radius: 0.55rem;
  display: grid;
  gap: 0.48rem;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  max-width: min(100%, 18rem);
  min-height: 2.5rem;
  padding: 0.28rem 0.35rem 0.28rem 0.28rem;
}

.agent-attachment-preview__thumb,
.agent-attachment-preview__file {
  border-radius: 0.42rem;
  height: 2rem;
  width: 2rem;
}

.agent-attachment-preview__thumb {
  object-fit: cover;
}

.agent-attachment-preview__file {
  align-items: center;
  background: var(--surface-sink);
  color: var(--accent);
  display: inline-flex;
  justify-content: center;
}

.agent-attachment-preview__file svg {
  fill: none;
  height: 1rem;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 1rem;
}

.agent-attachment-preview__meta {
  display: grid;
  min-width: 0;
}

.agent-attachment-preview__name {
  color: var(--ink-2);
  font-size: 0.78rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-attachment-preview__type {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.agent-attachment-preview__remove {
  align-items: center;
  appearance: none;
  background: transparent;
  border: 0;
  border-radius: 999px;
  color: var(--mute);
  cursor: pointer;
  display: inline-flex;
  height: 1.5rem;
  justify-content: center;
  padding: 0;
  width: 1.5rem;
}

.agent-attachment-preview__remove:hover {
  background: var(--surface-sink);
  color: var(--ink);
}

.agent-attachment-preview__remove svg {
  fill: none;
  height: 0.9rem;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 0.9rem;
}

.agent-attachment-error {
  color: var(--neg);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.35;
}

.agent-attach-button {
  flex: 0 0 auto;
}

.agent-send {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--surface);
  flex: 0 0 auto;
}

.agent-send:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}

.agent-send.is-stopping {
  background: var(--surface-2);
  border-color: var(--rule-strong);
  color: var(--ink);
}

@media (max-width: 760px) {
  .agent-chat {
    height: calc(100vh - 7.2rem);
    min-height: 32rem;
  }

  .agent-chat__header {
    align-items: flex-start;
    flex-direction: column;
  }

  .agent-chat__actions {
    width: 100%;
  }

  .agent-status {
    margin-left: auto;
  }

  .agent-turn--user .agent-turn__body {
    max-width: 94%;
  }
}

.load-more {
  align-items: center;
  border-top: 1px solid var(--rule-soft);
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
}

.load-more__all {
  font-size: 0.8rem;
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 3px;
}
.load-more__all:hover { color: var(--ink); text-decoration-color: var(--mute); }

.section-count {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.section-count strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 500;
}

.pager {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.pager .button { background: var(--surface-2); border-color: var(--rule-strong); color: var(--ink); }
.pager .button:hover { background: var(--surface-sink); border-color: var(--rule-strong); color: var(--ink); }

/* ── Tables ──────────────────────────────────────────── */
.table-wrap {
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--surface-2);
}

table {
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 100%;
  width: max-content;
}

thead th {
  background: var(--surface-sink);
  border-bottom: 1px solid var(--rule-strong);
  color: var(--mute);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 0.55rem 0.8rem;
  position: sticky;
  text-align: left;
  text-transform: uppercase;
  top: 0;
  white-space: nowrap;
}

tbody td {
  border-bottom: 1px solid var(--rule-soft);
  font-variant-numeric: tabular-nums;
  padding: 0.5rem 0.8rem;
  vertical-align: top;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(31, 62, 68, 0.035); }

th[title] {
  cursor: help;
  text-decoration: underline dotted var(--mute-2);
  text-underline-offset: 0.22rem;
}

/* Right-align numeric columns inside .table-wrap when class is applied */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Accordion block ─────────────────────────────────── */
.accordion-block {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-top: 0.75rem;
  overflow: hidden;
}

.accordion-block summary {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid transparent;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  list-style: none;
  padding: 0.85rem 1rem;
  transition: background-color 120ms ease;
}

.accordion-block summary:hover { background: var(--surface-sink); }
.accordion-block[open] summary { border-bottom: 1px solid var(--rule); }
.accordion-block summary::-webkit-details-marker { display: none; }

.accordion-block > :not(summary) {
  padding: 0.6rem 1rem 1.1rem;
}

.summary-metric {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.summary-metric strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 500;
}

.subpanel {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-top: 0.75rem;
  padding: 1rem;
}

.details-block { margin-top: 0.75rem; }
.details-block > summary {
  color: var(--ink-2);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.3rem 0;
}
.details-block > summary:hover { color: var(--ink); }

/* ── Rapporto holdings list (flat, table-like) ───────── */
.rapporto-list {
  border-top: 1px solid var(--rule);
  list-style: none;
  margin: 0.8rem 0 0;
  padding: 0;
}

.rapporto-row {
  border-bottom: 1px solid var(--rule);
}

.rapporto-row > details > summary {
  list-style: none;
}
.rapporto-row > details > summary::-webkit-details-marker { display: none; }

.rapporto-row__head {
  align-items: baseline;
  column-gap: 0.9rem;
  cursor: pointer;
  display: grid;
  grid-template-columns: 12rem minmax(18rem, 24rem) minmax(22rem, 1fr) 8rem 9.5rem;
  padding: 0.45rem 0.25rem 0.45rem 1.1rem;
  position: relative;
}

.rapporto-row__head::before {
  color: var(--mute);
  content: "▸";
  font-size: 0.7rem;
  left: 0.15rem;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 120ms ease;
}
.rapporto-row > details[open] > summary.rapporto-row__head::before {
  transform: translateY(-50%) rotate(90deg);
}

.rapporto-row__head:hover { background: var(--surface-sink); }

.rapporto-row__code {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.rapporto-row__type {
  color: var(--ink-2);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rapporto-row__meta {
  color: var(--mute);
  font-size: 0.76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rapporto-row__count {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-align: right;
  white-space: nowrap;
}

.rapporto-row__total {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: right;
  white-space: nowrap;
}

.rapporto-row:not(.has-holdings) .rapporto-row__total {
  color: var(--mute);
  font-weight: 400;
}

.rapporto-row__body {
  padding: 0.25rem 0 0.75rem 1.1rem;
}

.rapporto-row__body .table-wrap {
  margin: 0;
}

.rapporto-row__more {
  margin: 0.5rem 0 0;
}

@media (max-width: 900px) {
  .rapporto-row__head {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "code type total"
      "meta meta count";
    row-gap: 0.2rem;
  }
  .rapporto-row__code { grid-area: code; }
  .rapporto-row__type { grid-area: type; }
  .rapporto-row__meta { grid-area: meta; white-space: normal; }
  .rapporto-row__count { grid-area: count; text-align: right; }
  .rapporto-row__total { grid-area: total; }
}

/* ── Hints / badges ──────────────────────────────────── */
.hint-badge {
  align-items: center;
  background: var(--surface-sink);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--mute);
  cursor: help;
  display: inline-flex;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 500;
  height: 1.05rem;
  justify-content: center;
  margin-left: 0.4rem;
  vertical-align: middle;
  width: 1.05rem;
}

/* ── Performance cards ───────────────────────────────── */
.perf-card { display: grid; gap: 0.35rem; }
.perf-card strong {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.mini-track {
  background: var(--surface-sink);
  border-radius: 2px;
  height: 4px;
  overflow: hidden;
}
.mini-fill { background: var(--accent); border-radius: 2px; height: 100%; }
.mini-fill.accent { background: var(--accent); }
.mini-fill.warm { background: var(--warm-2); }
.mini-fill.down { background: var(--neg); }

/* ── Dashboard bars ──────────────────────────────────── */
.bar-row {
  align-items: center;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: 220px 1fr 110px;
  margin: 0.55rem 0;
}
.bar-row.wide-value { grid-template-columns: 220px 1fr 140px; }

.bar-label {
  color: var(--ink-2);
  font-size: 0.88rem;
}

.bar-track {
  background: var(--surface-sink);
  border-radius: 2px;
  height: 6px;
  overflow: hidden;
}
.bar-fill { background: var(--accent); border-radius: 2px; height: 100%; }
.bar-fill.accent { background: var(--accent); }
.bar-fill.warm { background: var(--warm-2); }

.bar-value {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ── Allocation redesign ─────────────────────────────── */
.alloc-card {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  margin-top: 0.85rem;
  overflow: hidden;
}

.alloc-card__head {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  justify-content: space-between;
  padding: 0.85rem 1.1rem;
}

.alloc-card__title {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.alloc-card__portfolio {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 32ch;
}

.alloc-card__meta {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.alloc-card__sums {
  display: flex;
  gap: 1rem;
}

.alloc-sum {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.02em;
}
.alloc-sum strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-weight: 500;
}

.alloc-card__body {
  padding: 1rem 1.1rem 1.2rem;
}

.alloc-section + .alloc-section { margin-top: 1.5rem; }

.alloc-stack {
  background: var(--surface-sink);
  border-radius: 3px;
  display: flex;
  height: 10px;
  margin: 0.35rem 0 0.6rem;
  overflow: hidden;
  width: 100%;
}
.alloc-stack__seg {
  height: 100%;
  min-width: 2px;
  transition: opacity 120ms ease;
}
.alloc-stack__seg:hover { opacity: 0.85; }

.alloc-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
  font-size: 0.78rem;
  color: var(--ink-2);
  margin-bottom: 0.8rem;
}
.alloc-legend__swatch {
  border-radius: 2px;
  display: inline-block;
  height: 0.6rem;
  margin-right: 0.45rem;
  vertical-align: 1px;
  width: 0.6rem;
}
.alloc-legend__name { color: var(--ink); }
.alloc-legend__val {
  color: var(--mute);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  margin-left: 0.35rem;
}

.alloc-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  width: 100%;
}

.alloc-table th {
  background: transparent;
  border-bottom: 1px solid var(--rule);
  color: var(--mute);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 0.4rem 0.5rem;
  position: static;
  text-transform: uppercase;
}

.alloc-table td {
  border-bottom: 1px solid var(--rule-soft);
  padding: 0.5rem 0.5rem;
}

.alloc-table tr:last-child td { border-bottom: 0; }
.alloc-table tr:hover td { background: rgba(31, 62, 68, 0.03); }

.alloc-table .col-class { width: 50%; }
.alloc-table .col-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  width: 14%;
  white-space: nowrap;
}

.alloc-table tr.is-parent td {
  background: var(--surface);
  border-top: 1px solid var(--rule);
  color: var(--ink);
  font-weight: 500;
}

.alloc-table tr.is-child .col-class {
  padding-left: 1.35rem;
  position: relative;
}
.alloc-table tr.is-child .col-class:before {
  color: var(--mute-2);
  content: "└";
  font-family: var(--font-mono);
  left: 0.5rem;
  position: absolute;
  top: 0.45rem;
}

.alloc-class__name { color: var(--ink); }
.alloc-class__code {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  margin-left: 0.4rem;
}

.alloc-compare-table tr.is-out td {
  background: rgba(139, 42, 35, 0.05);
}
.alloc-compare-table tr.is-out:hover td {
  background: rgba(139, 42, 35, 0.08);
}

.exposure-grid {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.exposure-section {
  min-width: 0;
}

.exposure-section__head {
  align-items: baseline;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  margin: 0 0 0.45rem;
}

.exposure-section__head h3,
.exposure-section__head h4 {
  margin: 0;
}

.exposure-section__meta {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.exposure-table .col-class {
  min-width: 10rem;
}

.exposure-table tbody tr.exposure-row {
  background-image: linear-gradient(
    to right,
    rgba(31, 62, 68, 0.14) 0,
    rgba(31, 62, 68, 0.14) var(--exposure-fill, 0%),
    transparent var(--exposure-fill, 0%)
  );
}
.exposure-table tbody tr.exposure-row > td { background-color: transparent; }
.exposure-table tbody tr.exposure-row:hover {
  background-image: linear-gradient(
    to right,
    rgba(31, 62, 68, 0.22) 0,
    rgba(31, 62, 68, 0.22) var(--exposure-fill, 0%),
    transparent var(--exposure-fill, 0%)
  );
}

.alloc-delta {
  color: var(--mute);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.alloc-delta.pos { color: var(--pos); }
.alloc-delta.neg { color: var(--neg); }

.alloc-row--mini {
  background: var(--surface-sink);
  border-radius: 2px;
  height: 4px;
  margin-top: 4px;
  overflow: hidden;
}
.alloc-row--mini > span {
  background: var(--accent);
  display: block;
  height: 100%;
}
.alloc-row--mini.warm > span { background: var(--warm-2); }

.alloc-empty {
  color: var(--mute);
  font-size: 0.85rem;
  padding: 0.4rem 0;
}

/* ── Performance breakdown ───────────────────────────── */
.perf-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  width: 100%;
}
.perf-table th {
  background: transparent;
  border-bottom: 1px solid var(--rule);
  color: var(--mute);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  padding: 0.4rem 0.5rem;
  position: static;
  text-transform: uppercase;
}
.perf-table td {
  border-bottom: 1px solid var(--rule-soft);
  font-variant-numeric: tabular-nums;
  padding: 0.5rem 0.5rem;
}
.perf-table tr:last-child td { border-bottom: 0; }
.perf-table tr:hover td { background: rgba(31, 62, 68, 0.03); }
.perf-table .perf-col-label { width: 46%; }
.perf-table .perf-col-num {
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}
.perf-trend {
  color: var(--mute);
  font-family: var(--font-mono);
  text-align: right;
}
.perf-trend.pos { color: var(--pos); }
.perf-trend.neg { color: var(--neg); }

/* ── Performance tabs + panels ───────────────────────── */
.perf-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.75rem 0 0.9rem;
}
.perf-tab {
  align-items: baseline;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  font-family: inherit;
  gap: 0.5rem;
  padding: 0.45rem 0.85rem;
  transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.perf-tab:hover { background: var(--surface-sink); }
.perf-tab.is-active {
  background: var(--surface-2);
  border-color: var(--ink);
}
.perf-tab__period {
  color: var(--ink-2);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.perf-tab__value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}
.perf-tab__value.warm { color: var(--pos); }
.perf-tab__value.down { color: var(--neg); }

.perf-panels { position: relative; }
.perf-panel { display: none; }
.perf-panel.is-active { display: block; }

.perf-panel__head {
  align-items: baseline;
  display: flex;
  gap: 0.75rem;
  margin: 0.25rem 0 0.6rem;
}
.perf-panel__title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

.perf-stats {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1rem;
}
.perf-stat {
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  display: grid;
  gap: 0.2rem;
  padding: 0.7rem 0.9rem;
}
.perf-stat__label {
  color: var(--mute);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.perf-stat__value {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.perf-stat__value.warm { color: var(--pos); }
.perf-stat__value.down { color: var(--neg); }
.perf-stat__sub { font-size: 0.78rem; }

.perf-breakdown-hint { margin: 0.1rem 0 0.4rem; font-size: 0.8rem; }
.perf-breakdowns {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}
.perf-breakdown {
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem 0.75rem;
}
.perf-breakdown__title {
  margin: 0 0 0.35rem;
}

/* ── Client master record ────────────────────────────── */
.master-groups {
  display: grid;
  gap: 0.75rem 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  margin-top: 0.4rem;
}
.master-group {
  border-top: 1px solid var(--rule-soft);
  padding-top: 0.5rem;
}
.master-group__title {
  margin: 0 0 0.35rem;
}
.master-fields {
  display: grid;
  gap: 0.3rem 1rem;
  grid-template-columns: minmax(7rem, auto) 1fr;
  margin: 0;
}
.master-fields--extras {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.35rem 1rem;
  margin-top: 0.4rem;
}
.master-fields--extras .master-field {
  display: grid;
  grid-template-columns: minmax(7rem, auto) 1fr;
  gap: 0 0.6rem;
}
.master-field {
  display: contents;
}
.master-fields--extras .master-field { display: grid; }
.master-field dt {
  color: var(--mute);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.5;
  align-self: baseline;
}
.master-field dd {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.4;
}
.master-field__value {
  font-family: var(--font-sans);
  font-size: 0.9rem;
}
.master-field__code {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  margin-left: 0.4rem;
  white-space: nowrap;
}
.master-field__hashed {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-style: italic;
}
.master-extras { margin-top: 0.6rem; }

/* ── Client relationship household ───────────────────── */
.relationship-household__header {
  align-items: center;
}

.relationship-block {
  border-top: 1px solid var(--rule-soft);
  margin-top: 0.95rem;
  padding-top: 0.85rem;
}

.relationship-block:first-of-type {
  margin-top: 0.35rem;
}

.relationship-block__head {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}

.relationship-block__head h3,
.relationship-block__head p {
  margin: 0;
}

.relationship-table-wrap {
  margin-top: 0.35rem;
}

.relationship-table {
  min-width: 1180px;
}

.relationship-label {
  display: inline-block;
  max-width: 18rem;
}

.relationship-code {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  margin-left: 0.35rem;
  white-space: nowrap;
}

.relationship-status {
  background: var(--surface-sink);
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--ink-2);
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.08rem 0.36rem;
  text-transform: uppercase;
  white-space: nowrap;
}

.relationship-status.is-warning {
  background: #fff4df;
  border-color: #d9a847;
  color: #6d4c06;
  margin-right: 0.25rem;
}

/* ── Doc block ───────────────────────────────────────── */
.doc-block {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  overflow-x: auto;
  padding: 1rem 1.1rem;
  white-space: pre-wrap;
}

/* ── Hierarchy tree ──────────────────────────────────── */
.htree {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border-top: 1px solid var(--rule);
  padding-top: 0.35rem;
}

.hnode {
  border: none;
  background: transparent;
}

.hnode > .hnode__row {
  align-items: center;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: minmax(0, 1fr) auto;
  list-style: none;
  padding: 0.5rem 0.5rem 0.5rem 0.25rem;
  transition: background 0.12s ease;
}

.hnode > .hnode__row::-webkit-details-marker { display: none; }
.hnode > .hnode__row::marker { content: ""; }

.hnode > .hnode__row:hover {
  background: var(--surface-sink);
}

.hnode__label {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  min-width: 0;
}

.hnode__chev {
  color: var(--mute-2);
  font-size: 0.75rem;
  transition: transform 0.15s ease;
  width: 0.9rem;
  display: inline-block;
}

.hnode[open] > .hnode__row .hnode__chev { transform: rotate(90deg); }
.hnode--leaf > .hnode__row .hnode__chev { opacity: 0; }

.hnode__level {
  background: var(--rule-soft);
  border-radius: 3px;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.08rem 0.35rem;
}

.hnode__title {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 500;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
}

a.hnode__title {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: var(--rule-strong);
  text-underline-offset: 3px;
}
a.hnode__title:hover { text-decoration-color: var(--accent); }

.hnode__code {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.hnode__sub {
  color: var(--mute);
  font-size: 0.82rem;
}

.hnode__stats {
  display: flex;
  gap: 1.25rem;
  align-items: baseline;
}

.hnode__stat {
  align-items: baseline;
  display: flex;
  flex-direction: column;
  min-width: 64px;
  text-align: right;
}

.hnode__stat-label {
  color: var(--mute);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hnode__stat strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 500;
}

.hnode__stat--eur { min-width: 128px; }
.hnode__stat--eur strong { font-size: 0.94rem; }

.hnode__children {
  border-left: 1px solid var(--rule);
  margin-left: 0.9rem;
  padding-left: 0.75rem;
}

.hnode__children--leaf {
  padding: 0.6rem 0 0.4rem 0.75rem;
}

.hnode--l1 > .hnode__row .hnode__title { font-size: 1.15rem; }
.hnode--l2 > .hnode__row .hnode__title,
.hnode--l3 > .hnode__row .hnode__title { font-size: 1.05rem; }
.hnode--leaf > .hnode__row {
  background: transparent;
}

.hnode__tag {
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 3px;
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  padding: 0.04rem 0.32rem;
  text-transform: uppercase;
}
.hnode__tag--link { color: var(--mute-2); }

.hnode__sub--adv { color: var(--ink-2); }

.hnode__attached {
  margin: 0.25rem 0 0.45rem 0.9rem;
  padding: 0.55rem 0.75rem 0.2rem;
  background: var(--surface-sink);
  border-left: 2px solid var(--accent-weak);
}
.hnode__attached-head {
  color: var(--mute);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.3rem;
  text-transform: uppercase;
}

.attached-table {
  border-collapse: collapse;
  font-size: 0.86rem;
  width: 100%;
}
.attached-table th,
.attached-table td {
  border-bottom: 1px dashed var(--rule-soft);
  padding: 0.35rem 0.6rem 0.35rem 0;
  text-align: left;
  vertical-align: baseline;
}
.attached-table th {
  color: var(--mute);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.attached-table td.num,
.attached-table th.num {
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}
.attached-table tr:last-child td { border-bottom: none; }

.role-badge {
  background: var(--rule-soft);
  border-radius: 3px;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.08rem 0.38rem;
  white-space: nowrap;
}
.role-badge--macro {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--mute);
}
.role-badge--lg {
  font-size: 0.82rem;
  padding: 0.14rem 0.5rem;
}

.cluster-group {
  border-top: 1px solid var(--rule);
  padding: 0.1rem 0;
}
.cluster-group:first-of-type { border-top: none; }
.cluster-group__row {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  list-style: none;
  padding: 0.7rem 0.25rem 0.55rem;
}
.cluster-group__row::-webkit-details-marker { display: none; }
.cluster-group__row::marker { content: ""; }
.cluster-group__row::before {
  color: var(--mute-2);
  content: "▾";
  font-size: 0.78rem;
  transition: transform 0.15s ease;
}
.cluster-group:not([open]) > .cluster-group__row::before { transform: rotate(-90deg); }
.cluster-group__row:hover { background: var(--surface-sink); }
.cluster-group__heading {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.cluster-group__heading h3 {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 500;
  margin: 0;
}
.cluster-group__body {
  padding: 0.2rem 0 0.7rem 0.5rem;
}

.role-group {
  border-top: 1px solid var(--rule-soft);
  padding: 0.15rem 0;
}
.role-group:first-of-type { border-top: none; }
.role-group__row {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 0.55rem;
  list-style: none;
  padding: 0.45rem 0.25rem 0.4rem;
}
.role-group__row::-webkit-details-marker { display: none; }
.role-group__row::marker { content: ""; }
.role-group__row::before {
  color: var(--mute-2);
  content: "▸";
  font-size: 0.7rem;
  transition: transform 0.15s ease;
}
.role-group[open] > .role-group__row::before { transform: rotate(90deg); }
.role-group__row:hover { background: var(--surface-sink); }
.role-group__heading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.role-group__label {
  color: var(--ink-2);
  font-size: 0.9rem;
}
.role-group__body {
  padding: 0.3rem 0.5rem 0.9rem 1.3rem;
}

/* ── Advisor branches table ─────────────────────────── */
.branch-table {
  border-collapse: collapse;
  font-size: 0.92rem;
  width: 100%;
}
.branch-table th,
.branch-table td {
  border-bottom: 1px solid var(--rule-soft);
  padding: 0.55rem 0.75rem 0.55rem 0;
  text-align: left;
}
.branch-table th {
  color: var(--mute);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.branch-table td.num,
.branch-table th.num {
  font-family: var(--font-mono);
  text-align: right;
  white-space: nowrap;
}
.branch-table td.share {
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  text-align: right;
  white-space: nowrap;
  width: 72px;
}
.branch-table tr.is-total td {
  border-top: 1px solid var(--rule);
  border-bottom: none;
  color: var(--ink);
  font-weight: 500;
  padding-top: 0.7rem;
}
.branch-table .share-bar {
  background: var(--rule-soft);
  border-radius: 2px;
  display: inline-block;
  height: 4px;
  margin-right: 0.45rem;
  vertical-align: middle;
  width: 46px;
}
.branch-table .share-bar > span {
  background: var(--accent);
  border-radius: 2px;
  display: block;
  height: 100%;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 860px) {
  .shell { --sidenav-w: 64px; }
  .sidenav { padding-left: 0.55rem; padding-right: 0.55rem; }
  .sidenav__brand-text,
  .sidenav__label,
  .sidenav__toggle-label { opacity: 0; pointer-events: none; width: 0; }
  .sidenav__brand,
  .sidenav__item,
  .sidenav__toggle { gap: 0; justify-content: center; padding-left: 0; padding-right: 0; }
  .page { padding: 1rem 1.2rem 3rem; }
  .form-grid .wide { grid-column: span 1; }
  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .bar-row,
  .bar-row.wide-value { grid-template-columns: 1fr; }
  .bar-value { text-align: left; }
  .alloc-card__head { gap: 0.5rem; }
  .alloc-card__portfolio { max-width: 100%; white-space: normal; }
}

/* ── Geo map ─────────────────────────────────────────── */
.geo-map {
  height: 620px;
  width: 100%;
  border: 1px solid var(--color-border, #e5ddca);
  border-radius: 14px;
  overflow: hidden;
  background: #eef1f4;
}
.geo-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.6rem;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #55402a;
  cursor: pointer;
}
.geo-toggle input { accent-color: #8a5a2b; }
.leaflet-tooltip {
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 0.82rem;
  line-height: 1.4;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #d8cdb7;
  background: #fffaf2;
  color: #2a1a0a;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
.leaflet-tooltip strong { font-family: 'Fraunces', serif; font-weight: 500; font-size: 0.95rem; }

table.sortable th[data-sort] {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.2rem;
}
table.sortable th[data-sort]::after {
  content: '↕';
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.25;
  font-size: 0.8em;
}
table.sortable th.sort-asc::after { content: '▲'; opacity: 0.9; color: #8a5a2b; }
table.sortable th.sort-desc::after { content: '▼'; opacity: 0.9; color: #8a5a2b; }

/* ── Dashboard hero + charts ─────────────────────────── */
.hero-panel { background: var(--surface); }
.hero-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 0.4rem;
}
.hero-card {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.hero-card--accent {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.hero-card__label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.8;
}
.hero-card__value {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-top: 0.15rem;
}
.hero-card__sub {
  font-size: 0.76rem;
  opacity: 0.7;
  margin-top: 0.25rem;
}
.chart-frame {
  position: relative;
  height: 260px;
  width: 100%;
}
.chart-frame--short { height: 220px; }
.chart-frame--tall { height: 340px; }
@media (max-width: 720px) {
  .chart-frame { height: 220px; }
  .chart-frame--short { height: 200px; }
  .chart-frame--tall { height: 280px; }
  .hero-card__value { font-size: 1.25rem; }
}




/* ── Product hierarchy & detail ──────────────────────── */
.product-tree {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.product-tree__l1 {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 0.5rem 0.7rem;
}
.product-tree__l1[open] {
  background: var(--surface);
}
.product-tree__l1 > summary {
  align-items: baseline;
  cursor: pointer;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  list-style: none;
}
.product-tree__l1 > summary::-webkit-details-marker { display: none; }
.product-tree__l2-list {
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  list-style: none;
  margin: 0.55rem 0 0;
  padding: 0.55rem 0 0.1rem 0.4rem;
}
.product-tree__l2-list li {
  align-items: baseline;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.15rem 0.2rem;
}
.product-tree__node {
  color: var(--ink);
  text-decoration: none;
}
.product-tree__node:hover { text-decoration: underline; }
.product-tree__node--active {
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
}
.product-tree__metrics {
  color: var(--mute);
  display: flex;
  font-size: 0.83rem;
  font-variant-numeric: tabular-nums;
  gap: 1rem;
  white-space: nowrap;
}

.spec-grid {
  display: grid;
  gap: 0.4rem 1.5rem;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  margin: 0;
}
.spec-row {
  border-bottom: 1px solid var(--rule);
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.35rem 0;
}
.spec-row dt {
  color: var(--mute);
  font-size: 0.8rem;
  font-weight: 500;
  margin: 0;
}
.spec-row dd {
  font-variant-numeric: tabular-nums;
  margin: 0;
  text-align: right;
}

.classification-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}
.classification-grid h3 {
  color: var(--mute);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin: 0 0 0.4rem;
  text-transform: uppercase;
}
.plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.plain-list li {
  border-bottom: 1px solid var(--rule);
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
  padding: 0.3rem 0;
}

.ac-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}
.ac-tree__hint {
  font-size: 0.78rem;
  margin: 0 0 0.6rem;
}
.ac-tree__hint code {
  background: var(--rule-soft);
  border-radius: 3px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  padding: 0 0.25rem;
}
.ac-tree__l1 {
  border-bottom: 1px solid var(--rule);
  padding: 0.45rem 0;
}
.ac-tree__l1:last-child {
  border-bottom: none;
}
.ac-tree__row {
  align-items: baseline;
  display: flex;
  gap: 0.75rem;
  justify-content: space-between;
}
.ac-tree__l1 > .ac-tree__row {
  font-weight: 500;
}
.ac-tree__code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  margin-left: 0.4rem;
}
.ac-tree__weight {
  color: var(--ink-2);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ac-tree__l2-list {
  border-left: 2px solid var(--rule);
  list-style: none;
  margin: 0.35rem 0 0 0.5rem;
  padding: 0 0 0 0.85rem;
}
.ac-tree__l2-list li {
  padding: 0.18rem 0;
}
.ac-section__title {
  margin: 1.5rem 0 0.5rem;
}
.ac-lenses {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 800px) {
  .ac-lenses {
    grid-template-columns: 1fr;
  }
}
.ac-lens h4 {
  align-items: baseline;
  display: flex;
  gap: 0.5rem;
  margin: 0 0 0.35rem;
}
.ac-lens__tag {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  font-weight: 400;
}
.ac-lens__hint {
  margin: 0 0 0.75rem;
}
