:root {
    /* Color Palette - NEUTRAL / BLUE Theme */
    --bg-body: #121212;
    /* Neutral Dark */
    --bg-card: #1e1e1e;
    /* Neutral Card */
    --bg-sidebar: #0a0a0a;
    /* Darker Sidebar */

    --primary: #10b981;
    /* Emerald 500 - Professional Green */
    --primary-hover: #059669;
    /* Emerald 600 */
    --primary-glow: rgba(16, 185, 129, 0.4);

    --text-main: #e4e4e7;
    /* Zinc 200 */
    --text-muted: #a1a1aa;
    /* Zinc 400 */

    --border-color: #27272a;
    /* Zinc 800 */

    --success-bg: rgba(34, 197, 94, 0.15);
    --success-text: #4ade80;

    --warning-bg: rgba(234, 179, 8, 0.15);
    --warning-text: #facc15;

    /* Metrics - COMPACTED */
    --sidebar-width: 240px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

* {
    box-sizing: border-box;
}

/* CUSTOM SCROLLBAR */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #52525b;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    margin: 0;
    padding: 0;
    display: flex;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    z-index: 100;
}

.brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-header {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin: 16px 0 6px 10px;
    letter-spacing: 0.05em;
    opacity: 0.8;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    font-weight: 500;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-link.active {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border-color: rgba(99, 102, 241, 0.2);
}

.nav-link i {
    width: 20px;
    margin-right: 10px;
    font-size: 1rem;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 24px 32px;
    /* Adjusted padding */
    width: calc(100% - var(--sidebar-width));
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    width: 100%;
    /* Ensure full width */
}

/* Header User Profile */
.header-profile {
    display: inline-flex;
    /* Changed to inline-flex */
    align-items: center;
    gap: 12px;
    padding: 6px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    margin-left: auto;
    /* Push to right */
    height: 42px;
    /* Fixed height for consistency */
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

/* Badges */
.badge {
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.status-active {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.status-completed {
    background: rgba(99, 102, 241, 0.2);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-family: inherit;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.85rem;
    margin-bottom: 6px;
    display: block;
    color: var(--text-muted);
}

.form-control {
    background-color: #27272a;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 10px 12px;
    border-radius: var(--radius-md);
    width: 100%;
    font-family: inherit;
    font-size: 0.9rem;
    transition: 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

/* Table Styling */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table thead {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--border-color);
}

.table th {
    text-align: left;
    padding: 12px 16px;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
    cursor: pointer;
}

.table tbody tr:last-child {
    border-bottom: none;
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.table td {
    padding: 12px 16px;
    color: var(--text-main);
    vertical-align: middle;
}

/* 3-Column Layout */
.detail-layout {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 24px;
    height: calc(100vh - 140px);
}

.col-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.col-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.col-content {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: #3f3f46 transparent;
    /* Firefox */
}

.col-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

/* Todo List & Areas */
.todo-item {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    margin-bottom: 6px;
}

.area-item {
    padding: 6px 10px;
    margin-bottom: 2px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-muted);
}

.area-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.area-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

/* Status Select Dropdown */
.status-select {
    padding: 4px 8px;
    font-size: 0.8rem;
    height: auto;
    border: 1px solid var(--border-color);
    background-color: var(--bg-body);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-right: 10px;
    transition: all 0.2s;
    outline: none;
}

.status-select option {
    background-color: var(--bg-card);
    color: var(--text-main);
}

.status-select.pending {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.05);
    /* Lighter bg */
}

.status-select.in_progress {
    border-color: #eab308;
    color: #eab308;
    background: rgba(234, 179, 8, 0.05);
}

.status-select.completed {
    border-color: #10b981;
    color: #10b981;
    background: rgba(16, 185, 129, 0.05);
}

/* RESPONSIVE SUB-SYSTEM */

/* Mobile Menu Button - Default Hidden on Desktop */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    margin-right: 15px;
}

/* Tablet & Smaller Desktop */
@media (max-width: 1024px) {
    .detail-layout {
        grid-template-columns: 1fr;
        /* Stack vertically */
        height: auto;
        /* Allow full page scrolling */
        gap: 20px;
    }

    .col-panel {
        height: auto;
        min-height: 300px;
    }

    .col-content {
        max-height: 500px;
        /* Limit inner height so page doesn't get infinitely long */
        overflow-y: auto;
    }
}

/* Mobile Devices */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        /* Hide sidebar by default */
        transition: transform 0.3s ease;
        z-index: 1000;
        box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
        /* Shadow when open */
    }

    .sidebar.active {
        transform: translateX(0);
        /* Show when active */
    }

    .main-content {
        margin-left: 0;
        /* Remove margin */
        width: 100%;
        padding: 16px;
        /* Reduce padding */
    }

    .page-header {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    /* Reveal Mobile Toggle Button */
    .mobile-menu-btn {
        display: block;
    }

    .header-actions {
        /* On very small screens, maybe wrap actions? */
        /* flex-wrap: wrap; */
    }

    /* Mobile Table to Card Transformation */
    .table thead {
        display: none;
        /* Hide headers */
    }

    .table,
    .table tbody,
    .table tr,
    .table td {
        display: block;
        width: 100%;
    }

    .table tr {
        background: var(--bg-card);
        margin-bottom: 12px;
        border: 1px solid var(--border-color);
        border-radius: var(--radius-md);
        padding: 12px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    }

    .table td {
        padding: 6px 0;
        text-align: right;
        /* Content on right */
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 0.9rem;
    }

    .table td:last-child {
        border-bottom: none;
    }

    /* Add labels via ::before pseudo-element */
    .table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-muted);
        text-transform: uppercase;
        font-size: 0.75rem;
        margin-right: 15px;
    }

    /* Hide Header Add Button on Mobile */
    .header-add-area-btn {
        display: none !important;
    }

    /* Show Content Add Button on Mobile */
    .mobile-add-area-btn {
        display: flex !important;
        width: 100%;
        justify-content: center;
        margin-bottom: 15px;
        padding: 12px !important;
    }
}

/* Default state for Content Add Button (Hidden on Desktop) */
.mobile-add-area-btn {
    display: none;
}

/* LOGIN PAGE STYLES */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-body);
    position: relative;
    overflow: hidden;
}

#starfield {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    /* Allow clicks to pass through to form */
}

.login-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: rgba(30, 30, 30, 0.9);
    /* --bg-card with opacity */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    padding: 40px;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.login-brand {
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-main);
}

.login-brand i {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary), #4ade80);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-brand h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-top: 10px;
    letter-spacing: -0.5px;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.btn-login:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(16, 185, 129, 0.4);
}

/* Transition Effects */
.login-card {
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.login-card.fade-out {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
}

/* Welcome Screen (Replaces Modal) */
.welcome-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    opacity: 0;
    transition: opacity 1s ease-in-out 0.5s;
    /* Delay to start after card fades */
    z-index: 20;
    width: 100%;
    pointer-events: none;
    /* KEY FIX: Prevent blocking inputs when invisible */
}

.welcome-screen.show {
    opacity: 1;
    pointer-events: auto;
    /* Re-enable clicks if needed (though it just shows text) */
}

.welcome-text-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.welcome-icon-large {
    font-size: 4rem;
    color: #ffd700;
    /* Gold */
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
    animation: float 3s ease-in-out infinite;
}

.welcome-text-large {
    font-size: 2.5rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.8s ease-out 0.8s;
    /* Staggered animation */
}

.welcome-screen.show .welcome-text-large {
    opacity: 1;
    transform: translateY(0);
}

.highlight-name {
    color: var(--primary);
    position: relative;
    display: inline-block;
}

.highlight-name::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}