/* ChatGPT-inspired palette: neutral charcoal dark mode, white/gray light
   mode, steel-blue accent, gray user bubbles. */
:root {
    color-scheme: dark;
    --primary: #2b658b;
    --primary-hover: #3a7ba6;
    --bg: #171717;
    --bg-glow: #262626;
    --surface: #212121;
    --surface-2: #2f2f2f;
    --surface-3: #3d3d3d;
    --border: #414141;
    --text: #ececec;
    --text-muted: #b4b4b4;
    --bot-bubble: #2f2f2f;
    --user-bubble: #2f2f2f;
    --user-bubble-text: #ececec;
    --danger: #ef4444;
    --online: #22c55e;
    --neg: #f87171;
    --link: #7ab7ff;
    --code-bg: rgba(255,255,255,0.1);
    --pre-bg: #0d0d0d;
    --pre-text: #ececec;
    --scrollbar: #424242;
    --send-disabled: #4a4a4a;
    --hitl-hover: #3d3d3d;
    --card-shadow: 0 24px 70px rgba(0,0,0,0.55);
    --pos: #34c98f;
    --amber: #f5a524;
}
html[data-theme="light"] {
    color-scheme: light;
    --primary: #2b658b;
    --primary-hover: #224f6e;
    --bg: #f9f9f9;
    --bg-glow: #ececec;
    --surface: #ffffff;
    --surface-2: #f4f4f4;
    --surface-3: #e8e8e8;
    --border: #e3e3e3;
    --text: #0d0d0d;
    --text-muted: #6e6e6e;
    --bot-bubble: #f4f4f4;
    --user-bubble: #f4f4f4;
    --user-bubble-text: #0d0d0d;
    --neg: #dc2626;
    --link: #2964aa;
    --code-bg: rgba(13,13,13,0.07);
    --pre-bg: #0d0d0d;   /* code blocks stay dark in light mode, like ChatGPT */
    --pre-text: #ececec;
    --scrollbar: #cdcdcd;
    --send-disabled: #c7c7c7;
    --hitl-hover: #e8e8e8;
    --card-shadow: 0 24px 70px rgba(0,0,0,0.14);
    --pos: #0f9d67;
    --amber: #b5790a;
}
* { box-sizing: border-box; }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: radial-gradient(1200px 600px at 50% -10%, var(--bg-glow) 0%, var(--bg) 60%);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
}
.container {
    position: relative;
    width: 100%;
    max-width: 100%;
    background: var(--surface);
    border: none;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh;
}
.header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 32px;
    background: transparent;
    border-bottom: none;
}
html[data-embedded="1"] .header { display: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; }
.brand-logo {
    width: 34px; height: 34px; border-radius: 9px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.brand small {
    display: block; font-weight: 400; font-size: 0.68rem;
    color: var(--text-muted); letter-spacing: 0.3px;
}
.conn-status {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.76rem; color: var(--text-muted);
    padding: 4px 11px; border: 1px solid var(--border); border-radius: 999px;
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: #6b7280; transition: background 0.2s; }
.conn-status.online .conn-dot { background: var(--online); box-shadow: 0 0 0 3px rgba(34,197,94,0.18); }
.conn-status.connecting .conn-dot { background: #f59e0b; }
.header-spacer { flex: 1; }
.chat-area {
    flex-grow: 1;
    width: 100%;
    overflow-y: auto;
    background: var(--surface);
    scroll-behavior: smooth;
}
/* Inner column keeps messages centered while the scrollbar lives on the
   full-width .chat-area (so it sits at the screen edge, not beside messages). */
.chat-inner {
    max-width: 1040px;
    margin: 0 auto;
    min-height: 100%;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.chat-area::-webkit-scrollbar { width: 8px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 8px; }
.message {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 0.95rem;
    animation: msg-in 0.18s ease-out;
}
@keyframes msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.message p { margin: 0 0 8px 0; }
.message p:last-child { margin-bottom: 0; }
.message ul, .message ol { margin: 4px 0; padding-left: 20px; }
.message a { color: var(--link); }
.message code {
    background: var(--code-bg);
    padding: 2px 5px; border-radius: 4px; font-size: 0.9em;
}
.message.user code { background: var(--code-bg); }
.message pre {
    background: var(--pre-bg); color: var(--pre-text);
    padding: 10px; border-radius: 8px; overflow-x: auto; margin: 8px 0;
    border: 1px solid var(--border);
}
.message pre code { background: none; padding: 0; color: inherit; }
.message table { border-collapse: collapse; margin: 8px 0; font-size: 0.9em; }
.message th, .message td { border: 1px solid var(--border); padding: 4px 8px; }
.message blockquote {
    border-left: 3px solid var(--border); margin: 8px 0;
    padding-left: 10px; color: var(--text-muted);
}
.message.system {
    align-self: center; background: var(--surface-2);
    color: var(--text-muted); font-size: 0.8em;
    padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border);
    animation: none;
}
.message.bot {
    align-self: flex-start; max-width: 96%;
    background: var(--bot-bubble); color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 5px;
}
.message.user {
    align-self: flex-end;
    background: var(--user-bubble); color: var(--user-bubble-text);
    border-bottom-right-radius: 5px;
}
/* Right-to-left rendering for Arabic content. */
.rtl { direction: rtl; text-align: right; }
.rtl ul, .rtl ol { padding-right: 20px; padding-left: 0; }
.rtl pre, .rtl code { direction: ltr; text-align: left; }
.rtl table { direction: rtl; }
/* Welcome empty-state */
.welcome { margin: auto; text-align: center; color: var(--text-muted); max-width: 380px; }
.welcome-logo {
    width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.welcome-logo img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.welcome h3 { margin: 0 0 6px; color: var(--text); font-size: 1.15rem; }
.welcome p { margin: 0; font-size: 0.9rem; line-height: 1.5; }
/* Typing indicator */
.typing { display: flex; gap: 4px; align-items: center; }
.typing span {
    width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted);
    animation: typing 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
.typing .typing-phrase {
    width: auto; height: auto; border-radius: 0; background: none;
    animation: none; margin-left: 6px; font-size: 0.85rem;
    color: var(--text-muted); font-style: italic;
}
@keyframes typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}
.input-area {
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: 16px 16px 22px;
    background: transparent;
    border-top: none;
    display: flex; gap: 12px; align-items: center;
}
.input-pill {
    flex-grow: 1;
    display: flex; align-items: center; gap: 4px;
    padding: 6px 8px 6px 12px;
    border: 1px solid var(--border);
    border-radius: 30px;
    background: var(--surface-2);
    transition: border 0.2s, box-shadow 0.2s;
}
.input-pill:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(43,101,139,0.28);
}
.input-pill input[type="text"] {
    flex-grow: 1;
    padding: 13px 6px;
    border: none; outline: none; background: transparent;
    color: var(--text); font-size: 1rem;
}
.input-pill input::placeholder { color: var(--text-muted); }
.input-pill input:disabled { opacity: 0.6; }
.field-btn {
    background: transparent; border: none; color: var(--text-muted);
    cursor: pointer; width: 38px; height: 38px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: background 0.15s, color 0.15s;
}
.field-btn svg { width: 20px; height: 20px; }
.field-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.field-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.field-btn.active { color: var(--danger); }
#send-btn {
    background: var(--primary); color: white; border: none;
    border-radius: 50%; width: 44px; height: 44px; flex-shrink: 0;
    cursor: pointer; font-weight: bold; font-size: 1.05rem;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s, transform 0.1s;
}
#send-btn:hover:not(:disabled) { background: var(--primary-hover); }
#send-btn:active:not(:disabled) { transform: scale(0.94); }
#send-btn:disabled { background: var(--send-disabled); cursor: not-allowed; }
/* One button, three modes: ➤ send (field has text), 🎙 record (field empty),
   ■ stop (mic live). Only the icon matching data-mode is painted. */
#send-btn svg { width: 20px; height: 20px; }
#send-btn > * { display: none; }
#send-btn[data-mode="send"] .icon-send,
#send-btn[data-mode="record"] .icon-mic,
#send-btn[data-mode="recording"] .icon-stop { display: block; }
#send-btn[data-mode="recording"] { background: var(--danger); }
#send-btn[data-mode="recording"]:hover:not(:disabled) { background: var(--danger); filter: brightness(1.1); }
/* Live-mic indicator inside the pill */
.rec-indicator {
    display: flex; align-items: center; gap: 7px; flex-shrink: 0;
    padding: 0 4px 0 6px;
    font-size: 0.82rem; font-variant-numeric: tabular-nums; color: var(--danger);
}
.rec-indicator[hidden] { display: none; }
.rec-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
    animation: rec-pulse 1.4s infinite ease-in-out;
}
@keyframes rec-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.35; transform: scale(0.8); }
}
.cards-container, .accounts-container {
    display: flex; gap: 10px; overflow-x: auto; padding: 8px 0;
}
.card-item {
    min-width: 190px; padding: 16px; border-radius: 14px;
    color: #fff; flex-shrink: 0; position: relative;
}
.card-item:nth-child(3n+1) { background: linear-gradient(135deg, #667eea, #764ba2); }
.card-item:nth-child(3n+2) { background: linear-gradient(135deg, #f093fb, #f5576c); }
.card-item:nth-child(3n)   { background: linear-gradient(135deg, #4facfe, #00f2fe); }
.card-item.locked { opacity: 0.55; }
/* Realistic bank-card styling for listed cards (Visa / Mastercard / Amex). */
.bank-card {
    width: 290px; min-width: 290px; aspect-ratio: 1.586 / 1;
    flex-shrink: 0; padding: 20px; border-radius: 16px;
    color: #fff; position: relative; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 10px 28px rgba(0,0,0,0.4);
    background: linear-gradient(135deg, #667eea, #764ba2);
}
.bank-card:nth-child(4n+2) { background: linear-gradient(135deg, #232526, #414345); }
.bank-card:nth-child(4n+3) { background: linear-gradient(135deg, #1e3c72, #2a5298); }
.bank-card:nth-child(4n)   { background: linear-gradient(135deg, #8e2de2, #4a00e0); }
.bank-card::after {   /* soft corner sheen */
    content: ''; position: absolute; top: -45%; right: -12%;
    width: 200px; height: 200px; border-radius: 50%;
    background: rgba(255,255,255,0.08); z-index: 0;
}
.bank-card > * { position: relative; z-index: 1; }
.bank-card.locked { opacity: 0.6; }
.bank-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.bank-card-name { font-size: 14px; font-weight: 700; }
.bank-card-status { font-size: 9px; opacity: 0.85; letter-spacing: 0.5px; margin-top: 2px; }
.bank-card-chip {
    width: 44px; height: 33px; border-radius: 6px; margin: 14px 0 0;
    background: linear-gradient(135deg, #f6d365, #b8860b); position: relative;
}
.bank-card-chip::after {
    content: ''; position: absolute; inset: 5px 6px;
    border: 1px solid rgba(0,0,0,0.25); border-radius: 3px;
}
.bank-card-number {
    font-family: 'Courier New', monospace; font-size: 17px;
    letter-spacing: 2px; margin-top: auto;
}
.bank-card-bottom { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 12px; }
.bank-card-label { font-size: 8px; opacity: 0.7; text-transform: uppercase; letter-spacing: 1px; }
.bank-card-holder { font-size: 12px; font-weight: 600; }
.bank-card-balance { font-size: 14px; font-weight: 700; }
.net-visa { font-style: italic; font-weight: 800; font-size: 20px; letter-spacing: 1px; }
.net-amex {
    font-weight: 800; font-size: 12px; letter-spacing: 1px;
    background: rgba(255,255,255,0.18); padding: 3px 6px; border-radius: 4px;
}
.net-mc { display: inline-flex; align-items: center; }
.net-mc i { width: 26px; height: 26px; border-radius: 50%; display: inline-block; }
.net-mc i:first-child { background: #eb001b; }
.net-mc i:last-child { background: #f79e1b; margin-left: -12px; mix-blend-mode: screen; }
.account-item {
    position: relative; min-width: 160px; flex-shrink: 0;
    padding: 14px 16px 14px 19px; border-radius: 12px;
    background: var(--surface-2); border: 1px solid var(--border);
}
.account-item::before {   /* accent bar — color carries account type, not position */
    content: ''; position: absolute; left: 0; top: 10px; bottom: 10px;
    width: 3px; border-radius: 3px; background: var(--acc, var(--primary));
}
.account-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.account-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.account-type {
    font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--acc, var(--primary)); background: color-mix(in srgb, var(--acc, var(--primary)) 16%, transparent);
    padding: 2px 7px; border-radius: 5px; flex-shrink: 0;
}
.account-balance { font-size: 23px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--text); }
.account-balance.neg { color: var(--neg); }
.account-sts { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.account-sts::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--pos); flex-shrink: 0; }
.account-sts b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.txn-category {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 14px; padding: 4px 16px; margin-bottom: 10px;
}
.txn-cat-title {
    font-weight: 600; font-size: 0.9rem; color: var(--text);
    padding: 13px 0 4px;
}
.txn-row {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 0; border-bottom: 1px solid var(--border);
}
.txn-row:last-child { border-bottom: none; }
.txn-row-icon {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; background: var(--surface-3); color: var(--text-muted);
}
.txn-row-main { flex-grow: 1; min-width: 0; }
.txn-row-name {
    font-weight: 600; font-size: 0.88rem; color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.txn-row-date { font-size: 0.74rem; color: var(--text-muted); }
.txn-row-amt { font-weight: 700; font-size: 0.88rem; white-space: nowrap; color: var(--text); }
.txn-row-amt.neg { color: var(--neg); }
.txn-row-amt.pos { color: var(--online); }
.txn-more { font-size: 0.78rem; color: var(--text-muted); text-align: center; padding: 10px 0 6px; }
.txn-chart {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 14px; padding: 14px 16px 10px; margin-bottom: 10px;
}
.txn-chart-title {
    font-weight: 600; font-size: 0.85rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 12px;
}
.txn-chart-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.txn-chart-row:last-child { margin-bottom: 0; }
.txn-chart-label {
    font-size: 0.78rem; color: var(--text); font-weight: 500;
    width: 90px; flex-shrink: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.txn-chart-bar-wrap {
    flex: 1; height: 10px; background: var(--surface-3);
    border-radius: 999px; overflow: hidden;
}
.txn-chart-bar {
    height: 100%; border-radius: 999px;
    transition: width 0.5s cubic-bezier(.25,.8,.25,1);
}
.txn-chart-val {
    font-size: 0.78rem; font-weight: 700; color: var(--text);
    width: 72px; text-align: right; flex-shrink: 0; white-space: nowrap;
}
.tool-html { margin: 8px 0; overflow-x: auto; }

/* ===================== EMPTY-STATE FINANCIAL DASHBOARD ===================== */
#dashboard {
    display: flex; flex-direction: column; gap: 16px;
    padding: 4px 0 8px;
}
/* Staggered entrance: each block fades + slides up in sequence. */
@keyframes dash-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
#dashboard .dash-greeting,
#dashboard .stat-card,
#dashboard .dash-panel {
    opacity: 0;
    animation: dash-rise 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
#dashboard .dash-greeting { animation-delay: 0.05s; }
#dashboard .dash-stats .stat-card:nth-child(1) { animation-delay: 0.15s; }
#dashboard .dash-stats .stat-card:nth-child(2) { animation-delay: 0.23s; }
#dashboard .dash-stats .stat-card:nth-child(3) { animation-delay: 0.31s; }
#dashboard .dash-stats .stat-card:nth-child(4) { animation-delay: 0.39s; }
#dashboard .dash-grid .dash-panel:nth-child(1) { animation-delay: 0.48s; }
#dashboard .dash-grid .dash-panel:nth-child(2) { animation-delay: 0.56s; }
/* Account bars grow from zero width (driven by JS in sync with the counters). */
#dashboard .acct-fill {
    transition: width 1.1s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes donut-sweep {
    from { transform: rotate(-120deg) scale(0.8); opacity: 0; }
    to   { transform: rotate(0) scale(1); opacity: 1; }
}
#dashboard .donut {
    animation: donut-sweep 0.7s 0.6s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
@media (prefers-reduced-motion: reduce) {
    #dashboard .dash-greeting,
    #dashboard .stat-card,
    #dashboard .dash-panel,
    #dashboard .acct-fill,
    #dashboard .donut { animation: none; opacity: 1; }
}
.dash-greeting h2 { margin: 0; font-size: 1.35rem; }
.dash-greeting p { margin: 4px 0 0; color: var(--text-muted); font-size: 0.9rem; }
.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat-card {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 14px; padding: 16px;
}
.stat-card .label {
    font-size: 0.72rem; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.4px;
}
.stat-card .value { font-size: 1.4rem; font-weight: 700; margin-top: 6px; }
.stat-card .value.neg { color: var(--neg); }
.stat-card .delta { font-size: 0.74rem; margin-top: 4px; color: var(--text-muted); }
.delta.up { color: var(--online); }
.delta.down { color: var(--danger); }
.dash-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 12px; }
.dash-panel {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 14px; padding: 16px;
}
.dash-panel h4 { margin: 0 0 16px; font-size: 0.88rem; font-weight: 600; }
/* Skeleton loading state: same card/panel containers as the real dashboard,
   filled with shimmering placeholder blocks instead of numbers. */
@keyframes dash-skel-shimmer {
    0%   { background-position: -120% 0; }
    100% { background-position: 120% 0; }
}
.dash-skel {
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--border) 50%, var(--surface-3) 75%);
    background-size: 250% 100%;
    animation: dash-skel-shimmer 1.6s ease-in-out infinite;
}
.dash-skel-title { height: 22px; width: 55%; margin-bottom: 8px; }
.dash-skel-sub { height: 13px; width: 80%; }
.dash-skel-label { height: 10px; width: 60%; margin-bottom: 10px; }
.dash-skel-value { height: 22px; width: 75%; }
.dash-skel-chart { height: 120px; width: 100%; }
@media (prefers-reduced-motion: reduce) {
    .dash-skel { animation: none; }
}
/* Cards fill the row evenly — no horizontal scroll inside the dashboard. */
#dashboard .cards-container { overflow: visible; padding: 0; }
#dashboard .card-item { flex: 1; min-width: 0; }
/* CSS bar chart */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 150px; }
.bar-col {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 6px; height: 100%; justify-content: flex-end;
}
.bar {
    width: 100%; border-radius: 6px 6px 0 0;
    background: linear-gradient(180deg, var(--primary-hover), var(--primary));
    transition: height 0.4s ease;
}
.bar-col span { font-size: 0.7rem; color: var(--text-muted); }
.bar-col .bar-val { font-size: 0.66rem; color: var(--text); font-weight: 600; }
/* Horizontal account-balance bars (handles the negative loan cleanly) */
.acct-bars { display: flex; flex-direction: column; gap: 14px; }
.acct-row { display: flex; align-items: center; gap: 12px; }
.acct-name { width: 116px; flex-shrink: 0; font-size: 0.82rem; color: var(--text); }
.acct-track {
    flex-grow: 1; height: 12px; border-radius: 6px;
    background: var(--surface-3); overflow: hidden;
}
.acct-fill { height: 100%; border-radius: 6px; transition: width 0.4s ease; }
.acct-bal { width: 104px; flex-shrink: 0; text-align: right; font-size: 0.82rem; font-weight: 700; white-space: nowrap; }
.acct-bal.neg { color: var(--neg); }
.acct-bal.pos { color: var(--online); }
/* Conic-gradient donut */
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut {
    width: 116px; height: 116px; border-radius: 50%; flex-shrink: 0; position: relative;
    background: conic-gradient(
        #2b658b 0 144deg, #f5576c 144deg 234deg, #4facfe 234deg 288deg,
        #a855f7 288deg 331deg, #f59e0b 331deg 360deg);
}
.donut::after {
    content: ''; position: absolute; inset: 20px;
    border-radius: 50%; background: var(--surface-2);
}
.legend { display: flex; flex-direction: column; gap: 9px; font-size: 0.8rem; flex: 1; min-width: 0; }
.legend-item { display: flex; align-items: center; gap: 8px; color: var(--text-muted); flex-wrap: wrap; min-width: 0; overflow-wrap: anywhere; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
/* Recent transactions list */
.dash-txns {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 14px; padding: 4px 16px;
}
.dash-txns h4 { margin: 14px 0 6px; font-size: 0.88rem; font-weight: 600; }
.dash-txn {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--border);
}
.dash-txn:last-child { border-bottom: none; }
.txn-icon {
    width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; background: var(--surface-3);
}
.txn-main { flex-grow: 1; min-width: 0; }
.txn-name { font-weight: 600; font-size: 0.9rem; }
.txn-sub { font-size: 0.74rem; color: var(--text-muted); }
.txn-amt { font-weight: 700; font-size: 0.9rem; white-space: nowrap; }
.txn-amt.pos { color: var(--online); }
/* Responsive: trim the dashboard down on small screens. */
@media (max-width: 680px) {
    .dash-stats { grid-template-columns: 1fr; }
    .dash-grid { display: none; }   /* drop both charts, keep just the 4 stat cards */
}
/* Line chart draw-on animation */
#dashboard .lc-line {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: lc-draw 1.4s ease-out 0.9s forwards;
}
@keyframes lc-draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
    #dashboard .lc-line { animation: none; stroke-dashoffset: 0; }
}

/* ===================== LOGIN MODAL ===================== */
.modal-overlay {
    position: fixed; inset: 0; z-index: 100;
    background: radial-gradient(1200px 600px at 50% -10%, var(--bg-glow) 0%, var(--bg) 60%);
    display: flex; align-items: center; justify-content: center; padding: 20px;
    overflow: hidden;
}
/* Decorative blurred shapes floating behind the login card. */
.bg-shapes { position: absolute; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-shape { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.45; }
.bg-shape.s1 {
    width: 420px; height: 420px; top: -120px; left: -100px;
    background: var(--primary); animation: float1 14s ease-in-out infinite;
}
.bg-shape.s2 {
    width: 360px; height: 360px; bottom: -120px; right: -80px;
    background: #0ea5e9; animation: float2 16s ease-in-out infinite;
}
.bg-shape.s3 {
    width: 280px; height: 280px; bottom: 40px; left: 12%;
    background: #4a90c2; opacity: 0.3; animation: float1 18s ease-in-out infinite;
}
@keyframes float1 {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(40px, 30px); }
}
@keyframes float2 {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(-50px, -30px); }
}
.login-card { position: relative; z-index: 1; }
.modal-overlay.hidden { display: none; }
.login-card {
    width: 100%; max-width: 380px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px; padding: 32px 28px;
    box-shadow: var(--card-shadow);
    text-align: center; animation: card-in 0.22s ease-out;
}
@keyframes card-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.login-logo {
    width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 16px;
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.login-logo img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.login-card h2 { margin: 0 0 4px; font-size: 1.4rem; }
.login-card .subtitle { margin: 0 0 22px; color: var(--text-muted); font-size: 0.88rem; }
.login-field { text-align: left; margin-bottom: 14px; }
.login-field label {
    display: block; font-size: 0.78rem; color: var(--text-muted);
    margin-bottom: 6px; font-weight: 600;
}
.login-card input {
    width: 100%; padding: 12px 14px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface-2); color: var(--text);
    outline: none; font-size: 0.95rem;
    transition: border 0.2s, box-shadow 0.2s;
}
.login-card input:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(43,101,139,0.28);
}
.login-btn {
    width: 100%; margin-top: 8px; padding: 13px;
    border: none; border-radius: 10px;
    background: var(--primary); color: #fff;
    font-weight: 700; font-size: 0.95rem; cursor: pointer;
    transition: background 0.15s;
}
.login-btn:hover:not(:disabled) { background: var(--primary-hover); }
.login-btn:disabled { opacity: 0.6; cursor: progress; }
.login-status { margin-top: 14px; font-size: 0.82rem; min-height: 1.2em; color: var(--text-muted); }
.login-status.error { color: var(--neg); }

/* HITL confirmation prompt (action buttons) */
.hitl-confirm { margin-top: 10px; padding: 12px; border: 1px solid var(--border);
    border-radius: 12px; background: var(--surface-2); }
.hitl-confirm-info { font-size: 0.86rem; color: var(--text-muted); margin-bottom: 10px; }
.hitl-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hitl-actions.column { flex-direction: column; }
.hitl-btn { flex: 1 1 auto; min-width: 120px; padding: 10px 14px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface-3); color: var(--text);
    font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: background 0.15s, opacity 0.15s; }
.hitl-btn:hover:not(:disabled) { background: var(--hitl-hover); }
.hitl-btn.approve { background: var(--primary); border-color: transparent; color: #fff; }
.hitl-btn.approve:hover:not(:disabled) { background: var(--primary-hover); }
.hitl-btn.reject { background: transparent; }
.hitl-btn.reject:hover:not(:disabled) { background: rgba(239,68,68,0.12); border-color: var(--danger); color: var(--danger); }
.hitl-confirm.resolved .hitl-btn { opacity: 0.5; cursor: default; }
.hitl-btn:disabled { cursor: default; }

/* ===================== VISUAL SUMMARY PANEL & CHARTS (graph_tool) ===================== */

/* Chat column + right insights panel */
.main-row { flex: 1; display: flex; min-height: 0; }
.chat-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.side-panel {
    width: 0; flex-shrink: 0; overflow: hidden;
    background: var(--surface); border-left: 1px solid transparent;
    display: flex; flex-direction: column;
    transition: width 0.25s ease, border-color 0.25s ease;
}
.side-panel.open { width: min(460px, 42vw); border-left-color: var(--border); }
/* min-width on the inner blocks keeps content from squishing mid-transition */
.side-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 18px; border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 0.92rem; min-width: 280px;
}
.panel-btn {
    background: transparent; border: 1px solid var(--border); color: var(--text-muted);
    border-radius: 8px; padding: 4px 10px; font-size: 0.74rem; cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.panel-btn:hover { background: var(--surface-3); color: var(--text); }
.side-panel-body { flex: 1; overflow-y: auto; padding: 14px 16px 20px; min-width: 280px; }
.side-panel-body::-webkit-scrollbar { width: 8px; }
.side-panel-body::-webkit-scrollbar-thumb { background: #29354c; border-radius: 8px; }
.panel-group { margin-bottom: 20px; animation: msg-in 0.18s ease-out; }
/* Vertical breathing room between a group's components — each chart
   arrives as its own component wrapper, so space the wrappers. */
.panel-group > * + * { margin-top: 14px; }
/* "View N charts" chip on chat bubbles whose turn produced components.
   Also doubles as the generating placeholder (with a spinner ring). */
.insights-chip {
    display: inline-flex; align-items: center; gap: 7px; margin-top: 10px;
    padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px;
    background: var(--surface-3); color: var(--text-muted);
    font-size: 0.78rem; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.insights-chip:hover { background: #324159; color: var(--text); }
.insights-chip.generating { cursor: default; }
.insights-chip.generating:hover { background: var(--surface-3); color: var(--text-muted); }
.insights-chip .ring {
    width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0;
    border: 2px solid var(--border); border-top-color: var(--primary);
    animation: chip-spin 0.8s linear infinite;
}
@keyframes chip-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .insights-chip .ring { animation-duration: 1.6s; }
}
/* Charts fill the panel width; drop the inline min-width there */
.side-panel .chart-card { min-width: 0; }
.side-panel .gbar-label { width: 92px; }
/* Cards & accounts stack vertically in the panel — no horizontal scrolling */
.side-panel .cards-container, .side-panel .accounts-container {
    flex-direction: column; align-items: stretch; gap: 12px;
    overflow-x: visible; overflow-y: visible;
}
.side-panel .bank-card { width: 100%; min-width: 0; max-width: 360px; }
.side-panel .account-item { min-width: 0; }
@media (max-width: 900px) {
    .side-panel.open {
        position: fixed; top: 0; right: 0; bottom: 0; z-index: 90;
        width: min(92vw, 420px);
        border-left: 1px solid var(--border);
        box-shadow: -18px 0 40px rgba(0,0,0,0.45);
    }
}

/* ===================== LLM-GENERATED CHARTS (display_graph) ===================== */
.chart-card {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 14px; padding: 14px 16px 12px; margin-top: 8px;
    /* Bot bubbles shrink-to-fit; keep charts readable even when the
       other message content is narrow. */
    min-width: min(560px, 76vw);
}
.chart-card:first-child { margin-top: 0; }
.chart-title { font-weight: 600; font-size: 0.92rem; color: var(--text); }
.chart-desc { font-size: 0.78rem; color: var(--text-muted); margin: 3px 0 10px; line-height: 1.4; }
.chart-axis-y { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 4px; }
.chart-axis-x { font-size: 0.7rem; color: var(--text-muted); text-align: center; margin-top: 4px; }
.chart-legend {
    display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px;
    font-size: 0.78rem; color: var(--text-muted);
}
.chart-legend-item { display: flex; align-items: center; gap: 6px; min-width: 0; }
.chart-legend-item .val { color: var(--text); font-weight: 600; }
.chart-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
/* Horizontal bar rows */
.gbar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; border-radius: 6px; }
.gbar-row:last-child { margin-bottom: 0; }
.gbar-label {
    font-size: 0.78rem; color: var(--text); font-weight: 500;
    width: 110px; flex-shrink: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gbar-track { flex: 1; height: 14px; background: var(--surface-3); border-radius: 0 4px 4px 0; overflow: hidden; }
.gbar-fill {
    height: 100%; border-radius: 0 4px 4px 0;
    background: #3987e5;
    transition: width 0.5s cubic-bezier(.25,.8,.25,1);
}
.gbar-val {
    font-size: 0.78rem; font-weight: 700; color: var(--text);
    min-width: 64px; text-align: right; flex-shrink: 0; white-space: nowrap;
}
/* Donut + hover */
.gpie-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.gpie-svg path { transition: opacity 0.15s; cursor: default; }
.gpie-svg path.dim { opacity: 0.35; }
/* Shared floating tooltip */
.chart-tooltip {
    position: fixed; z-index: 60; pointer-events: none;
    background: #0b1120; border: 1px solid var(--border); border-radius: 8px;
    padding: 6px 10px; font-size: 0.78rem; color: var(--text);
    box-shadow: 0 8px 24px rgba(0,0,0,0.45); white-space: nowrap;
    display: none;
}
.chart-tooltip .tt-label { color: var(--text-muted); }
@media (prefers-reduced-motion: reduce) {
    .gbar-fill { transition: none; }
}
/* ===================== THEME TOGGLE ===================== */
.theme-toggle {
    background: transparent; border: 1px solid var(--border); color: var(--text-muted);
    cursor: pointer; width: 36px; height: 36px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { background: var(--surface-3); color: var(--text); }
.theme-toggle svg { width: 18px; height: 18px; }
/* Show the icon of the mode you'd switch to. */
html[data-theme="light"] .theme-toggle .icon-sun { display: none; }
html:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
/* On the sign-in screen the toggle floats in the top-right corner. */
.modal-overlay .theme-toggle { position: absolute; top: 18px; right: 18px; z-index: 2; }
/* Blurred login shapes are too intense on a light background. */
html[data-theme="light"] .bg-shape { opacity: 0.3; }
html[data-theme="light"] .bg-shape.s3 { opacity: 0.2; }

