/* ============================================
   AlgoVista Solar Dashboard — Master Styles
   Matches the dark sidebar + light card theme
   ============================================ */

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

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 64px;

    --sidebar-bg: #111827;
    --sidebar-hover: rgba(255,255,255,0.06);
    --sidebar-active: rgba(59,130,246,0.12);
    --card-bg: #ffffff;
    --body-bg: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --text-white: #f8fafc;
    --accent-blue: #3b82f6;
    --accent-blue-dark: #2563eb;
    --accent-amber: #f59e0b;
    --accent-teal: #14b8a6;
    --accent-green: #22c55e;
    --accent-red: #ef4444;
    --accent-purple: #8b5cf6;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-primary: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Space Grotesk', 'DM Sans', sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-primary);
    background: var(--body-bg);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ========== SIDEBAR ========== */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: width var(--transition), min-width var(--transition);
    overflow: hidden;
}

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

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    min-height: 64px;
}

.logo-link {
    display: flex;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-full {
    display: block;
    transition: opacity 0.2s;
}

.logo-compact {
    display: none;
    transition: opacity 0.2s;
}

.sidebar.collapsed .logo-full { display: none; }
.sidebar.collapsed .logo-compact { display: flex; }

.logo-img-full {
    height: 36px;
    object-fit: contain;
}

.logo-img-compact {
    height: 32px;
    width: 32px;
    object-fit: contain;
}

.logo-fallback-full {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-mark {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-teal));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
}

.logo-mark-compact {
    width: 32px;
    height: 32px;
    font-size: 16px;
    border-radius: 7px;
}

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

.logo-name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 2.5px;
    color: white;
    line-height: 1.1;
}

.logo-sub {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-toggle {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,0.06);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.sidebar-toggle svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar.collapsed .sidebar-toggle {
    margin: 0 auto;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    overflow-y: auto;
    overflow-x: hidden;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: all 0.15s;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

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

.nav-item.active {
    background: var(--sidebar-active);
    color: var(--accent-blue-dark);
}

.nav-item.active svg { color: var(--accent-blue); }

.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 8px 12px;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: white;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.user-name {
    color: var(--text-white);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .user-details,
.sidebar.collapsed .logout-btn { display: none; }
.sidebar.collapsed .user-info { justify-content: center; }

.logout-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: background 0.2s;
    flex-shrink: 0;
    text-decoration: none;
}

.logout-btn svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.logout-btn:hover {
    background: rgba(239,68,68,0.15);
}

.logout-btn:hover svg { color: var(--accent-red); }

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

/* ========== TOPBAR ========== */
.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}

.page-title {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-top: 1px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--border-light);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 7px 14px;
    width: 240px;
    transition: all 0.2s;
}

.search-box:focus-within {
    border-color: var(--accent-blue);
    background: white;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.08);
}

.search-box svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    background: none;
    font-family: var(--font-primary);
    font-size: 13px;
    color: var(--text-primary);
    width: 100%;
    outline: none;
}

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

.connection-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 6px 12px;
    background: var(--border-light);
    border-radius: 20px;
}

.conn-dot {
    width: 7px;
    height: 7px;
    background: var(--accent-green);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.conn-time { color: var(--text-muted); }

.refresh-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent-blue);
    color: white;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-btn svg {
    width: 15px;
    height: 15px;
}

.refresh-btn:hover {
    background: var(--accent-blue-dark);
    box-shadow: 0 4px 12px rgba(59,130,246,0.3);
}

/* ========== CONTENT AREA ========== */
.content-area {
    flex: 1;
    padding: 24px 28px;
    overflow-y: auto;
}

/* KPI Cards Row */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s;
}

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

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 12px 12px 0 0;
}

.kpi-card.blue::before { background: var(--accent-blue); }
.kpi-card.green::before { background: var(--accent-green); }
.kpi-card.amber::before { background: var(--accent-amber); }
.kpi-card.teal::before { background: var(--accent-teal); }
.kpi-card.red::before { background: var(--accent-red); }
.kpi-card.purple::before { background: var(--accent-purple); }

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.kpi-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.3;
    max-width: 85%;
}

.kpi-ai-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.kpi-ai-btn svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.kpi-ai-btn:hover {
    background: rgba(59,130,246,0.1);
}

.kpi-ai-btn:hover svg {
    color: var(--accent-blue);
}

.kpi-value {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
}

.kpi-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.kpi-change {
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-left: 6px;
}

.kpi-change.up { color: var(--accent-green); }
.kpi-change.down { color: var(--accent-red); }

/* Section Label */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    margin-top: 8px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-teal);
    padding: 5px 12px;
    background: rgba(20,184,166,0.08);
    border-radius: 20px;
    letter-spacing: 0.5px;
}

.live-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent-teal);
    border-radius: 50%;
    animation: pulse-dot 2s infinite;
}

/* Chart Cards */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.chart-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.2s;
}

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

.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-light);
}

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

.chart-ai-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.chart-ai-btn svg {
    width: 13px;
    height: 13px;
}

.chart-ai-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    background: rgba(59,130,246,0.04);
}

.chart-card-body {
    padding: 16px 20px 20px;
    position: relative;
}

.chart-card-body canvas {
    width: 100% !important;
    max-height: 260px;
}

/* AI Insight Card */
.ai-insight-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

.ai-insight-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.ai-insight-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(139,92,246,0.1));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-insight-icon svg {
    width: 18px;
    height: 18px;
    color: var(--accent-blue);
}

.ai-insight-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-insight-refresh {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.ai-insight-refresh svg {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

.ai-insight-refresh:hover {
    border-color: var(--accent-blue);
    background: rgba(59,130,246,0.04);
}

.ai-insight-body {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.ai-insight-body .insight-bullet {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.ai-insight-body .insight-bullet::before {
    content: '';
    display: none;
}

.insight-emoji {
    font-size: 16px;
    flex-shrink: 0;
    line-height: 1.5;
}

.insight-text {
    flex: 1;
}

.insight-text strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Line Cards (Manufacturing) */
.line-cards-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.line-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}

.line-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.line-card-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.line-card-name svg {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.line-card-name span {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
}

.status-badge {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 3px 10px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-badge.running {
    color: var(--accent-green);
    background: rgba(34,197,94,0.08);
}

.status-badge.halted {
    color: var(--accent-red);
    background: rgba(239,68,68,0.08);
}

.status-badge.maintenance {
    color: var(--accent-amber);
    background: rgba(245,158,11,0.08);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.line-product {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.line-product-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.line-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.line-metric {
    padding: 10px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
}

.line-metric-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.line-metric-value {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
}

.line-metric-value.good { color: var(--accent-green); }
.line-metric-value.warn { color: var(--accent-amber); }
.line-metric-value.bad { color: var(--accent-red); }
.line-metric-value.neutral { color: var(--text-primary); }

.line-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
    font-size: 12px;
    color: var(--text-muted);
}

.line-manager {
    display: flex;
    align-items: center;
    gap: 5px;
}

.line-manager svg {
    width: 14px;
    height: 14px;
}

.resource-dots {
    display: flex;
    gap: 3px;
}

.resource-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.resource-dot.active { background: var(--accent-green); }
.resource-dot.inactive { background: #e2e8f0; }

/* ========== DATA UPLOAD SECTION ========== */
.upload-section {
    max-width: 800px;
}

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    background: white;
    transition: all 0.2s;
    cursor: pointer;
}

.upload-zone:hover {
    border-color: var(--accent-blue);
    background: rgba(59,130,246,0.02);
}

.upload-zone-icon {
    width: 56px;
    height: 56px;
    background: rgba(59,130,246,0.08);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
}

.upload-zone-icon svg {
    width: 28px;
    height: 28px;
    color: var(--accent-blue);
}

.upload-zone h3 {
    font-family: var(--font-display);
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.upload-zone p {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent-blue);
    color: white;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-btn:hover {
    background: var(--accent-blue-dark);
}

.upload-formats {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.format-tag {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: var(--border-light);
    color: var(--text-muted);
}

.upload-history {
    margin-top: 24px;
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.upload-history-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.upload-history-item:last-child { border-bottom: none; }

.upload-file-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.upload-file-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: white;
}

.upload-file-icon.csv { background: var(--accent-green); }
.upload-file-icon.xlsx { background: var(--accent-blue); }
.upload-file-icon.tally { background: var(--accent-purple); }

.upload-file-name { font-weight: 500; color: var(--text-primary); }
.upload-file-meta { font-size: 12px; color: var(--text-muted); }

.upload-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 600;
}

.upload-status.success { color: var(--accent-green); }
.upload-status.pending { color: var(--accent-amber); }

/* ========== AI MODAL ========== */
.ai-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    width: 560px;
    max-height: 80vh;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.25s;
}

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

.ai-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.ai-modal-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.ai-modal-title svg {
    width: 20px;
    height: 20px;
    color: var(--accent-blue);
}

.ai-modal-close {
    width: 30px;
    height: 30px;
    border: none;
    background: var(--border-light);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-modal-close svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

.ai-modal-body {
    padding: 20px;
    overflow-y: auto;
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.ai-loading {
    text-align: center;
    padding: 30px 0;
}

.ai-loading p {
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 13px;
}

.ai-loading-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.ai-loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent-blue);
    border-radius: 50%;
    animation: dotBounce 1.4s infinite ease-in-out;
}

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

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.ai-result {
    white-space: pre-wrap;
}

.ai-result strong {
    color: var(--text-primary);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1400px) {
    .kpi-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1100px) {
    .chart-grid { grid-template-columns: 1fr; }
    .chart-grid-3 { grid-template-columns: 1fr 1fr; }
    .line-cards-row { grid-template-columns: 1fr 1fr; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0 !important; }
    .topbar { padding: 0 16px; }
    .content-area { padding: 16px; }
    .search-box { display: none; }
    .kpi-row { grid-template-columns: 1fr; }
    .line-cards-row { grid-template-columns: 1fr; }
}
