:root, :root[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-gray: #94a3b8;
    --primary: #E60012;
    --primary-hover: #C50010;
    --nav-bg: rgba(15, 23, 42, 0.85);
    --glass-blur: blur(12px);
    --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    /* Form Controls, Inputs & Pills (Dark Theme) */
    --input-bg: rgba(15, 23, 42, 0.7);
    --input-border: rgba(255, 255, 255, 0.15);
    --input-text: #f8fafc;
    --input-placeholder: #64748b;
    --control-bg: rgba(15, 23, 42, 0.7);
    --pill-bg: rgba(255, 255, 255, 0.06);
    --pill-border: rgba(255, 255, 255, 0.12);
    --pill-text: #f1f5f9;
    --pill-hover: rgba(255, 255, 255, 0.14);
    --dropdown-bg: #1e293b;
    --dropdown-item-hover: rgba(255, 255, 255, 0.08);
}

:root[data-theme="light"] {
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 50%, #e2e8f0 100%);
    --card-bg: #ffffff;
    --card-border: #cbd5e1;
    --text-main: #0f172a;
    --text-gray: #475569;
    --primary: #E60012;
    --primary-hover: #C50010;
    --nav-bg: rgba(255, 255, 255, 0.95);
    --glass-blur: blur(12px);
    --shadow: 0 8px 30px 0 rgba(15, 23, 42, 0.08);

    /* Form Controls, Inputs & Pills (Light Theme - Crisp White & High Contrast) */
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --input-text: #0f172a;
    --input-placeholder: #94a3b8;
    --control-bg: #f8fafc;
    --pill-bg: #f1f5f9;
    --pill-border: #cbd5e1;
    --pill-text: #1e293b;
    --pill-hover: #e2e8f0;
    --dropdown-bg: #ffffff;
    --dropdown-item-hover: #f1f5f9;
}

:root[data-theme="light"] .role-badge {
    color: #3730a3;
    background: #e0e7ff;
    border-color: #c7d2fe;
}
:root[data-theme="light"] .role-badge-admin {
    color: #991b1b;
    background: #fee2e2;
    border-color: #fca5a5;
}
:root[data-theme="light"] .role-badge-lotte-manager {
    color: #92400e;
    background: #fef3c7;
    border-color: #fde68a;
}
:root[data-theme="light"] .role-badge-department-staff {
    color: #1e40af;
    background: #dbeafe;
    border-color: #bfdbfe;
}
:root[data-theme="light"] .role-badge-vendor {
    color: #065f46;
    background: #d1fae5;
    border-color: #a7f3d0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    min-height: 100vh;
    background: var(--bg-gradient);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
}

.background-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    background: radial-gradient(circle at 50% 20%, rgba(239, 68, 68, 0.12) 0%, transparent 60%);
    z-index: 0;
}

.top-nav {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 0.8rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: var(--glass-blur);
    background: var(--nav-bg);
    border-bottom: 1px solid var(--card-border);
    z-index: 100;
}

.top-nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo {
    display: flex;
    align-items: center;
}

.logo-icon {
    font-size: 1.8rem;
    color: #ef4444;
    margin-right: 0.75rem;
}

.logo-text {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 1px;
    background: linear-gradient(90deg, #ef4444, #f97316);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
}

.mobile-quick-bar {
    display: none;
    align-items: center;
    gap: 0.5rem;
}

.theme-btn-compact, .logout-btn-compact {
    background: var(--control-bg);
    border: 1px solid var(--input-border);
    color: var(--text-main);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.2s ease;
}

.logout-btn-compact {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1.2rem;
}

.user-greeting {
    font-size: 0.92rem;
    color: var(--text-main);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-reset-pw {
    background: rgba(59, 130, 246, 0.15) !important;
    border: 1px solid rgba(59, 130, 246, 0.35) !important;
    color: #60a5fa !important;
    cursor: pointer;
    padding: 0.45rem 0.85rem !important;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    white-space: nowrap;
}

.btn-reset-pw:hover {
    background: rgba(59, 130, 246, 0.25) !important;
}

.admin-links-scroll {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.admin-link:hover {
    text-decoration: underline;
}

.logout-link {
    color: var(--text-gray);
    text-decoration: none;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
}

.logout-link:hover {
    color: #ef4444;
}

.portal-container {
    max-width: 1200px;
    width: 90%;
    margin-top: 6.5rem;
    margin-bottom: 3rem;
    text-align: center;
    z-index: 1;
}

.portal-container header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.portal-container header p {
    color: var(--text-gray);
    font-size: 1.1rem;
    margin-bottom: 2.5rem;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.8rem;
}

.portal-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2rem;
    text-decoration: none;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    position: relative;
    overflow: hidden;
}

.portal-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 12px 40px rgba(239, 68, 68, 0.2);
}

.card-icon {
    font-size: 2.2rem;
    color: var(--primary);
    background: rgba(239, 68, 68, 0.12);
    width: 60px;
    height: 60px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.2rem;
}

.card-content h2 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
}

.card-content p {
    color: var(--text-gray);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.btn-action {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.95rem;
}

.portal-card:hover .btn-action {
    color: var(--primary-hover);
}

.portal-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.8);
}

/* ==========================================================================
   Mobile & Portrait Viewport Optimizations (Phone 360px - 768px)
   ========================================================================== */

@media (max-width: 900px) {
    .portal-container {
        width: 92%;
        margin-top: 6rem;
    }
    .grid-container {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 1.25rem;
    }
}

@media (max-width: 768px) {
    .top-nav {
        padding: 0.65rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .desktop-theme-btn, .desktop-logout-link {
        display: none !important;
    }

    .mobile-quick-bar {
        display: flex;
    }

    .top-nav-brand {
        width: 100%;
        justify-content: space-between;
    }

    .logo-icon {
        font-size: 1.4rem;
        margin-right: 0.5rem;
    }

    .logo-text {
        font-size: 1.3rem;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
        gap: 0.5rem;
        padding-top: 0.35rem;
        border-top: 1px solid rgba(255, 255, 255, 0.08);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .portal-container {
        width: 92%;
        margin-top: 7.2rem;
    }

    .portal-container header h1 {
        font-size: 1.85rem;
    }

    .portal-container header p {
        font-size: 0.95rem;
        margin-bottom: 1.75rem;
    }
}

@media (max-width: 480px) {
    .top-nav {
        padding: 0.5rem 0.85rem;
    }

    .logo-icon {
        font-size: 1.25rem;
        margin-right: 0.4rem;
    }

    .logo-text {
        font-size: 1.15rem;
        letter-spacing: 0.5px;
    }

    .user-greeting {
        font-size: 0.82rem;
    }

    .btn-reset-pw {
        font-size: 0.78rem !important;
        padding: 0.35rem 0.65rem !important;
    }

    .portal-container {
        width: 92%;
        margin-top: 6.8rem;
        margin-bottom: 2rem;
    }

    .portal-container header h1 {
        font-size: 1.55rem;
        margin-bottom: 0.3rem;
    }

    .portal-container header p {
        font-size: 0.88rem;
        margin-bottom: 1.25rem;
    }

    .grid-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .portal-card {
        padding: 1.25rem 1.15rem;
        border-radius: 16px;
    }

    .card-icon {
        width: 48px;
        height: 48px;
        font-size: 1.5rem;
        border-radius: 12px;
        margin-bottom: 0.85rem;
    }

    .card-content h2 {
        font-size: 1.2rem;
        margin-bottom: 0.25rem;
    }

    .card-content p {
        font-size: 0.85rem;
        margin-bottom: 0.85rem;
    }

    .btn-action {
        font-size: 0.88rem;
    }

    /* Modals & Login Card Responsive */
    .login-card {
        padding: 1.6rem 1.25rem !important;
        border-radius: 20px !important;
        width: 92% !important;
        margin-top: 3.5rem !important;
    }

    .login-card h2 {
        font-size: 1.35rem !important;
    }

    /* Reset password modal */
    #resetPasswordModal > div {
        width: 94vw !important;
        max-width: 94vw !important;
        padding: 18px 16px !important;
        border-radius: 16px !important;
    }
}
