/* =========================================================
   eco-fin — design system
   ========================================================= */

:root {
  /* Marine palette — deep marine-blue sidebar, bright blue primary, sky accent. */
  --color-primary: #1d4ed8;
  --color-primary-mid: #1e40af;
  --color-primary-dark: #12305e;
  --color-primary-soft: rgba(29, 78, 216, 0.09);
  --color-accent: #38bdf8;
  --color-bg: #eef2f9;
  --color-sidebar-bg: #062744;
  --color-sidebar-bg-alt: #0b4d86;
  --color-sidebar-glow: rgba(56, 189, 248, 0.32);
  --color-card: #ffffff;
  --color-text: #0f1e35;
  --color-text-muted: #5b6b85;
  --color-danger: #ef4444;
  --color-danger-dark: #b91c1c;
  --color-warn: #d97706;
  --color-border: #dbe4f2;
  --gradient-primary: linear-gradient(135deg, #2f7bf6 0%, #1d4ed8 52%, #183f92 100%);
  --gradient-sidebar: linear-gradient(168deg, #05203c 0%, #0a3d6d 46%, #0f5f9e 100%);
  --radius-lg: 20px;
  --radius-md: 10px;
  --shadow-card: 0 1px 2px rgba(12, 35, 64, 0.04), 0 8px 24px rgba(12, 35, 64, 0.06);
  --shadow-card-hover: 0 16px 32px rgba(12, 35, 64, 0.14), 0 4px 10px rgba(12, 35, 64, 0.07);
  --shadow-primary: 0 6px 18px rgba(29, 78, 216, 0.32);
  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);
  --topbar-height: 64px;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: 'Inter', 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  background:
    radial-gradient(1100px 520px at 88% -12%, rgba(56, 189, 248, 0.16), transparent 62%),
    radial-gradient(900px 480px at -8% 8%, rgba(29, 78, 216, 0.10), transparent 58%),
    var(--color-bg);
  background-attachment: fixed;
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; }

/* The native [hidden] attribute only sets `display: none` at user-agent priority, so any element
   that also carries a `display: flex/grid` utility class (e.g. .form-field, .form-grid) would
   otherwise stay visible — author styles beat user-agent styles regardless of specificity. Force
   it to really hide, since every `hidden` usage in this app means "not shown right now". */
[hidden] { display: none !important; }

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------------------------------------------------------
   Public / marketing pages
   --------------------------------------------------------- */

.public-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  max-width: 1180px;
  margin: 0 auto;
}

.brand-logo { height: 32px; }

.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.micro2media-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}

.micro2media-link:hover { opacity: 0.8; }

.micro2media-logo { height: 22px; width: auto; }

.micro2media-badge {
  background: #ffffff;
  border-radius: 999px;
  padding: 4px 8px;
}

.brand-divider {
  width: 1px;
  height: 22px;
  background: rgba(15, 23, 42, 0.15);
}

.hero {
  padding: 64px 24px 48px;
  text-align: center;
  background: radial-gradient(circle at 30% 20%, rgba(29, 78, 216, 0.12), transparent 60%),
              radial-gradient(circle at 80% 0%, rgba(45, 212, 191, 0.14), transparent 55%);
}

.hero h1 {
  font-size: clamp(28px, 5vw, 46px);
  margin: 0 0 12px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.hero p.tagline {
  color: var(--color-text-muted);
  font-size: clamp(16px, 2.2vw, 19px);
  max-width: 560px;
  margin: 0 auto 32px;
}

.google-signin-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

/* Holds the button Google's script injects. It gets a height so the card does not jump when the
   iframe lands, and clips so the fixed-width button never overflows the card on a narrow phone. */
.google-button-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  max-width: 100%;
  overflow: hidden;
}

.google-signin-status {
  margin: 8px 0 0;
  font-size: 13px;
  text-align: center;
  color: var(--color-text-muted);
}

.hero-note {
  color: var(--color-text-muted);
  font-size: 13px;
}

/* Shown only when the Google button never appeared (blocked script, in-app browser, unknown origin),
   so the e-mail form below is the clear next step and the owner sees the origin to whitelist. */
.google-blocked-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  text-align: left;
  border: 1px solid rgba(198, 40, 40, 0.3);
  background: rgba(198, 40, 40, 0.06);
  border-radius: var(--radius-md, 10px);
}

.google-blocked-note code {
  word-break: break-all;
  font-size: 12px;
}

/* Rendered in place of the button when Google Sign-In cannot work at all — an in-app browser or a
   plain-HTTP origin. Left-aligned and breakable so a long LAN/host name never widens the card. */
#googleWebviewNote,
#googleOriginNote {
  margin: 0 0 4px;
  text-align: left;
  overflow-wrap: anywhere;
}

.signin-card {
  max-width: 400px;
  margin: 0 auto;
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 28px 28px 24px;
  text-align: center;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 18px;
  color: var(--color-text-muted);
  font-size: 13px;
}

.auth-divider::before, .auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

.auth-form-inline {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}

.auth-form-inline .auth-submit {
  width: 100%;
  margin-top: 4px;
}

.auth-links {
  text-align: center;
  font-size: 13.5px;
  color: var(--color-text-muted);
  margin: 4px 0 0;
}

.auth-links a { color: var(--color-primary-dark); font-weight: 600; }
.auth-links a:hover { text-decoration: underline; }

.auth-page {
  max-width: 640px;
  padding-top: 48px;
  padding-bottom: 64px;
}

.auth-card h1 {
  font-size: 24px;
  margin: 0 0 8px;
}

.auth-subtitle {
  color: var(--color-text-muted);
  font-size: 14px;
  margin: 0 0 20px;
}

.auth-section-title {
  font-size: 16px;
  margin: 24px 0 4px;
}

.security-question-row { margin-bottom: 4px; }

.security-question-custom {
  margin-top: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}

.auth-form-actions {
  justify-content: space-between;
  align-items: center;
}

.features {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.feature-card {
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.feature-card .feature-icon {
  font-size: 28px;
  margin-bottom: 12px;
}

.feature-card h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

.feature-card p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 14.5px;
}

/* ---------------------------------------------------------
   App shell (sidebar + topbar + main)
   --------------------------------------------------------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background:
    radial-gradient(420px 260px at 100% 0%, var(--color-sidebar-glow), transparent 70%),
    radial-gradient(320px 300px at 0% 100%, rgba(37, 99, 235, 0.35), transparent 72%),
    var(--gradient-sidebar);
  color: #e8eefb;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  border-right: 1px solid rgba(56, 189, 248, 0.22);
  box-shadow: 8px 0 32px rgba(4, 26, 48, 0.28);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  margin-bottom: 8px;
}

.brand-mark-link {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

/* Icon-only eco-fin mark: no wordmark. Deliberately smaller than the Micro2media badge — the partner
   logo leads the sidebar, eco-fin is the product mark beside it. */
.brand-mark {
  display: block;
  height: 34px;
  width: auto;
  border-radius: 11px;
  box-shadow: 0 6px 16px rgba(4, 26, 48, 0.34);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.brand-mark-link:hover .brand-mark {
  transform: translateY(-1px) scale(1.04);
  box-shadow: 0 10px 24px rgba(56, 189, 248, 0.35);
}

.sidebar-brand .brand-logo {
  height: 34px;
}

.sidebar-brand .brand-divider {
  background: rgba(255, 255, 255, 0.2);
}

/* The Micro2media badge sits top-left and leads the brand row: bigger than the eco-fin mark. */
.sidebar-brand .micro2media-logo {
  height: 30px;
}

.sidebar-brand .micro2media-badge {
  padding: 7px 12px;
  box-shadow: 0 4px 14px rgba(4, 26, 48, 0.22);
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(195, 214, 244, 0.25) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(195, 214, 244, 0.22); border-radius: 999px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 999px;
  color: #c3d6f4;
  font-size: 14.5px;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), transform 0.15s var(--ease);
}

.nav-link:hover { background: rgba(255, 255, 255, 0.09); color: #fff; transform: translateX(2px); }

.nav-link.active {
  background: linear-gradient(135deg, #2f7bf6, #1d4ed8 60%, #16418f);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(24, 90, 210, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.nav-group-label {
  margin: 14px 12px 4px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(195, 214, 244, 0.58);
}

.nav-group-label:first-child { margin-top: 2px; }


.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.logout-link { color: #f3b0b0; }
.logout-link:hover { background: rgba(239, 68, 68, 0.15); color: #fff; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 30;
}

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(29, 78, 216, 0.14);
  box-shadow: 0 1px 0 rgba(12, 35, 64, 0.04), 0 6px 20px rgba(12, 35, 64, 0.05);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title {
  font-size: 19px;
  font-weight: 700;
  margin: 0;
  flex: 1;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-border);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--color-primary);
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text);
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 4px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}

.hamburger span {
  width: 22px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
}

.main-content {
  padding: 24px;
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

/* ---------------------------------------------------------
   Cards / stats / grids
   --------------------------------------------------------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.card {
  background: var(--color-card);
  border: 1px solid rgba(29, 78, 216, 0.07);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.stat-card .stat-label {
  color: var(--color-text-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 8px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  margin: 0;
}

.stat-card .stat-value.negative { color: var(--color-danger); }
.stat-card .stat-value.positive { color: var(--color-primary-dark); }

.stat-delta {
  font-size: 13px;
  margin-top: 6px;
  font-weight: 600;
}

.stat-delta.up { color: var(--color-primary-dark); }
.stat-delta.down { color: var(--color-danger); }
.stat-delta.neutral { color: var(--color-text-muted); }

/* Projected FIRE age: the plan's age and the profile's desired age, side by side in the same units
   (age on top, calendar year underneath) so the gap between them is read at a glance. */
.fire-age-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 4px 0 10px;
}

.fire-age-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 10px);
  background: #fafcff;
}

.fire-age-cell.is-plan.is-ahead,
.fire-age-cell.is-plan.is-even {
  border-color: rgba(29, 78, 216, 0.35);
  background: rgba(29, 78, 216, 0.05);
}

.fire-age-cell.is-plan.is-behind {
  border-color: rgba(198, 40, 40, 0.35);
  background: rgba(198, 40, 40, 0.05);
}

.fire-age-what {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.fire-age-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.fire-age-cell.is-plan.is-ahead .fire-age-value,
.fire-age-cell.is-plan.is-even .fire-age-value { color: var(--color-primary-dark); }

.fire-age-cell.is-plan.is-behind .fire-age-value { color: var(--color-danger); }

.fire-age-note {
  font-size: 12px;
  color: var(--color-text-muted);
}

.fire-age-note a { color: var(--color-primary-dark); font-weight: 600; }

@media (max-width: 480px) {
  .fire-age-value { font-size: 22px; }
  .fire-age-cell { padding: 7px 8px; }
}

.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}

.chart-card canvas { max-height: 280px; }

.chart-card h2, .section-card h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}

/* ---------------------------------------------------------
   Tables
   --------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th, .data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.data-table th {
  color: var(--color-text-muted);
  font-weight: 600;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.data-table tbody tr:hover { background: #fafcff; }

/* Record rows that open their edit dialog on a click anywhere inside them (assets, expenses,
   calendar — see the delegated handler in assets/js/app.js). The tint and the pointer only appear
   for rows that really are editable, and the focus ring keeps the keyboard path visible. */
.data-table tbody tr[data-edit-row] { cursor: pointer; }

.data-table tbody tr[data-edit-row]:hover { background: rgba(29, 78, 216, 0.055); }

.data-table tbody tr[data-edit-row]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}

/* On a phone the row is the only comfortable tap target, so the hint goes into the first cell of the
   table instead of relying on the pencil icon being hit. */
@media (hover: none) {
  .table-wrap:has(tr[data-edit-row])::after {
    content: 'Tap a row to edit it';
    display: block;
    padding: 8px 2px 0;
    font-size: 12px;
    color: var(--color-text-muted);
  }
}

/* The row built on the user's own withdrawal rate (distribution scenarios on the FIRE page). */
.data-table tbody tr.is-base-rate td {
  background: #f2f8ff;
  font-weight: 600;
}
.data-table tbody tr.is-base-rate td .form-hint { font-weight: 400; }

/* Distribution scenarios (FIRE page): three wide columns that wrap instead of scrolling. The generic
   .data-table sets white-space: nowrap on every cell, which is what pushed the older five-column
   version of this table into a horizontal scrollbar on a normal laptop screen. */
table.dist-table {
  table-layout: fixed;
}

table.dist-table th:nth-child(1) { width: 23%; }
table.dist-table th:nth-child(2) { width: 29%; }
table.dist-table th:nth-child(3) { width: 48%; }

table.dist-table td {
  white-space: normal;
  vertical-align: top;
  overflow-wrap: break-word;
}

table.dist-table td .form-hint {
  display: block;
  margin-top: 4px;
  white-space: normal;
}

@media (max-width: 780px) {
  table.dist-table { table-layout: auto; }
  table.dist-table th:nth-child(1),
  table.dist-table th:nth-child(2),
  table.dist-table th:nth-child(3) { width: auto; }
}

/* Cells that wrap. The generic table above keeps every cell on one line so figures line up in a
   scannable list, but a table of *sentences* (the FIRE page's "where you stand today", one-off
   payments, pension streams and timeline) then pushes the whole table past the card and forces a
   horizontal scrollbar. Opting those tables into wrapping lets the text break instead, so the table
   always fits its container. */
table.data-table.wrap-cells td,
table.data-table.wrap-cells th {
  white-space: normal;
  overflow-wrap: break-word;
  vertical-align: top;
}

table.data-table.wrap-cells td .form-hint {
  display: block;
  margin-top: 2px;
}

/* A category row in the assets breakdown ("Pension", "Other assets"…) with its explanation under it. */
.data-table td.breakdown-cat { font-weight: 600; }

/* Gains / losses inside a table (a surplus over the target, or a gap to it). */
.data-table td.positive { color: var(--color-primary-dark); font-weight: 600; }
.data-table td.negative { color: var(--color-danger-dark); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #e3ecfb;
  color: var(--color-primary-dark);
}

.badge.liabilities { background: #fdecec; color: var(--color-danger-dark); }

.row-actions { display: flex; gap: 8px; }

/* ---------------------------------------------------------
   Buttons / forms
   --------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #4a8dff 0%, #2563eb 55%, #1d4ed8 100%);
  box-shadow: 0 10px 26px rgba(29, 78, 216, 0.42);
}

.btn-outline {
  background: #fff;
  border: 1px solid var(--color-border);
  color: var(--color-primary-dark);
}
.btn-outline:hover { background: #eef4ff; border-color: rgba(29, 78, 216, 0.45); color: var(--color-primary); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: var(--color-danger-dark); }

.btn-icon {
  padding: 6px 9px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-sm { padding: 6px 12px; font-size: 13px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 18px;
  padding-bottom: 2px;
}

.tab-btn {
  border: 1px solid var(--color-border);
  background: var(--color-card);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--gradient-primary);
  border-color: var(--color-primary-mid);
  color: #fff;
  box-shadow: 0 3px 10px rgba(29, 78, 216, 0.28);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full { grid-column: 1 / -1; }

.form-section-label {
  margin: 18px 0 8px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.form-section-label:first-child { margin-top: 0; }

.form-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.form-field input, .form-field select, .form-field textarea {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
}

.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
}

.form-hint {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 12.5px;
}

.quick-add-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-add-row input {
  flex: 1;
  min-width: 240px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
}

.quick-add-row input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

/* ---------------------------------------------------------
   Stock/ETF picker + recommendations
   --------------------------------------------------------- */

.symbol-tag {
  display: inline-block;
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
}

.instrument-fields {
  background: #f7faff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.instrument-fields select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
}

.instrument-search-wrap {
  position: relative;
}

.instrument-search-wrap input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
}

.instrument-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  max-height: 220px;
  overflow-y: auto;
  z-index: 10;
}

.instrument-result {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 9px 12px;
  font-size: 13.5px;
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
}

.instrument-result:last-child { border-bottom: none; }
.instrument-result:hover { background: #f1f5fb; }

.instrument-result-empty {
  padding: 9px 12px;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* "Use as typed" escape hatch when the symbol lookup finds nothing. */
.instrument-result-custom {
  color: var(--color-primary-dark);
  font-weight: 600;
  border-top: 1px dashed var(--color-border);
}

.instrument-result-custom:hover { background: #eef4fc; }

/* A holding saved from typed text that was never matched to a curated instrument. */
.holding-row input.holding-search-custom {
  border-style: dashed;
  border-color: var(--color-primary);
  background: #f7faff;
}

.instrument-info { font-size: 13.5px; }

.holding-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 90px 110px 36px 36px;
  gap: 8px;
  align-items: start;
  margin-bottom: 10px;
}

.holding-row > * { min-width: 0; }

.holding-row select, .holding-row input {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  width: 100%;
  min-width: 0;
}

.holding-search-wrap { position: relative; min-width: 0; }

@media (max-width: 640px) {
  .holding-row { grid-template-columns: 1fr 1fr; }
  .holding-search-wrap { grid-column: 1 / -1; }
}

.etf-facts {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.etf-facts .stat-label {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.etf-tax-note {
  font-size: 12.5px;
  color: var(--color-text-muted);
  margin: 6px 0;
}

.etf-card { margin-bottom: 16px; }

.etf-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.etf-card-header h3 { margin: 0 0 4px; font-size: 16px; }

.etf-meta {
  margin: 0;
  font-size: 12.5px;
  color: var(--color-text-muted);
}

.etf-tags { margin: 8px 0; display: flex; gap: 6px; flex-wrap: wrap; }

/* Recommendations page — one block per portfolio sleeve (core equity, US, EM, ESG, dividend,
   premium income, bonds, cash, diversifiers). The tables are compact on purpose: they exist so the
   funds that used to be ranked off the page stay visible side by side. */
.etf-sleeve { margin-bottom: 16px; }

.etf-sleeve-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.etf-sleeve-head h3 { margin: 0; font-size: 15.5px; }

.etf-sleeve-note {
  margin: 6px 0 12px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--color-text-muted);
}

.etf-sleeve-table td { vertical-align: top; }

.etf-sleeve-table .holding-symbol,
.etf-sleeve-table .holding-name,
.etf-sleeve-table .holding-meta { display: block; }

.etf-sleeve-table .holding-meta { margin-top: 3px; }

.etf-sleeve-table .row-actions { flex-wrap: nowrap; }

@media (max-width: 640px) {
  .etf-sleeve-table .row-actions { flex-direction: column; align-items: stretch; }
}

/* ---------------------------------------------------------
   Stock & ETF Research page
   --------------------------------------------------------- */

.badge-muted { background: #eef1f7; color: var(--color-text-muted); }
.badge-success { background: #e3ecfb; color: var(--color-primary-dark); }
.badge-warning { background: #fef3e2; color: #b45309; }

.research-search-wrap { position: relative; max-width: 560px; }

.research-search-input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 15px;
  font-family: inherit;
}

.research-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

.research-results { max-height: 320px; }

/* The results sit in the flow directly under the input. On a research page the result list *is* the
   content, so it pushes the page down (and can't cover the empty state or the error banner) instead
   of behaving like a transient autocomplete dropdown that overlays what follows. */
.research-results {
  position: static;
  margin-top: 10px;
  box-shadow: none;
}

.research-result {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
}

.research-result-main { font-size: 13.5px; }
.research-result-meta { font-size: 11.5px; color: var(--color-text-muted); display: flex; align-items: center; gap: 6px; }

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.period-tabs { margin-bottom: 0; }

.chart-wrap { position: relative; }

.instrument-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.instrument-header h2 { margin: 0 0 4px; font-size: 20px; }
.instrument-header-name { font-weight: 500; color: var(--color-text-muted); font-size: 15px; }

.instrument-header-price { text-align: right; }
.price-value { font-size: 26px; font-weight: 800; }
.price-change { font-size: 14px; font-weight: 600; margin-top: 2px; }
.price-change.up { color: var(--color-primary-dark); }
.price-change.down { color: var(--color-danger); }

.fifty-two-week { margin-top: 16px; }
.fifty-two-week-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.fifty-two-week-bar {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--color-danger), var(--color-border) 50%, var(--color-primary));
}
.fifty-two-week-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 14px;
  background: var(--color-text);
  border-radius: 2px;
  transform: translateX(-1px);
}

/* Star rating: a grey 5-star background with a gold overlay clipped to the score's percentage,
   so half/partial stars render smoothly without needing separate icon glyphs. */
.star-rating {
  position: relative;
  display: inline-block;
  font-size: 17px;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 2px;
}
.star-rating-lg { font-size: 28px; }
.star-rating .star-bg { color: #e2e7f0; }
.star-rating .star-fg {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  white-space: nowrap;
  color: #f59e0b;
}

.rating-overall {
  text-align: center;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--color-border);
}
.rating-overall-value { display: block; font-size: 15px; font-weight: 700; margin-top: 6px; }
.rating-overall-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--color-text-muted); }

.rating-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.rating-row {
  background: #f7faff;
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.rating-row-label { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.rating-row-desc { font-size: 12px; color: var(--color-text-muted); margin-top: 6px; }

.replication-note {
  margin-top: 18px;
  padding: 14px;
  background: #f7faff;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}
.replication-note p { margin: 6px 0 0; font-size: 13px; color: var(--color-text-muted); }

.rating-disclaimer {
  margin: 18px 0 0;
  font-size: 11.5px;
  color: var(--color-text-muted);
  font-style: italic;
}

/* ---------------------------------------------------------
   Modal
   --------------------------------------------------------- */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-backdrop.visible { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
}

.modal-lg { max-width: 760px; }

.modal h2 { margin: 0 0 16px; font-size: 18px; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-text-muted);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ---------------------------------------------------------
   Profile page
   --------------------------------------------------------- */

.profile-card {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--color-border);
}

.profile-meta h2 { margin: 0 0 4px; font-size: 20px; }
.profile-meta p { margin: 0; color: var(--color-text-muted); font-size: 14px; }

.danger-zone {
  border: 1px solid #fbdada;
  background: #fff7f7;
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-top: 18px;
}

.danger-zone h2 { color: var(--color-danger-dark); }

/* ---------------------------------------------------------
   Footer + back to top (shared across all pages)
   --------------------------------------------------------- */

.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-card);
  margin-top: auto;
}

.footer-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.footer-copy {
  margin: 0;
  font-size: 13px;
  color: var(--color-text-muted);
}

.powered-by {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.back-to-top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.4);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
  z-index: 60;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover { background: var(--color-primary-dark); }

/* ---------------------------------------------------------
   Alerts
   --------------------------------------------------------- */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-error { background: #fdecec; color: var(--color-danger-dark); }
.alert-warning { background: #fef3e2; color: #b45309; }
.alert-success { background: #e3ecfb; color: var(--color-primary-dark); }


.market-scale { font-size: 13px; font-weight: 600; color: var(--color-text-muted); margin-left: 2px; }

.market-subline {
  margin: 2px 0 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.market-subline-sm {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--color-text-muted);
}

.fg-gauge {
  position: relative;
  height: 6px;
  border-radius: 999px;
  margin-top: 10px;
  background: linear-gradient(90deg, #ef4444, #f59e0b 25%, #e2e7f0 50%, #84cc16 75%, #16a34a);
}

.fg-gauge-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 14px;
  background: var(--color-text);
  border-radius: 2px;
  transform: translateX(-1px);
}

/* Gauge head + VIX scale bar (Market tab) */
.gauge-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 2px; }
.gauge-head .stat-label { margin: 0; }

.gauge-card-up { border-left: 4px solid #16a34a; }
.gauge-card-neutral { border-left: 4px solid var(--color-primary); }
.gauge-card-warn { border-left: 4px solid #f59e0b; }
.gauge-card-down { border-left: 4px solid #ef4444; }

.scale-bar {
  position: relative;
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #16a34a, #84cc16 30%, #f59e0b 62%, #ef4444);
}

.scale-bar-marker {
  position: absolute;
  top: -4px;
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: #0f1e35;
  box-shadow: 0 0 0 2px #fff;
  transform: translateX(-1.5px);
}

.scale-bar-labels {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  margin-top: 5px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
}

/* Screen-reader-only helper */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------------------------------------------------------
   AI Finance Chat — chat widget
   --------------------------------------------------------- */

.chat-quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chat-quick-actions .tab-btn {
  font-weight: 500;
  color: var(--color-text);
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: min(60vh, 620px);
  min-height: 220px;
  overflow-y: auto;
  padding: 4px 6px 8px;
  margin-bottom: 14px;
  scrollbar-width: thin;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 999px; }

.chat-bubble { display: flex; flex-direction: column; gap: 4px; max-width: 86%; }
.chat-bubble-user { align-self: flex-end; align-items: flex-end; }
.chat-bubble-assistant { align-self: flex-start; align-items: flex-start; max-width: 94%; }

.chat-bubble-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.chat-avatar {
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(29, 78, 216, 0.12);
  color: var(--color-primary-dark);
}

.chat-avatar-user { background: #e3e9f4; color: var(--color-text-muted); }
.chat-avatar-ai { background: rgba(29, 78, 216, 0.12); color: var(--color-primary-dark); }
.chat-time { font-variant-numeric: tabular-nums; }

.chat-day {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.chat-day::before, .chat-day::after { content: ''; flex: 1; height: 1px; background: var(--color-border); }

.chat-dots { display: inline-flex; gap: 3px; vertical-align: 1px; }
.chat-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-primary);
  animation: chat-dot 1.1s infinite ease-in-out;
}
.chat-dots span:nth-child(2) { animation-delay: 0.15s; }
.chat-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chat-dot {
  0%, 100% { opacity: 0.25; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

.chat-bubble-content {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.58;
  white-space: normal;
  word-break: break-word;
}

.chat-bubble-content p { margin: 0 0 10px; line-height: 1.62; }
.chat-bubble-content p:last-child { margin-bottom: 0; }
.chat-bubble-content p:first-child { margin-top: 0; }
.chat-bubble-content .chat-list { margin: 2px 0 10px; padding-left: 20px; }
.chat-bubble-content .chat-list:last-child { margin-bottom: 0; }
.chat-bubble-content ul.chat-list { list-style: disc; }
.chat-bubble-content ol.chat-list { list-style: decimal; }
.chat-bubble-content .chat-list li { margin-bottom: 6px; line-height: 1.55; }
.chat-bubble-content .chat-list li:last-child { margin-bottom: 0; }
.chat-bubble-content > p + .chat-list { margin-top: 4px; }
.chat-bubble-content strong { font-weight: 700; }
.chat-bubble-content code {
  background: rgba(16, 32, 43, 0.06);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 12.5px;
}

.chat-bubble-user .chat-bubble-content {
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble-assistant .chat-bubble-content {
  background: #ffffff;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(16, 32, 43, 0.04);
  max-width: 100%;
}

.chat-bubble-typing .chat-bubble-content {
  color: var(--color-text-muted);
  font-style: italic;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  position: sticky;
  bottom: 0;
  padding: 10px 0 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 38%);
}

.chat-input {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.45;
  max-height: 160px;
  background: #fff;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.chat-input::placeholder { color: #8c9bb3; }

.chat-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

.chat-input-row .btn { flex-shrink: 0; }

@media (max-width: 640px) {
  .chat-bubble { max-width: 92%; }
  .chat-messages { max-height: 360px; }
}

/* --- Ask eco-fin AI: Chat / Previous discussions tabs --------------------- */

.chat-card { margin-bottom: 18px; }

.chat-card .page-header { margin-bottom: 12px; }

.chat-tabs { margin-bottom: 14px; }

.chat-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  margin-left: 2px;
  border-radius: 999px;
  background: rgba(16, 32, 43, 0.08);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.chat-tabs .tab-btn.active .chat-tab-count { background: rgba(255, 255, 255, 0.26); color: #fff; }

.chat-view[hidden] { display: none; }

.discussion-toolbar { margin-bottom: 12px; }

.discussion-search {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--color-text);
}

.discussion-search:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}

.discussion-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.discussion-list::-webkit-scrollbar { width: 6px; }
.discussion-list::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 999px; }

.discussion {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
  overflow: hidden;
}

.discussion[open] { border-color: rgba(29, 78, 216, 0.35); box-shadow: 0 1px 2px rgba(16, 32, 43, 0.05); }

.discussion > summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}

.discussion > summary::-webkit-details-marker { display: none; }
.discussion > summary:hover { background: #f7f9fd; }

.discussion-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.discussion-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary-dark);
}

.discussion-when {
  font-size: 11.5px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.discussion-question { font-size: 14px; font-weight: 600; line-height: 1.45; color: var(--color-text); }
.discussion-preview { font-size: 12.5px; line-height: 1.5; color: var(--color-text-muted); }

.discussion-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--color-border);
}

.discussion-body .chat-bubble { max-width: 100%; }
.discussion-body .chat-bubble-user { max-width: 92%; }

.discussion-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }

.chat-bubble-flash .chat-bubble-content { animation: chat-flash 1.6s ease; }

@keyframes chat-flash {
  0%, 100% { box-shadow: 0 0 0 0 rgba(29, 78, 216, 0); }
  25% { box-shadow: 0 0 0 4px rgba(29, 78, 216, 0.28); }
}

@media (max-width: 640px) {
  .discussion-list { max-height: 420px; }
  .discussion-when { font-size: 11px; }
}

/* ---------------------------------------------------------
   Calendar — AI news suggestions
   --------------------------------------------------------- */

.news-suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.news-suggestion:last-child { border-bottom: none; }

.news-suggestion-title { margin: 0; font-size: 14px; font-weight: 600; }
.news-suggestion-meta { margin: 2px 0 0; font-size: 12.5px; color: var(--color-text-muted); }

/* ---------------------------------------------------------
   Market Desk reception agent
   --------------------------------------------------------- */

.reception-card { display: flex; flex-direction: column; gap: 14px; }

.reception-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.reception-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-border);
  flex-shrink: 0;
}

.status-dot.status-active, .status-dot.status-listening, .status-dot.status-speaking, .status-dot.status-thinking {
  background: var(--color-primary);
  box-shadow: 0 0 0 0 rgba(29, 78, 216, 0.5);
  animation: reception-pulse 1.6s infinite;
}

@keyframes reception-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(29, 78, 216, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(29, 78, 216, 0); }
  100% { box-shadow: 0 0 0 0 rgba(29, 78, 216, 0); }
}

.reception-controls { display: flex; align-items: center; gap: 8px; }

.mic-listening {
  background: var(--color-danger) !important;
  color: #fff !important;
  border-color: var(--color-danger) !important;
}

/* ---------------------------------------------------------
   Responsive
   --------------------------------------------------------- */

@media (max-width: 900px) {
  .charts-grid { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.visible { display: block; }

  .hamburger { display: flex; }
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .footer-inner { flex-direction: column; text-align: center; }
}

/* ---------------------------------------------------------
   Shared chips, badges & page-level helpers
   --------------------------------------------------------- */

.badge-live {
  background: rgba(29, 78, 216, 0.12);
  color: var(--color-primary-dark);
  box-shadow: inset 0 0 0 1px rgba(29, 78, 216, 0.2);
}

.badge-live::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: var(--color-primary);
  vertical-align: 1px;
  animation: ecofin-pulse 1.8s infinite;
}

@keyframes ecofin-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #eef3fb;
  color: var(--color-text-muted);
  border: 1px solid transparent;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.chip-goal { background: rgba(29, 78, 216, 0.10); color: var(--color-primary-dark); }
.chip-risk { background: rgba(56, 189, 248, 0.14); color: #1e40af; }
.chip-horizon { background: rgba(99, 102, 241, 0.10); color: #4338ca; }
.chip-ticker { background: #f1f5f9; color: #334155; font-family: 'SFMono-Regular', Consolas, monospace; letter-spacing: 0.02em; }
.chip-ticker:hover { background: var(--color-primary); color: #fff; }
.chip-edit { background: transparent; border-color: var(--color-border); }
.chip-edit:hover { border-color: var(--color-primary); color: var(--color-primary-dark); }

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.link-muted { font-size: 13px; font-weight: 600; color: var(--color-text-muted); }
.link-muted:hover { color: var(--color-primary-dark); }

.pref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.pref-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(29, 78, 216, 0.08), rgba(56, 189, 248, 0.06));
  border: 1px solid rgba(29, 78, 216, 0.12);
}

.pref-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.pref-value { font-size: 14.5px; font-weight: 700; color: var(--color-text); }

.field-hint {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--color-text-muted);
  font-size: 12px;
}

/* ---------------------------------------------------------
   Market & News — regime hero
   --------------------------------------------------------- */

.market-hero {
  position: relative;
  overflow: hidden;
  padding: 26px 28px 20px;
  margin-bottom: 24px;
  border-left: 5px solid var(--color-primary);
  background:
    radial-gradient(700px 260px at 100% 0%, rgba(56, 189, 248, 0.16), transparent 65%),
    var(--color-card);
}

.market-hero:hover { transform: none; }
.market-hero.tone-up { border-left-color: var(--color-primary); }
.market-hero.tone-warn { border-left-color: #f59e0b; }
.market-hero.tone-down { border-left-color: var(--color-danger); }
.market-hero.tone-neutral { border-left-color: #94a3b8; }

.market-hero-main { display: flex; gap: 18px; align-items: flex-start; }

.regime-icon {
  font-size: 38px;
  line-height: 1;
  padding: 14px;
  border-radius: 18px;
  background: rgba(29, 78, 216, 0.08);
  flex-shrink: 0;
}

.market-hero h2 {
  margin: 4px 0 6px;
  font-size: clamp(20px, 2.4vw, 26px);
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.market-hero-copy { margin: 0; max-width: 720px; color: var(--color-text-muted); font-size: 14.5px; }

.market-hero-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 20px 0 16px;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(248, 251, 251, 0.9);
  border: 1px solid var(--color-border);
}

.hero-stat-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.hero-stat-value { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.hero-stat-value.up { color: var(--color-primary-dark); }
.hero-stat-value.down { color: var(--color-danger); }
.hero-stat-note { font-size: 12px; color: var(--color-text-muted); }

.market-hero-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--color-border);
  padding-top: 14px;
}

.market-as-of { font-size: 12.5px; color: var(--color-text-muted); }

/* ---------------------------------------------------------
   Market & News — charts, gauges, headlines
   --------------------------------------------------------- */

.market-section-head { align-items: flex-end; }

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: 999px;
  background: #e7edf8;
  border: 1px solid var(--color-border);
}

.segmented button {
  border: none;
  background: transparent;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.segmented button:hover { color: var(--color-text); }
.segmented button.active { background: #fff; color: var(--color-primary-dark); box-shadow: var(--shadow-card); }

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.index-card { padding: 18px 20px; border-top: 3px solid var(--color-border); }
.index-card:hover { transform: none; }
.index-card-up { border-top-color: #16a34a; }
.index-card-neutral { border-top-color: var(--color-primary); }
.index-card-warn { border-top-color: #f59e0b; }
.index-card-down { border-top-color: #ef4444; }

.index-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }

.index-card-head .stat-label {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
}

.index-price { margin: 4px 0 0; font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }

.index-chart-wrap { height: 150px; margin: 14px 0 12px; }

.trend-chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.trend-chip {
  display: inline-flex;
  flex-direction: column;
  padding: 5px 10px;
  border-radius: 8px;
  background: #f7f9fd;
  border: 1px solid var(--color-border);
}

.trend-chip-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }
.trend-chip-value { font-size: 12.5px; font-weight: 700; }
.trend-chip-value.up { color: var(--color-primary-dark); }
.trend-chip-value.down { color: var(--color-danger); }

.index-status-hint { margin: 10px 0 0; font-size: 12.5px; color: var(--color-text-muted); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
  background: #eef2f9;
  color: #334155;
}

/* Readable, colour-coded market states — green = healthy/bull, amber = caution/elevated,
   red = stress/bear, blue = neutral/stable. Solid pastel fills read much better at a glance than
   the old translucent tints, especially for "Extreme Fear" / "Elevated" style labels. */
.status-badge.tone-up {
  background: linear-gradient(135deg, #d7f8e3, #f0fdf5);
  color: #0b6b36;
  border-color: #7fd3a2;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.status-badge.tone-warn {
  background: linear-gradient(135deg, #fde9bd, #fffaef);
  color: #9a4a04;
  border-color: #e9b455;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.status-badge.tone-down {
  background: linear-gradient(135deg, #fbd5d5, #fff5f5);
  color: #a51c1c;
  border-color: #e58b8b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}
.status-badge.tone-neutral {
  background: linear-gradient(135deg, #d9e7fd, #f2f7ff);
  color: #1b3d8f;
  border-color: #93b4ec;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.status-badge-sm { padding: 3px 8px; font-size: 10.5px; }
.status-badge-regime { font-size: 12px; padding: 6px 13px; vertical-align: middle; margin-left: 8px; }

.market-lower {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 20px;
}

.news-card { padding: 20px 22px; }
.news-card:hover { transform: none; }

.news-list { display: flex; flex-direction: column; }

.news-item {
  display: block;
  padding: 13px 2px;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s var(--ease);
}

.news-item:last-child { border-bottom: none; }
.news-item:hover { background: #f6f9fe; }

.news-item-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.news-source { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-primary-dark); }
.news-time { font-size: 11.5px; color: var(--color-text-muted); white-space: nowrap; }
.news-title { margin: 4px 0 6px; font-size: 14.5px; font-weight: 600; line-height: 1.4; }
.news-item:hover .news-title { color: var(--color-primary-dark); }

.market-side { display: flex; flex-direction: column; gap: 18px; }

.gauge-card { padding: 18px 20px; }
.gauge-card:hover { transform: none; }
.gauge-card .stat-label { margin: 0 0 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }
.gauge-card .stat-value { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }

.gauge-hint { margin: 8px 0 0; font-size: 12.5px; color: var(--color-text-muted); }

.ai-nudge { background: linear-gradient(160deg, rgba(29, 78, 216, 0.08), rgba(56, 189, 248, 0.07)); }
.ai-nudge:hover { transform: none; }
.ai-nudge h3 { margin: 0 0 6px; font-size: 15px; }
.ai-nudge p { margin: 0 0 10px; font-size: 13.5px; color: var(--color-text-muted); }
.ai-nudge-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.market-disclaimer { margin: 0; font-size: 12.5px; color: var(--color-text-muted); }

/* ---------------------------------------------------------
   Markets & News — shared strip items
   --------------------------------------------------------- */

.news-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.news-strip-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: #f6f9fe;
  border: 1px solid var(--color-border);
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}

.news-strip-item:hover { border-color: var(--color-primary); background: #fff; }
.news-strip-meta { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-primary-dark); }
.news-strip-title { font-size: 13px; font-weight: 600; line-height: 1.4; }

/* ---------------------------------------------------------
   eco-fin AI insights
   --------------------------------------------------------- */

.ai-badge { background: linear-gradient(135deg, var(--color-primary), var(--color-accent)); color: #fff; }
.ai-insights-card { scroll-margin-top: 84px; margin-bottom: 18px; }
.ai-insights-card:hover { transform: none; }

.ai-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: #f6f9ff;
  color: var(--color-text-muted);
  font-size: 13.5px;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(29, 78, 216, 0.25);
  border-top-color: var(--color-primary);
  animation: ecofin-spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes ecofin-spin { to { transform: rotate(360deg); } }

.ai-insight-result { margin-top: 18px; }

.ai-hero {
  padding: 18px 20px;
  border-radius: var(--radius-md);
  background: linear-gradient(155deg, rgba(29, 78, 216, 0.09), rgba(56, 189, 248, 0.07));
  border: 1px solid rgba(29, 78, 216, 0.14);
}

.ai-hero-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ai-generated { margin-left: auto; font-size: 11.5px; color: var(--color-text-muted); }
.ai-summary { margin: 10px 0 0; font-size: 15px; line-height: 1.55; }
.ai-regime-note { margin: 8px 0 0; font-size: 13px; color: var(--color-text-muted); }

.ai-section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 22px 0 10px;
  color: var(--color-text-muted);
}

.ai-action-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: ai-action;
  display: grid;
  gap: 10px;
}

.ai-action-list li {
  counter-increment: ai-action;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  padding: 13px 15px;
  border-radius: var(--radius-md);
  background: #fff;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
}

.ai-action-list li::before {
  content: counter(ai-action);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
}

/* The text block is pinned to the second column and is allowed to shrink: without this a long
   sentence either overflowed the card or forced the 1fr column wider than the card. */
.ai-action-list li > div,
.ai-action-body { grid-column: 2; min-width: 0; }

.ai-action-list strong { display: block; font-size: 14px; line-height: 1.45; }
.ai-action-list span {
  display: block;
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

.ai-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ai-panel { padding: 16px 16px 6px; border-radius: var(--radius-md); border: 1px solid var(--color-border); }
.ai-panel-risks { background: #fff9f5; border-color: #fde3d3; }
.ai-panel-opps { background: #f5f9ff; border-color: #d6e2f7; }

.ai-risk-list { margin: 0; padding-left: 18px; display: grid; gap: 8px; font-size: 13.5px; color: var(--color-text-muted); }
.ai-risk-list li::marker { color: #f59e0b; }

.ai-opp { padding: 8px 0; border-bottom: 1px dashed var(--color-border); }
.ai-opp:last-child { border-bottom: none; }
.ai-opp strong { font-size: 13.5px; }
.ai-opp p { margin: 3px 0 6px; font-size: 13px; color: var(--color-text-muted); }

/* Headline-by-headline insights ("Companies in today's headlines") */
.ai-news-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }

.ai-news-item {
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: #fff;
}

.ai-news-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.ai-news-item strong { display: block; font-size: 13.5px; line-height: 1.4; }
.ai-news-item p { margin: 5px 0 0; font-size: 12.5px; color: var(--color-text-muted); }

.ai-disclaimer { margin: 16px 0 0; font-size: 12px; color: var(--color-text-muted); }
.ai-error { margin: 14px 0 0; font-size: 13px; color: var(--color-danger-dark); }

@media (max-width: 960px) {
  .market-lower { grid-template-columns: 1fr; }
  .ai-two-col { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .market-hero { padding: 20px 18px 16px; }
  .market-hero-main { flex-direction: column; gap: 10px; }
  .regime-icon { font-size: 28px; padding: 10px; }
  .market-section-head { align-items: flex-start; }
  .segmented { overflow-x: auto; }
}


/* ---------------------------------------------------------
   Portfolio fit (Recommendations page) — deterministic,
   portfolio + country aware analysis cards
   --------------------------------------------------------- */

.portfolio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: 22px;
  margin-top: 16px;
}

.portfolio-subtitle {
  margin: 0 0 10px;
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.holding-symbol { display: block; font-size: 13px; }
.holding-name { display: block; font-size: 12.5px; color: var(--color-text-muted); margin: 1px 0 4px; }
.holding-meta { font-size: 12px; color: var(--color-text-muted); }

.portfolio-note {
  border-left: 3px solid var(--color-border);
  background: #f7faff;
  padding: 9px 12px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 10px;
}

.portfolio-note strong { display: block; font-size: 13px; margin-bottom: 2px; }
.portfolio-note p { margin: 0; font-size: 12.5px; color: var(--color-text-muted); line-height: 1.5; }
.portfolio-note-warn { border-left-color: #f59e0b; background: #fef8ee; }
.portfolio-note-bad { border-left-color: var(--color-danger); background: #fdf1f1; }
.portfolio-note-up { border-left-color: var(--color-primary); background: #f1f6fe; }
.portfolio-note-neutral { border-left-color: var(--color-border); background: #f7faff; }

.portfolio-fit-card { border-top: 3px solid var(--color-primary); }

/* Each block inside "Your portfolio fit" is separated, so the card reads as stacked sections. */
.portfolio-grid > div + div {
  border-left: 1px solid var(--color-border);
  padding-left: 22px;
}

.portfolio-divider {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: 20px 0 16px;
}

.portfolio-suggest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.portfolio-suggest {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: #fbfdff;
}

.portfolio-suggest-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.portfolio-suggest-name { margin: 3px 0 6px; font-size: 13px; font-weight: 600; }
.portfolio-suggest-why { margin: 0 0 10px; font-size: 12.5px; color: var(--color-text-muted); line-height: 1.5; }

.portfolio-tax {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.portfolio-tax-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px 18px;
  margin: 0 0 10px;
}

.portfolio-tax-list dt {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.portfolio-tax-list dd { margin: 2px 0 0; font-size: 12.8px; line-height: 1.5; }

.portfolio-tax-tips { margin: 0; padding-left: 18px; font-size: 12.8px; color: var(--color-text-muted); }
.portfolio-tax-tips li { margin-bottom: 4px; }

/* ESG & green investments (Recommendations) */
.esg-card { border-top: 3px solid #16a34a; }

.esg-block { margin-top: 20px; }

.esg-block + .esg-block {
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.esg-block .portfolio-subtitle { margin-bottom: 6px; }

.esg-block-note {
  margin: 0 0 10px;
  font-size: 12.8px;
  color: var(--color-text-muted);
  line-height: 1.55;
  max-width: 78ch;
}

.esg-table td:first-child { min-width: 260px; }

/* The "why" line under a fund name: same voice as .holding-meta but allowed to run to a sentence. */
.esg-why {
  display: block;
  margin-top: 5px;
  font-size: 12.3px;
  color: var(--color-text-muted);
  line-height: 1.5;
  max-width: 66ch;
}

/* The single-theme warning that travels with a green fund, kept visually distinct from the neutral text. */
.esg-risk {
  display: block;
  margin-top: 5px;
  padding: 6px 9px;
  font-size: 12px;
  line-height: 1.5;
  color: #8a5a12;
  background: #fef8ee;
  border-left: 3px solid #f59e0b;
  border-radius: 0 6px 6px 0;
  max-width: 70ch;
}

.esg-held {
  margin: 0 0 10px;
  padding: 8px 11px;
  font-size: 12.8px;
  background: #f1f8f2;
  border-left: 3px solid #16a34a;
  border-radius: 0 6px 6px 0;
}

.esg-stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.esg-stock {
  display: flex;
  flex-direction: column;
  padding: 12px;
  background: #fbfdff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.esg-stock-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.esg-stock-sector {
  font-size: 10.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.esg-stock-name { margin: 2px 0 6px; font-size: 13px; font-weight: 600; }

.esg-stock-note {
  flex: 1 1 auto;
  margin: 0 0 8px;
  font-size: 12.4px;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.esg-disclaimer {
  margin: 18px 0 0;
  padding: 10px 12px;
  font-size: 12.2px;
  line-height: 1.55;
  color: var(--color-text-muted);
  background: #f7faff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

@media (max-width: 640px) {
  .esg-table td:first-child { min-width: 0; }
  .esg-stock-grid { grid-template-columns: 1fr; }
}

/* MAI insights — portfolio fit bullets & tailored additions */
.ai-fit-list { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px; }
.ai-addition-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }

.ai-addition {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px;
  background: #ffffff;
}

.ai-addition-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11.5px;
  color: var(--color-text-muted);
}

.ai-addition-name { margin: 3px 0 6px; font-size: 13px; font-weight: 600; }
.ai-addition-why { margin: 0 0 10px; font-size: 12.5px; color: var(--color-text-muted); line-height: 1.5; }

@media (max-width: 960px) {
  .portfolio-grid { grid-template-columns: 1fr; }
  .portfolio-grid > div + div {
    border-left: 0;
    padding-left: 0;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
  }
}





/* ---------------------------------------------------------
   Market phase strip (bull / stable / correction / bear)
   --------------------------------------------------------- */

.phase-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}

.phase-tile {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-text-muted);
  opacity: 0.62;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.phase-tile .phase-emoji { font-size: 15px; }

.phase-tile.is-active {
  opacity: 1;
  transform: translateY(-1px);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 6px 18px rgba(12, 35, 64, 0.18);
}

.phase-tile.is-active.phase-up { background: linear-gradient(135deg, #16a34a, #15803d); }
.phase-tile.is-active.phase-neutral { background: var(--gradient-primary); }
.phase-tile.is-active.phase-warn { background: linear-gradient(135deg, #f59e0b, #b45309); }
.phase-tile.is-active.phase-down { background: linear-gradient(135deg, #ef4444, #b91c1c); }

/* ---------------------------------------------------------
   Inline sparklines (server-rendered SVG)
   --------------------------------------------------------- */

.sparkline { display: block; width: 100%; height: 38px; margin-top: 10px; overflow: visible; }
.sparkline-line { stroke: #94a3b8; }
.sparkline-area { fill: rgba(148, 163, 184, 0.12); }
.sparkline-flat { stroke: #cbd5e1; }

.sparkline-up .sparkline-line { stroke: #16a34a; }
.sparkline-up .sparkline-area { fill: rgba(22, 163, 74, 0.14); }
.sparkline-down .sparkline-line { stroke: #ef4444; }
.sparkline-down .sparkline-area { fill: rgba(239, 68, 68, 0.14); }
.sparkline-warn .sparkline-line { stroke: #f59e0b; }
.sparkline-warn .sparkline-area { fill: rgba(245, 158, 11, 0.16); }
.sparkline-neutral .sparkline-line { stroke: var(--color-primary); }
.sparkline-neutral .sparkline-area { fill: var(--color-primary-soft); }


/* ---------------------------------------------------------
   Chat page — market context strip
   --------------------------------------------------------- */

.chat-market {
  display: block;
  margin-top: 0;
  padding: 20px 22px 18px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(29, 78, 216, 0.16);
  background:
    radial-gradient(520px 200px at 100% 0%, rgba(56, 189, 248, 0.15), transparent 65%),
    linear-gradient(180deg, #ffffff, #f7faff);
  box-shadow: var(--shadow-card);
}

.chat-market-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.chat-market-title {
  margin: 0 0 4px;
  font-size: 17px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.chat-market-sub { margin: 0; font-size: 13px; color: var(--color-text-muted); max-width: 720px; }
.chat-market-sub a { color: var(--color-primary); font-weight: 600; }
.chat-market-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.chat-market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
}

.chat-market-tile {
  padding: 12px 14px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: #fff;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.chat-market-tile:hover { border-color: rgba(29, 78, 216, 0.35); box-shadow: 0 8px 20px rgba(12, 35, 64, 0.07); }

.chat-market-tile-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.chat-market-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-market-value {
  margin: 6px 0 0;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-market-suffix { font-size: 12px; font-weight: 600; color: var(--color-text-muted); }
.chat-market-change { font-size: 12px; font-weight: 700; }
.chat-market-change.up { color: #15803d; }
.chat-market-change.down { color: var(--color-danger-dark); }
.chat-market-change.neutral { color: var(--color-text-muted); }

.chat-market-note { margin: 14px 0 0; font-size: 12px; line-height: 1.55; color: var(--color-text-muted); }

@media (max-width: 640px) {
  .chat-market { padding: 16px 15px 14px; }
  .chat-market-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .chat-market-value { font-size: 18px; }
}


/* ---------------------------------------------------------
   Profile — investor preference choice cards
   --------------------------------------------------------- */

.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }

.choice-card { position: relative; display: block; cursor: pointer; }

.choice-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.choice-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  height: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--color-border);
  background: #fff;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}

.choice-card:hover .choice-body { border-color: rgba(29, 78, 216, 0.45); }

.choice-card input:checked + .choice-body {
  border-color: var(--color-primary);
  background: linear-gradient(160deg, #eef4ff, #ffffff);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.choice-card input:focus-visible + .choice-body { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.choice-title { font-size: 13.5px; font-weight: 700; }
.choice-desc { font-size: 12px; color: var(--color-text-muted); line-height: 1.45; }

/* ---------------------------------------------------------
   Research — chart fallback & loading skeletons
   --------------------------------------------------------- */

.chart-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 180px;
  margin: 0;
  padding: 18px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  background: #fbfdff;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
}

.skeleton-line {
  height: 12px;
  border-radius: 999px;
  background: linear-gradient(90deg, #eef2f9 25%, #e2ecfb 37%, #eef2f9 63%);
  background-size: 400% 100%;
  animation: skeleton-sweep 1.4s ease infinite;
}

@keyframes skeleton-sweep {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

.research-result .research-result-main { display: block; font-size: 13.5px; }
.research-result .research-result-meta { display: block; margin-top: 2px; font-size: 11.5px; color: var(--color-text-muted); }


/* ---------------------------------------------------------
   Calendar — month view of tasks, appointments & finance events
   --------------------------------------------------------- */

.calendar-card { padding: 20px 22px; }
.calendar-card:hover { transform: none; }

.calendar-head { align-items: flex-start; gap: 14px; }

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.calendar-month {
  min-width: 138px;
  text-align: center;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--color-primary-dark);
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-weekdays {
  margin: 14px 0 8px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  text-align: center;
}

.cal-day {
  min-height: 92px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: #fff;
  padding: 6px 6px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}

.cal-day:hover {
  border-color: rgba(29, 78, 216, 0.45);
  box-shadow: 0 6px 16px rgba(12, 35, 64, 0.1);
}

.cal-day.is-outside { background: #f7f9fd; }

.cal-day.is-today {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.16);
}

.cal-day-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  align-self: flex-start;
  padding: 1px 5px;
  border-radius: 6px;
}

.cal-day.is-today .cal-day-num { background: var(--color-primary); color: #fff; }

.cal-day-events { display: flex; flex-direction: column; gap: 3px; overflow: hidden; }

.cal-chip {
  display: flex;
  gap: 4px;
  align-items: baseline;
  width: 100%;
  border: none;
  border-radius: 7px;
  padding: 3px 6px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: filter 0.15s var(--ease);
}

.cal-chip:hover { filter: brightness(0.94); }

.cal-chip-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-chip-time { font-weight: 800; flex-shrink: 0; }

.cal-chip-appointment { background: #dbeafe; color: #1a3f8f; }
.cal-chip-task { background: #dcf7e6; color: #0b6b36; }
.cal-chip-news { background: #fde9bd; color: #8a4104; }

.cal-more { font-size: 10px; font-weight: 700; color: var(--color-text-muted); padding-left: 4px; }

/* Closed items: a closed task or appointment leaves the month view under the Active filter, and is
   drawn struck-through when the Closed / All filter shows it instead. */
.cal-chip.is-done { opacity: 0.55; text-decoration: line-through; }

.calendar-filter { margin: -2px 0 14px; }

.calendar-filter-count {
  margin-left: 3px;
  font-size: 11.5px;
  font-weight: 800;
  opacity: 0.7;
}

.data-table th.col-done,
.data-table td.col-done { width: 96px; white-space: nowrap; }

.done-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
}

.done-toggle input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--color-primary);
}

.done-toggle input:checked + .done-toggle-text { color: #15803d; font-weight: 700; }

.event-row-done .event-title-cell { text-decoration: line-through; color: var(--color-text-muted); }
.event-row-done td:not(.col-done):not(.row-actions) { opacity: 0.72; }

.form-actions-with-delete #eventDeleteBtn { margin-right: auto; }

.calendar-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 11.5px;
  color: var(--color-text-muted);
}

.cal-legend-item { display: inline-flex; align-items: center; gap: 6px; }

.cal-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.cal-dot-appointment { background: #2563eb; }
.cal-dot-task { background: #16a34a; }
.cal-dot-news { background: #d97706; }

/* ---------------------------------------------------------
   Market Desk (reception agent) + Markets & News AI events
   --------------------------------------------------------- */

.reception-hero { margin-bottom: 18px; }
.reception-hero:hover { transform: none; }
.reception-temp { margin-top: 14px; }

.reception-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reception-quick .chip { cursor: pointer; }

.reception-disclaimer {
  margin: 4px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--color-text-muted);
}

.ai-mood { margin: 0 0 12px; font-size: 13px; color: var(--color-text); }

.market-ai-events { padding: 20px 22px; margin-bottom: 20px; }
.market-ai-events:hover { transform: none; }

@media (max-width: 960px) {
  .cal-day { min-height: 74px; }
  .cal-chip { font-size: 10px; }
}

@media (max-width: 720px) {
  .calendar-card { padding: 16px 14px; }
  .cal-day { min-height: 62px; border-radius: 10px; padding: 4px; }
  .cal-chip { justify-content: center; }
  .cal-chip-title { display: none; }
  .calendar-nav { width: 100%; justify-content: space-between; }
}

/* ---------------------------------------------------------
   Market state colour scale
   bull = RED (hot / expensive), stable = ORANGE,
   correction = YELLOW, bear = GREEN (cheap / opportunity).
   One rule per state, used by status badges, index cards,
   the phase strip and the legend dots.
   --------------------------------------------------------- */

.status-badge.tone-bull {
  background: linear-gradient(135deg, #fbd5d5, #fff5f5);
  color: #a51c1c;
  border-color: #e58b8b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}
.status-badge.tone-stable {
  background: linear-gradient(135deg, #fde3c2, #fff8ef);
  color: #9a4a04;
  border-color: #eda75b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}
.status-badge.tone-correction {
  background: linear-gradient(135deg, #fbf0b8, #fffdf0);
  color: #7a5c04;
  border-color: #ddc14f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}
.status-badge.tone-bear {
  background: linear-gradient(135deg, #d7f8e3, #f0fdf5);
  color: #0b6b36;
  border-color: #7fd3a2;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.index-card-bull { border-top-color: #ef4444; }
.index-card-stable { border-top-color: #f59e0b; }
.index-card-correction { border-top-color: #eab308; }
.index-card-bear { border-top-color: #16a34a; }

.market-hero.tone-bull { border-left-color: #ef4444; }
.market-hero.tone-stable { border-left-color: #f59e0b; }
.market-hero.tone-correction { border-left-color: #eab308; }
.market-hero.tone-bear { border-left-color: #16a34a; }

.phase-tile.is-active.phase-bull { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.phase-tile.is-active.phase-stable { background: linear-gradient(135deg, #f59e0b, #b45309); }
.phase-tile.is-active.phase-correction { background: linear-gradient(135deg, #eab308, #a16207); }
.phase-tile.is-active.phase-bear { background: linear-gradient(135deg, #16a34a, #15803d); }

.market-tone-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin: -8px 0 18px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  font-size: 12.5px;
}

.market-tone-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  color: var(--color-text);
}

.market-tone-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.market-tone-dot.tone-bull { background: #ef4444; }
.market-tone-dot.tone-stable { background: #f59e0b; }
.market-tone-dot.tone-correction { background: #eab308; }
.market-tone-dot.tone-bear { background: #16a34a; }

.market-tone-legend-note { margin-left: auto; font-size: 12px; color: var(--color-text-muted); }

/* Horizontal rule that separates the month grid from the appointments table. */
.section-divider {
  height: 1px;
  border: 0;
  margin: 28px 0 18px;
  background: linear-gradient(90deg, var(--color-border), rgba(219, 228, 242, 0.1));
}

/* Headline rows on Markets & News can be dropped straight into the eco-fin calendar. */
.news-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border-bottom: 1px solid var(--color-border);
}

.news-row:last-child { border-bottom: none; }
.news-row .news-item { flex: 1 1 auto; min-width: 0; border-bottom: none; }

.news-row-actions { flex: 0 0 auto; padding-top: 10px; }

.news-add-cal { white-space: nowrap; }

/* Your own market/economic entries, surfaced on Markets & News. */
.market-cal-list { display: flex; flex-direction: column; gap: 8px; }

.market-cal-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: #f9fbff;
  font-size: 13.5px;
}

.market-cal-date {
  font-weight: 700;
  color: var(--color-primary-dark);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.market-cal-note { color: var(--color-text-muted); font-size: 12.5px; }

/* Per-expense currencies */
.expense-currency {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--color-primary-dark);
}

.monthly-total-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }

.monthly-total-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: #f7f9fd;
  font-size: 12.5px;
  font-weight: 700;
}

/* Previous-discussion sessions */
.discussion-session-title { font-size: 14.5px; font-weight: 700; line-height: 1.4; color: var(--color-text); }

.discussion-session-count {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-size: 11px;
  font-weight: 700;
}

.discussion-turn { display: flex; flex-direction: column; gap: 8px; }
.discussion-turn + .discussion-turn { border-top: 1px dashed var(--color-border); padding-top: 10px; }

.discussion-q { font-size: 13.5px; font-weight: 700; color: var(--color-text); }

.discussion-turn-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Research page: which listing the data actually came from */
.research-resolved { margin: 0 0 12px; font-size: 12.5px; color: var(--color-warn); font-weight: 600; }


/* =========================================================================
   Ask MAI — session browser (list on the right, open thread on the left)
   ========================================================================= */

.discussion-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(260px, 1fr);
  gap: 16px;
  align-items: start;
}

.discussion-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 300px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
}

.discussion-main-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

.discussion-main-kicker {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-primary-dark);
}

.discussion-main-title {
  margin: 3px 0 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--color-text);
  word-break: break-word;
}

.discussion-main-meta {
  margin: 3px 0 0;
  font-size: 12px;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.discussion-main-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex-shrink: 0;
}

.discussion-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 460px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.discussion-thread::-webkit-scrollbar { width: 6px; }
.discussion-thread::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: 999px; }

.discussion-thread .chat-bubble { max-width: 100%; }
.discussion-thread .chat-bubble-user { max-width: 92%; }

.discussion-live-note {
  margin: 0;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.discussion-side {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.discussion-side-label {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.discussion-list { max-height: 430px; gap: 6px; }

.discussion-session-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.discussion-session-row:hover { border-color: rgba(29, 78, 216, 0.35); background: #f7f9fd; }

.discussion-session-row.is-open {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.14);
  background: #f7f9fd;
}

/* The conversation currently open in the Chat tab. */
.discussion-session-row.is-active {
  border-left: 3px solid var(--color-primary);
}

.discussion-session-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
  padding: 0;
  border: 0;
  background: none;
  font-family: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.discussion-session-when {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.discussion-session-row.is-open .discussion-session-when { color: var(--color-primary-dark); }

.discussion-session-line {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.discussion-session-meta { font-size: 11.5px; color: var(--color-text-muted); }

.discussion-session-delete {
  flex-shrink: 0;
  padding: 3px 5px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

.discussion-session-delete:hover { background: #fee2e2; color: #b91c1c; }

@media (max-width: 900px) {
  .discussion-shell { grid-template-columns: 1fr; }
  .discussion-thread { max-height: 340px; }
  .discussion-list { max-height: 300px; }
}

/* =========================================================================
   Ask MAI — highlighted facts inside an answer (numbers, money, stances)
   ========================================================================= */

.chat-bubble-content mark.chat-hl {
  padding: 0 3px;
  border-radius: 4px;
  background: rgba(250, 204, 21, 0.3);
  color: inherit;
  font-weight: 700;
}

.chat-bubble-content mark.chat-hl-ticker {
  padding: 0 4px;
  border-radius: 5px;
  background: rgba(29, 78, 216, 0.1);
  color: var(--color-primary-dark);
  font-weight: 700;
  font-size: 12.8px;
  letter-spacing: 0.01em;
}

.chat-bubble-content mark.chat-hl-buy,
.chat-bubble-content mark.chat-hl-sell,
.chat-bubble-content mark.chat-hl-hold {
  padding: 0 6px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.chat-bubble-content mark.chat-hl-buy { background: rgba(22, 163, 74, 0.16); color: #14532d; }
.chat-bubble-content mark.chat-hl-sell { background: rgba(220, 38, 38, 0.14); color: #7f1d1d; }
.chat-bubble-content mark.chat-hl-hold { background: rgba(217, 119, 6, 0.18); color: #78350f; }

/* =========================================================================
   Market Desk — phone line card (the desk is a call, not an in-app chat)
   ========================================================================= */

.desk-call-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.desk-call-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 26px;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
  word-break: break-all;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.desk-call-number:hover {
  transform: translateY(-1px);
  background: var(--color-primary-dark);
  box-shadow: 0 14px 30px rgba(29, 78, 216, 0.32);
}

/* Call and text sit side by side; the number keeps its pill, the text link stays a quiet button. */
.desk-call-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

@media (max-width: 520px) {
  .desk-call-number { font-size: 20px; padding: 12px 18px; }
}

.desk-call-hours { margin: 0; font-size: 13px; color: var(--color-text-muted); }

.desk-call-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  width: 100%;
  text-align: left;
}

.desk-call-step {
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #f8fafc;
}

.desk-call-step strong { display: block; margin-bottom: 4px; font-size: 13px; color: var(--color-text); }
.desk-call-step p { margin: 0; font-size: 12.5px; line-height: 1.55; color: var(--color-text-muted); }

.desk-call-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.desk-call-topics li {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-size: 12.5px;
  font-weight: 600;
}

.desk-config-note { margin: 0; font-size: 12px; font-weight: 600; color: var(--color-warn); }

@media (max-width: 560px) {
  .desk-call-number { font-size: 20px; padding: 12px 18px; }
}

/* ---------------------------------------------------------
   Market Desk — payment status + scheduled callback
   (the paid call that used to live on its own page)
   --------------------------------------------------------- */

.desk-status-card { gap: 14px; }

.desk-status-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.desk-status-rows {
  display: grid;
  gap: 10px;
  margin: 0;
}

.desk-status-row {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 6px 16px;
  padding: 12px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #f8fafc;
}

.desk-status-row dt {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.desk-status-row dd {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin: 0;
}

.desk-status-row dd strong {
  font-size: 14px;
  color: var(--color-text);
  word-break: break-word;
}

.desk-status-detail {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--color-text-muted);
}

.desk-status-foot {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-text-muted);
}

@media (max-width: 560px) {
  .desk-status-row { grid-template-columns: 1fr; }
}


/* ---------------------------------------------------------
   Assets & Liabilities — recurring income (pensions, AVS…)
   --------------------------------------------------------- */

/* Toolbar above the list: search, value band, count. It sits inside the same card as the table, and
   stays on one line on desktop while wrapping on a phone. */
.assets-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 14px;
  margin-bottom: 12px;
}

.assets-toolbar-search { flex: 1 1 280px; min-width: 200px; }
.assets-toolbar-search input { width: 100%; }

.assets-toolbar-field { display: flex; flex-direction: column; gap: 4px; }
.assets-toolbar-field label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.assets-toolbar-field select { min-width: 150px; }

.assets-toolbar-count {
  margin: 0 0 0 auto;
  align-self: center;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-muted);
}

/* One sort button per column: the arrow is dim until that column orders the table. */
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
  white-space: nowrap;
}

.th-sort:hover,
.th-sort:focus-visible { color: var(--color-primary); outline: none; }
.th-sort-arrow { font-size: 10px; line-height: 1; opacity: 0.35; }
.assets-table th.is-sorted .th-sort { color: var(--color-primary); }
.assets-table th.is-sorted .th-sort-arrow { opacity: 1; }

.assets-empty-row td {
  padding: 24px 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
}

/* Fixed column widths + wrapping cells: the table used to inherit `white-space: nowrap` on every
   cell, so a broker account with many holdings (or a 7-figure value) pushed the whole table wider
   than its card and produced a horizontal scrollbar. */
.assets-table { table-layout: fixed; width: 100%; }
.assets-table col.col-name { width: 34%; }
.assets-table col.col-category { width: 15%; }
.assets-table col.col-value { width: 15%; }
.assets-table col.col-notes { width: 28%; }
.assets-table col.col-actions { width: 8%; }

.assets-table th, .assets-table td {
  white-space: normal;
  overflow-wrap: anywhere;
}

.assets-table td:nth-child(3) { white-space: nowrap; }
.assets-table .cell-notes { color: var(--color-text-muted); font-size: 13px; }
.assets-table .row-actions { flex-wrap: nowrap; }
.assets-table .symbol-tag { display: block; white-space: normal; }

.badge.income { background: #e6f7f1; color: #0f766e; }

.income-row > td { background: #fbfdff; }
.income-amount { font-weight: 700; }
.income-unit { font-size: 11.5px; color: var(--color-text-muted); }
.income-tag { color: #0f766e; }

/* Future-dated capital (an inheritance in 2035, a property sale, a loan starting later). */
.future-tag {
  color: #7c3aed;
  font-weight: 600;
}

.future-capital-field label { display: flex; gap: 6px; align-items: baseline; }

.recurrence-fields {
  background: #f7faff;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
}

/* Cash / bank account interest: optional, so the block is grouped and explained like the pension one,
   and it spans the whole form so the rate and its yearly amount never sit in a half-width column. */
.cash-fields {
  grid-column: 1 / -1;
  background: #f7faff;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
}

.checkbox-inline {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
}

.checkbox-inline input {
  width: auto;
  margin: 2px 0 0;
  flex-shrink: 0;
}

.income-amount-fields { margin-top: 10px; }

@media (max-width: 760px) {
  .assets-table { table-layout: auto; }
  .assets-table col { width: auto; }
  .assets-table td:nth-child(3) { white-space: normal; }
}

/* ---------------------------------------------------------
   Markets & News — "how to read this page" explainer
   --------------------------------------------------------- */

.market-explainer { padding: 16px 20px; margin-bottom: 20px; }
.market-explainer:hover { transform: none; }

.market-explainer > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: -0.01em;
}

.market-explainer[open] > summary { margin-bottom: 12px; }

.market-explainer-list { margin: 0; display: grid; gap: 12px; }
.market-explainer-list > div { border-left: 2px solid var(--color-primary-soft); padding-left: 12px; }
.market-explainer-list dt { font-weight: 700; font-size: 13.5px; }
.market-explainer-list dd {
  margin: 3px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text-muted);
}

.market-hero-note {
  margin: 10px 0 0;
  max-width: 720px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------
   Dashboard — breakdown legend (fixed colour per category)
   --------------------------------------------------------- */

.breakdown-legend { display: grid; gap: 6px; margin-top: 12px; }

.breakdown-legend-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}

.breakdown-dot { width: 10px; height: 10px; border-radius: 3px; }

.breakdown-legend-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breakdown-legend-value { font-weight: 600; }

.breakdown-legend-share {
  min-width: 92px;
  text-align: right;
  color: var(--color-text-muted);
}

/* ---------------------------------------------------------
   Recommendations — residence & tax comparison
   --------------------------------------------------------- */

.country-switch-card { margin-bottom: 18px; }
.country-switch-table th, .country-switch-table td { white-space: nowrap; }
.country-switch-table .positive { color: #0f766e; font-weight: 700; }
.country-switch-current { background: #f7faff; }

@media (max-width: 720px) {
  .country-switch-table th, .country-switch-table td { white-space: normal; }
}




/* ---------------------------------------------------------
   Dashboard — breakdown bars (assets vs liabilities), today
   --------------------------------------------------------- */

.chart-subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.breakdown-legend-row.is-liability { color: #b91c1c; }
.breakdown-legend-row.is-liability .breakdown-legend-value,
.breakdown-legend-row.is-liability .breakdown-legend-share { font-weight: 700; }

.breakdown-footer {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.category-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  white-space: nowrap;
}

/* Rows of the "where you stand today" card on the FIRE page. */
.today-income-row { background: #f7faff; }

/* ---------------------------------------------------------
   Profile / FIRE helpers
   --------------------------------------------------------- */

.form-hint strong { font-weight: 700; }

/* ---------------------------------------------------------
   Market — index value vs its 200-day moving average
   --------------------------------------------------------- */

.index-ma-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--color-text-muted);
}

.index-ma-item { display: inline-flex; align-items: baseline; gap: 5px; }
.index-ma-item strong { color: var(--color-text); font-weight: 600; }
.index-ma-diff.up { color: #0f766e; font-weight: 600; }
.index-ma-diff.down { color: #b91c1c; font-weight: 600; }

/* ---------------------------------------------------------
   Research — "add to my portfolio" panel
   --------------------------------------------------------- */

.add-to-portfolio {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #f8fafc;
}

.add-to-portfolio h3 { margin: 0 0 4px; font-size: 15px; }

.add-to-portfolio .form-grid { margin-top: 10px; }

.add-to-portfolio .form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
}

.instrument-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}



/* Full country reference table (collapsible) inside the residence & tax card. */
.country-rate-details {
  margin-top: 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  background: #fbfcff;
}

.country-rate-details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--color-primary-dark);
}

.country-rate-details[open] > summary { margin-bottom: 10px; }
.country-rate-wrapper { white-space: normal; min-width: 260px; font-size: 12.5px; }

.country-other-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  font-size: 12.5px;
}

.country-other-label { color: var(--color-text-muted); }

/* ---------------------------------------------------------
   Call MAI — paid phone call (Stripe checkout → dial → status)
   --------------------------------------------------------- */

.call-mai-hero:hover,
.call-mai-form-card:hover,
.call-mai-status:hover,
.call-mai-house-rules:hover { transform: none; }

.call-mai-steps {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.call-mai-steps li {
  position: relative;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fbfcff;
  font-size: 13px;
  line-height: 1.55;
  color: var(--color-text-muted);
}

.call-mai-steps li strong { color: var(--color-text); }

.call-mai-steps li::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 17px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.call-mai-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.call-mai-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 16px;
}

.call-mai-actions .btn { min-width: 220px; }

.call-mai-secure {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted);
}

.call-mai-alert:empty { display: none; }

.call-mai-alert .alert {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.55;
  border-radius: var(--radius-md);
  padding: 11px 14px;
}

.call-mai-timer {
  margin: 12px 0 0;
  font-size: 13.5px;
  color: var(--color-text-muted);
}

.call-mai-timer strong { color: var(--color-text); font-variant-numeric: tabular-nums; }

.call-mai-note {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--color-text-muted);
  border-left: 2px solid var(--color-primary-soft);
  padding-left: 12px;
}

.call-mai-house-rules .call-mai-rules {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 7px;
}

.call-mai-rules li {
  font-size: 13px;
  line-height: 1.6;
  color: var(--color-text-muted);
}


@media (max-width: 560px) {
  .call-mai-actions .btn { width: 100%; min-width: 0; }
  .call-mai-steps li { padding-left: 34px; }
  .call-mai-steps li::before { left: 13px; }
}

/* =========================================================================
   ETF screener (Stock & ETF Research) — facet filters over the fund catalogue
   ========================================================================= */

.screener-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  margin: 4px 0 14px;
  padding: 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #f8fafc;
}

.screener-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.screener-field-wide { grid-column: span 2; }

.screener-field label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.screener-field input,
.screener-field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--color-text);
}

.screener-field input:focus,
.screener-field select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.screener-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.screener-count { font-weight: 600; color: var(--color-text); }
.screener-chips { display: flex; flex-wrap: wrap; gap: 6px; }

.screener-chip {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-size: 11.5px;
  font-weight: 700;
}

.screener-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.screener-table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
  font-size: 13px;
}

.screener-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 12px;
  background: #f1f5fd;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.screener-table th.num,
.screener-table td.num { text-align: right; white-space: nowrap; }

/* Sortable headers: the whole <th> is a button, and the arrow only lights up on the column that is
   currently ordering the table — so the sort is readable at a glance without a legend. */
.screener-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  margin: -2px 0;
  padding: 2px 0;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 4px;
}

.screener-table th.num .screener-sort { justify-content: flex-end; }

.screener-sort:hover,
.screener-sort:focus-visible { color: var(--color-primary); outline: none; }

.screener-sort:focus-visible { box-shadow: 0 0 0 2px var(--color-primary-soft); }

.screener-sort-arrow { font-size: 10px; line-height: 1; opacity: 0.4; }
.screener-table th.is-sorted .screener-sort { color: var(--color-primary); }
.screener-table th.is-sorted .screener-sort-arrow { opacity: 1; }

.screener-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #eef2f9;
  color: var(--color-text);
  vertical-align: middle;
}

.screener-table tbody tr:last-child td { border-bottom: 0; }

.screener-row { cursor: pointer; transition: background 0.12s ease; }
.screener-row:hover,
.screener-row:focus-visible { background: var(--color-primary-soft); outline: none; }

.screener-fund-name { display: block; font-weight: 700; font-size: 13.5px; }
.screener-fund-meta { display: block; margin-top: 2px; font-size: 11.5px; color: var(--color-text-muted); }

.screener-cost {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}

.screener-cost.is-cheaper { background: rgba(22, 163, 74, 0.14); color: #14532d; }
.screener-cost.is-pricier { background: rgba(217, 119, 6, 0.16); color: #78350f; }

.screener-table td .is-up { color: #15803d; font-weight: 600; }
.screener-table td .is-down { color: var(--color-danger-dark); font-weight: 600; }
.screener-na { color: #9aa8bf; }

.screener-empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 13px;
}

.screener-table tbody.is-loading { opacity: 0.45; transition: opacity 0.2s ease; }

.screener-note {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--color-text-muted);
}

@media (max-width: 720px) {
  .screener-field-wide { grid-column: span 1; }
  .screener-filters { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); padding: 12px; }
  .screener-table { min-width: 820px; font-size: 12.5px; }
  .screener-fund-name { font-size: 13px; }
}

/* ---------------------------------------------------------------------------
   Watchlist (Stock & ETF Research) — the symbols the user starred.
   Each row is one button (whole row opens the instrument on the research page)
   plus a separate remove button, so the tap target is the row and the ✕ stays a
   real, separate control for keyboard and screen-reader users.
   --------------------------------------------------------------------------- */
.watchlist-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.watchlist-status { font-size: 12px; color: var(--color-text-muted); }

.watchlist-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

.watchlist-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 10px 10px 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-card);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.watchlist-row:hover,
.watchlist-row:focus-within {
  border-color: rgba(29, 78, 216, 0.35);
  box-shadow: 0 6px 18px rgba(15, 30, 53, 0.06);
}

.watchlist-open {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    'id quote'
    'range range';
  gap: 6px 14px;
  align-items: center;
  padding: 2px 4px;
  border: 0;
  border-radius: 8px;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.watchlist-open:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.watchlist-id { grid-area: id; display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.watchlist-symbol-line { display: flex; align-items: center; gap: 6px; }
.watchlist-symbol-line strong { font-size: 14px; letter-spacing: 0.2px; }
.watchlist-symbol-line .badge { font-size: 10px; padding: 1px 6px; }

.watchlist-name {
  font-size: 12.5px;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.watchlist-exchange { font-size: 11px; color: #8a97ad; }

.watchlist-quote {
  grid-area: quote;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  white-space: nowrap;
}

.watchlist-price { font-size: 16px; font-weight: 700; }
.watchlist-price.is-pending { color: #9aa8bf; }

.watchlist-change { font-size: 11.5px; font-weight: 600; color: var(--color-text-muted); }
.watchlist-change.up { color: #15803d; }
.watchlist-change.down { color: var(--color-danger-dark); }
.watchlist-change.is-error { color: var(--color-text-muted); font-weight: 500; }

.watchlist-range {
  grid-area: range;
  display: block;
  padding-top: 2px;
}

.watchlist-range-labels {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 11px;
  color: var(--color-text-muted);
}

.watchlist-range-zone { font-weight: 600; color: var(--color-text); text-align: center; }

.watchlist-range-detail {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  color: var(--color-text-muted);
}

.watchlist-remove {
  flex: 0 0 auto;
  align-self: flex-start;
  color: var(--color-text-muted);
}

.watchlist-remove:hover,
.watchlist-remove:focus-visible {
  color: var(--color-danger-dark);
  border-color: rgba(185, 28, 28, 0.4);
}

/* The instrument-header star, once the symbol on screen is followed. */
#watchlistToggleBtn.is-followed {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-primary-dark);
  font-weight: 600;
}

@media (max-width: 560px) {
  .watchlist-open {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'id'
      'quote'
      'range';
  }

  .watchlist-quote { align-items: flex-start; }
  .watchlist-range-labels { font-size: 10.5px; }
}




/* =========================================================================
   Section shortcuts, mobile & touch polish
   -------------------------------------------------------------------------
   The app is used on a phone as often as on a laptop, so this block is the
   mobile contract: no sideways scrolling of the whole page, 44px tap
   targets, 16px inputs (iOS zooms any field it thinks is smaller), tables
   that reflow into cards instead of six cramped columns, and sections that
   announce themselves when a tab or a shortcut jumps to them.
   ========================================================================= */

/* Long pages: anchor jumps land below the sticky top bar, never behind it. */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-height) + 14px);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body { -webkit-tap-highlight-color: transparent; }

/* A flex/grid child defaults to min-width:auto, which is how one wide table takes the whole page
   with it. Every container that can hold a table is told it may shrink, so the scroll stays inside
   the .table-wrap instead of moving the layout. */
.card,
.section-card,
.etf-sleeve,
.etf-card,
.esg-block,
.esg-stock,
.table-wrap,
.portfolio-grid > *,
.portfolio-suggest-grid > *,
.esg-stock-grid > * { min-width: 0; }

/* --- The shortcut bar on the Recommendations page ------------------------- */

.section-jump {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 18px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(29, 78, 216, 0.1);
  border-radius: 999px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(8px);
}

.section-jump a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary-dark);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.section-jump a:hover,
.section-jump a:focus-visible { background: #eef4ff; color: var(--color-primary); }

/* Sections that a tab or a shortcut opens: keep them clear of the sticky bars and give the arrival a
   visible pulse, because a silent jump reads as "nothing happened" on a phone. */
#portfolioFitCard,
#esgCard,
#strategySection,
#countrySwitchCard,
#recommendationsWrap { scroll-margin-top: calc(var(--topbar-height) + 20px); }

@keyframes ecofin-jump-flash {
  0%   { outline-color: rgba(29, 78, 216, 0.55); }
  100% { outline-color: rgba(29, 78, 216, 0); }
}

.is-jump-target {
  outline: 3px solid transparent;
  outline-offset: -3px;
  border-radius: var(--radius-lg);
  animation: ecofin-jump-flash 1s ease-out 2;
}

/* --- Green stock cards: the five-year figure a "green" label never shows --- */

.esg-stock-perf {
  margin: 0 0 6px;
  font-size: 12.5px;
  color: var(--color-text-muted);
}

.esg-stock-perf strong { font-size: 14px; }
.esg-stock-perf.positive strong { color: var(--color-primary-dark); }
.esg-stock-perf.negative strong { color: var(--color-danger-dark); }

/* --- Tablet / phone: the sidebar becomes a drawer, the shortcuts stick --- */

@media (max-width: 900px) {
  .sidebar { width: min(84vw, 320px); }

  .section-jump {
    position: sticky;
    top: calc(var(--topbar-height) + 8px);
    z-index: 15;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    margin-bottom: 14px;
  }

  .section-jump::-webkit-scrollbar { display: none; }
}

/* --- Phone ---------------------------------------------------------------- */

@media (max-width: 640px) {
  .main-content { padding: 12px 12px calc(20px + env(safe-area-inset-bottom)); }

  .card { padding: 15px 14px; border-radius: 16px; }

  /* Cards no longer float on hover: a tap should not leave one stuck 2px up. */
  .card:hover { transform: none; }

  .topbar { gap: 10px; padding: 0 12px; }

  .topbar-title {
    font-size: 16px;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* The avatar alone identifies the account; the name costs the title its room. */
  .user-name { display: none; }
  .user-avatar { width: 30px; height: 30px; }

  .hamburger { padding: 12px 10px; } /* a real 44px tap target */

  .page-header { gap: 10px; }

  /* A stacked header puts its call-to-action on its own line, full width, where a thumb is. */
  .page-header > .btn,
  .page-header > a.btn,
  .page-header > form { width: 100%; }

  .section-card h2 { font-size: 17px; }

  /* Profile tabs: swipeable, one tap landing per chip, no clipped shadow on the last one. */
  .tabs {
    gap: 8px;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 6px;
  }

  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { scroll-snap-align: start; padding: 10px 15px; font-size: 13px; }

  /* 44px minimum for anything tappable; .btn-sm keeps a slightly tighter row, and the icon buttons
     inside dense tables stay small enough not to turn each row into a slab. */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; padding: 7px 13px; }
  .btn-icon { min-height: 36px; }

  /* iOS Safari zooms the page when a focused field is under 16px. The app's own form selectors set
     14px, so they are named here as well — a bare `input` rule loses on specificity and the zoom
     would still happen on exactly the fields people type into on a phone. */
  .form-field input,
  .form-field select,
  .form-field textarea,
  .quick-add-row input,
  .instrument-search-wrap input,
  .instrument-fields select,
  .research-search-input,
  .holding-row select,
  .holding-row input,
  input,
  select,
  textarea { font-size: 16px; }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .row-actions { flex-wrap: wrap; gap: 6px; }
  .chip-row { gap: 5px; }
  .chip { padding: 5px 10px; font-size: 12px; }

  .esg-stock-grid { gap: 10px; }
  .esg-stock { padding: 12px; }
  .esg-why, .esg-risk { max-width: none; }

  /* Login / signup pages: the hero is the page, so it keeps its padding but loses the desktop one. */
  .hero { padding: 36px 16px 32px; }
  .signin-card { padding: 20px 16px 18px; border-radius: 16px; }
  .public-header { padding: 10px 14px; }
  .public-header .brand-logo { height: 26px; }
  .public-header .micro2media-logo { height: 18px; }
}

/* --- Small phone: wide tables become cards --------------------------------- */

@media (max-width: 560px) {
  /* A six-column sleeve table cannot be read on a phone, and scrolling it sideways loses the fund name
     the moment the user moves right. Tables marked .stack-table carry a data-label on every cell, so
     each row becomes one card: name on top, figures labelled underneath, actions at the bottom. */
  table.stack-table thead { display: none; }

  table.stack-table,
  table.stack-table tbody,
  table.stack-table tr,
  table.stack-table td { display: block; width: auto; }

  table.stack-table tr {
    padding: 12px 0;
    border-bottom: 1px solid var(--color-border);
  }

  table.stack-table tr:last-child { border-bottom: 0; }
  table.stack-table tbody tr:hover { background: transparent; }

  table.stack-table td {
    border: 0;
    padding: 1px 0;
    white-space: normal;
    font-size: 13px;
    overflow-wrap: anywhere;
  }

  table.stack-table td:first-child { padding: 0 0 6px; }

  table.stack-table td:not(:first-child)[data-label]:not([data-label=""]) {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    max-width: 280px;
  }

  table.stack-table td[data-label]:not([data-label=""])::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 12px;
    color: var(--color-text-muted);
  }

  table.stack-table td[data-label=""] { padding-top: 9px; }
  table.stack-table td[data-label=""] .row-actions { flex-wrap: nowrap; }

  /* Once the rows are blocks there is nothing left to scroll. */
  .table-wrap:has(table.stack-table) { overflow-x: visible; }
}

@media (max-width: 400px) {
  .topbar-title { font-size: 15px; }
  .esg-stock-grid { grid-template-columns: 1fr; }
  .btn { padding: 9px 16px; }
}

/* The drawer takes the scroll with it, so the page behind cannot move under the thumb. */
body.nav-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .is-jump-target { animation: none; outline-color: rgba(29, 78, 216, 0.35); }
  .sidebar { transition: none; }
}

/* A value the app derives (sum of holdings, a pension's absent resale value, a one-off amount) is
   read-only. The tint plus the not-allowed cursor makes that obvious before anyone tries to type in
   it — the hint under the label says which rule produced the number. */
.form-field input.is-auto-value,
input.is-auto-value {
  background: rgba(15, 23, 42, 0.045);
  color: var(--color-text-muted);
  cursor: not-allowed;
}

/* Provenance line under the screener table: says how many funds quote returns computed from market
   prices (with the read date) versus still showing the catalogue's reference snapshot. */
.screener-source {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.screener-source.is-warn {
  color: var(--color-danger);
}





