/* Financial Copilot — styles translated from the "AI Financial Copilot" design. */

:root {
    --bg: #F6F7F9;
    --surface: #FFFFFF;
    --surface-sunken: #FAFBFC;
    --border: #E4E7EC;
    --border-soft: #EEF0F3;
    --input-border: #D0D5DD;
    --text: #101828;
    --text-2: #344054;
    --muted: #5D6675;
    --chip: #F2F4F7;
    --track: #EEF0F3;
    --bar-muted: #A9B4C2;

    --brand: #1A6B57;
    --brand-dark: #0F4D3E;
    --brand-tint: #E8F2EE;
    --brand-border: #B7D6CB;
    --brand-ring: #D3E8E0;

    --warn: #B54708;
    --warn-bg: #FEF3E8;
    --warn-border: #F5C9A0;
    --danger: #B42318;
    --danger-bg: #FEF3F2;
    --danger-border: #FDA29B;

    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.4;
    font-variant-numeric: tabular-nums;
}

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

h1, h2, h3, p { margin: 0; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* ---------- Shell ---------- */

.shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    overflow: hidden;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
    width: 44px; height: 32px; border-radius: 8px;
    object-fit: contain; background: var(--surface);
    display: flex; align-items: center; justify-content: center;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
    display: flex; align-items: center; gap: 12px;
    min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 500; font-size: 14px; text-decoration: none;
}
.nav-link:hover { background: var(--chip); color: var(--text-2); }
.nav-link.active { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.nav-link.disabled { color: #98A2B3; cursor: not-allowed; }
.nav-link.disabled:hover { background: transparent; color: #98A2B3; }
.nav-soon {
    margin-left: auto; font-size: 11px; font-weight: 600; padding: 2px 8px;
    border-radius: 999px; background: var(--chip); color: var(--muted);
}

.user-chip {
    margin-top: auto; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto;
    align-items: center; gap: 10px; min-width: 0;
    padding: 16px 8px 4px; border-top: 1px solid var(--border);
}
.avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--brand-tint);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; color: var(--brand);
}
.user-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.user-name { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.user-sub { font-size: 12px; color: var(--muted); }
.user-signout {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 32px; padding: 0 8px; border-radius: 6px;
    color: var(--muted); font-size: 12px; text-decoration: none; white-space: nowrap;
}
.user-signout:hover { background: var(--chip); color: var(--brand-dark); }
.currency-picker {
    display: flex; flex-direction: column; gap: 4px; padding: 10px 8px 0;
    border-top: 1px solid var(--border); color: var(--muted); font-size: 11px;
    font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
}
.currency-picker select {
    width: 100%; min-height: 32px; border: 1px solid var(--input-border);
    border-radius: 6px; background: var(--surface); color: var(--text-2);
    font: inherit; font-size: 12px; text-transform: none; letter-spacing: normal;
}

.auth-required {
    min-height: 60vh; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 12px; text-align: center;
}
.auth-required h1 { font-size: 28px; }
.auth-required p { color: var(--muted); }

.login-shell { min-height: 100vh; }

.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    padding: 32px; background: var(--bg);
}
.login-card {
    width: min(100%, 420px); padding: 40px; display: flex; flex-direction: column;
    align-items: center; gap: 16px; text-align: center; background: var(--surface);
    border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 12px 32px rgba(16, 24, 40, .08);
}
.login-mark { width: 96px; height: 96px; border-radius: 16px; }
.login-card h1 { font-size: 30px; letter-spacing: -0.02em; }
.login-card > p { color: var(--muted); }
.google-signin {
    width: 100%; min-height: 48px; display: inline-flex; align-items: center;
    justify-content: center; gap: 10px; padding: 0 16px; border: 1px solid var(--input-border);
    border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2);
    font-weight: 600; text-decoration: none;
}
.google-signin:hover { background: var(--surface-sunken); color: var(--text); }
.google-signin svg { width: 20px; height: 20px; }
.login-note { font-size: 12px; }

.main {
    min-height: 100vh;
    min-width: 0;
    margin-left: 240px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: calc(100% - 240px);
}

.page-header {
    display: flex; flex-wrap: wrap; align-items: center;
    justify-content: space-between; gap: 16px;
}
.page-title { display: flex; flex-direction: column; gap: 4px; }
.page-title h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.page-title h1:focus { outline: none; }
.page-title p { font-size: 14px; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* ---------- Buttons & inputs ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 44px; padding: 0 16px;
    border: 1px solid var(--input-border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text-2);
    font: inherit; font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-sunken); color: var(--text-2); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; padding: 0 18px; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

.btn-dark { background: var(--text); border-color: var(--text); color: #fff; font-weight: 600; }
.btn-dark:hover { background: #1D2939; border-color: #1D2939; color: #fff; }

.btn-tint { background: var(--surface); border-color: var(--brand-border); color: var(--brand); font-weight: 600; }
.btn-tint:hover { background: var(--brand-tint); color: var(--brand); }

.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn-danger-text { color: var(--danger); }
.btn-danger-text:hover { color: var(--danger); background: var(--danger-bg); }

select.btn {
    appearance: none;
    padding-right: 34px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23344054' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); font-weight: 500; }
.input, .select {
    min-height: 44px; width: 100%;
    border: 1px solid var(--input-border); border-radius: var(--radius-sm);
    padding: 0 10px; background: var(--surface); color: var(--text);
    font: inherit; font-size: 14px;
}
.select {
    appearance: none; padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235D6675' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.input:focus, .select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.input-strong { font-weight: 600; }
.input.invalid, .select.invalid { border-color: var(--danger); }
.field-error { font-size: 12px; color: var(--danger); font-weight: 500; }

/* ---------- Cards ---------- */

.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; display: flex; flex-direction: column; gap: 18px;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.card h2, .section-title { font-size: 16px; font-weight: 600; }
.card-link { font-size: 13px; font-weight: 500; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; display: flex; flex-direction: column; gap: 8px;
}
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat-value.income { color: var(--brand); }
.stat-note { font-size: 13px; color: var(--muted); }
.stat-note.warn { color: var(--warn); font-weight: 500; }
.stat-note.good { color: var(--brand); font-weight: 500; }

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

/* ---------- Quick entry & insight ---------- */

.quick {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 12px 12px 12px 16px;
}
.quick:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.quick input {
    flex: 1 1 320px; min-width: 0; min-height: 44px; border: none; outline: none;
    font: inherit; font-size: 15px; color: var(--text); background: transparent;
}

.insight {
    display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between;
    background: var(--brand-tint); border-radius: var(--radius); padding: 20px 24px;
}
.insight-body { display: flex; flex-direction: column; gap: 6px; flex: 1 1 420px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--brand); }
.insight p { font-size: 16px; line-height: 1.5; }
.insight-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------- Bars & charts ---------- */

.cat-row { display: flex; flex-direction: column; gap: 6px; }
.cat-line { display: flex; justify-content: space-between; font-size: 14px; gap: 12px; }
.cat-name { font-weight: 500; }
.cat-share { color: var(--muted); }
.bar { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar > span { display: block; height: 8px; border-radius: 4px; background: var(--brand); }

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.swatch.income { background: var(--brand); }
.swatch.expense { background: var(--bar-muted); }
.swatch.forecast { background: var(--brand-border); }

.flow { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; height: 200px; border-bottom: 1px solid var(--border); padding: 0 4px; }
.flow-col { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 4px; height: 100%; }
.flow-bar { width: 14px; border-radius: 3px 3px 0 0; min-height: 2px; }
.flow-bar.income { background: var(--brand); }
.flow-bar.expense { background: var(--bar-muted); }
.flow-labels { display: flex; justify-content: space-between; gap: 12px; padding: 0 4px; font-size: 12px; color: var(--muted); }
.flow-labels span { flex: 1; text-align: center; }

.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; min-width: 560px; border-collapse: collapse; font-size: 14px; }
table.data.wide { min-width: 720px; }
table.data th {
    text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase;
    letter-spacing: .05em; padding: 10px 8px; font-weight: 600;
}
table.data td { padding: 12px 8px; border-top: 1px solid var(--border-soft); }
table.data.roomy td { padding: 13px 8px; }
table.data .num { text-align: right; }
table.data td.muted { color: var(--muted); }
table.data td.desc { font-weight: 500; }
table.data td.amount { text-align: right; font-weight: 600; white-space: nowrap; }
table.data td.amount.income { color: var(--brand); }
table.data td.actions { text-align: right; white-space: nowrap; width: 1%; }

.chip {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    background: var(--chip); font-size: 12px; font-weight: 500; color: var(--text-2);
}
.chip.good { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.chip.warn { background: var(--warn-bg); color: var(--warn); font-weight: 600; }
.chip.neutral { background: var(--chip); color: var(--text-2); font-weight: 600; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pill {
    min-height: 40px; padding: 0 14px; border-radius: 999px; font: inherit; font-size: 13px; font-weight: 500;
    border: 1px solid var(--input-border); background: var(--surface); color: var(--text-2); cursor: pointer;
}
.pill[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: #fff; }
.search { min-height: 40px; width: 220px; padding: 0 12px; border: 1px solid var(--input-border); border-radius: var(--radius-sm); font: inherit; font-size: 14px; }
.search:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }

.list-foot {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px;
    padding-top: 12px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted);
}
.list-foot strong.income { color: var(--brand); }
.list-foot strong.expense { color: var(--text); }

.month-nav { display: flex; align-items: center; gap: 8px; }
.icon-btn {
    width: 36px; height: 36px; border: 1px solid var(--input-border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text-2); font: inherit; font-size: 16px; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface-sunken); }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Copilot entry ---------- */

.nl-row { display: flex; flex-wrap: wrap; gap: 12px; }
.nl-input {
    flex: 1 1 320px; min-width: 0; min-height: 48px; padding: 0 16px;
    border: 1px solid var(--input-border); border-radius: var(--radius-sm);
    font: inherit; font-size: 15px; color: var(--text);
}
.nl-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.nl-row .btn { min-height: 48px; padding: 0 20px; }

.draft {
    border: 1px solid var(--border); border-radius: 10px; background: var(--surface-sunken);
    padding: 20px; display: flex; flex-direction: column; gap: 16px;
}
.draft-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; }
.draft-title { font-size: 13px; font-weight: 600; color: var(--text-2); }
.draft-hint { font-size: 12px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.draft-foot { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.draft-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.warnings { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--warn); font-weight: 500; }
.parsed-by { font-size: 12px; color: var(--muted); }

.notice {
    border-radius: var(--radius-sm); padding: 12px 16px; font-size: 14px; font-weight: 500;
    display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px;
}
.notice.success { background: var(--brand-tint); color: var(--brand-dark); }
.notice.error { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger); }
.notice .btn { min-height: 36px; }

/* ---------- Budgets ---------- */

.total-budget { gap: 16px; }
.total-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; align-items: flex-end; }
.total-label { font-size: 14px; font-weight: 500; color: var(--muted); }
.total-value { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.total-value small { font-size: 18px; font-weight: 500; color: var(--muted); }
.mini-stats { display: flex; gap: 24px; flex-wrap: wrap; font-size: 13px; }
.mini-stat { display: flex; flex-direction: column; gap: 2px; }
.mini-stat span { color: var(--muted); }
.mini-stat strong { font-size: 16px; }
.mini-stat strong.good { color: var(--brand); }

.meter { position: relative; height: 12px; border-radius: 6px; background: var(--track); overflow: hidden; }
.meter .spent { position: absolute; left: 0; top: 0; height: 12px; border-radius: 6px; background: var(--brand); }
.meter .forecast {
    position: absolute; top: 0; height: 12px;
    background: repeating-linear-gradient(135deg, var(--brand-border) 0 4px, var(--track) 4px 8px);
}

.budget-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.budget-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; display: flex; flex-direction: column; gap: 12px;
}
.budget-card.warn { border-color: var(--warn-border); }
.budget-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.budget-name { font-size: 15px; font-weight: 600; }
.budget-amount { font-size: 14px; }
.budget-amount strong { font-size: 18px; }
.budget-amount span { color: var(--muted); }
.gauge { position: relative; height: 8px; border-radius: 4px; background: var(--track); }
.gauge .fill { position: absolute; left: 0; top: 0; height: 8px; border-radius: 4px; background: var(--brand); }
.budget-card.warn .gauge .fill { background: var(--warn); }
.gauge .tick { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--text); }
.budget-note { font-size: 13px; color: var(--muted); }
.budget-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.inline-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline-edit .input { width: 140px; min-height: 36px; }
.small-note { font-size: 12px; color: var(--muted); }

/* ---------- Misc ---------- */

.loading { color: var(--muted); padding: 24px 0; }

#blazor-error-ui {
    color-scheme: light only;
    background: #FEF3C7;
    color: #101828;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

@media (max-width: 820px) {
    .main { padding: 20px 16px; margin-inline: 0; width: 100%; }
    .sidebar {
        flex-basis: 100%;
        padding: 16px; gap: 16px; border-right: none; border-bottom: 1px solid var(--border); }
    .nav { flex-direction: row; flex-wrap: wrap; }
    .nav-link { min-height: 40px; }
    .user-chip { display: none; }
    .page-title h1 { font-size: 24px; }
    .form-grid .span-2 { grid-column: auto; }
}

@media (prefers-reduced-motion: no-preference) {
    .btn, .pill, .nav-link, .icon-btn { transition: background-color .12s, border-color .12s; }
}

/* ---------- Copilot chat ---------- */

.copilot-grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.convo { flex: 999 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }

.welcome { gap: 8px; }
.welcome p { color: var(--muted); font-size: 15px; line-height: 1.5; }

.messages { display: flex; flex-direction: column; gap: 20px; }

.bubble-user {
    align-self: flex-end; max-width: 80%;
    background: var(--text); color: #fff; border-radius: 16px 16px 4px 16px;
    padding: 14px 18px; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere;
}
.bubble-bot {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px 16px 16px 4px;
    padding: 22px; display: flex; flex-direction: column; gap: 16px; max-width: 92%;
}
.bubble-bot.thinking { flex-direction: row; align-items: center; gap: 12px; color: var(--muted); padding: 16px 22px; align-self: flex-start; }
.bubble-foot { padding-top: 4px; border-top: 1px solid var(--border-soft); }
.bubble-foot .small-note { display: block; padding-top: 10px; }
.bubble-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bubble-actions .btn { min-height: 40px; font-size: 13px; }
.bubble-actions .btn[aria-pressed="true"] { background: var(--chip); }

.dots { display: inline-flex; gap: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--brand); opacity: .35; }
@media (prefers-reduced-motion: no-preference) {
    .dots i { animation: pulse 1.2s infinite ease-in-out; }
    .dots i:nth-child(2) { animation-delay: .15s; }
    .dots i:nth-child(3) { animation-delay: .3s; }
    @keyframes pulse { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
}

/* Model output, rendered from markdown */
.markdown { font-size: 15px; line-height: 1.6; overflow-wrap: anywhere; overflow-x: auto; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p { margin: 0 0 12px; }
.markdown ul, .markdown ol { margin: 0 0 12px; padding-left: 22px; }
.markdown li { margin: 2px 0; }
.markdown strong { font-weight: 600; }
.markdown code { font-family: ui-monospace, "JetBrains Mono", monospace; font-size: 13px; background: var(--chip); padding: 1px 5px; border-radius: 4px; }
.markdown table { width: 100%; min-width: 360px; border-collapse: collapse; font-size: 14px; margin: 0 0 12px; }
.markdown th {
    text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase;
    letter-spacing: .05em; padding: 8px; font-weight: 600; white-space: nowrap; text-align: left;
}
.markdown td { padding: 10px 8px; border-top: 1px solid var(--border-soft); }

.composer { position: sticky; bottom: 0; display: flex; flex-direction: column; gap: 12px; padding: 12px 0 16px; background: linear-gradient(to bottom, rgba(246, 247, 249, 0), var(--bg) 14px); }
.suggestions .pill { font-weight: 400; }
.ask {
    display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
    background: var(--surface); border: 1px solid var(--input-border); border-radius: var(--radius);
    padding: 10px 10px 10px 16px;
}
.ask:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.ask input { flex: 1 1 280px; min-width: 0; min-height: 44px; border: none; outline: none; font: inherit; font-size: 15px; background: transparent; color: var(--text); }
.ask .icon-btn { width: 44px; height: 44px; }

/* Trace panel */
.trace { flex: 1 1 300px; min-width: 0; padding: 20px; gap: 16px; position: sticky; top: 24px; }
.trace-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.trace-head h2 { font-size: 15px; }
.trace-head .btn { white-space: nowrap; flex-shrink: 0; }
.agent-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg); border-radius: var(--radius-sm); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.agent-name { font-size: 13px; font-weight: 600; }
.agent-meta { font-size: 12px; color: var(--muted); margin-left: auto; }
.steps { display: flex; flex-direction: column; gap: 10px; padding-left: 14px; border-left: 2px solid var(--border); margin-left: 4px; }
.step { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
.step.failed { border-color: var(--danger-border); background: var(--danger-bg); }
.step-top { display: flex; justify-content: space-between; gap: 8px; }
.step-agent { font-size: 13px; font-weight: 600; }
.step-ms { font-size: 12px; color: var(--muted); }
.step code { font-family: ui-monospace, "JetBrains Mono", monospace; font-size: 12px; color: var(--brand); background: #F2F7F5; padding: 4px 6px; border-radius: 4px; overflow-wrap: anywhere; }
.step-result { font-size: 12px; color: var(--muted); line-height: 1.45; }
.sources { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.eyebrow-muted { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.source-line { font-size: 13px; color: var(--text-2); }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.metrics div { display: flex; flex-direction: column; gap: 2px; }
.metrics span { font-size: 11px; color: var(--muted); }
.metrics strong { font-size: 14px; font-weight: 600; }

@media (max-width: 820px) {
    .sidebar {
        position: static;
        width: 100%;
        height: auto;
        min-height: auto;
    }
    .main {
        min-height: auto;
        margin-left: 0;
    }
    .trace { position: static; }
    .bubble-bot { max-width: 100%; }
}

/* ---------- Trace: hand-offs ---------- */

.handoffs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.handoffs li {
    display: flex; justify-content: space-between; gap: 8px; align-items: center;
    padding: 8px 12px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500;
}
.handoffs li.failed { border-color: var(--danger-border); background: var(--danger-bg); }

/* ---------- Goals ---------- */

.goals { display: flex; flex-direction: column; gap: 16px; }
.goal-form { gap: 16px; }
.goals-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.goal-list { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.goal-card { gap: 16px; }
.goal-name { font-size: 16px; font-weight: 600; }
.goal-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.goal-value small { font-size: 16px; font-weight: 500; color: var(--muted); }
.goal-bar { height: 10px; border-radius: 5px; background: var(--track); }
.goal-bar span { display: block; height: 10px; border-radius: 5px; background: var(--brand); }
.goal-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; font-size: 13px; }
.goal-stats div { display: flex; flex-direction: column; gap: 2px; }
.goal-stats span { color: var(--muted); }
.goal-stats strong { font-size: 16px; }
.goal-stats strong.late { color: var(--warn); }
.goal-stats strong.good { color: var(--brand); }

.advisor { background: var(--brand-tint); border: none; gap: 14px; }
.advisor .markdown { font-size: 15px; }
.advisor .markdown ol, .advisor .markdown ul { margin-bottom: 0; }
.advisor-hint { font-size: 15px; line-height: 1.5; margin: 0; }
.thinking-row { display: flex; align-items: center; gap: 12px; color: var(--muted); }

@media (max-width: 820px) {
    .goal-stats { grid-template-columns: 1fr; }
}
