:root {
    /* ICEPRE Color Palette */
    --primary-navy: #1a237e;
    --primary-light: #534bae;
    --primary-dark: #000051;

    --accent-red: #c62828;
    --accent-green: #2e7d32;

    --bg-gray: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --white: #ffffff;

    /* Layout */
    --border-radius: 12px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Fonts */
    --font-main: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-gray);
    color: var(--text-main);
    line-height: 1.6;
}

h1,
h2,
h3 {
    color: var(--primary-navy);
    font-weight: 700;
}

input[type="text"] {
    display: block;
    width: 100%;
    height: calc(2.25rem + 2px);
    padding: .375rem .75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

input[type="number"] {
    display: block;
    width: 100%;
    height: calc(2.25rem + 2px);
    padding: .375rem .75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: .25rem;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

input[type="text"]:focus {
    color: #495057;
    background-color: #fff;
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 .2rem rgba(0, 123, 255, .25);
}

/* Base Components */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background-color: #0f172a;
    color: var(--white);
}

.btn-primary:hover {
    background-color: #203158;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-accent-red {
    background-color: var(--accent-red);
    color: var(--white);
}

.btn-accent-green {
    background-color: var(--accent-green);
    color: var(--white);
}

.card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid #e2e8f0;
}

/* Formal Utility */
.text-elegant {
    letter-spacing: -0.025em;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background-color: #0f172a;
    color: white;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
}

.sidebar h2 {
    color: white;
    margin-bottom: 2rem;
    text-align: center;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: all 0.2s;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-icon {
    margin-right: 0.75rem;
}

/* Main Content Layout */
.main,
.main-content {
    flex-grow: 1;
    margin-left: 280px;
    padding: 3rem;
    min-height: 100vh;
    box-sizing: border-box;
    width: calc(100% - 280px);
}

/* Data Tables */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-top: 2rem;
}

th {
    background-color: #f8fafc;
    color: #64748b;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    padding: 1rem;
    text-align: left;
    border-bottom: 2px solid #f1f5f9;
}

td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

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

tr:hover td {
    background-color: #fbfcfe;
}

/* ==========================================
   Shared Layout Styles (Sidebar, User Profile & Modals)
   ========================================== */

:root {
    --sidebar-width: 280px;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: #0f172a !important;
    /* Force matching dark theme */
    color: white;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    box-sizing: border-box;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.sidebar-logo {
    margin-bottom: 3rem;
    text-align: center;
}

.nav-menu {
    list-style: none !important;
    flex-grow: 1;
    padding: 0 !important;
    margin: 0 !important;
}

.nav-item {
    margin-bottom: 0.5rem;
    list-style-type: none !important;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: var(--border-radius);
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

.nav-icon {
    margin-right: 0.75rem;
    width: 20px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Header & User Profile Dropdown */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.user-profile-wrapper {
    position: relative;
    z-index: 200;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: white;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
    border: 1px solid #e2e8f0;
    color: var(--text-main);
}

.user-profile:hover {
    background-color: #f8fafc;
    box-shadow: var(--shadow-md);
}

.avatar {
    width: 35px;
    height: 35px;
    background-color: var(--accent-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
}

.dropdown-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    margin-left: 0.25rem;
}

.user-profile.active .dropdown-arrow {
    transform: rotate(180deg);
}

.profile-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 220px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid #e2e8f0;
    z-index: 1000;
    display: none;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(-10px);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.profile-dropdown.show {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.25rem;
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background 0.2s ease, color 0.2s ease;
}

.dropdown-item:hover {
    background-color: #f8fafc;
}

.dropdown-item.text-red {
    color: var(--accent-red);
}

.dropdown-item.text-red:hover {
    background-color: #fee2e2;
}

.dropdown-divider {
    height: 1px;
    background-color: #f1f5f9;
}

.item-icon {
    margin-right: 0.75rem;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Modals & Overlays */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    opacity: 1;
}

.modal-card {
    background: white;
    border-radius: 16px;
    padding: 2.2rem;
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-lg);
    border: 1px solid #e2e8f0;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.show .modal-card {
    transform: scale(1);
}

.modal-confirm {
    max-width: 400px;
    text-align: center;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.75rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    color: var(--primary-navy);
}

.close-modal-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.close-modal-btn:hover {
    color: var(--accent-red);
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    display: none;
    font-weight: 500;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
    display: block;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
    display: block;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Submenu Styles */
.nav-submenu {
    list-style: none !important;
    padding-left: 2.25rem !important;
    margin-top: 0.25rem;
    margin-bottom: 0.5rem;
    display: none;
    transition: all 0.3s ease;
}

/* Hover-based submenu expansion */
.nav-item.has-submenu {
    position: relative;
}

.nav-item.has-submenu:hover>.nav-submenu,
.nav-item.has-submenu.open>.nav-submenu {
    display: block;
    animation: submenuFadeIn 0.2s ease forwards;
}

.nav-item.has-submenu:hover>.nav-link .submenu-arrow,
.nav-item.has-submenu.open>.nav-link .submenu-arrow {
    transform: rotate(90deg);
}

@keyframes submenuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

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

.submenu-arrow {
    margin-left: auto;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.nav-sub-item {
    margin-bottom: 0.25rem;
    list-style-type: none !important;
}

.nav-sub-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-sub-link:hover,
.nav-sub-link.active {
    background-color: rgba(255, 255, 255, 0.09);
    color: white !important;
    padding-left: 1rem;
}

.nav-sub-icon {
    margin-right: 0.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Modal Lock Background Scroll */
body.modal-open,
html.modal-open {
    overflow: hidden !important;
    height: 100vh !important;
    touch-action: none;
}