:root {
    --primary-color: #1A237E;
    --primary-dark: #121858;
    --bg-light: #F4F7FC;
    --bg-white: #FFFFFF;
    --text-main: #333333;
    --text-muted: #888888;
    --sidebar-bg: #111827;
    --sidebar-text: #A0B2C6;
    --sidebar-active: #1F2937;
    --border-color: #E2E8F0;
    --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 rgba(0,0,0,0.1);
    --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

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

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    background-color: var(--bg-light);
    line-height: 1.5;
}

/* --- Layout & Sidebar --- */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-menu li a span,
.sidebar.collapsed .menu-title {
    display: none;
}

.sidebar-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--sidebar-active);
    padding: 10px;
}

.sidebar-logo {
    max-height: 40px;
    max-width: 100%;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 0;
    overflow-y: auto;
}

.sidebar-menu .menu-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 15px 20px 5px;
    color: #556B8A;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s ease;
}

.sidebar-menu li a i {
    width: 24px;
    margin-right: 10px;
    text-align: center;
    font-size: 1.1rem;
}

.sidebar-menu li a:hover,
.sidebar-menu li a.active {
    background-color: var(--sidebar-active);
    color: #FFFFFF;
    border-left: 4px solid var(--primary-color);
}

/* Accordion Support */
.sidebar-menu li.has-submenu > a::after {
    content: '\f107'; /* FontAwesome angle-down */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    margin-left: auto;
    transition: transform 0.3s ease;
}

.sidebar-menu li.has-submenu.open > a::after {
    transform: rotate(180deg);
}

.sidebar-submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background-color: rgba(0,0,0,0.2);
}

.sidebar-menu li.has-submenu.open .sidebar-submenu {
    max-height: 500px;
}

.sidebar-submenu li a {
    padding: 10px 20px 10px 54px;
    font-size: 0.85rem;
    border-left: none;
}

.sidebar-submenu li a:hover,
.sidebar-submenu li a.active {
    background-color: transparent;
    color: #FFFFFF;
    border-left: 4px solid var(--primary-color);
    padding-left: 50px;
}

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

.top-header {
    height: 60px;
    background-color: var(--primary-color);
    color: #FFFFFF;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

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

.header-left h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: #FFFFFF;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.content-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* --- Sovereign ERP Login Layout --- */
.login-bg {
    display: flex;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

.login-left {
    width: 50%;
    background-color: #121858;
    background-image: radial-gradient(circle at center, #1b2786 0%, #121858 100%);
    color: white;
    padding: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
}

.security-badge {
    display: inline-flex;
    align-items: center;
    background: #6EE7B7;
    color: #064E3B;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-bottom: 30px;
    width: max-content;
}

.security-badge i {
    margin-right: 6px;
    font-size: 0.7rem;
}

.login-hero-title {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 24px;
    letter-spacing: -1px;
}

.login-hero-subtitle {
    font-size: 1.15rem;
    line-height: 1.6;
    color: #A0B2C6;
    max-width: 450px;
    margin-bottom: 60px;
}

.login-stats {
    display: flex;
    gap: 40px;
}

.stat-item h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: #059669; /* Greenish */
    margin-bottom: 4px;
}

.stat-item p {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #A0B2C6;
}

.login-footer-text {
    margin-top: 60px;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.login-right {
    width: 50%;
    background-color: #F0F4FA;
    display: flex;
    flex-direction: column;
    position: relative;
}

.auth-card {
    background: #FFFFFF;
    border-radius: 12px;
    padding: 40px 48px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    text-align: left;
    color: var(--text-main);
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 8px;
}

.auth-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 32px;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

.input-with-icon {
    position: relative;
}

.input-with-icon i.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9CA3AF;
    font-size: 0.9rem;
}

.input-with-icon input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border: none;
    border-radius: 6px;
    background-color: #E6F0F9;
    color: #374151;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s;
}

.input-with-icon input:focus {
    background-color: #DDE8F4;
    box-shadow: inset 0 0 0 1px var(--primary-color);
}

.input-with-icon input::placeholder {
    color: #9CA3AF;
}

.forgot-password {
    float: right;
    font-size: 0.8rem;
    font-weight: 600;
    color: #059669;
    text-decoration: none;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: #4B5563;
    margin-top: 24px;
    margin-bottom: 24px;
}

.remember-me input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    accent-color: var(--primary-color);
}

.auth-btn {
    width: 100%;
    padding: 14px;
    background-color: #1A237E;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.auth-btn:hover {
    background-color: #121858;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #4B5563;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.card-footer .status-green {
    color: #059669;
}

.card-footer .status-green i {
    font-size: 0.5rem;
    margin-right: 4px;
    vertical-align: middle;
}

.right-footer {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 30px;
    font-size: 0.75rem;
    color: #9CA3AF;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-wrap: wrap;
    text-align: center;
}

.signup-link-area {
    margin-top: 24px;
    margin-bottom: auto; /* pushes footer to bottom */
    font-size: 0.9rem;
    color: #4B5563;
    text-align: center;
}

.signup-link-area a {
    font-weight: 700;
    color: #1A237E;
    text-decoration: none;
}

/* Responsive Overrides */
@media (max-width: 992px) {
    .login-bg {
        flex-direction: column;
    }
    
    .login-left, .login-right {
        width: 100%;
    }
    
    .login-left {
        padding: 40px 20px;
        min-height: auto;
    }
    
    .login-hero-title {
        font-size: 2.5rem;
    }
    
    .login-right {
        min-height: 100vh;
    }
    
    .auth-card {
        padding: 30px 20px;
        box-shadow: none;
        border-radius: 0;
        background: transparent;
    }

    .login-top-nav {
        flex-direction: column;
        gap: 15px;
        padding: 20px !important;
        justify-content: center !important;
    }
    
    .login-top-nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px !important;
    }
}

/* --- Card & Table Styles for ERP --- */
.card {
    background: var(--bg-white);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    padding: 20px;
    margin-bottom: 20px;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
}

.table-toolbar input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    width: 250px;
}

.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

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

.table th {
    background-color: #F8FAFC;
    font-weight: 600;
    color: #475569;
}

.table tbody tr:hover {
    background-color: #F1F5F9;
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    margin-right: 8px;
    font-size: 1.1rem;
    transition: color 0.15s;
}

.action-btn.edit:hover { color: var(--primary-color); }
.action-btn.delete:hover { color: #E53E3E; }

/* --- Small screens: the 250px sidebar goes off-canvas ---
   Without this the shell keeps a fixed 250px rail on a phone and every page is
   squeezed into whatever is left. The existing #toggle-sidebar button flips the
   .collapsed class, which below this breakpoint means "slide the drawer in". */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1000;
        width: 250px;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.25);
    }

    .sidebar.collapsed {
        width: 250px;
        transform: translateX(0);
    }

    /* The drawer is full width when open, so the labels come back. */
    .sidebar.collapsed .sidebar-menu li a span,
    .sidebar.collapsed .menu-title {
        display: inline;
    }

    .main-content {
        width: 100%;
        min-width: 0;
    }
}
