/* Dashboard CSS — split from index.html (Session 27) */
/* ==================== 1. CSS VARIABLES (Palette C) ==================== */
        :root {
            --color-primary: #0F172A;
            --color-secondary: #1E293B;
            --color-accent: #334155;
            --color-success: #10B981;
            --color-danger: #EF4444;
            --color-warning: #F59E0B;
            --color-gold: #C8985E;
            --color-text: #F8FAFC;
            --color-text-muted: #94A3B8;
            --color-text-dim: #64748B;
            --color-surface: #1E293B;
            --color-surface-hover: #334155;
            --color-border: #334155;
            --color-available: #10B981;
            --color-available-bg: rgba(16, 185, 129, 0.15);
            --color-sold: #EF4444;
            --color-sold-bg: rgba(239, 68, 68, 0.15);
            --color-reserved: #F59E0B;
            --color-reserved-bg: rgba(245, 158, 11, 0.15);
            --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            --font-size-xs: 11px;
            --font-size-sm: 13px;
            --font-size-base: 15px;
            --font-size-lg: 17px;
            --font-size-xl: 20px;
            --font-size-2xl: 24px;
            --font-size-3xl: 30px;
            --spacing-xs: 4px;
            --spacing-sm: 8px;
            --spacing-md: 12px;
            --spacing-lg: 16px;
            --spacing-xl: 24px;
            --spacing-2xl: 32px;
            --container-padding: 16px;
            --border-radius-sm: 6px;
            --border-radius: 8px;
            --border-radius-lg: 12px;
            --border-radius-xl: 16px;
            --border-radius-full: 999px;
            --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
            --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
            --transition-fast: 150ms ease-in-out;
            --transition-base: 250ms ease-in-out;
        }

        /* ==================== 2. RESET / BASE ==================== */
        *, *::before, *::after { box-sizing: border-box; }
        html { font-size: var(--font-size-base); line-height: 1.5; -webkit-text-size-adjust: 100%; }
        body {
            margin: 0; padding: 0;
            font-family: var(--font-family);
            color: var(--color-text);
            background: var(--color-primary);
            -webkit-font-smoothing: antialiased;
            overscroll-behavior: contain;
        }

        /* ==================== 3. LAYOUT ==================== */
        .app { min-height: 100vh; display: flex; flex-direction: column; }

        .app__header {
            position: sticky; top: 0; z-index: 50;
            background: var(--color-primary);
            padding: var(--spacing-lg) var(--container-padding) var(--spacing-sm);
            border-bottom: 1px solid var(--color-border);
        }
        .app__header-row { display: flex; align-items: center; justify-content: space-between; }
        .app__header-title { font-size: var(--font-size-xl); font-weight: 700; margin: 0; }
        .app__header-status {
            display: flex; align-items: center; gap: 6px;
            font-size: var(--font-size-xs); color: var(--color-success);
        }
        .app__header-dot {
            width: 8px; height: 8px; border-radius: 50%;
            background: var(--color-success);
            animation: pulse 2s infinite;
        }
        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.4; }
        }

        /* ==================== 4. TABS (8 вкладок) ==================== */
        .dash-tabs {
            display: flex; gap: 2px;
            padding: var(--spacing-sm) var(--container-padding);
            background: var(--color-primary);
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: none;
            border-bottom: 1px solid var(--color-border);
        }
        .dash-tabs::-webkit-scrollbar { display: none; }

        .dash-tabs__item {
            flex-shrink: 0;
            padding: 8px 14px;
            border-radius: var(--border-radius-sm);
            font-size: var(--font-size-sm);
            font-weight: 500;
            color: var(--color-text-muted);
            background: transparent;
            border: none;
            cursor: pointer;
            transition: all var(--transition-fast);
            white-space: nowrap;
            -webkit-tap-highlight-color: transparent;
        }
        .dash-tabs__item.is-active {
            background: var(--color-success);
            color: white;
        }
        .dash-tabs__item:not(.is-active):active {
            background: var(--color-accent);
        }

        /* ==================== 5. CONTENT ==================== */
        .app__content {
            flex: 1;
            padding: var(--spacing-lg) var(--container-padding);
            padding-bottom: calc(var(--spacing-2xl) + env(safe-area-inset-bottom, 0px));
        }

        .tab-panel { display: none; }
        .tab-panel.is-active { display: block; }

        /* ==================== 6. METRIC CARDS ==================== */
        .dash__grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: var(--spacing-md);
            margin-bottom: var(--spacing-xl);
        }
        .dash__grid--3 { grid-template-columns: repeat(3, 1fr); }

        .dash__card {
            background: var(--color-surface);
            border-radius: var(--border-radius-lg);
            padding: var(--spacing-lg);
            border: 1px solid var(--color-border);
            transition: all var(--transition-fast);
        }
        .dash__card--full { grid-column: 1 / -1; }
        .dash__card--alert { border-color: var(--color-danger); }

        .dash__card-label {
            font-size: var(--font-size-xs);
            color: var(--color-text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: var(--spacing-xs);
        }
        .dash__card-value {
            font-size: var(--font-size-2xl);
            font-weight: 700;
            line-height: 1.2;
        }
        .dash__card-value--success { color: var(--color-success); }
        .dash__card-value--danger { color: var(--color-danger); }
        .dash__card-value--warning { color: var(--color-warning); }
        .dash__card-value--gold { color: var(--color-gold); }

        .dash__card-delta {
            font-size: var(--font-size-xs);
            margin-top: var(--spacing-xs);
        }
        .dash__card-delta--up { color: var(--color-success); }
        .dash__card-delta--down { color: var(--color-danger); }

        /* ==================== 7. CHART CONTAINERS ==================== */
        .dash__chart-wrap {
            background: var(--color-surface);
            border-radius: var(--border-radius-lg);
            padding: var(--spacing-lg);
            border: 1px solid var(--color-border);
            margin-bottom: var(--spacing-lg);
        }
        .dash__chart-title {
            font-size: var(--font-size-sm);
            font-weight: 600;
            margin-bottom: var(--spacing-md);
        }
        .dash__chart-canvas {
            width: 100% !important;
            max-height: 220px;
        }

        /* ==================== 8. LEADS TABLE ==================== */
        .dash__table {
            width: 100%;
            border-collapse: separate;
            border-spacing: 0;
        }
        .dash__table th {
            font-size: var(--font-size-xs);
            color: var(--color-text-dim);
            text-align: left;
            padding: var(--spacing-sm) var(--spacing-md);
            border-bottom: 1px solid var(--color-border);
            white-space: nowrap;
        }
        .dash__table td {
            font-size: var(--font-size-sm);
            padding: var(--spacing-md);
            border-bottom: 1px solid var(--color-border);
            vertical-align: middle;
        }
        .dash__table tr:active { background: var(--color-surface-hover); }

        /* ==================== 9. BADGES & PILLS ==================== */
        .badge {
            display: inline-flex; align-items: center; gap: 4px;
            padding: 2px 8px; border-radius: var(--border-radius-full);
            font-size: var(--font-size-xs); font-weight: 500;
        }
        .badge--hot { background: rgba(239,68,68,0.15); color: var(--color-danger); }
        .badge--warm { background: rgba(245,158,11,0.15); color: var(--color-warning); }
        .badge--cold { background: rgba(100,116,139,0.15); color: var(--color-text-dim); }
        .badge--success { background: var(--color-available-bg); color: var(--color-success); }

        .pills {
            display: flex; gap: var(--spacing-sm);
            overflow-x: auto; padding: var(--spacing-xs) 0;
            margin-bottom: var(--spacing-lg);
            -webkit-overflow-scrolling: touch;
        }
        .pills__item {
            flex-shrink: 0;
            padding: 6px 14px;
            border-radius: var(--border-radius-full);
            font-size: var(--font-size-sm);
            border: 1px solid var(--color-border);
            background: transparent;
            color: var(--color-text-muted);
            cursor: pointer;
            transition: all var(--transition-fast);
            -webkit-tap-highlight-color: transparent;
        }
        .pills__item.is-active {
            background: var(--color-success); color: white;
            border-color: var(--color-success);
        }

        /* ==================== 10. SECTION HEADERS ==================== */
        .dash__section-title {
            font-size: var(--font-size-lg);
            font-weight: 600;
            margin: var(--spacing-xl) 0 var(--spacing-md);
        }
        .dash__section-title:first-child { margin-top: 0; }

        /* ==================== 11. HEATMAP ==================== */
        .heatmap {
            display: grid;
            grid-template-columns: 40px repeat(24, 1fr);
            gap: 2px;
            overflow-x: auto;
        }
        .heatmap__label {
            font-size: 10px; color: var(--color-text-dim);
            display: flex; align-items: center; justify-content: center;
        }
        .heatmap__cell {
            aspect-ratio: 1;
            border-radius: 3px;
            min-width: 14px;
            transition: background var(--transition-fast);
        }

        /* ==================== 12. FUNNEL ==================== */
        .funnel__bar-wrap { margin-bottom: var(--spacing-md); }
        .funnel__bar-label {
            display: flex; justify-content: space-between;
            font-size: var(--font-size-sm); margin-bottom: var(--spacing-xs);
        }
        .funnel__bar-label span:last-child { color: var(--color-text-muted); }
        .funnel__bar {
            height: 28px;
            border-radius: var(--border-radius-sm);
            background: var(--color-accent);
            overflow: hidden;
        }
        .funnel__bar-fill {
            height: 100%;
            border-radius: var(--border-radius-sm);
            background: var(--color-success);
            transition: width 0.6s ease;
            min-width: 4px;
        }

        /* ==================== 13. MODAL ==================== */
        .modal-overlay {
            position: fixed; inset: 0;
            background: rgba(0,0,0,0.7);
            backdrop-filter: blur(4px);
            z-index: 100;
            display: flex; align-items: flex-end; justify-content: center;
            opacity: 0; pointer-events: none;
            transition: opacity var(--transition-base);
        }
        .modal-overlay.is-active { opacity: 1; pointer-events: auto; }
        .modal {
            background: var(--color-secondary);
            border-radius: var(--border-radius-xl) var(--border-radius-xl) 0 0;
            padding: var(--spacing-xl);
            width: 100%; max-height: 85vh; overflow-y: auto;
            transform: translateY(100%);
            transition: transform var(--transition-base);
        }
        .modal-overlay.is-active .modal { transform: translateY(0); }
        .modal__handle {
            width: 36px; height: 4px; border-radius: 2px;
            background: var(--color-accent);
            margin: 0 auto var(--spacing-lg);
        }

        /* ==================== 14. LOADING ==================== */
        .skeleton {
            background: linear-gradient(90deg, var(--color-accent) 25%, var(--color-surface-hover) 50%, var(--color-accent) 75%);
            background-size: 200% 100%;
            animation: shimmer 1.5s infinite;
            border-radius: var(--border-radius-sm);
        }
        @keyframes shimmer {
            0% { background-position: 200% 0; }
            100% { background-position: -200% 0; }
        }

        .dash__loading {
            display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--spacing-md);
        }
        .dash__loading .skeleton { height: 90px; border-radius: var(--border-radius-lg); }

        /* ==================== 15. STATES & UTILITIES ==================== */
        .is-hidden { display: none !important; }
        .is-active { }
        .text-center { text-align: center; }
        .text-muted { color: var(--color-text-muted); }
        .text-success { color: var(--color-success); }
        .text-danger { color: var(--color-danger); }
        .text-gold { color: var(--color-gold); }
        .mt-sm { margin-top: var(--spacing-sm); }
        .mt-md { margin-top: var(--spacing-md); }
        .mt-lg { margin-top: var(--spacing-lg); }

        /* ==================== 16. EMPTY STATE ==================== */
        .dash__empty {
            text-align: center; padding: var(--spacing-2xl);
            color: var(--color-text-dim);
        }
        .dash__empty-icon { font-size: 48px; margin-bottom: var(--spacing-lg); }
        .dash__empty-text { font-size: var(--font-size-sm); }

        .dash__score {
            display: inline-block;
            min-width: 32px;
            text-align: center;
            padding: 2px 8px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: 600;
            background: var(--color-accent);
            color: var(--color-text);
        }
        .btn--sm {
            padding: 6px 14px;
            font-size: 12px;
            border-radius: 8px;
            background: var(--color-accent);
            color: var(--color-text);
            border: 1px solid var(--color-border);
            cursor: pointer;
            transition: background 0.2s;
        }
        .btn--sm:hover { background: var(--color-surface-hover); }
        .btn--sm:disabled { opacity: 0.5; cursor: not-allowed; }
    
/* ========== LIGHT THEME AUTO-DETECT ========== */
:root.light-theme {
  --color-bg: #F8FAFC;
  --color-surface: #FFFFFF;
  --color-surface-alt: #F1F5F9;
  --color-text: #0F172A;
  --color-text-secondary: #64748B;
  --color-border: #E2E8F0;
  --color-accent: #10B981;
  --color-accent-hover: #059669;
  --color-danger: #EF4444;
  --color-warning: #F59E0B;
  --color-muted: #94A3B8;
}
.light-theme .dash__card,
.light-theme .dash__table th {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.light-theme .dash__tabs-item.is-active {
  background: var(--color-accent);
  color: #fff;
}
.light-theme .pills__item.is-active {
  background: var(--color-accent);
  color: #fff;
}
.light-theme .modal__content {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
/* ========== END LIGHT THEME ========== */


/* ========== ANIMATIONS ========== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes countUp {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes skeletonPulse {
  0%, 100% { opacity: 0.15; }
  50%      { opacity: 0.3; }
}
.dash__card {
  animation: fadeInUp 0.3s ease both;
}
.dash__card:nth-child(2) { animation-delay: 0.05s; }
.dash__card:nth-child(3) { animation-delay: 0.1s; }
.dash__card:nth-child(4) { animation-delay: 0.15s; }
.dash__card:nth-child(5) { animation-delay: 0.2s; }
.dash__card:nth-child(6) { animation-delay: 0.25s; }
.dash__card-value {
  animation: countUp 0.4s ease both;
  animation-delay: 0.15s;
}
.skeleton {
  animation: skeletonPulse 1.2s ease-in-out infinite !important;
  background: var(--color-surface-alt, #1E293B) !important;
  border-radius: 8px;
}
.tab-panel {
  animation: fadeInUp 0.25s ease both;
}
.dash__table tbody tr {
  animation: fadeInUp 0.2s ease both;
}
.dash__table tbody tr:nth-child(n) {
  animation-delay: calc(0.03s * var(--row-index, 0));
}
/* Smooth transitions */
.dash__tabs-item,
.pills__item,
.funnel__bar-fill {
  transition: all 0.2s ease;
}
.dash__card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dash__card:active {
  transform: scale(0.97);
}
/* ========== END ANIMATIONS ========== */


/* ========== RESPONSIVE TABLES ========== */
@media (max-width: 480px) {
  .dash__table { font-size: 12px; }
  .dash__table th,
  .dash__table td { padding: 6px 8px; }
  .dash__grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .dash__card { padding: 12px; }
  .dash__card-value { font-size: 20px; }
  .dash__card-label { font-size: 11px; }
  .dash__section-title { font-size: 14px; }
  .pills { gap: 4px; }
  .pills__item { padding: 4px 10px; font-size: 12px; }
  .dash__tabs { gap: 2px; padding: 0 8px; }
  .dash__tabs-item { padding: 6px 10px; font-size: 12px; }
  /* Horizontal scroll for wide tables */
  .dash__table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
  .dash__table { min-width: 500px; }
  /* Swipeable pills */
  .pills {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }
  .pills::-webkit-scrollbar { display: none; }
  .pills__item { flex-shrink: 0; }
}
@media (max-width: 360px) {
  .dash__grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .dash__card-value { font-size: 18px; }
  body { padding: 8px; }
}
/* ========== END RESPONSIVE ========== */

/* ==================== PROJECT SELECTOR ==================== */
.project-selector {
    padding: 8px 16px;
    background: var(--color-surface, #1E293B);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.project-selector__dropdown {
    width: 100%;
    padding: 10px 14px;
    background: var(--color-primary, #0F172A);
    color: var(--color-text, #F8FAFC);
    border: 1px solid rgba(200,152,94,0.3);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23C8985E' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.project-selector__dropdown:focus {
    outline: none;
    border-color: #C8985E;
    box-shadow: 0 0 0 2px rgba(200,152,94,0.2);
}
.project-selector__dropdown option {
    background: #0F172A;
    color: #F8FAFC;
}
