/*
 * AdReportGen — Design System
 * Matches landing page at adreportgen.com
 *
 * COLOR TOKENS (also set as CSS custom properties in :root via each template)
 * --bg-primary:   #1D1A35
 * --bg-secondary: #252240
 * --bg-surface:   #2D2850
 * --text-primary: #FFFFFF
 * --text-secondary: rgba(255,255,255,0.761)
 * --text-muted:   rgba(255,255,255,0.45)
 * --accent-purple:#483C5C
 * --border-color: rgba(255,255,255,0.1)
 * --btn-primary-bg: #FFFFFF
 * --btn-primary-text: #483C5C
 */

:root {
    --bg-primary:   #1D1A35;
    --bg-secondary: #252240;
    --bg-surface:   #2D2850;
    --text-primary: #FFFFFF;
    --text-secondary: rgba(255, 255, 255, 0.761);
    --text-muted:   rgba(255, 255, 255, 0.45);
    --accent-purple:#483C5C;
    --accent-light: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-subtle:rgba(255, 255, 255, 0.06);
    --btn-primary-bg: #FFFFFF;
    --btn-primary-text: #483C5C;
    --btn-primary-radius: 0.75rem;
    /* ── Light chat area ── */
    --chat-bg: #F7F6FB;
    --chat-bubble-ai: #FFFFFF;
    --chat-text-primary: #1D1A35;
    --chat-text-secondary: rgba(29,26,53,0.65);
    --chat-text-muted: rgba(29,26,53,0.4);
    --chat-border: rgba(29,26,53,0.12);
    --chat-input-border: rgba(29,26,53,0.18);
    --chat-input-focus: #483C5C;
    --chat-bubble-user-bg: #483C5C;
    --chat-bubble-user-text: #FFFFFF;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ── */
html, body {
    height: 100%;
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    background: linear-gradient(135deg, #1D1A35 0%, #0F1A2E 100%);
    background-attachment: fixed;
    color: var(--text-primary);
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
    font-family: 'Sora', sans-serif;
    font-weight: 500;
    color: var(--text-primary);
}

/* ── App shell ── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ─────────────────────────────────────────
   SIDEBAR
───────────────────────────────────────── */
.sidebar {
    width: 240px; flex-shrink: 0;
    background: linear-gradient(180deg, #1D1A35 0%, #141628 100%);
    color: var(--text-secondary);
    display: flex; flex-direction: column;
    overflow-y: auto; z-index: 100;
    border-right: 1px solid rgba(255,255,255,0.08);
    transition: transform 0.25s ease;
}
.sidebar-brand {
    padding: 1.25rem 1rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center;
    background: transparent;
}
.sidebar-brand img { width: 160px; height: auto; display: block; }
.sidebar-title {
    font-family: 'Sora', sans-serif;
    font-size: 1rem; font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.sidebar-workspace { padding: 0.75rem 1rem 0.65rem; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-ws-label {
    display: block; font-family: 'Roboto', sans-serif; font-weight: 300;
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted); margin-bottom: 0.2rem;
}
.sidebar-ws-name {
    font-family: 'Sora', sans-serif;
    font-size: 0.88rem; font-weight: 500;
    color: var(--text-primary); word-break: break-word;
}
.sidebar-section { padding: 0.65rem 0.75rem 0.5rem; }
.sidebar-section-label {
    font-family: 'Roboto', sans-serif; font-weight: 400;
    font-size: 0.67rem; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-muted);
    margin-bottom: 0.35rem; padding-left: 0.3rem;
}
.sidebar-link {
    display: block; padding: 0.38rem 0.6rem; border-radius: 5px;
    color: var(--text-secondary); text-decoration: none;
    font-family: 'Roboto', sans-serif; font-size: 0.84rem;
    margin-bottom: 0.1rem;
    transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}
.sidebar-link.active {
    background: var(--accent-light);
    color: var(--text-primary);
    border-left: 3px solid #FFFFFF;
    padding-left: calc(0.6rem - 3px);
}
.sidebar-error { font-size: 0.75rem; color: #f87171; margin-top: 0.35rem; }
.focus-btn { display: none; }
.scope-tab-btn { display: none; }

/* New Workspace button — primary style */
.sidebar-new-ws-btn {
    display: block; width: calc(100% - 1.5rem); margin: 0.55rem 0.75rem 0.1rem;
    padding: 0.5rem 0.75rem;
    font-family: 'Sora', sans-serif; font-size: 0.81rem; font-weight: 500;
    background: var(--btn-primary-bg); color: var(--btn-primary-text);
    border: none; border-radius: var(--btn-primary-radius);
    cursor: pointer; text-align: left;
    transition: background 0.25s ease, transform 0.25s ease;
}
.sidebar-new-ws-btn:hover {
    background: #F0EBF8;
    transform: translateY(-1px);
}

/* Workspace list */
.sidebar-ws-list { padding: 0.2rem 0.5rem 0.5rem; }
.sidebar-ws-row {
    display: flex; align-items: center;
    border-radius: 5px; margin-bottom: 0.05rem;
    transition: background 0.15s;
}
.sidebar-ws-row:hover { background: rgba(255,255,255,0.05); }
.sidebar-ws-item {
    flex: 1; display: block; padding: 0.38rem 0.6rem; border-radius: 5px;
    color: var(--text-secondary); text-decoration: none;
    font-family: 'Roboto', sans-serif; font-size: 0.84rem;
    min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: color 0.15s;
}
.sidebar-ws-row:hover .sidebar-ws-item { color: var(--text-primary); }
.sidebar-ws-row.active { background: var(--accent-light); }
.sidebar-ws-row.active .sidebar-ws-item { color: var(--text-primary); font-weight: 500; }
.ws-delete-btn {
    display: none; flex-shrink: 0; padding: 0 6px;
    color: #f87171; cursor: pointer; font-size: 1rem; line-height: 1;
    border-radius: 3px; transition: color 0.12s;
}
.sidebar-ws-row:hover .ws-delete-btn { display: inline; }
.ws-delete-btn:hover { color: #ff3b3b; }
.ws-rename-btn {
    display: none; flex-shrink: 0; padding: 0 5px;
    color: var(--text-muted); cursor: pointer; font-size: 0.85rem; line-height: 1;
    border-radius: 3px; transition: color 0.12s;
}
.sidebar-ws-row:hover .ws-rename-btn { display: inline; }
.ws-rename-btn:hover { color: var(--text-secondary); }
.ws-rename-input {
    flex: 1; background: var(--bg-surface);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px; color: var(--text-primary);
    font-size: 0.84rem; padding: 0.2rem 0.4rem; outline: none; min-width: 0;
}
.sidebar-ws-sub {
    display: block; padding: 0.28rem 0.6rem 0.28rem 1.5rem; border-radius: 5px;
    color: var(--text-muted); text-decoration: none; font-size: 0.79rem;
    margin-bottom: 0.05rem; transition: background 0.12s, color 0.12s;
}
.sidebar-ws-sub:hover { background: var(--accent-light); color: var(--text-secondary); }
.sidebar-bottom-links { margin-top: auto; padding: 0.5rem 0.5rem 0.75rem; }
.sidebar-bottom-links .sidebar-link { color: var(--text-muted); font-size: 0.81rem; }

/* Hamburger (mobile) */
.hamburger {
    display: none; position: fixed; top: 0.7rem; left: 0.7rem; z-index: 200;
    background: var(--bg-secondary); border: 1px solid rgba(255,255,255,0.08);
    border-radius: 5px; color: var(--text-secondary);
    padding: 0.35rem 0.5rem; font-size: 1.05rem;
    cursor: pointer; line-height: 1;
}
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); z-index: 90;
}

/* ─────────────────────────────────────────
   CHAT MAIN
───────────────────────────────────────── */
.chat-main {
    display: flex; flex-direction: column; flex: 1;
    height: 100vh; overflow: hidden;
    background: transparent; min-width: 0;
}

/* Session context bar */
#session-context-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary) !important;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
    font-size: 0.82rem;
    color: var(--text-muted) !important;
    flex-shrink: 0;
}
#ctx_date_start, #ctx_date_end {
    border: none !important;
    background: transparent !important;
    color: var(--text-primary) !important;
    font-size: 0.82rem !important;
    cursor: pointer !important;
    outline: none !important;
    /* Force white calendar icon on dark bg */
    color-scheme: dark;
}
#session-context-bar .date-arrow { color: var(--text-muted) !important; }

/* Context bar — Apply button (primary style) */
#session-context-bar button:first-of-type,
.ctx-apply-btn {
    padding: 3px 10px;
    font-family: 'Sora', sans-serif; font-size: 0.78rem; font-weight: 500;
    background: var(--btn-primary-bg) !important;
    color: var(--btn-primary-text) !important;
    border: none !important; border-radius: 0.5rem !important;
    cursor: pointer !important;
    transition: background 0.25s ease, transform 0.25s ease !important;
}
#session-context-bar button:first-of-type:hover { background: #F0EBF8 !important; transform: translateY(-1px); }

/* Refresh Data + Benchmarks buttons (secondary style) */
.ctx-secondary-btn {
    display: flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    font-family: 'Roboto', sans-serif; font-size: 0.78rem;
    background: rgba(255,255,255,0.08) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    border-radius: 0.5rem !important;
    cursor: pointer !important;
    transition: background 0.15s;
}
.ctx-secondary-btn:hover { background: rgba(255,255,255,0.14) !important; }

#ctx-freshness {
    margin-left: auto;
    font-family: 'Roboto', sans-serif; font-weight: 300;
    color: var(--text-muted) !important; font-size: 0.78rem !important;
}

/* ── Chat history ── */
.chat-history {
    flex: 1; overflow-y: auto; padding: 1.25rem 1.5rem 0.75rem;
    display: flex; flex-direction: column; gap: 1rem;
    background: var(--chat-bg);
}
.chat-history::-webkit-scrollbar { width: 6px; }
.chat-history::-webkit-scrollbar-track { background: var(--chat-bg); }
.chat-history::-webkit-scrollbar-thumb { background: var(--chat-border); border-radius: 3px; }
.chat-history::-webkit-scrollbar-thumb:hover { background: var(--chat-text-muted); }

.chat-empty {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    color: var(--chat-text-muted); text-align: center; padding: 3rem 1rem;
}
.chat-empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.chat-empty-title {
    font-family: 'Sora', sans-serif; font-size: 1.05rem; font-weight: 500;
    color: var(--chat-text-secondary); margin-bottom: 0.3rem;
}
.chat-empty-sub { font-size: 0.85rem; color: var(--chat-text-muted); }

/* ── Messages ── */
.msg { display: flex; align-items: flex-start; gap: 0.6rem; }
.msg.user { flex-direction: row-reverse; align-self: flex-end; max-width: 72%; }
.msg.bot  { align-self: flex-start; max-width: 92%; width: 100%; }
.msg.bot.has-chart { max-width: 100%; }

.msg-avatar { display: none; } /* avatars removed — bubbles only */

.msg-content { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; flex: 1 1 0; width: 100%; }
.msg-bubble {
    padding: 0.7rem 0.95rem;
    font-family: 'Roboto', sans-serif; font-size: 0.88rem; line-height: 1.6;
}
.msg.user .msg-bubble {
    background: var(--chat-bubble-user-bg); color: var(--chat-bubble-user-text);
    border-radius: 1rem 0.25rem 1rem 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}
.msg.bot .msg-bubble {
    background: var(--chat-bubble-ai); color: var(--chat-text-primary);
    border-radius: 0.25rem 1rem 1rem 1rem;
    border: 1px solid var(--chat-border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* Markdown inside bot bubbles */
.msg-bubble p { margin: 0 0 0.55em; }
.msg-bubble p:last-child { margin-bottom: 0; }
/* User bubble headings — white on purple */
.msg.user .msg-bubble h1,
.msg.user .msg-bubble h2,
.msg.user .msg-bubble h3 {
    font-family: 'Sora', sans-serif; font-weight: 500;
    font-size: 0.95em; margin: 0.8em 0 0.3em; color: var(--btn-primary-text);
}
/* Bot bubble headings */
.msg.bot .msg-bubble h1,
.msg.bot .msg-bubble h2,
.msg.bot .msg-bubble h3 {
    font-family: 'Sora', sans-serif; font-weight: 500;
    font-size: 0.95em; margin: 0.8em 0 0.3em;
    color: var(--chat-text-primary);
}
.msg-bubble h1:first-child, .msg-bubble h2:first-child, .msg-bubble h3:first-child { margin-top: 0; }
.msg-bubble ul, .msg-bubble ol { padding-left: 1.4em; margin: 0.4em 0; }
.msg-bubble li { margin-bottom: 0.2em; }
.msg.bot .msg-bubble strong { font-weight: 600; color: #1D1A35; }
.msg.user .msg-bubble strong { font-weight: 600; }
.msg.bot .msg-bubble a { color: #483C5C; }
.msg.bot .msg-bubble a:hover { text-decoration: underline; }
/* Bot bubble code */
.msg.bot .msg-bubble code {
    background: rgba(29,26,53,0.08); padding: 0.1em 0.35em;
    border-radius: 3px; font-size: 0.84em;
    font-family: "SFMono-Regular", Consolas, monospace;
    color: #2D2850;
}
.msg.bot .msg-bubble pre {
    background: rgba(29,26,53,0.06); padding: 0.65rem;
    border-radius: 6px; overflow-x: auto; margin: 0.5em 0;
}
/* User bubble code */
.msg.user .msg-bubble code {
    background: rgba(255,255,255,0.15); padding: 0.1em 0.35em;
    border-radius: 3px; font-size: 0.84em;
    font-family: "SFMono-Regular", Consolas, monospace;
}
.msg-bubble pre code { background: none; padding: 0; font-size: 0.84em; }
/* Bot bubble tables */
.msg.bot .msg-bubble table { width: 100%; border-collapse: collapse; font-size: 0.83rem; margin: 0.5em 0; }
.msg.bot .msg-bubble th,
.msg.bot .msg-bubble td { padding: 0.32rem 0.55rem; border: 1px solid var(--chat-border); text-align: left; color: var(--chat-text-primary); }
.msg.bot .msg-bubble th {
    background: rgba(29,26,53,0.05); font-weight: 500; color: var(--chat-text-secondary);
    text-transform: uppercase; font-size: 0.75em; letter-spacing: 0.06em;
}
.msg.bot .msg-bubble tr:hover td { background: rgba(29,26,53,0.03); }

.msg-meta { display: flex; align-items: center; gap: 0.4rem; }
.msg-extras { margin-top: 0.5rem; width: 100%; min-width: 0; }
.msg-extras > div { width: 100%; box-sizing: border-box; }

/* ── Copy button (bot message meta row) ── */
.copy-btn, .msg-copy-btn {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.28rem 0.7rem;
    background: #FFFFFF; border: 1px solid var(--chat-border);
    border-radius: 0.4rem;
    color: var(--chat-text-secondary);
    font-family: 'Roboto', sans-serif; font-size: 0.79rem; font-weight: 400;
    cursor: pointer; transition: all 0.15s ease;
    user-select: none;
}
.copy-btn:hover, .msg-copy-btn:hover {
    background: #EBE9F4; border-color: #B5AECF;
    color: var(--chat-text-primary);
}
.copy-btn.copied, .msg-copy-btn.copied {
    background: rgba(34,197,94,0.1); border-color: rgba(34,197,94,0.4);
    color: #16a34a; pointer-events: none;
    animation: copySuccess 0.2s ease;
}
@keyframes copySuccess {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Typing indicator */
.typing-indicator { display: flex; gap: 0.28rem; align-items: center; padding: 0.5rem 0.6rem; }
.typing-dot {
    width: 0.42rem; height: 0.42rem; border-radius: 50%;
    background: var(--text-muted); animation: tdot 1.2s infinite;
}
/* Bot bubbles are white — use dark dots so they're visible */
.msg.bot .msg-bubble .typing-dot { background: #483C5C; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes tdot {
    0%, 80%, 100% { opacity: 0.4; transform: scale(1); }
    40% { opacity: 1; transform: scale(1.25); }
}

/* ── Results panel ── */
.results-panel { flex-shrink: 0; padding: 0 1.5rem 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; background: var(--chat-bg); }
.results-panel-inner {
    background: #FFFFFF; border: 1px solid var(--chat-border);
    border-radius: 0.75rem; padding: 0.75rem 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
#ai-bot-copy-table-wrap {
    background: #FFFFFF; border: 1px solid var(--chat-border);
    border-radius: 0.75rem; padding: 0.7rem 0.9rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
#ai-bot-copy-table-preview {
    overflow-x: auto; margin-bottom: 0.4rem;
    border: 1px solid var(--chat-border); border-radius: 4px; max-height: 16rem;
}
.export-btns { display: flex; gap: 0.35rem; margin-top: 0.35rem; flex-wrap: wrap; }
.export-btn {
    padding: 0.3rem 0.7rem; font-size: 0.78rem;
    background: #483C5C; color: #FFFFFF;
    border: none; border-radius: 0.5rem;
    cursor: pointer; transition: background 0.15s; font-weight: 500;
    font-family: 'Roboto', sans-serif;
}
.export-btn:hover { background: #1D1A35; }
.export-btn.secondary {
    background: #FFFFFF; color: var(--chat-text-secondary);
    border: 1px solid var(--chat-border);
}
.export-btn.secondary:hover { background: #EBE9F4; border-color: #B5AECF; color: var(--chat-text-primary); }
/* Target both the staging element (by ID) and flushed clones (by class) */
#ai-bot-answer-trace,
.answer-trace-details {
    font-size: 0.8rem; color: var(--chat-text-secondary);
    background: rgba(72,60,92,0.06); border: 1px solid var(--chat-border);
    border-radius: 0.5rem; padding: 0.4rem 0.7rem;
    margin-top: 0.4rem;
}
#ai-bot-answer-trace summary,
.answer-trace-details summary {
    cursor: pointer; color: var(--chat-text-secondary); font-size: 0.78rem;
    font-family: 'Roboto', sans-serif;
}
#ai-bot-answer-trace summary:hover,
.answer-trace-details summary:hover { color: var(--chat-text-primary); }
#ai-bot-answer-trace-body,
.answer-trace-body {
    margin-top: 0.35rem; padding: 0.4rem 0.35rem;
    background: rgba(29,26,53,0.04);
    border-radius: 4px; border: 1px solid var(--chat-border);
    color: var(--chat-text-secondary); font-size: 0.78rem;
}
.answer-trace-body div,
.answer-trace-body span,
.answer-trace-body p { color: var(--chat-text-secondary); }
.answer-trace-body strong,
.answer-trace-body b { color: var(--chat-text-primary); font-weight: 600; }

/* ── Funnel ── */
.funnel-root { padding: 0 1.5rem 0.5rem; overflow-y: auto; flex-shrink: 0; }
.funnel-card, .funnel-subcard {
    border: 1px solid rgba(255,255,255,0.08); border-radius: 0.75rem;
    margin-bottom: 0.45rem; background: var(--bg-secondary);
}
.funnel-summary {
    padding: 0.55rem 0.8rem; cursor: pointer;
    font-family: 'Sora', sans-serif; font-size: 0.85rem; font-weight: 500;
    color: var(--text-primary); list-style: none;
}
.funnel-summary::-webkit-details-marker { display: none; }
.funnel-body { padding: 0.5rem 0.8rem; font-size: 0.83rem; }
.funnel-item {
    border: 1px solid rgba(255,255,255,0.06); border-radius: 7px;
    padding: 0.5rem 0.8rem; margin-bottom: 0.4rem;
    background: var(--bg-surface);
}
.funnel-metrics { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.18rem; }
.ai-highlight {
    border-color: rgba(255,255,255,0.35) !important;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.15) !important;
}

/* ── Input bar ── */
.chat-input-bar {
    background: #FFFFFF;
    border-top: 1px solid var(--chat-border);
    box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
    padding: 0.55rem 1.5rem 0.7rem; flex-shrink: 0;
}
#suggested-prompts-wrap { margin-bottom: 0.45rem; }
.prompt-chips-row { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.prompt-chip {
    padding: 0.26rem 0.68rem; font-size: 0.82rem;
    background: #FFFFFF; color: var(--chat-text-secondary);
    border: 1px solid var(--chat-border); border-radius: 2rem;
    cursor: pointer; white-space: nowrap;
    font-family: 'Roboto', sans-serif;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.prompt-chip:hover { background: #EBE9F4; border-color: #B5AECF; color: var(--chat-text-primary); }
.prompt-chip:active { background: #483C5C; border-color: #483C5C; color: #FFFFFF; }
.chat-form { display: flex; gap: 0.45rem; align-items: flex-end; }

#ai-bot-question {
    flex: 1; padding: 0.58rem 0.8rem;
    background: #FFFFFF;
    border: 1px solid var(--chat-input-border);
    border-radius: 0.75rem;
    color: var(--chat-text-primary);
    font-family: 'Roboto', sans-serif; font-size: 0.88rem;
    resize: none; min-height: 2.5rem; max-height: 7rem;
    outline: none; line-height: 1.45;
    overflow-y: auto; transition: border-color 0.15s, box-shadow 0.15s;
}
#ai-bot-question::placeholder { color: var(--chat-text-muted); }
#ai-bot-question:focus {
    border-color: var(--chat-input-focus);
    box-shadow: 0 0 0 3px rgba(72,60,92,0.12);
}

#ai-bot-ask {
    padding: 0.58rem 1.1rem;
    background: #483C5C; color: #FFFFFF;
    border: none; border-radius: 0.75rem;
    font-family: 'Sora', sans-serif; font-size: 0.88rem; font-weight: 500;
    cursor: pointer; white-space: nowrap;
    transition: background 0.2s ease;
    height: 2.5rem;
}
#ai-bot-ask:hover { background: #1D1A35; }

.input-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 0.3rem;
}
#ai-bot-clear {
    background: none; border: none; color: var(--chat-text-muted);
    font-size: 0.75rem; cursor: pointer; padding: 0.1rem 0.2rem;
    font-family: 'Roboto', sans-serif;
}
#ai-bot-clear:hover { color: var(--chat-text-secondary); }
.input-footer-info { font-size: 0.73rem; color: var(--chat-text-muted); }

/* ── Report content ── */
.report-content {
    padding: 1.25rem 1.5rem 2.5rem;
    overflow-y: auto; background: var(--bg-primary);
}
.report-content h2 {
    font-family: 'Sora', sans-serif; font-size: 1rem; font-weight: 500;
    margin: 1.1rem 0 0.5rem; color: var(--text-primary);
}
.report-content h3 {
    font-family: 'Sora', sans-serif; font-size: 0.9rem; font-weight: 500;
    margin: 0.8rem 0 0.4rem; color: var(--text-secondary);
}
.report-section { margin-bottom: 1.25rem; }
.table-wrap { overflow-x: auto; margin-bottom: 0.7rem; }
table { border-collapse: collapse; width: 100%; margin-top: 0.35rem; font-size: 0.82rem; }
th, td { border: 1px solid var(--border-subtle); padding: 0.38rem 0.55rem; text-align: left; }
th {
    background: rgba(255,255,255,0.06); font-weight: 500;
    font-family: 'Sora', sans-serif; color: var(--text-muted);
    text-transform: uppercase; font-size: 0.75em; letter-spacing: 0.08em;
}
tr:hover td { background: rgba(255,255,255,0.04); }
.num { text-align: right; white-space: nowrap; }
.errors { color: #fca5a5; margin: 0.5rem 0; font-size: 0.85rem; }
.badge-pass {
    display: inline-block; padding: 0.2rem 0.6rem; border-radius: 2rem;
    background: rgba(34,197,94,0.15); color: #86EFAC;
    border: 1px solid rgba(34,197,94,0.3); font-size: 0.75em;
}
.badge-fail {
    display: inline-block; padding: 0.2rem 0.6rem; border-radius: 2rem;
    background: rgba(239,68,68,0.15); color: #FCA5A5;
    border: 1px solid rgba(239,68,68,0.3); font-size: 0.75em;
}
.banner-fail {
    margin: 0.65rem 0; padding: 0.55rem 0.7rem; border-radius: 4px;
    border: 1px solid rgba(239,68,68,0.3); background: rgba(239,68,68,0.15);
    color: #FCA5A5; font-weight: 500; font-size: 0.85rem;
}

/* ── Status badges ── */
.status-active, [class*="badge"][class*="active"], .badge-active {
    background: rgba(34,197,94,0.15); color: #86EFAC;
    border: 1px solid rgba(34,197,94,0.3);
    border-radius: 2rem; padding: 0.2rem 0.6rem;
    font-size: 0.75em; display: inline-block;
}
.status-paused, [class*="badge"][class*="paused"], .badge-paused {
    background: rgba(234,179,8,0.15); color: #FDE047;
    border: 1px solid rgba(234,179,8,0.3);
    border-radius: 2rem; padding: 0.2rem 0.6rem;
    font-size: 0.75em; display: inline-block;
}
.status-error, .badge-error {
    background: rgba(239,68,68,0.15); color: #FCA5A5;
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: 2rem; padding: 0.2rem 0.6rem;
    font-size: 0.75em; display: inline-block;
}

/* ─────────────────────────────────────────
   MODALS
───────────────────────────────────────── */
.modal-backdrop {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6); z-index: 1000;
    display: none; align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }

/* Override inline-styled modals */
#benchmarks-modal > div,
#new-workspace-modal > div {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 1rem !important;
    color: var(--text-primary) !important;
    box-shadow: 0 8px 40px rgba(0,0,0,0.4) !important;
}
#benchmarks-modal h3,
#new-workspace-modal h3 {
    color: var(--text-primary) !important;
    font-family: 'Sora', sans-serif !important;
    font-weight: 500 !important;
}
#benchmarks-modal p,
#new-workspace-modal p {
    color: var(--text-muted) !important;
}
#benchmarks-modal table th {
    background: rgba(255,255,255,0.06) !important;
    color: var(--text-muted) !important;
    border-color: rgba(255,255,255,0.08) !important;
}
#benchmarks-modal table tr { border-color: rgba(255,255,255,0.06) !important; }
#benchmarks-modal table td { color: var(--text-secondary) !important; border-color: rgba(255,255,255,0.06) !important; }
#benchmarks-modal label { color: var(--text-muted) !important; font-size: 0.75rem; }
#benchmarks-modal select,
#benchmarks-modal input[type="number"],
#benchmarks-modal input[type="text"] {
    background: var(--bg-surface) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-radius: 0.5rem !important;
    color: var(--text-primary) !important;
    font-family: 'Roboto', sans-serif !important;
}
#benchmarks-modal select option { background: var(--bg-surface); }
#new-workspace-modal input[type="text"] {
    background: var(--bg-surface) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    border-radius: 0.5rem !important;
    color: var(--text-primary) !important;
}
#benchmarks-modal button[onclick="closeBenchmarksModal()"],
#new-workspace-modal button[onclick="closeNewWorkspaceModal()"] {
    color: var(--text-muted) !important;
    background: none !important;
    border: none !important;
}
#benchmarks-modal button[onclick="closeBenchmarksModal()"]:hover,
#new-workspace-modal button[onclick="closeNewWorkspaceModal()"]:hover {
    color: var(--text-primary) !important;
}
#benchmarks-modal button[onclick="addBenchmark()"] {
    background: var(--btn-primary-bg) !important;
    color: var(--btn-primary-text) !important;
    border: none !important; border-radius: 0.5rem !important;
    font-family: 'Sora', sans-serif !important; font-weight: 500 !important;
}
#new-workspace-modal button[onclick="submitNewWorkspace()"] {
    background: var(--btn-primary-bg) !important;
    color: var(--btn-primary-text) !important;
    border: none !important; border-radius: 0.5rem !important;
    font-family: 'Sora', sans-serif !important; font-weight: 500 !important;
}
#new-workspace-modal button[onclick="closeNewWorkspaceModal()"] {
    background: rgba(255,255,255,0.08) !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
    border-radius: 0.5rem !important;
}
#benchmarks-modal .border-top { border-top-color: rgba(255,255,255,0.08) !important; }
#bm-error { color: #FCA5A5 !important; }
#benchmarks-empty-row td { color: var(--text-muted) !important; font-style: italic; }

/* ─────────────────────────────────────────
   AUTH PAGES (login / signup)
───────────────────────────────────────── */
.auth-page-bg {
    background: linear-gradient(135deg, #1D1A35 0%, #0F1A2E 100%);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 1.5rem;
    font-family: 'Roboto', sans-serif;
}
.auth-wrap { width: 100%; max-width: 420px; }
.auth-logo {
    text-align: center; margin-bottom: 2rem;
}
.auth-logo img { width: 180px; height: auto; }
.auth-logo-text {
    font-family: 'Sora', sans-serif; font-size: 1.25rem; font-weight: 500;
    color: var(--text-primary);
}
.auth-card {
    background: var(--bg-secondary);
    border-radius: 1rem; padding: 2rem 2rem 1.75rem;
    border: 1px solid var(--border-color);
}
.auth-headline {
    font-family: 'Sora', sans-serif; font-size: 1.2rem; font-weight: 500;
    color: var(--text-primary); margin-bottom: 0.3rem; text-align: center;
}
.auth-subheadline {
    font-size: 0.83rem; color: var(--text-muted);
    text-align: center; margin-bottom: 1.5rem; line-height: 1.5;
}
.btn-google {
    display: flex; align-items: center; justify-content: center; gap: 0.6rem;
    width: 100%; padding: 0.65rem 1rem;
    background: rgba(255,255,255,0.08); color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 0.75rem; text-decoration: none;
    font-family: 'Roboto', sans-serif; font-size: 0.88rem;
    transition: background 0.15s;
}
.btn-google:hover { background: rgba(255,255,255,0.14); }
.divider {
    display: flex; align-items: center; gap: 0.75rem;
    margin: 1.25rem 0; color: var(--text-muted); font-size: 0.8rem;
}
.divider::before, .divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border-color);
}
.error-banner {
    background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3);
    border-radius: 7px; padding: 0.65rem 0.85rem;
    font-size: 0.82rem; color: #FCA5A5; margin-bottom: 1rem;
}
.form-group { margin-bottom: 0.9rem; }
.form-label {
    display: block; font-size: 0.8rem;
    font-family: 'Roboto', sans-serif; font-weight: 400;
    color: var(--text-secondary); margin-bottom: 0.35rem;
}
.form-input {
    width: 100%; padding: 0.6rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 0.75rem;
    font-family: 'Roboto', sans-serif; font-size: 0.88rem;
    color: var(--text-primary); outline: none;
    transition: border-color 0.15s;
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:focus { border-color: rgba(255,255,255,0.35); }
.form-error { font-size: 0.76rem; color: #FCA5A5; margin-top: 0.3rem; }
.btn-submit {
    width: 100%; padding: 0 1.75rem;
    height: 3.5rem;
    background: var(--btn-primary-bg); color: var(--btn-primary-text);
    border: none; border-radius: 0.75rem;
    font-family: 'Sora', sans-serif; font-size: 0.88rem; font-weight: 500;
    cursor: pointer; margin-top: 0.35rem;
    transition: background 0.25s ease, transform 0.25s ease;
}
.btn-submit:hover { background: #F0EBF8; transform: translateY(-1px); }
.forgot-link {
    display: block; text-align: right; font-size: 0.78rem;
    color: var(--text-muted); margin-top: 0.4rem; text-decoration: none;
}
.forgot-link:hover { color: var(--text-secondary); }
.auth-footer { text-align: center; margin-top: 1.25rem; font-size: 0.82rem; color: var(--text-muted); }
.auth-footer a { color: var(--text-secondary); text-decoration: none; }
.auth-footer a:hover { color: var(--text-primary); text-decoration: underline; }

/* ─────────────────────────────────────────
   SETTINGS PAGE
───────────────────────────────────────── */
.settings-page { background: var(--bg-primary); min-height: 100vh; color: var(--text-primary); }
.top-bar {
    padding: 0.85rem 1.5rem; display: flex; align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.logo {
    font-family: 'Sora', sans-serif; font-size: 1rem; font-weight: 500;
    color: var(--text-primary); text-decoration: none;
}
.logo img { height: 32px; width: auto; }
.top-bar-links { display: flex; gap: 1rem; align-items: center; }
.top-bar-link {
    font-family: 'Roboto', sans-serif; font-size: 0.83rem;
    color: var(--text-muted); text-decoration: none;
}
.top-bar-link:hover { color: var(--text-primary); }
.page-body { max-width: 560px; margin: 2.5rem auto; padding: 0 1.5rem; }
.page-body h1 {
    font-family: 'Sora', sans-serif; font-size: 1.35rem; font-weight: 500;
    color: var(--text-primary); margin-bottom: 0.35rem;
}
.page-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 2rem; }
.card {
    background: var(--bg-secondary); border-radius: 0.75rem;
    padding: 1.75rem 1.5rem;
    border: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 1.25rem;
}
.card-title {
    font-family: 'Sora', sans-serif; font-size: 0.95rem; font-weight: 500;
    color: var(--text-primary); margin-bottom: 1.1rem;
}
.field { margin-bottom: 1rem; }
.field label {
    display: block; font-size: 0.8rem;
    font-family: 'Roboto', sans-serif; font-weight: 400;
    color: var(--text-secondary); margin-bottom: 0.3rem;
}
.field input {
    width: 100%; padding: 0.55rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 0.75rem;
    font-family: 'Roboto', sans-serif; font-size: 0.88rem;
    color: var(--text-primary); outline: none;
    transition: border-color 0.15s;
}
.field input::placeholder { color: var(--text-muted); }
.field input:focus { border-color: rgba(255,255,255,0.35); }
.field input[readonly] { opacity: 0.6; cursor: default; }
.field-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }
.btn-primary {
    padding: 0 1.2rem; height: 3rem;
    background: var(--btn-primary-bg); color: var(--btn-primary-text);
    border: none; border-radius: 0.75rem;
    font-family: 'Sora', sans-serif; font-size: 0.85rem; font-weight: 500;
    cursor: pointer; transition: background 0.25s ease, transform 0.25s ease;
    display: inline-flex; align-items: center;
}
.btn-primary:hover { background: #F0EBF8; transform: translateY(-1px); }
.alert {
    padding: 0.6rem 0.85rem; border-radius: 0.5rem;
    font-size: 0.83rem; margin-bottom: 1rem;
}
.alert-success {
    background: rgba(34,197,94,0.15); color: #86EFAC;
    border: 1px solid rgba(34,197,94,0.3);
}
.alert-error {
    background: rgba(239,68,68,0.15); color: #FCA5A5;
    border: 1px solid rgba(239,68,68,0.3);
}
.divider-hr { height: 1px; background: rgba(255,255,255,0.08); margin: 1.1rem 0; }

/* ─────────────────────────────────────────
   ONBOARDING
───────────────────────────────────────── */
.onboarding-page {
    background: linear-gradient(135deg, #1D1A35 0%, #0F1A2E 100%);
    min-height: 100vh;
    display: flex; flex-direction: column;
    font-family: 'Roboto', sans-serif;
}
.onboarding-top-bar {
    padding: 1rem 1.5rem; display: flex;
    align-items: center; justify-content: space-between;
}
.onboarding-logo img { height: 32px; width: auto; }
.onboarding-logo-text {
    font-family: 'Sora', sans-serif; font-size: 1rem; font-weight: 500;
    color: var(--text-primary); text-decoration: none;
}
.progress { display: flex; align-items: center; gap: 6px; }
.progress-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-color); }
.progress-dot.done { background: #86EFAC; }
.progress-dot.active { background: rgba(255,255,255,0.6); }
.progress-label { font-size: 0.76rem; color: var(--text-muted); margin-left: 4px; }
.onboarding-body {
    flex: 1; display: flex; align-items: center;
    justify-content: center; padding: 2rem 1.5rem;
}
.onboarding-card {
    background: var(--bg-secondary); border-radius: 1rem;
    padding: 2.5rem 2rem 2rem;
    border: 1px solid rgba(255,255,255,0.08);
    width: 100%; max-width: 480px;
}
.step-label {
    font-size: 0.72rem; font-weight: 400; font-family: 'Roboto', sans-serif;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted); margin-bottom: 0.6rem;
}
.onboarding-card h1 {
    font-family: 'Sora', sans-serif; font-size: 1.35rem; font-weight: 500;
    color: var(--text-primary); margin-bottom: 0.4rem;
}
.subtitle { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1.75rem; line-height: 1.55; }
.platform-card {
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 0.75rem; padding: 14px 16px; margin-bottom: 10px;
    display: flex; align-items: center; gap: 14px;
    background: var(--bg-surface); text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
}
.platform-card:hover {
    border-color: rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.06);
}
.platform-card.connected { border-color: rgba(34,197,94,0.4); }
.platform-icon { font-size: 1.4rem; flex-shrink: 0; }
.platform-info { flex: 1; }
.platform-name { font-family: 'Sora', sans-serif; font-weight: 500; font-size: 0.88rem; color: var(--text-primary); }
.platform-desc { font-size: 0.76rem; color: var(--text-muted); margin-top: 2px; }
.btn-connect {
    padding: 7px 16px;
    background: rgba(255,255,255,0.08); color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.15);
    text-decoration: none; border-radius: 0.5rem;
    font-family: 'Roboto', sans-serif; font-size: 0.81rem;
    white-space: nowrap; flex-shrink: 0;
    transition: background 0.15s;
}
.btn-connect:hover { background: rgba(255,255,255,0.14); }
.actions-row {
    display: flex; align-items: center;
    justify-content: space-between; margin-top: 1.25rem;
}
.back-link, .skip-link {
    font-size: 0.8rem; color: var(--text-muted); text-decoration: none; cursor: pointer;
}
.back-link:hover, .skip-link:hover { color: var(--text-secondary); }
.onboarding-form-input {
    width: 100%; padding: 0.75rem 0.9rem;
    background: var(--bg-surface);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 0.75rem;
    color: var(--text-primary); font-family: 'Roboto', sans-serif; font-size: 0.95rem;
    outline: none; transition: border-color 0.15s; margin-bottom: 1.1rem;
}
.onboarding-form-input::placeholder { color: var(--text-muted); }
.onboarding-form-input:focus { border-color: rgba(255,255,255,0.35); }
.btn-onboarding-primary {
    width: 100%; height: 3.5rem; padding: 0 1.75rem;
    background: var(--btn-primary-bg); color: var(--btn-primary-text);
    border: none; border-radius: 0.75rem;
    font-family: 'Sora', sans-serif; font-size: 0.92rem; font-weight: 500;
    cursor: pointer; transition: background 0.25s ease, transform 0.25s ease;
    display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-onboarding-primary:hover { background: #F0EBF8; transform: translateY(-1px); }

/* ── Mobile ── */
@media (max-width: 768px) {
    .hamburger { display: block; }
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.4); }
    .sidebar-overlay.open { display: block; }
    .chat-main { width: 100%; }
    .msg.user { max-width: 88%; }
    .msg.bot  { max-width: 100%; }
    .chat-history { padding: 1rem 1rem 0.5rem; }
    .chat-input-bar { padding: 0.5rem 1rem 0.6rem; }
    .results-panel { padding: 0 1rem 0.5rem; }
    .funnel-root { padding: 0 1rem 0.5rem; }
    .report-content { padding: 1rem 1rem 2rem; }
}
