/* MoneyBot Chat — Vanilla CSS */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f5f6fa;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

#app {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: auto repeat(3, 1fr) auto;
    height: 100vh;
    width: 100%;
    background: #f5f6fa;
    gap: 1px;
    overflow: hidden;
}

/* View switcher bar — spans full width */
#view-bar {
    grid-column: 1 / -1;
    grid-row: 1;
    background: #1a1a2e;
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 2px;
    height: 36px;
    z-index: 10;
}

/* View bar branding */
.view-bar-brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-right: 16px;
    flex-shrink: 0;
}
.view-bar-brand .brand-name {
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 1.5px;
}
.view-bar-brand .brand-powered {
    font-family: 'Georgia', serif;
    font-size: 10px;
    font-style: italic;
    color: rgba(255,255,255,0.3);
    letter-spacing: 0.3px;
}

#view-bar .view-btn {
    padding: 5px 14px;
    font-size: 11px;
    font-weight: 600;
    border: none;
    border-radius: 4px 4px 0 0;
    background: transparent;
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

#view-bar .view-btn:hover {
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.06);
}

#view-bar .view-btn.active {
    background: #f5f6fa;
    color: #1a1a2e;
}

#view-bar .view-profile-name {
    margin-left: auto;
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    font-weight: 500;
}

#view-bar #back-btn {
    margin-left: 8px;
}

/* ================================================================
   Grid Card System
   ================================================================ */
.grid-card {
    background: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.grid-card.hidden {
    display: none;
}

/* Card header */
.card-header {
    display: flex;
    align-items: center;
    padding: 8px 12px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    font-weight: 600;
    background: #fafbfc;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.card-header .card-title {
    flex: 1;
}

.card-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 12px;
}

/* Minimized bar */
#minimized-bar {
    grid-column: 1 / -1;
    grid-row: 5;
    display: flex;
    gap: 6px;
    padding: 4px 12px;
    background: #e8e8ec;
    min-height: 0;
    align-items: center;
    flex-wrap: wrap;
}
#minimized-bar:empty { display: none; }

.minimized-chip {
    padding: 4px 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 11px;
    cursor: grab;
    user-select: none;
    white-space: nowrap;
}
.minimized-chip:hover { background: #f0f4ff; border-color: #6c63ff; }

/* Card header with drag handle */
.card-header { cursor: grab; }
.drag-handle {
    width: 14px;
    color: #bbb;
    margin-right: 6px;
    font-size: 14px;
}
.drag-handle::before { content: '\2261'; }

/* Card size dropdown in header */
.card-size-select {
    font-size: 9px;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: auto;
    background: #fff;
    color: #666;
    cursor: pointer;
}

/* Drop indicator overlay */
#drop-indicator {
    position: absolute;
    background: rgba(108, 99, 255, 0.15);
    border: 2px dashed #6c63ff;
    border-radius: 4px;
    pointer-events: none;
    z-index: 100;
    display: none;
}

/* Dragging state */
.grid-card.dragging { opacity: 0.4; }

/* View bar: add button, close button, goal dropdown */
.view-add-btn {
    color: rgba(255,255,255,0.5);
    background: none;
    border: 1px dashed rgba(255,255,255,0.3);
    border-radius: 4px;
    font-size: 14px;
    padding: 2px 8px;
    cursor: pointer;
    margin-left: 2px;
}
.view-add-btn:hover { color: rgba(255,255,255,0.85); border-color: rgba(255,255,255,0.5); }

.view-tab-close {
    font-size: 10px;
    margin-left: 4px;
    color: rgba(255,255,255,0.4);
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}
.view-tab-close:hover { color: rgba(255,255,255,0.8); }

#goal-context-select {
    margin-left: 12px;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: #fff;
}
#goal-context-select option { color: #333; background: #fff; }

/* Profile sidebar (now a grid card) */
#profile-sidebar {
    overflow-y: auto;
    background: #fafbfc;
    padding: 12px;
}

#profile-sidebar:empty {
    display: none;
}

.sidebar-name {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 2px;
}

.sidebar-archetype {
    font-size: 13px;
    color: #6c63ff;
    font-weight: 500;
    margin-bottom: 16px;
}

.sidebar-section {
    margin-bottom: 14px;
}

.sidebar-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    font-weight: 600;
    margin-bottom: 4px;
}

.sidebar-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px 12px;
    font-size: 12px;
    color: #444;
}

.sidebar-grid .label {
    color: #888;
}

.sidebar-grid .value {
    font-weight: 500;
    text-align: right;
}

.sidebar-notes {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
    font-size: 11px;
    color: #666;
    line-height: 1.5;
    font-style: italic;
}

/* Sidebar transaction history (collapsible) */
.sidebar-transactions {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.sidebar-transactions summary {
    cursor: pointer;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    font-weight: 600;
    padding: 4px 0;
    user-select: none;
}

.sidebar-transactions summary:hover {
    color: #555;
}

.txn-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-top: 6px;
}

.txn-table th {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #888;
    font-weight: 600;
    text-align: left;
    padding: 4px 4px;
    border-bottom: 1px solid #e0e0e0;
}

.txn-table th:last-child {
    text-align: right;
}

.txn-table td {
    padding: 3px 4px;
    color: #444;
    border-bottom: 1px solid #f0f0f0;
}

.txn-table td:last-child {
    text-align: right;
    font-weight: 500;
}

.txn-table tr:nth-child(even) {
    background: #f8f9fa;
}

.txn-table tr.txn-rebalance {
    background: #fff8e1;
    font-style: italic;
}

.txn-table tr.txn-rebalance td {
    color: #8d6e00;
    font-size: 10px;
}

.txn-month-header td {
    font-weight: 600;
    color: #1a1a2e;
    padding-top: 8px;
    border-bottom: 1px solid #ddd;
    font-size: 11px;
}

/* Chat column (now a grid card) */
#chat-column {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
}

/* Header — hidden in grid mode, replaced by view bar */
header {
    display: none;
}

#session-status {
    font-size: 12px;
    color: #888;
}

#session-status.connected {
    color: #4caf50;
}

/* Chat container */
#chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Messages */
.message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.message.user {
    align-self: flex-end;
    background: #1a1a2e;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    align-self: flex-start;
    background: #f0f0f5;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
}

.message.system {
    align-self: center;
    background: #fff8e1;
    color: #666;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 6px;
}

/* Visualization containers inside messages */
.viz-container {
    margin: 12px 0 4px 0;
    padding: 12px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.viz-container canvas {
    max-width: 100%;
    max-height: 250px;
}

/* Metric card */
.metric-card {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 20px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin: 4px;
    min-width: 120px;
}

.metric-card .metric-value {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
}

.metric-card .metric-label {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    margin-top: 4px;
}

.metric-card .metric-delta {
    font-size: 12px;
    margin-top: 2px;
}

.metric-card .metric-delta.positive { color: #4caf50; }
.metric-card .metric-delta.negative { color: #f44336; }

/* Probability gauge (SVG) */
.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
}

.gauge-container svg {
    max-width: 160px;
}

.gauge-label {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

/* Typing indicator */
#typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    color: #888;
    font-size: 13px;
}

#typing-indicator.hidden {
    display: none;
}

.typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Tool call progress */
.tool-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 6px;
    font-size: 12px;
    align-self: flex-start;
}

.tool-progress .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid #81c784;
    border-top-color: #2e7d32;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Input bar */
#input-bar {
    display: flex;
    padding: 12px;
    gap: 8px;
    border-top: 1px solid #e0e0e0;
    background: #fff;
}

#message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#message-input:focus {
    border-color: #1a1a2e;
}

#send-btn {
    padding: 10px 20px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

#send-btn:hover {
    background: #2d2d4e;
}

#send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Hidden utility */
.hidden { display: none !important; }

/* Profile Selector */
#profile-selector {
    max-width: 1000px;
    margin: 40px auto;
    padding: 20px;
    text-align: center;
}

#profile-selector h2 {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.selector-subtitle {
    color: #888;
    margin-bottom: 20px;
    font-size: 14px;
}

/* Mode Toggle */
#mode-toggle {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 24px;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 14px;
    color: #555;
}

.mode-option:has(input:checked) {
    border-color: #1a1a2e;
    background: #f0f0f5;
    color: #1a1a2e;
    font-weight: 600;
}

.mode-option input[type="radio"] {
    accent-color: #1a1a2e;
}

#profile-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    text-align: left;
}

.profile-card {
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.profile-card:hover {
    border-color: #1a1a2e;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.profile-name {
    font-size: 17px;
    font-weight: 700;
    color: #1a1a2e;
}

.profile-archetype {
    font-size: 13px;
    color: #6c63ff;
    margin: 2px 0 12px 0;
    font-weight: 500;
}

.profile-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    font-size: 12px;
    color: #555;
}

.profile-notes {
    margin-top: 12px;
    font-size: 11px;
    color: #888;
    line-height: 1.4;
    border-top: 1px solid #eee;
    padding-top: 10px;
}

/* Back button */
#back-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 12px;
}

#back-btn:hover {
    background: rgba(255,255,255,0.1);
}

/* Dashboard panels in sidebar */
.sidebar-dashboard {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.dash-section {
    margin-bottom: 16px;
}

.dash-gauge {
    display: flex;
    justify-content: center;
    margin: 6px 0 4px 0;
}

.dash-gauge svg {
    max-width: 110px;
}

.dash-gauge-label {
    text-align: center;
    font-size: 10px;
    color: #888;
    margin-top: 2px;
}

.dash-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3px 8px;
    font-size: 11px;
    color: #444;
    margin-top: 6px;
}

.dash-stats .label { color: #888; }
.dash-stats .value { font-weight: 500; text-align: right; }

.dash-no-target {
    text-align: center;
    font-size: 11px;
    color: #999;
    font-style: italic;
    padding: 8px 0;
}

.dash-donut-wrap {
    display: flex;
    justify-content: center;
}

.dash-donut-wrap canvas {
    max-height: 160px;
}

.dash-account-row {
    display: flex;
    gap: 4px;
    justify-content: space-between;
}

.dash-account {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.dash-account-label {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #888;
    font-weight: 600;
    margin-bottom: 2px;
}

.dash-account canvas {
    max-height: 80px;
}

.dash-hill-wrap {
    margin-top: 4px;
}

.dash-hill-wrap canvas {
    max-height: 160px;
    width: 100%;
}

.dash-hill-legend {
    display: flex;
    justify-content: center;
    gap: 10px;
    font-size: 9px;
    margin-top: 4px;
    color: #888;
}

.dash-hill-legend span {
    display: flex;
    align-items: center;
    gap: 3px;
}

.dash-hill-legend .swatch {
    display: inline-block;
    width: 12px;
    height: 3px;
    border-radius: 1px;
}

/* Changeable Factors */
.cf-section {
    margin-bottom: 14px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.cf-row {
    margin-bottom: 8px;
}

.cf-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.cf-label {
    font-size: 11px;
    color: #888;
    font-weight: 500;
}

.cf-value {
    font-size: 11px;
    font-weight: 600;
    color: #1a1a2e;
}

.cf-slider {
    width: 100%;
    margin: 2px 0;
    -webkit-appearance: none;
    height: 4px;
    background: #e0e0e0;
    border-radius: 2px;
    outline: none;
}

.cf-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #1a1a2e;
    cursor: pointer;
}

.cf-input {
    width: 90px;
    padding: 4px 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 11px;
    text-align: right;
}

.cf-input:focus {
    border-color: #1a1a2e;
    outline: none;
}

.cf-risk-detail {
    font-size: 10px;
    color: #888;
    text-align: center;
    margin-top: 2px;
    padding: 2px 6px;
    background: #f8f9fa;
    border-radius: 3px;
}

.cf-risk-return {
    color: #28a745;
    font-weight: 700;
    font-size: 1.1em;
}

.cf-risk-loss {
    color: #dc3545;
    font-weight: 700;
    font-size: 1.1em;
}

.cf-risk-info-icon {
    cursor: pointer;
    position: relative;
    font-size: 0.85em;
    opacity: 0.7;
}
.cf-risk-info-icon:hover {
    opacity: 1;
}
.cf-risk-info-icon:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 400;
    width: 220px;
    line-height: 1.4;
    white-space: normal;
    z-index: 100;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.cf-nav {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 10px 0 6px;
}

.cf-nav button {
    padding: 4px 12px;
    font-size: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    color: #555;
}

.cf-nav button:hover:not(:disabled) {
    border-color: #1a1a2e;
    color: #1a1a2e;
}

.cf-nav button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.rebalance-btn {
    display: block;
    width: 100%;
    padding: 8px;
    margin-top: 6px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background 0.2s;
}

.rebalance-btn:hover {
    background: #2d2d4e;
}

.rebalance-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.cf-updating {
    text-align: center;
    font-size: 10px;
    color: #6c63ff;
    padding: 4px 0;
    font-style: italic;
}

.cf-pension-equiv {
    font-size: 0.85em;
    color: #666;
    text-align: center;
    margin-top: 1px;
}

.cf-savings-split {
    font-size: 0.85em;
    color: #666;
    margin-top: 3px;
    line-height: 1.4;
}

.cf-isa-first-label {
    font-size: 10px;
    color: #888;
    font-weight: 400;
    cursor: pointer;
    margin-left: 6px;
}

.cf-isa-first-label input {
    vertical-align: middle;
    margin-right: 2px;
}

/* Question suggestion buttons — above input bar */
#question-bar {
    padding: 0 12px;
}

.question-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0 4px;
    max-height: 108px;
    overflow: hidden;
}

.question-btn {
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 16px;
    padding: 6px 14px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.question-btn:hover {
    background: #f5f5f5;
    border-color: #999;
    color: #222;
}

.question-btn:active {
    transform: scale(0.97);
}

/* Responsive */
@media (max-width: 900px) {
    #app {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
    }

    .grid-card {
        grid-column: 1 !important;
        grid-row: auto !important;
    }

    #minimized-bar { grid-row: auto; }

    .message {
        max-width: 92%;
    }
}

/* ================================================================
   Portfolio Holdings
   ================================================================ */

.portfolio-section {
    padding: 0;
}

.portfolio-account {
    margin-bottom: 4px;
    border: 1px solid #eee;
    border-radius: 4px;
}

.portfolio-account summary {
    font-size: 11px;
    font-weight: 600;
    color: #444;
    cursor: pointer;
    padding: 6px 8px;
    user-select: none;
    background: #fafbfc;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.portfolio-account summary .acct-value {
    font-weight: 700;
    color: #1a1a2e;
    font-size: 11px;
}

.portfolio-account[open] summary {
    border-radius: 4px 4px 0 0;
    border-bottom: 1px solid #eee;
}

.portfolio-table {
    width: 100%;
    font-size: 10px;
    border-collapse: collapse;
    margin: 0;
    table-layout: fixed;
}

.portfolio-table thead th {
    text-align: left;
    font-weight: 600;
    color: #999;
    padding: 3px 6px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.portfolio-table tbody td {
    padding: 2px 6px;
    border-bottom: 1px solid #f8f8f8;
    vertical-align: middle;
    font-size: 10px;
    line-height: 1.3;
}

.portfolio-table tbody tr:hover {
    background: #f8f9ff;
}

.ptf-ticker {
    font-weight: 600;
    color: #333;
    font-family: "SF Mono", "Monaco", "Consolas", monospace;
    font-size: 9px;
    letter-spacing: 0.3px;
}

.ptf-name {
    color: #666;
    font-size: 9px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ptf-class {
    font-size: 8px;
    color: #999;
    background: #f0f0f0;
    padding: 1px 3px;
    border-radius: 2px;
    display: inline-block;
}

.ptf-pct {
    text-align: right;
    color: #666;
    font-size: 10px;
    font-weight: 500;
}

.ptf-val {
    text-align: right;
    font-weight: 600;
    color: #333;
    font-size: 10px;
}

.ptf-actions {
    text-align: right;
    white-space: nowrap;
}

.btn-buy, .btn-sell {
    font-size: 9px;
    padding: 2px 6px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    margin-left: 2px;
    font-weight: 600;
}

.btn-buy {
    background: #e8f5e9;
    color: #2e7d32;
}

.btn-buy:hover {
    background: #c8e6c9;
}

.btn-sell {
    background: #fce4ec;
    color: #c62828;
}

.btn-sell:hover {
    background: #f8bbd0;
}

.portfolio-cash {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-top: 1px solid #e0e0e0;
    margin-top: 4px;
    font-size: 12px;
}

.portfolio-cash .label {
    font-weight: 600;
    color: #444;
}

.portfolio-cash .value {
    font-weight: 700;
    color: #2e7d32;
}

/* Instrument search */
.instrument-search-wrap {
    position: relative;
    margin-top: 8px;
}

#instrument-search {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
}

#instrument-search:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 2px rgba(124,58,237,0.1);
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.search-dropdown:empty {
    display: none;
}

.search-result {
    display: flex;
    gap: 6px;
    padding: 6px 8px;
    cursor: pointer;
    font-size: 11px;
    align-items: center;
    border-bottom: 1px solid #f5f5f5;
}

.search-result:hover {
    background: #f0f0ff;
}

.sr-symbol {
    font-weight: 700;
    font-family: monospace;
    color: #333;
    min-width: 60px;
}

.sr-name {
    flex: 1;
    color: #555;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sr-class {
    font-size: 9px;
    color: #999;
    background: #f0f0f0;
    padding: 1px 4px;
    border-radius: 2px;
    white-space: nowrap;
}

.search-no-results {
    padding: 8px;
    color: #999;
    font-size: 11px;
    text-align: center;
}

/* Trade dialog overlay */
.trade-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.trade-dialog {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    width: 320px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.trade-title {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
}

.trade-name {
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
}

.trade-dialog label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #555;
    margin: 8px 0 3px;
}

.trade-dialog select,
.trade-dialog input[type="number"] {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.trade-buttons {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.trade-buttons .btn-confirm {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 4px;
    font-weight: 700;
    cursor: pointer;
    font-size: 13px;
    background: #7c3aed;
    color: #fff;
}

.trade-buttons .btn-confirm:hover {
    background: #6d28d9;
}

.trade-buttons .btn-confirm:disabled {
    background: #aaa;
    cursor: not-allowed;
}

.trade-buttons .btn-cancel {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
    background: #fff;
    color: #666;
}

.trade-buttons .btn-cancel:hover {
    background: #f5f5f5;
}

.trade-error {
    color: #c62828;
    font-size: 11px;
    margin-top: 8px;
    min-height: 14px;
}

/* ================================================================
   Goal Detail Styles (used by projection & allocation cards)
   ================================================================ */
.goal-detail-title {
    font-size: 13px; font-weight: 600; color: #1a1a2e;
    margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1px solid #eee;
}

.goal-alloc-summary {
    font-size: 11px; color: #555;
}
.goal-alloc-row {
    display: flex; justify-content: space-between;
    padding: 4px 0; border-bottom: 1px solid #f5f5f5;
}
.goal-alloc-row .label { color: #888; }
.goal-alloc-row .value { font-weight: 500; }

/* ================================================================
   Dashboard card adjustments (when in grid cards)
   ================================================================ */
.card-body .sidebar-dashboard {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.card-body .cf-section {
    margin-bottom: 8px;
    padding-top: 0;
    border-top: none;
}

.card-body .cf-section:first-child {
    border-top: none;
}

/* Compact factor styles for card */
.card-body .sidebar-section {
    margin-bottom: 8px;
}

.card-body .sidebar-transactions {
    margin-top: 8px;
    padding-top: 8px;
}

/* Goal overview in projection card */
.goal-overview-section { margin-top: 12px; }
.goal-overview-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}
.goal-overview-row:last-child { border-bottom: none; }
.goal-overview-gauge { width: 40px; height: 40px; flex-shrink: 0; }
.goal-overview-gauge svg { width: 40px; height: 40px; }
.goal-overview-info { flex: 1; min-width: 0; }
.goal-overview-name { font-size: 12px; font-weight: 600; color: #333; }
.goal-overview-target { font-size: 10px; color: #888; }
.goal-overview-pct { font-size: 16px; font-weight: 700; flex-shrink: 0; }

/* Goal-scoped portfolio subtitle */
.goal-portfolio-subtitle {
    font-size: 11px;
    color: #888;
    padding: 2px 0 8px;
    border-bottom: 1px solid #eee;
    margin-bottom: 8px;
}

/* Goal summary table in factors card */
.goal-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-top: 8px;
}
.goal-summary-table th {
    text-align: left;
    font-size: 9px;
    text-transform: uppercase;
    color: #888;
    padding: 4px 6px;
    border-bottom: 1px solid #eee;
}
.goal-summary-table td {
    padding: 6px;
    border-bottom: 1px solid #f5f5f5;
}
.goal-summary-name { font-weight: 600; color: #333; }
.goal-summary-type { font-size: 9px; text-transform: uppercase; color: #999; }

/* Goal journey charts */
.goal-journeys-section { margin-top: 8px; }
.goal-journey-mini { margin: 8px 0; }
.goal-journey-label { font-size: 11px; font-weight: 600; color: #555; margin-bottom: 4px; }
.goal-journey-wrap { height: 200px; }
.goal-journey-mini canvas { height: 120px !important; }
