/* static/css/urbanist.css */

/* =====================================================
   URBANIST DASHBOARD - СДЕРЖАННАЯ ЦВЕТОВАЯ ГАММА
   FIXED: Modal inheritance, z-index conflicts, font specifications
   ===================================================== */

/* Custom color scheme for urbanist - более спокойные тона */
:root {
    /* Primary urbanist colors — Editorial Calm (ТЗ §6.1): значения =
       платформенные --primary/--primary-dark/--primary-lightest.
       ВАЖНО: только ЛИТЕРАЛЫ — ниже есть `--primary: var(--urbanist-primary)`,
       и var(--primary) здесь дал бы ЦИКЛ → обе переменные invalid →
       прозрачные кнопки с невидимым текстом (реальный баг 2026-07-16). */
    --urbanist-primary: var(--status-success);
    --urbanist-primary-hover: var(--dark);
    --urbanist-primary-light: var(--status-success-bg);
    --urbanist-primary-dark: var(--dark);

    /* Secondary - убрана яркая фуксия */
    --urbanist-secondary: var(--gray-500);      /* Нейтральный серо-голубой */
    --urbanist-secondary-hover: var(--text-secondary);

    /* Accent - приглушенный оранжевый */
    --urbanist-accent: var(--accent-color);         /* Более спокойный оранжевый */
    --urbanist-accent-hover: var(--accent-hover);

    /* Override base colors for urbanist theme */
    --primary: var(--urbanist-primary);
    --primary-hover: var(--urbanist-primary-hover);
    --primary-light: var(--urbanist-primary-light);
    --primary-dark: var(--urbanist-primary-dark);

    /* Z-index system */
    --z-sidebar: 100;
    --z-header: 200;
    --z-dropdown: 300;
    --z-overlay: 400;
    /* Modal layers inherit the shared scale above floating widgets. */
    --z-toast: 600;
    --z-tooltip: 700;

    /* Urbanist-specific gradients - более мягкие */
    --urbanist-gradient-primary: linear-gradient(135deg, var(--urbanist-primary) 0%, var(--urbanist-secondary) 100%);
    --urbanist-gradient-accent: linear-gradient(135deg, var(--urbanist-accent) 0%, var(--danger-dark) 100%);
    --urbanist-gradient-soft: color-mix(in srgb, var(--status-success) 5%, transparent);
}

/* Accessibility */
.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
.btn:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--urbanist-primary, var(--color-primary));
    outline-offset: 2px;
}

/* Ensure fonts are applied to all elements */
body,
body * {
    font-family: var(--font-sans);
}

/* ✅ НОВОЕ: Стили для сортируемых заголовков колонок */
.table thead th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 24px;
}

.table thead th.sortable:hover {
    background-color: color-mix(in srgb, var(--status-success) 5%, transparent);
}

.table thead th.sortable .sort-indicator {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.9em;
    color: var(--urbanist-secondary);
    transition: color 0.2s;
}

.table thead th.sortable.sorted .sort-indicator {
    color: var(--urbanist-primary);
    font-weight: bold;
}

.table thead th.sortable:hover .sort-indicator {
    color: var(--urbanist-primary);
}

/* Header customization for urbanist (shared dashboard header) */
@media (max-width: 767px) {
    body[data-dashboard-theme="urbanist"] .education-widget-slot {
        /* Reserve the screen edges for the existing drawer handles. */
        padding-inline: var(--spacing-xl);
    }
}

body[data-dashboard-theme="urbanist"] .dashboard-header .header-right {
    gap: var(--spacing-sm);
    /* §12: шапка была переполнена уже на 1280 (KPI-блок 850px + виджеты =
       1452px) — часть контролов уезжала за экран. Правая группа сжимается,
       KPI-блок скроллится внутри себя. */
    min-width: 0;
}

body[data-dashboard-theme="urbanist"] .dashboard-header .header-right > .u-flex {
    min-width: 0;
    flex: 0 1 auto;
    overflow-x: auto;
}

body[data-dashboard-theme="urbanist"] .urbanist-header-kpis .kpi-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.35rem 0.6rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1;
}

body[data-dashboard-theme="urbanist"] .urbanist-header-kpis .kpi-pill strong {
    color: var(--urbanist-primary);
}

/* На mobile header переполняется: KPI скрываем, оставляем только название
   + переход к мастеру. KPI пользователь увидит в основном теле. */
@media (max-width: 768px) {
    body[data-dashboard-theme="urbanist"] .urbanist-header-kpis {
        display: none;
    }
}

/* KPI cards with urbanist theme - убрана градиентная заливка */
.kpi-card {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
}

.kpi-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.kpi-value {
    color: var(--urbanist-primary);
    font-weight: 700;
}

.kpi-label {
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.75rem;
}

/* Buttons with urbanist style - более спокойные */


.btn-ghost:hover:not(:disabled) {
    background: var(--urbanist-primary-light);
    color: var(--urbanist-primary);
}

/* View tabs with urbanist style */
.view-tab {
    border-color: var(--border);
    background: var(--bg-elevated);
}

.view-tab:hover {
    background: var(--urbanist-primary-light);
    color: var(--urbanist-primary);
    border-color: var(--urbanist-primary);
}

.view-tab.active {
    background: var(--urbanist-primary);
    color: var(--text-inverse);
    border-color: transparent;
    box-shadow: 0 1px 3px color-mix(in srgb, var(--status-success) 20%, transparent);
}

/* Search input with urbanist style */
.search-input:focus,
.input:focus {
    border-color: var(--urbanist-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-success) 10%, transparent);
}

/* Progress bar with urbanist style - упрощенный */
.progress {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.progress-bar {
    background: var(--urbanist-primary);
    position: relative;
    transition: width 0.3s ease;
}

/* Map customizations for urbanist */
.custom-marker {
    background: var(--bg-elevated);
    border: 2px solid var(--urbanist-primary) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all var(--transition-fast);
}

/* Leaflet divIcon container should be transparent; the inner .custom-marker is the visual */
.custom-marker-container,
.city-marker-container,
.custom-search-marker {
    background: transparent !important;
    border: none !important;
}

/* ✅ FIX: Ensure MapLibre markers are clickable above map canvas and overlays */
.maplibregl-marker {
    pointer-events: auto !important;
    z-index: 10 !important;
    cursor: pointer;
}

.maplibregl-marker .custom-marker-container,
.maplibregl-marker .city-marker-container,
.custom-marker-container.maplibregl-marker,
.city-marker-container.maplibregl-marker {
    pointer-events: auto !important;
    cursor: pointer;
}

/* Base city marker layout */
.city-marker {
    position: relative;
    width: 40px;
    height: 40px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
    pointer-events: auto !important;
}

.marker-content {
    font-size: 0.95rem;
    line-height: 1;
    letter-spacing: -0.02em;
}

.marker-count-badge {
    position: absolute;
    bottom: -7px;
    right: -7px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--urbanist-primary);
    color: var(--text-inverse);
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--white);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.marker-badge {
    position: absolute;
    top: -5px;
    left: -5px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
}

.urbanist-kb-overlay {
    top: clamp(16px, 2vw, 36px);
    right: clamp(20px, 4vw, 56px);
    max-width: clamp(260px, 26vw, 360px);
    pointer-events: none; /* Don't block map interaction */
}
.urbanist-kb-overlay > * {
    pointer-events: auto; /* But children (buttons, links) remain clickable */
}

/* Popup z-index — see components/map-popups.css */

@media (max-width: 1200px) {
    .urbanist-kb-overlay {
        display: none;
    }
}

.custom-marker:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: scale(1.05);
}

.city-marker--wizard {
    border-color: var(--warning) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 25%, transparent), 0 0 20px color-mix(in srgb, var(--warning) 35%, transparent);
    animation: wizardPulse 1.8s ease-in-out infinite;
}

.city-marker--wizard .marker-content {
    color: var(--warning) !important;
}

.city-marker--wizard .marker-count-badge {
    background: var(--warning);
}

.city-marker--ready {
    border-color: var(--info) !important;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--info) 25%, transparent);
}

.city-marker--ready .marker-content {
    color: var(--info) !important;
}

.city-marker--pending {
    border-color: var(--gray-400) !important;
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--gray-400) 20%, transparent);
}

.city-marker--pending .marker-content {
    color: var(--text-secondary) !important;
}

/* New / starting surveys (recent pending) */
.city-marker--starting {
    border-color: var(--warning) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 18%, transparent), 0 0 18px color-mix(in srgb, var(--warning) 22%, transparent);
}

.city-marker--starting .marker-content {
    color: var(--status-warning) !important;
}

.city-marker--starting .marker-count-badge {
    background: var(--warning);
}

.marker-ribbon {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--warning);
    color: var(--text-inverse);
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 999px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

@keyframes wizardPulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--warning) 40%, transparent); }
    70% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--warning) 0%, transparent); }
    100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--warning) 0%, transparent); }
}

.marker-content {
    color: var(--urbanist-primary) !important;
    font-weight: 600;
}

.marker-badge {
    background: var(--urbanist-accent);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.wizard-badge {
    background: color-mix(in srgb, var(--warning) 12%, transparent);
    color: var(--warning);
    border-radius: 999px;
    font-size: 0.75rem;
    padding: 2px 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.wizard-badge--muted {
    background: color-mix(in srgb, var(--warning) 8%, transparent);
    color: color-mix(in srgb, var(--warning) 70%, transparent);
}

.map-legend {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#parser-keywords-view {
    position: absolute;
    inset: 0;
    padding: var(--spacing-md);
    overflow: auto;
    background: var(--bg-primary);
}

#parser-keywords-view .card {
    max-width: 1200px;
    margin: 0 auto;
}

#parser-keywords-view .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    align-items: end;
}

#parser-keywords-view .form-group.align-end {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}

#parser-keywords-view .table-responsive {
    border: 1px solid var(--border);
    border-radius: 10px;
    max-height: 45vh;
    overflow: auto;
    background: var(--bg-elevated);
}

#parser-keywords-view table.table th,
#parser-keywords-view table.table td {
    white-space: nowrap;
    vertical-align: top;
}

#parser-keywords-view td.pk-keywords-cell {
    white-space: normal;
    max-width: 520px;
}

#parser-keywords-view .pk-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

#parser-keywords-view .pk-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--status-success) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--status-success) 22%, transparent);
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.1;
}

#parser-keywords-view .pk-chip.pk-chip--dup {
    background: color-mix(in srgb, var(--danger) 8%, transparent);
    border-color: color-mix(in srgb, var(--danger) 22%, transparent);
    color: var(--danger);
}

#parser-keywords-view .pk-chip.pk-chip--more {
    background: color-mix(in srgb, var(--dark) 6%, transparent);
    border-color: color-mix(in srgb, var(--dark) 10%, transparent);
    color: color-mix(in srgb, var(--dark) 75%, transparent);
    font-weight: 700;
}

#parser-keywords-view .pk-chip button {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    color: inherit;
    font-weight: 800;
}

#parser-keywords-view .pk-hint {
    border: 1px solid color-mix(in srgb, var(--status-success) 18%, transparent);
    background: color-mix(in srgb, var(--primary-lightest) 60%, transparent);
    border-radius: 14px;
    padding: 12px 14px;
    margin-bottom: 12px;
}

#parser-keywords-view .pk-hint-title {
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

#parser-keywords-view .pk-hint-text {
    color: color-mix(in srgb, var(--dark) 80%, transparent);
    font-size: 0.9rem;
    line-height: 1.35;
}

#parser-keywords-view .pk-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 10px 0 12px;
}

#parser-keywords-view .pk-search {
    width: min(520px, 60vw);
}

#parser-keywords-view .pk-edit-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

#parser-keywords-view .pk-llm-box {
    margin-top: 10px;
    border: 1px solid color-mix(in srgb, var(--status-success) 18%, transparent);
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    border-radius: 14px;
    padding: 12px 12px;
}

#parser-keywords-view .pk-llm-head {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: flex-start;
    margin-bottom: 10px;
}

#parser-keywords-view .pk-llm-title {
    font-weight: 800;
    color: var(--text-primary);
}

#parser-keywords-view .pk-llm-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

#parser-keywords-view .pk-llm-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#parser-keywords-view .pk-llm-suggestions .pk-chip {
    background: color-mix(in srgb, var(--success) 10%, transparent);
    border-color: color-mix(in srgb, var(--success) 22%, transparent);
    color: var(--success);
}

#parser-keywords-view .pk-llm-suggestions .pk-chip.is-selected {
    outline: 2px solid color-mix(in srgb, var(--success) 55%, transparent);
    outline-offset: 1px;
}

#parser-keywords-view #pk-edit-keywords,
#parser-keywords-view textarea.form-control {
    min-height: 110px;
    resize: vertical;
}

.map-legend .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
}

.map-legend .legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.legend-item--ready .legend-dot {
    background: var(--info);
}

.legend-item--pending .legend-dot {
    background: var(--gray-400);
}

.survey-list-section {
    margin-bottom: var(--spacing-lg);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-sm);
}

.section-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.section-counter {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.survey-row-empty td {
    text-align: center;
    font-style: italic;
    color: var(--text-muted);
}

.list-view-tabs {
    display: inline-flex;
    gap: var(--spacing-xs);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px;
    background: var(--bg-primary);
    margin-bottom: var(--spacing-sm);
}

.list-view-tab {
    border: none;
    background: transparent;
    padding: 6px 16px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
}

.list-view-tab.active {
    background: var(--urbanist-primary);
    color: var(--text-inverse);
    box-shadow: 0 6px 24px color-mix(in srgb, var(--status-success) 35%, transparent);
}

.list-view-hint {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.survey-list-section.list-section-hidden {
    display: none;
}

.pipeline-chip {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--success-dark) 10%, transparent);
    color: var(--success-dark);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.pipeline-chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--success-dark) 15%, transparent);
}

.pipeline-chip.pipeline-in_progress {
    background: color-mix(in srgb, var(--status-info) 10%, transparent);
    color: var(--info);
}

.pipeline-chip.pipeline-pending {
    background: color-mix(in srgb, var(--warning-dark) 15%, transparent);
    color: var(--status-warning);
}

.pipeline-chip.pipeline-completed {
    background: color-mix(in srgb, var(--success) 12%, transparent);
    color: var(--success);
}

.pipeline-chip.pipeline-failed {
    background: color-mix(in srgb, var(--danger) 15%, transparent);
    color: var(--danger);
}

.pipeline-progress-mini {
    margin-top: 4px;
    height: 4px;
    background: var(--bg-hover);
    border-radius: 999px;
    overflow: hidden;
}

.pipeline-progress-mini > div {
    height: 100%;
    background: var(--urbanist-primary);
    transition: width 0.3s ease;
}

.pipeline-stage-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.pipeline-actions {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pipeline-actions .btn {
    width: 100%;
}

.pipeline-hint {
    margin-top: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px dashed var(--border-light);
    line-height: 1.4;
}

.pipeline-progress-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(24px, 4vw, 48px);
    background: color-mix(in srgb, var(--dark) 55%, transparent);
    opacity: 0;
    pointer-events: none;
    /* visibility убирает скрытый модал из tab-order (axe aria-hidden-focus) */
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: var(--z-modal);
}

.pipeline-progress-modal.open {
    opacity: 1;
    pointer-events: auto;
    visibility: visible;
}

.pipeline-progress-modal__backdrop {
    position: absolute;
    inset: 0;
}

.pipeline-progress-modal__dialog {
    position: relative;
    width: min(960px, 100%);
    max-height: 90vh;
    overflow: hidden;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 20px 60px color-mix(in srgb, var(--dark) 35%, transparent);
    display: flex;
    flex-direction: column;
}

.pipeline-progress-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.pipeline-modal-summary {
    padding: 0 var(--spacing-lg) var(--spacing-md);
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.pipeline-modal-stage-list {
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.pipeline-stage-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    background: var(--bg-primary);
}

.pipeline-stage-card:last-child {
    margin-bottom: 0;
}

.pipeline-stage-card--empty {
    text-align: center;
    font-style: italic;
    color: var(--text-muted);
}

.pipeline-stage-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.pipeline-stage-card__title {
    font-weight: 600;
    color: var(--text-primary);
}

.pipeline-stage-card__status {
    font-size: 0.85rem;
    font-weight: 600;
}

.pipeline-stage-card[data-status="completed"] {
    border-color: color-mix(in srgb, var(--success) 40%, transparent);
    background: color-mix(in srgb, var(--success) 5%, transparent);
}

.pipeline-stage-card[data-status="failed"] {
    border-color: color-mix(in srgb, var(--danger) 40%, transparent);
    background: color-mix(in srgb, var(--danger) 5%, transparent);
}

.pipeline-stage-card[data-status="in_progress"] {
    border-color: color-mix(in srgb, var(--status-info) 40%, transparent);
}

.pipeline-task-list {
    margin-top: var(--spacing-sm);
    border-top: 1px solid var(--border);
    padding-top: var(--spacing-sm);
}

.pipeline-task {
    display: flex;
    justify-content: space-between;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border-light);
}

.pipeline-task:last-child {
    border-bottom: none;
}

.pipeline-task__info {
    flex: 1;
}

.pipeline-task__status {
    font-weight: 600;
    min-width: 120px;
    text-align: right;
}

.pipeline-task__status[data-status="completed"] {
    color: var(--success);
}

.pipeline-task__status[data-status="failed"] {
    color: var(--danger);
}

.pipeline-task__status[data-status="in_progress"] {
    color: var(--info);
}

.pipeline-task__status[data-status="pending"],
.pipeline-task__status[data-status="waiting"] {
    color: var(--text-muted);
}

.pipeline-task--empty {
    font-style: italic;
    color: var(--text-muted);
}

.pipeline-task__meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.pipeline-task__error {
    font-size: 0.78rem;
    color: var(--danger);
}

.media-sources-modal p {
    margin-top: 0;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* Блок «Канал города» в модалке автопостинга. Сам компонент
   (window.CityChannelBinder) везёт свои стили с собой — здесь только
   обрамление в модалке Урбаниста, чтобы не дублировать .ccb-*. */
.city-channel-block {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    background: var(--surface-2, transparent);
}

.city-channel-title {
    margin: 0 0 10px;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.media-sources-sep {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

.media-sources-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.media-source-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.media-source-item.selected {
    border-color: var(--urbanist-primary);
    box-shadow: 0 12px 20px -12px color-mix(in srgb, var(--status-success) 40%, transparent);
}

.media-source-info {
    flex: 1;
}

.media-source-title {
    font-weight: 600;
    color: var(--text-primary);
}

.media-source-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Состояние сбора с источника: чип исхода + причина словами.
   Причина переносится, а не обрезается многоточием — обрезанная причина
   не лечится, а именно ради лечения она и показана. */
.media-source-state {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.media-source-state-reason {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.media-source-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    color: var(--text-primary);
}

.media-source-toggle input[type="checkbox"] {
    transform: scale(1.2);
}

.media-sources-empty {
    text-align: center;
    padding: 24px;
    border: 1px dashed var(--primary-lightest);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
    background: var(--bg-secondary);
}

.media-sources-add {
    display: flex;
    gap: 8px;
    margin: 8px 0 16px;
    align-items: stretch;
}

.media-sources-add-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    background: var(--bg-elevated);
    color: var(--text-primary);
    min-height: 44px;
}

.media-sources-add-input:focus {
     border-color: var(--urbanist-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--status-success) 15%, transparent);
}

.media-source-delete {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 1.3rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.media-source-delete:hover,
.media-source-delete:focus-visible {
    background: var(--danger-lightest);
    color: var(--status-danger);
    border-color: var(--danger-lighter);
 }

/* Cluster icons with urbanist theme - спокойные цвета */
.cluster-icon {
    background: var(--bg-elevated);
    border: 2px solid var(--urbanist-primary);
    color: var(--urbanist-primary);
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cluster-small {
    border-color: var(--urbanist-primary) !important;
}

.cluster-medium {
    border-color: var(--urbanist-secondary) !important;
    color: var(--urbanist-secondary) !important;
}

.cluster-large {
    border-color: var(--urbanist-accent) !important;
    color: var(--urbanist-accent) !important;
}

/* Cluster state coloring (derived from child markers) */
.cluster--wizard {
    border-color: var(--warning) !important;
    color: var(--warning) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 18%, transparent), 0 0 18px color-mix(in srgb, var(--warning) 22%, transparent);
}

.cluster--starting {
    border-color: var(--warning) !important;
    color: var(--status-warning) !important;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--warning) 16%, transparent), 0 0 18px color-mix(in srgb, var(--warning) 20%, transparent);
}

.cluster--ready {
    border-color: var(--info) !important;
    color: var(--info) !important;
}

.cluster--pending {
    border-color: var(--gray-400) !important;
    color: var(--text-secondary) !important;
}

/* Safety net: if default Leaflet markercluster styles leak in, override them too */
.marker-cluster,
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: transparent !important;
}

.marker-cluster div,
.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: var(--bg-elevated) !important;
    border: 2px solid var(--urbanist-primary) !important;
    color: var(--urbanist-primary) !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 999px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Table enhancements for urbanist */
.table tr:hover {
    background: var(--bg-secondary);
}

.table tr.active {
    background: var(--urbanist-primary-light) !important;
    position: relative;
}

.table tr.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--urbanist-primary);
}

.table tr.selected {
    background: var(--warning-lightest) !important;  /* Легкий желтоватый для выделения */
}

/* Badge variations - без градиентов */
.badge {
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    transition: all var(--transition-fast);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
}

.badge-success {
    background: color-mix(in srgb, var(--success) 15%, var(--bg-primary));
    color: var(--success);
}

.badge-warning {
    background: color-mix(in srgb, var(--warning) 15%, var(--bg-primary));
    color: var(--status-warning);
}

.badge-danger {
    background: color-mix(in srgb, var(--danger) 15%, var(--bg-primary));
    color: var(--danger);
}

.badge-info {
    background: var(--urbanist-primary-light);
    color: var(--urbanist-primary);
}

/* Card styles with urbanist theme */
.card {
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: all var(--transition-fast);
    background: var(--bg-elevated);
}

.card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
}

.card-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.card-title {
    color: var(--text-primary);
    font-weight: 600;
}

/* Tab system with urbanist style */
.tab {
    position: relative;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
}

.tab.active {
    color: var(--urbanist-primary);
    font-weight: 500;
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--urbanist-primary);
}

.tab:hover:not(.active) {
    color: var(--urbanist-primary);
    background: var(--urbanist-primary-light);
}

/* Parser item styles - спокойные цвета */
.parser-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: var(--spacing-sm) var(--spacing-md);
}

.parser-item:hover {
    border-color: var(--urbanist-primary);
    box-shadow: 0 2px 4px color-mix(in srgb, var(--status-success) 10%, transparent);
}

.parser-icon {
    background: var(--urbanist-primary-light);
}

.parser-status {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--success);
}

.parser-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

@media (max-width: 640px) {
    body[data-dashboard-theme="urbanist"] #sources-view .parser-item {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-sm);
    }
    body[data-dashboard-theme="urbanist"] #sources-view .parser-info,
    body[data-dashboard-theme="urbanist"] #sources-view .parser-details {
        min-width: 0;
    }
    body[data-dashboard-theme="urbanist"] #sources-view .parser-details {
        overflow-wrap: anywhere;
    }
    body[data-dashboard-theme="urbanist"] #sources-view .parser-icon {
        flex-shrink: 0;
    }
    body[data-dashboard-theme="urbanist"] #sources-view .parser-actions {
        flex-wrap: wrap;
    }
    body[data-dashboard-theme="urbanist"] #sources-view .parser-actions .btn {
        flex: 1 1 auto;
        min-width: 0;
        white-space: normal;
    }
}

.parser-inspector-modal {
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--dark) 55%, transparent);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: var(--z-modal);
}

.parser-inspector-modal.is-visible {
    display: flex;
}

.parser-inspector-modal__dialog {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    max-width: 980px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px color-mix(in srgb, var(--dark) 25%, transparent);
    border: 1px solid color-mix(in srgb, var(--status-success) 10%, transparent);
}

.parser-inspector-modal__backdrop {
    position: absolute;
    inset: 0;
}

.parser-inspector-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
}

.parser-inspector-eyebrow {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.parser-inspector-body {
    padding: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.parser-inspector-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--spacing-md);
}

.parser-summary-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm) var(--spacing-md);
}

.parser-summary-item .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.parser-progress-panel {
    background: var(--dark);
    color: var(--text-inverse);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    box-shadow: inset 0 1px 0 color-mix(in srgb, var(--bg-primary) 5%, transparent);
}

.parser-progress-bar {
    background: color-mix(in srgb, var(--bg-primary) 15%, transparent);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.parser-progress-bar > div {
    background: var(--primary);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.parser-history-section,
.parser-config-section,
.parser-result-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
}

.parser-history-header,
.parser-config-toolbar,
.parser-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.parser-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.parser-history-entry {
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: space-between;
}

.parser-history-entry .status-chip {
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-chip.success {
    background: color-mix(in srgb, var(--success) 15%, transparent);
    color: var(--success);
}

.status-chip.error {
    background: color-mix(in srgb, var(--danger) 15%, transparent);
    color: var(--danger);
}

.status-chip.pending {
    background: color-mix(in srgb, var(--warning) 15%, transparent);
    color: var(--status-warning);
}

.parser-config-textarea {
    width: 100%;
    min-height: 220px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    border: 1px solid var(--primary-lightest);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
    background: var(--bg-elevated);
    color: var(--text-primary);
    resize: vertical;
}

.parser-config-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-sm);
}

.parser-result-preview {
    background: var(--bg-elevated);
    border-radius: var(--radius-md);
    border: 1px dashed var(--info-lightest);
    padding: var(--spacing-md);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    max-height: 220px;
    overflow-y: auto;
}

@media (max-width: 768px) {
    .parser-inspector-modal {
        padding: 1rem;
    }
    .parser-inspector-modal__dialog {
        max-height: 100vh;
    }
}

/* Sidebar sections */
.sidebar {
    background: var(--bg-secondary);
    box-shadow: none;
}

.sidebar-section {
    border-bottom: 1px solid var(--border);
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}


.sidebar-title svg {
    fill: var(--urbanist-primary);
    opacity: 0.7;
}

/* Empty state styling */
.empty-state-icon {
    opacity: 0.3;
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Loading spinner is standardized in static/css/components/loading.css */

/* Modal styles (Urbanist)
   IMPORTANT: do NOT override generic `.modal` z-index with `!important`.
   `modalManager` uses `.modal` for dynamic modals and sets z-index inline.
   These rules are scoped to Bootstrap modals only (.fade/.show) to avoid
   "blurred / not clickable" modals (overlay stacking issues).
*/

/* Center Bootstrap modals like other dashboards */
.modal.fade,
.modal.show {
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex !important;
    padding: 1.5rem;
}

.modal.show .modal-dialog {
    margin: 0;
}

@media (max-width: 768px) {
    .modal.show {
        align-items: flex-start;
        padding-top: 2.5rem;
    }
}

/* Improved backdrop support (Bootstrap modals only) */
.modal.fade,
.modal.show {
    background: rgba(0, 0, 0, 0.35);
}

@supports (backdrop-filter: blur(4px)) {
    .modal.fade,
    .modal.show {
        background: rgba(0, 0, 0, 0.3);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
}

/* DS-03: локальный .modal-content удалён — шрифт модалок задаёт канон
   components/modals.css (секция FONT INHERITANCE: .modal * → var(--font-sans)),
   тень — канонический box-shadow: var(--shadow-2xl). */

/* ==========================================
   Survey Wizard Modal Enhancements
   ========================================== */
.survey-wizard-dialog {
    max-width: min(1600px, 96vw);
    width: clamp(1100px, 90vw, 1600px);
    margin: 0 auto;
    padding: 1.5rem;
}

.survey-wizard-modal {
    transition: none;
}

.survey-wizard-modal.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    padding: 2rem;
    background: color-mix(in srgb, var(--dark) 35%, transparent);
    backdrop-filter: blur(6px);
    z-index: var(--z-modal);
}

.survey-wizard-modal .modal-dialog {
    width: clamp(1400px, 94vw, 1900px) !important;
    max-width: none !important;
    margin: 0 auto;
}

.survey-wizard-content {
    border-radius: var(--radius-2xl);
    border: none;
    min-height: 640px;
    max-height: min(1000px, 96vh);
    box-shadow: 0 30px 60px color-mix(in srgb, var(--dark) 25%, transparent);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100% !important;
    max-width: none !important;
}

.survey-wizard-body {
    padding: 0;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.survey-wizard {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 40px;
    padding: 40px 48px;
    height: 100%;
    min-height: 0;
}

.survey-wizard .wizard-progress {
    background: var(--urbanist-primary-light);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: sticky;
    top: 0;
    max-height: calc(90vh - 64px);
    overflow-y: auto;
    border: 1px solid color-mix(in srgb, var(--status-success) 15%, transparent);
}

.wizard-progress .progress-connector {
    display: none;
}

.wizard-progress .progress-step {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid transparent;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.wizard-progress .progress-step.active {
    background: var(--bg-elevated);
    border-color: color-mix(in srgb, var(--status-success) 25%, transparent);
    color: var(--urbanist-primary);
    box-shadow: var(--shadow-sm);
}

.wizard-progress .progress-step .step-number {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-lg);
    background: var(--bg-elevated);
    color: var(--urbanist-primary);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--status-success) 25%, transparent);
}

.wizard-progress .progress-step.active .step-number {
    background: var(--urbanist-primary);
    color: var(--text-inverse);
    box-shadow: none;
}

.wizard-progress .progress-step .step-label {
    font-weight: 600;
    line-height: 1.3;
}

.wizard-progress .progress-step.completed {
    opacity: 0.7;
}

.survey-wizard .wizard-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-height: none;
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    padding-right: 8px;
}

.survey-wizard .wizard-step {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--dark) 4%, transparent);
}

.survey-wizard .step-title {
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.survey-wizard .form-group {
    margin-bottom: 20px;
    position: relative;
}

.survey-wizard .form-group label.required::after {
    content: '*';
    margin-left: 4px;
    color: var(--danger);
}

/* NOTE: form-control sizing + геокодер-dropdown стили мастера живут в
   dashboard-base.css (.survey-wizard ...) — он грузится и в дашборде
   урбаниста, и на отдельной странице /admin survey_wizard. */

.survey-wizard .wizard-actions {
    position: sticky;
    bottom: -1px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 16px 0 0;
    margin-top: auto;
    background: linear-gradient(180deg, transparent 0%, var(--bg-primary) 45%);
    border-top: 1px solid var(--border);
}

/* Мастер новых исследований (autonomous_master): stepper, progress, url-preview, inline errors */
.wizard-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 24px;
    padding: 16px 0;
}
.wizard-stepper__step {
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0.5;
    transition: opacity 0.3s;
}
.wizard-stepper__step.active,
.wizard-stepper__step.completed {
    opacity: 1;
}
.wizard-stepper__number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--urbanist-primary-light);
    color: var(--urbanist-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    position: relative;
}
.wizard-stepper__step.active .wizard-stepper__number {
    background: var(--urbanist-primary);
    color: var(--text-inverse);
}
.wizard-stepper__step.completed .wizard-stepper__number {
    background: var(--success);
    color: var(--text-inverse);
    font-size: 0;
}
.wizard-stepper__step.completed .wizard-stepper__number::after {
    content: '✓';
    font-size: 1rem;
    font-weight: 600;
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.wizard-stepper__connector {
    flex: 1;
    height: 2px;
    background: var(--border);
    margin: 0 16px;
}
.generation-progress {
    margin-bottom: 16px;
}
.generation-progress__bar {
    height: 8px;
    background: var(--urbanist-primary-light);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 8px;
}
.generation-progress__fill {
    height: 100%;
    background: var(--urbanist-primary);
    width: 0%;
    transition: width 0.3s ease;
}
.generation-progress__text {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.url-preview {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}
.url-preview__label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}
#url-preview-value {
    font-size: 0.9rem;
    background: var(--bg-elevated);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    display: inline-block;
}
.url-preview__note {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 6px;
}
.field-error {
    border-color: var(--danger) !important;
}
.field-error-message {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 4px;
}

.survey-wizard .wizard-error {
    border-radius: var(--radius-lg);
    border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}

.survey-wizard .survey-type-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.survey-wizard .type-option {
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    transition: var(--transition);
}

.survey-wizard .type-option input {
    display: none;
}

.survey-wizard .type-option label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 18px;
    cursor: pointer;
    height: 100%;
}

.survey-wizard .type-option .type-icon {
    font-size: 1.5rem;
}

.survey-wizard .type-option .type-title {
    font-weight: 600;
    color: var(--text-primary);
}

.survey-wizard .type-option .type-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.survey-wizard .type-option input:checked + label,
.survey-wizard .type-option:hover {
    background: var(--bg-elevated);
    border-radius: var(--radius-xl);
    box-shadow: 0 10px 20px color-mix(in srgb, var(--status-success) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--status-success) 30%, transparent);
}

.survey-wizard .summary-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 16px;
    background: var(--bg-secondary);
}

.survey-wizard .summary-item {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 6px 0;
    font-size: 0.95rem;
}

.survey-wizard .summary-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.survey-wizard .summary-value {
    color: var(--text-primary);
    font-weight: 600;
    text-align: right;
}

@media (max-width: 1280px) {
    .survey-wizard {
        grid-template-columns: 360px minmax(0, 1fr);
        padding: 32px;
        gap: 28px;
    }
    .survey-wizard-modal .modal-dialog,
    .survey-wizard-dialog {
        width: min(1200px, 94vw) !important;
    }
}

@media (max-width: 1024px) {
    .survey-wizard {
        grid-template-columns: 1fr;
        padding: 24px;
    }
    .survey-wizard-modal .modal-dialog,
    .survey-wizard-dialog {
        width: min(960px, 94vw) !important;
    }

    .survey-wizard .wizard-progress {
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        max-height: none;
    }

    .wizard-progress .progress-step {
        flex: 1 1 220px;
    }
}

@media (max-width: 640px) {
    .survey-wizard-dialog {
        padding: 0;
    }
    .survey-wizard-modal .modal-dialog,
    .survey-wizard-dialog {
        width: 100% !important;
        margin: 0;
    }

    .survey-wizard {
        padding: 20px 20px 28px;
    }

    .survey-wizard .wizard-progress {
        flex-direction: column;
    }

    .survey-wizard .wizard-form {
        max-height: none;
        padding-right: 0;
    }

    .survey-wizard .wizard-step {
        padding: 18px;
    }

    .survey-wizard .wizard-actions {
        flex-direction: column-reverse;
        align-items: stretch;
    }
}

.modal-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-family: var(--font-sans)!important;
}

/* Notification customization - FIXED */
.notification {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    font-family: var(--font-sans)!important;
}

.notification * {
    font-family: inherit !important;
}

.notification.success {
    border-left: 3px solid var(--success);
}

.notification.error {
    border-left: 3px solid var(--danger);
}

.notification.warning {
    border-left: 3px solid var(--warning);
}

.notification.info {
    border-left: 3px solid var(--urbanist-primary);
}

/* Loading overlay/spinner are provided by static/css/components/loading.css */

/* AI Roles (Prompts) styles - спокойные */
.prompt-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

.prompt-card:hover {
    border-color: var(--urbanist-primary);
    box-shadow: 0 4px 6px color-mix(in srgb, var(--status-success) 10%, transparent);
}

.prompt-card .card-header {
    background: color-mix(in srgb, var(--status-success) 5%, transparent);
}

.prompts-info-banner {
    background: color-mix(in srgb, var(--info) 8%, var(--bg-primary));
    border: 1px solid var(--info-lightest);
}

/* Footer styles */
.app-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.footer-actions .btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
}

.footer-actions .btn:hover {
    background: var(--urbanist-primary-light);
    border-color: var(--urbanist-primary);
    color: var(--urbanist-primary);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .kpi-card {
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    }

    .app-logo span {
        display: none;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--border);
    }
}

/* High specificity fixes for technical windows */
.modal,
.modal .modal-content,
.modal .modal-header,
.modal .modal-body,
.modal .modal-footer,
.loading-overlay,
.loading-overlay .loading-content,
.notification {
    font-family: var(--font-sans)!important;
}

/* Ensure all text in modals uses proper font */
.modal h1, .modal h2, .modal h3, .modal h4, .modal h5, .modal h6,
.modal p, .modal span, .modal div, .modal label, .modal input,
.modal button, .modal a {
    font-family: inherit !important;
}
/* ==========================================
   DSS Assistant Styles
   ========================================== */

.dss-message {
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
}

.dss-message-user {
    justify-content: flex-end;
}

.dss-message-assistant {
    justify-content: flex-start;
}

.dss-message-content {
    max-width: 80%;
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.5;
}

.dss-message-user .dss-message-content {
    background: var(--urbanist-gradient-primary);
    color: var(--text-inverse);
    border-bottom-right-radius: var(--radius-sm);
}

.dss-message-assistant .dss-message-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-bottom-left-radius: var(--radius-sm);
}

.dss-message.dss-error .dss-message-content {
    background: color-mix(in srgb, var(--danger) 10%, transparent);
    border-color: color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--danger);
}

/* Loading animation */
.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--urbanist-primary);
    border-radius: 50%;
    animation: loadingDot 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loadingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.dss-suggestion {
    font-size: 0.875rem;
    padding: var(--spacing-xs) var(--spacing-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.dss-suggestion:hover {
    background: var(--urbanist-primary-light);
    border-color: var(--urbanist-primary);
    color: var(--urbanist-primary);
}

#dss-messages {
    min-height: 200px;
}

#dss-messages::-webkit-scrollbar {
    width: 6px;
}

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

#dss-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

#dss-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Knowledge Base snapshot --- */
.kb-card {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 16px;
    background: var(--bg-elevated);
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 12px 24px color-mix(in srgb, var(--dark) 8%, transparent);
}

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

.kb-stats-grid span.label {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.kb-stats-grid strong {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.kb-pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.kb-pill {
    padding: 4px 10px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--status-success) 8%, transparent);
    border: 1px solid color-mix(in srgb, var(--status-success) 20%, transparent);
    font-size: 0.8rem;
    color: var(--primary-dark);
}

.kb-fact-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kb-fact-item {
    border: 1px solid color-mix(in srgb, var(--gray-400) 40%, transparent);
    border-radius: var(--radius-lg);
    padding: 10px 12px;
    background: var(--bg-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

.kb-fact-item small {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.kb-placeholder {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* === Accessibility === */
/* .visually-hidden объявлен выше в этом же файле — второй копии не держим. */

.btn:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--urbanist-primary, var(--color-primary));
    outline-offset: 2px;
}

/* === Connection indicator === */
.connection-indicator {
    display: inline-flex;
    align-items: center;
    margin-left: 12px;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.connection-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--success);
    transition: background 0.3s;
    flex-shrink: 0;
}
.connection-dot.disconnected {
    background: var(--danger);
}
.connection-reconnect-btn {
    font-size: 0.75rem;
    padding: 1px 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    display: none;
}
.connection-dot.disconnected ~ .connection-reconnect-btn {
    display: inline-block;
}

/* === Toast notifications === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: var(--z-toast, 600);
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast-item {
    padding: 10px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    color: var(--text-inverse);
    pointer-events: auto;
    animation: toastIn 0.3s ease forwards;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.toast-item.toast-success { background: var(--success); }
.toast-item.toast-error { background: var(--danger); }
.toast-item.toast-warning { background: var(--warning); color: var(--text-primary); }
.toast-item.toast-info { background: var(--info); }
.toast-item.toast-removing { animation: toastOut 0.2s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(40px); } }

/* === Empty state === */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state p { margin: 12px 0; font-size: 0.9rem; }
.empty-state .btn { margin-top: 16px; }

/* === 👥 Команда ЦПУ — карточки специалистов (лица + текущая задача) === */
.cpu-team-strip { width: 100%; }
.cpu-team-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.cpu-member {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    padding: 12px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 12px);
    background: var(--bg-elevated, var(--white));
    transition: var(--transition-fast, all .15s ease);
}
.cpu-member:hover {
    border-color: var(--urbanist-primary, var(--color-primary));
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.07);
}
.cpu-member--lead {
    background: var(--urbanist-primary-light);
    border-color: var(--urbanist-primary, var(--color-primary));
}
.cpu-ava {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    flex-shrink: 0;
}
.cpu-ava--lead {
    background: var(--urbanist-primary, var(--color-primary));
    color: var(--text-inverse, var(--white));
    border-color: var(--urbanist-primary, var(--color-primary));
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: .5px;
}
/* Реальное фото профиля (users.avatar_url) — заполняет круг. */
.cpu-ava--photo {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    color: transparent;
}
.cpu-member-name {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.2;
}
.cpu-member-task {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cpu-team-meta {
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-align: center;
}

/* 🏘 Команды города — несколько city_teams компактными чипами */
.cpu-teams {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}
.cpu-teams-head {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}
.cpu-teams-count {
    display: inline-block;
    min-width: 18px;
    padding: 0 6px;
    margin-left: 4px;
    font-size: 0.75rem;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    background: var(--urbanist-primary, var(--color-primary));
    color: var(--text-inverse, var(--white));
}
.cpu-teams-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.cpu-team-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-primary);
}
.cpu-team-chip-name { font-weight: 600; }
.cpu-team-chip-meta { color: var(--text-secondary); font-size: 0.75rem; }
/* ============================================================
   Разгрузка правой панели (2026-07-03): группы вкладок
   11 вкладок → 3 смысловые группы. Ряды вкладок (.tab-row)
   переключаются классом u-hidden, вкладки/контент не менялись.
   ============================================================ */
.tab-groups {
    display: flex;
    gap: 4px;
    padding: 6px 6px 0;
    border-bottom: 1px solid var(--border);
}
.tab-group-btn {
    flex: 1 1 auto;
    padding: 7px 8px;
    border: none;
    border-bottom: 3px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    border-radius: var(--radius) var(--radius) 0 0;
    white-space: nowrap;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.tab-group-btn:hover { background: var(--bg-secondary); }
.tab-group-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ============================================================
   Сеть ЦПУ (#cpu-network-view): соседние города, команды, обмены
   ============================================================ */
.cpun-section-title {
    margin: 20px 0 10px;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 8px;
}
.cpun-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border-radius: 999px;
    padding: 2px 9px;
}
.cpun-count--alert {
    color: var(--white);
    background: var(--warning);
}
.cpun-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}
.cpun-card { margin: 0; }
.cpun-card--mine {
    border-left: 4px solid var(--primary);
}
.cpun-city-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    flex-wrap: wrap;
}
.cpun-city-name { font-weight: 700; font-size: 1rem; }
.cpun-badge-mine {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    border-radius: 999px;
    padding: 2px 8px;
    vertical-align: middle;
}
.cpun-metrics {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.cpun-metrics span {
    font-size: 0.78rem;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    white-space: nowrap;
}
.cpun-team-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}
.cpun-team-row:last-child { border-bottom: none; }
.cpun-team-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cpun-team-name { font-weight: 600; }
.cpun-exchanges {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 12px;
}
.cpun-exchange-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--border);
}
.cpun-exchange-row:last-child { border-bottom: none; }
.cpun-exchange-main { min-width: 0; flex: 1 1 auto; }
.cpun-exchange-actions { display: flex; gap: 6px; flex: 0 0 auto; flex-wrap: wrap; }
.cpun-res-type {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    margin-right: 4px;
    white-space: nowrap;
}
.cpun-status {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}
.cpun-status--offered { background: color-mix(in srgb, var(--warning) 14%, transparent); color: var(--status-warning); }
.cpun-status--accepted { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success-dark); }
.cpun-status--declined { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--status-danger); }
.cpun-dataset { margin-top: 6px; font-size: 0.82rem; }
.cpun-dataset summary { cursor: pointer; color: var(--primary); }
.cpun-fact { padding: 3px 0 3px 8px; color: var(--text-secondary); }

/* Модалы сети ЦПУ (создание команды / предложение обмена) */
.cpun-modal {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cpun-modal-backdrop {
    position: absolute;
    inset: 0;
    background: color-mix(in srgb, var(--dark) 55%, transparent);
}
.cpun-modal-dialog {
    position: relative;
    width: min(480px, calc(100vw - 32px));
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    background: var(--bg-primary, var(--white));
    color: var(--text-primary);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: 0 20px 60px color-mix(in srgb, var(--dark) 35%, transparent);
}

/* ── Командный центр: классы вместо статических inline (F-07, декомпозиция
   этап 1.5, 2026-07-17). Значения перенесены 1:1 из inline-стилей. ── */
.cc-section-scroll {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    padding: var(--spacing-md);
    background: var(--bg-primary);
}
.cc-max-width { max-width: 1280px; margin: 0 auto; }
.cc-title { font-size: 1.3rem; }
.cc-city-select { max-width: 240px; padding: 6px 10px; font-size: 0.85rem; }
.cc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    align-items: start;
}
.cc-card--full { grid-column: 1 / -1; }
.cc-launcher-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}
.cc-launcher--card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 14px;
    text-align: left;
    height: auto;
    text-decoration: none;
}
.cc-city-map { height: 240px; border-radius: var(--radius-md); background: var(--bg-secondary); }
