/* ── Worldesk FX Multi-Agent Advisors ── */

:root {
    /* Brand Core — derived from Worldesk logo */
    --brand-blue: #0A8AF2;
    --brand-dark: #1E2A3A;
    --brand-primary: #1B3A6B;
    --brand-primary-light: #234B8A;
    --brand-primary-dim: rgba(27, 58, 107, 0.07);
    --brand-accent: #00997A;
    --brand-accent-light: #00B67A;
    --brand-accent-dim: rgba(0, 153, 122, 0.08);

    /* Surfaces */
    --bg-page: #F5F7FA;
    --bg-white: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-card: #F0F3F7;

    /* Borders */
    --border: rgba(27, 58, 107, 0.1);
    --border-hover: rgba(27, 58, 107, 0.18);

    /* Text */
    --text-primary: #0F1F3D;
    --text-secondary: #3D5170;
    --text-muted: #8A9BBD;
    --text-on-brand: #FFFFFF;

    /* Utility */
    --danger: #D93025;
    --danger-dim: rgba(217, 48, 37, 0.06);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 31, 61, 0.04);
    --shadow-sm: 0 1px 3px rgba(15, 31, 61, 0.06), 0 1px 2px rgba(15, 31, 61, 0.04);
    --shadow-input: 0 1px 4px rgba(15, 31, 61, 0.06);
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ── Layout ── */
.app {
    display: grid;
    grid-template-columns: 280px 1fr;
    grid-template-rows: auto 1fr;
    height: 100vh;
}

/* ── Header — White with brand accent bar ── */
.header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: 64px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    position: relative;
}

.header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--brand-blue), var(--brand-accent-light), var(--brand-blue));
    pointer-events: none;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    height: 37px;
    width: auto;
    display: block;
}

.header-divider {
    width: 1px;
    height: 28px;
    background: var(--border);
}

.header-product {
    display: flex;
    flex-direction: column;
}

.header-product-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--brand-primary);
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.header-product-name span {
    color: var(--brand-blue);
}

.header-product-sub {
    font-size: 12px;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
    margin-top: 2px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 100px;
    background: var(--brand-accent-dim);
    border: 1px solid rgba(0, 153, 122, 0.15);
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-accent);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand-accent);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* ── Sidebar ── */
.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.session-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-xs);
}

.session-id {
    font-size: 11px;
    font-family: 'Plus Jakarta Sans', monospace;
    color: var(--text-secondary);
    background: rgba(27, 58, 107, 0.04);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    word-break: break-all;
    line-height: 1.4;
}

.session-note {
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-accent);
    display: flex;
    align-items: center;
    gap: 6px;
}

.session-note svg { flex-shrink: 0; }

/* Quick Examples */
.quick-examples {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.example-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-family: inherit;
}

.example-btn:hover {
    background: var(--brand-primary-dim);
    border-color: var(--border-hover);
    color: var(--brand-primary);
    transform: translateX(4px);
}

.example-btn .icon {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    background: var(--brand-primary-dim);
}

/* Utilities */
.utility-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    width: 100%;
    text-align: left;
}

.utility-btn:hover {
    color: var(--danger);
    border-color: rgba(217, 48, 37, 0.15);
    background: var(--danger-dim);
}

/* Advisors */
.advisors-section {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.advisors-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
    color: var(--brand-primary);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 8px;
}

.advisors-badge .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand-accent);
}

.advisors-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 10px;
}

.advisors-toggle {
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-blue);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    font-family: inherit;
    padding: 0;
}

.advisors-toggle:hover { text-decoration: underline; }

.advisors-list {
    display: none;
    margin-top: 10px;
    padding: 0;
    list-style: none;
}

.advisors-list.open {
    display: block;
}

.advisors-list li {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.6;
    padding: 2px 0;
}

.advisors-list li strong {
    color: var(--brand-primary);
}

.advisors-note {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    line-height: 1.5;
}

/* ── Main Chat Area ── */
.main {
    display: flex;
    flex-direction: column;
    background: var(--bg-page);
    position: relative;
    overflow: hidden;
}

.chat-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 40px 48px;
    display: flex;
    flex-direction: column;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Welcome screen (shown when no messages) */
.welcome {
    text-align: center;
    max-width: 640px;
    margin: auto;
    animation: fadeUp 0.6s ease-out;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-logo {
    height: 46px;
    width: auto;
    margin: 0 auto 24px;
    display: block;
}

.welcome h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--brand-primary);
    letter-spacing: -0.3px;
}

.welcome h2 span {
    color: var(--brand-blue);
}

.welcome p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0;
}

.welcome-powered {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 4px;
}

/* Welcome input (hero-area input) */
.welcome-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px 6px 6px 20px;
    margin-top: 28px;
    transition: all 0.25s ease;
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.welcome-input-wrapper:focus-within {
    border-color: var(--brand-blue);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06), 0 0 0 3px rgba(10, 138, 242, 0.08);
}

.welcome-input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    padding: 12px 0;
    font-weight: 500;
}

.welcome-input-wrapper input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

/* Example cards */
.welcome-examples {
    margin-top: 32px;
}

.welcome-examples-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.welcome-examples-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.welcome-example-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--bg-white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.45;
}

.welcome-example-card:hover {
    border-color: var(--brand-blue);
    background: #f0f7ff;
    box-shadow: 0 2px 8px rgba(10, 138, 242, 0.1);
    transform: translateY(-1px);
}

.welcome-example-card:active {
    transform: translateY(0);
}

.wec-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.wec-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.45;
}

/* ── Messages ── */
.message {
    margin-bottom: 2rem;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    text-align: right;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--brand-blue), #0670CC);
    color: var(--text-on-brand);
    display: inline-block;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    max-width: 70%;
    text-align: left;
    box-shadow: 0 2px 8px rgba(10, 138, 242, 0.2);
}

.message.assistant .message-content {
    background: var(--bg-white);
    border: 1px solid var(--border);
    padding: 1.5rem;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.message.assistant .message-content h4 {
    color: var(--brand-blue);
}

.message.assistant .message-content a {
    color: var(--brand-blue);
    text-decoration: none;
}

.message.assistant .message-content a:hover {
    text-decoration: underline;
}

.market-context {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
}

.market-context h4 {
    margin-bottom: 1rem;
    color: var(--brand-blue);
}

.market-context ul {
    margin: 2px 0 4px 1.25rem;
    padding: 0;
}

.market-context li {
    margin: 0 0 2px 0;
    padding: 0;
    line-height: 1.4;
}

/* Currency pair sub-headings (e.g. USD/PHP:, PHP/USD:) — space above to separate sections */
.market-context > p + ul + p {
    margin-top: 12px;
}

.chart-container {
    background: var(--bg-white);
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    height: 300px;
    width: 100%;
    border: 1px solid var(--border);
}

.message-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    overflow: hidden;
}

.message-text pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-x: auto;
    max-width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}

/* ── Brief text (non-table content from brief responses) ── */
.brief-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

/* ── Brief tables (converted from ASCII) ── */
.brief-table-wrap {
    overflow-x: auto;
    margin: 1rem 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.brief-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    line-height: 1.5;
}

.brief-table th,
.brief-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.brief-table th {
    background: var(--brand-primary-dim);
    font-weight: 700;
    color: var(--brand-primary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.brief-table tbody tr:last-child td {
    border-bottom: none;
}

.brief-table tbody tr:hover {
    background: rgba(27, 58, 107, 0.03);
}

.brief-table td:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .brief-table-wrap {
        margin: 0.75rem -0.5rem;
        border-radius: var(--radius-sm);
    }

    .brief-table {
        font-size: 12px;
    }

    .brief-table th,
    .brief-table td {
        padding: 8px 10px;
    }
}

/* ══════════════════════════════════════════
   STRUCTURED SECTION CARDS
   ══════════════════════════════════════════ */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
}

.section-card:last-child {
    margin-bottom: 0;
}

.section-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--brand-primary);
    margin: 0;
}

.section-card h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--brand-blue);
    margin: 0 0 1rem 0;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.section-title-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, rgba(10, 138, 242, 0.06), rgba(0, 153, 122, 0.04));
    border-color: rgba(10, 138, 242, 0.15);
}

.section-icon {
    font-size: 24px;
    line-height: 1;
}

.section-icon-sm {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

/* ── Key-Value Grid ── */
.kv-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kv-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 8px 12px;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    gap: 16px;
}

.kv-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.kv-value {
    font-size: 13px;
    color: var(--text-primary);
    text-align: right;
    word-break: break-word;
}

/* ── Analysis Text ── */
.analysis-text {
    font-size: 15px;
    line-height: 1.4;
    color: var(--text-primary);
}

.analysis-text p {
    margin: 0 0 4px 0;
}

.analysis-text p:last-child {
    margin-bottom: 0;
}

/* Section titles: bold-only lines like "Key Drivers:" — space above, tight below */
.analysis-text .analysis-section-title {
    margin: 12px 0 2px 0;
    font-size: 15px;
}

/* First section title needs no top gap */
.analysis-text .analysis-section-title:first-child,
.analysis-text > .analysis-section-title:first-child {
    margin-top: 0;
}

.analysis-text ul,
.analysis-text ol {
    margin: 2px 0 4px 1.25rem;
    padding: 0;
}

.analysis-text li {
    margin: 0 0 2px 0;
    padding: 0;
}

.analysis-text li p {
    margin: 0;
}

.analysis-text h1, .analysis-text h2, .analysis-text h3, .analysis-text h4, .analysis-text h5 {
    color: var(--brand-primary);
    margin: 12px 0 2px;
    font-size: 15px;
    font-weight: 700;
}

.analysis-text h1:first-child, .analysis-text h2:first-child, .analysis-text h3:first-child,
.analysis-text h4:first-child, .analysis-text h5:first-child {
    margin-top: 0;
}

.analysis-text hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 8px 0;
}

.analysis-text strong {
    color: var(--brand-primary);
}

.section-note {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.table-note {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 8px;
    padding: 0 4px;
    line-height: 1.5;
}

/* ── Sleep-at-Night Meter ── */
.sleep-meter-card {
    background: linear-gradient(135deg, rgba(10, 138, 242, 0.04), rgba(0, 153, 122, 0.04));
}

.sleep-visual {
    font-size: 20px;
    letter-spacing: 2px;
    padding: 12px 16px;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    text-align: center;
    margin-bottom: 12px;
    overflow-x: auto;
}

.sleep-rec {
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-primary);
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 12px;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ── Urgency Badge ── */
.urgency-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(217, 48, 37, 0.08);
    color: var(--danger);
    border: 1px solid rgba(217, 48, 37, 0.15);
}

/* ── Danger Windows ── */
.danger-windows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.danger-window-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    border: 1px solid var(--border);
}

.danger-window-item.risk-low {
    border-left: 3px solid #22C55E;
}
.danger-window-item.risk-moderate, .danger-window-item.risk-medium {
    border-left: 3px solid #F59E0B;
}
.danger-window-item.risk-high {
    border-left: 3px solid var(--danger);
}
.danger-window-item.risk-very-high {
    border-left: 3px solid #991B1B;
}

.dw-indicator {
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    padding-top: 2px;
}

.dw-details {
    flex: 1;
    min-width: 0;
}

.dw-period {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.dw-risk-label {
    font-size: 11px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 100px;
    background: rgba(27, 58, 107, 0.06);
    color: var(--text-secondary);
}

.dw-desc {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ── Cost Breakdown ── */
.cost-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.cost-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
}

.cost-line:last-child {
    border-bottom: none;
}

.cost-line.cost-base {
    background: var(--bg-white);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-weight: 700;
}

.cost-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.cost-amount {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.cost-amount.green {
    color: #16A34A;
}

.cost-amount.red {
    color: var(--danger);
}

/* ── Case Bars (Worst/Best) ── */
.case-bars {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.case-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.case-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.case-dot.case-best { background: #22C55E; }
.case-dot.case-current { background: #F59E0B; }
.case-dot.case-worst { background: var(--danger); }

.case-label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 140px;
    flex-shrink: 0;
}

.case-track {
    flex: 1;
    height: 10px;
    background: rgba(27, 58, 107, 0.06);
    border-radius: 5px;
    overflow: hidden;
}

.case-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 0.6s ease;
}

.case-fill.case-best { background: linear-gradient(90deg, #22C55E, #4ADE80); }
.case-fill.case-current { background: linear-gradient(90deg, #F59E0B, #FBBF24); }
.case-fill.case-worst { background: linear-gradient(90deg, var(--danger), #EF4444); }

/* ── Timeline Risks ── */
.timeline-risks {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-risk-item {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
}

.timeline-risk-item.risk-low { border-left-color: #22C55E; }
.timeline-risk-item.risk-moderate, .timeline-risk-item.risk-medium { border-left-color: #F59E0B; }
.timeline-risk-item.risk-high { border-left-color: var(--danger); }

.tr-period {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
}

.tr-level {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.tr-detail {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ══════════════════════════════════════════
   OPTION CARDS (A, B, C)
   ══════════════════════════════════════════ */
.options-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 4px;
}

.option-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    transition: box-shadow 0.2s ease;
}

.option-card:hover {
    box-shadow: 0 2px 12px rgba(15, 31, 61, 0.06);
}

.option-card.recommended {
    border-color: rgba(10, 138, 242, 0.3);
    box-shadow: 0 0 0 1px rgba(10, 138, 242, 0.08);
}

.option-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.option-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    background: var(--brand-primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.option-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.rec-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 700;
    background: rgba(10, 138, 242, 0.08);
    color: var(--brand-blue);
    border: 1px solid rgba(10, 138, 242, 0.15);
}

.traffic-light {
    font-size: 16px;
}

.option-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0 0 10px;
}

.option-amount {
    font-size: 13px;
    color: var(--text-primary);
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

/* ── Risk Profile Bars ── */
.risk-profile {
    margin: 12px 0;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.risk-profile-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.risk-bar-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.risk-bar-row:last-child {
    margin-bottom: 0;
}

.risk-bar-label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 110px;
    flex-shrink: 0;
}

.risk-bar-track {
    flex: 1;
    height: 8px;
    background: rgba(27, 58, 107, 0.06);
    border-radius: 4px;
    overflow: hidden;
}

.risk-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--brand-blue), #0670CC);
    transition: width 0.6s ease;
}

.risk-bar-val {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 32px;
    text-align: right;
}

/* ── Pros / Cons ── */
.option-pros, .option-cons {
    margin: 8px 0;
}

.pros-title, .cons-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.pro-item, .con-item {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.6;
    padding: 2px 0;
}

/* ── Outcomes ── */
.option-outcome, .option-bestfor {
    font-size: 13px;
    color: var(--text-primary);
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-top: 8px;
    line-height: 1.5;
}

.option-outcomes {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.outcome-row {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.6;
}

.outcome-label {
    font-weight: 600;
    color: var(--text-secondary);
}

/* ── Cost Mini (scenarios) ── */
.cost-mini {
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.cost-mini-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 3px 0;
}

.cost-mini-row span:last-child {
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Outcomes Mini ── */
.outcomes-mini {
    padding: 10px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.outcomes-mini-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.outcomes-mini .outcome-row {
    font-size: 12px;
    padding: 2px 0;
}

.outcomes-mini .outcome-row.worst span:first-child {
    color: var(--danger);
}

.outcomes-mini .outcome-row.best span:first-child {
    color: #16A34A;
}

/* ── Decision Matrix ── */
.decision-matrix {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dm-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.dm-icon {
    font-size: 18px;
    flex-shrink: 0;
    padding-top: 2px;
}

.dm-content {
    flex: 1;
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

.dm-reason {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Board Language ── */
.board-language {
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
    padding: 10px 14px;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-top: 10px;
    line-height: 1.5;
}

/* ── Implementation Steps (Legs) ── */
.legs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.leg-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-white);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.leg-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.leg-details {
    flex: 1;
}

.leg-main {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.leg-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

.leg-notes {
    font-size: 12px;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 2px;
}

/* ── Footer Section ── */
.section-footer {
    background: linear-gradient(135deg, rgba(27, 58, 107, 0.04), rgba(10, 138, 242, 0.03));
    border-color: rgba(27, 58, 107, 0.12);
}

.footer-grid {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.footer-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 120px;
}

.footer-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.next-steps, .evidence, .explain {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 10px;
    line-height: 1.6;
}

.next-steps ol, .evidence ul, .explain ul {
    margin: 4px 0 0 1.25rem;
}

/* ── Table color helpers ── */
.brief-table td.green { color: #16A34A; font-weight: 600; }
.brief-table td.red { color: var(--danger); font-weight: 600; }

/* ── Legacy brief ── */
.legacy-brief {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}

.legacy-brief p { margin-bottom: 0.5rem; }
.legacy-brief ul, .legacy-brief ol { margin: 0.5rem 0 0.5rem 1.25rem; }

/* ── Error message ── */
.error-msg {
    color: var(--danger);
    font-weight: 600;
}

/* ── Responsive for structured sections ── */
@media (max-width: 768px) {
    .section-card {
        padding: 1rem;
    }

    .kv-row {
        flex-direction: column;
        gap: 2px;
    }

    .kv-value {
        text-align: left;
    }

    .case-label {
        min-width: 100px;
        font-size: 11px;
    }

    .risk-bar-label {
        min-width: 80px;
        font-size: 11px;
    }

    .footer-grid {
        flex-direction: column;
        gap: 12px;
    }

    .option-card {
        padding: 1rem;
    }

    .sleep-visual {
        font-size: 16px;
        letter-spacing: 1px;
    }

    .dw-period {
        font-size: 12px;
    }

    .danger-window-item {
        gap: 8px;
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .section-card {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .section-card h4 {
        font-size: 13px;
    }

    .option-letter {
        font-size: 10px;
        padding: 2px 8px;
    }

    .risk-bar-label {
        min-width: 70px;
    }

    .case-label {
        min-width: 80px;
    }
}

/* ══════════════════════════════════════════
   FEEDBACK WIDGET
   ══════════════════════════════════════════ */
.feedback-widget {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.feedback-prompt {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.feedback-row {
    display: flex;
    gap: 6px;
}

.feedback-emoji {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border);
    background: var(--bg-page);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.feedback-emoji:hover {
    border-color: var(--brand-blue);
    background: rgba(10, 138, 242, 0.04);
    transform: translateY(-2px);
}

.feedback-emoji.selected {
    border-color: var(--brand-blue);
    background: rgba(10, 138, 242, 0.08);
    box-shadow: 0 0 0 2px rgba(10, 138, 242, 0.12);
}

.emoji-icon {
    font-size: 22px;
    line-height: 1;
}

.emoji-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.2px;
}

.feedback-emoji.selected .emoji-label {
    color: var(--brand-blue);
}

/* Expanded area (text + submit) */
.feedback-expanded {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
    margin-top: 0;
}

.feedback-expanded.open {
    max-height: 200px;
    opacity: 1;
    margin-top: 10px;
}

.feedback-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-page);
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary);
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease;
}

.feedback-textarea:focus {
    border-color: var(--brand-blue);
}

.feedback-textarea::placeholder {
    color: var(--text-muted);
}

.feedback-submit {
    margin-top: 8px;
    padding: 8px 20px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--brand-blue);
    color: white;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.feedback-submit:hover {
    background: #0670CC;
    box-shadow: 0 2px 8px rgba(10, 138, 242, 0.25);
}

.feedback-submit:disabled {
    background: var(--bg-card);
    color: var(--text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* Thank you message */
.feedback-thanks {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-accent);
    padding: 8px 0;
}

.thanks-emoji {
    font-size: 18px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .feedback-row {
        gap: 4px;
    }

    .feedback-emoji {
        padding: 6px 8px;
    }

    .emoji-icon {
        font-size: 20px;
    }

    .emoji-label {
        font-size: 9px;
    }
}

@media (max-width: 480px) {
    .feedback-emoji {
        padding: 5px 6px;
        flex: 1;
    }

    .emoji-icon {
        font-size: 18px;
    }

    .emoji-label {
        display: none;
    }
}

/* ══════════════════════════════════════════
   SUGGESTION CHIPS — Follow-up actions
   ══════════════════════════════════════════ */
.suggestion-chips {
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s;
}

.suggestion-chips-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    letter-spacing: 0.2px;
}

.suggestion-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggestion-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border-radius: 100px;
    border: 1.5px solid rgba(10, 138, 242, 0.25);
    background: var(--bg-white);
    color: var(--brand-blue);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.4;
    max-width: 100%;
    text-align: left;
}

.suggestion-chip:hover {
    background: rgba(10, 138, 242, 0.06);
    border-color: var(--brand-blue);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(10, 138, 242, 0.12);
}

.suggestion-chip:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .suggestion-chips-row {
        gap: 6px;
    }

    .suggestion-chip {
        padding: 7px 14px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .suggestion-chip {
        padding: 6px 12px;
        font-size: 11px;
    }
}

/* ── Input Area ── */
.input-area {
    padding: 20px 48px 28px;
    background: var(--bg-white);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-page);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 6px 6px 6px 20px;
    transition: all 0.25s ease;
    box-shadow: var(--shadow-input);
}

.input-wrapper:focus-within {
    border-color: var(--brand-blue);
    box-shadow: var(--shadow-input), 0 0 0 3px rgba(10, 138, 242, 0.08);
    background: var(--bg-white);
}

.input-wrapper input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    padding: 10px 0;
    font-weight: 500;
}

.input-wrapper input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--brand-blue), #0670CC);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(10, 138, 242, 0.3);
}

.send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(10, 138, 242, 0.35);
}

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

.send-btn:disabled {
    background: var(--bg-card);
    cursor: not-allowed;
    box-shadow: none;
    color: var(--text-muted);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding: 0 4px;
}

.input-footer span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.input-footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    transition: color 0.15s;
}

.input-footer a:hover {
    color: var(--brand-blue);
    text-decoration: underline;
}

.powered-by {
    display: flex;
    align-items: center;
    gap: 6px;
}

.powered-by .wb-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--brand-primary-dim);
    font-size: 10px;
    font-weight: 700;
    color: var(--brand-primary);
    letter-spacing: 0.3px;
}

/* ── Loading Indicator ── */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 12px;
    padding: 0 4px;
    color: var(--text-muted);
    font-size: 13px;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid var(--border);
    border-top-color: var(--brand-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(27, 58, 107, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(27, 58, 107, 0.18); }

/* ===================================
   RESPONSIVE DESIGN
   =================================== */

/* Tablet and smaller (< 1024px) */
@media (max-width: 1024px) {
    .app {
        grid-template-columns: 240px 1fr;
    }

    .sidebar {
        padding: 20px 16px;
    }

    .chat-area {
        padding: 32px 32px;
    }

    .input-area {
        padding: 16px 32px 24px;
    }
}

/* ── Mobile sidebar toggle button (hidden on desktop) ── */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-page);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: var(--brand-primary-dim);
    color: var(--brand-primary);
}

/* ── Mobile overlay ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 31, 61, 0.3);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile devices (< 768px) */
@media (max-width: 768px) {
    body {
        height: 100vh;
        height: 100dvh;
    }

    .app {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: 100vh;
        height: 100dvh;
    }

    .header {
        padding: 0 16px;
        height: 56px;
        z-index: 10;
    }

    .header-product-sub {
        display: none;
    }

    .header-product-name {
        font-size: 16px;
    }

    .mobile-menu-btn {
        display: flex;
    }

    /* Sidebar as slide-out drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 300px;
        max-width: 85vw;
        height: 100%;
        z-index: 100;
        border-right: 1px solid var(--border);
        border-bottom: none;
        padding: 24px 20px;
        gap: 20px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(15, 31, 61, 0.12);
    }

    .sidebar-overlay {
        display: block;
    }

    .advisors-section {
        margin-top: 0;
    }

    /* Main area takes remaining height */
    .main {
        grid-row: 2;
        height: calc(100vh - 56px);
        height: calc(100dvh - 56px);
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .chat-area {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 20px 16px;
    }

    .input-area {
        flex-shrink: 0;
        padding: 12px 16px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .input-wrapper {
        padding: 4px 4px 4px 16px;
    }

    .input-wrapper input {
        font-size: 16px; /* prevents iOS zoom on focus */
    }

    /* Message bubbles */
    .message.user .message-content {
        max-width: 90%;
        padding: 0.75rem 1rem;
    }

    .message.assistant .message-content {
        max-width: 100%;
        padding: 1rem;
    }

    /* Chart adjustments */
    .chart-container {
        height: 250px;
    }

    .welcome {
        padding: 0 8px;
    }

    .welcome h2 {
        font-size: 22px;
    }

    .welcome p {
        font-size: 13px;
    }

    .welcome-examples-grid {
        grid-template-columns: 1fr;
    }

    .welcome-input-wrapper input {
        font-size: 16px; /* prevents iOS zoom */
    }

    .input-footer {
        justify-content: center;
    }

    /* Status pill compact */
    .status-pill {
        font-size: 11px;
        padding: 4px 10px;
    }
}

/* Small mobile devices (< 480px) */
@media (max-width: 480px) {
    .header {
        padding: 0 12px;
        height: 50px;
    }

    .header-logo {
        height: 25px;
    }

    .header-product-name {
        font-size: 14px;
    }

    .header-divider {
        height: 22px;
    }

    .mobile-menu-btn {
        width: 36px;
        height: 36px;
    }

    .sidebar {
        width: 280px;
        padding: 20px 16px;
    }

    .example-btn {
        padding: 8px 12px;
        font-size: 12px;
    }

    .example-btn .icon {
        width: 26px;
        height: 26px;
        font-size: 12px;
    }

    .chat-area {
        padding: 16px 12px;
    }

    .input-area {
        padding: 10px 12px 16px;
    }

    .input-wrapper {
        padding: 4px 4px 4px 14px;
    }

    .input-wrapper input {
        font-size: 13px;
    }

    .send-btn {
        width: 38px;
        height: 38px;
    }

    .message.user .message-content {
        padding: 0.6rem 0.85rem;
        font-size: 0.9rem;
    }

    .message.assistant .message-content {
        padding: 0.75rem;
        font-size: 0.9rem;
    }

    .chart-container {
        height: 200px;
    }

    .welcome h2 {
        font-size: 20px;
    }

    .welcome p {
        font-size: 12px;
    }

    .welcome-examples-grid {
        grid-template-columns: 1fr;
    }

    .welcome-example-card {
        padding: 12px 14px;
    }

    .wec-text {
        font-size: 12px;
    }
}

/* Landscape mode on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .sidebar {
        width: 280px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .example-btn,
    .utility-btn,
    .send-btn,
    .mobile-menu-btn {
        min-height: 44px;
    }

    .advisors-toggle {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}
