/**
 * Dashboard Base Styles - Unified Design System
 * Version 4.1 - Added Cultural Map Components
 * FIXED: Font imports, modal styles, backdrop-filter fallbacks
 */

/* ========================================================================
   Design tokens moved to static/css/variables.css
   ======================================================================== */

/* Stream Recorder styles were moved to static/css/stream-panel.css and are lazy-loaded
   by static/js/stream/streamToggle.js (to avoid global z-index collisions). */

/* ========================================================================
   RESET & BASE
   ======================================================================== */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body[data-dashboard-theme] {
    /* One-screen dashboards: keep footer visible and make inner panes scroll */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* body stays flex-column; nav-sidebar is position:fixed, shell uses margin-left */

body[data-dashboard-theme] .dashboard-header {
    flex-shrink: 0;
}

/* Desktop: lock body height so footer never "falls down" */
@media (min-width: 901px) {
    html,
    body[data-dashboard-theme] {
        height: 100%;
    }

    body[data-dashboard-theme] {
        height: 100vh;
        overflow: hidden;
    }
}

/* ========================================================================
   NAV SIDEBAR — persistent vertical navigation
   ======================================================================== */

:root {
    --nav-sidebar-width: 240px;
    --nav-sidebar-collapsed-width: 56px;
}

.nav-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--nav-sidebar-width);
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.nav-sidebar.collapsed {
    width: var(--nav-sidebar-collapsed-width);
}

/* Brand / Logo area */
.nav-sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    height: 48px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.nav-sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    min-width: 0;
    overflow: hidden;
}

.nav-sidebar-logo-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    color: var(--primary);
}

.nav-sidebar-brand-text {
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s;
}

.nav-sidebar.collapsed .nav-sidebar-brand-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* Toggle button */
.nav-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.nav-sidebar-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-sidebar .toggle-icon-expand { display: none; }
.nav-sidebar .toggle-icon-collapse { display: block; }
.nav-sidebar.collapsed .toggle-icon-expand { display: block; }
.nav-sidebar.collapsed .toggle-icon-collapse { display: none; }

/* Menu area */
.nav-sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.nav-sidebar-menu::-webkit-scrollbar {
    width: 4px;
}

.nav-sidebar-menu::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* Section labels */
.nav-sidebar-section {
    padding: 4px 0;
}

.nav-sidebar-section-label {
    display: block;
    padding: 6px 16px 4px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s;
}

.nav-sidebar.collapsed .nav-sidebar-section-label {
    opacity: 0;
    height: 0;
    padding: 0;
    overflow: hidden;
}

/* Nav items */
.nav-sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    margin: 1px 8px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    cursor: pointer;
    border: none;
    background: none;
    width: calc(100% - 16px);
    text-align: left;
    transition: background 0.15s, color 0.15s;
}

.nav-sidebar-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-sidebar-item.active {
    background: var(--primary);
    color: #fff;
}

.nav-sidebar-item.active:hover {
    background: var(--primary-dark, var(--primary));
    color: #fff;
}

.nav-sidebar-item.disabled {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

.nav-sidebar-item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1;
}

.nav-sidebar-item-icon svg {
    width: 20px;
    height: 20px;
}

.nav-sidebar-item-text {
    opacity: 1;
    transition: opacity 0.2s;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-sidebar.collapsed .nav-sidebar-item-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.nav-sidebar.collapsed .nav-sidebar-item {
    justify-content: center;
    padding: 8px;
    margin: 1px 6px;
    gap: 0;
}

/* Bottom section */
.nav-sidebar-bottom {
    border-top: 1px solid var(--border);
    padding: 8px 0;
    flex-shrink: 0;
}

/* Theme toggle icons */
.nav-sidebar-theme-btn .theme-icon-dark { display: none; }
[data-theme="dark"] .nav-sidebar-theme-btn .theme-icon-light { display: none; }
[data-theme="dark"] .nav-sidebar-theme-btn .theme-icon-dark { display: block; }

/* ========================================================================
   DASHBOARD SHELL — offset by nav sidebar
   ======================================================================== */

.dashboard-shell {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    min-width: 0;
    margin-left: var(--nav-sidebar-width);
    transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100vh;
    overflow: hidden;
}

html.nav-sidebar-is-collapsed .dashboard-shell {
    margin-left: var(--nav-sidebar-collapsed-width);
}

/* ========================================================================
   NAV SIDEBAR BACKDROP & MOBILE TOGGLE
   ======================================================================== */

.nav-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.25s;
}

.nav-sidebar-backdrop.visible {
    display: block;
    opacity: 1;
}

.nav-sidebar-mobile-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 201;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .nav-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        width: var(--nav-sidebar-width);
    }

    .nav-sidebar.mobile-open {
        transform: translateX(0);
    }

    .dashboard-shell {
        margin-left: 0;
    }

    html.nav-sidebar-is-collapsed .dashboard-shell {
        margin-left: 0;
    }

    .nav-sidebar-mobile-toggle {
        display: flex;
    }
}

@media print {
    .nav-sidebar,
    .nav-sidebar-backdrop,
    .nav-sidebar-mobile-toggle {
        display: none !important;
    }

    .dashboard-shell {
        margin-left: 0 !important;
    }
}

/* ========================================================================
   DASHBOARD HEADER (unified) — Phase 2: compact after nav-link cleanup
   ======================================================================== */

body[data-dashboard-theme] .dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    padding: 0 var(--spacing-lg);
    height: var(--header-height, 48px);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}

body[data-dashboard-theme] .dashboard-header .header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    min-width: 0;
}

body[data-dashboard-theme] .dashboard-header .header-left h1 {
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body[data-dashboard-theme] .dashboard-header .city-name,
body[data-dashboard-theme] .dashboard-header .survey-name {
    font-size: 0.8125rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 40vw;
}

body[data-dashboard-theme] .dashboard-header .header-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.375rem;
    flex-wrap: nowrap;
}

/* Hide header-right when empty (all nav links removed) */
body[data-dashboard-theme] .dashboard-header .header-right:empty {
    display: none;
}

/* Header center stats (moderator, etc.) — compact */
body[data-dashboard-theme] .dashboard-header .header-center {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

body[data-dashboard-theme] .dashboard-header .stats-container {
    display: flex;
    gap: var(--spacing-md);
}

body[data-dashboard-theme] .dashboard-header .stat-item {
    text-align: center;
    line-height: 1.2;
}

body[data-dashboard-theme] .dashboard-header .stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

body[data-dashboard-theme] .dashboard-header .stat-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

body[data-dashboard-theme] .llm-balance-widget {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

body[data-dashboard-theme] .llm-balance-widget .details-link {
    color: var(--primary);
    text-decoration: none;
}

@media (max-width: 640px) {
    body[data-dashboard-theme] .dashboard-header {
        padding: 0 var(--spacing-md);
        height: var(--header-height-mobile, 40px);
    }
    body[data-dashboard-theme] .dashboard-header .header-left h1 {
        font-size: 0.875rem;
    }
    body[data-dashboard-theme] .dashboard-header .city-name,
    body[data-dashboard-theme] .dashboard-header .survey-name {
        display: none;
    }
    body[data-dashboard-theme] .dashboard-header .header-center {
        display: none;
    }
    body[data-dashboard-theme] .user-info-panel .user-details {
        display: none;
    }
}

body[data-dashboard-theme] .dashboard-main {
    /* Allow main layout to shrink so footer stays visible and inner panes can scroll */
    flex: 1 1 auto;
    width: 100%;
    display: flex;
    flex-direction: row;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-secondary);
    /* Subtle inner shadow to separate from header */
    box-shadow: inset 0 1px 0 var(--border);
}

/* Layout wrappers used by role dashboards inside shell.
   Each needs flex:1 + min-height:0 so the 3-column content fills the shell. */
.dashboard-shell .dashboard-layout,
.dashboard-shell .developer-dashboard-root,
.dashboard-shell .econ-wrap,
.dashboard-shell > .page-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: row;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

/* KPI/status bars between header and main — don't let them shrink */
.dashboard-shell .strategy-kpi-grid,
.dashboard-shell .status-bar,
.dashboard-shell .view-mode-bar {
    flex-shrink: 0;
}

/* Main container (methodologist etc.) — fill shell like dashboard-main */
.dashboard-shell .main-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: row;
    min-height: 0;
    overflow: hidden;
    width: 100%;
}

/* Header actions — compact button group */
body[data-dashboard-theme] .header-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

/* User info panel in header — keep compact */
body[data-dashboard-theme] .user-info-panel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

body[data-dashboard-theme] .user-info-panel .user-avatar {
    font-size: 1.25rem;
    line-height: 1;
}

body[data-dashboard-theme] .user-info-panel .user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

body[data-dashboard-theme] .user-info-panel .user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body[data-dashboard-theme] .user-info-panel .user-meta {
    display: flex;
    gap: 0.5rem;
    font-size: 0.6875rem;
    color: var(--text-muted);
}

body[data-dashboard-theme] .dashboard-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    /* Critical for nested flex layouts: enables .content-wrapper/.view-pane scroll instead of clipping */
    min-height: 0;
    overflow: auto;
    padding: var(--spacing-md);
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

body[data-dashboard-theme] .dashboard-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

body[data-dashboard-theme] .dashboard-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

body[data-dashboard-theme] .dashboard-content::-webkit-scrollbar-track {
    background: transparent;
}

body[data-dashboard-theme] .dashboard-sidebar-left,
body[data-dashboard-theme] .dashboard-sidebar-right {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

body[data-dashboard-theme] .dashboard-sidebar-left::-webkit-scrollbar,
body[data-dashboard-theme] .dashboard-sidebar-right::-webkit-scrollbar {
    width: 4px;
}

body[data-dashboard-theme] .dashboard-sidebar-left::-webkit-scrollbar-thumb,
body[data-dashboard-theme] .dashboard-sidebar-right::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

body[data-dashboard-theme] .dashboard-sidebar-left {
    width: var(--sidebar-left-width);
    border-left: none;
    border-right: 1px solid var(--border);
}

body[data-dashboard-theme] .dashboard-sidebar-right {
    width: var(--sidebar-right-width);
    border-right: none;
    border-left: 1px solid var(--border);
}

body[data-dashboard-theme] .sidebar-section {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border);
}

body[data-dashboard-theme] .sidebar-section:last-child {
    border-bottom: none;
}

body[data-dashboard-theme] .sidebar-title {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: var(--spacing-sm);
}

/* Central panel containers — fill available space, scroll when needed */
body[data-dashboard-theme] .dashboard-main > main,
body[data-dashboard-theme] .dashboard-main .dashboard-center,
body[data-dashboard-theme] .dashboard-main .center-panel {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

@media (max-width: 1200px) {
    body[data-dashboard-theme] .dashboard-main {
        flex-direction: column;
    }
    body[data-dashboard-theme] .dashboard-sidebar-left,
    body[data-dashboard-theme] .dashboard-sidebar-right {
        width: 100%;
        max-height: 30vh;
        border: none;
    }
    body[data-dashboard-theme] .dashboard-sidebar-left { border-bottom: 1px solid var(--border); }
    body[data-dashboard-theme] .dashboard-sidebar-right { border-top: 1px solid var(--border); }
}

@media (max-width: 768px) {
    body[data-dashboard-theme] .dashboard-sidebar-left,
    body[data-dashboard-theme] .dashboard-sidebar-right {
        position: fixed;
        left: -100%;
        height: 100vh;
        z-index: var(--z-fixed);
        transition: left 0.3s;
        box-shadow: var(--shadow-lg);
        max-height: 100vh;
    }
    body[data-dashboard-theme] .dashboard-sidebar-right {
        left: auto;
        right: -100%;
        transition: right 0.3s;
    }
    body[data-dashboard-theme] .dashboard-sidebar-left.open { left: 0; }
    body[data-dashboard-theme] .dashboard-sidebar-right.open { right: 0; }
}

/* ========================================================================
   CONTEXT PANEL — slide-over panel (V2 Design System)
   Replaces permanent right sidebar for dashboards that need on-demand info.
   Usage: add .context-panel to a right-side element, toggle .is-open via JS.
   ======================================================================== */

.context-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 400px;
    max-width: 90vw;
    background: var(--bg-elevated, #fff);
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.08);
    z-index: var(--z-fixed, 100);
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.context-panel.is-open {
    transform: translateX(0);
}

.context-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.context-panel__title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.context-panel__close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.context-panel__close:hover {
    background: color-mix(in srgb, var(--danger) 12%, var(--bg-primary));
    color: var(--danger);
}

.context-panel__body {
    flex: 1 1 0;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* Backdrop overlay when panel is open */
.context-panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.2);
    z-index: calc(var(--z-fixed, 100) - 1);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.context-panel-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

[data-theme="dark"] .context-panel {
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.35);
}

/* Ensure font inheritance for all elements */
button, input, select, textarea, optgroup {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* ========================================================================
   TYPOGRAPHY
   ======================================================================== */

h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1.125rem; }
h6 { font-size: 1rem; }

p {
    margin: 0 0 1rem;
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
}

/* ========================================================================
   LAYOUT COMPONENTS
   ======================================================================== */

.page-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    z-index: var(--z-sticky);
    display: flex;
    align-items: center;
    padding: 0 var(--spacing-lg);
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(20px)) {
    .app-header {
        background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    }
}

.app-logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-left: auto;
    margin-right: auto;
}

/* ========================================================================
   KNOWLEDGE OVERLAY COMPONENT
   ======================================================================== */

.kb-overlay {
    position: absolute;
    top: clamp(12px, 2vw, 32px);
    right: clamp(12px, 3vw, 40px);
    width: clamp(240px, 24vw, 340px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
    z-index: 60;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    pointer-events: auto;
}

.kb-overlay.is-hidden {
    display: none;
}

.kb-overlay__header {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: flex-start;
}

.kb-overlay__eyebrow {
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 0.2rem;
}

.kb-overlay__title {
    font-size: 0.95rem;
    margin: 0;
    color: var(--text-primary);
}

.kb-overlay__btn {
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.kb-overlay__btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.kb-overlay__stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
}

.kb-overlay__stat {
    padding: 0.5rem;
    border-radius: var(--radius);
    background: var(--bg-tertiary);
}

.kb-overlay__stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.kb-overlay__stat-value {
    display: block;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.kb-overlay__section {
    border-top: 1px solid var(--border-light);
    padding-top: 0.6rem;
}

.kb-overlay__section h4 {
    margin: 0 0 0.4rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.kb-overlay__fact {
    padding: 0.35rem 0;
    border-bottom: 1px dashed var(--border-light);
}

.kb-overlay__fact:last-child {
    border-bottom: none;
}

.kb-overlay__fact-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.2rem;
}

.kb-overlay__fact-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
}

.kb-overlay__fact button {
    border: none;
    background: none;
    color: var(--primary);
    font-size: 0.78rem;
    padding: 0;
    cursor: pointer;
}

.kb-overlay__principle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.45rem;
    display: flex;
    gap: 0.4rem;
}

.kb-overlay__principle span {
    color: var(--primary);
    font-weight: 600;
}

.kb-overlay__footnote {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    gap: 0.4rem;
    align-items: center;
}

.kb-overlay__loading {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    color: var(--text-secondary);
    text-align: center;
}

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

.header-user-section {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

#current-user-name {
    font-weight: 500;
    color: var(--text-primary);
}

/* Footer */
.app-footer {
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    padding: var(--spacing-md) var(--spacing-lg);
    margin-top: auto;
}

@supports not (backdrop-filter: blur(20px)) {
    .app-footer {
        background: var(--bg-elevated);
    }
}

.footer-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-md);
}

/* Buttons moved to static/css/components/buttons.css */

/* ========================================================================
   FORMS
   ======================================================================== */

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.input,
.form-input,
.search-input {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--gray-900);
    background: var(--bg-elevated);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
    outline: none;
}

.input:focus,
.form-input:focus,
.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input:disabled {
    background: var(--gray-50);
    color: var(--text-muted);
    cursor: not-allowed;
}

textarea.input,
textarea.form-input {
    resize: vertical;
    min-height: 100px;
}

select.input {
    cursor: pointer;
}

/* ========================================================================
   CARDS
   ======================================================================== */

.card {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: var(--spacing-md);
    background: var(--gray-50);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--gray-900);
}

.card-body {
    padding: var(--spacing-md);
}

.card-footer {
    padding: var(--spacing-md);
    background: var(--gray-50);
    border-top: 1px solid var(--border);
}

/* ========================================================================
   CULTURAL MAP COMPONENTS
   ======================================================================== */

/* Masonry Grid Layout */
.masonry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Art Card */
.art-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    break-inside: avoid;
    position: relative;
    overflow: hidden;
}

.art-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.art-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.art-card:hover::before {
    opacity: 1;
}

/* Art Card Type Badge */
.art-card-type {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Art Type Specific Colors */
.art-card[data-type="street-art"] .art-card-type {
    background: rgba(231, 76, 60, 0.15);
    color: var(--art-street);
}

.art-card[data-type="music"] .art-card-type {
    background: rgba(52, 152, 219, 0.15);
    color: var(--art-music);
}

.art-card[data-type="visual-art"] .art-card-type {
    background: rgba(155, 89, 182, 0.15);
    color: var(--art-visual);
}

.art-card[data-type="design"] .art-card-type {
    background: rgba(46, 204, 113, 0.15);
    color: var(--art-design);
}

.art-card[data-type="event"] .art-card-type {
    background: rgba(243, 156, 18, 0.15);
    color: var(--art-event);
}

.art-card[data-type="other"] .art-card-type {
    background: rgba(149, 165, 166, 0.15);
    color: var(--art-other);
}

/* Art Card Content */
.art-card-title {
    margin: 12px 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    line-height: 1.4;
}

.art-card-author {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--gray-600);
    font-size: 14px;
    margin-bottom: 12px;
}

.art-card-author svg {
    width: 14px;
    height: 14px;
    opacity: 0.6;
}

.art-card-description {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin: 12px 0;
}

.art-card-location,
.art-card-date {
    font-size: 13px;
    color: var(--gray-500);
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.art-card-location::before {
    content: '📍';
}

.art-card-date::before {
    content: '📅';
}

.art-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light);
}

.art-card-actions .btn {
    flex: 1;
    font-size: 13px;
    padding: 8px 12px;
}

/* Filter Buttons */
.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.filter-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.filter-btn:hover {
    border-color: var(--primary);
    background: var(--primary-lightest);
    transform: translateY(-1px);
}

.filter-btn.active {
    background: var(--primary);
    color: var(--text-inverse);
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.filter-btn .filter-count {
    background: color-mix(in srgb, var(--bg-primary) 20%, transparent);
    padding: 2px 6px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
}

.filter-btn.active .filter-count {
    background: color-mix(in srgb, var(--bg-primary) 30%, transparent);
}

/* Art Statistics */
#art-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 20px 0;
}

#art-stats .stat-card {
    background: var(--bg-elevated);
    padding: 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    transition: var(--transition);
}

#art-stats .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#art-stats .stat-value {
    font-size: 32px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

#art-stats .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Cultural Map Tab */
#tab-cultural-map {
    padding: var(--spacing-lg);
}

#tab-cultural-map .content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

#tab-cultural-map .content-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

/* ========================================================================
   TABLES
   ======================================================================== */

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead {
    background: var(--gray-50);
}

.table th {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-600);
    text-align: left;
    border-bottom: 2px solid var(--border);
}

.table td {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}

.table tbody tr {
    transition: var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Modals moved to static/css/components/modals.css */

/* ========================================================================
   DASHBOARD LAYOUT - FLEX CONTAINERS
   ======================================================================== */

body.dashboard-layout {
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-sans);
}

body.dashboard-layout > .dashboard-header {
    flex-shrink: 0;
}

body.dashboard-layout > .main-container {
    flex: 1;
    display: flex;
    min-height: 0;
    min-width: 0;
}

body.dashboard-layout .sidebar {
    flex-shrink: 0;
    min-height: 0;
    overflow-y: auto;
}

body.dashboard-layout .main-content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

body.dashboard-layout .view-container,
body.dashboard-layout .view-panel {
    flex: 1;
    min-height: 0;
}

body.dashboard-layout .view-panel {
    display: none;
    overflow: auto;
}

body.dashboard-layout .view-panel.active {
    display: flex;
    flex-direction: column;
}

body.dashboard-layout footer,
body.dashboard-layout .dashboard-footer {
    flex-shrink: 0;
    margin-top: auto;
}

/* ========================================================================
   LOADING & STATES
   NOTE: loading overlay/spinner styles moved to static/css/components/loading.css
   ======================================================================== */

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: var(--spacing-md);
    opacity: 0.3;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-sm);
    font-family: var(--font-sans);
}

.empty-state-text {
    color: var(--text-secondary);
    font-size: 14px;
    font-family: var(--font-sans);
}

/* ========================================================================
   NOTIFICATIONS - FIXED
   ======================================================================== */

.notification {
    box-shadow: var(--shadow-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--spacing-md);
    font-family: var(--font-sans);
}

.notification * {
    font-family: var(--font-sans);
}

.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(--info);
}

/* ========================================================================
   BADGES
   ======================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    border-radius: var(--radius-full);
    line-height: 1.5;
    font-family: var(--font-sans);
}

.badge-primary {
    background: var(--primary);
    color: var(--text-inverse);
}

.badge-success {
    background: var(--success);
    color: var(--text-inverse);
}

.badge-warning {
    background: var(--warning);
    color: var(--text-inverse);
}

.badge-danger {
    background: var(--danger);
    color: var(--text-inverse);
}

.badge-info {
    background: var(--info);
    color: var(--text-inverse);
}

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

.sidebar {
    background: color-mix(in srgb, var(--bg-primary) 92%, transparent);
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

@supports (backdrop-filter: blur(20px)) {
    .sidebar {
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }
}

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

.sidebar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--spacing-sm);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    font-family: var(--font-sans);
}

/* ========================================================================
   KPI COMPONENTS
   ======================================================================== */

.kpi-container {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
}

.kpi-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    font-family: var(--font-sans);
}

.kpi-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: var(--font-sans);
}

/* Stats Row for Cultural Map */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: var(--bg-elevated);
    padding: var(--spacing-md);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.progress {
    height: 8px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    transition: width 0.3s ease;
}

/* ========================================================================
   UTILITIES
   ======================================================================== */

/* Text */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-xs { font-size: 12px; }
.text-sm { font-size: 13px; }
.text-md { font-size: 14px; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 18px; }
.text-2xl { font-size: 24px; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* Spacing */
.m-0 { margin: 0; }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

.p-0 { padding: 0; }
.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }

/* Display */
.hidden { display: none; }
.block { display: block; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }

.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }

.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }

.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }

.flex-1 { flex: 1; }
.flex-grow { flex-grow: 1; }
.flex-shrink-0 { flex-shrink: 0; }

.gap-xs { gap: var(--spacing-xs); }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

/* Width */
.w-full { width: 100%; }
.w-auto { width: auto; }

/* Borders */
.border { border: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }
.border-l { border-left: 1px solid var(--border); }
.border-r { border-right: 1px solid var(--border); }

.rounded { border-radius: var(--radius); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-md { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

/* Shadows */
.shadow-xs { box-shadow: var(--shadow-xs); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow { box-shadow: var(--shadow); }
.shadow-md { box-shadow: var(--shadow-md); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }
.shadow-2xl { box-shadow: var(--shadow-2xl); }

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

@media (max-width: 1024px) {
    .sidebar {
        width: 280px;
    }

    .masonry-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: 56px;
    }

    .app-header {
        padding: 0 var(--spacing-md);
    }

    .kpi-container {
        flex-direction: column;
        align-items: stretch;
    }

    .sidebar {
        display: none;
    }

    /* Cultural Map Mobile */
    .masonry-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .filter-buttons {
        padding: 12px;
        gap: 8px;
    }

    .filter-btn {
        font-size: 13px;
        padding: 6px 12px;
    }

    #art-stats {
        grid-template-columns: 1fr 1fr;
    }

    .art-card {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .header-title {
        font-size: 16px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .art-card-actions {
        flex-direction: column;
    }

    .art-card-actions .btn {
        width: 100%;
    }

    #art-stats {
        grid-template-columns: 1fr;
    }
}

/* ========================================================================
   UNIVERSAL ACTIVE TAB STYLES (P1.5)
   ======================================================================== */

/* Улучшенные стили для активных табов во всех дашбордах */
.view-tab.active,
.view-switcher-btn.active,
.tab.active,
.central-view-tab.active,
.view-tabs .view-tab.active,
.list-view-tab.active {
    position: relative;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
    transform: translateY(-1px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Индикатор активного таба (нижняя линия) */
.view-tab.active::before,
.view-switcher-btn.active::before,
.tab.active::after,
.central-view-tab.active::before {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary, #3b82f6);
    transform: scaleX(1);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Для табов с вертикальной ориентацией */
.tab.active::after {
    bottom: auto;
    top: 0;
    left: -1px;
    right: auto;
    width: 2px;
    height: 100%;
}

/* Улучшенные hover эффекты для неактивных табов */
.view-tab:not(.active):hover,
.view-switcher-btn:not(.active):hover,
.tab:not(.active):hover,
.central-view-tab:not(.active):hover {
    transform: translateY(-1px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================================================
   PRINT
   ======================================================================== */

@media print {
    .app-header,
    .app-footer,
    .sidebar,
    .btn,
    .modal, .modal-overlay {
        display: none !important;
    }
}
/* TEP Wizard Styles */
.tep-wizard {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tep-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 8px 8px 0 0;
    overflow: hidden;
}

.tep-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.3s ease;
    position: relative;
}

.tep-tab:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.tep-tab.active {
    color: var(--primary);
    background: var(--bg-elevated);
    border-bottom-color: var(--primary);
}

.tep-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.tep-tab-content {
    display: none;
    padding: 1.5rem 0;
    animation: tepFadeIn 0.3s ease-out;
}

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

.tep-tab-content h4 {
    margin: 0 0 1.5rem 0;
    color: var(--text-primary);
    font-size: 1.125rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}

.tep-modal .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.tep-modal .form-group label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.tep-modal .form-input {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-strong, var(--border));
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.tep-modal .form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.tep-modal .form-input::placeholder {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.tep-modal .form-group small {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: -0.25rem;
}

/* fadeIn keyframes moved to static/css/components/animations.css */

@keyframes tepFadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}
/* Стили для информации о генерации */
.generation-info {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-secondary, #f8f9fa);
    border-radius: 4px;
    border-left: 3px solid var(--primary, #3b82f6);
}

.generation-info ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

/* Стили для контейнера статистики мастер-плана */
.masterplan-stats-container {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-elevated);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.masterplan-stats-container h4 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.5rem;
}

.stats-section {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-light, #fafafa);
    border-radius: 4px;
}

.stats-section h5 {
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.stats-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
}

.stats-list li {
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-color, #e5e5e5);
}

.stats-list li:last-child {
    border-bottom: none;
}

/* Анимация для кнопки генерации */
#btn-generate-masterplan {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

#btn-generate-masterplan:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

#btn-generate-masterplan:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* === НОВЫЙ БЛОК: Стили для карты и мудборда v2 === */

/* Улучшенный маркер для арт-объектов */
.art-marker {
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    border: 2px solid white;
}
.art-marker svg {
    transform: rotate(45deg);
    width: 20px;
    height: 20px;
    color: var(--text-inverse);
}

/* Стандартный маркер для других объектов */
.default-marker {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 2px solid white;
    box-sizing: border-box; /* ✅ ИСПРАВЛЕНО: учитываем border */
    overflow: hidden; /* ✅ ДОБАВЛЕНО: обрезаем содержимое */
    flex-shrink: 0; /* ✅ ДОБАВЛЕНО: маркер не сжимается */
    text-align: center; /* ✅ ДОБАВЛЕНО: центрирование текста */
    line-height: 1; /* ✅ ДОБАВЛЕНО: выравнивание по вертикали */
}

/* Подсветка карточки при переходе с карты */
.art-card.highlight {
    transition: all 0.5s ease-in-out;
    box-shadow: 0 0 0 3px var(--primary), 0 8px 25px rgba(0,0,0,0.4);
    transform: scale(1.02);
}

/* ========================================================================
   TEXT OVERFLOW & BUTTON UTILITIES (shared across all dashboards)
   ======================================================================== */

/* Clamp text to N lines (use with --line-clamp: N) */
.text-clamp {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--line-clamp, 2);
    overflow: hidden;
    word-break: break-word;
}

/* Single-line truncation */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Safe word-wrapping for long content */
.text-wrap-break {
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Map / chart error fallback */
.map-error,
.chart-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 120px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius, 8px);
    font-size: 0.875rem;
    padding: 1rem;
    text-align: center;
}

/* Empty state hint (reusable) */
.empty-state-hint {
    padding: 1rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius, 8px);
    text-align: center;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Filter / tag pill (reusable) */
.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.8125rem;
    max-width: 100%;
}

.filter-pill-label {
    color: var(--text-muted);
    white-space: nowrap;
}

.filter-pill-value {
    color: var(--text-primary);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-pill-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.filter-pill-remove:hover {
    background: var(--danger);
    color: var(--text-inverse);
}

/* Clue basket (analyst) */
.clue-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    margin-bottom: 6px;
}

.clue-text {
    flex: 1;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--text-primary);
    overflow-wrap: break-word;
    word-break: break-word;
}

.clue-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.clue-remove:hover {
    background: var(--danger);
    color: var(--text-inverse);
}

/* Grant card (producer/patron JS-rendered) */
.grant-card {
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-elevated);
    margin-bottom: 12px;
}

/* Scenario save controls (visionary JS-rendered) */
.scenario-save-controls {
    margin: 10px 0 15px 0;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 4px;
    border-left: 3px solid var(--primary);
    color: var(--text-primary);
}