:root {
    /* Color Palette - Premium & Modern */
    --primary-hue: 250;
    --primary: hsl(var(--primary-hue), 70%, 60%);
    --primary-dark: hsl(var(--primary-hue), 70%, 50%);
    --primary-light: hsl(var(--primary-hue), 70%, 95%);
    --accent: hsl(330, 80%, 60%);

    --bg-body: hsl(220, 20%, 98%);
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;

    --text-main: hsl(220, 20%, 20%);
    --text-muted: hsl(220, 10%, 50%);
    --border-color: hsl(220, 20%, 92%);

    --success: hsl(150, 60%, 45%);
    --warning: hsl(35, 90%, 55%);
    --danger: hsl(0, 70%, 60%);

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;

    --font-main: 'Noto Sans JP', 'Outfit', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode {
    --bg-body: hsl(220, 20%, 10%);
    --bg-card: hsl(220, 20%, 14%);
    --bg-sidebar: hsl(220, 20%, 12%);

    --text-main: hsl(220, 20%, 90%);
    --text-muted: hsl(220, 10%, 60%);
    --border-color: hsl(220, 20%, 18%);

    --primary-light: hsl(var(--primary-hue), 30%, 20%);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#app {
    display: flex;
    height: 100%;
}

/* Sidebar */
#sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    transition: var(--transition);
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.logo-icon {
    font-size: 2rem;
    color: var(--primary);
}

.logo-text .accent {
    color: var(--primary);
}

.nav-links {
    list-style: none;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
    font-weight: 500;
}

.nav-item:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 0.875rem;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
#main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#top-bar {
    height: 80px;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#page-title {
    font-size: 1.5rem;
    font-weight: 600;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.icon-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary-light);
}

.badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-card);
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
}

.primary-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.secondary-btn {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    transition: var(--transition);
}

.secondary-btn:hover {
    background: var(--bg-body);
    color: var(--text-main);
    border-color: var(--primary);
}

#module-container {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

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

/* Responsive Grid Utilities */
.responsive-grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.responsive-grid-1-1 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

/* Mobile Overrides for Grids */
@media (max-width: 768px) {

    .responsive-grid-2-1,
    .responsive-grid-1-1 {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }
}

/* Zen Mode Styles */
body.zen-mode #sidebar {
    display: none;
}

body.zen-mode #theme-toggle {
    display: none;
}

body.zen-mode #alerts-column {
    display: none;
}

body.zen-mode #goals-column {
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

body.zen-mode #goals-list>div:not(:first-child) {
    opacity: 0.3;
    pointer-events: none;
    filter: blur(2px);
}

/* Zen Exit Button (FAB) */
#zen-exit-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: none;
    /* Hidden by default */
    animation: fadeIn 0.3s ease;
}

body.zen-mode #zen-exit-btn {
    display: flex !important;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Navigation */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        z-index: 1000;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

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

    #mobile-menu-btn {
        display: flex !important;
    }

    #mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s;
    }

    #mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    #page-title {
        font-size: 1.1rem;
    }

    #module-container {
        padding: 1rem !important;
    }

    .card {
        padding: 1rem !important;
    }

    /* Force vertical layout for security score card on mobile */
    #monitoring-section .card>div[style*="display: flex"] {
        flex-direction: column;
        gap: 1rem !important;
    }

    /* Adjust button sizes */
    .primary-btn,
    .secondary-btn {
        padding: 0.6rem 1rem;
        font-size: 0.85rem;
        width: 100%;
        /* Full width buttons on mobile */
        justify-content: center;
    }

    /* Fix toggle switch alignment */
    .switch {
        margin-left: 0.5rem;
    }

    /* Mobile Menu Consolidation */
    .mobile-tools {
        display: block !important;
    }

    .top-actions {
        display: none !important;
    }
}

body.zen-mode #top-bar {
    justify-content: center;
}

body.zen-mode #page-title {
    text-align: center;
}

body.zen-mode .top-actions>*:not(#zen-toggle) {
    display: none;
}