:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --danger-color: #e74c3c;
    --bg-color: #f8f9fa;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #7f8c8d;
    --border-color: #e0e0e0;
    --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);
    --radius: 8px;
    --sidebar-width: 260px;
    --header-height: 60px;
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
}

body.sidebar-open {
    overflow: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* Layout Structure */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    transition: var(--transition);
}

.sidebar-backdrop {
    display: none;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}

.sidebar-menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.menu-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--secondary-color);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.menu-item:hover, .menu-item.active {
    background-color: #f0f4f8;
    color: var(--accent-color);
}

.menu-item i {
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.top-header {
    height: var(--header-height);
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.page-title h2 {
    font-size: 1.25rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-toggle {
    display: none;
    flex: 0 0 auto;
}

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

.content-body {
    padding: 30px;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Components */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-primary { background: var(--accent-color); color: white; }
.btn-primary:hover { background: #2980b9; }

.btn-secondary { background: #ecf0f1; color: var(--secondary-color); }
.btn-secondary:hover { background: #bdc3c7; }

.btn-danger { background: var(--danger-color); color: white; }
.btn-danger:hover { background: #c0392b; }

.alert {
    padding: 12px 15px;
    border-radius: 6px;
    border: 1px solid transparent;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th {
    text-align: left;
    padding: 12px 15px;
    border-bottom: 2px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

tr:hover {
    background-color: #fcfcfc;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Badges */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background: #d4edda; color: #155724; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }

/* Table Filters */
.table-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
}

.search-box {
    position: relative;
    flex: 1;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.search-box input {
    padding-left: 35px;
}

/* Responsiveness */
@media (max-width: 1024px) {
    :root {
        --header-height: 56px;
    }

    .sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-width), 86vw);
        max-width: 320px;
        box-shadow: var(--shadow-md);
    }

    .sidebar-header {
        padding: 0 16px;
    }

    .sidebar-header img {
        max-width: 165px !important;
    }

    .sidebar-menu {
        padding: 12px 0;
    }

    .sidebar-footer {
        padding: 14px 16px !important;
    }

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

    .top-header {
        padding: 0 12px;
        gap: 10px;
    }

    .menu-toggle {
        display: inline-flex;
        width: 42px;
        height: 42px;
        justify-content: center;
        padding: 0;
    }

    .user-profile {
        min-width: 0;
        gap: 8px;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar.active .sidebar-header h1,
    .sidebar.active .menu-item span {
        display: block;
    }

    .sidebar.active + .sidebar-backdrop {
        display: block;
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: min(var(--sidebar-width), 86vw);
        background: rgba(44, 62, 80, 0.45);
        z-index: 950;
    }

    .content-body {
        padding: 15px;
        max-width: 100%;
    }

    .card {
        padding: 15px;
        margin-bottom: 15px;
    }

    .card-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .card-header .btn,
    .card-header form,
    .table-filters,
    .table-filters .form-control {
        width: 100%;
    }

    .table-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
    }

    .dashboard-stats,
    .dashboard-charts,
    .dashboard-bottom {
        grid-template-columns: 1fr !important;
    }

    .dashboard-stats {
        gap: 15px !important;
        margin-bottom: 20px !important;
    }

    .dashboard-charts,
    .dashboard-bottom {
        gap: 15px !important;
        margin-bottom: 20px !important;
    }

    .stat-card {
        min-height: 112px;
        position: relative;
    }

    table {
        min-width: 640px;
    }
}

@media (max-width: 768px) {
    .user-profile span {
        display: none;
    }
}

@media (max-width: 480px) {
    .page-title h2 {
        font-size: 1.05rem;
    }

    .content-body {
        padding: 12px;
    }

    .btn {
        justify-content: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Login Page */
.login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h2 {
    color: var(--primary-color);
    margin-bottom: 10px;
}
