/* ==========================================================================
   RoB - Research & Opportunity Builder
   Telekom Scale Design System — Dark Theme
   ========================================================================== */

/* ---------- Design Tokens ---------- */
:root {
    --rob-sidebar-width: 280px;
    --rob-header-height: 52px;
    --rob-magenta: #E20074;
    --rob-magenta-hover: #c80066;
    --rob-magenta-dim: rgba(226, 0, 116, 0.12);
    --rob-bg: #0F0F0F;
    --rob-bg-card: #1A1A1A;
    --rob-bg-sidebar: #141414;
    --rob-bg-elevated: #222;
    --rob-border: #2A2A2A;
    --rob-border-light: #333;
    --rob-text: #D4D4D4;
    --rob-text-bright: #F0F0F0;
    --rob-text-muted: #888;
    --rob-text-dim: #555;
    --rob-radius: 8px;
    --rob-radius-sm: 6px;
}

[x-cloak] { display: none !important; }

body {
    margin: 0;
    padding: 0;
    background: var(--rob-bg);
    color: var(--rob-text);
    font-family: TeleNeoWeb, "Helvetica Neue", Helvetica, Arial, sans-serif;
    min-height: 100vh;
    overflow: hidden;
}

/* ---------- App Header ---------- */
.app-header {
    height: var(--rob-header-height);
    background: linear-gradient(135deg, #E20074 0%, #B8005E 100%);
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 100;
}

.app-header-inner {
    display: flex;
    align-items: center;
    width: 100%;
}

.app-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.t-logo {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
}

.app-header-title {
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.03em;
}

.app-header-subtitle {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.75);
    font-weight: 400;
    margin-left: 4px;
}

/* ---------- Header Feedback Button ---------- */
.header-feedback-btn {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    padding: 5px 12px;
    border-radius: var(--rob-radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.header-feedback-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ---------- Admin Modal ---------- */
.admin-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.admin-modal {
    background: var(--rob-bg-card);
    border: 1px solid var(--rob-border);
    border-radius: var(--rob-radius);
    width: 100%;
    max-width: 850px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px -12px rgba(0, 0, 0, 0.6);
}

.admin-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--rob-border);
}

.admin-modal-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--rob-text-bright);
}

.admin-close-btn {
    background: none;
    border: none;
    color: var(--rob-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s;
}

.admin-close-btn:hover {
    color: var(--rob-text-bright);
}

.admin-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
}

.admin-login {
    text-align: center;
    padding: 40px 20px;
}
.admin-login-label {
    color: var(--rob-text-dim);
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.admin-login-form {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}
.admin-password-input {
    background: var(--rob-surface);
    border: 1px solid var(--rob-border);
    color: var(--rob-text);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    width: 220px;
    outline: none;
}
.admin-password-input:focus {
    border-color: var(--rob-magenta);
}
.admin-login-btn {
    background: var(--rob-magenta);
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}
.admin-login-btn:hover {
    opacity: 0.9;
}
.admin-login-error {
    color: #e74c3c;
    margin-top: 12px;
    font-size: 0.85rem;
}

.share-modal {
    background: var(--rob-surface);
    border-radius: var(--rob-radius);
    width: 500px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.share-modal-body {
    padding: 16px 20px 20px;
}
.share-modal-label {
    color: var(--rob-text-dim);
    font-size: 0.85rem;
    margin-bottom: 12px;
}
.share-url-row {
    display: flex;
    gap: 8px;
}
.share-url-input {
    flex: 1;
    background: var(--rob-bg);
    border: 1px solid var(--rob-border);
    color: var(--rob-text);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
}
.share-url-input:focus {
    border-color: var(--rob-magenta);
}

.admin-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--rob-text-dim);
    font-size: 0.9rem;
    font-style: italic;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.admin-table thead th {
    text-align: left;
    padding: 10px 12px;
    color: var(--rob-text-bright);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--rob-magenta);
    background: rgba(226, 0, 116, 0.08);
}

.admin-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--rob-border);
    color: var(--rob-text);
    vertical-align: top;
}

.admin-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.admin-td-date {
    white-space: nowrap;
    color: var(--rob-text-muted);
    font-size: 0.75rem;
}

.admin-td-comment {
    max-width: 300px;
    word-break: break-word;
}

.rating-good {
    font-size: 1.1rem;
}

.rating-bad {
    font-size: 1.1rem;
}

/* ---------- Layout ---------- */
.app-layout {
    display: grid;
    grid-template-columns: var(--rob-sidebar-width) 1fr;
    height: calc(100vh - var(--rob-header-height));
}

/* ---------- Sidebar ---------- */
.sidebar {
    background: var(--rob-bg-sidebar);
    border-right: 1px solid var(--rob-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--rob-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--rob-text-bright);
}

.new-research-btn {
    background: var(--rob-magenta-dim);
    border: 1px solid rgba(226, 0, 116, 0.3);
    color: var(--rob-magenta);
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--rob-radius-sm);
    cursor: pointer;
    transition: all 0.15s;
}

.new-research-btn:hover {
    background: var(--rob-magenta);
    color: #fff;
}

/* ---------- Filter Toggle ---------- */
.filter-bar {
    padding: 10px 16px 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-toggle {
    display: flex;
    background: var(--rob-bg);
    border-radius: var(--rob-radius-sm);
    padding: 2px;
    gap: 2px;
}

.filter-btn {
    flex: 1;
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    background: transparent;
    color: var(--rob-text-muted);
}

.filter-btn:hover {
    color: var(--rob-text-bright);
}

.filter-btn--active {
    background: var(--rob-magenta);
    color: #fff;
}

.filter-count {
    font-size: 0.7rem;
    color: var(--rob-text-dim);
    text-align: right;
}

.history-search-input {
    width: 100%;
    background: var(--rob-bg);
    border: 1px solid var(--rob-border);
    color: var(--rob-text);
    padding: 6px 10px;
    border-radius: var(--rob-radius-sm);
    font-size: 0.75rem;
    outline: none;
    box-sizing: border-box;
}
.history-search-input:focus {
    border-color: var(--rob-magenta);
}
.history-search-input::placeholder {
    color: var(--rob-text-dim);
}

/* ---------- History List ---------- */
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px 10px;
}

.history-item {
    padding: 10px 12px;
    border-radius: var(--rob-radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 2px;
    border-left: 3px solid transparent;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.history-item--active {
    background: var(--rob-magenta-dim);
    border-left-color: var(--rob-magenta);
}

.history-item--failed {
    opacity: 0.4;
}

.history-item-query {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--rob-text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
    font-size: 0.7rem;
    color: var(--rob-text-dim);
}

/* Status badges */
.status-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-badge--completed {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.status-badge--failed {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.status-badge--running {
    background: rgba(250, 204, 21, 0.15);
    color: #fbbf24;
}

.history-item {
    position: relative;
}
.history-item-actions {
    display: none;
    position: absolute;
    top: 6px;
    right: 6px;
    gap: 4px;
    align-items: center;
}
.history-item:hover .history-item-actions {
    display: flex;
}
.history-action-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 4px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.15s, background 0.15s;
}
.history-action-btn:hover {
    opacity: 1;
}
.history-action-btn--abort {
    color: #fbbf24;
}
.history-action-btn--abort:hover {
    background: rgba(251, 191, 36, 0.2);
}
.history-action-btn--rerun {
    color: #38bdf8;
}
.history-action-btn--rerun:hover {
    background: rgba(56, 189, 248, 0.2);
}
.history-action-btn--delete {
    color: #f87171;
}
.history-action-btn--delete:hover {
    background: rgba(248, 113, 113, 0.2);
}

.history-empty {
    padding: 24px 16px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--rob-text-dim);
    font-style: italic;
}

/* ---------- Sidebar Footer / Feedback ---------- */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--rob-border);
}

.feedback-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: none;
    border: none;
    color: var(--rob-text-dim);
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 0;
}

.feedback-toggle:hover { color: var(--rob-text-bright); }

.feedback-form { margin-top: 10px; }

.feedback-inner {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.feedback-rate-btn {
    flex: 1;
    padding: 5px;
    border: 1px solid var(--rob-border);
    border-radius: var(--rob-radius-sm);
    background: transparent;
    color: var(--rob-text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
}

.feedback-rate-btn:hover {
    border-color: var(--rob-text-muted);
}

.feedback-rate-btn--good {
    background: rgba(34, 197, 94, 0.15);
    border-color: #4ade80;
    color: #4ade80;
}

.feedback-rate-btn--bad {
    background: rgba(239, 68, 68, 0.15);
    border-color: #f87171;
    color: #f87171;
}

.feedback-textarea {
    width: 100%;
    background: var(--rob-bg);
    border: 1px solid var(--rob-border);
    border-radius: var(--rob-radius-sm);
    padding: 8px;
    font-size: 0.75rem;
    color: var(--rob-text);
    resize: vertical;
    font-family: inherit;
    box-sizing: border-box;
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--rob-magenta);
}

.feedback-send-btn {
    width: 100%;
    padding: 6px;
    border: none;
    border-radius: var(--rob-radius-sm);
    background: var(--rob-magenta);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.feedback-send-btn:hover { background: var(--rob-magenta-hover); }
.feedback-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.feedback-thanks {
    text-align: center;
    padding: 10px 0;
    font-size: 0.75rem;
    color: var(--rob-magenta);
}

/* ---------- Main Content ---------- */
.main-content {
    overflow-y: auto;
    padding: 20px 28px;
}

.content-wrapper {
    max-width: 960px;
    margin: 0 auto;
}

/* ---------- Card ---------- */
.card {
    background: var(--rob-bg-card);
    border: 1px solid var(--rob-border);
    border-radius: var(--rob-radius);
    padding: 20px;
    margin-bottom: 16px;
}

/* ---------- Buttons ---------- */
.btn-primary {
    padding: 10px 24px;
    border: none;
    border-radius: var(--rob-radius-sm);
    background: var(--rob-magenta);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.btn-primary:hover { background: var(--rob-magenta-hover); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
    padding: 8px 16px;
    border: 1px solid var(--rob-border-light);
    border-radius: var(--rob-radius-sm);
    background: transparent;
    color: var(--rob-text);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-secondary:hover {
    border-color: var(--rob-text-muted);
    background: rgba(255, 255, 255, 0.04);
}

.btn-magenta {
    padding: 8px 16px;
    border: none;
    border-radius: var(--rob-radius-sm);
    background: var(--rob-magenta);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
}

.btn-magenta:hover { background: var(--rob-magenta-hover); }

.btn-sm {
    padding: 5px 12px;
    font-size: 0.75rem;
}

.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Spinner ---------- */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ---------- Search Card ---------- */
.search-card {
    padding: 16px 20px;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.search-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.search-input {
    flex: 1;
}

.search-actions {
    display: flex;
    gap: 10px;
}

.research-btn {
    flex: 1;
}

/* ---------- Empty State ---------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 40px;
    opacity: 0.7;
}

.empty-state-icon {
    margin-bottom: 20px;
}

.empty-state-title {
    margin: 0 0 8px;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--rob-text-bright);
}

.empty-state-text {
    margin: 0;
    font-size: 0.85rem;
    color: var(--rob-text-muted);
    max-width: 420px;
    line-height: 1.6;
}

/* ---------- Session Panel ---------- */
.session-panel {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
}

.section-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--rob-text-bright);
}

.session-id {
    font-size: 0.65rem;
    color: var(--rob-text-dim);
    font-family: monospace;
}

/* ---------- Error Card ---------- */
.error-card {
    margin-top: 14px;
    padding: 14px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: var(--rob-radius-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.error-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.error-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    font-weight: 800;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.error-text strong {
    display: block;
    color: #f87171;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.error-text p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--rob-text-muted);
    line-height: 1.4;
}

.retry-btn {
    flex-shrink: 0;
}

.error-banner {
    padding: 12px 16px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--rob-radius-sm);
    color: #f87171;
    font-size: 0.85rem;
}

/* ---------- Log Container ---------- */
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.log-container {
    background: var(--rob-bg);
    border: 1px solid var(--rob-border);
    border-radius: var(--rob-radius-sm);
    padding: 14px;
    max-height: 260px;
    overflow-y: auto;
    font-family: "Courier New", monospace;
    font-size: 0.72rem;
}

.log-entry { margin-bottom: 8px; }
.log-time { color: var(--rob-text-dim); }

.log-title {
    font-weight: 700;
    margin-left: 8px;
}

.log-info { color: #5bc0eb; }
.log-success { color: #4ecdc4; }
.log-warning { color: #ffe066; }
.log-error { color: #ff6b6b; }

.log-message {
    color: var(--rob-text-muted);
    margin-top: 2px;
    margin-left: 56px;
    word-break: break-word;
}

.show-log-link { padding: 2px 0; }

.link-magenta {
    color: var(--rob-magenta);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.link-magenta:hover {
    text-decoration: underline;
}

/* ---------- Results ---------- */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.results-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.view-toggle {
    display: flex;
    background: var(--rob-bg);
    border-radius: var(--rob-radius-sm);
    padding: 2px;
    gap: 2px;
}

.download-buttons {
    display: flex;
    gap: 6px;
}

/* ---------- Report Rendered (Markdown Prose) ---------- */
.report-rendered {
    padding: 8px 0;
    line-height: 1.75;
    color: var(--rob-text);
}

.report-rendered h1 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--rob-text-bright);
    margin: 28px 0 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--rob-magenta);
}

.report-rendered h2 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--rob-text-bright);
    margin: 24px 0 10px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--rob-border);
}

.report-rendered h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--rob-text-bright);
    margin: 18px 0 8px;
}

.report-rendered h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--rob-text);
    margin: 14px 0 6px;
}

.report-rendered p { margin: 0 0 12px; }

.report-rendered a {
    color: var(--rob-magenta);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.report-rendered a:hover { color: #ff3399; }

.report-rendered strong {
    color: var(--rob-text-bright);
    font-weight: 700;
}

.report-rendered ul, .report-rendered ol {
    margin: 0 0 12px;
    padding-left: 22px;
}

.report-rendered li { margin-bottom: 4px; }

.report-rendered blockquote {
    border-left: 3px solid var(--rob-magenta);
    margin: 14px 0;
    padding: 10px 16px;
    background: var(--rob-magenta-dim);
    border-radius: 0 var(--rob-radius-sm) var(--rob-radius-sm) 0;
    color: var(--rob-text);
}

.report-rendered table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-size: 0.825rem;
}

.report-rendered thead th {
    background: rgba(226, 0, 116, 0.12);
    color: var(--rob-text-bright);
    font-weight: 700;
    text-align: left;
    padding: 9px 12px;
    border-bottom: 2px solid var(--rob-magenta);
}

.report-rendered tbody td {
    padding: 7px 12px;
    border-bottom: 1px solid var(--rob-border);
    vertical-align: top;
}

.report-rendered tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.report-rendered code {
    background: rgba(255, 255, 255, 0.07);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.83em;
    font-family: "Courier New", monospace;
}

.report-rendered pre {
    background: var(--rob-bg);
    border: 1px solid var(--rob-border);
    border-radius: var(--rob-radius-sm);
    padding: 14px;
    overflow-x: auto;
    margin: 14px 0;
}

.report-rendered pre code {
    background: none;
    padding: 0;
}

.report-rendered hr {
    border: none;
    border-top: 1px solid var(--rob-border);
    margin: 22px 0;
}

/* ---------- Report Raw ---------- */
.report-raw {
    background: var(--rob-bg);
    border: 1px solid var(--rob-border);
    border-radius: var(--rob-radius-sm);
    padding: 14px;
    font-size: 0.72rem;
    color: var(--rob-text-muted);
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ---------- Citations ---------- */
.citation {
    display: inline-block;
    background: var(--rob-magenta);
    color: white !important;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 2px;
    cursor: pointer;
    text-decoration: none !important;
    transition: background 0.15s;
    vertical-align: super;
    line-height: 1;
}

.citation:hover { background: var(--rob-magenta-hover); }

/* ---------- Source Tooltip ---------- */
.source-tooltip {
    position: fixed;
    background: var(--rob-bg-elevated);
    border: 1px solid var(--rob-magenta);
    padding: 12px 14px;
    border-radius: var(--rob-radius);
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    max-width: 340px;
    font-size: 0.8rem;
    pointer-events: none;
    line-height: 1.4;
}

.tooltip-title {
    font-weight: 700;
    color: var(--rob-magenta);
    margin-bottom: 6px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--rob-border);
}

.tooltip-url {
    color: var(--rob-text-dim);
    font-size: 0.68rem;
    word-break: break-all;
    font-style: italic;
}

/* ---------- Custom Scrollbar ---------- */
.custom-scrollbar::-webkit-scrollbar { width: 5px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: #2A2A2A; border-radius: 3px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: #444; }

/* ---------- Scale Component Overrides (Dark Mode) ---------- */
scale-text-field {
    --scl-color-background: var(--rob-bg-card);
}

scale-progress-bar {
    --scl-color-primary: var(--rob-magenta);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .app-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .sidebar {
        max-height: 35vh;
        border-right: none;
        border-bottom: 1px solid var(--rob-border);
    }

    .main-content { padding: 14px; }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .results-actions { width: 100%; }
    .download-buttons { flex-wrap: wrap; }

    .app-header-subtitle { display: none; }

    .ab-grid { grid-template-columns: 1fr !important; }
}

/* ---------- A/B testing UI ---------- */
.ab-mode-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 10px 0 0 0;
    flex-wrap: wrap;
}

.ab-mode-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    cursor: pointer;
}

.ab-mode-label input[type="radio"] { accent-color: var(--rob-magenta); }

.ab-mode-badge {
    font-size: 12px;
    color: var(--rob-magenta);
    padding: 2px 8px;
    border: 1px solid var(--rob-magenta);
    border-radius: 4px;
    background: rgba(226, 0, 116, 0.05);
}

.ab-results-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ab-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.ab-column {
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.ab-column-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.ab-column-header .section-title { margin: 0; }

.ab-status-pill {
    font-size: 11px;
    padding: 2px 10px;
    border-radius: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ab-status-running { background: #fff8e1; color: #b8860b; border: 1px solid #ffc107; }
.ab-status-completed { background: #e6f4ea; color: #1e7c3a; border: 1px solid #2ea44f; }
.ab-status-failed { background: #fdecea; color: #c62828; border: 1px solid #e53935; }

.ab-duration {
    font-size: 12px;
    color: var(--rob-text-muted, #666);
    margin-left: auto;
}

.ab-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.ab-actions .btn-sm { font-size: 12px; padding: 4px 10px; }

.ab-running {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 30px;
    justify-content: center;
    color: var(--rob-text-muted, #666);
}

.ab-grounding {
    margin-top: 12px;
    border-top: 1px solid var(--rob-border);
    padding-top: 10px;
}

.ab-grounding summary {
    cursor: pointer;
    font-size: 13px;
    color: var(--rob-text-muted, #666);
}

.ab-grounding-iframe {
    width: 100%;
    height: 80px;
    border: none;
    margin-top: 8px;
}

.ab-metrics-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}

.ab-metrics-table th,
.ab-metrics-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--rob-border);
}

.ab-metrics-table th {
    font-weight: 600;
    color: var(--rob-text-muted, #666);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ab-metric-winner {
    background: rgba(46, 164, 79, 0.08);
    font-weight: 600;
    color: #1e7c3a;
}

.ab-feedback-card .ab-winner-buttons {
    display: flex;
    gap: 8px;
    margin: 12px 0;
    flex-wrap: wrap;
}

.ab-feedback-textarea {
    width: 100%;
    margin: 8px 0;
    padding: 8px;
    border: 1px solid var(--rob-border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
}

.admin-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}

.admin-subtitle {
    margin: 16px 0 8px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--rob-text-muted, #666);
}

.admin-provider-tag,
.admin-winner-tag {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-provider-tag { background: #eef; color: #334; }
.admin-winner-tag { background: #f5e8ff; color: #6a1b9a; }
