/* --- DeepDive Analytics: Main Styles --- */
/* Consta Design System - https://consta.design */

/* Подключение шрифтов Inter и IBM Plex Mono (локально) */
@import url('../assets/fonts/fonts.css');

/* ===== CSS Variables (Consta Defaults) ===== */
/* Переопределяются темой из css/themes/consta-*.css */
:root {
    /* Типографика - Consta использует Inter */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    --font-mono: 'IBM Plex Mono', 'JetBrains Mono', 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', 'Source Code Pro', monospace;
    
    /* Размеры текста - Consta scale (Compact) */
    --font-size-2xs: 8px;
    --font-size-xs: 10px;
    --font-size-sm: 11px;
    --font-size-base: 11px;
    --font-size-md: 12px;
    --font-size-lg: 14px;
    --font-size-xl: 16px;
    --font-size-2xl: 20px;
    --font-size-3xl: 24px;
    --font-size-4xl: 32px;
    --font-size-5xl: 48px;
    --font-size-6xl: 64px;
    
    /* Межстрочный интервал */
    --line-height-2xs: 1.1em;
    --line-height-xs: 1.2em;
    --line-height-sm: 1.4em;
    --line-height-md: 1.5em;
    --line-height-lg: 1.6em;
    
    /* Начертания */
    --font-weight-thin: 100;
    --font-weight-extralight: 200;
    --font-weight-light: 300;
    --font-weight-regular: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;
    --font-weight-extrabold: 800;
    --font-weight-black: 900;
    
    /* Отступы - Consta spacing */
    --space-3xs: 2px;
    --space-2xs: 4px;
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 16px;
    --space-lg: 20px;
    --space-xl: 24px;
    --space-2xl: 32px;
    --space-3xl: 40px;
    --space-4xl: 48px;
    --space-5xl: 72px;
    --space-6xl: 96px;
    
    /* Размеры элементов */
    --radius-xs: 2px;
    --radius-s: 4px;
    --radius-m: 8px;
    --radius-l: 6px;
    --border-radius: var(--radius-s);
    --border-radius-sm: var(--radius-xs);
    --border-radius-lg: var(--radius-m);
    --border-radius-module: var(--radius-l);
    --header-height: 32px;
    --row-height: 20px;
    --input-height: 28px;
    
    /* Переходы */
    --transition: 0.2s ease;
    --transition-speed: 0.2s;
    --transition-fast: 0.15s ease;
    --transition-slow: 0.3s ease;
    
    /* ===== Consta-compatible Aliases ===== */
    /* Typography */
    --font-primary: var(--font-family);
    --size-text-2xs: var(--font-size-2xs);
    --size-text-xs: var(--font-size-xs);
    --size-text-s: var(--font-size-sm);
    --size-text-m: var(--font-size-base);
    --size-text-md: var(--font-size-md);
    --size-text-l: var(--font-size-lg);
    --size-text-xl: var(--font-size-xl);
    --size-text-3xl: var(--font-size-3xl);
    
    /* Spacing */
    --space-s: var(--space-sm);
    --space-m: var(--space-md);
    --space-l: var(--space-lg);
    
    /* Shadows */
    --shadow-group: var(--shadow-sm);
    --shadow-layer: var(--shadow-md);
    --shadow-modal: var(--shadow-lg);
    
    /* Colors — Consta token names mapped to project proxy variables */
    --color-bg-default: var(--primary-bg);
    --color-bg-secondary: var(--surface-secondary);
    --color-bg-border: var(--border-light);
    --color-bg-ghost: var(--surface-hover);
    --color-bg-tone: var(--modal-overlay-bg);
    --color-bg-success: var(--success-bg);
    --color-bg-warning: var(--warning-bg);
    --color-bg-alert: var(--error-bg);
    --color-bg-normal: var(--info-bg);
    --color-bg-caution: var(--caution-bg);
    --color-bg-critical: var(--critical-bg);
    
    --color-typo-primary: var(--text-primary);
    --color-typo-secondary: var(--text-secondary);
    --color-typo-ghost: var(--text-tertiary);
    --color-typo-brand: var(--text-brand);
    --color-typo-link: var(--text-link);
    --color-typo-link-hover: var(--text-link-hover);
    --color-typo-success: var(--success-color);
    --color-typo-warning: var(--warning-color);
    --color-typo-alert: var(--error-color);
    --color-typo-normal: var(--info-color);
    --color-typo-caution: var(--caution-color);
    --color-typo-critical: var(--critical-color);
    --color-typo-system: var(--system-color);
    
    --color-control-bg-primary: var(--accent-color);
    --color-control-bg-primary-hover: var(--accent-hover);
    --color-control-typo-primary: #fff;
    --color-control-bg-default: var(--surface-bg);
    --color-control-bg-border-default: var(--border-color);
    --color-control-bg-border-default-hover: var(--border-color-hover);
    --color-control-bg-border-focus: var(--border-focus);
    --color-control-bg-focus: var(--accent-bg);
    --color-control-bg-active: var(--active-bg);
    --color-control-bg-ghost: var(--surface-hover);
    --color-control-bg-ghost-hover: var(--surface-hover);
    --color-control-typo-ghost: var(--text-tertiary);
    
    --color-scroll-bg: var(--scroll-bg);
    --color-scroll-thumb: var(--scroll-thumb);
    --color-scroll-thumb-hover: var(--scroll-thumb-hover);
}

/* ===== Base Styles ===== */
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-family);
    background-color: var(--primary-bg);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    line-height: var(--line-height-text-m, 1.4em);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
}

/* ===== App Loader ===== */
.app-loader {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm, 12px);
    z-index: 5000;
    background-color: var(--color-bg-default);
    color: var(--color-typo-secondary);
    font-size: var(--font-size-xs, 10px);
    line-height: var(--line-height-xs, 1.2em);
    transition: opacity 0.26s ease, visibility 0.26s ease;
}

.app-loader--hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.app-loader__spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--color-control-bg-border-default);
    border-top-color: var(--color-control-bg-primary);
    border-radius: 50%;
    animation: app-loader-spin 0.8s linear infinite;
}

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

/* ===== Layout ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 240px 3px 1fr 3px 260px;
    grid-template-rows: 1fr;
    gap: var(--space-3xs, 2px);
    padding: 0 var(--space-2xs, 4px) var(--space-2xs, 4px);
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    flex: 1;
    min-height: 0;
    flex-shrink: 1;
}

/* Compaction Controller: data-compaction attribute on .main-content */
.main-content[data-compaction="compact"] .module-header h3 {
    font-size: 9px;
}
.main-content[data-compaction="short"] .module-header h3 {
    font-size: 9px;
}
.main-content[data-compaction="compact"] .module {
    padding: var(--space-3xs, 2px) var(--space-2xs, 4px);
}
.main-content[data-compaction="short"] .module {
    padding: var(--space-3xs, 2px);
}

/* App Header */
.app-header {
    min-height: var(--header-height, 40px);
    background-color: var(--surface-bg);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    row-gap: var(--space-3xs, 2px);
    padding: var(--space-3xs, 2px) var(--space-2xs, 4px);
    box-sizing: border-box;
    box-shadow: var(--shadow-sm);
    z-index: 100;
    width: 100%;
    flex-shrink: 0;
}

.app-header-title {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-brand);
    justify-self: start;
    min-width: 0;
    flex: 0 0 auto;
    white-space: nowrap;
}

.app-header-home {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.app-header-home:hover {
    opacity: 0.8;
}

.app-logo-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-brand);
}

.app-logo-icon svg {
    width: 100%;
    height: 100%;
}

/* Header Project Description */
.app-header-divider {
    color: var(--text-tertiary);
    font-weight: var(--font-weight-regular, 400);
    opacity: 0.6;
    margin: 0 var(--space-3xs);
}

.app-header-project {
    color: var(--text-secondary);
    font-size: var(--font-size-sm, 11px);
    font-weight: var(--font-weight-semibold, 600);
    text-transform: uppercase;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.app-header-data-date {
    color: var(--text-secondary);
    font-size: var(--font-size-sm, 11px);
    font-weight: var(--font-weight-semibold, 600);
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    line-height: 1;
}

.app-header-data-date-divider {
    color: var(--text-secondary);
    font-weight: var(--font-weight-semibold, 600);
    opacity: 1;
}

.app-header-data-date:empty + .app-header-data-date-divider,
.app-header-data-date-divider:has(+ .app-header-data-date:empty) {
    display: none;
}

.app-header-version {
    color: var(--text-tertiary);
    font-size: var(--font-size-2xs, 10px);
    font-weight: var(--font-weight-regular, 400);
    padding: 2px 6px;
    border-radius: var(--radius-sm, 2px);
    background-color: var(--bg-ghost);
    line-height: 1;
    user-select: none;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.app-header-version:hover {
    background-color: var(--surface-hover);
    color: var(--text-secondary);
}

/* Header Filter Bar */
.header-filter-bar {
    display: flex;
    align-items: center;
    justify-self: center;
    min-width: 0;
    flex: 1 1 auto;
    justify-content: center;
    margin: 0 var(--space-xs, 8px);
    overflow: hidden;
}

/* Header Actions Container */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0;
    justify-self: end;
    min-width: 0;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    margin-left: auto;
}

/* Header Menu (Dropdown) */
.header-menu-container {
    position: relative;
    display: flex;
    align-items: center;
}

.header-menu-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-2xs) var(--space-xs);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2xs);
    transition: all var(--transition);
}

.header-menu-btn:hover {
    background: var(--surface-hover);
    color: var(--accent-color);
}

.header-menu-btn.active {
    background: var(--surface-hover);
    color: var(--accent-color);
}

.header-menu-btn-label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-black, 900);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}

.header-menu-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-menu-icon svg {
    width: 18px;
    height: 18px;
    stroke-width: 3;
}

.header-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 220px;
    padding: var(--space-2xs);
    background: var(--primary-bg);
    border: 1px solid var(--panel-border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    flex-direction: column;
    gap: 0;
}

.header-menu.open {
    display: flex;
}

.header-menu-divider {
    height: 1px;
    margin: var(--space-2xs) var(--space-xs);
    background: var(--panel-border-color);
}

.header-menu-item-label {
    font-size: var(--font-size-xs);
    line-height: 1.4;
    white-space: nowrap;
    color: var(--text-primary);
}

/* Пункты меню: иконка + название во всю ширину */
.header-menu button {
    width: 100%;
    justify-content: flex-start;
    gap: var(--space-xs);
    padding: 6px var(--space-xs);
    border-radius: var(--radius-xs);
    text-align: left;
}

/* Header Theme Button */
.header-theme-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.header-theme-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* Theme Icon Animation (Consta-style) */
/* Переменные анимации */
:root {
    --animate-icon-transition: 260ms;
    --animate-icon-easing: cubic-bezier(0.7, 0, 0.5, 1);
}

.theme-icon-wrapper {
    position: relative;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-icon-wrapper .theme-icon-svg {
    position: absolute;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 
        transform var(--animate-icon-transition) var(--animate-icon-easing),
        opacity var(--animate-icon-transition) var(--animate-icon-easing);
}

.theme-icon-wrapper .theme-icon-svg svg {
    width: 100%;
    height: 100%;
}

/* Состояния иконок */
.theme-icon-sun {
    opacity: 0;
    transform: scale(0.1);
}

.theme-icon-moon {
    opacity: 1;
    transform: scale(1);
}

/* Класс visible - иконка показывается (scale 1, opacity 1) */
.theme-icon-sun.visible,
.theme-icon-moon.visible {
    opacity: 1;
    transform: scale(1);
}

/* Класс hidden - иконка скрыта (scale 0.1, opacity 0) */
.theme-icon-sun.hidden,
.theme-icon-moon.hidden {
    opacity: 0;
    transform: scale(0.1);
}

/* Header Zen Button */
.header-zen-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.header-zen-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.header-zen-btn.active {
    color: var(--accent-color);
}

.header-zen-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-zen-icon svg {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
}

/* Header Settings Button */
.header-settings-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.header-settings-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.header-settings-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.header-settings-icon svg {
    width: 100%;
    height: 100%;
}

/* Анимация вращения при клике */
.header-settings-btn.spinning .header-settings-icon {
    animation: settings-spin 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Header Report Button */
.header-report-btn,
.header-compare-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.header-report-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.header-report-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-report-icon svg {
    width: 100%;
    height: 100%;
}

/* Header Load Button */
.header-load-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.header-load-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.header-load-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-load-icon svg {
    width: 18px;
    height: 18px;
}

/* Header Material Delivery Import Button */
.header-material-delivery-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.header-material-delivery-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.header-material-delivery-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-material-delivery-icon svg {
    width: 18px;
    height: 18px;
}

/* Header Open File Button */
.header-open-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.header-open-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.header-open-btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.header-open-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-open-icon svg {
    width: 18px;
    height: 18px;
}

/* Header Export Database Button */
.header-export-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.header-export-btn:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.header-export-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-export-icon svg {
    width: 18px;
    height: 18px;
}

@keyframes settings-spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(180deg);
    }
}

/* ===== Resizers ===== */
.resizer-y {
    cursor: col-resize;
    background-color: transparent;
    z-index: 10;
    position: relative;
    transition: all var(--transition);
}

.resizer-y::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    background-color: var(--accent-color);
    opacity: 0;
    transform: translateX(-50%);
    transition: opacity var(--transition);
}

.resizer-y:hover::after, .resizer-y:active::after {
    opacity: 1;
}

.resizer-x {
    cursor: row-resize;
    height: 4px;
    background-color: transparent;
    z-index: 10;
    position: relative;
    transition: all var(--transition);
}

.resizer-x::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    background-color: var(--accent-color);
    opacity: 0;
    transform: translateY(-50%);
    transition: opacity var(--transition);
}

.resizer-x:hover::after, .resizer-x:active::after {
    opacity: 1;
}

/* ===== Sidebars ===== */
.sidebar {
    background-color: var(--surface-bg);
    border: 1px solid var(--panel-border-color);
    border-radius: var(--border-radius-module);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.sidebar-header {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: var(--space-2xs) var(--space-xs);
    border-bottom: 1px solid var(--border-light);
    cursor: move;
    min-height: 20px;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 10px;
    font-weight: var(--font-weight-semibold, 600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.sidebar-content {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: var(--space-2xs);
    gap: var(--space-xs);
    flex: 1;
}

/* ===== Modules ===== */
.module-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
    overflow-y: auto;
    box-sizing: border-box;
    height: 100%;
    border-radius: var(--border-radius-module);
}

.module {
    background-color: var(--surface-bg);
    border-radius: var(--border-radius-module);
    padding: var(--space-2xs) var(--space-xs);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    position: relative;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: 100%;
    min-height: min-content;
    overflow: hidden;
    transition: box-shadow var(--transition), border-color var(--transition);
}

/* Only the header is a drag handle; the rest of the module keeps the default cursor. */
.module[draggable="true"]:not(.docked-out) {
    cursor: default;
}

.module:hover {
    box-shadow: var(--shadow-md);
}

.module.dragging {
    opacity: 0.5;
    border: 1px dashed var(--accent-color);
}

/* Collapsed State */
.module.collapsed {
    min-height: auto !important;
    height: auto !important;
    flex: 0 0 auto !important;
    overflow: hidden;
}

.module.collapsed > *:not(.module-header) {
    display: none !important;
}

.module.collapsed .module-header {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* ===== Module Header ===== */
.module-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2xs);
    padding-bottom: 2px;
    border-bottom: 1px solid var(--border-light);
    cursor: move;
    min-height: 20px;
}

.module-header h3 {
    margin: 0;
    font-size: 10px;
    font-weight: var(--font-weight-semibold, 600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    line-height: 1.2;
    display: flex;
    align-items: center;
}

/* Draggable icon in module header */
.draggable-icon {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.draggable-icon svg {
    width: 100%;
    height: 100%;
}

.module-actions {
    display: flex;
    gap: 1px;
    opacity: 0;
    transition: opacity var(--transition);
    margin-left: auto;
    flex-shrink: 0;
}

.module-header:hover .module-actions {
    opacity: 1;
}

/* ===== Main Content ===== */
.main-content {
    background-color: var(--primary-bg);
    min-width: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
    border: 1px solid var(--panel-border-color);
    border-radius: var(--border-radius-module);
    padding: var(--space-2xs);
    height: 100%;
}

#data-module {
    min-height: 0;
    overflow: hidden;
    box-shadow: none;
    cursor: default;
    display: flex;
    flex-direction: column;
}

#data-module::part(container) {
    height: 100%;
}

/* ===== Buttons ===== */
button {
    font-family: var(--font-family);
    font-weight: var(--font-weight-medium, 500);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    padding: var(--space-2xs) var(--space-sm);
    font-size: var(--font-size-xs);
    line-height: var(--line-height-text-s, 1.4em);
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2xs);
    height: 24px;
}

button.primary {
    background: var(--accent-color);
    color: white;
}

button.primary:hover {
    background: var(--accent-hover);
}

button.secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

button.secondary:hover {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.icon-button {
    background: transparent;
    color: var(--text-tertiary);
    padding: var(--space-2xs);
    border-radius: 50%;
    min-width: auto;
    min-height: auto;
    height: 20px;
    width: 20px;
}

.icon-button:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.icon-button svg,
.icon-button .icon {
    width: 16px;
    height: 16px;
    display: block;
    min-width: 16px;
    min-height: 16px;
}

/* Module actions icons */
.module-actions .icon-button svg {
    width: 16px;
    height: 16px;
}

/* ===== Collapse/Expand Arrow Animation ===== */
.collapse-btn .arrow-icon {
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.collapse-btn .arrow-icon.collapsed {
    transform: rotate(-90deg);
}

.module.collapsed .collapse-btn .arrow-icon,
[data-collapsed="true"] .collapse-btn .arrow-icon {
    transform: rotate(-90deg);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: var(--space-xs);
}

.form-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    margin-bottom: var(--space-2xs);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium, 500);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: var(--line-height-text-xs, 1.2em);
}

input[type="text"],
select {
    width: 100%;
    padding: var(--space-2xs) var(--space-xs);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-sizing: border-box;
    background: var(--surface-bg);
    font-family: inherit;
    font-size: var(--font-size-xs);
    line-height: var(--line-height-text-m, 1.5em);
    height: var(--input-height);
    color: var(--text-primary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--accent-bg);
}

input[type="text"]::placeholder {
    color: var(--text-tertiary);
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: var(--space-3xs);
    margin-bottom: var(--space-2xs);
    border-bottom: 1px solid var(--border-color);
    padding: 0 var(--space-2xs);
    background: var(--surface-bg);
}

.tabs button {
    background: none;
    border-radius: 0;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    padding: var(--space-2xs) var(--space-xs);
    font-size: 10px;
    font-weight: var(--font-weight-medium, 500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    height: 24px;
}

.tabs button.active {
    color: var(--accent-color);
    border-bottom-color: var(--accent-color);
    font-weight: var(--font-weight-semibold, 600);
}

.tabs button:hover:not(.active) {
    color: var(--text-primary);
}

/* ===== Data Table ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-xs);
    line-height: 1.3;
}

.data-table th,
.data-table td {
    padding: var(--space-2xs) var(--space-xs);
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table th {
    background: var(--primary-bg);
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: var(--font-weight-semibold, 600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky;
    top: 0;
    z-index: 5;
    height: 20px;
}

.data-table td {
    height: 20px;
    color: var(--text-primary);
    line-height: 1.2;
}

/* Zebra striping */
.data-table tbody tr:nth-child(even) {
    background: var(--surface-hover);
}

.data-table tbody tr:hover {
    background: var(--accent-bg);
}

/* ===== Status Badges ===== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3xs);
    padding: 1px var(--space-2xs);
    border-radius: var(--space-2xs);
    font-size: 10px;
    font-weight: var(--font-weight-medium, 500);
    line-height: 1.2;
    white-space: nowrap;
}

.status-badge::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
}

.status-badge.in-progress {
    background: var(--success-bg);
    color: var(--success-color);
}

.status-badge.in-progress::before {
    background: var(--success-color);
}

.status-badge.completed {
    background: var(--info-bg);
    color: var(--info-color);
}

.status-badge.completed::before {
    background: var(--info-color);
}

.status-badge.pending {
    background: var(--warning-bg);
    color: var(--warning-color);
}

.status-badge.pending::before {
    background: var(--warning-color);
}

.status-badge.overdue {
    background: var(--error-bg);
    color: var(--error-color);
}

.status-badge.overdue::before {
    background: var(--error-color);
}

/* ===== KPI Cards ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: var(--space-2xs);
}

.kpi-card {
    padding: var(--space-2xs) var(--space-xs);
    border-radius: var(--border-radius-sm);
    border-left: 2px solid var(--border-color);
    background: var(--primary-bg);
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.kpi-card.success { border-left-color: var(--success-color); background: var(--success-bg); }
.kpi-card.warning { border-left-color: var(--warning-color); background: var(--warning-bg); }
.kpi-card.error { border-left-color: var(--error-color); background: var(--error-bg); }
.kpi-card.info { border-left-color: var(--accent-color); background: var(--accent-bg); }

.kpi-value {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-bold, 700);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: var(--line-height-text-2xs, 1.1em);
}

.kpi-label {
    font-size: 9px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.kpi-delta {
    font-size: 9px;
    font-weight: var(--font-weight-medium, 500);
    line-height: 1.2;
}

.kpi-delta.positive { color: var(--success-color); }
.kpi-delta.negative { color: var(--error-color); }

/* ===== Layouts List ===== */
#layouts-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#layouts-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2xs) var(--space-xs);
    margin: 0 calc(-1 * var(--space-xs));
    border-radius: var(--border-radius-sm);
    transition: background-color var(--transition);
    font-size: var(--font-size-xs);
    height: 20px;
}

#layouts-list li:hover {
    background-color: var(--surface-hover);
}

.delete-layout {
    opacity: 0;
    color: var(--error-color);
}

#layouts-list li:hover .delete-layout {
    opacity: 1;
}

.danger { color: var(--error-color); }

/* ===== Filter Panel ===== */
#right-sidebar .sidebar-content,
#right-sidebar .module-container {
    overflow: hidden;
}

#left-sidebar .sidebar-content,
#left-sidebar .module-container {
    overflow: hidden;
}

wbs-filter.module {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

resource-filter.module {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

schedule-deviation-analyzer.module {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

#left-sidebar #layouts-module.module {
    min-height: 0;
}

/* Prevent grid items from expanding the row beyond 1fr */
.dashboard-grid > #right-sidebar,
.dashboard-grid > #left-sidebar,
.dashboard-grid > #main-content {
    min-height: 0;
}

filter-panel.module,
filter-resource-tabs.module {
    min-height: 0;
    overflow: hidden;
}

timeline-panel.module {
    min-height: 0;
    overflow: hidden;
}

grouping-panel.module {
    min-height: 0;
}

.filter-panel-body,
.grouping-panel-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.available-settings-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

code-picker {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.code-picker-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.filter-section-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: var(--space-2xs) 0;
}

.filter-active-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2xs);
    min-height: 24px;
    padding: var(--space-2xs);
    border-radius: var(--radius-l);
    background: transparent;
}

.filter-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.filter-chip {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
    padding: 1px var(--space-xs);
    padding-right: 48px;
    background: transparent;
    border: none;
    border-radius: 0;
    position: relative;
}

.filter-chip.filter-chip--disabled {
    opacity: 0.6;
    background: transparent;
}

.filter-chip-toggle input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--accent-color);
    cursor: pointer;
}

.filter-chip-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    gap: 2px;
}

.filter-chip-label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: var(--font-weight-medium, 500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-chip-value {
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.available-settings {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.available-types-view,
.code-values-view {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    overflow: hidden;
}

.code-values-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px var(--space-2xs);
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--color-typo-primary);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border-light);
    border-radius: 0;
    cursor: pointer;
    text-align: left;
    margin-bottom: 2px;
    flex-shrink: 0;
    align-self: flex-start;
    max-width: 100%;
    overflow: hidden;
}

.code-values-back:hover {
    color: var(--color-typo-primary);
}

.code-values-back .chevron-left {
    color: var(--color-typo-primary);
    width: 12px;
    height: 12px;
}

.chevron-left,
.chevron-right {
    font-size: 10px;
    color: var(--text-secondary);
    flex-shrink: 0;
    display: inline-flex;
    width: 12px;
    height: 12px;
    align-items: center;
    justify-content: center;
}

.folder-icon {
    font-size: 10px;
    color: var(--text-secondary);
    flex-shrink: 0;
    display: inline-flex;
    width: 12px;
    height: 12px;
    align-items: center;
    justify-content: center;
}

.available-type-item.has-active-filter .folder-icon {
    color: var(--accent-color);
}

.available-type-item.has-active-filter .folder-icon svg {
    fill: var(--accent-color);
    stroke-width: 1.5px;
}

.code-values-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    max-width: 100%;
}

.available-types-list,
.code-values-list,
.code-picker-types-list,
.code-picker-values-list {
    min-height: 0;
    flex: 1;
    overflow-y: auto;
}

.available-type-item {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
    padding: 2px var(--space-2xs);
    font-size: var(--font-size-xs);
    color: var(--color-typo-primary);
    background: transparent;
    border-radius: 2px;
    cursor: pointer;
    overflow: hidden;
}

.available-type-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1;
}

.available-type-item:focus-visible,
.code-value-option:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: -2px;
}

.available-type-item:hover {
    background: var(--hover-bg, rgba(0,0,0,0.04));
}

.code-value-option {
    display: flex;
    align-items: center;
    /* gap: 2px; */
    padding: 2px var(--space-2xs);
    font-size: var(--font-size-xs);
    color: var(--color-typo-primary);
    cursor: pointer;
    border-radius: 2px;
    overflow: hidden;
}

.code-value-option.selected {
    background: var(--hover-bg, rgba(0,0,0,0.04));
    color: var(--text-primary);
}

.code-value-option:hover {
    background: var(--hover-bg, rgba(0,0,0,0.04));
}

.code-value-radio {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1.5px solid var(--border-color);
    background: transparent;
    flex-shrink: 0;
    transition: all 0.15s ease;
}

.code-value-option.selected .code-value-radio {
    background: var(--accent-color);
    border-color: var(--accent-color);
    box-shadow: 0 0 2px 0.5px var(--accent-color);
}

.filter-chip .code-value-name {
    margin-right: 0;
}

.filter-chip .code-value-radio {
    cursor: pointer;
}

.filter-chip.filter-chip--system {
    opacity: 0.85;
    background: var(--color-bg-secondary, rgba(0, 0, 0, 0.04));
    border-radius: var(--radius-s, 2px);
}

.filter-chip.filter-chip--system .code-value-name,
.filter-chip.filter-chip--system .code-value-desc {
    color: var(--text-secondary);
}

.filter-chip-badge {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 9px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.available-types-search,
.code-values-search {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
    padding: 4px var(--space-2xs);
    background: var(--surface-bg, var(--primary-bg));
    flex-shrink: 0;
}

.available-types-search {
    margin-bottom: 2px;
}

.code-values-search {
    padding-left: 0;
    margin-bottom: 2px;
}

.compact-input {
    flex: 1;
    height: 24px;
    padding: 0 6px;
    font-size: var(--font-size-xs);
    color: var(--text-primary);
    background: var(--input-bg, var(--surface-bg, var(--primary-bg)));
    border: 1px solid var(--border-color);
    border-radius: 2px;
    outline: none;
}

.compact-input:focus {
    border-color: var(--accent-color);
}

.compact-input::placeholder {
    color: var(--text-tertiary);
}

.clear-search {
    width: 18px;
    height: 18px;
    padding: 0;
    font-size: 12px;
    line-height: 1;
    color: var(--text-tertiary);
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-search:hover {
    color: var(--text-primary);
    background: var(--hover-bg, rgba(0,0,0,0.04));
}



.code-value-name {
    font-weight: 500;
    color: var(--accent-color);
    flex-shrink: 0;
    margin-right: 4px;
    font-size: var(--font-size-xs);
}

.code-value-desc {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    color: var(--color-typo-primary);
    font-size: var(--font-size-xs);
}

/* ===== Placeholders ===== */
.compact-placeholder,
.aggregation-placeholder,
.grouping-placeholder {
    min-height: 40px;
    background: var(--primary-bg);
    border: 1px dashed var(--border-color);
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    font-size: var(--font-size-xs);
    font-style: italic;
}

.aggregation-placeholder::after,
.grouping-placeholder::after {
    content: 'Нет данных для отображения';
}

/* ===== Layout Changing (Drag/Resize) ===== */
body.layout-changing .module,
body.layout-changing .module-header,
body.layout-changing .module-actions,
body.layout-changing .icon-button,
body.layout-changing .year-token,
body.layout-changing .timeline-slider::-webkit-slider-thumb,
body.layout-changing .timeline-slider::-moz-range-thumb,
body.layout-changing .timeline-tooltip {
    transition: none !important;
}
body.layout-changing .module:hover {
    box-shadow: var(--shadow-sm) !important;
}
body.layout-changing .module-actions {
    opacity: 1 !important;
}

/* ===== Floating State ===== */
.module.docked-out {
    position: fixed;
    z-index: 2000;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    max-height: calc(100vh - var(--header-height, 32px));
    min-height: auto;
}

.module.overlap-warning::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        rgba(211, 47, 47, 0.05),
        rgba(211, 47, 47, 0.05) 10px,
        rgba(211, 47, 47, 0.1) 10px,
        rgba(211, 47, 47, 0.1) 20px
    );
    pointer-events: none;
    z-index: 3000;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay-bg, rgba(0, 32, 51, 0.6));
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.modal-content {
    background: var(--surface-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    min-width: 320px;
    max-width: 90vw;
    max-height: 90vh;
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
    margin: 0;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold, 600);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-md);
    overflow-y: auto;
}

.modal-footer {
    padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-xs);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ===== Resize Handle ===== */
.resize-handle {
    width: 16px;
    height: 16px;
    background-color: transparent;
    position: absolute;
    right: 0;
    bottom: 0;
    cursor: nwse-resize;
    z-index: 1002;
    display: none;
}

.resize-handle::after {
    content: '';
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 16px;
    height: 16px;
    background-color: var(--text-tertiary);
    -webkit-mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" stroke="black" stroke-width="2" stroke-linecap="round"><line x1="14" y1="5" x2="5" y2="14"/><line x1="14" y1="10" x2="10" y2="14"/></svg>');
    mask-image: url('data:image/svg+xml;utf8,<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" stroke="black" stroke-width="2" stroke-linecap="round"><line x1="14" y1="5" x2="5" y2="14"/><line x1="14" y1="10" x2="10" y2="14"/></svg>');
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    opacity: 0.6;
    transition: background-color var(--transition), opacity var(--transition);
}

.resize-handle:hover::after {
    opacity: 1;
    background-color: var(--accent-color);
}

.module.docked-out .resize-handle {
    display: block;
}

/* ===== Timeline ===== */
.timeline-container {
    min-height: 60px;
    padding: var(--space-xs);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

/* ===== Loading States ===== */
.waiting-database-state,
.loading-state,
.error-state,
.empty-state {
    padding: 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.waiting-database-state .state-icon,
.error-state .state-icon,
.empty-state .state-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 12px;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.waiting-database-state .state-icon svg,
.error-state .state-icon svg,
.empty-state .state-icon svg {
    width: 100%;
    height: 100%;
}

.error-state .state-icon {
    color: var(--error-color);
}

.waiting-database-state h3,
.error-state h3,
.empty-state h3 {
    margin: 0 0 4px 0;
    font-weight: 500;
    color: var(--text-primary);
    font-size: var(--font-size-md);
}

.waiting-database-state p,
.error-state p,
.empty-state p {
    margin: 0;
    max-width: 320px;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===== Summary Drill Navigator ===== */
.summary-drill-navigator {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    font-family: var(--font-family);
}

/* State messages */
.sdn-state-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    height: 100%;
    padding: var(--space-md);
    text-align: center;
    color: var(--text-secondary);
}

.sdn-state-message.empty {
    color: var(--text-tertiary);
}

.sdn-state-message.error {
    color: var(--error-color);
}

.sdn-state-icon {
    width: 32px;
    height: 32px;
    color: inherit;
    opacity: 0.7;
}

.sdn-state-text {
    font-size: var(--font-size-sm);
    max-width: 280px;
}

.sdn-state-action {
    margin-top: var(--space-xs);
}

/* ===== Utility Classes ===== */
.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }

.p-0 { padding: 0; }
.p-xs { padding: var(--space-xs); }
.p-sm { padding: var(--space-sm); }

.m-0 { margin: 0; }
.mb-xs { margin-bottom: var(--space-xs); }
.mb-sm { margin-bottom: var(--space-sm); }

/* ===== Responsive Adjustments ===== */
@media (max-width: 1400px) {
    .dashboard-grid {
        grid-template-columns: 200px 3px 1fr 3px 220px;
    }
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 180px 3px 1fr 3px 200px;
    }
    
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== Typography (Consta) ===== */
h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: var(--font-weight-semibold, 600);
    line-height: var(--line-height-text-xs, 1.2em);
    color: var(--text-primary);
}

h1 { font-size: var(--font-size-3xl, 32px); }
h2 { font-size: var(--font-size-2xl, 24px); }
h3 { font-size: var(--font-size-xl, 20px); }
h4 { font-size: var(--font-size-lg, 18px); }
h5 { font-size: var(--font-size-md, 16px); }
h6 { font-size: var(--font-size-sm, 14px); }

p {
    margin: 0 0 var(--space-sm) 0;
    line-height: var(--line-height-text-m, 1.5em);
}

/* Text utilities */
.text-2xs { font-size: var(--font-size-2xs); }
.text-xs { font-size: var(--font-size-xs); }
.text-sm { font-size: var(--font-size-sm); }
.text-base { font-size: var(--font-size-base); }
.text-md { font-size: var(--font-size-md); }
.text-lg { font-size: var(--font-size-lg); }
.text-xl { font-size: var(--font-size-xl); }
.text-2xl { font-size: var(--font-size-2xl); }
.text-3xl { font-size: var(--font-size-3xl); }

.text-regular { font-weight: var(--font-weight-regular, 400); }
.text-medium { font-weight: var(--font-weight-medium, 500); }
.text-semibold { font-weight: var(--font-weight-semibold, 600); }
.text-bold { font-weight: var(--font-weight-bold, 700); }

.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-brand { color: var(--text-brand); }
.text-link { color: var(--text-link); }

/* ===== Floating Deviation Window ===== */
.deviation-window {
    position: fixed;
    display: flex;
    flex-direction: column;
    background: var(--surface-bg);
    border: 1px solid var(--border-color-hover);
    border-radius: var(--radius-m, 8px);
    box-shadow: 0 8px 24px rgba(0, 32, 51, 0.08), 0 16px 48px rgba(0, 32, 51, 0.16);
    overflow: hidden;
    resize: both;
    min-width: 320px;
    min-height: 120px;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.deviation-window.active {
    box-shadow: 0 12px 32px rgba(0, 32, 51, 0.12), 0 24px 48px rgba(0, 32, 51, 0.2);
    border-color: var(--border-focus);
}

.deviation-window-header {
    display: flex;
    align-items: center;
    gap: var(--space-2xs, 4px);
    padding: var(--space-2xs, 4px) var(--space-xs, 8px);
    background: var(--surface-ghost);
    border-bottom: 1px solid var(--border-light);
    min-height: 28px;
    flex-shrink: 0;
    cursor: grab;
    user-select: none;
    touch-action: none;
    border-radius: var(--radius-m, 8px) var(--radius-m, 8px) 0 0;
}

.deviation-window-header h3 {
    font-size: var(--font-size-xs, 10px);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.deviation-window-drag-handle {
    display: inline-flex;
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    cursor: grab;
}

.deviation-window-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3xs, 2px);
    flex-shrink: 0;
}

.deviation-window-actions .icon-button {
    padding: 2px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius-s, 4px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.deviation-window-actions .icon-button:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.deviation-window-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.deviation-window.minimized .deviation-window-body {
    display: none !important;
}

.deviation-window.minimized {
    height: auto !important;
    min-height: 0 !important;
    resize: none !important;
}

/* Resize grip indicator */
.deviation-window::after {
    content: '';
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 10px;
    height: 10px;
    background:
        linear-gradient(135deg, transparent 40%, var(--text-tertiary) 40%, var(--text-tertiary) 45%, transparent 45%,
                         transparent 55%, var(--text-tertiary) 55%, var(--text-tertiary) 60%, transparent 60%);
    opacity: 0.35;
    pointer-events: none;
    border-radius: 0 0 var(--radius-m) 0;
    transition: opacity 0.2s ease;
}

.deviation-window:hover::after {
    opacity: 0.6;
}

.deviation-window-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    gap: var(--space-xs, 8px);
    color: var(--text-tertiary);
    font-size: var(--font-size-xs, 10px);
    text-align: center;
}

.deviation-window-loading svg {
    animation: deviation-spin 1s linear infinite;
    width: 20px;
    height: 20px;
}

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