/* Probiv - Interface Theme */

:root {
    --bg-primary: #091217;
    --bg-secondary: #0f1b22;
    --bg-tertiary: #16262f;
    --bg-card: rgba(14, 23, 29, 0.82);
    --bg-glass: rgba(255, 255, 255, 0.03);
    
    --text-primary: #ffffff;
    --text-secondary: #9db1bc;
    --text-muted: #6f8791;
    
    --accent: #41d3a2;
    --accent-secondary: #f0b35a;
    --accent-gradient: linear-gradient(135deg, #41d3a2 0%, #f0b35a 100%);
    
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    --border: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(65, 211, 162, 0.26);
    
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(65, 211, 162, 0.16);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

[hidden] {
    display: none !important;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    background-image:
        radial-gradient(circle at top right, rgba(65, 211, 162, 0.12), transparent 28%),
        radial-gradient(circle at bottom left, rgba(240, 179, 90, 0.1), transparent 24%);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.grid-lines {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(65, 211, 162, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(65, 211, 162, 0.035) 1px, transparent 1px);
    background-size: 60px 60px;
    animation: gridMove 20s linear infinite;
}

@keyframes gridMove {
    0% { transform: translate(0, 0); }
    100% { transform: translate(60px, 60px); }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(20px);
    background: rgba(9, 18, 23, 0.86);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
}

.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-title {
    font-size: 1.25rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.nav {
    display: flex;
    gap: 8px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.user-badge-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.8rem;
}

#user-phone {
    color: var(--text-primary);
    font-weight: 600;
}

#user-role {
    color: var(--accent);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    background: transparent;
    border: 1px solid transparent;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-glass);
    border-color: var(--border);
}

.nav-link.active {
    color: var(--accent);
    background: rgba(65, 211, 162, 0.1);
    border-color: rgba(65, 211, 162, 0.24);
}

.main {
    padding: 40px 0 80px;
    min-height: calc(100vh - 180px);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

.hero-section {
    text-align: center;
    margin-bottom: 32px;
    padding: 12px 0 8px;
}

.hero-title {
    font-size: 2.75rem;
    font-weight: 800;
    margin-bottom: 16px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 760px;
    margin: 0 auto;
}

.auth-gate {
    max-width: 860px;
    margin: 0 auto 32px;
}

.auth-card {
    padding: 28px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
}

.auth-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.auth-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 14px;
}

.auth-actions .btn-secondary,
.auth-actions .btn-primary {
    width: auto;
}

.auth-hint,
.auth-status,
.auth-bot-link-wrap {
    color: var(--text-secondary);
}

.auth-status {
    min-height: 24px;
}

.auth-bot-link {
    color: var(--accent);
    text-decoration: none;
}

.search-container {
    max-width: 800px;
    margin: 0 auto 40px;
}

.search-wrapper {
    display: flex;
    gap: 12px;
    padding: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(20px);
    transition: var(--transition);
}

.search-wrapper:focus-within {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow);
}

.search-input-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-container input {
    width: 100%;
    padding: 16px 20px 16px 56px;
    background: transparent;
    border: none;
    font-size: 1.1rem;
    color: var(--text-primary);
    outline: none;
}

.search-input-container input::placeholder {
    color: var(--text-muted);
}

.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 32px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-lg);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    min-width: 160px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(65, 211, 162, 0.26);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-loader {
    display: flex;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

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

.examples-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 48px;
    flex-wrap: wrap;
}

.examples-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.examples-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.example-btn {
    padding: 8px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.example-btn:hover {
    background: rgba(65, 211, 162, 0.1);
    border-color: rgba(65, 211, 162, 0.28);
    color: var(--accent);
}

.progress-card,
.history-card,
.status-card {
    max-width: 900px;
    margin: 0 auto 40px;
    padding: 32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
}

.progress-header,
.results-title,
.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
    margin: 14px 0 8px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-percent,
.progress-message {
    display: block;
    color: var(--text-secondary);
}

.results-card {
    max-width: 1000px;
    margin: 0 auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(20px);
    overflow: hidden;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.results-actions,
.telegram-auth-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-action,
.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-action:hover,
.btn-secondary:hover {
    background: rgba(65, 211, 162, 0.1);
    border-color: rgba(65, 211, 162, 0.28);
    color: var(--accent);
}

.result-tabs {
    display: flex;
    gap: 4px;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.1);
}

.result-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.result-tab.active {
    color: var(--accent);
    background: rgba(65, 211, 162, 0.1);
}

.result-content {
    display: none;
    padding: 32px;
}

.result-content.active {
    display: block;
}

.result-report-shell {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 24px 32px 32px;
}

.result-report-label {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 8px 12px;
    border: 1px solid rgba(65, 211, 162, 0.2);
    border-radius: var(--radius-sm);
    background: rgba(65, 211, 162, 0.08);
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.result-dossier,
.analysis-dossier {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.result-overview {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.9fr);
    gap: 20px;
    padding: 24px;
    border: 1px solid rgba(65, 211, 162, 0.16);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(65, 211, 162, 0.08), rgba(15, 27, 34, 0.72));
}

.overview-label,
.dossier-kicker {
    display: inline-block;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent-secondary);
    margin-bottom: 10px;
}

.overview-copy h3,
.dossier-heading h3 {
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.result-overview .overview-copy {
    grid-column: 1 / -1;
}

.overview-copy p,
.analysis-copy p {
    color: var(--text-secondary);
}

.analysis-copy {
    color: var(--text-secondary);
    line-height: 1.7;
    white-space: pre-wrap;
}

.overview-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.overview-stat,
.dossier-block,
.analysis-block,
.history-item,
.telegram-auth-card {
    padding: 18px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.status-hint {
    display: block;
    margin-top: 8px;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.4;
}

.overview-stat span,
.detail-label,
.contact-kind,
.timeline-index,
.profile-platform {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.overview-stat strong,
.detail-value,
.contact-value,
.timeline-body,
.profile-handle {
    display: block;
    margin-top: 8px;
    color: var(--text-primary);
    word-break: break-word;
}

.result-dossier-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.dossier-block-wide,
.analysis-block-summary {
    grid-column: 1 / -1;
}

.dossier-heading {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.dossier-heading.warning h3,
.insight-item-warning {
    color: var(--warning);
}

.detail-list,
.contact-list,
.timeline-list,
.profile-list,
.insight-list,
.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-row,
.contact-row,
.timeline-item,
.insight-item {
    display: grid;
    gap: 10px;
    padding: 14px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.detail-row,
.contact-row {
    grid-template-columns: minmax(120px, 160px) minmax(0, 1fr);
    align-items: start;
}

.detail-row:last-child,
.contact-row:last-child,
.timeline-item:last-child,
.insight-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-row:first-child,
.contact-row:first-child,
.timeline-item:first-child,
.insight-item:first-child {
    padding-top: 0;
}

.timeline-item {
    grid-template-columns: 56px minmax(0, 1fr);
    align-items: start;
}

.profile-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.profile-link {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    border: 1px solid rgba(65, 211, 162, 0.14);
    border-radius: var(--radius-md);
    background: rgba(65, 211, 162, 0.05);
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
}

.profile-link:hover {
    border-color: rgba(65, 211, 162, 0.28);
    transform: translateY(-1px);
}

.analysis-copy {
    padding: 4px 0 0;
}

.insight-item {
    color: var(--text-secondary);
}

.result-empty {
    padding: 18px;
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.02);
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    margin-bottom: 24px;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.status-item-clickable {
    cursor: pointer;
    transition: var(--transition);
}

.status-item-clickable:hover,
.status-item-clickable:focus-visible {
    border-color: rgba(65, 211, 162, 0.28);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
    outline: none;
}

.status-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.status-icon.telegram { background: rgba(0, 136, 204, 0.12); color: #40a9d8; }
.status-icon.llm { background: rgba(240, 179, 90, 0.12); color: var(--accent-secondary); }
.status-icon.bot { background: rgba(65, 211, 162, 0.1); color: var(--accent); }

.status-value.status-ok { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.status-value.status-error { background: rgba(239, 68, 68, 0.1); color: var(--error); }
.status-value.status-unknown { background: rgba(96, 96, 112, 0.1); color: var(--text-muted); }

.status-value {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.telegram-auth-card {
    margin-bottom: 24px;
}

.telegram-auth-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin: 18px 0;
}

.telegram-auth-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.telegram-auth-field label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.telegram-auth-field input {
    width: 100%;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
}

.telegram-auth-field input[readonly] {
    color: var(--text-muted);
}

.admin-grid .auth-span-2 {
    grid-column: span 2;
}

.admin-session-summary {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--text-secondary);
}

.admin-status-row {
    word-break: break-word;
}

.settings-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.settings-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.68);
    backdrop-filter: blur(6px);
}

.settings-dialog {
    position: relative;
    width: min(720px, 100%);
    max-height: calc(100vh - 48px);
    overflow-y: auto;
    padding: 28px;
    background: #121b21;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.settings-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.settings-subtitle {
    color: var(--text-secondary);
    margin-top: 6px;
}

.settings-close {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
}

.settings-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

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

.settings-field label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.settings-field input,
.settings-field select,
.settings-field textarea {
    width: 100%;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.24);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
}

.settings-field textarea {
    resize: vertical;
    min-height: 220px;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.55;
}

.settings-status {
    grid-column: 1 / -1;
    min-height: 24px;
    color: var(--text-secondary);
}

.settings-status.is-error {
    color: var(--error);
}

.settings-status.is-success {
    color: var(--accent);
}

.settings-actions {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

body.modal-open {
    overflow: hidden;
}

.full-report {
    padding: 24px;
    background: rgba(0, 0, 0, 0.12);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    max-height: none;
    overflow: visible;
}

.error-card {
    max-width: 500px;
    margin: 60px auto;
    text-align: center;
    padding: 48px;
    background: var(--bg-card);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-lg);
}

.footer {
    padding: 24px 0;
    border-top: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.footer .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.footer-brand {
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
}

/* Средние экраны: навигация не помещается в строку рядом с логотипом и блоком
   пользователя (особенно у админа с 6 пунктами) — переносим её на отдельную строку. */
@media (max-width: 1200px) {
    .header .container { flex-wrap: wrap; row-gap: 12px; }
    .nav {
        order: 3;
        flex-basis: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
        scrollbar-width: thin;
    }
    .nav-link { flex-shrink: 0; white-space: nowrap; }
    .nav::-webkit-scrollbar { height: 4px; }
    .nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
}

@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        align-items: flex-start;
    }

    .user-badge {
        margin-left: 0;
        width: 100%;
        justify-content: space-between;
    }

    .hero-title {
        font-size: 2rem;
    }

    .auth-grid,
    .telegram-auth-grid,
    .status-grid,
    .result-overview,
    .result-dossier-grid,
    .overview-stats,
    .profile-list {
        grid-template-columns: 1fr;
    }

    .detail-row,
    .contact-row,
    .timeline-item {
        grid-template-columns: 1fr;
    }

    .auth-actions,
    .telegram-auth-actions,
    .search-wrapper,
    .results-header,
    .settings-actions,
    .footer .container {
        flex-direction: column;
    }

    .auth-actions .btn-secondary,
    .auth-actions .btn-primary,
    .telegram-auth-actions .btn-secondary,
    .telegram-auth-actions .btn-primary,
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }

    .result-content {
        padding: 20px;
    }

    .result-report-shell {
        padding: 20px;
    }

    .result-tabs {
        overflow-x: auto;
        padding: 12px;
    }
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::selection {
    background: rgba(0, 212, 255, 0.3);
    color: white;
}

/* ============ NARRATIVE "выжимка" reading view — 2026-05-29 ============ */

.result-narrative {
    max-width: 820px;
    margin: 0 auto;
    padding: 6px 2px 4px;
}

.narrative-head {
    margin-bottom: 26px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}
.narrative-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-secondary);
    margin-bottom: 14px;
}
.narrative-kicker svg { width: 16px; height: 16px; }
.narrative-head h2 {
    font-size: 2.1rem;
    line-height: 1.16;
    margin: 0 0 18px;
    color: var(--text-primary);
}
.narrative-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
}
.meta-chip svg { width: 14px; height: 14px; color: var(--text-muted); }

.confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 13px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--border);
}
.confidence-badge svg { width: 15px; height: 15px; }
.conf-high { color: var(--success); border-color: rgba(65, 211, 162, 0.42); background: rgba(65, 211, 162, 0.10); }
.conf-medium { color: var(--accent-secondary); border-color: rgba(240, 179, 90, 0.42); background: rgba(240, 179, 90, 0.10); }
.conf-low { color: var(--text-muted); border-color: var(--border); background: rgba(255, 255, 255, 0.03); }

/* The digest itself — readable prose */
.narrative-body {
    font-size: 1.12rem;
    line-height: 1.85;
    color: var(--text-secondary);
}
.narrative-body p { margin: 0 0 18px; }
.narrative-body p:first-child {
    color: var(--text-primary);
    font-size: 1.2rem;
    line-height: 1.7;
}
.narrative-body p:last-child { margin-bottom: 0; }

/* Soft callouts (no tables) */
.narrative-callout {
    margin-top: 22px;
    padding: 18px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.03);
}
.callout-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    margin-bottom: 10px;
}
.callout-title svg { width: 16px; height: 16px; }
.narrative-callout ul { margin: 0; padding-left: 20px; color: var(--text-secondary); line-height: 1.7; }
.narrative-callout li { margin-bottom: 6px; }
.narrative-callout li:last-child { margin-bottom: 0; }
.narrative-callout p { margin: 0; color: var(--text-secondary); line-height: 1.7; }
.callout-warning { border-color: rgba(240, 93, 93, 0.30); background: rgba(240, 93, 93, 0.07); }
.callout-warning .callout-title { color: var(--warning); }
.callout-accent { border-color: rgba(65, 211, 162, 0.28); background: rgba(65, 211, 162, 0.06); }
.callout-accent .callout-title { color: var(--accent); }

/* Sources footnote */
.narrative-sources { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--border); }
.sources-label {
    display: block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.source-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.source-tag {
    display: inline-flex;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
}

@media (max-width: 760px) {
    .narrative-head h2 { font-size: 1.62rem; }
    .narrative-body { font-size: 1.05rem; line-height: 1.8; }
    .narrative-body p:first-child { font-size: 1.1rem; }
}

/* ===== Markdown-formatted выжимка (2026-05-29) ===== */
.narrative-body h3.md-h { font-size: 1.18rem; color: var(--text-primary); margin: 24px 0 12px; padding-bottom: 7px; border-bottom: 1px solid var(--border); }
.narrative-body h3.md-h:first-child { margin-top: 0; }
.narrative-body h4.md-h { font-size: 1rem; color: var(--accent); margin: 16px 0 8px; }
.narrative-body .md-ul { margin: 0 0 16px; padding-left: 2px; list-style: none; }
.narrative-body .md-ul li { position: relative; padding-left: 20px; margin-bottom: 8px; line-height: 1.62; color: var(--text-secondary); }
.narrative-body .md-ul li::before { content: ""; position: absolute; left: 3px; top: 10px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.narrative-body strong { color: var(--text-primary); font-weight: 600; }
.narrative-body a { color: var(--accent); text-decoration: none; word-break: break-all; }
.narrative-body a:hover { text-decoration: underline; }
.narrative-body p { margin: 0 0 14px; }

/* ===== Чат-ассистент (2026-05-29) ===== */
/* ===== Раскладка чата с боковой панелью истории ===== */
.chat-layout { display:flex; gap:16px; align-items:stretch; height:min(72vh,640px); }
.chat-sidebar { width:250px; flex-shrink:0; display:flex; flex-direction:column; gap:10px; background:rgba(255,255,255,0.02); border:1px solid var(--border); border-radius:16px; padding:12px; overflow:hidden; }
.chat-new-btn { display:flex; align-items:center; justify-content:center; gap:8px; padding:11px 14px; border-radius:12px; border:1px solid rgba(65,211,162,0.3); background:rgba(65,211,162,0.1); color:var(--accent); font:inherit; font-weight:600; font-size:0.9rem; cursor:pointer; transition:all .15s; }
.chat-new-btn:hover { background:rgba(65,211,162,0.18); }
.chat-search-wrap { position:relative; display:flex; align-items:center; }
.chat-search-icon { position:absolute; left:10px; color:var(--text-muted); pointer-events:none; }
.chat-search { width:100%; padding:9px 10px 9px 30px; border-radius:10px; border:1px solid var(--border); background:var(--bg-glass); color:var(--text-primary); font:inherit; font-size:0.84rem; outline:none; }
.chat-search:focus { border-color:rgba(65,211,162,0.4); }
.chat-search::placeholder { color:var(--text-muted); }
.chat-list { flex:1; overflow-y:auto; display:flex; flex-direction:column; gap:4px; }
.chat-list-empty { color:var(--text-muted); font-size:0.8rem; text-align:center; padding:16px 8px; }
.chat-list-item { display:flex; align-items:center; gap:6px; padding:10px 12px; border-radius:10px; cursor:pointer; color:var(--text-secondary); font-size:0.86rem; border:1px solid transparent; transition:all .12s; }
.chat-list-item:hover { background:rgba(255,255,255,0.04); color:var(--text-primary); }
.chat-list-item.active { background:rgba(65,211,162,0.10); border-color:rgba(65,211,162,0.24); color:var(--text-primary); }
.chat-list-title { flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.chat-list-del { opacity:0; border:none; background:none; color:var(--text-muted); cursor:pointer; font-size:1.05rem; padding:0 4px; border-radius:6px; line-height:1; flex-shrink:0; }
.chat-list-item:hover .chat-list-del { opacity:0.7; }
.chat-list-del:hover { opacity:1 !important; color:var(--warning); }
.chat-card { display:flex; flex-direction:column; height:min(72vh,640px); padding:0; overflow:hidden; flex:1; min-width:0; }
.chat-card .section-header { padding:20px 24px; margin:0; border-bottom:1px solid var(--border); }
.chat-messages { flex:1; overflow-y:auto; padding:22px 24px; display:flex; flex-direction:column; gap:16px; }
.chat-empty { margin:auto; max-width:460px; text-align:center; color:var(--text-muted); line-height:1.7; }
.chat-msg { display:flex; }
.chat-msg.chat-user { justify-content:flex-end; }
.chat-msg.chat-assistant { flex-direction:column; align-items:flex-start; }
.chat-bubble { max-width:82%; padding:13px 16px; border-radius:16px; line-height:1.65; font-size:1rem; word-break:break-word; }
.chat-user .chat-bubble { background:var(--accent-gradient); color:#06121a; border-bottom-right-radius:6px; font-weight:500; }
.chat-assistant .chat-bubble { background:rgba(255,255,255,0.04); border:1px solid var(--border); color:var(--text-secondary); border-bottom-left-radius:6px; max-width:94%; }
.chat-assistant .chat-bubble h3.md-h { font-size:1.05rem; margin:14px 0 8px; padding-bottom:5px; }
.chat-assistant .chat-bubble h3.md-h:first-child { margin-top:0; }
.chat-assistant .chat-bubble .md-ul { margin:0 0 10px; }
.chat-assistant .chat-bubble p { margin:0 0 10px; }
.chat-assistant .chat-bubble p:last-child, .chat-assistant .chat-bubble .md-ul:last-child { margin-bottom:0; }
.chat-steps { display:flex; flex-wrap:wrap; gap:6px; margin-bottom:8px; }
.chat-step { font-size:0.78rem; color:var(--accent-secondary); background:rgba(240,179,90,0.1); border:1px solid rgba(240,179,90,0.25); border-radius:999px; padding:4px 10px; }
.chat-input-bar { display:flex; gap:10px; padding:16px 24px; border-top:1px solid var(--border); align-items:flex-end; }
.chat-input { flex:1; resize:none; max-height:160px; padding:12px 14px; border-radius:14px; border:1px solid var(--border); background:var(--bg-glass); color:var(--text-primary); font:inherit; font-size:1rem; line-height:1.5; outline:none; }
.chat-input:focus { border-color:rgba(65,211,162,0.4); }
.chat-send { flex:0 0 46px; height:46px; width:46px; border:none; border-radius:14px; background:var(--accent-gradient); color:#06121a; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:var(--transition); }
.chat-send:hover { transform:translateY(-1px); }
.chat-attach { flex:0 0 46px; height:46px; width:46px; border:1px solid var(--border); border-radius:14px; background:var(--bg-glass); color:var(--text-secondary); cursor:pointer; display:flex; align-items:center; justify-content:center; transition:var(--transition); }
.chat-attach:hover { color:var(--text-primary); border-color:rgba(65,211,162,0.4); transform:translateY(-1px); }
.chat-typing { display:inline-flex; gap:5px; align-items:center; padding:4px 2px; }
.chat-typing span { width:7px; height:7px; border-radius:50%; background:var(--text-muted); animation:chatdot 1.2s infinite ease-in-out; }
.chat-typing span:nth-child(2){ animation-delay:.2s; }
.chat-typing span:nth-child(3){ animation-delay:.4s; }
@keyframes chatdot { 0%,60%,100%{ opacity:.3; transform:translateY(0); } 30%{ opacity:1; transform:translateY(-3px); } }

/* ===== Кнопки копирования: вся переписка + каждое сообщение ===== */
.chat-card .section-header { display:flex; align-items:center; gap:10px; }
.chat-copyall-btn { margin-left:auto; display:inline-flex; align-items:center; gap:6px; padding:7px 13px; font:inherit; font-size:0.82rem; font-weight:600; color:var(--accent); background:transparent; border:1px solid var(--accent); border-radius:10px; cursor:pointer; transition:all .15s; white-space:nowrap; }
.chat-copyall-btn:hover { background:var(--accent); color:#06121a; }
.chat-copyall-btn.copied { background:#16a34a; border-color:#16a34a; color:#fff; }
.chat-copyall-btn svg { flex-shrink:0; }
.chat-msg { position:relative; }
.msg-copy { position:absolute; bottom:-9px; width:24px; height:24px; padding:0; display:inline-flex; align-items:center; justify-content:center; border:none; border-radius:7px; cursor:pointer; color:var(--text-muted); background:var(--bg-glass); opacity:0; transition:opacity .15s, color .15s, background .15s; }
.chat-user .msg-copy { right:4px; }
.chat-assistant .msg-copy { left:4px; }
.chat-msg:hover .msg-copy { opacity:.6; }
.msg-copy:hover { opacity:1 !important; color:var(--accent); background:rgba(65,211,162,0.14); }
.msg-copy.copied { opacity:1 !important; color:#16a34a; }
@media (hover:none) { .msg-copy { opacity:.45; } }
@media (max-width:760px){ .chat-copyall-btn .copyall-label { display:none; } }
@media (max-width:760px){
    .chat-bubble{ max-width:90%; }
    .chat-layout{ flex-direction:column; height:auto; gap:10px; }
    /* боковая панель -> компактная горизонтальная лента (без пустых блоков) */
    .chat-sidebar{ width:auto; max-height:none; flex-direction:row; align-items:center; gap:8px; overflow-x:auto; overflow-y:hidden; padding:8px 10px; }
    .chat-sidebar .chat-search-wrap{ display:none; }
    .chat-new-btn{ flex-shrink:0; white-space:nowrap; padding:9px 12px; font-size:0.85rem; }
    .chat-list{ flex-direction:row; overflow-x:auto; overflow-y:hidden; gap:6px; flex:1; }
    .chat-list-item{ flex-shrink:0; max-width:150px; padding:8px 12px; }
    .chat-list-del{ display:none; }
    /* карточка чата выше — intro и сообщения не обрезаются */
    .chat-card{ height:auto; min-height:64vh; }
    .chat-card .section-header{ padding:14px 16px; }
    .chat-messages{ padding:16px 14px; }
    .chat-empty{ font-size:0.95rem; }
    /* поле ввода: помещается плейсхолдер, кнопка по центру */
    .chat-input-bar{ padding:12px 14px; align-items:center; }
    .chat-input{ font-size:0.95rem; padding:11px 12px; }
}

/* ===== Фото в выжимке/чате ===== */
.chat-photo, .narrative-body img {
    display: inline-block;
    max-width: 180px;
    max-height: 220px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin: 6px 8px 6px 0;
    object-fit: cover;
    vertical-align: top;
    background: rgba(255,255,255,0.04);
}
.chat-assistant .chat-bubble .chat-photo { max-width: 160px; }
.chat-bubble .mermaid {
    margin: 12px 0;
    padding: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-x: auto;
    text-align: center;
    font-size: 0.85rem;
    line-height: 1.2;
}
.chat-bubble .mermaid svg { max-width: 100%; height: auto; }

/* ===== Управление доступом (whitelist) ===== */
.users-add { display:flex; gap:10px; margin:16px 0 18px; flex-wrap:wrap; }
.users-add-input { flex:1; min-width:200px; padding:12px 14px; border-radius:12px; border:1px solid var(--border); background:var(--bg-glass); color:var(--text-primary); font:inherit; outline:none; }
.users-add-input:focus { border-color:rgba(65,211,162,0.4); }
.users-list { display:flex; flex-direction:column; gap:8px; }
.user-row { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:12px 14px; border:1px solid var(--border); border-radius:12px; background:rgba(255,255,255,0.03); }
.user-row.user-allowed { border-color:rgba(65,211,162,0.25); background:rgba(65,211,162,0.05); }
.user-info { display:flex; flex-direction:column; gap:2px; min-width:0; }
.user-phone { color:var(--text-primary); font-family:'JetBrains Mono',monospace; word-break:break-all; }
.user-name { color:var(--text-muted); font-size:0.85rem; }
.user-pending { font-style:italic; color:var(--accent-secondary); }
.user-badge { font-size:0.78rem; padding:5px 10px; border-radius:999px; white-space:nowrap; }
.user-badge-admin { color:var(--accent-secondary); background:rgba(240,179,90,0.12); border:1px solid rgba(240,179,90,0.3); }
.user-allow { color:var(--accent) !important; border-color:rgba(65,211,162,0.3) !important; }
.user-revoke { color:var(--warning) !important; }

/* ===== Лимиты пользователей ===== */
.user-controls { display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.user-limit { display:flex; align-items:center; gap:6px; }
.user-limit-used { font-size:0.82rem; color:var(--text-muted); font-family:'JetBrains Mono',monospace; white-space:nowrap; }
.user-limit-input { width:84px; padding:6px 8px; border-radius:8px; border:1px solid var(--border); background:var(--bg-glass); color:var(--text-primary); font:inherit; font-size:0.85rem; outline:none; }
.user-limit-input:focus { border-color:rgba(65,211,162,0.4); }
.user-limit-info { font-size:0.8rem; color:var(--text-muted); }

/* ===== Журнал активности ===== */
.activity-toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:6px 0 14px; flex-wrap:wrap; }
.activity-filters { display:flex; gap:6px; }
.activity-filter { padding:6px 14px; border-radius:999px; border:1px solid var(--border); background:rgba(255,255,255,0.03); color:var(--text-muted); font:inherit; font-size:0.85rem; cursor:pointer; transition:all .15s; }
.activity-filter:hover { color:var(--text-primary); }
.activity-filter.active { color:var(--accent); border-color:rgba(65,211,162,0.4); background:rgba(65,211,162,0.08); }
.activity-list { display:flex; flex-direction:column; gap:8px; max-height:62vh; overflow-y:auto; }
.activity-row { display:flex; gap:14px; padding:12px 14px; border:1px solid var(--border); border-radius:12px; background:rgba(255,255,255,0.03); }
.activity-side { display:flex; flex-direction:column; gap:6px; align-items:flex-start; min-width:74px; flex-shrink:0; }
.activity-kind { font-size:0.74rem; padding:3px 9px; border-radius:999px; white-space:nowrap; font-weight:600; }
.activity-kind-search { color:var(--accent); background:rgba(65,211,162,0.12); border:1px solid rgba(65,211,162,0.3); }
.activity-kind-chat { color:var(--accent-secondary); background:rgba(240,179,90,0.12); border:1px solid rgba(240,179,90,0.3); }
.activity-time { font-size:0.78rem; color:var(--text-muted); font-family:'JetBrains Mono',monospace; white-space:nowrap; }
.activity-main { display:flex; flex-direction:column; gap:4px; min-width:0; flex:1; }
.activity-who { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.activity-phone { color:var(--text-secondary); font-family:'JetBrains Mono',monospace; font-size:0.85rem; }
.activity-name { color:var(--text-muted); font-size:0.85rem; }
.activity-admin { font-size:0.72rem; padding:2px 8px; border-radius:999px; color:var(--accent-secondary); background:rgba(240,179,90,0.12); border:1px solid rgba(240,179,90,0.3); }
.activity-query { color:var(--text-primary); font-size:0.92rem; line-height:1.45; word-break:break-word; white-space:pre-wrap; }

/* ===== Живой прогресс агента ===== */
.chat-progress { display:inline-flex; align-items:center; gap:8px; color:var(--text-secondary); }
.chat-progress-dots { display:inline-flex; gap:4px; align-items:center; }
.chat-progress-dots span { width:6px; height:6px; border-radius:50%; background:var(--accent); animation:chatdot 1.2s infinite ease-in-out; }
.chat-progress-dots span:nth-child(2){ animation-delay:.2s; }
.chat-progress-dots span:nth-child(3){ animation-delay:.4s; }

/* Кнопка скачивания готового Excel в чате (конвейер лидов) */
.chat-dl-link { display:inline-block; margin-top:8px; padding:9px 16px; border-radius:12px; background:var(--accent-gradient); color:#06121a !important; font-weight:600; text-decoration:none; transition:var(--transition); }
.chat-dl-link:hover { transform:translateY(-1px); box-shadow:0 6px 18px rgba(65,211,162,0.25); }
