/* Research tool (Tools > Research) — local SearXNG + DGX Spark LLM */

.rs-page {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    min-width: 0;
}

/* === Split-inline topbar (vision: logo · name · tagline ......... About · health) === */
.rs-topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    margin: 0 0 14px;
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
    border: 1px solid rgba(255,255,255,0.08);
    min-width: 0;
}
.rs-topbar-brand {
    display: inline-flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}
.rs-brand-logo {
    width: 40px; height: 40px;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.35), 0 0 0 1px rgba(255,255,255,0.06);
    object-fit: contain;
    flex-shrink: 0;
}
.rs-topbar-name {
    margin: 0;
    font-size: 18px; font-weight: 700;
    letter-spacing: -0.01em;
    color: #fff;
    line-height: 1.1;
    white-space: nowrap;
}
.rs-topbar-sep {
    color: var(--text-muted, #9aa3b2);
    font-size: 16px;
    flex-shrink: 0;
}
.rs-topbar-tagline {
    margin: 0;
    color: #c7d2fe;
    font-size: 13px; font-weight: 500;
    white-space: nowrap;
    min-width: 0;
    overflow: hidden; text-overflow: ellipsis;
}
.rs-topbar-spacer { flex: 1; min-width: 0; }

/* About popover — uses native <details> for zero-JS behavior. */
.rs-topbar-about { position: relative; }
.rs-topbar-about summary {
    list-style: none; cursor: pointer;
    padding: 6px 12px;
    font-size: 12px; font-weight: 600;
    color: #c7d2fe;
    background: rgba(99,102,241,0.12);
    border: 1px solid rgba(99,102,241,0.35);
    border-radius: 999px;
    user-select: none;
}
.rs-topbar-about summary::-webkit-details-marker { display: none; }
.rs-topbar-about summary:hover { background: rgba(99,102,241,0.22); }
.rs-topbar-about-pop {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: min(340px, 90vw);
    padding: 14px 16px;
    background: rgba(20, 22, 32, 0.97);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    box-shadow: 0 12px 28px rgba(0,0,0,0.45);
    z-index: 50;
}
.rs-topbar-about-pop p { margin: 0 0 8px; font-size: 13px; line-height: 1.55; color: #cbd5e1; }
.rs-topbar-about-pop p:last-child { margin-bottom: 0; }
.rs-topbar-about-pop strong { color: #fff; }
.rs-health { display: flex; gap: 8px; font-size: 12px; }
.rs-health .pill {
    padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
}
.rs-health .pill.ok { color: #4ade80; border-color: rgba(74,222,128,0.4); }
.rs-health .pill.bad { color: #f87171; border-color: rgba(248,113,113,0.4); }

.rs-layout {
    display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 20px; align-items: start;
}
@media (max-width: 900px) {
    .rs-layout { grid-template-columns: 1fr; }
}

.rs-history {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px; padding: 12px; max-height: 70vh; overflow-y: auto;
}
.rs-history-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
}
.rs-history-title { font-weight: 600; font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted, #9aa3b2); }
.rs-history-list { list-style: none; padding: 0; margin: 0; }
.rs-history-list li {
    padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px;
    border: 1px solid transparent; margin-bottom: 4px; line-height: 1.35;
}
.rs-history-list li:hover { background: rgba(255,255,255,0.05); }
.rs-history-list li.active { background: rgba(99,102,241,0.18); border-color: rgba(99,102,241,0.5); }
.rs-history-list li .rs-h-q { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rs-history-list li .rs-h-meta { display: block; color: var(--text-muted,#9aa3b2); font-size: 11px; margin-top: 2px; }
.rs-history-empty { color: var(--text-muted,#9aa3b2); font-size: 12px; padding: 8px 0; }

.rs-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.rs-form {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px; padding: 16px;
}
.rs-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; }
.rs-form textarea {
    width: 100%; padding: 10px 12px;
    background: rgba(0,0,0,0.25); color: inherit;
    border: 1px solid rgba(255,255,255,0.12); border-radius: 8px;
    font: inherit; resize: vertical; min-height: 70px;
}
.rs-form textarea:focus { outline: 1px solid rgba(99,102,241,0.7); }

.rs-controls { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; align-items: end; }
.rs-inline { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted, #9aa3b2); }
.rs-inline select, .rs-inline input[type=number] {
    background: rgba(0,0,0,0.25); color: inherit;
    border: 1px solid rgba(255,255,255,0.12); border-radius: 6px;
    padding: 6px 8px; font: inherit; min-width: 140px;
}

.rs-btn {
    padding: 8px 14px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15);
    background: rgba(255,255,255,0.05); color: inherit; cursor: pointer; font: inherit;
}
.rs-btn:hover:not(:disabled) { background: rgba(255,255,255,0.1); }
.rs-btn:disabled { opacity: 0.6; cursor: progress; }
.rs-btn-primary { background: linear-gradient(135deg, #6366f1, #8b5cf6); border-color: rgba(99,102,241,0.6); color: #fff; font-weight: 600; }
.rs-btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.rs-btn-ghost { background: transparent; border-color: rgba(255,255,255,0.12); padding: 4px 8px; font-size: 12px; }

.rs-error {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.4);
    color: #fecaca; padding: 10px 12px; border-radius: 8px;
    margin-top: 12px; font-size: 13px; white-space: pre-wrap;
}

.rs-result {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px; padding: 18px;
}
.rs-result-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 16px; margin-bottom: 10px;
}
.rs-result-question { margin: 0; font-size: 18px; line-height: 1.3; }
.rs-result-meta {
    color: var(--text-muted, #9aa3b2);
    font-size: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 1;
    min-width: 0;
}
.rs-result-answer {
    line-height: 1.55; font-size: 14px; word-wrap: break-word;
    padding: 8px 0 14px; border-bottom: 1px dashed rgba(255,255,255,0.08);
}
.rs-result-answer a.rs-cite {
    display: inline-block; min-width: 22px; text-align: center;
    background: rgba(99,102,241,0.18); color: #c7d2fe;
    border: 1px solid rgba(99,102,241,0.4); border-radius: 999px;
    padding: 0 6px; margin: 0 2px; font-size: 11px; font-weight: 600;
    text-decoration: none; line-height: 1.6;
}
.rs-result-answer a.rs-cite:hover { background: rgba(99,102,241,0.35); }

/* Markdown rendering for the answer panel */
.rs-result-answer p { margin: 0 0 12px; }
.rs-result-answer p:last-child { margin-bottom: 0; }
.rs-result-answer strong { font-weight: 700; color: #fff; }
.rs-result-answer em { font-style: italic; }
.rs-result-answer .rs-md-h1 {
    font-size: 20px; font-weight: 700; margin: 22px 0 10px;
    padding-bottom: 6px; border-bottom: 1px solid rgba(255,255,255,0.08); color: #fff;
}
.rs-result-answer .rs-md-h2 { font-size: 17px; font-weight: 600; margin: 18px 0 8px; color: #fff; }
.rs-result-answer .rs-md-h3 { font-size: 15px; font-weight: 600; margin: 14px 0 6px; color: #fff; }
.rs-result-answer .rs-md-h4,
.rs-result-answer .rs-md-h5,
.rs-result-answer .rs-md-h6 { font-size: 14px; font-weight: 600; margin: 12px 0 6px; color: #fff; }
.rs-result-answer .rs-md-ul { margin: 6px 0 12px; padding-left: 22px; }
.rs-result-answer .rs-md-ul li { margin: 4px 0; line-height: 1.55; }
.rs-result-answer .rs-md-code {
    background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.08);
    padding: 1px 6px; border-radius: 4px; font-size: 12.5px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.rs-result-answer .rs-md-pre {
    background: rgba(0,0,0,0.25); border: 1px solid rgba(255,255,255,0.08);
    padding: 10px 12px; border-radius: 8px; margin: 10px 0; overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
}
.rs-result-answer a:not(.rs-cite) {
    color: #93c5fd; text-decoration: none;
    border-bottom: 1px solid rgba(147,197,253,0.4);
}
.rs-result-answer a:not(.rs-cite):hover { border-bottom-color: #93c5fd; }

.rs-sources { margin-top: 12px; }
.rs-sources-title { font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted, #9aa3b2); margin: 0 0 8px; }
.rs-sources-list { padding-left: 22px; margin: 0; }
.rs-sources-list li { margin-bottom: 8px; }
.rs-sources-list .rs-src-title { font-weight: 600; }
.rs-sources-list a { color: #93c5fd; text-decoration: none; }
.rs-sources-list a:hover { text-decoration: underline; }
.rs-sources-list .rs-src-snippet { color: var(--text-muted, #9aa3b2); font-size: 12px; margin-top: 2px; line-height: 1.4; }
.rs-sources-list .rs-src-domain { color: var(--text-muted, #9aa3b2); font-size: 11px; }
.rs-sources-list li.rs-src-unused { opacity: 0.55; }
.rs-sources-list li.rs-src-error a.rs-src-title { color: #f87171; }

.rs-toggles { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.rs-toggle { font-size: 12px; color: var(--text-muted, #9aa3b2); display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.rs-toggle input[type=checkbox] { accent-color: #6366f1; }

.rs-status {
    margin-top: 12px; padding: 8px 12px;
    background: rgba(99,102,241,0.08); border: 1px solid rgba(99,102,241,0.3);
    border-radius: 8px; font-size: 13px;
}

/* === Live research progress ring === */
.rs-progress-ring {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.22);
    border-radius: 10px;
    position: relative;
}
.rs-progress-ring[hidden] { display: none; }
.rs-progress-ring svg {
    flex-shrink: 0;
    width: 64px; height: 64px;
    overflow: visible;
}
.rs-ring-bg { stroke: rgba(99, 102, 241, 0.18); }
.rs-ring-fg {
    stroke: #818cf8;
    transition: stroke-dashoffset 0.4s cubic-bezier(.4, 0, .2, 1);
    filter: drop-shadow(0 0 6px rgba(129, 140, 248, 0.45));
}
.rs-ring-pct {
    position: absolute;
    left: 14px;
    width: 64px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    color: #c7d2fe;
    line-height: 64px;
    pointer-events: none;
}
.rs-ring-stage {
    font-size: 13px;
    color: var(--text-muted, #9aa3b2);
    text-transform: lowercase;
    letter-spacing: 0.01em;
}

.rs-section-title { font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted, #9aa3b2); margin: 14px 0 8px; }

.rs-trail-section { margin-top: 12px; }
.rs-trail-toggle { cursor: pointer; user-select: none; }
.rs-trail-chevron { display: inline-block; transition: transform 0.15s; font-size: 11px; }
.rs-trail-toggle.rs-collapsed .rs-trail-chevron { transform: rotate(-90deg); }
.rs-trail-list {
    list-style: decimal; padding-left: 22px; margin: 0;
    background: rgba(0,0,0,0.18); border-radius: 6px; padding: 10px 10px 10px 28px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
}
.rs-trail-list li { padding: 3px 0; color: var(--text-muted, #9aa3b2); }
.rs-trail-list li.rs-trail-error { color: #f87171; }
.rs-trail-list li.rs-trail-ok { color: #4ade80; }

/* === Prospecting candidates panel === */
.rs-companies-panel { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }

.rs-card {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px;
    padding: 16px 18px;
}
.rs-card-validated { border-color: rgba(74, 222, 128, 0.25); background: rgba(74, 222, 128, 0.04); }
.rs-card-needs     { border-color: rgba(245, 158, 11, 0.25); background: rgba(245, 158, 11, 0.04); }
.rs-card-rejected  { opacity: 0.85; }
.rs-card-next      { border-color: rgba(99, 102, 241, 0.3); background: rgba(99, 102, 241, 0.04); }
.rs-card-health    { border-color: rgba(248, 113, 113, 0.35); background: rgba(248, 113, 113, 0.06); }
.rs-card-health p code { background: rgba(255,255,255,0.06); color: #d4d8e4; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

.rs-card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; gap: 12px; flex-wrap: wrap;
}
.rs-card .rs-section-title { margin: 0; font-size: 13px; }
.rs-card-empty { color: var(--text-muted, #9aa3b2); font-size: 13px; margin: 6px 0 0; }
.rs-card-empty-error { color: #fda4af; font-weight: 500; }
.rs-card-hint  { color: var(--text-muted, #9aa3b2); font-size: 12px; margin: 4px 0 10px; }

/* Per-provider source badges — small inline pills shown on each source card
 * and inside the provider-diagnostics table so the user can see which
 * provider returned a given result at a glance. */
.rs-prov { display: inline-block; padding: 2px 8px; margin-left: 6px;
           font-size: 10px; font-weight: 600; border-radius: 999px;
           border: 1px solid rgba(255,255,255,0.1);
           background: rgba(255,255,255,0.04); color: #cbd5e1;
           letter-spacing: 0.03em; text-transform: uppercase;
           vertical-align: middle; }
.rs-prov-searxng       { background: rgba(56,189,248,0.12); color: #7dd3fc;
                         border-color: rgba(56,189,248,0.3); }
.rs-prov-brave         { background: rgba(251,146,60,0.12); color: #fdba74;
                         border-color: rgba(251,146,60,0.3); }
.rs-prov-serpapi       { background: rgba(167,139,250,0.12); color: #c4b5fd;
                         border-color: rgba(167,139,250,0.3); }
.rs-prov-tavily        { background: rgba(52,211,153,0.12); color: #6ee7b7;
                         border-color: rgba(52,211,153,0.3); }
.rs-prov-sec_edgar     { background: rgba(248,113,113,0.12); color: #fca5a5;
                         border-color: rgba(248,113,113,0.3); }
.rs-prov-direct_domain { background: rgba(148,163,184,0.12); color: #cbd5e1;
                         border-color: rgba(148,163,184,0.3); }
.rs-card-sublabel { color: var(--text-muted, #9aa3b2); font-size: 11px; text-transform: uppercase;
                    letter-spacing: 0.06em; margin: 8px 0 4px; }

.rs-pill { display: inline-block; padding: 3px 10px; border-radius: 999px;
           font-size: 11px; font-weight: 600; background: rgba(255,255,255,0.06);
           border: 1px solid rgba(255,255,255,0.08); color: var(--text-muted, #9aa3b2); }
.rs-pill-ok    { background: rgba(74, 222, 128, 0.12); color: #4ade80; border-color: rgba(74,222,128,0.3); }
.rs-pill-warn  { background: rgba(245, 158, 11, 0.12); color: #f59e0b; border-color: rgba(245,158,11,0.3); }
.rs-pill-muted { opacity: 0.7; }

/* === Candidate table: business-user readability pass (vision doc §4) === */
.rs-companies-table { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.45; }
.rs-companies-table th, .rs-companies-table td {
    padding: 14px 14px; text-align: left; vertical-align: top;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.rs-companies-table th { font-weight: 600; color: var(--text-muted, #9aa3b2);
                         text-transform: uppercase; letter-spacing: 0.04em; font-size: 11px; }
.rs-co-name   { font-weight: 700; font-size: 15px; color: #f1f5f9; }
.rs-co-domain { font-size: 12px; color: #cbd5e1; margin-top: 2px; }
.rs-co-cap    { display: inline-block; margin-top: 4px; padding: 1px 7px;
                background: rgba(99,102,241,0.12); color: #c7d2fe; border-radius: 4px;
                font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.rs-co-ex     { display: inline-block; padding: 2px 8px; margin-left: 4px;
                background: rgba(255,255,255,0.06); border-radius: 4px;
                font-size: 12px; color: #d4d8e4; }
/* Evidence quote: wraps cleanly, stays readable across long quotes. */
.rs-co-ev     { margin-top: 8px; font-size: 13px; font-style: italic;
                color: #cbd5e1; border-left: 3px solid rgba(99,102,241,0.5);
                padding: 4px 10px; line-height: 1.5;
                white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
/* Source link: clear but not noisy. */
.rs-companies-table td a {
    color: #c7d2fe; text-decoration: none; font-weight: 600;
    border-bottom: 1px dashed rgba(199,210,254,0.4);
}
.rs-companies-table td a:hover { color: #e0e7ff; border-bottom-style: solid; }
/* Confidence badge: bigger, higher-contrast. */
.rs-conf { display: inline-block; padding: 5px 12px; border-radius: 999px;
           font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.rs-conf-high { background: rgba(74, 222, 128, 0.22); color: #86efac;
                border: 1px solid rgba(74,222,128,0.45); }
.rs-conf-med  { background: rgba(245, 158, 11, 0.22); color: #fcd34d;
                border: 1px solid rgba(245,158,11,0.45); }
.rs-conf-low  { background: rgba(248, 113, 113, 0.22); color: #fca5a5;
                border: 1px solid rgba(248,113,113,0.45); }

/* Save button: larger target, more obviously clickable. */
.rs-co-save  { padding: 8px 18px; border-radius: 8px; cursor: pointer; font-size: 13px;
               font-weight: 600; min-width: 84px;
               background: linear-gradient(180deg, rgba(99,102,241,0.32), rgba(99,102,241,0.18));
               color: #e0e7ff;
               border: 1px solid rgba(99,102,241,0.55);
               transition: background 0.12s ease, transform 0.05s ease; }
.rs-co-save:hover:not(:disabled) {
    background: linear-gradient(180deg, rgba(99,102,241,0.48), rgba(99,102,241,0.28));
}
.rs-co-save:active:not(:disabled) { transform: translateY(1px); }
.rs-co-save:disabled { opacity: 0.7; cursor: default; }
.rs-co-saved { background: rgba(74, 222, 128, 0.22); color: #86efac;
               border-color: rgba(74,222,128,0.5); }
.rs-co-needs { display: inline-block; padding: 5px 11px; border-radius: 999px;
               font-size: 12px; font-weight: 600;
               background: rgba(245, 158, 11, 0.15); color: #fcd34d;
               border: 1px solid rgba(245,158,11,0.35); }

/* === Summary bar at the top of the result panel === */
.rs-summary-bar {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 12px 14px; margin: 0 0 14px;
    background: rgba(255,255,255,0.025);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
}
.rs-summary-pill {
    display: inline-flex; align-items: center; padding: 6px 12px;
    border-radius: 999px; font-size: 12px; font-weight: 600;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    color: #cbd5e1;
}
.rs-summary-ok       { background: rgba(74,222,128,0.18); color: #86efac;
                       border-color: rgba(74,222,128,0.4); }
.rs-summary-warn     { background: rgba(245,158,11,0.16); color: #fcd34d;
                       border-color: rgba(245,158,11,0.35); }
.rs-summary-muted    { color: #cbd5e1; background: rgba(255,255,255,0.06);
                       border-color: rgba(255,255,255,0.14); }
.rs-summary-fallback { background: rgba(56,189,248,0.16); color: #7dd3fc;
                       border-color: rgba(56,189,248,0.35); }
.rs-summary-guard    { background: rgba(167,139,250,0.16); color: #c4b5fd;
                       border-color: rgba(167,139,250,0.35); cursor: help; }

/* === Candidate-count lead line above the synthesis === */
.rs-answer-lead {
    margin: 0 0 12px; padding: 10px 14px;
    background: rgba(99,102,241,0.06);
    border: 1px solid rgba(99,102,241,0.18);
    border-radius: 10px;
    font-size: 14px; color: #e0e7ff;
}
.rs-answer-lead strong { color: #fff; }

/* === Collapsible debug-y sections (search strategy, rejected, diagnostics) === */
.rs-collapsible { padding: 0; }
.rs-collapsible > summary {
    list-style: none; cursor: pointer; user-select: none;
    padding: 14px 16px;
    border-radius: 12px;
    transition: background 0.12s ease;
}
.rs-collapsible > summary::-webkit-details-marker { display: none; }
.rs-collapsible > summary:hover { background: rgba(255,255,255,0.03); }
.rs-collapsible > summary::before {
    content: '▸'; display: inline-block; margin-right: 8px;
    font-size: 12px; color: var(--text-muted, #9aa3b2);
    transition: transform 0.15s ease;
}
.rs-collapsible[open] > summary::before { transform: rotate(90deg); }
.rs-collapsible[open] > summary { border-bottom: 1px solid rgba(255,255,255,0.06); }
.rs-collapsible .rs-section-title { display: inline; }
.rs-collapsible-body { padding: 12px 18px 16px; }

.rs-q-list { margin: 6px 0 0; padding-left: 18px; font-size: 12px; }
.rs-q-list li { padding: 3px 0; color: var(--text-muted, #9aa3b2); }
.rs-q-list code { background: rgba(255,255,255,0.06); color: #d4d8e4;
                  padding: 1px 6px; border-radius: 4px; font-size: 12px; }

.rs-rejected-list { margin: 6px 0 0; padding-left: 18px; font-size: 12px; }
.rs-rejected-list li { padding: 3px 0; color: var(--text-muted, #9aa3b2); }
.rs-rejected-list li a { color: #93c5fd; text-decoration: none; }
.rs-rejected-list li a:hover { text-decoration: underline; }
.rs-rejected-reason { color: var(--text-muted, #9aa3b2); font-size: 11px;
                      margin-left: 8px; font-style: italic; }

/* === Provider badges + diagnostics === */
.rs-prov {
    display: inline-block;
    padding: 1px 7px;
    margin: 0 4px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.06);
    color: var(--text-muted, #9aa3b2);
    vertical-align: middle;
}
.rs-prov-searxng       { background: rgba(99,102,241,0.18);  color: #c7d2fe; border-color: rgba(99,102,241,0.4); }
.rs-prov-brave         { background: rgba(244,114,22,0.16);  color: #fdba74; border-color: rgba(244,114,22,0.4); }
.rs-prov-serpapi       { background: rgba(20,184,166,0.16);  color: #5eead4; border-color: rgba(20,184,166,0.4); }
.rs-prov-tavily        { background: rgba(168,85,247,0.16);  color: #d8b4fe; border-color: rgba(168,85,247,0.4); }
.rs-prov-sec_edgar     { background: rgba(34,197,94,0.16);   color: #86efac; border-color: rgba(34,197,94,0.4); }
.rs-prov-direct_domain { background: rgba(244,63,94,0.16);   color: #fda4af; border-color: rgba(244,63,94,0.4); }

.rs-card-diag { border-color: rgba(255,255,255,0.10); background: rgba(255,255,255,0.02); }
.rs-prov-table th, .rs-prov-table td { font-size: 12px; padding: 6px 8px; }
.rs-prov-table td:not(:first-child):not(:last-child) { text-align: right; font-variant-numeric: tabular-nums; }

@media (max-width: 720px) {
    .rs-page {
        padding: 12px;
    }

    .rs-result-header {
        flex-direction: column;
        align-items: stretch;
    }

    .rs-result-meta { width: 100%; }

    /* Topbar collapses to two lines on phones:
       row 1 = logo + name + health,
       row 2 = tagline (smaller).
       The "About" pill stays inline next to the name. */
    .rs-topbar {
        flex-wrap: wrap;
        padding: 8px 10px;
        gap: 8px 10px;
    }
    .rs-topbar-sep      { display: none; }
    .rs-topbar-tagline  { font-size: 12px; flex-basis: 100%; order: 99;
                          white-space: normal; overflow: visible; }
    .rs-topbar-spacer   { flex: 1; }
    .rs-topbar-name     { font-size: 16px; }
    .rs-topbar-about-pop { right: auto; left: 0; }

    .rs-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .rs-inline,
    .rs-inline select,
    .rs-inline input[type=number],
    .rs-btn-primary {
        width: 100%;
        min-width: 0;
    }

    .rs-btn {
        min-height: 44px;
    }

    .rs-companies-table {
        display: block;
        border-collapse: separate;
        border-spacing: 0;
    }

    .rs-companies-table thead {
        position: absolute;
        left: -10000px;
        width: 1px;
        height: 1px;
        overflow: hidden;
    }

    .rs-companies-table tbody,
    .rs-companies-table tr,
    .rs-companies-table td {
        display: block;
        width: 100%;
    }

    .rs-companies-table tr {
        margin: 0 0 12px;
        padding: 12px;
        border: 1px solid rgba(255,255,255,0.08);
        border-radius: 10px;
        background: rgba(255,255,255,0.03);
    }

    .rs-companies-table td {
        padding: 6px 0;
        border: 0;
        text-align: left !important;
        overflow-wrap: anywhere;
    }

    .rs-companies-table td::before {
        display: block;
        margin-bottom: 3px;
        color: var(--text-muted, #9aa3b2);
        font-size: 10px;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .rs-companies-table td:nth-child(1)::before { content: "Company"; }
    .rs-companies-table td:nth-child(2)::before { content: "Ticker / Exchange"; }
    .rs-companies-table td:nth-child(3)::before { content: "Signal / Evidence"; }
    .rs-companies-table td:nth-child(4)::before { content: "Source"; }
    .rs-companies-table td:nth-child(5)::before { content: "Confidence"; }
    .rs-companies-table td:nth-child(6)::before { content: "Next action"; }
    .rs-companies-table td:nth-child(7)::before { content: none; }

    .rs-prov-table td:nth-child(1)::before { content: "Provider"; }
    .rs-prov-table td:nth-child(2)::before { content: "Status"; }
    .rs-prov-table td:nth-child(3)::before { content: "Attempted"; }
    .rs-prov-table td:nth-child(4)::before { content: "Succeeded"; }
    .rs-prov-table td:nth-child(5)::before { content: "Failed"; }
    .rs-prov-table td:nth-child(6)::before { content: "Timeouts"; }
    .rs-prov-table td:nth-child(7)::before { content: "Blocked / Rate-limited"; }
    .rs-prov-table td:nth-child(8)::before { content: "Configured"; }

    .rs-co-save {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 420px) {
    .rs-page {
        padding: 8px;
    }

    .rs-form,
    .rs-result,
    .rs-card {
        padding: 14px;
    }

    .rs-summary-pill {
        width: 100%;
        justify-content: center;
    }
}

/* === Follow-up section (chips, manual input, answer card) === */
.rs-followup-panel {
    margin-top: 14px;
    padding: 16px 18px;
    background: rgba(99,102,241,0.04);
    border: 1px solid rgba(99,102,241,0.18);
    border-radius: 12px;
}
.rs-fu-chips {
    display: flex; flex-wrap: wrap; gap: 8px;
    margin: 8px 0 14px;
}
.rs-fu-chip {
    padding: 8px 14px;
    font-size: 13px; font-weight: 500;
    color: #e0e7ff;
    background: rgba(99,102,241,0.16);
    border: 1px solid rgba(99,102,241,0.42);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.12s ease, transform 0.05s ease;
    min-height: 36px;
}
.rs-fu-chip:hover  { background: rgba(99,102,241,0.28); }
.rs-fu-chip:active { transform: translateY(1px); }
.rs-fu-chip:disabled { opacity: 0.55; cursor: progress; }
.rs-fu-chip-active   { background: rgba(99,102,241,0.36); color: #fff;
                       border-color: rgba(99,102,241,0.7); font-weight: 600; }

/* Live loading state for the follow-up answer card */
.rs-fu-spinner {
    display: inline-block; width: 14px; height: 14px;
    margin-right: 8px; vertical-align: -2px;
    border: 2px solid rgba(99,102,241,0.25);
    border-top-color: #818cf8;
    border-radius: 50%;
    animation: rs-fu-spin 0.85s linear infinite;
}
@keyframes rs-fu-spin { to { transform: rotate(360deg); } }
.rs-fu-q-preview {
    display: inline-block; margin-left: 8px;
    font-style: italic; color: #c7d2fe;
}
.rs-fu-status-sub {
    display: block; margin-top: 6px;
    font-size: 12px; color: var(--text-muted, #9aa3b2);
}

.rs-fu-form  { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.rs-fu-label { font-size: 12px; color: var(--text-muted, #9aa3b2); }
.rs-fu-row   { display: flex; gap: 8px; align-items: center; }
.rs-fu-input {
    flex: 1; min-width: 0;
    padding: 10px 14px; font-size: 14px;
    background: rgba(0,0,0,0.28); color: inherit;
    border: 1px solid rgba(255,255,255,0.14); border-radius: 8px;
}
.rs-fu-input:focus { outline: 1px solid rgba(99,102,241,0.7); }
.rs-fu-submit {
    padding: 10px 18px; min-height: 44px;
    background: linear-gradient(180deg, rgba(99,102,241,0.42), rgba(99,102,241,0.22));
    color: #e0e7ff;
    border: 1px solid rgba(99,102,241,0.55);
    border-radius: 8px; font-weight: 600; cursor: pointer;
}
.rs-fu-submit:hover { background: linear-gradient(180deg, rgba(99,102,241,0.58), rgba(99,102,241,0.32)); }

.rs-fu-answer {
    margin-top: 14px; padding: 14px 16px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 10px;
}
.rs-fu-answer.rs-fu-loading { border-style: dashed; opacity: 0.85; }
.rs-fu-answer.rs-fu-error   { border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.06); }
.rs-fu-answer-title  { margin: 0 0 6px; font-size: 13px; text-transform: uppercase;
                       letter-spacing: 0.05em; color: var(--text-muted, #9aa3b2); }
.rs-fu-answer-q      { margin: 0 0 8px; font-weight: 600; color: #e2e8f0; font-size: 14px; }
.rs-fu-answer-body   { font-size: 14px; line-height: 1.55; white-space: pre-wrap;
                       word-break: break-word; overflow-wrap: anywhere; }
.rs-fu-supports      { margin: 8px 0 0; font-size: 12px; color: var(--text-muted, #9aa3b2); }
.rs-fu-status        { margin: 0; font-size: 13px; color: var(--text-muted, #9aa3b2); }
.rs-fu-extra         { margin-top: 10px; font-size: 12px; color: var(--text-muted, #9aa3b2); }
.rs-fu-extra summary { cursor: pointer; }
.rs-fu-followups     { margin-top: 12px; }

/* === Per-row Expand button + actions cell === */
.rs-co-actions {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.rs-co-expand,
.rs-co-pdf {
    padding: 6px 12px; min-height: 32px;
    font-size: 12px; font-weight: 600;
    background: rgba(255,255,255,0.06); color: #e0e7ff;
    border: 1px solid rgba(255,255,255,0.18); border-radius: 6px; cursor: pointer;
}
.rs-co-expand:hover,
.rs-co-pdf:hover { background: rgba(255,255,255,0.12); }
.rs-co-pdf {
    background: rgba(63,180,176,0.14);
    border-color: rgba(63,180,176,0.42);
    color: #99e6e2;
}
.rs-co-pdf:hover { background: rgba(63,180,176,0.24); }
.rs-co-pdf:disabled { opacity: 0.7; cursor: progress; }
.rs-co-pdf-deep {
    margin-top: 6px; margin-left: 8px;
    min-height: 44px; padding: 10px 18px;
    background: rgba(63,180,176,0.16); color: #99e6e2;
    border: 1px solid rgba(63,180,176,0.45); border-radius: 8px;
    font-weight: 600; cursor: pointer;
}
.rs-co-pdf-deep:hover    { background: rgba(63,180,176,0.28); }
.rs-co-pdf-deep:disabled { opacity: 0.7; cursor: progress; }

/* === Company detail drawer (desktop right-slide / mobile bottom-sheet) === */
.rs-co-drawer {
    position: fixed; inset: 0;
    z-index: 1000;
    pointer-events: none;
}
.rs-co-drawer-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.55);
    opacity: 0; transition: opacity 0.18s ease;
    pointer-events: none;
}
.rs-co-drawer-panel {
    position: absolute; top: 0; right: 0; bottom: 0;
    width: min(480px, 100%);
    background: rgb(20, 22, 32);
    border-left: 1px solid rgba(255,255,255,0.1);
    box-shadow: -10px 0 30px rgba(0,0,0,0.45);
    transform: translateX(100%); transition: transform 0.22s ease;
    display: flex; flex-direction: column;
    overflow-y: auto;
    pointer-events: none;
}
.rs-co-drawer.open                       { pointer-events: auto; }
.rs-co-drawer.open .rs-co-drawer-backdrop { opacity: 1; pointer-events: auto; }
.rs-co-drawer.open .rs-co-drawer-panel    { transform: translateX(0); pointer-events: auto; }

.rs-co-drawer-head {
    position: sticky; top: 0; z-index: 2;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px;
    background: rgba(20, 22, 32, 0.95);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    backdrop-filter: blur(8px);
}
.rs-co-drawer-body  { padding: 16px 18px 28px; }
.rs-co-drawer-name  { margin: 0 0 12px; font-size: 18px; }
.rs-co-drawer-src   { margin: 0 0 12px; font-size: 13px; word-break: break-all; }
.rs-co-drawer-src a { color: #c7d2fe; }

.rs-co-kv { margin: 0 0 12px; display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.rs-co-kv dt { color: var(--text-muted, #9aa3b2); font-weight: 600; }
.rs-co-kv dd { margin: 0; word-break: break-word; }
.rs-co-kv-row { display: contents; }

.rs-co-list-tight { margin: 4px 0 12px; padding-left: 20px; font-size: 13px; line-height: 1.55; }
.rs-co-list-tight li { margin: 2px 0; }
.rs-co-drawer .rs-co-ev {
    margin: 8px 0 12px; padding: 8px 12px;
    font-style: italic; color: #cbd5e1;
    background: rgba(99,102,241,0.07);
    border-left: 3px solid rgba(99,102,241,0.5);
    border-radius: 0 6px 6px 0;
    word-break: break-word; overflow-wrap: anywhere;
}
.rs-co-expand-deeper { margin-top: 6px; min-height: 44px; }
.rs-co-expansion { margin-top: 16px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,0.08); }
.rs-co-expansion-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }

body.rs-drawer-open { overflow: hidden; }

/* === Mobile: drawer becomes a bottom sheet === */
@media (max-width: 720px) {
    .rs-co-drawer-panel {
        top: auto; right: 0; left: 0; bottom: 0;
        width: 100%; height: 88vh;
        border-left: 0;
        border-top: 1px solid rgba(255,255,255,0.1);
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        transform: translateY(100%);
        box-shadow: 0 -10px 30px rgba(0,0,0,0.45);
    }
    .rs-co-drawer.open .rs-co-drawer-panel { transform: translateY(0); }

    .rs-co-actions      { flex-direction: column; align-items: stretch; }
    .rs-co-actions .rs-co-expand,
    .rs-co-actions .rs-co-save { width: 100%; justify-content: center; }

    .rs-fu-row     { flex-direction: column; align-items: stretch; }
    .rs-fu-submit  { width: 100%; }
    .rs-fu-chip    { font-size: 14px; padding: 10px 14px; min-height: 44px; }

    .rs-co-kv      { grid-template-columns: 1fr; }
    .rs-co-kv dt   { margin-top: 6px; }
}

/* === Page-wide mobile polish (rest of the page, not just tables) === */
@media (max-width: 720px) {
    .rs-page,
    .rs-result,
    .rs-form,
    .rs-card,
    .rs-followup-panel { min-width: 0; }

    /* Header collapse: title above health pills, breadcrumb wraps. */
    .rs-result-meta { gap: 6px 10px; font-size: 11px; }
    .rs-result-meta .rs-btn { min-height: 44px; padding: 8px 12px; }

    .rs-summary-bar { padding: 10px; gap: 6px; }
    .rs-summary-pill { font-size: 11px; padding: 5px 9px; }

    /* Live progress ring shrinks. */
    .rs-progress-ring { padding: 8px 10px; gap: 10px; }
    .rs-progress-ring svg,
    .rs-ring-pct { width: 52px; height: 52px; line-height: 52px; font-size: 12px; }

    /* Source list cleanup so long URLs don't push the row wider. */
    .rs-sources-list { padding-left: 18px; }
    .rs-sources-list li,
    .rs-sources-list .rs-src-snippet { word-break: break-word; overflow-wrap: anywhere; font-size: 13px; }

    /* Trail items can wrap their detail string. */
    .rs-trail-list li { overflow-wrap: anywhere; word-break: break-word; font-size: 12px; }

    /* Diagnostics tables fall back to stacked cards (covered above). */
    .rs-card-diag,
    .rs-card-strategy { padding: 12px 14px; }
    .rs-collapsible > summary { padding: 12px 14px; }

    /* Provider badges shouldn't push table rows wider than the screen. */
    .rs-prov { font-size: 9px; padding: 1px 6px; }
}

/* Workspace tab bar — keep horizontally scrollable on phones rather than
   wrapping into multiple jumbled rows. */
@media (max-width: 720px) {
    .rws-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .rws-tab { flex: 0 0 auto; }
    .rws-table { display: block; overflow-x: auto; }
    .rws-grid-3 { grid-template-columns: 1fr; }

    /* Logo shrinks on phones — still inline with the wordmark. */
    .rs-brand-logo   { width: 32px; height: 32px; border-radius: 8px; }
}

/* === Deep Scout info button + popover, completion-chime toggle === */
.rs-toggle-deep { display: inline-flex; align-items: center; gap: 6px; }
.rs-info-btn {
    width: 18px; height: 18px;
    min-width: 18px;
    display: inline-flex; align-items: center; justify-content: center;
    margin-left: 4px;
    font-family: ui-serif, Georgia, serif;
    font-style: italic; font-weight: 700; font-size: 11px;
    line-height: 1;
    color: #c7d2fe;
    background: rgba(99,102,241,0.18);
    border: 1px solid rgba(99,102,241,0.5);
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    transition: background 0.12s ease;
}
.rs-info-btn:hover,
.rs-info-btn[aria-expanded="true"] { background: rgba(99,102,241,0.34); }
.rs-info-btn:focus-visible { outline: 2px solid rgba(99,102,241,0.7); outline-offset: 2px; }

.rs-info-pop {
    margin: 10px 0 0;
    padding: 14px 16px;
    background: rgba(20, 22, 32, 0.96);
    border: 1px solid rgba(99,102,241,0.32);
    border-left: 3px solid #6366f1;
    border-radius: 10px;
    box-shadow: 0 6px 22px rgba(0,0,0,0.4);
    max-width: 640px;
}
.rs-info-pop h4 {
    margin: 0 0 6px;
    font-size: 13px; font-weight: 700;
    color: #e0e7ff;
    letter-spacing: 0.02em;
}
.rs-info-pop p { margin: 0 0 8px; font-size: 13px; line-height: 1.55; color: #cbd5e1; }
.rs-info-pop ul { margin: 4px 0 8px; padding-left: 20px; font-size: 12.5px; color: #cbd5e1; }
.rs-info-pop ul li { margin: 2px 0; }
.rs-info-pop .rs-info-pop-foot {
    margin: 8px 0 0;
    font-style: italic;
    color: var(--text-muted, #9aa3b2);
    font-size: 11.5px;
}

.rs-helper {
    margin: 8px 0 0;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-muted, #9aa3b2);
    max-width: 720px;
}
.rs-helper strong { color: #c7d2fe; }
.rs-toggle-chime { color: var(--text-muted, #9aa3b2); }

/* === Mobile breakpoint hardening (spec §FEATURE 3) ===
   Tight rules for 430 / 390 / 360 px so the form, results, and popover stay
   tap-friendly without horizontal scroll. */
@media (max-width: 430px) {
    /* Buttons stay ≥ 44px tall — Apple HIG / WCAG tap target. */
    .rs-btn,
    .rs-btn-primary,
    .rs-co-pdf,
    .rs-co-expand,
    .rs-co-save,
    .rs-fu-submit { min-height: 44px; padding: 10px 14px; }

    /* Primary action becomes full-width so it's never half-off-screen. */
    .rs-btn-primary { width: 100%; }

    /* Toggle row stacks vertically; each toggle becomes its own row so the
       Deep Scout info icon doesn't get squeezed onto a second line. */
    .rs-toggles { flex-direction: column; align-items: stretch; gap: 8px; }
    .rs-toggle  { padding: 4px 0; }

    /* Popover takes the full content width, never overflows. */
    .rs-info-pop { padding: 12px 14px; }
    .rs-info-pop ul { padding-left: 18px; }

    /* Helper text uses smaller leading so it fits without ballooning the
       form. */
    .rs-helper { font-size: 12px; }

    /* Result-header buttons wrap. */
    .rs-result-meta { flex-wrap: wrap; }
    .rs-result-meta .rs-btn { flex: 1 1 auto; }
}

@media (max-width: 390px) {
    .rs-page { padding: 10px; }
    .rs-result, .rs-form, .rs-card { padding: 12px; }
    .rs-topbar { padding: 8px 10px; }
    .rs-topbar-name { font-size: 15px; }
    .rs-summary-bar { gap: 4px; padding: 8px; }
    .rs-summary-pill { font-size: 10.5px; padding: 4px 8px; }
}

@media (max-width: 360px) {
    /* Very small phones — pull margins in further and shrink the logo so the
       brand band doesn't push the About pill off-screen. */
    .rs-page { padding: 8px; }
    .rs-brand-logo { width: 28px; height: 28px; border-radius: 7px; }
    .rs-topbar-name { font-size: 14px; }
    .rs-topbar-tagline { font-size: 11.5px; }
}
