:root {
    /* Elegant Theme Palette */
    --primary-color: #ff9f43;
    /* Orange */
    --primary-hover: #e58e3c;
    --secondary-color: #a0a0a0;

    --success-color: #28c76f;
    /* Green */
    --info-color: #00cfe8;
    /* Blue */
    --warning-color: #ff9f43;
    /* Orange again for warning sometimes, or yellow */
    --danger-color: #ea5455;
    /* Red */

    /* Light Mode - Elegant */
    --bg-body: #fff6f0;
    /* Creamy/Peach Background */
    --bg-card: #ffffff;

    --text-main: #333333;
    --text-muted: #888888;

    --border-color: #f0f0f0;

    /* Sidebar specific */
    --sidebar-bg: #ffffff;
    --sidebar-text: #6e6b7b;
    --sidebar-active-bg: #ff9f43;
    --sidebar-active-text: #ffffff;

    --shadow-sm: 0 4px 24px 0 rgba(34, 41, 47, 0.1);
    --shadow-md: 0 4px 24px 0 rgba(34, 41, 47, 0.15);

    --radius: 1rem;
    /* Softer rounded corners */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
    --bg-body: #161d31;
    --bg-card: #283046;
    --text-main: #d0d2d6;
    --text-muted: #676d7d;
    --border-color: #3b4253;
    --sidebar-bg: #283046;
    --sidebar-text: #d0d2d6;
    --sidebar-active-bg: #ff9f43;
    --sidebar-active-text: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    padding: 1.5rem;
    /* Add padding to body for floating effect */
    gap: 1.5rem;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease-in-out;
    flex-shrink: 0;
    border-radius: var(--radius);
    /* Rounded sidebar */
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    /* For radius */
    height: calc(100vh - 3rem);
    /* Full height minus padding */
    position: sticky;
    top: 1.5rem;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    /* Dark text for logo in light mode */
    display: flex;
    align-items: center;
    gap: 0.75rem;
    /* Removed border bottom for cleaner look */
}

.sidebar-nav {
    flex: 1;
    padding: 1rem;
    list-style: none;
    font-size: 0.95rem;
    overflow-y: auto;
}

.sidebar-nav li {
    margin-bottom: 0.5rem;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--sidebar-text);
    gap: 1rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.3s ease;
    border-right: none;
    /* remove old style */
}

.sidebar-nav li a:hover {
    color: var(--text-main);
    background-color: rgba(0, 0, 0, 0.03);
}

.sidebar-nav li a.active {
    background-color: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    box-shadow: 0 4px 15px -3px rgba(255, 159, 67, 0.5);
    /* Orange gloss */
}

.sidebar-footer {
    padding: 1rem;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    gap: 1.5rem;
    min-width: 0;
    /* Fix flex child overflow */
}

.topbar {
    background-color: transparent;
    /* Transparent topbar */
    padding: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: auto;
    border-bottom: none;
}

.page-content {
    padding: 0;
    /* Already padded by app-container */
    flex: 1;
    overflow-y: auto;
}

/* Components */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: none;
    /* No border */
    margin-bottom: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background-color: var(--border-color);
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 0.625rem;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    background-color: var(--bg-body);
    color: var(--text-main);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    ring: 2px solid var(--primary-color);
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    /* Prevent wrap on small screens */
}

.table th {
    font-weight: 600;
    color: var(--text-muted);
    background-color: rgba(0, 0, 0, 0.02);
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.badge-info {
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
}

/* Grid Dashboard */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Login Page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, var(--bg-body) 0%, var(--bg-card) 100%);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
    margin: 0;
}

/* Progress Bar */
.progress-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin: 2rem 0;
    overflow-x: auto;
    /* Scroll on mobile */
    padding-bottom: 1rem;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    height: 4px;
    background-color: var(--border-color);
    z-index: 0;
}

.step-item {
    position: relative;
    z-index: 1;
    background-color: var(--bg-card);
    padding: 0 1rem;
    text-align: center;
    min-width: 80px;
    /* Force width */
}

.step-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--border-color);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.5rem;
    font-weight: 600;
    transition: all 0.3s;
}

.step-item.active .step-circle {
    background-color: var(--primary-color);
    color: white;
}

.step-item.completed .step-circle {
    background-color: var(--success-color);
    color: white;
}

.step-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Mobile Responsiveness */
.toggle-sidebar {
    display: block;
    /* Show on all devices */
    cursor: pointer;
}

/* Collapsed Sidebar (Desktop) */
@media (min-width: 1025px) {
    .sidebar.collapsed {
        width: 80px;
    }

    .sidebar.collapsed .sidebar-header span,
    .sidebar.collapsed .sidebar-nav span,
    .sidebar.collapsed .sidebar-footer {
        display: none;
    }

    .sidebar.collapsed .sidebar-header {
        justify-content: center;
        padding: 1.5rem 0.5rem;
    }

    .sidebar.collapsed .sidebar-header img {
        margin: 0;
    }

    .sidebar.collapsed .sidebar-nav li a {
        justify-content: center;
        padding: 0.75rem;
    }

    .sidebar.collapsed .sidebar-nav li a i {
        font-size: 1.2rem;
        margin: 0;
    }
}

@media (max-width: 1024px) {

    .app-container {
        padding: 1rem;
        gap: 1rem;
        flex-direction: column;
        display: block;
        /* Stack */
    }

    /* Fixed Header for Hamburger */
    .topbar {
        position: sticky;
        top: 0;
        z-index: 900;
        background-color: var(--bg-body);
        /* Opaque background */
        padding: 0.5rem 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        /* Subtle border */
        margin-bottom: 1rem;
    }

    .sidebar {
        position: fixed;
        left: -280px;
        /* Fully hide */
        top: 0;
        bottom: 0;
        height: 100vh;
        z-index: 1000;
        width: 280px;
        border-radius: 0;
        margin: 0;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        transition: left 0.3s ease-in-out;
        /* Smooth slide */
        visibility: hidden;
        /* Hide access when closed */
    }

    .sidebar.show {
        left: 0;
        visibility: visible;
    }

    /* Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.show {
        display: block;
    }

    .main-content {
        width: 100%;
        margin-left: 0;
    }

    .grid-4,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 1rem;
    }
}