/* Copyright (c) 2026 Andrew Clay. All rights reserved.
   This source code is proprietary and confidential. See TRADE_SECRETS.md. */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #171717;
    --sidebar-hover: #212121;
    --sidebar-active: #2a2a2a;
    --accent: #007aff;
    --chat-max-width: 900px;
    --results-max-width: 1400px;
}

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

#snipeFields[hidden],
#chatSection[hidden],
#resultsSection[hidden] {
    display: none !important;
}

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

/* ================================================================
   SIDEBAR
   ================================================================ */

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: margin-left 0.25s ease;
    z-index: 50;
}

body.sidebar-collapsed .sidebar {
    margin-left: calc(-1 * var(--sidebar-width));
}

/* Mobile overlay — shown behind open sidebar so tapping it closes the sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 49;
}

@media (max-width: 768px) {
    body:not(.sidebar-collapsed) .sidebar-overlay {
        display: block;
    }
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 12px 8px;
}

.sidebar-new-chat {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid #444;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.sidebar-new-chat:hover {
    background: var(--sidebar-hover);
}

.sidebar-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #999;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.sidebar-icon-btn:hover {
    background: var(--sidebar-hover);
    color: #e0e0e0;
}

/* Sidebar Client Selector */
.sidebar-client-select {
    padding: 8px 12px 12px;
    border-bottom: 1px solid #2a2a2a;
}

.sidebar-client-select label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.sidebar-client-select select {
    width: 100%;
    padding: 8px 10px;
    background: var(--sidebar-hover);
    border: 1px solid #333;
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    appearance: auto;
}

.sidebar-client-select select:focus {
    border-color: var(--accent);
}

/* Sidebar History */
.sidebar-history {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-history-group {
    padding: 0 8px;
    margin-bottom: 4px;
}

.sidebar-history-label {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 8px 8px 4px;
}

.sidebar-history-item-wrapper {
    display: flex;
    align-items: center;
    border-radius: 8px;
    transition: background 0.12s;
    cursor: pointer;
}

.sidebar-history-item-wrapper:hover {
    background: var(--sidebar-hover);
}

.sidebar-history-item-wrapper.active {
    background: var(--sidebar-active);
}

.sidebar-history-item-wrapper.active .sidebar-history-item {
    color: #fff;
}

.sidebar-history-item {
    display: block;
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    color: #ccc;
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-history-item:hover {
    color: #fff;
}

.sidebar-history-delete {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    margin-right: 4px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #888;
    cursor: pointer;
    font-size: 14px;
    transition: color 0.12s, background 0.12s;
}

.sidebar-history-item-wrapper:hover .sidebar-history-delete {
    display: flex;
}

.sidebar-history-delete:hover {
    color: #ff5555;
    background: rgba(255, 85, 85, 0.1);
}

.sidebar-history-empty {
    padding: 24px 16px;
    text-align: center;
    color: #555;
    font-size: 13px;
}

/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid #2a2a2a;
    padding: 10px 12px;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 4px 10px;
}

.sidebar-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-email {
    font-size: 12px;
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-actions {
    display: flex;
    gap: 4px;
}

/* Sidebar scrollbar */
.sidebar-history::-webkit-scrollbar {
    width: 4px;
}

.sidebar-history::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-history::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 2px;
}

/* ================================================================
   MAIN CONTENT
   ================================================================ */

.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #fff;
    transition: margin-left 0.25s ease;
}

/* Top Bar */
.main-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    border-bottom: 1px solid #e5e5e5;
    background: #fff;
    flex-shrink: 0;
    height: 48px;
}

.topbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #666;
    cursor: pointer;
    transition: background 0.15s;
}

.topbar-btn:hover {
    background: #f0f0f0;
}

.model-pill {
    font-size: 13px;
    font-weight: 500;
    color: #666;
    background: #f5f5f5;
    padding: 5px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #e8e8e8;
}

.pill-label {
    font-size: 11px;
    font-weight: 600;
    color: #444;
    letter-spacing: 0.01em;
}

.pill-divider {
    width: 1px;
    height: 11px;
    background: #d8d8d8;
    margin: 0 2px;
}

.pill-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    letter-spacing: 0.02em;
}

.pill-badge--meta    { background: #e8f0fe; color: #1877f2; }
.pill-badge--google  { background: #e6f4ea; color: #1e8e3e; }
.pill-badge--nb      { background: #f0ebff; color: #6d28d9; }
.pill-badge--shopify { background: #edf7e6; color: #5a8a00; }

/* ================================================================
   CHAT SECTION
   ================================================================ */

.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: center;
}

.chat-messages > *:not(.empty-state) {
    width: 100%;
    max-width: var(--chat-max-width);
}

/* ================================================================
   EMPTY STATE
   ================================================================ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px 20px;
    min-height: 400px;
    max-width: var(--chat-max-width) !important;
}

.empty-state[hidden] {
    display: none !important;
}

.empty-state-logo {
    height: 56px;
    width: auto;
    margin-bottom: 16px;
    opacity: 0.9;
}

.empty-state-title {
    font-size: 22px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 32px;
}

.suggestion-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    max-width: 560px;
}

.suggestion-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    color: #555;
    line-height: 1.45;
    transition: background 0.15s, border-color 0.15s;
}

.suggestion-card:hover {
    background: #f8f8f8;
    border-color: #ccc;
}

.suggestion-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #f0f0f0;
    color: #888;
}

/* ================================================================
   CHAT MESSAGES (User + Assistant)
   ================================================================ */

.chat-msg {
    display: flex;
    padding: 8px 0;
    max-width: var(--chat-max-width);
}

.chat-msg.user {
    justify-content: flex-end;
    max-width: var(--chat-max-width);
}

.chat-msg.assistant {
    align-self: flex-start;
    gap: 12px;
    max-width: var(--chat-max-width);
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 16px;
    margin-bottom: 8px;
}

/* Assistant Avatar */
.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #1a1a1a;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
    letter-spacing: 0.5px;
}

/* Message Body (wrapper for content + copy btn) */
.chat-msg-body {
    position: relative;
    flex: 1;
    min-width: 0;
}

.chat-msg-content {
    font-size: 15px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* User bubble style */
.chat-msg.user .chat-msg-content {
    background: var(--accent);
    color: #fff;
    padding: 10px 16px;
    border-radius: 18px;
    border-bottom-right-radius: 4px;
    display: inline-block;
    word-break: break-word;
}

/* Assistant — clean text, no bubble */
.chat-msg.assistant .chat-msg-content {
    color: #1a1a1a;
    overflow-x: hidden;
}

/* Copy button on assistant messages — inline below content, like ChatGPT */
.copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    padding: 4px 8px;
    background: none;
    border: none;
    border-radius: 6px;
    color: #aaa;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.chat-msg.assistant:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    color: #555;
    background: #f0f0f0;
}

/* ---- Markdown inside chat messages ---- */

/* Headings: sized close to body text so they paste cleanly without giant headers */
.chat-msg-content h1 {
    font-size: 1.05em;
    font-weight: 700;
    margin-top: 14px;
    margin-bottom: 4px;
}
.chat-msg-content h2 {
    font-size: 1.0em;
    font-weight: 700;
    margin-top: 12px;
    margin-bottom: 4px;
}
.chat-msg-content h3 {
    font-size: 1.0em;
    font-weight: 600;
    margin-top: 10px;
    margin-bottom: 4px;
}
.chat-msg-content h4 {
    font-size: 1.0em;
    font-weight: 600;
    margin-top: 8px;
    margin-bottom: 2px;
}

.chat-msg-content h1:first-child,
.chat-msg-content h2:first-child,
.chat-msg-content h3:first-child {
    margin-top: 0;
}

/* Emoji — constrained to body text size so they don't paste oversized */
.chat-msg-content img.emoji,
.chat-msg-content .emoji {
    height: 1em;
    width: 1em;
    vertical-align: -0.1em;
    font-size: inherit;
}

.chat-msg-content p { margin-bottom: 6px; }
.chat-msg-content p:last-child { margin-bottom: 0; }
.chat-msg-content ul, .chat-msg-content ol { margin: 6px 0; padding-left: 20px; }
.chat-msg-content li { margin-bottom: 3px; }

.chat-msg-content .table-wrapper {
    overflow-x: auto;
    margin: 8px 0;
}

.table-toolbar {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    padding: 4px 0;
}

.table-btn {
    font-size: 11px;
    padding: 3px 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: #f8f8f8;
    color: #555;
    cursor: pointer;
    white-space: nowrap;
}

.table-btn:hover {
    background: #efefef;
    color: #222;
}

/* Table expand modal */
.table-expand-modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.table-expand-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.55);
}

.table-expand-dialog {
    position: relative;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    max-width: 92vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.table-expand-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
}

.table-expand-title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.table-expand-close {
    background: none;
    border: none;
    font-size: 16px;
    color: #888;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}

.table-expand-close:hover {
    background: #f0f0f0;
    color: #333;
}

.table-expand-content {
    overflow: auto;
    padding: 16px;
}

.table-expand-content table {
    border-collapse: collapse;
    font-size: 13px;
    white-space: nowrap;
}

.table-expand-content th,
.table-expand-content td {
    border: 1px solid #e0e0e0;
    padding: 7px 12px;
    text-align: left;
}

.table-expand-content th {
    background: #eef0f2;
    font-weight: 600;
}

.chat-msg-content table {
    border-collapse: collapse;
    font-size: 13px;
    width: 100%;
    white-space: nowrap;
}

.chat-msg-content th,
.chat-msg-content td {
    border: 1px solid #e0e0e0;
    padding: 6px 10px;
    text-align: left;
}

.chat-msg-content th {
    background: #eef0f2;
    font-weight: 600;
    font-size: 13px;
}

.chat-msg-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 13px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.chat-msg-content pre {
    background: #1a1a1a;
    color: #f0f0f0;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.chat-msg-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* ================================================================
   CHAT INPUT AREA
   ================================================================ */

.chat-input-wrapper {
    flex-shrink: 0;
    background: #fff;
    padding: 0;
}

.chat-input-area {
    max-width: calc(var(--chat-max-width) + 48px);
    margin: 0 auto;
    padding: 0 24px 16px;
}

.chat-input-actions {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.open-analysis-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.12s, color 0.12s;
}

.open-analysis-btn:hover {
    background: #f0f0f0;
    color: #555;
}

.view-results-btn {
    color: var(--accent);
}

.textarea-container {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 16px;
    background: #fff;
    transition: border-color 0.2s;
}

.textarea-container:focus-within {
    border-color: var(--accent);
}

#chatInput {
    display: block;
    width: 100%;
    padding: 14px 52px 14px 18px;
    border: none;
    border-radius: 16px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.5;
    outline: none;
    resize: none;
    background: transparent;
    min-height: 52px;
    max-height: 200px;
    overflow-y: auto;
}

#chatInput::placeholder {
    color: #aaa;
}

#chatInput:disabled {
    background: #fafafa;
    color: #999;
}

.chat-send-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.chat-send-btn:hover {
    background: #0066d6;
}

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

.chat-disclaimer {
    text-align: center;
    font-size: 12px;
    color: #aaa;
    margin-top: 8px;
}

/* ================================================================
   PROGRESS BAR
   ================================================================ */

.progress-bar {
    height: 28px;
    padding: 0 24px;
    font-size: 12px;
    color: #888;
    display: flex;
    align-items: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    max-width: calc(var(--chat-max-width) + 48px);
    margin: 0 auto;
    width: 100%;
    flex-shrink: 0;
}

.progress-bar:empty {
    height: 0;
    padding: 0;
}

.progress-bar.active {
    color: var(--accent);
}

.progress-bar.active::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    margin-right: 8px;
    animation: spin 0.8s linear infinite;
}

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

/* Analysis loading skeleton */
.analysis-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 16px;
    color: #888;
    font-size: 14px;
}

.analysis-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--accent-color, #6366f1);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ================================================================
   DRAWER (Analysis) — replaces centered modal
   ================================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay[hidden] {
    display: none !important;
}

.modal-overlay.drawer-open {
    opacity: 1;
    pointer-events: auto;
}

.modal-dialog {
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 440px;
    background: #fff;
    border-radius: 16px 0 0 16px;
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    z-index: 101;
}

.modal-overlay.drawer-open .modal-dialog {
    transform: translateX(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 16px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #888;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.modal-close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 20px 24px 32px;
}

/* ================================================================
   TYPE CARD LIST
   ================================================================ */

.type-card-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.type-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border: 1.5px solid #e5e5e5;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
    width: 100%;
}

.type-card:hover:not(.active) {
    background: #fafafa;
    border-color: #ccc;
}

.type-card.active {
    border-color: var(--accent);
    background: #f0f7ff;
}

.type-card-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 28px;
    text-align: center;
}

.type-card-content {
    flex: 1;
}

.type-card-name {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
}

.type-card-desc {
    font-size: 11px;
    color: #888;
    margin-top: 1px;
}

.type-card.active .type-card-name {
    color: var(--accent);
}

/* ================================================================
   PROGRESS LOG (terminal-style)
   ================================================================ */

.progress-log {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 16px 20px;
    margin: 24px 0;
    font-family: ui-monospace, 'Fira Code', 'SF Mono', monospace;
    font-size: 13px;
}

.progress-log-header {
    font-size: 11px;
    font-weight: 600;
    color: #58a6ff;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 12px;
}

.progress-log-header::before {
    content: "$ ";
    color: #3fb950;
}

.progress-log-lines {
    max-height: 320px;
    overflow-y: auto;
}

.log-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 2px 0;
    color: #8b949e;
    animation: logLineIn 0.2s ease;
    font-size: 12px;
}

.log-line.active {
    color: #e6edf3;
}

.log-line.done {
    color: #3fb950;
}

.log-line-icon {
    width: 16px;
    flex-shrink: 0;
    text-align: center;
    line-height: 1.6;
}

.log-spinner {
    width: 10px;
    height: 10px;
    border: 1.5px solid #58a6ff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

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

/* ================================================================
   FORM STYLES (shared between modal and legacy)
   ================================================================ */

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

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

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    flex: 1 1 100%;
}

.form-group label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.label-hint {
    font-weight: 400;
    color: #999;
}

.form-group select,
.form-group input[type="number"],
.form-group textarea {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.form-group select:focus,
.form-group input[type="number"]:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

/* Toggle group */
.toggle-group {
    display: flex;
    flex-wrap: wrap;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.toggle-btn {
    flex: 1;
    padding: 8px 16px;
    border: none;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
    color: #555;
    transition: all 0.15s;
}

.toggle-btn:not(:last-child) {
    border-right: 1px solid #ddd;
}

.toggle-btn.active {
    background: var(--accent);
    color: #fff;
    font-weight: 500;
}

.toggle-btn:hover:not(.active) {
    background: #f5f5f5;
}

/* Form actions */
.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

#runBtn {
    padding: 10px 28px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

#runBtn:hover {
    background: #0066d6;
}

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

/* ================================================================
   RESULTS SECTION
   ================================================================ */

.results-section {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 32px;
    border-bottom: 1px solid #e5e5e5;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 10;
    max-width: var(--results-max-width);
    margin: 0 auto;
    width: 100%;
    gap: 16px;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid #ddd;
    border-radius: 8px;
    color: #555;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.btn-back:hover {
    background: #f0f0f0;
}

.results-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-secondary {
    padding: 6px 16px;
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-accent {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
}

.btn-accent:hover {
    background: #0066d6;
    border-color: #0066d6;
}

.results-header-buttons {
    display: flex;
    gap: 8px;
}

.results-content {
    padding: 28px 32px;
    font-size: 15px;
    line-height: 1.6;
    color: #1a1a1a;
    max-width: var(--results-max-width);
    margin: 0 auto;
    width: 100%;
}

/* Markdown inside results */
.results-content h1,
.results-content h2,
.results-content h3 {
    margin-top: 20px;
    margin-bottom: 8px;
}

.results-content h1:first-child,
.results-content h2:first-child,
.results-content h3:first-child {
    margin-top: 0;
}

.results-content h1 { font-size: 22px; }
.results-content h2 { font-size: 19px; }
.results-content h3 { font-size: 16px; font-weight: 600; }

.results-content p {
    margin-bottom: 10px;
}

.results-content p:last-child {
    margin-bottom: 0;
}

.results-content ul, .results-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.results-content li {
    margin-bottom: 4px;
}

.results-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 13px;
}

.results-content pre {
    background: #1a1a1a;
    color: #f0f0f0;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.results-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.results-content table {
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 13px;
    width: 100%;
}

.results-content th,
.results-content td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.results-content th {
    background: #f5f5f5;
    font-weight: 600;
}

.results-content strong {
    font-weight: 600;
}

.results-content hr {
    border: none;
    border-top: 1px solid #e5e5e5;
    margin: 16px 0;
}

.error-text {
    color: #d32f2f;
    font-weight: 500;
}

/* ================================================================
   FOLLOW-UP SECTION (inside results)
   ================================================================ */

.followup-section {
    border-top: 1px solid #e5e5e5;
    padding: 16px 24px 24px;
}

.followup-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    margin-bottom: 12px;
}

.followup-messages {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.followup-msg {
    display: flex;
    max-width: 90%;
}

.followup-msg.user {
    align-self: flex-end;
}

.followup-msg.assistant {
    align-self: flex-start;
}

.followup-msg-content {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.followup-msg.user .followup-msg-content {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.followup-msg.assistant .followup-msg-content {
    background: #f0f0f0;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

/* Markdown inside follow-up messages */
.followup-msg-content h1,
.followup-msg-content h2,
.followup-msg-content h3 {
    margin-top: 12px;
    margin-bottom: 6px;
}

.followup-msg-content h1:first-child,
.followup-msg-content h2:first-child,
.followup-msg-content h3:first-child {
    margin-top: 0;
}

.followup-msg-content p { margin-bottom: 6px; }
.followup-msg-content p:last-child { margin-bottom: 0; }
.followup-msg-content ul, .followup-msg-content ol { margin: 6px 0; padding-left: 20px; }
.followup-msg-content li { margin-bottom: 3px; }

.followup-msg-content table {
    border-collapse: collapse;
    margin: 8px 0;
    font-size: 13px;
}

.followup-msg-content th,
.followup-msg-content td {
    border: 1px solid #ddd;
    padding: 4px 8px;
    text-align: left;
}

.followup-msg-content th {
    background: #f5f5f5;
    font-weight: 600;
}

.followup-form {
    display: flex;
    gap: 8px;
}

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

#followupInput:focus {
    border-color: var(--accent);
}

#followupInput:disabled {
    background: #f5f5f5;
    color: #999;
}

#followupBtn {
    padding: 10px 20px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

#followupBtn:hover {
    background: #0066d6;
}

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

/* ================================================================
   DASHBOARD MODE
   ================================================================ */

/* KPI Cards */
.kpi-row {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.kpi-card {
    flex: 1;
    background: #f8f9fa;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 14px 16px;
    text-align: center;
}

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

.kpi-value {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    line-height: 1.2;
}

.kpi-delta {
    font-size: 12px;
    font-weight: 500;
    margin-top: 4px;
}

.kpi-delta.positive { color: #16a34a; }
.kpi-delta.negative { color: #dc2626; }
.kpi-delta.neutral { color: #9ca3af; }

/* Quadrant Cards */
.quadrant-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.quadrant-card {
    padding: 12px 14px;
    border-radius: 10px;
    border-left: 4px solid;
}

.quadrant-card.ideal {
    background: #f0fdf4;
    border-left-color: #16a34a;
}

.quadrant-card.inefficient-winner {
    background: #fffbeb;
    border-left-color: #d97706;
}

.quadrant-card.efficient-loser {
    background: #eff6ff;
    border-left-color: #2563eb;
}

.quadrant-card.failing {
    background: #fef2f2;
    border-left-color: #dc2626;
}

.quadrant-card-label {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.quadrant-card-count {
    font-size: 20px;
    font-weight: 700;
    color: #1a1a1a;
}

.quadrant-card-margin {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

/* Dashboard Sections (details/summary) */
.dashboard-section {
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
}

.dashboard-section > summary {
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    cursor: pointer;
    background: #f8f9fa;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.dashboard-section > summary::-webkit-details-marker {
    display: none;
}

.dashboard-section > summary::before {
    content: "\25B8";
    font-size: 12px;
    transition: transform 0.15s;
    color: #888;
}

.dashboard-section[open] > summary::before {
    transform: rotate(90deg);
}

.dashboard-section > summary:hover {
    background: #f0f0f0;
}

.dashboard-section-body {
    padding: 16px;
}

/* Window Tabs */
.window-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.window-tab {
    padding: 5px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    background: #fff;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.15s;
}

.window-tab:hover {
    background: #f5f5f5;
}

.window-tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* Dashboard Tables */
.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.dashboard-table th {
    background: #f8f9fa;
    font-weight: 600;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid #e5e5e5;
    color: #555;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.dashboard-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #f0f0f0;
    color: #1a1a1a;
}

.dashboard-table tr:hover td {
    background: #f8f9fa;
}

.dashboard-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-ideal { background: #dcfce7; color: #15803d; }
.badge-inefficient-winner { background: #fef3c7; color: #92400e; }
.badge-efficient-loser { background: #dbeafe; color: #1d4ed8; }
.badge-failing { background: #fee2e2; color: #b91c1c; }

.badge-active { background: #dcfce7; color: #15803d; }
.badge-recently-paused { background: #fef3c7; color: #92400e; }
.badge-inactive { background: #f3f4f6; color: #6b7280; }

/* Correlation cell coloring */
.corr-strong-pos { background: #dcfce7; }
.corr-strong-neg { background: #fee2e2; }
.corr-noise { color: #ccc; }

/* False-kill rate coloring */
.fkr-green { color: #16a34a; font-weight: 600; }
.fkr-amber { color: #d97706; font-weight: 600; }
.fkr-red { color: #dc2626; font-weight: 600; }

/* Funnel side-by-side */
.funnel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.funnel-group h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

/* Ad name truncation in tables */
.ad-name-cell {
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Section checkbox in accordion summary */
.section-check {
    display: inline-flex;
    align-items: center;
    margin-right: 4px;
    position: relative;
    z-index: 1;
}

.section-checkbox {
    width: 15px;
    height: 15px;
    cursor: pointer;
    accent-color: #2563eb;
}

/* ================================================================
   HELP BUTTON
   ================================================================ */

.bug-report-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.bug-report-popover {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.14);
    width: 300px;
    overflow: hidden;
    animation: popoverIn 0.18s ease;
}

.bug-report-popover[hidden] {
    display: none !important;
}

@keyframes popoverIn {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.bug-report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 10px;
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    border-bottom: 1px solid #f0f0f0;
}

.bug-report-close-btn {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: color 0.15s;
}

.bug-report-close-btn:hover { color: #555; }

.bug-report-textarea {
    display: block;
    width: 100%;
    padding: 12px 14px;
    border: none;
    resize: none;
    font-size: 13px;
    font-family: inherit;
    color: #333;
    outline: none;
    line-height: 1.5;
}

.bug-report-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px 12px;
    gap: 8px;
}

.bug-report-status {
    font-size: 12px;
    color: #888;
    flex: 1;
}

.bug-report-status.success { color: #15803d; }
.bug-report-status.error   { color: #b91c1c; }

.bug-report-submit-btn {
    padding: 7px 16px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.bug-report-submit-btn:hover { background: #333; }
.bug-report-submit-btn:disabled { opacity: 0.5; cursor: default; }

.help-btn {
    width: auto;
    height: 36px;
    padding: 0 14px;
    border-radius: 18px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: background 0.15s;
    flex-shrink: 0;
    white-space: nowrap;
}

.help-btn:hover {
    background: #333;
}

/* ================================================================
   SHARE CONVERSATION MODAL
   ================================================================ */

.share-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.share-modal-overlay[hidden] { display: none; }

.share-modal {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.share-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
}

.share-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: #888;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}
.share-modal-close:hover { color: #333; background: #f0f0f0; }

.share-modal-desc {
    font-size: 13px;
    color: #666;
    margin-bottom: 16px;
    line-height: 1.5;
}

.share-modal-link-row {
    display: flex;
    gap: 8px;
}

.share-modal-input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    color: #333;
    background: #f9f9f9;
    outline: none;
}

.share-modal-copy-btn {
    padding: 9px 16px;
    background: #1a1a1a;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}
.share-modal-copy-btn:hover { background: #333; }

.share-modal-status {
    margin-top: 10px;
    font-size: 13px;
    color: #888;
    min-height: 18px;
}

/* ================================================================
   FOOTER (print-only)
   ================================================================ */

.app-footer {
    display: none;
}

.app-footer p {
    font-size: 12px;
    color: #999;
}

/* ================================================================
   SCROLLBAR
   ================================================================ */

.chat-messages::-webkit-scrollbar,
.results-section::-webkit-scrollbar,
.followup-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.results-section::-webkit-scrollbar-track,
.followup-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.results-section::-webkit-scrollbar-thumb,
.followup-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* ================================================================
   PRINT HEADER (hidden on screen)
   ================================================================ */

.print-header {
    display: none;
}

/* ================================================================
   PRINT / PDF EXPORT
   ================================================================ */

@page {
    size: letter;
    margin: 0.6in 0.7in 0.8in;
}

@page {
    @bottom-center {
        content: counter(page);
        font-size: 9pt;
        color: #999;
    }
}

@media print {
    /* --- Hide UI chrome --- */
    .sidebar,
    .main-top-bar,
    .chat-section,
    .modal-overlay,
    .help-btn,
    .app-footer,
    .progress-bar,
    .results-header-buttons,
    .section-check,
    .window-tabs,
    .cd-share-modal {
        display: none !important;
    }

    /* --- Show print header --- */
    .print-header {
        display: flex !important;
        align-items: center;
        gap: 12px;
        border-bottom: 1.5px solid #d0d0d0;
        padding-bottom: 8px;
        margin-bottom: 14px;
    }

    .print-logo {
        height: 32px;
        width: auto;
    }

    .print-header-text {
        display: flex;
        flex-direction: column;
    }

    .print-title {
        font-size: 14pt;
        font-weight: 700;
        color: #1a1a1a;
    }

    .print-date {
        font-size: 9pt;
        color: #666;
    }

    /* Hide the on-screen results header (replaced by print header) */
    .results-header {
        display: none !important;
    }

    /* --- Remove app container constraints --- */
    body {
        display: block;
        overflow: visible;
        height: auto;
        background: #fff;
        font-size: 11pt;
        color: #1a1a1a;
    }

    .main-content {
        height: auto;
        overflow: visible;
        margin-left: 0 !important;
    }

    .results-section {
        overflow: visible;
        flex: none;
    }

    .results-content {
        padding: 0;
    }

    /* --- Typography --- */
    h1 { font-size: 16pt; font-weight: 700; color: #1a1a1a; }
    h2 { font-size: 13pt; font-weight: 600; color: #1a1a1a; margin-top: 10pt; }
    h3 { font-size: 11pt; font-weight: 600; color: #1a1a1a; margin-top: 8pt; }
    p, li { color: #1a1a1a; line-height: 1.45; }
    li { margin-bottom: 2px; }
    strong { font-weight: 700; }

    /* --- Section styling (details/summary) --- */
    .dashboard-section {
        border: none;
        border-top: none;
        margin-bottom: 6pt;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .dashboard-section > summary {
        background: #f5f5f7;
        border-left: 3px solid var(--accent);
        padding: 6px 10px;
        font-size: 12pt;
        font-weight: 600;
        color: #1a1a1a;
        list-style: none;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .dashboard-section > summary::-webkit-details-marker,
    .dashboard-section > summary::marker {
        display: none;
        content: "";
    }

    summary::before {
        display: none !important;
    }

    .dashboard-section-body {
        display: block !important;
        padding: 6px 0 2px;
    }

    /* --- Creative analysis accordion sections --- */
    .results-content details {
        page-break-inside: avoid;
        break-inside: avoid;
        margin-bottom: 4pt;
    }

    .results-content details > summary {
        background: #f5f5f7;
        border-left: 3px solid var(--accent);
        padding: 5px 10px;
        font-weight: 600;
        color: #1a1a1a;
        list-style: none;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .results-content details > summary::-webkit-details-marker,
    .results-content details > summary::marker {
        display: none;
        content: "";
    }

    /* --- Preserve colored backgrounds in print --- */
    .kpi-card,
    .quadrant-card,
    .badge,
    .corr-strong-pos,
    .corr-strong-neg,
    .fkr-green,
    .fkr-amber,
    .fkr-red,
    .badge-ideal,
    .badge-inefficient-winner,
    .badge-efficient-loser,
    .badge-failing,
    .badge-active,
    .badge-recently-paused,
    .badge-inactive,
    .badge-scale_now,
    .badge-watch,
    .badge-pause,
    .badge-scale_back,
    .cd-kpi-alert,
    .cd-performer-card,
    .cd-audience-card,
    .cd-audience-alert,
    .cd-bar-fill,
    .cd-brief-card-priority,
    .cd-brief-header-gradient,
    .cd-persona-signal-box,
    .cd-persona-mismatch,
    .cd-copy-methodology,
    .cd-copy-insight,
    .cd-summary-col,
    .quadrant-card.ideal,
    .quadrant-card.inefficient-winner,
    .quadrant-card.efficient-loser,
    .quadrant-card.failing,
    .dashboard-table th {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    /* --- Table improvements --- */
    .dashboard-table {
        border: 0.5pt solid #ccc;
        border-collapse: collapse;
        width: 100%;
        font-size: 10pt;
    }

    .dashboard-table th {
        background: #f0f0f2;
        text-transform: uppercase;
        font-size: 8pt;
        font-weight: 700;
        letter-spacing: 0.3px;
        padding: 4px 8px;
        border: 0.5pt solid #ccc;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .dashboard-table td {
        padding: 4px 8px;
        border: 0.5pt solid #ccc;
    }

    .dashboard-table tr:nth-child(even) {
        background: #fafafa;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .dashboard-table tr {
        page-break-inside: avoid;
    }

    /* Markdown tables in creative analysis */
    .results-content table {
        border-collapse: collapse;
        width: 100%;
        font-size: 10pt;
        margin: 6pt 0;
    }

    .results-content table th {
        background: #f0f0f2;
        text-transform: uppercase;
        font-size: 8pt;
        font-weight: 700;
        letter-spacing: 0.3px;
        padding: 4px 8px;
        border: 0.5pt solid #ccc;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .results-content table td {
        padding: 4px 8px;
        border: 0.5pt solid #ccc;
    }

    .results-content table tr:nth-child(even) {
        background: #fafafa;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .results-content table tr {
        page-break-inside: avoid;
    }

    /* --- Page break rules --- */
    .kpi-row {
        page-break-inside: avoid;
    }

    .quadrant-row {
        page-break-inside: avoid;
    }

    /* Allow ad name to wrap in print */
    .ad-name-cell {
        white-space: normal;
        max-width: 200px;
    }
}

/* ================================================================
   CREATIVE DASHBOARD
   ================================================================ */

/* Tab Navigation */
.cd-tabs {
    display: flex;
    gap: 2px;
    border-bottom: 2px solid #e5e5e5;
    margin-bottom: 20px;
    overflow-x: auto;
}

.cd-tab {
    padding: 10px 18px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    color: #888;
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}

.cd-tab:hover {
    color: #555;
}

.cd-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    font-weight: 600;
}

/* KPI Alert Card */
.cd-kpi-alert {
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cd-kpi-alert.above_target,
.cd-kpi-alert.no_target {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.cd-kpi-alert.near_target {
    background: #fffbeb;
    border: 1px solid #fde68a;
}

.cd-kpi-alert.below_target {
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.cd-kpi-alert-icon {
    font-size: 24px;
}

.cd-kpi-alert-text {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
}

.cd-kpi-alert-text span {
    font-weight: 700;
}

.cd-kpi-alert-body {
    flex: 1;
}

.cd-kpi-alert-headline {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.cd-kpi-alert-detail {
    font-size: 13px;
    color: #555;
    margin-bottom: 4px;
}

.cd-kpi-alert-cta {
    font-size: 13px;
    font-weight: 600;
    color: #b91c1c;
}

.cd-kpi-alert.above_target .cd-kpi-alert-cta {
    color: #15803d;
}

.cd-kpi-alert.near_target .cd-kpi-alert-cta {
    color: #92400e;
}

.cd-kpi-alert.no_target .cd-kpi-alert-cta {
    color: #555;
}

/* Performer Cards */
.cd-performer-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.cd-performer-card {
    padding: 16px;
    border-radius: 12px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.cd-performer-card.rank-1 {
    background: linear-gradient(135deg, #7c3aed, #4f46e5);
}

.cd-performer-card.rank-2 {
    background: linear-gradient(135deg, #2563eb, #0891b2);
}

.cd-performer-card.rank-3 {
    background: linear-gradient(135deg, #0d9488, #059669);
}

.cd-performer-card.waste {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
}

.cd-performer-card-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cd-performer-card-metrics {
    display: flex;
    gap: 16px;
    font-size: 12px;
    opacity: 0.9;
}

.cd-performer-card-metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cd-performer-card-metric-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
}

.cd-performer-card-metric-value {
    font-size: 16px;
    font-weight: 700;
}

/* Audience Cards */
.cd-audience-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.cd-audience-card {
    background: #f8f9fa;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 14px;
}

.cd-audience-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.cd-audience-card-age {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
}

.cd-audience-card-pct {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent);
}

.cd-audience-card-stats {
    font-size: 12px;
    color: #666;
    line-height: 1.6;
}

/* Bar Chart (CSS-only horizontal bars) */
.cd-bar-chart {
    margin: 12px 0;
}

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

.cd-bar-label {
    font-size: 12px;
    font-weight: 500;
    color: #555;
    min-width: 50px;
    text-align: right;
}

.cd-bar-track {
    flex: 1;
    height: 20px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.cd-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--accent);
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    padding-left: 6px;
    font-size: 10px;
    font-weight: 600;
    color: #fff;
    min-width: 0;
}

/* Persona Cards */
.cd-persona-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.cd-persona-card {
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    overflow: hidden;
}

.cd-persona-card-header {
    padding: 14px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cd-persona-card-name {
    font-size: 16px;
    font-weight: 700;
    color: #1a1a1a;
}

.cd-persona-card-age {
    font-size: 12px;
    color: #666;
    margin-left: 8px;
    font-weight: 400;
}

.cd-persona-card-body {
    padding: 14px 16px;
}

.cd-persona-signal {
    font-size: 13px;
    color: #555;
    margin-bottom: 10px;
    font-style: italic;
}

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

.cd-persona-card-body ul {
    margin: 0;
    padding-left: 16px;
    font-size: 13px;
    color: #333;
    line-height: 1.6;
}

/* Brief Cards */
.cd-brief-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.cd-brief-card {
    border: 1px solid #e5e5e5;
    border-radius: 12px;
    overflow: hidden;
}

.cd-brief-card-header {
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cd-brief-card-priority {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
}

.cd-brief-card-priority.P1 { background: #fee2e2; color: #b91c1c; }
.cd-brief-card-priority.P2 { background: #fef3c7; color: #92400e; }
.cd-brief-card-priority.P3 { background: #dbeafe; color: #1d4ed8; }

.cd-brief-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
}

.cd-brief-card-body {
    padding: 14px 16px;
    font-size: 13px;
    color: #333;
}

.cd-brief-field {
    margin-bottom: 8px;
}

.cd-brief-field-label {
    font-weight: 600;
    color: #555;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.cd-brief-dos-donts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 8px 0;
}

.cd-brief-dos-donts ul {
    margin: 4px 0 0;
    padding-left: 16px;
    font-size: 12px;
    line-height: 1.5;
}

.cd-brief-dos h5 { color: #16a34a; font-size: 12px; margin: 0; }
.cd-brief-donts h5 { color: #dc2626; font-size: 12px; margin: 0; }

.cd-brief-headlines {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.cd-brief-headline-chip {
    background: #f0f0f0;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    color: #333;
}

/* KPI Status Badges */
.badge-scale_now,
.badge-scale { background: #dcfce7; color: #15803d; }
.badge-watch { background: #fef3c7; color: #92400e; }
.badge-pause { background: #fee2e2; color: #b91c1c; }
.badge-scale_back { background: #dbeafe; color: #1d4ed8; }
.badge-new { background: #f3f4f6; color: #6b7280; }
.badge-untapped { background: #f3e8ff; color: #7c3aed; }
.badge-core_converter { background: #dcfce7; color: #15803d; }
.badge-engaged { background: #dbeafe; color: #1d4ed8; }
.badge-opportunity { background: #fef3c7; color: #92400e; }

/* Copy Angle Table */
.cd-angle-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 12px;
}

.cd-angle-table th {
    background: #f8f9fa;
    font-weight: 600;
    text-align: left;
    padding: 8px 10px;
    border-bottom: 2px solid #e5e5e5;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #555;
}

.cd-angle-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #f0f0f0;
}

/* Insight items count */
.cd-insight-count {
    font-size: 12px;
    color: #888;
    margin-bottom: 12px;
}

/* Next steps */
.cd-next-steps {
    margin: 12px 0;
    padding-left: 0;
    list-style: none;
    counter-reset: steps;
}

.cd-next-steps li {
    counter-increment: steps;
    padding: 8px 12px 8px 36px;
    position: relative;
    font-size: 13px;
    line-height: 1.5;
    color: #333;
    border-bottom: 1px solid #f0f0f0;
}

.cd-next-steps li::before {
    content: counter(steps);
    position: absolute;
    left: 8px;
    top: 8px;
    width: 20px;
    height: 20px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Winning/Failing insight rows */
.cd-insight-item {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 8px;
}

.cd-insight-item:last-child { border-bottom: none; }

.cd-insight-ad-name {
    font-weight: 600;
    font-size: 13px;
    color: #1a1a1a;
    min-width: 200px;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cd-insight-text {
    font-size: 13px;
    color: #555;
}

/* Three-column summary layout */
.cd-summary-columns {
    display: flex;
    gap: 16px;
    margin: 16px 0;
}

.cd-summary-col {
    flex: 1;
    min-width: 0;
    background: #f8f9fa;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    padding: 14px;
}

.cd-summary-col-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e5e5;
}

.cd-col-winning { color: #15803d; border-bottom-color: #16a34a; }
.cd-col-failing { color: #b91c1c; border-bottom-color: #dc2626; }
.cd-col-steps { color: #1d4ed8; border-bottom-color: #2563eb; }

.cd-summary-col .cd-insight-item {
    flex-direction: column;
    gap: 2px;
}

.cd-summary-col .cd-insight-ad-name {
    min-width: 0;
    max-width: none;
}

.cd-empty-col {
    font-size: 13px;
    color: #999;
    font-style: italic;
}

/* 2x3 KPI Grid for Top Performers */
.cd-kpi-grid-2x3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

/* Threshold alert line */
.cd-threshold-line {
    font-size: 12px;
    color: #888;
    margin-bottom: 16px;
    padding: 6px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid var(--accent);
}

/* Performer card rank badge */
.cd-performer-card-rank {
    font-size: 11px;
    font-weight: 700;
    opacity: 0.7;
    margin-bottom: 4px;
}

/* Performer card description paragraph */
.cd-performer-card-description {
    font-size: 12px;
    line-height: 1.5;
    margin-top: 10px;
    opacity: 0.85;
    border-top: 1px solid rgba(255,255,255,0.2);
    padding-top: 8px;
}

/* Spend cards (neutral gradient) */
.cd-performer-card.cd-spend-card {
    background: linear-gradient(135deg, #374151, #1f2937);
}

/* Audience alert banner */
.cd-audience-alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    font-weight: 500;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-left: 4px solid #d97706;
}

/* Audience card description */
.cd-audience-card-desc {
    font-size: 12px;
    color: #555;
    line-height: 1.5;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e5e5e5;
}

/* Bar chart dollar amount */
.cd-bar-dollars {
    font-size: 12px;
    color: #555;
    font-weight: 500;
    min-width: 60px;
    text-align: right;
}

/* Copy methodology info box */
.cd-copy-methodology {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 12px;
    color: #555;
    background: #f0f4ff;
    border: 1px solid #dbeafe;
    line-height: 1.5;
}

.cd-copy-methodology strong {
    color: #1d4ed8;
}

/* Copy insight narrative card */
.cd-copy-insight {
    padding: 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    background: #f8f9fa;
    border: 1px solid #e5e5e5;
}

.cd-copy-insight-title {
    font-size: 15px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.cd-copy-insight p {
    font-size: 13px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 6px;
}

.cd-copy-insight p:last-child {
    margin-bottom: 0;
}

/* Attribution note (Insights tab) */
.cd-attribution-note {
    font-size: 12px;
    color: #888;
    margin-bottom: 8px;
    padding: 6px 10px;
    background: #f8f9fa;
    border-radius: 6px;
    display: inline-block;
}

/* Persona — gray signal box */
.cd-persona-signal-box {
    font-size: 13px;
    color: #555;
    background: #f3f4f6;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    line-height: 1.5;
}

/* Persona — geography label */
.cd-persona-card-geo {
    display: block;
    font-size: 11px;
    color: #888;
    margin-top: 2px;
}

/* Persona — arrow list (creative recommendations) */
.cd-persona-arrow-list {
    margin: 4px 0 8px;
}

.cd-persona-arrow-item {
    font-size: 13px;
    color: #333;
    line-height: 1.6;
    padding: 2px 0;
}

/* Persona — quoted hooks */
.cd-persona-hooks-list {
    margin: 4px 0 8px;
}

.cd-persona-hook {
    font-size: 13px;
    color: #555;
    font-style: italic;
    padding: 3px 0;
    line-height: 1.5;
}

/* Persona — spend mismatch alert */
.cd-persona-mismatch {
    margin-top: 20px;
    padding: 14px 16px;
    border-radius: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #dc2626;
}

.cd-persona-mismatch-title {
    font-size: 14px;
    font-weight: 700;
    color: #b91c1c;
    margin-bottom: 6px;
}

.cd-persona-mismatch p {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
    margin: 0;
}

/* Brief — numbered gradient header */
.cd-brief-header-gradient {
    background: linear-gradient(135deg, #1e293b, #334155) !important;
    color: #fff;
    padding: 14px 16px !important;
    border-bottom: none !important;
}

.cd-brief-card-number {
    font-size: 28px;
    font-weight: 800;
    opacity: 0.3;
    margin-right: 12px;
    line-height: 1;
}

.cd-brief-card-header-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.cd-brief-header-gradient .cd-brief-card-title {
    color: #fff;
    font-size: 15px;
}

.cd-brief-header-gradient .cd-brief-card-priority {
    align-self: flex-start;
}

/* Brief — angle section */
.cd-brief-angle {
    background: #f3f4f6;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 8px 0;
}

.cd-brief-angle .cd-brief-field-label {
    display: block;
    margin-bottom: 4px;
}

.cd-brief-angle p {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
    margin: 0;
}

/* Share modal */
.cd-share-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.cd-share-modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-width: 480px;
    width: 90%;
}

.cd-share-modal-content h3 {
    margin: 0 0 12px;
    font-size: 16px;
}

.cd-share-url-row {
    display: flex;
    gap: 8px;
}

.cd-share-url-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    background: #f8f8f8;
}

.cd-share-copy-btn {
    padding: 8px 16px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

.cd-share-close-btn {
    margin-top: 12px;
    padding: 6px 16px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

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

@media (max-width: 900px) {
    .kpi-row {
        flex-wrap: wrap;
    }

    .kpi-card {
        flex: 1 1 calc(50% - 8px);
        min-width: 0;
    }

    .quadrant-row {
        grid-template-columns: repeat(2, 1fr);
    }

    .funnel-grid {
        grid-template-columns: 1fr;
    }

    .suggestion-grid {
        grid-template-columns: 1fr;
    }

    .cd-performer-cards {
        grid-template-columns: 1fr;
    }

    .cd-persona-grid {
        grid-template-columns: 1fr;
    }

    .cd-brief-grid {
        grid-template-columns: 1fr;
    }

    .cd-brief-dos-donts {
        grid-template-columns: 1fr;
    }

    .cd-summary-columns {
        flex-direction: column;
    }

    .cd-kpi-grid-2x3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
    }

    body.sidebar-collapsed .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
    }

    .form-row {
        flex-direction: column;
        gap: 12px;
    }
}

@media (max-width: 600px) {
    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .results-content {
        padding: 16px;
    }

    .results-header {
        padding: 10px 16px;
        flex-wrap: wrap;
    }

    .followup-section {
        padding: 12px 16px 16px;
    }

    .followup-msg {
        max-width: 95%;
    }

    .kpi-card {
        flex: 1 1 100%;
    }

    .quadrant-row {
        grid-template-columns: 1fr;
    }

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

    .dashboard-table th,
    .dashboard-table td {
        padding: 5px 6px;
    }

    .chat-input-area {
        padding: 0 12px 12px;
    }

    .suggestion-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   Segment tab — Naming convention performance breakdown
   ============================================================ */

.cd-segments-intro {
    font-size: 13px;
    color: #666;
    margin-bottom: 20px;
    padding: 10px 14px;
    background: #f9f9f9;
    border-radius: 6px;
    border-left: 3px solid #d1d5db;
}

.cd-segments-empty {
    padding: 32px 24px;
    text-align: center;
    color: #666;
}

.cd-segment-section {
    margin-bottom: 32px;
}

.cd-segment-label {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    margin: 0 0 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e5e7eb;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.cd-segment-table {
    width: 100%;
}

.cd-segment-value-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cd-segment-value-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.cd-segment-spend-bar-wrap {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    width: 100%;
    max-width: 260px;
}

.cd-segment-spend-bar {
    height: 100%;
    background: #6366f1;
    border-radius: 2px;
    min-width: 2px;
}

/* ROAS badge coloring relative to account average */
.cd-roas-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

.cd-roas-high {
    background: #d1fae5;
    color: #065f46;
}

.cd-roas-mid {
    background: #fef3c7;
    color: #92400e;
}

.cd-roas-low {
    background: #fee2e2;
    color: #991b1b;
}

/* ============================================================
   Performer card thumbnails
   ============================================================ */

.cd-performer-thumb {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
    display: block;
}

/* ============================================================
   Analysis tab — KPI tiles
   ============================================================ */

.cd-analysis-kpis {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin: 0 0 20px;
}

.cd-analysis-kpi {
    background: #fff;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 10px;
    padding: 16px;
}

.cd-analysis-kpi-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #9ca3af;
    margin-bottom: 6px;
}

.cd-analysis-kpi-val {
    font-size: 22px;
    font-weight: 700;
    color: #111;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.cd-analysis-kpi-sub {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 4px;
}

.cd-analysis-alert {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid #6b7280;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
}

.cd-analysis-alert-head {
    font-size: 14px;
    font-weight: 700;
    color: #111;
    margin-bottom: 4px;
}

.cd-analysis-alert-detail {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.5;
}

.cd-analysis-alert-cta {
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    margin-top: 6px;
}

/* ============================================================
   Analysis tab — narrative markdown renderer
   ============================================================ */

.cd-narrative {
    line-height: 1.7;
}

.cd-sec-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 40px 0 16px;
    padding-top: 8px;
}

.cd-sec-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #111;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.cd-sec-title {
    font-size: 18px;
    font-weight: 700;
    color: #111;
    flex: 1;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 8px;
}

.cd-nar-h3 {
    font-size: 15px;
    font-weight: 600;
    color: #1f2937;
    margin: 20px 0 8px;
}

.cd-nar-p {
    font-size: 14px;
    color: #374151;
    line-height: 1.75;
    margin: 8px 0;
}

.cd-nar-ul,
.cd-nar-ol {
    font-size: 14px;
    color: #374151;
    line-height: 1.75;
    padding-left: 22px;
    margin: 8px 0 12px;
}

.cd-nar-ul li,
.cd-nar-ol li {
    margin-bottom: 4px;
}

.cd-narrative code {
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    font-family: monospace;
}

@media (max-width: 700px) {
    .cd-analysis-kpis {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   Tab bar (Analyze / Create Ads)
   ============================================================ */
.view-tabs {
  display: flex;
  padding: 0 16px;
  border-bottom: 1px solid #e5e5e5;
  background: #fff;
  flex-shrink: 0;
}
.view-tab-btn {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #6b7280;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s;
}
.view-tab-btn:hover { color: #374151; }
.view-tab-btn.active { color: #1e40af; border-bottom-color: #1e40af; font-weight: 600; }

/* ============================================================
   Uploader section (embedded tab)
   ============================================================ */
#uploaderSection { display: none; flex: 1; overflow-y: auto; flex-direction: column; }
.uploader-wrap { max-width: 720px; margin: 0 auto; padding: 24px 16px 80px; }
.uploader-title { font-size: 20px; font-weight: 700; color: #111827; margin-bottom: 4px; }
.uploader-subtitle { font-size: 13px; color: #6b7280; margin-bottom: 24px; }
.up-section { border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; margin-bottom: 16px; }
.up-section-header {
  background: #f1f5f9; padding: 10px 16px;
  font-size: 11px; font-weight: 700; color: #334155;
  text-transform: uppercase; letter-spacing: .05em;
  display: flex; align-items: center; justify-content: space-between;
}
.up-section-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.up-label { font-size: 12px; color: #6b7280; margin-bottom: 4px; }
.up-label span { color: #9ca3af; font-size: 11px; }
.up-input, .up-select {
  width: 100%; box-sizing: border-box;
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 7px 10px; font-size: 13px; color: #374151; font-family: inherit;
}
.up-input:focus, .up-select:focus { outline: none; border-color: #1e40af; background: white; }
.up-textarea {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 52px;
  background: #f9fafb; border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 7px 10px; font-size: 13px; color: #374151; font-family: inherit;
}
.up-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.up-btn {
  background: #1e40af; color: white; border: none; border-radius: 6px;
  padding: 7px 14px; font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.up-btn:hover { background: #1e3a8a; }
.up-btn:disabled { background: #93c5fd; cursor: not-allowed; }
.up-btn-row { display: flex; gap: 8px; align-items: center; }
.up-file-list { border: 1px solid #bfdbfe; border-radius: 6px; background: #eff6ff; padding: 10px 12px; }
.up-file-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #374151; padding: 3px 0; }
.up-file-item.skipped { color: #9ca3af; }
.up-file-item input[type=checkbox] { accent-color: #1e40af; }
.up-file-meta { color: #9ca3af; margin-left: auto; font-size: 11px; }
.up-file-skip { color: #ef4444; margin-left: auto; font-size: 11px; }
.variant-list { display: flex; flex-direction: column; gap: 6px; }
.variant-row { display: flex; gap: 6px; align-items: flex-start; }
.variant-num { font-size: 11px; color: #9ca3af; min-width: 14px; padding-top: 8px; }
.variant-remove { font-size: 16px; color: #9ca3af; cursor: pointer; padding-top: 4px; line-height: 1; }
.variant-remove:hover { color: #ef4444; }
.add-variant { font-size: 12px; color: #1e40af; cursor: pointer; margin-top: 4px; display: inline-block; }
.add-variant:hover { text-decoration: underline; }
.dc-warning {
  background: #fef9c3; border: 1px solid #fde68a; border-radius: 6px;
  padding: 8px 12px; font-size: 12px; color: #92400e; display: none;
}
.name-preview { font-size: 11px; color: #6b7280; margin-top: 4px; }
.name-preview strong { color: #374151; }
.review-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.review-table th { color: #6b7280; border-bottom: 1px solid #e5e7eb; padding: 5px 8px; text-align: left; font-weight: 600; }
.review-table td { padding: 6px 8px; border-bottom: 1px solid #f3f4f6; color: #374151; }
.review-footer { margin-top: 14px; display: flex; align-items: center; justify-content: space-between; }
.review-count { font-size: 12px; color: #6b7280; }
.submit-btn {
  background: #dc2626; color: white; border: none; border-radius: 6px;
  padding: 10px 20px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.submit-btn:hover { background: #b91c1c; }
.submit-btn:disabled { background: #9ca3af; cursor: not-allowed; }
#uploaderProgressView { display: none; max-width: 720px; margin: 0 auto; padding: 24px 16px; }
.progress-title { font-size: 18px; font-weight: 700; color: #111827; margin-bottom: 16px; }
.progress-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f3f4f6; font-size: 13px; }
.progress-file { flex: 1; color: #374151; font-weight: 500; }
.progress-step { color: #6b7280; font-size: 12px; min-width: 100px; }
.progress-status { font-size: 12px; font-weight: 600; min-width: 60px; text-align: right; }
.progress-status.done { color: #16a34a; }
.progress-status.error { color: #dc2626; }
.progress-status.running { color: #1e40af; }
.summary-banner { margin-top: 20px; padding: 14px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; }
.summary-banner.ok { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.summary-banner.partial { background: #fef9c3; color: #92400e; border: 1px solid #fde68a; }
.summary-banner.fail { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.drive-auth-banner {
  background: #fef3c7; border: 1px solid #fde68a; border-radius: 6px;
  padding: 10px 14px; font-size: 12px; color: #92400e; display: none;
  align-items: center; gap: 10px;
}
.drive-auth-banner a { color: #1e40af; font-weight: 600; }

/* Sidebar nav link */
.sidebar-nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; font-size: 13px; color: #9ca3af;
  text-decoration: none; border-radius: 6px; margin: 2px 8px;
}
.sidebar-nav-link:hover { background: var(--sidebar-hover); color: #e5e7eb; }

/* ── Sidebar Reports Section ─────────────────────────────────────────────── */
.sidebar-reports-section {
    border-bottom: 1px solid #2a2a2a;
    flex-shrink: 0;
}

.sidebar-reports-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #1c1c1c;
    border: none;
    color: #e5e7eb;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: color 0.12s;
}

.sidebar-reports-toggle svg { stroke: #007aff; }

.sidebar-reports-toggle:hover { color: #fff; }

.sidebar-reports-chevron {
    margin-left: auto;
    transition: transform 0.2s;
}

.sidebar-reports-toggle.open .sidebar-reports-chevron {
    transform: rotate(180deg);
}

.sidebar-reports-list {
    padding: 4px 8px 8px;
    max-height: 220px;
    overflow-y: auto;
}

.sidebar-reports-empty,
.sidebar-reports-loading {
    padding: 10px 8px;
    font-size: 12px;
    color: #555;
    text-align: center;
}

.sidebar-report-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 6px;
    background: #212121;
    cursor: pointer;
    transition: background 0.12s;
}

.sidebar-report-item:hover { background: var(--sidebar-hover); }

.sidebar-report-title {
    font-size: 12px;
    color: #e5e7eb;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.sidebar-report-date {
    font-size: 11px;
    color: #555;
    flex-shrink: 0;
}

.sidebar-report-pending .sidebar-report-title {
    color: #777;
    font-style: italic;
}

/* ── Report Ready Toast ───────────────────────────────────────────────────── */
.report-ready-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0F1133;
    color: #fff;
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: Inter, sans-serif;
    font-size: 14px;
    z-index: 2000;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.report-ready-toast[hidden] { display: none; }

.report-ready-toast button {
    background: #eeff41;
    color: #0F1133;
    border: none;
    padding: 7px 14px;
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

/* ── Report preview header ────────────────────────────────────────────────── */
.report-preview-header {
    justify-content: space-between;
}

/* ── Sidebar section label (e.g. "Chats") ───────────────────────────────── */
.sidebar-section-label {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ================================================================
   NAV REDESIGN — Analyze tab, stub tabs, tab coming-soon style
   ================================================================ */

.tab-coming-soon {
    color: #bbb !important;
}

.tab-coming-soon:hover {
    color: #999 !important;
}

/* Analyze Tab */
.analyze-tab-section {
    flex: 1;
    flex-direction: column;
    overflow-y: auto;
    padding: 32px 40px;
}

.analyze-tab-header {
    margin-bottom: 24px;
}

.analyze-tab-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
}

.analyze-tab-header p {
    font-size: 14px;
    color: #666;
    margin-top: 4px;
}

.analyze-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    max-width: 900px;
}

.analyze-type-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    background: #ffffff;
    border: 1px solid #e5e5e5;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.analyze-type-card:hover {
    border-color: #007aff;
    box-shadow: 0 2px 10px rgba(0, 122, 255, 0.08);
}

.analyze-type-icon {
    width: 38px;
    height: 38px;
    background: #f5f5f5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #555;
}

.analyze-type-card:hover .analyze-type-icon {
    background: #eaf2ff;
    color: #007aff;
}

.analyze-type-body {
    flex: 1;
}

.analyze-type-name {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
}

.analyze-type-desc {
    font-size: 12px;
    color: #888;
    margin-top: 2px;
}

.analyze-type-arrow {
    color: #ccc;
    flex-shrink: 0;
    transition: color 0.15s;
}

.analyze-type-card:hover .analyze-type-arrow {
    color: #007aff;
}

/* Stub tabs (Generate Ads, Manage Ads) */
.stub-tab-section {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
    padding: 40px;
}

.stub-tab-icon {
    width: 56px;
    height: 56px;
    background: #f0f0f0;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
    margin-bottom: 4px;
}

.stub-tab-badge {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: #f0f0f0;
    color: #888;
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-block;
}

.stub-tab-section h2 {
    font-size: 20px;
    font-weight: 600;
    color: #1a1a1a;
}

.stub-tab-section p {
    font-size: 14px;
    color: #666;
    max-width: 360px;
    line-height: 1.6;
}

/* ================================================================
   ANALYZE TAB — Inline config panel
   ================================================================ */

.analyze-type-card.aic-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}

.analyze-type-card.aic-selected .analyze-type-icon {
    background: #eaf2ff;
    color: var(--accent);
}

.analyze-type-card.aic-selected .analyze-type-arrow {
    color: var(--accent);
    transform: rotate(90deg);
}

/* Analyze tab section dividers */
.analyze-section-label {
    font-size: 10px;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0 8px;
    grid-column: 1 / -1;
}

.analyze-section-label.google {
    color: #34a853;
}

.analyze-section-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e0e0e0;
}

.analyze-section-label.google::after {
    background: #ceead6;
}

/* Google analysis cards */
.analyze-type-card.google-card {
    border-color: #ceead6;
    background: #f8fdf9;
}

.analyze-type-card.google-card .analyze-type-icon {
    background: #e6f4ea;
    color: #34a853;
}

/* Dimmed state (not connected) */
.analyze-type-card.dimmed {
    opacity: 0.45;
    pointer-events: none;
}

.analyze-card-wrapper {
    position: relative;
}

.analyze-card-not-connected {
    position: absolute;
    inset: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

/* Gated state (coming soon) */
.analyze-type-card.gated {
    opacity: 0.7;
    cursor: default;
    pointer-events: none;
}

.analyze-card-gated-label {
    font-size: 10px;
    color: #888;
    margin-top: 2px;
}

.aic-wrapper {
    max-width: 900px;
    background: #ffffff;
    border: 1px solid var(--accent);
    border-radius: 12px;
    margin-top: 12px;
    padding: 24px;
    box-shadow: 0 4px 16px rgba(0,122,255,0.07);
}

.aic-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
    margin-bottom: 20px;
}

.aic-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.aic-field.aic-full {
    grid-column: 1 / -1;
}

.aic-field--full {
    grid-column: 1 / -1;
}

/* Module card grid */
.module-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.module-card {
    border: 1.5px solid #e5e5e5;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    position: relative;
    background: #fff;
    user-select: none;
}

.module-card:hover {
    border-color: var(--accent);
    background: #f0f5ff;
}

.module-card--selected {
    border-color: var(--accent);
    background: #f0f5ff;
}

.module-card--selected::after {
    content: "✓";
    position: absolute;
    top: 7px;
    right: 9px;
    font-size: 10px;
    color: var(--accent);
    font-weight: 700;
}

.module-card__icon {
    font-size: 16px;
    line-height: 1;
    margin-bottom: 5px;
}

.module-card__name {
    font-size: 12px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.module-card__desc {
    font-size: 11px;
    color: #999;
    line-height: 1.35;
}

.aic-field label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.aic-hint {
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #aaa;
}

.aic-field select,
.aic-field input,
.aic-field textarea {
    padding: 9px 12px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    font-size: 14px;
    background: #ffffff;
    color: #1a1a1a;
    font-family: inherit;
    transition: border-color 0.15s;
}

.aic-field select:focus,
.aic-field input:focus,
.aic-field textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.aic-field textarea {
    resize: vertical;
}

.aic-info {
    font-size: 13px;
    color: #666;
    line-height: 1.6;
    background: #f8f8f8;
    border-radius: 8px;
    padding: 12px 14px;
}

.aic-info code {
    font-size: 12px;
    background: #ebebeb;
    padding: 2px 5px;
    border-radius: 4px;
}

.aic-toggle {
    display: flex;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
}

.aic-toggle-btn {
    flex: 1;
    padding: 9px 12px;
    background: transparent;
    border: none;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}

.aic-toggle-btn + .aic-toggle-btn {
    border-left: 1px solid #e5e5e5;
}

.aic-toggle-btn.active {
    background: var(--accent);
    color: #ffffff;
    font-weight: 500;
}

.aic-toggle-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.aic-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.aic-run-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.15s;
}

.aic-run-btn:hover { opacity: 0.88; }

.aic-cancel-btn {
    background: transparent;
    border: none;
    font-size: 13px;
    color: #999;
    cursor: pointer;
    padding: 10px 8px;
    font-family: inherit;
}

.aic-cancel-btn:hover { color: #1a1a1a; }

.aic-cache-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    margin-left: auto;
}

/* ──────────────────────────────────────────────
   Ad Uploader v2 — Preset bar, toggles, launch status, partnership
   ────────────────────────────────────────────── */

/* Preset bar */
.preset-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 10px 16px; margin-bottom: 16px;
}
.preset-bar-label { font-size: 11px; font-weight: 700; color: #6b7280;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.preset-bar-save { font-size: 12px; color: #4f46e5; font-weight: 500;
  cursor: pointer; border: 1px solid #c7d2fe; border-radius: 5px;
  padding: 5px 10px; white-space: nowrap; }
.preset-bar-save:hover { background: #eef2ff; }
.preset-save-input { display: flex; align-items: center; gap: 6px; flex: 1; }
.preset-bar-error { color: #dc2626; font-size: 12px; width: 100%; }
.up-btn-secondary { background: transparent; border: 1px solid #d1d5db;
  border-radius: 5px; padding: 6px 10px; font-size: 13px; cursor: pointer; color: #374151; }
.up-btn-secondary:hover { background: #f9fafb; }

/* Toggle switch */
.up-toggle { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.up-toggle input { opacity: 0; width: 0; height: 0; }
.up-slider { position: absolute; inset: 0; background: #d1d5db;
  border-radius: 10px; cursor: pointer; transition: background .2s; }
.up-slider::before { content: ''; position: absolute; width: 14px; height: 14px;
  left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.up-toggle input:checked + .up-slider { background: #4f46e5; }
.up-toggle input:checked + .up-slider::before { transform: translateX(16px); }

/* Toggle list */
.toggle-list { display: flex; flex-direction: column; }
.toggle-item { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid #f3f4f6; }
.toggle-item:last-child { border-bottom: none; }
.toggle-text { font-size: 13px; color: #374151; }
.toggle-text small { display: block; font-size: 11px; color: #9ca3af; margin-top: 2px; }

/* Launch status */
.launch-status-row { display: flex; gap: 8px; }
.launch-opt { flex: 1; border: 1px solid #d1d5db; border-radius: 6px;
  padding: 8px 12px; font-size: 13px; color: #6b7280; cursor: pointer;
  background: #fff; text-align: center; font-family: inherit; }
.launch-opt.selected { border-color: #4f46e5; color: #4f46e5;
  background: #eef2ff; font-weight: 600; }
.launch-opt:hover:not(.selected) { background: #f9fafb; }

/* Partnership */
.partnership-toggle-row { display: flex; align-items: center; justify-content: space-between; }

/* YouTube fatigue badges */
.youtube-fatigue-badge {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    margin-left: 6px;
}

.youtube-fatigue-badge.high {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

/* Knowledge Base Tab */
.kb-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding: 16px;
}
.kb-card {
    background: var(--card-bg, #1a1a2e);
    border: 1px solid var(--border-color, #2a2a4a);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: border-color 0.2s;
}
.kb-card:hover { border-color: var(--accent-color, #7c3aed); }
.kb-card-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.kb-platform { font-size: 12px; text-transform: uppercase; opacity: 0.6; }
.kb-badge { font-size: 11px; padding: 2px 8px; border-radius: 12px; }
.kb-badge-curated { background: #1e40af; color: #fff; }
.kb-badge-monitored { background: #374151; color: #d1d5db; }
.kb-stale-badge { font-size: 11px; color: #f59e0b; }
.kb-card-type { font-size: 12px; opacity: 0.6; margin-bottom: 6px; text-transform: capitalize; }
.kb-category { font-size: 11px; background: rgba(124,58,237,0.15); color: #a78bfa; padding: 2px 6px; border-radius: 10px; margin-right: 4px; }
.kb-hook { font-size: 14px; font-weight: 500; margin: 8px 0; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kb-takeaways { font-size: 13px; opacity: 0.75; padding-left: 16px; margin: 4px 0; }
.kb-takeaways li { margin-bottom: 4px; }
.kb-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.kb-source-link { font-size: 12px; opacity: 0.5; text-decoration: none; }
.kb-source-link:hover { opacity: 1; }
.kb-used-btn { font-size: 12px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--border-color, #2a2a4a); background: transparent; cursor: pointer; color: inherit; }
.kb-used-btn:hover { background: rgba(124,58,237,0.15); }
.kb-empty { text-align: center; padding: 60px 24px; opacity: 0.5; }
.kb-header { padding: 16px; border-bottom: 1px solid var(--border-color, #2a2a4a); }
.kb-search-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.kb-search-bar input { flex: 1; padding: 8px 12px; border-radius: 6px; border: 1px solid var(--border-color, #2a2a4a); background: var(--input-bg, #0f0f23); color: inherit; }
.kb-filters { display: flex; gap: 8px; }
.kb-filters select { padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border-color, #2a2a4a); background: var(--input-bg, #0f0f23); color: inherit; font-size: 13px; }
#kb-load-more { text-align: center; padding: 16px; }
#kb-load-more-btn { padding: 8px 24px; border-radius: 6px; border: 1px solid var(--border-color, #2a2a4a); background: transparent; cursor: pointer; color: inherit; }
@media (max-width: 900px) { .kb-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .kb-grid { grid-template-columns: 1fr; } }

/* === Snipe Hierarchy === */

/* Browse/Paste segmented toggle */
.snipe-mode-toggle { display:flex; background:#efefef; border-radius:8px; padding:3px; gap:3px; }
.snipe-mode-btn { flex:1; border-radius:6px; padding:7px; text-align:center; font-size:13px; color:#888; cursor:pointer; user-select:none; }
.snipe-mode-btn.active { background:#fff; font-weight:600; color:#007aff; box-shadow:0 1px 3px rgba(0,0,0,0.1); }

/* Searchable dropdown panel */
.snipe-dropdown { position:relative; }
.snipe-dropdown-trigger { background:#fff; border:1px solid #ddd; border-radius:8px; padding:8px 12px; font-size:14px; color:#111; display:flex; justify-content:space-between; align-items:center; cursor:pointer; user-select:none; }
.snipe-dropdown-trigger.open { border-color:#007aff; }
.snipe-dropdown-trigger.disabled { opacity:0.5; cursor:not-allowed; }
.snipe-dropdown-panel { position:absolute; top:calc(100% + 4px); left:0; right:0; background:#fff; border:1px solid #ddd; border-radius:8px; box-shadow:0 4px 16px rgba(0,0,0,0.12); z-index:100; overflow:hidden; max-height:300px; display:none; flex-direction:column; }
.snipe-dropdown-panel.open { display:flex; }
.snipe-dropdown-search { padding:8px 12px; border:none; border-bottom:1px solid #eee; font-size:13px; outline:none; }
.snipe-dropdown-list { overflow-y:auto; }
.snipe-dropdown-item { padding:9px 12px; font-size:13px; cursor:pointer; display:flex; justify-content:space-between; align-items:center; }
.snipe-dropdown-item:hover { background:#f5f5f5; }
.snipe-dropdown-item.selected { font-weight:600; color:#007aff; }
.snipe-dropdown-item.inactive { color:#aaa; }
.snipe-dropdown-item .item-meta { font-size:11px; color:#aaa; }

/* Status badges */
.status-badge { font-size:11px; padding:2px 6px; border-radius:4px; font-weight:500; }
.status-badge.active { background:#dcfce7; color:#166534; }
.status-badge.paused { background:#fef3c7; color:#92400e; }
.status-badge.unknown { background:#f3f4f6; color:#6b7280; }

/* Scope summary bar */
.snipe-scope-bar { background:#f0f7ff; border:1px solid #bfdbfe; border-radius:8px; padding:10px 14px; color:#1d4ed8; font-size:13px; display:none; }
.snipe-scope-bar.visible { display:block; }
.snipe-scope-bar.warning { background:#fffbe6; border-color:#fbbf24; color:#92400e; }

/* Status warning banner */
.snipe-status-warning { background:#fef3c7; border:1px solid #fcd34d; border-radius:8px; padding:8px 12px; font-size:13px; color:#92400e; display:none; margin-bottom:8px; }
.snipe-status-warning.visible { display:block; }

/* Loading/error states */
.snipe-hierarchy-error { color:#dc2626; font-size:13px; padding:8px 0; display:none; }
.snipe-hierarchy-error.visible { display:block; }
