/* ── Reset & base ── */
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: #f4f6f8; color: #1f2937; }
.hidden { display: none !important; }

/* ── Login overlay ── */
.login-overlay { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; overflow-y: auto; background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); }
.login-overlay.hidden { display: none !important; }
.login-card { background: #fff; border-radius: 12px; box-shadow: 0 8px 32px rgba(0,0,0,0.18); padding: 40px 36px 32px; width: 100%; max-width: 380px; }
.register-card { max-width: 760px; }
.login-card h2 { margin: 0 0 4px; font-size: 22px; color: #0f172a; text-align: center; }
.login-subtitle { text-align: center; color: #64748b; font-size: 14px; margin: 0 0 24px; }
.login-card .form-group { margin-bottom: 16px; }
.login-card label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 4px; }
.login-card input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 14px; transition: border-color 0.15s; }
.login-card input:focus { border-color: #2563eb; outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.12); }
.login-version { text-align: center; margin-top: 16px; font-size: 11px; color: #000; }
.login-btn { width: 100%; padding: 10px; background: #2563eb; color: #fff; border: none; border-radius: 6px; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.login-btn:hover { background: #1d4ed8; }
.login-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 6px; padding: 8px 12px; font-size: 13px; margin-bottom: 12px; }
.login-secondary-btn { width: 100%; margin-top: 12px; background: transparent; color: #2563eb; border: 1px solid #bfdbfe; }
.login-secondary-btn:hover { background: #eff6ff; color: #1d4ed8; }
.registration-callout { margin-bottom: 16px; padding: 12px 14px; border-radius: 10px; border: 1px solid #fcd34d; background: #fff7d6; color: #92400e; font-size: 13px; line-height: 1.45; }

/* ── App shell ── */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.page { display: none; }
.page.active { display: block; }

/* ── Top nav ── */
.topnav { background: #0f172a; color: #fff; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 24px; height: 90px; position: sticky; top: 0; z-index: 100; }
.topnav-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topnav .brand { font-weight: 700; font-size: 16px; letter-spacing: 0.02em; cursor: pointer; transition: background 0.15s, color 0.15s; padding: 4px 12px; border-radius: 6px; white-space: nowrap; display: flex; align-items: center; gap: 8px; min-width: 0; }
.topnav .brand .brand-logo { height: 80px; width: auto; flex-shrink: 0; }
.topnav .brand:hover { background: #1e293b; }
.topnav .brand.active { background: #2563eb; }
.topnav-tabs { display: flex; gap: 12px; align-items: center; justify-self: center; }
.topnav-channel-group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.topnav-channel-tabs { display: flex; align-items: center; gap: 4px; padding-left: 14px; position: relative; }
.topnav-channel-tabs::before { content: ''; position: absolute; left: 2px; top: 7px; bottom: 7px; width: 1px; background: #334155; }
.topnav-tab { background: transparent; border: none; color: #94a3b8; font-size: 14px; font-weight: 500; padding: 6px 16px; border-radius: 6px; cursor: pointer; transition: background 0.15s, color 0.15s; width: auto; }
.topnav-tab .tab-short { display: none; }
.topnav-tab .tab-full { display: inline; }
.topnav-tab:hover { background: #1e293b; color: #fff; }
.topnav-tab.active { background: #2563eb; color: #fff; }
.topnav-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: #64748b; font-weight: 700; margin-left: 0; text-align: center; }
.profile-menu-shell { position: relative; display: flex; align-items: center; justify-self: end; }
.profile-menu-trigger { width: auto; padding: 4px 10px; border: 1px solid transparent; border-radius: 8px; background: transparent; display: flex; align-items: center; gap: 8px; height: 40px; }
.profile-menu-trigger:hover, .profile-menu-trigger[aria-expanded="true"] { background: #172033; border-color: #2b3a55; }
.profile-menu-avatar-wrap { width: 30px; height: 30px; border-radius: 999px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #1e293b; border: 1px solid #334155; flex-shrink: 0; }
.profile-menu-avatar-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-menu-avatar-fallback { color: #e2e8f0; font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.profile-menu-name { max-width: 110px; color: #cbd5e1; font-size: 11px; line-height: 1.15; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-menu-dropdown { position: absolute; top: calc(100% + 10px); right: 0; min-width: 210px; padding: 8px; border-radius: 12px; background: #fff; border: 1px solid #e2e8f0; box-shadow: 0 16px 40px rgba(15, 23, 42, 0.22); z-index: 250; }
.profile-menu-item { width: 100%; background: transparent; color: #0f172a; border: none; text-align: left; padding: 10px 12px; border-radius: 8px; font-weight: 600; }
.profile-menu-item:hover { background: #eff6ff; color: #0f172a; }
.profile-menu-item-danger { color: #b91c1c; }
.profile-menu-item-danger:hover { background: #fef2f2; color: #991b1b; }
.app-version { font-size: 10px; color: #000; margin-left: 8px; font-weight: 400; }

/* ── Chat with your Data (topnav + panel) ── */
.topnav-right-group { display: flex; align-items: center; gap: 8px; justify-self: end; }
.ai-chat-toggle-btn { display: flex; align-items: center; gap: 6px; background: transparent; border: 1px solid #334155; color: #94a3b8; border-radius: 8px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.ai-chat-toggle-btn:hover { background: #172033; border-color: #475569; color: #e2e8f0; }
.ai-chat-toggle-btn svg { flex-shrink: 0; }

.ai-chat-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.35); z-index: 299; }
.ai-chat-panel { position: fixed; top: 0; right: 0; width: 420px; max-width: 100vw; height: 100vh; background: #0f172a; border-left: 1px solid #1e293b; z-index: 300; display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.25s ease; }
.ai-chat-panel.open { transform: translateX(0); }
.ai-chat-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #1e293b; flex-shrink: 0; }
.ai-chat-header h3 { margin: 0; font-size: 15px; color: #e2e8f0; font-weight: 700; }
.ai-chat-header-right { display: flex; align-items: center; gap: 12px; }
.ai-chat-remaining { font-size: 11px; color: #64748b; white-space: nowrap; }
.ai-chat-close-btn { background: transparent; border: none; color: #94a3b8; font-size: 22px; cursor: pointer; padding: 0 4px; line-height: 1; }
.ai-chat-close-btn:hover { color: #e2e8f0; }
.ai-chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.ai-chat-welcome { color: #94a3b8; font-size: 13px; line-height: 1.6; }
.ai-chat-welcome strong { color: #e2e8f0; }
.ai-msg { padding: 10px 14px; border-radius: 10px; font-size: 13px; line-height: 1.6; max-width: 92%; word-wrap: break-word; }
.ai-msg-user { background: #1e3a5f; color: #e2e8f0; align-self: flex-end; border-bottom-right-radius: 2px; }
.ai-msg-assistant { background: #1e293b; color: #cbd5e1; align-self: flex-start; border-bottom-left-radius: 2px; }
.ai-msg-assistant p { margin: 0 0 8px; }
.ai-msg-assistant p:last-child { margin-bottom: 0; }
.ai-msg-assistant ul, .ai-msg-assistant ol { margin: 4px 0 8px 18px; padding: 0; }
.ai-msg-assistant li { margin-bottom: 4px; }
.ai-msg-assistant strong { color: #e2e8f0; }
.ai-msg-assistant code { background: #0f172a; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.ai-msg-error { background: #3b1111; color: #fca5a5; align-self: flex-start; }
.ai-msg-loading { background: #1e293b; color: #64748b; align-self: flex-start; font-style: italic; }
.ai-chat-input-area { padding: 12px 20px 16px; border-top: 1px solid #1e293b; flex-shrink: 0; }
.ai-chat-form { display: flex; gap: 8px; align-items: flex-end; }
.ai-chat-input { flex: 1; background: #1e293b; border: 1px solid #334155; color: #e2e8f0; border-radius: 8px; padding: 10px 12px; font-size: 13px; resize: none; font-family: inherit; line-height: 1.4; }
.ai-chat-input:focus { border-color: #3b82f6; outline: none; }
.ai-chat-input::placeholder { color: #475569; }
.ai-chat-send-btn { width: auto; background: #2563eb; border: none; color: #fff; border-radius: 8px; padding: 10px 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.15s; }
.ai-chat-send-btn:hover { background: #1d4ed8; }
.ai-chat-send-btn:disabled { background: #334155; cursor: not-allowed; }

/* ── RAG Document Panel ── */
.ai-chat-docs-btn { background: transparent; border: none; color: #94a3b8; font-size: 16px; cursor: pointer; padding: 2px 4px; line-height: 1; }
.ai-chat-docs-btn:hover { color: #e2e8f0; }
.ai-chat-docs-panel { padding: 14px 20px; border-bottom: 1px solid #1e293b; background: #0b1120; flex-shrink: 0; max-height: 260px; overflow-y: auto; }
.ai-chat-docs-panel h4 { color: #e2e8f0; font-size: 14px; }
.ai-chat-docs-close-btn { background: transparent; border: none; color: #94a3b8; font-size: 18px; cursor: pointer; padding: 0 4px; }
.ai-chat-docs-close-btn:hover { color: #e2e8f0; }
.btn-small { display: inline-flex; align-items: center; gap: 4px; background: #1e293b; border: 1px solid #334155; color: #94a3b8; border-radius: 6px; padding: 5px 10px; font-size: 11px; cursor: pointer; white-space: nowrap; transition: background 0.15s, color 0.15s; }
.btn-small:hover { background: #334155; color: #e2e8f0; }
.btn-danger { border-color: #7f1d1d; color: #fca5a5; }
.btn-danger:hover { background: #7f1d1d; color: #fecaca; }
.ai-rag-docs-list { display: flex; flex-direction: column; gap: 6px; }
.ai-rag-doc-item { display: flex; align-items: center; justify-content: space-between; background: #1e293b; border-radius: 6px; padding: 8px 10px; }
.ai-rag-doc-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ai-rag-doc-title { color: #e2e8f0; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-rag-doc-delete { flex-shrink: 0; font-size: 12px; padding: 3px 6px; }
.ai-rag-sources { margin-top: 8px; padding-top: 6px; border-top: 1px solid #334155; color: #64748b; }
.ai-cursor { display: inline-block; width: 2px; height: 1em; background: #60a5fa; margin-left: 1px; vertical-align: text-bottom; animation: ai-blink 0.6s step-end infinite; }
@keyframes ai-blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
.ai-streaming p:last-child, .ai-streaming li:last-child { display: inline; }

/* ── Record Attachment UI ── */
.record-attachments-group { margin-top: 8px; border-top: 1px solid #334155; padding-top: 10px; }
.record-attach-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.record-attach-list { display: flex; flex-direction: column; gap: 4px; }
.record-attach-item { display: flex; align-items: center; gap: 8px; background: #1e293b; border-radius: 6px; padding: 6px 10px; font-size: 12px; }
.record-attach-title { color: #e2e8f0; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.record-attach-delete, .record-attach-pending-remove { flex-shrink: 0; font-size: 11px; padding: 2px 6px; }

/* ── Dashboard layout ── */
.app { display: grid; grid-template-columns: 260px 1fr; min-height: calc(100vh - 52px); }
.sidebar { background: #0f172a; color: #fff; padding: 20px; }
.sidebar h2 { margin-top: 0; }
.sidebar-hint { font-size: 12px; color: #64748b; margin: 4px 0 12px; }
.portfolio-list { margin: 4px 0; display: grid; gap: 6px; }
.sidebar-section-label { font-size: 10px; font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: 0.08em; margin: 14px 0 6px 2px; }
.sidebar-section-label:first-child { margin-top: 0; }
.portfolio-item { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; background: #1e293b; border: 1px solid #334155; border-radius: 8px; padding: 8px 10px; cursor: pointer; color: #e2e8f0; font-size: 13px; text-align: left; transition: background 0.15s, border-color 0.15s; }
.portfolio-item:hover { background: #263348; }
.portfolio-item.active { background: #2563eb; border-color: #2563eb; color: #fff; }
.portfolio-item.active .portfolio-item-meta { color: #bfdbfe; }
.broker-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.portfolio-item-name { font-weight: 600; flex: 1 1 100%; }
.portfolio-item-meta { font-size: 11px; color: #94a3b8; }
.content { padding: 20px; min-width: 0; overflow: hidden; }

/* ── Card ── */
.card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 16px; margin-top: 12px; }
.sidebar .card { background: #111827; border-color: #1f2937; }
.sidebar input, .sidebar select { background: #0b1220; color: #fff; border: 1px solid #334155; }

/* ── Dashboard header & summary ── */
header { display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 16px; }
.summary-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.summary-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.summary-card span { color: #6b7280; font-size: 12px; }
.summary-card strong { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-alert { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid #fcd34d; background: #fef3c7; color: #92400e; border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.app-alert p { margin: 4px 0 0; font-size: 13px; }

/* ── Forms ── */
input, select { padding: 9px 11px; border-radius: 8px; border: 1px solid #d1d5db; font-size: 14px; width: 100%; }
textarea { padding: 9px 11px; border-radius: 8px; border: 1px solid #d1d5db; font-size: 14px; width: 100%; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #2563eb; outline-offset: -1px; border-color: transparent; }
button { width: 100%; padding: 10px; border-radius: 8px; border: 1px solid transparent; background: #2563eb; color: #fff; cursor: pointer; font-weight: 600; font-size: 14px; transition: background 0.15s; }
button:hover { background: #1d4ed8; }
button:disabled,
button[disabled] { background: #cbd5e1; border-color: #cbd5e1; color: #475569; cursor: not-allowed; box-shadow: none; }
button:disabled:hover,
button[disabled]:hover { background: #cbd5e1; }
button.secondary { width: auto; background: #e5e7eb; color: #111827; }
button.secondary:hover { background: #d1d5db; }

/* ── Holdings tables ── */
.table-scroll-wrapper {
  overflow: hidden;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}
.table-scroll-wrapper h3 {
  margin: 0 0 12px;
  font-size: 16px;
}
.table-scroll-inner {
  overflow: auto;
  flex: 1;
  min-height: 0;
  max-height: min(62vh, 720px);
}
.table-scroll-wrapper table {
  width: max-content;
  border-collapse: collapse;
  table-layout: auto;
}
.table-scroll-wrapper th,
.table-scroll-wrapper td {
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  font-size: 12px;
  overflow: hidden;
}
.table-scroll-wrapper th {
  color: #6b7280;
  font-weight: 600;
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}
.table-scroll-wrapper td {
  white-space: nowrap;
  text-overflow: ellipsis;
}
.table-scroll-wrapper th { position: relative; }
.table-scroll-wrapper th:nth-child(1),
.table-scroll-wrapper td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #fff;
  border-right: 2px solid #e5e7eb;
}
.table-scroll-wrapper th:nth-child(1) {
  background: #f9fafb;
  z-index: 4;
}
.table-scroll-wrapper th .col-resize-handle {
  position: absolute;
  right: -3px;
  top: 0;
  bottom: 0;
  width: 7px;
  cursor: col-resize;
  user-select: none;
  z-index: 10;
}
.table-scroll-wrapper th .col-resize-handle:hover,
.table-scroll-wrapper th .col-resize-handle.active {
  background: #2563eb;
  opacity: 0.4;
}
.table-scroll-wrapper th[data-sort-key] { cursor: pointer; user-select: none; }
.table-scroll-wrapper th[data-sort-key]:hover { color: #374151; }
.table-scroll-wrapper th[data-sort-key]::after { content: '\2195'; margin-left: 4px; opacity: 0.3; font-size: 10px; }
.table-scroll-wrapper th.sort-asc::after { content: '\25B2'; opacity: 0.8; }
.table-scroll-wrapper th.sort-desc::after { content: '\25BC'; opacity: 0.8; }
.positive { color: #15803d; }
.negative { color: #b91c1c; }
.cell-date { font-size: 11px; color: #6b7280; }

/* ── Inline edit inputs in table cells ── */
.inline-edit { width: 72px; padding: 4px 6px; font-size: 12px; border: 1px solid #e5e7eb; border-radius: 4px; background: #f9fafb; }
.pct-input-wrap { display: inline-flex; align-items: center; gap: 2px; }
.pct-suffix { font-size: 12px; color: #6b7280; flex-shrink: 0; }
.inline-edit:focus { outline: 2px solid #2563eb; border-color: transparent; background: #fff; }
.inline-edit-comment { width: 120px; }

/* ── Tag badges ── */
.tag-badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 12px; border: 1px solid; white-space: nowrap; letter-spacing: 0.02em; }
.tag-badge-removable { cursor: default; }
.tag-badge-removable .tag-remove { display: inline-block; margin-left: 4px; cursor: pointer; font-size: 13px; font-weight: 700; opacity: 0.6; vertical-align: middle; }
.tag-badge-removable .tag-remove:hover { opacity: 1; }
.tag-badges-wrap { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.tag-add-btn { display: inline-flex; align-items: center; justify-content: center; width: 20px; min-width: 20px; height: 20px; border-radius: 50%; border: 1px dashed #94a3b8; background: none; color: #94a3b8; font-size: 14px; cursor: pointer; padding: 0; line-height: 1; flex-shrink: 0; }
.tag-add-btn:hover { border-color: #2563eb; color: #2563eb; background: #eff6ff; }
.tag-cell { position: relative; min-width: 100px; }

/* ── Signal badges ── */
.signals-cell { min-width: 90px; white-space: normal; }
.signals-empty { color: #d1d5db; font-size: 11px; }
.signal-badge { display: inline-flex; align-items: center; gap: 2px; font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; background: #dcfce7; color: #166534; border: 1px solid #86efac; white-space: nowrap; margin: 1px 2px; }
.signal-remove { cursor: pointer; font-size: 12px; font-weight: 700; opacity: 0.5; margin-left: 3px; }
.signal-remove:hover { opacity: 1; color: #b91c1c; }
.dma-scale-wrap { display: inline-flex; align-items: flex-start; gap: 0; position: relative; vertical-align: middle; }
.dma-scale { display: block; }
.signal-filter-select { font-size: 10px; padding: 1px 2px; border: 1px solid #d1d5db; border-radius: 4px; background: #fff; color: #374151; max-width: 90px; cursor: pointer; margin-left: 2px; }
.ie-waterfall-summary {
  margin-bottom: 10px;
  font-size: 12px;
  color: #6b7280;
}
.ie-waterfall-axis {
  stroke: #cbd5e1;
  stroke-width: 1;
}
.ie-waterfall-baseline {
  stroke: #94a3b8;
  stroke-width: 1.5;
}
.ie-waterfall-connector {
  stroke: #94a3b8;
  stroke-width: 1.25;
  stroke-dasharray: 4 3;
  fill: none;
}
.ie-waterfall-bar-income { fill: #16a34a; }
.ie-waterfall-bar-expense { fill: #ef4444; }
.ie-waterfall-bar-investment { fill: #f59e0b; }
.ie-waterfall-bar-net-positive { fill: #2563eb; }
.ie-waterfall-bar-net-negative { fill: #b91c1c; }
.ie-waterfall-bar-group:hover rect { opacity: 0.8; transition: opacity 0.15s; }
.ie-waterfall-label {
  font-size: 11px;
  font-weight: 600;
  fill: #374151;
}
.ie-waterfall-value {
  font-size: 10px;
  fill: #6b7280;
}
.signal-remove:hover { opacity: 1; color: #b91c1c; }

/* ── Tag picker popover ── */
.tag-picker-popover { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.12); padding: 10px; min-width: 200px; max-width: 280px; }
.tag-picker-search { margin-bottom: 8px; }
.tag-picker-items { display: flex; flex-wrap: wrap; gap: 4px; max-height: 150px; overflow-y: auto; }
.tag-picker-item:hover { filter: brightness(0.92); }
.tag-picker-create { border-style: dashed !important; }
.tag-picker-empty { font-size: 12px; color: #9ca3af; }
.tag-picker-input { width: 100%; padding: 6px 8px; font-size: 12px; border: 1px solid #e5e7eb; border-radius: 6px; box-sizing: border-box; }
.tag-picker-input:focus { outline: 2px solid #2563eb; border-color: transparent; }
.tag-merge-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 8px; background: #fef3c7; border: 1px solid #fbbf24; border-radius: 8px; font-size: 12px; color: #92400e; }

/* ── Form tag picker (Add Holding modal) ── */
.form-tag-picker { display: flex; flex-direction: column; gap: 6px; }
.form-tag-badges { display: flex; flex-wrap: wrap; gap: 4px; min-height: 24px; }
.form-tag-badges-selected { padding: 8px 10px; border: 1px solid #dbe4f0; border-radius: 10px; background: #f8fbff; }
.form-tag-toolbar { display: flex; align-items: center; gap: 8px; }
.form-tag-toolbar-text { font-size: 12px; color: #64748b; }
.form-tag-empty { font-size: 12px; color: #94a3b8; }
.form-tag-picker .tag-add-btn { width: 24px; min-width: 24px; height: 24px; }

/* ── Add Holding: symbol search suggestions ── */
.symbol-suggest {
  position: relative;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
  z-index: 5;
}
.symbol-suggest-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
  cursor: pointer;
  font-size: 12px;
}
.symbol-suggest-item:last-child { border-bottom: none; }
.symbol-suggest-item:hover { background: #eff6ff; }
.symbol-suggest-sym { font-weight: 600; color: #1e293b; font-size: 13px; }
.symbol-suggest-name { color: #475569; }
.symbol-suggest-meta { color: #94a3b8; font-size: 11px; }
.symbol-status { margin-top: 4px; font-size: 11px; min-height: 14px; }
.symbol-status--ok { color: #059669; }
.symbol-status--err { color: #dc2626; }
.symbol-status--info { color: #2563eb; }
.symbol-override-row {
  margin-top: 8px;
  padding: 8px 10px;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 8px;
}
.symbol-override-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  color: #92400e;
  cursor: pointer;
}
.symbol-override-label input { margin-top: 2px; }

/* ── Equities treemap ── */
.treemap-section { margin-bottom: 14px; }
.treemap-section h3 { margin: 0 0 4px; font-size: 16px; }
.treemap-subtitle { margin: 0 0 10px; font-size: 12px; color: #6b7280; }
#treemap-chart { width: 100%; min-height: 240px; overflow: hidden; }
#treemap-chart svg { width: 100%; height: auto; display: block; max-width: 100%; }
.treemap-tile {
  stroke: rgba(255, 255, 255, 0.96);
  stroke-width: 2;
  transition: opacity 0.15s;
}
.treemap-tile-group:hover .treemap-tile {
  opacity: 0.8;
}
.treemap-label {
  font-size: 12px;
  font-weight: 700;
  fill: #0f172a;
  pointer-events: none;
}
.treemap-value {
  font-size: 11px;
  fill: #334155;
  pointer-events: none;
}
.treemap-meta {
  font-size: 10px;
  fill: #475569;
  pointer-events: none;
}
.sankey-empty { color: #9ca3af; font-size: 14px; padding: 16px 0; }

/* ── Tag management ── */
.tag-add-row { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.tag-add-row input[type="text"] { flex: 1; min-width: 120px; }
.tag-add-row input[type="color"] { width: 36px; height: 36px; padding: 2px; border: 1px solid #d1d5db; border-radius: 6px; cursor: pointer; }
.tag-add-row button { flex-shrink: 0; width: auto; }
.tag-mgmt-list { display: flex; flex-direction: column; gap: 6px; }
.tag-mgmt-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid #e5e7eb; border-radius: 8px; background: #fff; }
.tag-mgmt-row .tag-badge { min-width: 80px; text-align: center; }
.tag-mgmt-row .tag-usage-count { font-size: 12px; color: #64748b; white-space: nowrap; }
.tag-count-limit { color: #92400e; font-weight: 600; }
.tag-mgmt-row .tag-color-picker { width: 32px; height: 32px; padding: 1px; border: 1px solid #d1d5db; border-radius: 6px; cursor: pointer; margin-left: auto; }
.tag-mgmt-row .btn-sm { margin-left: 4px; }

/* ════════════════════════════════
   Settings layout
════════════════════════════════ */
.settings-shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 52px); }
.settings-sidebar { background: #0f172a; color: #fff; padding: 24px 16px; }
.settings-sidebar h2 { margin-top: 0; font-size: 18px; }
.settings-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.settings-nav-item { background: transparent; border: none; color: #94a3b8; text-align: left; font-size: 14px; padding: 9px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; width: 100%; transition: background 0.15s, color 0.15s; }
.settings-nav-item:hover { background: #1e293b; color: #e2e8f0; }
.settings-nav-item.active { background: #2563eb; color: #fff; }

.settings-main { padding: 28px 32px; overflow-y: auto; }
.stab-panel { display: none; }
.stab-panel.active { display: block; }
.stab-header { margin-bottom: 24px; }
.stab-header h2 { margin: 0 0 6px; font-size: 22px; }
.stab-header p { margin: 0; color: #6b7280; font-size: 14px; }
.global-settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
.global-submenu { display: flex; flex-direction: column; gap: 6px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 8px; }
.global-submenu-item { width: 100%; background: transparent; color: #1f2937; border: 1px solid transparent; text-align: left; padding: 9px 12px; border-radius: 8px; }
.global-submenu-item:hover { background: #e2e8f0; }
.global-submenu-item.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.global-stab-panel { display: none; }
.global-stab-panel.active { display: block; }

/* ── Settings two-column layout ── */
.settings-columns { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }
.settings-form-card h3, .settings-list-card h3 { margin-top: 0; font-size: 16px; }

/* ── Form groups ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 600; color: #374151; }
.form-group input, .form-group select { width: 100%; }
.form-group.hidden { display: none; }
.date-select-row { display: grid; grid-template-columns: minmax(84px, 0.9fr) minmax(120px, 1.2fr) minmax(96px, 1fr); gap: 8px; align-items: center; }
.date-select-row-compact { flex: 1; min-width: 0; }
.date-select-row select { width: 100%; }
.profile-photo-section { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; padding: 14px; border: 1px solid #e5e7eb; border-radius: 12px; background: #f8fafc; }
.profile-photo-preview-wrap { width: 88px; height: 88px; border-radius: 16px; overflow: hidden; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: linear-gradient(135deg, #dbeafe, #e2e8f0); border: 1px solid #cbd5e1; }
.profile-photo-preview-image { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-photo-preview-fallback { color: #1e3a8a; font-size: 28px; font-weight: 700; }
.profile-photo-controls { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.profile-photo-action-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.profile-photo-selected-name { font-size: 12px; color: #64748b; word-break: break-word; }
.secondary-btn-inline { width: auto; min-width: 0; align-self: flex-start; }
.phone-input-row { display: grid; grid-template-columns: 180px 1fr; gap: 10px; }
.snapshot-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 14px; }
.form-error { color: #b91c1c; font-size: 13px; margin-bottom: 10px; padding: 8px 12px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; }
.form-error.hidden { display: none; }
.form-success { color: #166534; font-size: 13px; margin-bottom: 10px; padding: 8px 12px; background: #dcfce7; border: 1px solid #86efac; border-radius: 6px; }
.form-success.hidden { display: none; }
.input-readonly { background: #f1f5f9; color: #64748b; cursor: default; font-family: ui-monospace, monospace; font-size: 13px; letter-spacing: 0.02em; }
.field-hint { display: block; margin-top: 4px; font-size: 12px; color: #94a3b8; line-height: 1.45; }
.storage-card { max-width: 680px; }
.secondary-btn { width: auto; min-width: 170px; background: #e2e8f0; color: #0f172a; border: 1px solid #cbd5e1; }
.secondary-btn:hover { background: #cbd5e1; }
.verification-block { margin-bottom: 16px; padding: 14px; border: 1px solid #e5e7eb; border-radius: 10px; background: #f8fafc; }
.verification-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.verification-entry { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.verification-entry input { flex: 1; }
.verification-action-btn { width: auto; min-width: 170px; }
.verification-status { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; margin-top: 8px; }
.verification-status-verified { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.verification-status-pending { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.admin-users-card { max-width: 100%; }
.admin-users-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.admin-users-header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-emulation-banner { margin-bottom: 16px; padding: 12px 14px; background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; border-radius: 8px; font-size: 13px; }
#global-emulation-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 12px 24px 0; }
#global-emulation-banner button { flex-shrink: 0; }
.admin-create-user-form { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr auto; gap: 14px; align-items: end; margin-bottom: 18px; }
.admin-create-user-form .form-group { margin-bottom: 0; }
.admin-users-table-wrap { overflow-x: auto; border: 1px solid #e5e7eb; border-radius: 10px; }
.admin-users-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.admin-users-table th, .admin-users-table td { padding: 12px 14px; border-bottom: 1px solid #e5e7eb; text-align: left; vertical-align: top; }
.admin-users-table th { background: #f8fafc; color: #334155; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.admin-users-table tbody tr:last-child td { border-bottom: none; }
.admin-user-row { cursor: pointer; }
.admin-user-row:hover td { background: #f8fafc; }
.admin-user-link { background: transparent; border: none; padding: 0; color: #0f172a; font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.admin-user-link:hover { color: #2563eb; }
.admin-users-name { font-weight: 600; color: #0f172a; }
.admin-users-meta { margin-top: 4px; font-size: 12px; color: #64748b; }
.admin-users-code { font-family: ui-monospace, monospace; font-size: 12px; color: #334155; word-break: break-all; }
.admin-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #1f2937; }
.admin-toggle input { width: 16px; height: 16px; }

@media (max-width: 640px) {
  .phone-input-row { grid-template-columns: 1fr; }
  .admin-users-header-row { flex-direction: column; align-items: stretch; }
  .admin-create-user-form { grid-template-columns: 1fr; }
}

/* ── Portfolio groups in settings list ── */
.portfolio-group { margin-bottom: 28px; }
.portfolio-group-header { margin-bottom: 14px; }
.portfolio-region-section { margin-bottom: 16px; }
.portfolio-region-header { font-size: 12px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 8px 4px; padding-bottom: 4px; border-bottom: 1px solid #e5e7eb; }
.portfolio-region-list { display: flex; flex-direction: column; gap: 6px; }
.portfolio-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fff; transition: box-shadow 0.15s; }
.portfolio-row:hover { box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.portfolio-row-info { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.portfolio-row-actions { display: flex; align-items: center; gap: 8px; }
.portfolio-row-info strong { font-size: 14px; }
.portfolio-stats { font-size: 12px; color: #6b7280; margin-left: 4px; }
.portfolio-stats--fresh { color: #16a34a; font-weight: 600; }

/* ── Badges & tags ── */
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 4px 12px; border-radius: 20px; letter-spacing: 0.04em; text-transform: uppercase; }
.badge-equity  { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
.badge-assets  { background: #dcfce7; color: #15803d; border: 1px solid #86efac; }
.badge-income  { background: #ede9fe; color: #6d28d9; border: 1px solid #c4b5fd; }
/* Legacy aliases */
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.tag-currency { background: #fef9c3; color: #854d0e; border-color: #fde68a; }

/* ── Modal / Popup ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); display: flex; align-items: center; justify-content: center; z-index: 200; }
.modal-overlay.hidden { display: none !important; }
.modal-dialog { background: #fff; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,0.18); width: 460px; max-width: 92vw; max-height: 90vh; overflow-y: auto; animation: modalIn 0.18s ease-out; }
.modal-dialog-wide { width: 640px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; }
.modal-header h3 { margin: 0; font-size: 18px; }
.modal-close-btn { background: none; border: none; font-size: 24px; color: #6b7280; cursor: pointer; padding: 0 4px; width: auto; line-height: 1; }
.modal-close-btn:hover { color: #111827; background: none; }
.modal-body { padding: 16px 22px 22px; }
.modal-divider { border: none; border-top: 1px solid #e5e7eb; margin: 18px 0 14px; }
.modal-btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.modal-btn-row button { flex: 1 1 auto; min-width: 0; }

/* ── Holding form (modal grid) ── */
.holding-modal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.holding-modal-grid .form-group { margin-bottom: 0; }
.al-entry-value-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── Header actions row ── */
.header-actions { display: flex; gap: 8px; align-items: center; }
.search-input { width: 320px; padding: 8px 12px; border-radius: 8px; border: 1px solid #d1d5db; font-size: 14px; }

/* ── Danger button ── */
.btn-danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.btn-danger:hover { background: #fecaca; color: #991b1b; }
.btn-sm { width: auto; padding: 5px 12px; font-size: 12px; font-weight: 600; border-radius: 6px; flex-shrink: 0; }
.btn-sync { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; cursor: pointer; }
.btn-sync:hover { background: #bfdbfe; color: #1e40af; }
.btn-sync:disabled { opacity: 0.6; cursor: wait; }

/* ── Empty state ── */
.empty-state { color: #9ca3af; font-size: 14px; padding: 16px 0; }

/* ── CSV Upload Area ── */
.csv-upload-area { position: relative; border: 2px dashed #d1d5db; border-radius: 10px; padding: 24px 16px; text-align: center; transition: border-color 0.2s, background 0.2s; cursor: pointer; }
.csv-upload-area:hover, .csv-upload-area.csv-drop-active { border-color: #2563eb; background: #eff6ff; }
.csv-file-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.csv-upload-label { display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; font-size: 14px; color: #6b7280; }
.csv-upload-icon { font-size: 28px; }

/* ── Responsive ── */
@media (max-width: 1200px) {
  .settings-columns { grid-template-columns: 1fr; }
  .global-settings-layout { grid-template-columns: 1fr; }
  .global-submenu { flex-direction: row; flex-wrap: wrap; }
  .global-submenu-item { width: auto; }
}
@media (max-width: 1000px) {
  .app { grid-template-columns: 1fr; }
  .settings-shell { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-sidebar { padding: 16px; }
  .settings-nav { flex-direction: row; flex-wrap: wrap; }
}

/* ── Back to website link ── */
.topnav-home-link {
  display: flex; align-items: center;
  text-decoration: none;
  padding: 4px 10px 4px 4px;
  line-height: 1;
  border-right: 1px solid #334155;
  margin-right: 10px;
}
.topnav-home-link .brand-logo { height: 40px; width: auto; }
.topnav-home-link:hover { opacity: 0.85; }

/* ── Hamburger button (hidden by default on desktop) ── */
.hamburger-btn { display: none; background: transparent; border: none; color: #fff; font-size: 22px; cursor: pointer; padding: 4px 8px; line-height: 1; }

/* ── Mobile portfolio drawer (hidden by default) ── */
.mobile-portfolio-drawer { background: #0f172a; padding: 12px 16px; max-height: 50vh; overflow-y: auto; }
.mobile-portfolio-drawer .portfolio-list { gap: 6px; }
.mobile-eq-subnav { display: none; }

/* ── Mobile profile (≤768px) ── */
@media (max-width: 768px) {
  /* Hide Settings tab, group label, divider & sidebar */
  .topnav-group-label, .topnav-divider { display: none; }
  .topnav-channel-tabs { padding-left: 0; }
  .topnav-channel-tabs::before { display: none; }
  .sidebar { display: none; }
  .app { grid-template-columns: 1fr; }

  /* Show hamburger */
  .hamburger-btn { display: block; }

  /* Compact nav — switch to flex-wrap layout */
  .topnav { display: flex; flex-wrap: wrap; align-items: center; padding: 6px 12px; height: auto; min-height: 50px; gap: 4px; }
  .topnav-left { flex: 0 0 auto; }
  .topnav-left .brand { display: none; }
  .topnav-left .brand-logo { height: 36px; }
  .topnav-tabs { order: 3; flex: 1 1 100%; justify-content: center; padding: 4px 0 2px; }
  .topnav-right-group { margin-left: auto; }
  .topnav .brand { font-size: 14px; }
  .profile-menu-name { display: none; }
  .profile-menu-trigger { min-width: 0; padding: 2px 4px; }
  .profile-menu-dropdown { right: -4px; min-width: 180px; }

  /* AI chat responsive */
  .ai-chat-label { display: none; }
  .ai-chat-toggle-btn { padding: 6px 8px; }
  .ai-chat-panel { width: 100vw; }

  /* Short tab labels on mobile */
  .tab-full { display: none; }
  .tab-short { display: inline; }

  /* Compact content */
  .content { padding: 10px; }
  header { flex-wrap: wrap; gap: 6px; }
  .header-actions { flex-wrap: wrap; gap: 6px; }
  .search-input { width: 100%; }
  .profile-photo-section { flex-direction: column; align-items: flex-start; }

  /* Summary: 3 key cards only */
  .summary-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
  .summary-card { padding: 8px 10px; }
  .summary-card span { font-size: 10px; }
  .summary-card strong { font-size: 14px; }
  /* Hide Holdings count and Total Cost cards on mobile */
  .summary-card:nth-child(1),
  .summary-card:nth-child(2) { display: none; }

  /* Keep treemap compact on mobile */
  #treemap-chart { min-height: 200px; }

    /* Table: show only Symbol(1), Market Value(12), P&L(13), P&L%(14), Tags(18) */
    /* Hide columns: Signals(2), Exchange(3), Type(4), Qty(5), Avg Cost(6),
      Current(7), Prev Close(8), Day Chg(9), Day%(10), Purchase Cost(11),
      Cur%(15), Target%(16), Addl Invest(17), Comment(19) */
    th:nth-child(2), td:nth-child(2),
    th:nth-child(3), td:nth-child(3),
    th:nth-child(4), td:nth-child(4),
    th:nth-child(5), td:nth-child(5),
    th:nth-child(6), td:nth-child(6),
    th:nth-child(7), td:nth-child(7),
    th:nth-child(8), td:nth-child(8),
    th:nth-child(9), td:nth-child(9),
    th:nth-child(10), td:nth-child(10),
    th:nth-child(11), td:nth-child(11),
    th:nth-child(15), td:nth-child(15),
    th:nth-child(16), td:nth-child(16),
    th:nth-child(17), td:nth-child(17),
    th:nth-child(19), td:nth-child(19) { display: none; }

  /* Make visible columns fit */
  table { table-layout: auto; }
  th, td { padding: 6px 8px; font-size: 11px; }
  td { white-space: nowrap; }

  /* Modal responsive */
  .modal-dialog { width: 95vw; }
  .holding-modal-grid { grid-template-columns: 1fr 1fr; }
  .al-entry-value-grid { grid-template-columns: 1fr; }

  /* Hide month-by-month projection tables on mobile */
  #eq-subview-eq-dashboard .table-scroll-wrapper,
  #view-income-expense .ie-table-wrapper,
  #view-assets-liabilities .ie-table-wrapper { display: none; }
}

/* ═══════════════════════════════════════════
  Cash Flow Planner
   ═══════════════════════════════════════════ */
#view-income-expense.active {
  display: flex !important;
  flex-direction: column;
  height: calc(100vh - 52px);
  overflow: hidden;
}
.ie-shell {
  padding: 20px 24px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.ie-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.ie-header h2 { margin: 0; }
.ie-header-actions { display: flex; gap: 8px; }

.ie-flow-section {
  margin-bottom: 16px;
  padding: 14px 16px 12px;
}
.ie-flow-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.ie-flow-header h3 {
  margin: 0 0 4px;
  font-size: 16px;
}
.ie-flow-header p {
  margin: 0;
  font-size: 12px;
  color: #6b7280;
}
.ie-flow-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #4b5563;
}
.ie-flow-controls {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.ie-flow-filter input[type="range"] {
  width: 140px;
  accent-color: #2563eb;
}
.ie-flow-filter strong {
  min-width: 38px;
  color: #111827;
  font-weight: 600;
}
.ie-flow-filter span {
  font-weight: 600;
}
.ie-flow-filter select {
  min-width: 136px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 7px 10px;
  font: inherit;
  color: #111827;
  background: #fff;
}
#ie-flow-chart {
  width: 100%;
  min-height: 120px;
  overflow: hidden;
}
#ie-flow-chart svg {
  width: 100%;
  height: auto;
  display: block;
  max-width: 100%;
}
.ie-flow-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.ie-flow-left {
  min-width: 0;
}
.ie-flow-right {
  min-width: 0;
  border-left: 1px solid #e5e7eb;
  padding-left: 20px;
}
.ie-major-title {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}
.ie-major-subtitle {
  margin: 0 0 12px;
  font-size: 11px;
  color: #6b7280;
}
#ie-major-items {
  max-height: 260px;
  overflow-y: auto;
}
.ie-major-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  gap: 12px;
}
.ie-major-item .ie-major-info {
  min-width: 0;
  flex: 1 1 auto;
  display: inline-flex;
  align-items: baseline;
}
.ie-major-item .ie-major-right {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.ie-major-item .ie-major-months {
  font-size: 11px;
  color: #6b7280;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ie-major-item-expense {
  background: #fef2f2;
  border: 1px solid #fecaca;
}
.ie-major-item-investment {
  background: #fffbeb;
  border: 1px solid #fde68a;
}
.ie-major-item .ie-major-name {
  font-weight: 500;
  color: #1f2937;
}
.ie-major-item .ie-major-type {
  font-size: 11px;
  color: #6b7280;
  margin-left: 6px;
}
.ie-major-item .ie-major-amount {
  font-weight: 600;
  white-space: nowrap;
}
.ie-major-item-expense .ie-major-amount { color: #dc2626; }
.ie-major-item-investment .ie-major-amount { color: #d97706; }
.ie-major-empty {
  font-size: 12px;
  color: #9ca3af;
  padding: 16px 0;
}
@media (max-width: 900px) {
  .ie-flow-split {
    grid-template-columns: 1fr;
  }
  .ie-flow-right {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid #e5e7eb;
    padding-top: 14px;
  }
}
.ie-pie-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}
.ie-pie-card {
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
  background: #fff;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ie-pie-card h4 {
  margin: 0;
  font-size: 14px;
}
.ie-pie-total {
  font-size: 12px;
  color: #6b7280;
}
.ie-pie-figure {
  width: min(100%, 300px);
  height: auto;
  margin: 0 auto;
  flex: 0 0 auto;
}
.ie-pie-callout-line {
  stroke: #94a3b8;
  stroke-width: 1;
  fill: none;
}
.ie-pie-callout-dot {
  stroke: #ffffff;
  stroke-width: 0.75;
}
.ie-pie-callout-label {
  font-size: 7px;
  font-weight: 600;
  fill: #374151;
}
.ie-pie-callout-value {
  font-size: 6px;
  fill: #6b7280;
}
.ie-pie-empty {
  margin: auto 0;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
}

@media (max-width: 640px) {
  .ie-flow-filter {
    width: 100%;
    justify-content: space-between;
  }
  .ie-flow-filter select {
    flex: 1 1 auto;
  }
}

/* Summary cards */
.ie-items-summary { margin-bottom: 16px; }
.ie-summary-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ie-summary-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 160px;
  flex: 0 0 auto;
  font-size: 12px;
}
.ie-card-income { background: #f0fdf4; border: 1px solid #bbf7d0; border-left: 3px solid #16a34a; }
.ie-card-expense { background: #fef2f2; border: 1px solid #fecaca; border-left: 3px solid #dc2626; }
.ie-card-investment { background: #fffbeb; border: 1px solid #fde68a; border-left: 3px solid #d97706; }
.ie-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
  font-size: 0.75em;
}
.ie-card-type { font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.ie-card-income .ie-card-type { color: #16a34a; }
.ie-card-expense .ie-card-type { color: #dc2626; }
.ie-card-investment .ie-card-type { color: #d97706; }
.ie-card-freq { color: #6b7280; }
.ie-card-name { font-weight: 600; font-size: 0.92em; margin-bottom: 1px; }
.ie-card-amount { font-size: 1em; font-weight: 700; color: #111827; }
.ie-card-dates { font-size: 0.75em; color: #6b7280; margin-top: 2px; }
.ie-card-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; min-height: 20px; }
.ie-card-meta { font-size: 0.75em; color: #6b7280; margin-top: 4px; }
.ie-card-actions { margin-top: 4px; display: flex; gap: 4px; }
.al-summary-cards .ie-summary-card { min-width: 220px; }
.al-card-asset { background: #f0fdf4; border: 1px solid #bbf7d0; border-left: 3px solid #16a34a; }
.al-card-liability { background: #fef2f2; border: 1px solid #fecaca; border-left: 3px solid #dc2626; }
.al-card-asset .ie-card-type { color: #16a34a; }
.al-card-liability .ie-card-type { color: #dc2626; }

/* Goal cards */
.goal-summary-cards .ie-summary-card { min-width: 220px; }

.al-double-count-notice { background: #fffbeb; border: 1px solid #fbbf24; border-left: 3px solid #f59e0b; border-radius: 6px; padding: 10px 14px; margin-bottom: 16px; font-size: 0.85rem; color: #78350f; line-height: 1.45; }
.al-double-count-notice strong { color: #92400e; }

/* Link card picker (A&L ↔ MMF linking) */
.link-card-picker { display: flex; flex-wrap: wrap; gap: 8px; max-height: 180px; overflow-y: auto; padding: 4px 0; }
.link-card { display: inline-flex; flex-direction: column; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 0.8rem; line-height: 1.35; min-width: 120px; max-width: 200px; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; user-select: none; border: 2px solid #e5e7eb; background: #f9fafb; }
/* MMF type colors on link cards */
.link-card.lc-income { background: #f0fdf4; border: 2px solid #bbf7d0; border-left: 3px solid #16a34a; }
.link-card.lc-expense { background: #fef2f2; border: 2px solid #fecaca; border-left: 3px solid #dc2626; }
.link-card.lc-investment { background: #fffbeb; border: 2px solid #fde68a; border-left: 3px solid #d97706; }
/* A&L type colors on link cards */
.link-card.lc-asset { background: #f0fdf4; border: 2px solid #bbf7d0; border-left: 3px solid #16a34a; }
.link-card.lc-liability { background: #fef2f2; border: 2px solid #fecaca; border-left: 3px solid #dc2626; }
/* Linked state overlay */
.link-card.linked { box-shadow: 0 0 0 2px #2563eb; }
.link-card-name { font-weight: 600; color: #1e293b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-card.lc-income .link-card-name { color: #166534; }
.link-card.lc-expense .link-card-name { color: #991b1b; }
.link-card.lc-investment .link-card-name { color: #92400e; }
.link-card.lc-asset .link-card-name { color: #166534; }
.link-card.lc-liability .link-card-name { color: #991b1b; }
.link-card-detail { color: #64748b; font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-card-badge { display: inline-block; font-size: 0.65rem; font-weight: 600; padding: 1px 6px; border-radius: 4px; margin-top: 3px; align-self: flex-start; }
.link-card-badge.badge-linked { background: #2563eb; color: #fff; }
.link-card-badge.badge-unlinked { background: #e5e7eb; color: #6b7280; }

.ie-flow-label-income { color: #166534; }
.ie-flow-label-expense { color: #b91c1c; }
.ie-flow-label-investment { color: #b45309; }
.ie-flow-label-balance { color: #1d4ed8; }

@media (max-width: 960px) {
  .topnav-tabs { position: static; left: auto; transform: none; }
  .ie-pie-grid {
    grid-template-columns: 1fr;
  }
}

/* Dashboard table */
.ie-table-wrapper { overflow: hidden; flex: none; min-height: 320px; display: flex; flex-direction: column; }
.ie-table-scroll {
  overflow: auto;
  flex: 1;
  min-height: 0;
  max-height: min(62vh, 720px);
}
#ie-dashboard-table {
  width: max-content;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 12px;
}
#ie-dashboard-table th,
#ie-dashboard-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#ie-dashboard-table th {
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 600;
  color: #6b7280;
  white-space: normal;
  word-wrap: break-word;
}
#ie-dashboard-table th small {
  font-weight: 400;
  color: #6b7280;
}
.ie-month-col { text-align: left !important; font-weight: 500; min-width: 100px; position: sticky; left: 0; z-index: 3; background: #fff; border-right: 2px solid #e5e7eb; }
#ie-dashboard-table thead .ie-month-col { background: #f9fafb; z-index: 4; }
.ie-item-col { min-width: 120px; }
.ie-total-col { min-width: 130px; font-weight: 600; background: #f0f9ff; }
.ie-cumulative-col { background: #faf5ff; }
.ie-group-total-col { min-width: 130px; font-weight: 600; }
.ie-expense-group { background: #fef2f2; }
.ie-income-group { background: #f0fdf4; }
.ie-investment-group { background: #fffbeb; }
.ie-group-toggle { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 4px; background: #e5e7eb; color: #374151; font-weight: 700; font-size: 14px; cursor: pointer; margin-right: 4px; line-height: 1; vertical-align: middle; }
.ie-group-toggle:hover { background: #d1d5db; }
.al-group-toggle { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 4px; background: #e5e7eb; color: #374151; font-weight: 700; font-size: 14px; cursor: pointer; margin-right: 4px; line-height: 1; vertical-align: middle; }
.al-group-toggle:hover { background: #d1d5db; }
.ie-val-income { color: #16a34a; }
.ie-val-expense { color: #dc2626; }
.ie-val-investment { color: #d97706; }
.ie-val-empty { color: #d1d5db; }

#ie-dashboard-table tbody tr:hover {
  background: #f8fafc;
}

#al-dashboard-table {
  width: max-content;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 12px;
}
#al-dashboard-table th,
#al-dashboard-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#al-dashboard-table th {
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 600;
  color: #6b7280;
  white-space: normal;
  word-wrap: break-word;
}
#al-dashboard-table th small {
  font-weight: 400;
  color: #6b7280;
}
#al-dashboard-table thead .ie-month-col { background: #f9fafb; z-index: 4; }
#al-dashboard-table tbody tr:hover {
  background: #f8fafc;
}

#wd-dashboard-table {
  width: max-content;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 12px;
}
#wd-dashboard-table th,
#wd-dashboard-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#wd-dashboard-table th {
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 600;
  color: #6b7280;
  white-space: normal;
  word-wrap: break-word;
}
#wd-dashboard-table thead .ie-month-col { background: #f9fafb; z-index: 4; }
#wd-dashboard-table tbody tr:hover {
  background: #f8fafc;
}
.wd-eq-group { background: #eff6ff; }
.wd-mmf-group { background: #faf5ff; }
.wd-liquid-group { background: #f5f3ff; }
.wd-al-group { background: #f0fdf4; }
.wd-liquid-adj-group { background: #fef2f2; }
.wd-goal-group { background: #fff7ed; }
.wd-grand-col { background: #fefce8; font-weight: 700; }

/* ── Goal modal layout ── */
.goal-calc-row { display: flex; gap: 12px; margin-bottom: 4px; }
.goal-calc-row .form-group-inline { flex: 1; }
.goal-future-row { display: flex; gap: 12px; align-items: flex-end; margin-bottom: 8px; }
.goal-future-row .form-group-inline { flex: 1; }
.goal-future-row .btn-sm { margin-bottom: 4px; }
.optional-label { font-size: 0.8em; color: #94a3b8; }
.sp-detail { font-size: 0.82em; color: #64748b; margin-left: 4px; }

/* ── Wealth Dashboard Grand Total Chart ── */
.wd-chart-container { margin-bottom: 20px; padding: 16px; background: #fff; border-radius: 10px; border: 1px solid #e5e7eb; }
.wd-chart-container svg { display: block; width: 100%; height: auto; }
.wd-chart-title { font-size: 14px; font-weight: 600; color: #1e293b; margin-bottom: 8px; }
.wd-chart-grid-line { stroke: #e5e7eb; stroke-width: 0.5; }
.wd-chart-axis-label { font-size: 9px; fill: #6b7280; }
.wd-chart-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.wd-chart-line-grand { stroke: #166534; }
.wd-chart-line-al { stroke: #2563eb; }
.wd-chart-line-lag { stroke: #9333ea; }
.wd-chart-area { stroke: none; }
.wd-chart-area-al { fill: #2563eb; opacity: 0.18; }
.wd-chart-area-lag { fill: #9333ea; opacity: 0.18; }
.wd-chart-legend { display: flex; gap: 16px; margin-top: 6px; font-size: 11px; color: #4b5563; }
.wd-chart-legend-item { display: flex; align-items: center; gap: 4px; }
.wd-chart-legend-swatch { width: 12px; height: 3px; border-radius: 2px; }
.wd-swatch-area { height: 8px; opacity: 0.7; border-radius: 2px; }
.wd-swatch-goal { width: 10px; height: 10px; border-radius: 50%; opacity: 1; }
.wd-goal-marker { pointer-events: all; }
.wd-goal-marker title { pointer-events: none; }

/* ── Equities sub-view nav & dashboard ── */
.eq-sidebar-dashboard-btn { display: block; width: 100%; background: transparent; border: 1px solid #334155; color: #94a3b8; font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 8px; cursor: pointer; transition: background 0.15s, color 0.15s; text-align: center; margin-bottom: 12px; }
.eq-sidebar-dashboard-btn:hover { background: #1e293b; color: #fff; }
.eq-sidebar-dashboard-btn.active { background: #2563eb; color: #fff; border-color: #2563eb; }
.eq-subview { display: none; }
.eq-subview.active { display: block; }

#eq-dashboard-table {
  width: max-content;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 12px;
}
#eq-dashboard-table th,
#eq-dashboard-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#eq-dashboard-table th {
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 2;
  font-weight: 600;
  color: #6b7280;
  white-space: normal;
  word-wrap: break-word;
}
#eq-dashboard-table thead .ie-month-col { background: #f9fafb; z-index: 4; }
#eq-dashboard-table tbody tr:hover { background: #f8fafc; }
.eq-india-group { background: #fff7ed; }
.eq-global-group { background: #eff6ff; }
.eq-total-col { background: #fefce8; font-weight: 700; }
.eq-assumed-col { background: #ecfdf5; font-weight: 700; }
.eq-chart-area { fill: #f59e0b; opacity: 0.10; stroke: none; }
.eq-chart-line { fill: none; stroke: #f59e0b; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Equity return sliders ── */
.eq-return-sliders { display: flex; gap: 24px; padding: 12px 16px; background: #fff; border-radius: 10px; border: 1px solid #e5e7eb; margin-bottom: 16px; }
.eq-slider-group { flex: 1; }
.eq-slider-group label { display: block; font-size: 0.82rem; color: #374151; margin-bottom: 4px; }
.eq-slider-group input[type="range"] { width: 100%; accent-color: #f59e0b; }

/* ── Assets & Liabilities view ── */
.al-shell { padding: 20px 24px; }
.al-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.al-header h2 { font-size: 1.25rem; font-weight: 600; color: #1e293b; margin: 0; }
.al-header-actions { display: flex; gap: 8px; }

/* ── IE months picker ── */
.ie-months-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 12px; }
.ie-months-picker label { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }
.ie-months-picker input[type="checkbox"] { margin: 0; }

/* ── IE sporadic entries picker ── */
.ie-sporadic-add-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; }
.ie-sporadic-add-row .date-select-row { flex: 1; min-width: 0; }
.ie-sporadic-add-row input[type="number"] { width: 110px; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }
.ie-sporadic-list { max-height: 220px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 6px; }
.ie-sporadic-list:empty { display: none; }
.ie-sporadic-entry { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.ie-sporadic-entry:last-child { border-bottom: none; }
.ie-sporadic-entry .sp-month { font-weight: 500; color: #1f2937; min-width: 130px; }
.ie-sporadic-entry .sp-amount { font-weight: 600; color: #111827; }
.ie-sporadic-entry .sp-remove { background: none; border: none; color: #dc2626; cursor: pointer; font-size: 16px; padding: 0 4px; line-height: 1; }

@media (max-width: 640px) {
  .date-select-row {
    grid-template-columns: 1fr;
  }

  .ie-sporadic-add-row {
    flex-direction: column;
    align-items: stretch;
  }

  .ie-sporadic-add-row input[type="number"],
  .ie-sporadic-add-row .secondary {
    width: 100%;
  }
}

/* ══════════════════════════════════════════
   Analytics & Insights
   ══════════════════════════════════════════ */
.analytics-shell { padding: 20px 24px; max-width: 1200px; }
.analytics-header-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.analytics-filters { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.analytics-filters label { display: flex; flex-direction: column; gap: 2px; font-size: 0.78rem; color: #6b7280; }
.analytics-filters select { padding: 5px 10px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.85rem; min-width: 160px; background: #fff; }
.analytics-section { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.analytics-section h3 { font-size: 1.1rem; font-weight: 600; color: #1e293b; margin: 0 0 14px 0; }
.analytics-controls { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.analytics-controls label { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: #374151; }
.analytics-controls select, .analytics-controls input[type="number"] { padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 0.85rem; }
.analytics-row { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.analytics-chart { min-height: 280px; overflow-x: auto; }
.analytics-summary { margin-top: 12px; }

/* Health Score Ring */
.health-score-ring { flex: 0 0 130px; }
.health-ring-svg { width: 130px; height: 130px; }
.health-ring-score { font-size: 28px; font-weight: 700; fill: #111827; }
.health-ring-grade { font-size: 12px; fill: #6b7280; }
#health-ring-progress { transition: stroke-dashoffset 0.8s ease-in-out, stroke 0.5s; }

/* Health Components */
.health-components { flex: 1; min-width: 200px; }
.health-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 0.82rem; color: #374151; }
.health-bar-row > span:first-child { min-width: 100px; }
.health-bar-row > span:last-child { min-width: 50px; text-align: right; font-weight: 600; color: #6b7280; }
.health-bar { flex: 1; height: 8px; background: #f3f4f6; border-radius: 4px; overflow: hidden; }
.health-bar-fill { height: 100%; border-radius: 4px; transition: width 0.6s; }

/* Health Details */
.health-details { flex: 0 0 auto; }
.health-detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.health-detail-grid div { text-align: center; padding: 8px; background: #f9fafb; border-radius: 8px; }
.health-detail-grid strong { display: block; font-size: 1.1rem; color: #111827; }
.health-detail-grid small { color: #6b7280; font-size: 0.75rem; }

/* Recap */
.recap-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.recap-card { background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 8px; padding: 14px; }
.recap-card-wide { grid-column: 1 / -1; }
.recap-card h4 { margin: 0 0 10px 0; font-size: 0.9rem; color: #374151; }
.recap-stats { display: flex; gap: 20px; flex-wrap: wrap; }
.recap-stats div { text-align: center; }
.recap-stats strong { display: block; font-size: 1.1rem; }
.recap-stats small { color: #6b7280; font-size: 0.75rem; }
.recap-period { margin-top: 10px; padding-top: 8px; border-top: 1px solid #e5e7eb; display: flex; justify-content: space-between; font-size: 0.85rem; }
.recap-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.recap-table th, .recap-table td { padding: 5px 8px; text-align: right; border-bottom: 1px solid #f3f4f6; }
.recap-table th { text-align: left; color: #6b7280; font-weight: 500; background: transparent; }
.recap-table td:first-child { text-align: left; font-weight: 500; }
.recap-portfolio-name { text-align: left !important; color: #6b7280; font-weight: 400 !important; font-size: 0.78rem; }
.recap-alerts { list-style: none; padding: 0; margin: 0; }
.recap-alerts li { padding: 4px 0; font-size: 0.82rem; border-bottom: 1px solid #f3f4f6; }
.recap-alerts li:last-child { border-bottom: none; }

/* Investment Limit card (per-portfolio holdings view) */
.invest-limit-card { padding: 16px 18px; margin-bottom: 14px; }
.invest-limit-card .invest-limit-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.invest-limit-card h3 { margin: 0 0 2px 0; font-size: 1rem; color: #1f2937; }
.invest-limit-card .treemap-subtitle { margin: 0; }
.invest-limit-status { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.invest-limit-status.is-under { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.invest-limit-status.is-near { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.invest-limit-status.is-over { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.invest-limit-status.is-unset { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }
.invest-limit-stats { display: flex; gap: 24px; flex-wrap: wrap; margin-top: 12px; }
.invest-limit-stats div { display: flex; flex-direction: column; min-width: 110px; }
.invest-limit-stats small { color: #6b7280; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
.invest-limit-stats strong { font-size: 1.05rem; color: #1f2937; }
.invest-limit-bar { margin-top: 12px; height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.invest-limit-bar > div { height: 100%; width: 0%; background: #16a34a; transition: width 0.3s ease, background 0.3s ease; }
.invest-limit-bar > div.is-near { background: #d97706; }
.invest-limit-bar > div.is-over { background: #dc2626; }

/* Investment Limits analytics table */
#invest-limits-table .invest-limit-status { font-size: 0.72rem; padding: 2px 8px; }
.invest-limit-status-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.invest-limit-edit-btn { padding: 2px 8px; font-size: 0.72rem; line-height: 1.6; white-space: nowrap; }

/* Rebalance Sankey */
.rebalance-sankey-svg { display: block; width: 100%; height: auto; }
.rebalance-summary-row { display: flex; gap: 24px; font-size: 0.9rem; padding: 8px 0; flex-wrap: wrap; align-items: center; }
.rebalance-formula { flex-basis: 100%; color: #6b7280; font-size: 0.8rem; font-style: italic; }



/* ═══════════════════════════════════════════
   Responsive: Tablet (≤960px)
   ═══════════════════════════════════════════ */
@media (max-width: 960px) {
  .analytics-shell { padding: 16px 14px; }
  .analytics-section { padding: 14px; }
  .health-detail-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }

  .rebalance-summary-row { flex-wrap: wrap; gap: 12px; }
  .recap-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ═══════════════════════════════════════════
   Responsive: Mobile (≤768px)
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  /* ── Global overflow safety ── */
  .content, .ie-shell, .al-shell, .analytics-shell { overflow-x: hidden; }

  /* ── Mobile equity sub-nav in drawer ── */
  .mobile-eq-subnav { display: flex; gap: 6px; margin-bottom: 10px; }
  .mobile-eq-subnav .eq-sidebar-dashboard-btn { flex: 1; font-size: 0.8rem; padding: 8px 6px; }

  /* ── Summary grid: 2 columns at mobile ── */
  .al-shell .summary-grid,
  .ie-shell .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }

  /* ── Analytics ── */
  .analytics-shell { padding: 10px 8px; max-width: 100%; }
  .analytics-header-bar { flex-direction: column; align-items: flex-start; gap: 8px; }
  .analytics-filters { width: 100%; }
  .analytics-filters label { flex: 1; min-width: 0; }
  .analytics-filters select { min-width: 0; width: 100%; font-size: 0.82rem; }
  .analytics-section { padding: 12px 10px; margin-bottom: 12px; }
  .analytics-section h3 { font-size: 0.95rem; }
  .analytics-controls { gap: 8px; }
  .analytics-controls label { font-size: 0.78rem; }
  .analytics-controls select, .analytics-controls input[type="number"] { font-size: 0.78rem; padding: 4px 6px; }
  .analytics-row { gap: 12px; }
  .analytics-chart { min-height: 200px; }

  /* Health score ring compact */
  .health-score-ring { flex: 0 0 100px; }
  .health-ring-svg { width: 100px; height: 100px; }
  .health-ring-score { font-size: 22px; }
  .health-components { min-width: 0; }
  .health-bar-row > span:first-child { min-width: 80px; font-size: 0.75rem; }
  .health-bar-row > span:last-child { min-width: 40px; font-size: 0.75rem; }
  .health-detail-grid { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .health-detail-grid strong { font-size: 0.9rem; }
  .health-detail-grid small { font-size: 0.68rem; }

  /* Recap compact */
  .recap-grid { grid-template-columns: 1fr; gap: 10px; }
  .recap-stats { gap: 10px; }
  .recap-stats strong { font-size: 0.9rem; }
  .recap-period { flex-direction: column; gap: 4px; font-size: 0.78rem; }
  .recap-table { font-size: 0.75rem; }
  .recap-table th, .recap-table td { padding: 4px 5px; }


  .whatif-table-wrap { max-height: 300px; }

  /* Rebalance compact */
  .rebalance-summary-row { flex-direction: column; gap: 6px; font-size: 0.8rem; }

  /* Forecast compact */
  .forecast-svg { min-width: 500px; }
}

/* ═══════════════════════════════════════════
   Responsive: Small phone (≤480px)
   ═══════════════════════════════════════════ */
@media (max-width: 480px) {
  .topnav-channel-tabs { gap: 2px; }
  .topnav-tab { font-size: 11px; padding: 4px 6px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .analytics-row { flex-direction: column; }
  .health-score-ring { flex: 0 0 auto; align-self: center; }
  .risk-metric { flex: 1 1 calc(50% - 8px); }
  .whatif-compare { flex-direction: column; }
  .whatif-arrow { transform: rotate(90deg); }
  .ie-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .ie-header-actions { width: 100%; flex-wrap: wrap; }
  .al-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .al-header-actions { width: 100%; flex-wrap: wrap; }
}
