:root {
    /* Light Mode */
    --primary-color: #4F46E5; /* Indigo 600 */
    --secondary-color: #1E293B; /* Slate 800 */
    --accent-color: #F97316; /* Orange 500 */
    --text-color: #334155; /* Slate 700 */
    --text-color-light: #F8FAFC; /* Slate 50 */
    --background-color: #F1F5F9; /* Slate 100 */
    --card-background: #FFFFFF;
    --sidebar-background: rgba(255, 255, 255, 0.7); /* Glassmorphism light */
    --sidebar-hover-background: rgba(241, 245, 249, 0.8); /* Slate 100 light */
    --border-color: #E2E8F0; /* Slate 200 */
    --input-background: #FFFFFF;
    --input-border: #CBD5E1; /* Slate 300 */
    --positive-color: #22C55E; /* Green 500 */
    --negative-color: #EF4444; /* Red 500 */
    --neutral-color: #64748B; /* Slate 500 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.15);
    --glass-blur: 10px;
    --glass-border: 1px solid rgba(255, 255, 255, 0.18);

    /* Typography */
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Source Sans Pro', sans-serif;
}

body.dark-mode {
    /* Dark Mode */
    --primary-color: #818CF8; /* Indigo 400 */
    --secondary-color: #F8FAFC; /* Slate 50 */
    --accent-color: #FDBA74; /* Orange 300 */
    --text-color: #CBD5E1; /* Slate 300 */
    --text-color-light: #1E293B; /* Slate 800 */
    --background-color: #0F172A; /* Slate 900 */
    --card-background: #1E293B; /* Slate 800 */
    --sidebar-background: rgba(30, 41, 59, 0.7); /* Glassmorphism dark */
    --sidebar-hover-background: rgba(51, 65, 85, 0.8); /* Slate 700 dark */
    --border-color: #334155; /* Slate 700 */
    --input-background: #1E293B;
    --input-border: #475569; /* Slate 600 */
    --positive-color: #4ADE80; /* Green 400 */
    --negative-color: #F87171; /* Red 400 */
    --neutral-color: #94A3B8; /* Slate 400 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

/* General Styles */
body {
    font-family: var(--font-body);
    margin: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    display: flex;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
    font-size: 16px;
    line-height: 1.6;
    font-weight: 400;
    letter-spacing: 0.01em;
    overflow-x: hidden; /* Prevent horizontal scroll on transitions */
}

.dashboard-container {
    display: flex;
    width: 100%;
}

/* Headings - Montserrat */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--secondary-color);
    transition: color 0.3s ease;
}

/* Sidebar */
.sidebar {
    width: 260px;
    min-width: 260px;
    background-color: var(--sidebar-background);
    backdrop-filter: blur(var(--glass-blur));
    border-right: none;
    box-shadow: var(--shadow-lg);
    padding: 0;
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, transform 0.3s ease, width 0.3s ease, border-right 0.3s ease;
    position: sticky;
    top: 0;
    height: 100vh; /* Ensure sidebar takes full height */
    z-index: 1000;
}

.sidebar-header {
    padding: 0;
    text-align: center;
    flex-shrink: 0;
    overflow: hidden;
    background-color: transparent;
    border: none;
    margin-bottom: 11px; /* ~3mm gap above first menu item */
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.8rem;
    color: #fff;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    position: relative;
    overflow: hidden; /* For gradient hover effect */
}

.sidebar-nav li a .fa-icon {
    margin-right: 1rem;
    font-size: 1.2rem;
    width: 20px; /* Ensure consistent icon alignment */
    text-align: center;
}

.sidebar-nav li a:hover {
    background-color: var(--sidebar-hover-background);
    color: var(--primary-color);
    transform: translateX(5px);
}

.sidebar-nav li a.active {
    background: linear-gradient(90deg, var(--primary-color) 0%, rgba(255,255,255,0) 100%);
    color: var(--text-color-light);
    font-weight: 600;
}

.sidebar-nav li a.active .fa-icon {
    color: var(--text-color-light);
}

/* Main Content Area */
.main-content {
    flex-grow: 1;
    padding: 2rem;
    background-color: var(--background-color);
    transition: background-color 0.3s ease;
}

/* Header/Topbar */
.header {
    background-color: var(--card-background);
    padding: 1.5rem 2rem;
    border-bottom: var(--border-color) solid 1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    position: sticky;
    top: 0;
    z-index: 999;
}

.header-left {
    display: flex;
    align-items: center;
}

.breadcrumb {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-color);
}

.breadcrumb a {
    text-decoration: none;
    color: var(--text-color);
    transition: color 0.2s ease;
}

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

.breadcrumb span {
    margin: 0 0.5rem;
    color: var(--neutral-color);
}

.header-right {
    display: flex;
    align-items: center;
}

.search-bar {
    margin-right: 1.5rem;
    position: relative;
}

.search-bar input {
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    background-color: var(--input-background);
    color: var(--text-color);
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.search-bar input::placeholder {
    color: var(--neutral-color);
}

.search-bar input:focus {
    border-color: var(--primary-color);
    outline: none;
}

.search-bar .fa-search {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--neutral-color);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary-color);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color-light);
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.user-avatar:hover {
    transform: scale(1.05);
}

/* KPI Cards */
.kpi-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background-color: var(--card-background);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    background-image: none;
}

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

.kpi-card-icon {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 2.5rem;
    color: rgba(var(--primary-color-rgb), 0.2); /* Faded primary color */
}

.kpi-card h3 {
    font-size: 1.1rem;
    color: var(--secondary-color);
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.kpi-card-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.kpi-card-change {
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    font-weight: 600;
}

.kpi-card-change.positive {
    color: var(--positive-color);
}

.kpi-card-change.negative {
    color: var(--negative-color);
}

.kpi-card-change .fa-icon {
    margin-right: 0.5rem;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--card-background);
    border-radius: 1rem;
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: background-color 0.3s ease;
}

.data-table th, .data-table td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: var(--background-color);
    color: var(--secondary-color);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.data-table tbody tr:nth-child(odd) {
    background-color: var(--card-background);
}

.data-table tbody tr:nth-child(even) {
    background-color: rgba(var(--background-color-rgb), 0.5); /* Lighter background for even rows */
}

.data-table tbody tr:hover {
    background-color: var(--sidebar-hover-background);
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--text-color-light);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background-color: #4338CA; /* Indigo 700 */
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background-color: var(--neutral-color);
    color: var(--text-color-light);
}

.btn-secondary:hover {
    background-color: #4B5563; /* Slate 700 */
    transform: translateY(-2px);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-outline:hover {
    background-color: rgba(var(--primary-color-rgb), 0.1);
    transform: translateY(-2px);
}

/* Hide all sections by default; JS/CSS shows only the active one */
.content-section {
    display: none;
    padding-top: 1.5rem;
}
.content-section.active {
    display: block;
}

/* Mobile Optimization (basic example) */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        position: fixed;
        height: 100vh;
        z-index: 1001;
    }

    .sidebar.open {
        transform: translateX(0%);
    }

    .main-content {
        margin-left: 0;
    }

    .header {
        padding: 1rem 1.5rem;
    }

    .header-left {
        width: 100%;
        justify-content: space-between;
    }

    .search-bar {
        margin-right: 1rem;
        flex-grow: 1;
    }

    .search-bar input {
        width: 100%;
    }

    .breadcrumb {
        display: none;
    }

    .user-avatar {
        margin-left: 1rem;
    }

    .kpi-cards {
        grid-template-columns: 1fr;
    }

    .data-table th, .data-table td {
        padding: 0.75rem 1rem;
    }

    /* Hamburger Menu Icon */
    .hamburger-menu {
        display: block;
        cursor: pointer;
        font-size: 1.5rem;
        color: var(--secondary-color);
        margin-right: 1rem;
    }
}

/* Utility for RGB conversion for rgba() */
:root {
    --primary-color-rgb: 79, 70, 229;
    --background-color-rgb: 241, 245, 249;
}
body.dark-mode {
    --primary-color-rgb: 129, 140, 248;
    --background-color-rgb: 15, 23, 42;
}

.hidden-mobile {
    display: block;
}

@media (max-width: 768px) {
    .hidden-mobile {
        display: none;
    }
}



/* ============================================================
   FEATURE 2: ALERT-CENTER STYLES
   ============================================================ */

/* Alert-Karten */
.alert-card {
    background-color: var(--input-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 15px;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
    border-left: 5px solid var(--neutral-color);
}

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

.alert-card.alert-severity-critical {
    border-left-color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.04);
}

.alert-card.alert-severity-warning {
    border-left-color: #f39c12;
    background-color: rgba(243, 156, 18, 0.04);
}

.alert-card.alert-severity-info {
    border-left-color: #3498db;
    background-color: rgba(52, 152, 219, 0.04);
}

body.dark-mode .alert-card.alert-severity-critical {
    background-color: rgba(231, 76, 60, 0.1);
}

body.dark-mode .alert-card.alert-severity-warning {
    background-color: rgba(243, 156, 18, 0.1);
}

body.dark-mode .alert-card.alert-severity-info {
    background-color: rgba(52, 152, 219, 0.1);
}

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

.alert-card-body {
    margin-bottom: 12px;
}

.alert-card-body strong {
    font-size: 1.05em;
    color: var(--secondary-color);
}

.alert-card-body p {
    margin: 6px 0;
    font-size: 0.92em;
    color: var(--text-color);
    line-height: 1.5;
}

.alert-meta {
    font-size: 0.8em;
    color: var(--neutral-color);
    font-family: 'Source Code Pro', monospace;
}

.alert-card-actions {
    display: flex;
    gap: 8px;
}

.alert-timestamp {
    font-size: 0.8em;
    color: var(--neutral-color);
}

/* Severity-Badges */
.alert-severity-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.alert-severity-badge.alert-severity-critical {
    background-color: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
}

.alert-severity-badge.alert-severity-warning {
    background-color: rgba(243, 156, 18, 0.15);
    color: #f39c12;
}

.alert-severity-badge.alert-severity-info {
    background-color: rgba(52, 152, 219, 0.15);
    color: #3498db;
}

/* Alert-Badge in Sidebar */
.alert-badge {
    display: inline-block;
    background: #e74c3c;
    color: #fff;
    border-radius: 50%;
    padding: 2px 7px;
    font-size: 0.75em;
    margin-left: 6px;
    font-weight: 700;
    animation: alertPulse 2s infinite;
}

@keyframes alertPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Bestätigen-Button */
.btn-acknowledge {
    background-color: #2ecc71;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.85em;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.btn-acknowledge:hover {
    background-color: #27ae60;
}

/* Alert-Regeln Grid */
.alert-rules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
}

.alert-rule-card {
    background-color: var(--input-background);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 18px;
    transition: background-color 0.3s ease, border-color 0.3s ease, opacity 0.3s ease;
}

.alert-rule-card.rule-disabled {
    opacity: 0.55;
}

.alert-rule-card h4 {
    margin: 10px 0 6px 0;
    font-size: 1.05em;
    color: var(--secondary-color);
}

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rule-category {
    font-size: 0.8em;
    color: var(--neutral-color);
    font-weight: 600;
    text-transform: capitalize;
}

.rule-category i {
    margin-right: 4px;
}

.rule-description {
    font-size: 0.88em;
    color: var(--text-color);
    margin-bottom: 10px;
    line-height: 1.5;
}

.rule-condition {
    margin-bottom: 12px;
}

.rule-condition code {
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.85em;
    font-family: 'Source Code Pro', 'Courier New', monospace;
    color: var(--primary-color);
}

.rule-actions {
    display: flex;
    gap: 8px;
}

.btn-toggle {
    border: none;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.85em;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.2s ease;
}

.btn-toggle.rule-enabled {
    background-color: rgba(231, 76, 60, 0.12);
    color: #e74c3c;
}

.btn-toggle.rule-enabled:hover {
    background-color: rgba(231, 76, 60, 0.25);
}

.btn-toggle.rule-disabled {
    background-color: rgba(46, 204, 113, 0.12);
    color: #2ecc71;
}

.btn-toggle.rule-disabled:hover {
    background-color: rgba(46, 204, 113, 0.25);
}

/* Alert-Historie Tabelle */
.alert-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.alert-history-table th {
    text-align: left;
    padding: 10px 12px;
    background-color: var(--sidebar-hover-background);
    font-weight: 600;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.alert-history-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
}

.alert-ack {
    color: var(--positive-color);
    font-weight: 600;
    font-size: 0.85em;
}

.alert-unack {
    color: var(--accent-color);
    font-weight: 600;
    font-size: 0.85em;
}

/* Alert-Notification (Toast) */
.alert-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 24px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95em;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transform: translateX(100px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-notification.alert-notif-show {
    opacity: 1;
    transform: translateX(0);
}

.alert-notif-success {
    background-color: #2ecc71;
    color: #fff;
}

.alert-notif-warning {
    background-color: #f39c12;
    color: #fff;
}

.alert-notif-error {
    background-color: #e74c3c;
    color: #fff;
}

/* Responsive Alert-Center */
@media (max-width: 768px) {
    .alert-rules-grid {
        grid-template-columns: 1fr;
    }

    .alert-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .alert-history-table {
        font-size: 0.8em;
    }

    .alert-history-table th,
    .alert-history-table td {
        padding: 8px 6px;
    }

    .alert-notification {
        right: 10px;
        left: 10px;
        top: 10px;
    }
}


/* ============================================
   CHAT SECTION STYLES
   ============================================ */

.chat-container {
    display: flex;
    flex-direction: column;
    height: 70vh;
    max-height: 600px;
    padding: 0 !important;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--background-color);
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

.chat-message.bot {
    align-self: flex-start;
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.chat-message.bot .chat-avatar {
    background: var(--gradient-primary);
    color: white;
}

.chat-message.user .chat-avatar {
    background: var(--gradient-success);
    color: white;
}

.chat-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    line-height: 1.5;
    font-size: 14px;
}

.chat-message.bot .chat-bubble {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
    color: var(--text-color);
}

.chat-message.user .chat-bubble {
    background: var(--gradient-primary);
    color: white;
    border-top-right-radius: 4px;
}

.chat-input-area {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--card-background);
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    background: var(--input-background);
    color: var(--text-color);
    font-size: 14px;
    font-family: var(--font-body);
    transition: border-color var(--transition-fast);
    outline: none;
}

.chat-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.chat-send-btn {
    padding: 12px 20px !important;
    border-radius: var(--radius-md) !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn i {
    font-size: 16px;
}

/* Chat loading animation */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typing 1.4s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}


/* ============================================================
   FIXES: Class name aliases & missing rules
   ============================================================ */

/* Hide all sections by default; JS shows the active one */
.dashboard-section {
    display: none;
}
.dashboard-section.active {
    display: block;
}

/* nav.navigation → sidebar-nav equivalent */
nav.navigation {
    flex: 1;
    overflow-y: auto;
}
nav.navigation ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
nav.navigation li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.5rem;
    color: var(--text-color);
    text-decoration: none;
    font-size: 1.05rem;
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
nav.navigation li a:hover {
    background-color: var(--sidebar-hover-background);
    color: var(--primary-color);
    transform: translateX(5px);
}
nav.navigation li a.active {
    background: linear-gradient(90deg, var(--primary-color) 0%, rgba(255,255,255,0) 100%);
    color: var(--text-color-light);
    font-weight: 600;
}

/* .topbar → header equivalent */
.topbar {
    background-color: var(--card-background);
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 999;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* .kpi-grid → kpi-cards grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Chart layout */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.chart-card {
    background-color: var(--card-background);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    transition: background-color 0.3s ease;
}
.chart-card h3 {
    margin: 0 0 1rem;
    font-size: 1rem;
    color: var(--secondary-color);
}
.chart-card canvas {
    height: 250px !important;
}

/* Section header */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}
.section-header h2 {
    margin: 0;
}
.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* KPI card sub-elements */
.kpi-icon-wrapper {
    font-size: 2rem;
    color: rgba(var(--primary-color-rgb), 0.25);
    margin-bottom: 0.75rem;
}
.kpi-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.kpi-label {
    font-size: 0.72rem;
    color: var(--secondary-color);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.65;
}
.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.1;
}
.kpi-trend {
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}
.kpi-trend.positive { color: var(--positive-color); }
.kpi-trend.negative { color: var(--negative-color); }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
}
.sidebar-overlay.active {
    display: block;
}

/* Hamburger button */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--secondary-color);
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 0.4rem;
    transition: background-color 0.2s ease;
}
.hamburger-btn:hover {
    background-color: var(--sidebar-hover-background);
}
@media (max-width: 768px) {
    .hamburger-btn { display: block; }
}

/* User profile in topbar */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
}
.user-profile img.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}
.user-name {
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.95rem;
}

/* Icon button (dark mode toggle etc.) */
.icon-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.45rem 0.75rem;
    color: var(--text-color);
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.icon-btn:hover {
    background-color: var(--sidebar-hover-background);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Search input */
.search-input {
    padding: 0.5rem 1rem 0.5rem 2.25rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    background-color: var(--input-background);
    color: var(--text-color);
    font-size: 0.9rem;
    transition: border-color 0.2s ease;
    outline: none;
}
.search-input:focus {
    border-color: var(--primary-color);
}
.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--neutral-color);
    font-size: 0.85rem;
}

/* Sidebar footer */
.sidebar-footer {
    flex-shrink: 0;
    padding: 1rem 0;
    border-top: 1px solid var(--border-color);
}
.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: var(--neutral-color);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s ease, background-color 0.2s ease;
}
.sidebar-footer .nav-link:hover {
    color: var(--primary-color);
    background-color: var(--sidebar-hover-background);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1.5rem;
    color: var(--neutral-color);
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Table container */
.table-container {
    overflow-x: auto;
    border-radius: 1rem;
}

/* Responsive: kpi-grid and chart-grid on mobile */
@media (max-width: 768px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .chart-grid { grid-template-columns: 1fr; }
    .topbar { padding: 0.75rem 1rem; }
    .user-name { display: none; }
}

/* ==========================================
   INTEGRATIONS-HUB
   ========================================== */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}
.integration-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.integration-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}
.integration-card.connected {
    border: 1px solid var(--border-color);
}
.integration-card.disconnected {
    opacity: 0.7;
}
.integration-card.testing {
    animation: pulse 1s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}
.integration-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.integration-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}
.integration-card h3 {
    margin: 0.5rem 0;
    font-size: 1.1rem;
}
.integration-category {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-secondary, #f1f5f9);
}
.integration-meta {
    margin: 0.75rem 0;
    color: var(--text-muted, #94a3b8);
}
.integration-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}
.integration-detail {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* ==========================================
   ACTIVITY FEED
   ========================================== */
.activity-feed-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.activity-feed-container h3 {
    margin: 0 0 1rem 0;
}
.activity-feed {
    max-height: 300px;
    overflow-y: auto;
}
.activity-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}
.activity-item:hover {
    background: var(--bg-secondary, #f8fafc);
}
.activity-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}
.activity-text {
    flex: 1;
}
.activity-time {
    color: var(--text-muted, #94a3b8);
    font-size: 0.8rem;
    flex-shrink: 0;
}

/* ==========================================
   DETAIL TABLES
   ========================================== */
.detail-content {
    max-height: 400px;
    overflow-y: auto;
}
.detail-section {
    margin-bottom: 1rem;
}
.detail-section h4 {
    margin: 0 0 0.5rem 0;
    text-transform: capitalize;
    color: var(--primary-color);
    font-size: 0.9rem;
}
.detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.detail-table td {
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.detail-table td:first-child {
    font-weight: 500;
    color: var(--text-muted, #64748b);
    width: 40%;
}

/* ==========================================
   STOCK INDICATOR
   ========================================== */
.stock-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.stock-bar {
    height: 6px;
    border-radius: 3px;
    min-width: 40px;
    max-width: 80px;
    display: inline-block;
}

/* ==========================================
   TOAST NOTIFICATIONS
   ========================================== */
.toast {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    animation: slideIn 0.3s ease;
    min-width: 300px;
    max-width: 450px;
}
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
.toast button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-muted);
    margin-left: auto;
}
.toast-success { border-left: 4px solid #10b981; }
.toast-error { border-left: 4px solid #ef4444; }
.toast-info { border-left: 4px solid #3b82f6; }
.toast-warning { border-left: 4px solid #f59e0b; }

/* ==========================================
   CHAT
   ========================================== */
.chat-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 250px);
    min-height: 400px;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}
.chat-msg {
    display: flex;
    margin-bottom: 1rem;
}
.chat-msg.user {
    justify-content: flex-end;
}
.chat-msg.bot {
    justify-content: flex-start;
}
.chat-bubble {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    line-height: 1.5;
    font-size: 0.95rem;
}
.chat-msg.user .chat-bubble {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}
.chat-msg.bot .chat-bubble {
    background: var(--bg-secondary, #f1f5f9);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.chat-msg.typing .chat-bubble {
    animation: pulse 1.5s infinite;
}
.chat-form {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
}
.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--card-bg);
    color: var(--text-primary);
}

/* ==========================================
   SETTINGS
   ========================================== */
.settings-container {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
}
.settings-group {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.settings-group:last-child {
    border-bottom: none;
}
.settings-group h3 {
    margin: 0 0 1rem 0;
    color: var(--primary-color);
}
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.9rem;
}
.form-input {
    width: 100%;
    max-width: 400px;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--card-bg);
    color: var(--text-primary);
}
.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

/* ==========================================
   ADDITIONAL UI
   ========================================== */
.summary-stat {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.75rem;
    background: var(--bg-secondary, #f1f5f9);
    border-radius: 20px;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}
.header-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted, #94a3b8);
}
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted, #94a3b8);
    font-size: 1.1rem;
}
.badge-danger {
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: 0.5rem;
}
.alert-actions {
    margin-top: 0.5rem;
}
.product-name {
    font-weight: 600;
}
.product-sku {
    font-size: 0.8rem;
    color: var(--text-muted, #94a3b8);
}
.customer-name {
    font-weight: 600;
}
.customer-email {
    font-size: 0.8rem;
    color: var(--text-muted, #94a3b8);
}
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    border-radius: 4px;
    transition: background 0.2s;
}
.btn-icon:hover {
    background: var(--bg-secondary, #f1f5f9);
}
.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
}
.btn-secondary {
    background: var(--bg-secondary, #e2e8f0);
    color: var(--text-primary);
    border: none;
    cursor: pointer;
}
.btn-secondary:hover {
    background: #cbd5e1;
}
.alerts-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.alerts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}
.alert-item {
    background: var(--card-background);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
}
.alert-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}
.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}
.alert-time {
    font-size: 0.8rem;
    color: var(--text-muted, #94a3b8);
}

/* ==========================================
   DASHBOARD SUBSECTION TILES
   ========================================== */

/* Section subheading (e.g. "Was ist heute wichtig") */
.subsection-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--neutral-color);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 2rem 0 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.subsection-title i {
    font-size: 0.9rem;
}

/* Challenge / action-plan tile: large coloured number */
.tile-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    margin: 0.25rem 0;
}
.tile-number.severity-danger  { color: #EF4444; }
.tile-number.severity-warning { color: #F97316; }
.tile-number.severity-info    { color: var(--primary-color); }

/* Small description text inside the tile */
.tile-desc {
    font-size: 0.88rem;
    color: var(--text-color);
    line-height: 1.55;
    margin-top: 0.35rem;
    opacity: 0.82;
}

/* No left accent borders — tiles use severity class for colouring */

/* Priority badge positioned in top-right corner of action tile */
.tile-priority-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.55rem;
    border-radius: 99px;
}
.tile-priority-badge.danger  { background: rgba(239,68,68,0.12);  color: #EF4444; }
.tile-priority-badge.warning { background: rgba(249,115,22,0.12); color: #F97316; }
.tile-priority-badge.success { background: rgba(34,197,94,0.12);  color: #22C55E; }

/* Action tile title */
.tile-task-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--secondary-color);
    line-height: 1.3;
    margin: 0.5rem 0 0.25rem;
}

/* ==========================================
   INSIGHT PROSE (Proaktive Insights, Meta-BI, Szenario)
   ========================================== */

.scenario-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

#scenario-result {
    width: 100%;
    height: auto;
    overflow: visible;
}

.insight-prose {
    background: var(--card-background);
    border-radius: 1rem;
    padding: 2rem 2.5rem;
    box-shadow: var(--shadow-md);
    line-height: 1.75;
    color: var(--text-color);
    max-width: 100%;
    height: auto;
    overflow: visible;
}

.insight-prose h1,
.insight-prose h2,
.insight-prose h3,
.insight-prose h4 {
    font-family: var(--font-heading);
    color: var(--secondary-color);
    margin: 1.75rem 0 0.6rem;
    line-height: 1.25;
}
.insight-prose h1 { font-size: 1.5rem; }
.insight-prose h2 {
    font-size: 1.15rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
}
.insight-prose h3 { font-size: 1rem; color: var(--primary-color); }
.insight-prose h4 { font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--neutral-color); }

.insight-prose p {
    margin: 0 0 1rem;
}
.insight-prose p:last-child { margin-bottom: 0; }

.insight-prose ul,
.insight-prose ol {
    margin: 0.5rem 0 1rem 1.5rem;
    padding: 0;
}
.insight-prose li {
    margin-bottom: 0.4rem;
}
.insight-prose li::marker {
    color: var(--primary-color);
}

.insight-prose strong {
    font-weight: 700;
    color: var(--secondary-color);
}
.insight-prose em {
    color: var(--neutral-color);
}

.insight-prose blockquote {
    border-left: 3px solid var(--primary-color);
    margin: 1rem 0;
    padding: 0.5rem 1.25rem;
    background: rgba(79, 70, 229, 0.05);
    border-radius: 0 0.5rem 0.5rem 0;
    color: var(--neutral-color);
    font-style: italic;
}

.insight-prose code {
    background: var(--background-color);
    padding: 0.15em 0.4em;
    border-radius: 0.25rem;
    font-size: 0.85em;
    color: var(--accent-color);
}

.insight-prose hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

/* Data source badges (Meta-BI) */
.source-badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 1.25rem;
    font-size: 0.82rem;
    color: var(--neutral-color);
}
.source-badges i { margin-right: 0.25rem; }
.source-badge {
    background: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 99px;
    padding: 0.15rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--neutral-color);
    white-space: nowrap;
}

/* Alert product list */
.alert-product-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.alert-product-list li {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 0.75rem;
    row-gap: 0.2rem;
    align-items: center;
}
.ap-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-color);
    grid-column: 1;
    grid-row: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ap-stock {
    font-size: 0.78rem;
    color: var(--neutral-color);
    grid-column: 2;
    grid-row: 1;
    white-space: nowrap;
}
.ap-bar {
    grid-column: 1 / -1;
    grid-row: 2;
    height: 4px;
    background: var(--border-color);
    border-radius: 99px;
    overflow: hidden;
}
.ap-bar-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s ease;
}
.ap-bar-fill.bar-danger  { background: var(--danger-color, #e53e3e); }
.ap-bar-fill.bar-warning { background: var(--warning-color, #dd6b20); }

/* =====================================================
   ERP & FINANZEN SECTION
   ===================================================== */

/* Supplier cards grid */
.erp-supplier-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.erp-supplier-card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 1.1rem 1.2rem;
    box-shadow: var(--card-shadow);
}

.erp-supplier-card .supplier-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 0.6rem;
}

.erp-supplier-card .supplier-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 1rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
}

.erp-supplier-card .supplier-meta span {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.erp-supplier-card .supplier-reliability {
    margin-top: 0.4rem;
}

.reliability-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.reliability-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 99px;
    overflow: hidden;
}

.reliability-fill {
    height: 100%;
    border-radius: 99px;
    transition: width 0.5s ease;
}

.reliability-fill.bar-ok      { background: #10b981; }
.reliability-fill.bar-warning  { background: #f59e0b; }
.reliability-fill.bar-danger   { background: #ef4444; }

/* ERP source badge */
.source-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 999px;
    background: rgba(99,102,241,0.12);
    color: #6366f1;
    border: 1px solid rgba(99,102,241,0.25);
    white-space: nowrap;
}

/* Badge colours (already partially defined, extend) */
.badge-primary { background: rgba(99,102,241,0.15); color: #6366f1; }
.badge-success { background: rgba(16,185,129,0.15); color: #059669; }
.badge-warning { background: rgba(245,158,11,0.15); color: #d97706; }
.badge-danger  { background: rgba(239,68,68,0.15);  color: #dc2626; }
.badge-info    { background: rgba(59,130,246,0.15);  color: #2563eb; }
.ap-bar-fill.bar-ok      { background: var(--success-color, #38a169); }

/* Logo styling */
.sidebar-header img {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0;
    object-fit: contain;
}


/* =====================================================================
   AI OUTPUT — clar_core() SIGNATURE DESIGN
   Applies to: .ai-output (wrapper class for all AI-generated content)
   Used in: Optimierungsfahrplan, Szenario-Planer, Proaktive Insights,
            KI-Chat, Meta-BI Insights
   ===================================================================== */

:root {
    --ai-cyan: #00BCD4;
    --ai-cyan-light: #4DD0E1;
    --ai-cyan-dark: #00838F;
    --ai-cyan-glow: rgba(0, 188, 212, 0.12);
    --ai-cyan-border: rgba(0, 188, 212, 0.25);
    --ai-cyan-accent: #26C6DA;
    --ai-font-prose: 'IBM Plex Serif', 'Georgia', serif;
    --ai-font-mono: 'JetBrains Mono', 'IBM Plex Mono', 'Fira Code', monospace;
    --ai-font-data: 'IBM Plex Mono', 'JetBrains Mono', monospace;
}

body.dark-mode {
    --ai-cyan: #4DD0E1;
    --ai-cyan-light: #80DEEA;
    --ai-cyan-dark: #00ACC1;
    --ai-cyan-glow: rgba(77, 208, 225, 0.1);
    --ai-cyan-border: rgba(77, 208, 225, 0.2);
    --ai-cyan-accent: #4DD0E1;
}

/* --- Base AI Output Container --- */
.ai-output {
    font-family: var(--ai-font-prose);
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text-color);
    position: relative;
    letter-spacing: 0.005em;
}

/* --- Terminal Prompt Indicator --- */
.ai-prompt-indicator {
    display: inline-block;
    width: auto;
    margin-right: 0.5rem;
    font-family: var(--ai-font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--ai-cyan);
    opacity: 0.9;
    vertical-align: baseline;
    letter-spacing: 0;
}
.ai-prompt-indicator::before {
    content: "clar_core()";
    display: inline-block;
    padding: 0.1rem 0.45rem;
    background: var(--ai-cyan-glow);
    border: 1px solid var(--ai-cyan-border);
    border-radius: 4px;
    line-height: 1.4;
}
.ai-prompt-indicator::after {
    content: " >";
    color: var(--ai-cyan-accent);
    font-weight: 600;
}

/* --- insight-prose with AI styling --- */
.insight-prose.ai-output,
.ai-output .insight-prose {
    border-left: 3px solid var(--ai-cyan);
    background: linear-gradient(135deg, var(--ai-cyan-glow) 0%, transparent 60%), var(--card-background);
    border-radius: 0 1rem 1rem 0;
    padding: 2rem 2.5rem 2rem 2rem;
}

/* --- AI Output Headings --- */
.ai-output h1,
.ai-output h2,
.ai-output h3,
.ai-output h4,
.ai-output h5 {
    font-family: var(--ai-font-mono);
    color: var(--ai-cyan-dark);
    letter-spacing: -0.01em;
    position: relative;
}
body.dark-mode .ai-output h1,
body.dark-mode .ai-output h2,
body.dark-mode .ai-output h3,
body.dark-mode .ai-output h4 {
    color: var(--ai-cyan-light);
}
.ai-output h1 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--ai-cyan-border);
}
.ai-output h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 1.5rem 0 0.5rem;
    padding-bottom: 0.35rem;
    border-bottom: 1px solid var(--ai-cyan-border);
}
.ai-output h3 {
    font-size: 1rem;
    font-weight: 500;
    margin: 1.25rem 0 0.4rem;
    color: var(--ai-cyan);
}
.ai-output h4 {
    font-size: 0.88rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ai-cyan-dark);
    opacity: 0.85;
}

/* --- AI Output Paragraphs --- */
.ai-output p {
    margin: 0 0 0.9rem;
    font-family: var(--ai-font-prose);
    line-height: 1.8;
}
.ai-output p:last-child { margin-bottom: 0; }

/* --- AI Output Lists --- */
.ai-output ul,
.ai-output ol {
    margin: 0.5rem 0 1rem 1.25rem;
    padding: 0;
}
.ai-output li {
    margin-bottom: 0.4rem;
    line-height: 1.7;
    font-family: var(--ai-font-prose);
}
.ai-output li::marker {
    color: var(--ai-cyan);
    font-weight: 600;
}
.ai-output ul li::marker {
    content: "\25B8\00a0";
    font-size: 0.85em;
}

/* --- AI Output Strong/Em --- */
.ai-output strong {
    font-weight: 600;
    color: var(--secondary-color);
}
.ai-output em {
    font-style: italic;
    color: var(--ai-cyan-dark);
}
body.dark-mode .ai-output em {
    color: var(--ai-cyan-light);
}

/* --- AI Output Blockquote --- */
.ai-output blockquote {
    border-left: 3px solid var(--ai-cyan);
    margin: 1rem 0;
    padding: 0.6rem 1.25rem;
    background: var(--ai-cyan-glow);
    border-radius: 0 0.5rem 0.5rem 0;
    font-style: italic;
    color: var(--text-color);
}

/* --- AI Output Code --- */
.ai-output code {
    font-family: var(--ai-font-mono);
    background: var(--ai-cyan-glow);
    border: 1px solid var(--ai-cyan-border);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.82em;
    color: var(--ai-cyan-dark);
}
body.dark-mode .ai-output code {
    color: var(--ai-cyan-light);
}

.ai-output pre {
    background: #0d1117;
    border: 1px solid var(--ai-cyan-border);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin: 1rem 0;
}
.ai-output pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: #e6edf3;
    font-size: 0.82rem;
    line-height: 1.6;
}

/* --- AI Output Tables --- */
.ai-output table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.88rem;
    border: 1px solid var(--ai-cyan-border);
    border-radius: 0.5rem;
    overflow: hidden;
}
.ai-output th {
    background: var(--ai-cyan-glow);
    color: var(--ai-cyan-dark);
    font-family: var(--ai-font-mono);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.65rem 0.9rem;
    text-align: left;
    border-bottom: 2px solid var(--ai-cyan-border);
}
body.dark-mode .ai-output th {
    color: var(--ai-cyan-light);
}
.ai-output td {
    padding: 0.55rem 0.9rem;
    border-bottom: 1px solid var(--border-color);
    font-family: var(--ai-font-prose);
}
.ai-output tr:last-child td {
    border-bottom: none;
}
.ai-output tbody tr:hover {
    background: var(--ai-cyan-glow);
}

/* --- AI Output HR --- */
.ai-output hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--ai-cyan-border), var(--ai-cyan), var(--ai-cyan-border), transparent);
    margin: 1.5rem 0;
}

/* --- Data/Numbers in AI output --- */
.ai-output .ai-data,
.ai-output [data-type="number"],
.ai-output .metric-value {
    font-family: var(--ai-font-data);
    font-weight: 500;
    color: var(--ai-cyan-dark);
    letter-spacing: 0.02em;
}
body.dark-mode .ai-output .ai-data,
body.dark-mode .ai-output [data-type="number"],
body.dark-mode .ai-output .metric-value {
    color: var(--ai-cyan-light);
}

/* --- Custom Icons replacing emojis --- */
.ai-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3em;
    height: 1.3em;
    margin-right: 0.3rem;
    vertical-align: -0.15em;
    flex-shrink: 0;
}
.ai-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: var(--ai-cyan);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* --- Chat AI Bot Bubble Styling --- */
.chat-msg.bot .chat-bubble.ai-output {
    font-family: var(--ai-font-prose);
    background: linear-gradient(135deg, var(--ai-cyan-glow) 0%, var(--card-background) 40%);
    border: 1px solid var(--ai-cyan-border);
    border-left: 3px solid var(--ai-cyan);
    border-bottom-left-radius: 4px;
    color: var(--text-color);
    font-size: 0.93rem;
    line-height: 1.7;
}

/* --- Loading State with AI Branding --- */
.ai-loading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem;
    color: var(--ai-cyan);
    font-family: var(--ai-font-mono);
    font-size: 0.85rem;
}
.ai-loading::before {
    content: "";
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--ai-cyan-border);
    border-top-color: var(--ai-cyan);
    border-radius: 50%;
    animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin {
    to { transform: rotate(360deg); }
}

/* --- Section-level AI container (for Insights, Scenario, etc.) --- */
.ai-output-section {
    position: relative;
    margin-top: 0.5rem;
}
.ai-output-section::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(180deg, var(--ai-cyan), var(--ai-cyan-border), transparent);
    border-radius: 2px;
}

/* --- Animated subtle glow on fresh AI output --- */
@keyframes ai-fade-in {
    0% {
        opacity: 0;
        transform: translateY(6px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}
.ai-output {
    animation: ai-fade-in 0.4s ease-out;
}

/* --- Override insight-prose when inside ai-output --- */
.ai-output.insight-prose h1,
.ai-output.insight-prose h2,
.ai-output.insight-prose h3,
.ai-output.insight-prose h4 {
    font-family: var(--ai-font-mono);
}
.ai-output.insight-prose h1 {
    color: var(--ai-cyan-dark);
    border-bottom-color: var(--ai-cyan-border);
}
.ai-output.insight-prose h2 {
    color: var(--ai-cyan-dark);
    border-bottom-color: var(--ai-cyan-border);
}
.ai-output.insight-prose h3 {
    color: var(--ai-cyan);
}
.ai-output.insight-prose li::marker {
    color: var(--ai-cyan);
}
.ai-output.insight-prose strong {
    color: var(--secondary-color);
}
.ai-output.insight-prose blockquote {
    border-left-color: var(--ai-cyan);
    background: var(--ai-cyan-glow);
}
.ai-output.insight-prose code {
    background: var(--ai-cyan-glow);
    border: 1px solid var(--ai-cyan-border);
    color: var(--ai-cyan-dark);
}
body.dark-mode .ai-output.insight-prose h1,
body.dark-mode .ai-output.insight-prose h2 {
    color: var(--ai-cyan-light);
}
body.dark-mode .ai-output.insight-prose h3 {
    color: var(--ai-cyan);
}
body.dark-mode .ai-output.insight-prose code {
    color: var(--ai-cyan-light);
}

/* ========================================== */
/* MODAL STYLES */
/* ========================================== */
.btn-action {
    background-color: var(--primary-color);
    color: var(--text-color-light);
    border: none;
    padding: 6px 10px;
    margin-left: 4px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.btn-action i { font-size: 0.9rem; }
.btn-details { background-color: var(--neutral-color); }
.btn-details:hover { background-color: #7a8ba1; }
.btn-ai { background-color: var(--ai-cyan, #00e5ff); color: #0a0a1a; font-weight: 600; }
.btn-ai:hover { background-color: #33ecff; }
.actions-cell { white-space: nowrap; }

.spinner {
    border: 4px solid rgba(0, 229, 255, 0.2);
    border-top: 4px solid var(--ai-cyan, #00e5ff);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
@keyframes slideInTop {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ========================================== */
/* MODAL STYLES */
/* ========================================== */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 10000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0, 0, 0, 0.7); /* Black w/ opacity */
    backdrop-filter: blur(5px); /* Subtle blur for background */
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background-color: var(--card-background);
    margin: 8% auto; /* 8% from the top and centered */
    padding: 30px;
    border: 1px solid var(--ai-cyan-border);
    border-radius: 12px;
    width: 90%; /* Could be more or less, depending on screen size */
    max-width: 800px;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: slideInTop 0.3s ease-out;
}

.modal-body {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 10px; /* For scrollbar */
}

.modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.modal-body th, .modal-body td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.modal-body th {
    color: var(--ai-cyan);
    font-family: var(--ai-font-heading);
    font-weight: 500;
}

.modal-body tr:last-child td {
    border-bottom: none;
}

.close-button {
    color: var(--text-color);
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-button:hover,
.close-button:focus {
    color: var(--negative-color);
    text-decoration: none;
}

/* ========================================== */
/* SLIDE PANEL STYLES (AI Analysis) */
/* ========================================== */
.slide-panel-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    animation: fadeIn 0.3s ease-out;
}

.slide-panel {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 450px; /* Adjust width as needed */
    max-width: 90vw;
    height: 100%;
    background-color: var(--card-background);
    border-left: 2px solid var(--ai-cyan-border);
    z-index: 9999;
    overflow-y: auto;
    padding: 25px;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    transform: translateX(100%);
    animation: slideInRight 0.3s forwards;
    display: flex;
    flex-direction: column;
}

.slide-panel.open {
    transform: translateX(0%);
}

.slide-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.slide-panel-header h2 {
    color: var(--ai-cyan);
    margin: 0;
}

.close-slide-panel {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 32px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-slide-panel:hover {
    color: var(--negative-color);
}

.slide-panel-body {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 10px; /* For scrollbar */
}

.slide-panel-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    text-align: right;
    flex-shrink: 0;
}

/* ========================================== */
/* ACTION BUTTONS IN TABLES */
/* ========================================== */
.actions-cell {
    white-space: nowrap;
}

.btn-action {
    background-color: var(--primary-color);
    color: var(--text-color-light);
    border: none;
    padding: 8px 12px;
    margin-left: 5px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-action:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-action i {
    font-size: 1rem;
}

.btn-details {
    background-color: var(--neutral-color);
}

.btn-details:hover {
    background-color: #7a8ba1; /* Darker neutral */
}

.btn-ai {
    background-color: var(--ai-cyan);
    color: var(--secondary-color);
}

.btn-ai:hover {
    background-color: var(--ai-cyan-light);
}

/* Spinner for loading states */
.spinner {
    border: 4px solid rgba(0, 229, 255, 0.2); /* Light cyan */
    border-top: 4px solid var(--ai-cyan); /* Cyan */
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

@keyframes slideInTop {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ==================== MODAL SYSTEM ==================== */
.cc-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}

.cc-modal {
    background: var(--card-bg, var(--card-background, #1a1a2e));
    border: 1px solid var(--ai-cyan-border, var(--border-color, #0d7377));
    border-radius: 12px;
    width: 100%;
    max-width: 750px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideInTop 0.25s ease-out;
}

.cc-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--ai-cyan-border, var(--border-color, #0d7377));
    flex-shrink: 0;
}

.cc-modal-header h3 {
    margin: 0;
    font-family: var(--ai-font-heading, var(--font-heading, 'JetBrains Mono'));
    color: var(--ai-cyan, var(--primary-color, #00e5ff));
    font-size: 1.15rem;
    word-break: break-word;
}

.cc-modal-close {
    background: none;
    border: none;
    color: var(--text-color-light, #fff);
    font-size: 28px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    flex-shrink: 0;
    margin-left: 16px;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.cc-modal-close:hover {
    opacity: 1;
}

.cc-modal-body {
    padding: 20px 24px 24px;
    overflow-y: auto;
    overflow-x: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.cc-modal-body .ai-output {
    line-height: 1.7;
    font-family: var(--ai-font-body, var(--font-body, 'IBM Plex Serif'));
    color: var(--text-color-light, var(--text-color, #e0e0e0));
}

.cc-modal-body .detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.cc-modal-body .data-table {
    width: 100%;
    table-layout: auto;
}

@media (max-width: 600px) {
    .cc-modal {
        max-width: 100%;
        max-height: 90vh;
        border-radius: 8px;
    }
    .cc-modal-header {
        padding: 16px;
    }
    .cc-modal-body {
        padding: 16px;
    }
}

/* ===== INTERACTIVE DASHBOARD CARDS ===== */
.dash-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}
.dash-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.10);
}
.dash-card.completed {
  opacity: 0.5;
  transform: scale(0.97);
  pointer-events: none;
  transition: all 0.6s ease;
}
.dash-card.completed::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  color: #22c55e;
  font-weight: bold;
}
.dash-card.fade-out {
  opacity: 0;
  max-height: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  transition: all 0.5s ease;
}

/* Urgency indicator */
.urgency-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.urgency-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.urgency-dot.urgent { background: #ef4444; }
.urgency-dot.this-week { background: #f97316; }
.urgency-dot.soon { background: #eab308; }
.urgency-dot.info { background: #22c55e; }
.urgency-label.urgent { color: #ef4444; }
.urgency-label.this-week { color: #f97316; }
.urgency-label.soon { color: #eab308; }
.urgency-label.info { color: #22c55e; }

/* Priority badge */
.priority-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.priority-badge.high { background: #fef2f2; color: #dc2626; }
.priority-badge.medium { background: #fff7ed; color: #ea580c; }
.priority-badge.recommendation { background: #eff6ff; color: #2563eb; }
.priority-badge.optional { background: #f3f4f6; color: #6b7280; }

/* Card title & desc */
.dash-card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.3;
}
.dash-card-desc {
  font-size: 0.9rem;
  color: #64748b;
  line-height: 1.5;
}
.dash-card-impact {
  font-size: 0.85rem;
  color: #059669;
  font-weight: 600;
  padding: 6px 0;
}

/* Card buttons */
.dash-card-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 8px;
}
.btn-card {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  border: 2px solid;
}
.btn-card.btn-details {
  background: transparent;
  border-color: #3b82f6;
  color: #3b82f6;
}
.btn-card.btn-details:hover {
  background: #3b82f6;
  color: #fff;
}
.btn-card.btn-done {
  background: transparent;
  border-color: #22c55e;
  color: #22c55e;
}
.btn-card.btn-done:hover {
  background: #22c55e;
  color: #fff;
}

/* ===== DETAIL MODAL ===== */
.detail-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}
.detail-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}
.detail-modal {
  background: #fff;
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}
.detail-modal-overlay.active .detail-modal {
  transform: translateY(0);
}
.detail-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.detail-modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
}
.detail-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #94a3b8;
  line-height: 1;
}
.detail-modal-close:hover { color: #1e293b; }
.detail-modal-body {
  padding: 24px;
}
.detail-modal-body h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #334155;
  margin: 16px 0 8px;
}
.detail-modal-body h4:first-child { margin-top: 0; }
.detail-modal-body p, .detail-modal-body li {
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.6;
}
.detail-modal-body ol {
  padding-left: 20px;
}
.detail-modal-body ol li {
  margin-bottom: 6px;
}
.detail-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.btn-modal-navigate {
  padding: 10px 20px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.btn-modal-navigate:hover { background: #2563eb; }
.btn-modal-close {
  padding: 10px 20px;
  background: #f1f5f9;
  color: #475569;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-modal-close:hover { background: #e2e8f0; }

/* ==========================================
   INTERACTIVE TILES - CHALLENGES & ACTION PLAN
   ========================================== */
.interactive-tile {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.4s;
}
.interactive-tile:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.interactive-tile.tile-done {
    opacity: 0.4;
    pointer-events: none;
}

.tile-urgency-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}
.urgency-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    display: inline-block;
}
.urgency-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-color);
    opacity: 0.75;
}

.tile-priority-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tile-priority-badge.danger  { background: #fee2e2; color: #b91c1c; }
.tile-priority-badge.warning { background: #ffedd5; color: #c2410c; }
.tile-priority-badge.info    { background: #dbeafe; color: #1d4ed8; }
.tile-priority-badge.neutral { background: #f1f5f9; color: #64748b; }
body.dark-mode .tile-priority-badge.danger  { background: #450a0a; color: #fca5a5; }
body.dark-mode .tile-priority-badge.warning { background: #431407; color: #fdba74; }
body.dark-mode .tile-priority-badge.info    { background: #1e3a5f; color: #93c5fd; }
body.dark-mode .tile-priority-badge.neutral { background: #1e293b; color: #94a3b8; }

.tile-meta {
    font-size: 0.8rem;
    margin-top: 5px;
    color: var(--text-color);
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}
.tile-meta-icon { font-style: normal; }

.tile-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.tile-btn {
    flex: 1;
    min-width: 100px;
    padding: 7px 10px;
    border: none;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
    white-space: nowrap;
}
.tile-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tile-btn-detail {
    background: #e0e7ff;
    color: #3730a3;
}
.tile-btn-detail:hover { background: #c7d2fe; }
.tile-btn-done {
    background: #dcfce7;
    color: #166534;
}
.tile-btn-done:hover { background: #bbf7d0; }
body.dark-mode .tile-btn-detail { background: #1e3a5f; color: #93c5fd; }
body.dark-mode .tile-btn-detail:hover { background: #1e40af; }
body.dark-mode .tile-btn-done { background: #14532d; color: #86efac; }
body.dark-mode .tile-btn-done:hover { background: #166534; }

/* ==========================================
   DETAIL MODAL
   ========================================== */
.detail-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.detail-modal-overlay.active {
    display: flex;
}
.detail-modal-overlay .modal-content {
    background: var(--card-background);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 560px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    animation: modalSlideIn 0.22s ease;
}
@keyframes modalSlideIn {
    from { transform: translateY(24px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-color);
}
.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--secondary-color);
    margin: 0;
}
.modal-close-btn {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: var(--text-color);
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
    transition: background 0.15s;
}
.modal-close-btn:hover { background: var(--border-color); }
.modal-body {
    padding: 20px 24px;
}
.modal-description {
    font-size: 0.95rem;
    color: var(--text-color);
    line-height: 1.6;
    margin: 0 0 16px;
}
.modal-steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.modal-steps li {
    background: var(--background-color);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--text-color);
    border-left: 3px solid var(--primary-color);
}
.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 14px 24px 20px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

/* Detail Modal Footer */
.detail-modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}
