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

:root {
    --bg-primary: #1a1d29;
    --bg-secondary: #23262f;
    --bg-tertiary: #2a2d39;
    --sidebar-bg: #1e2130;
    --text-primary: #ffffff;
    --text-secondary: #a0a3bd;
    --text-muted: #6e7191;
    --border-color: #2d3142;
    --blue: #4A9EFF;
    --orange: #FF9F43;
    --cyan: #00C9DB;
    --green: #28C76F;
    --red: #EA5455;
    --sidebar-width: 240px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    overflow-y: auto;
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.app-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--blue);
    font-weight: 600;
    font-size: 0.938rem;
    line-height: 1.3;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    margin-bottom: 0.25rem;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--blue);
    color: var(--text-primary);
}

.nav-link svg {
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

.system-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.813rem;
    color: var(--text-secondary);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 0 0 0 rgba(40, 199, 111, 0.7);
    }
    50% {
        opacity: 0.8;
        box-shadow: 0 0 0 8px rgba(40, 199, 111, 0);
    }
}

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

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.page-icon {
    color: var(--text-secondary);
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.icon-button {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.icon-button:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--blue);
}

.icon-button.refresh {
    color: var(--blue);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--red);
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.user-menu:hover {
    background: var(--border-color);
}

/* Dashboard Content */
.dashboard-content {
    padding: 2rem;
    flex: 1;
}

/* Stats Row */
.stats-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.stat-card.card-blue { border-top: 3px solid var(--blue); }
.stat-card.card-orange { border-top: 3px solid var(--orange); }
.stat-card.card-cyan { border-top: 3px solid var(--cyan); }
.stat-card.card-green { border-top: 3px solid var(--green); }
.stat-card.card-red { border-top: 3px solid var(--red); }

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-header svg {
    opacity: 0.5;
}

.card-blue .stat-header svg { color: var(--blue); }
.card-orange .stat-header svg { color: var(--orange); }
.card-cyan .stat-header svg { color: var(--cyan); }
.card-green .stat-header svg { color: var(--green); }
.card-red .stat-header svg { color: var(--red); }

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.stat-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-change {
    font-size: 0.813rem;
    color: var(--text-muted);
}

.stat-change.positive {
    color: var(--green);
}

.action-btn-small {
    background: var(--red);
    color: white;
    border: none;
    padding: 0.375rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn-small:hover {
    background: #d93d3e;
    transform: scale(1.05);
}

/* Chart Section */
.chart-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.section-header {
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

/* Progress Bars */
.progress-bars {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.progress-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
}

.progress-label span:first-child {
    color: var(--text-primary);
    font-weight: 500;
}

.progress-count {
    color: var(--text-secondary);
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.progress-fill.orange { background: var(--orange); }
.progress-fill.cyan { background: var(--cyan); }
.progress-fill.green { background: var(--green); }
.progress-fill.blue { background: var(--blue); }
.progress-fill.red { background: var(--red); }

.unit {
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

/* Event Chart */
#eventChart {
    width: 100%;
    height: 300px;
    margin-bottom: 1rem;
}

.chart-stats {
    display: flex;
    justify-content: center;
    gap: 4rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.chart-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
}

.chart-stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--blue);
}

.chart-stat-value.orange {
    color: var(--orange);
}

.chart-stat-value.green {
    color: var(--green);
}

.chart-stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--sidebar-bg);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 1400px) {
    .stats-row {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: 1fr;
    }
    
    .header {
        padding: 1rem;
    }
    
    .dashboard-content {
        padding: 1rem;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card {
    animation: fadeIn 0.4s ease;
}

.stat-card:nth-child(1) { animation-delay: 0.1s; }
.stat-card:nth-child(2) { animation-delay: 0.2s; }
.stat-card:nth-child(3) { animation-delay: 0.3s; }
.stat-card:nth-child(4) { animation-delay: 0.4s; }
.stat-card:nth-child(5) { animation-delay: 0.5s; }

/* Transactions Table */
.transactions-table {
    overflow-x: auto;
}

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

.transactions-table thead {
    background: var(--bg-tertiary);
}

.transactions-table th {
    padding: 0.875rem;
    text-align: left;
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

.transactions-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s ease;
}

.transactions-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.transactions-table td {
    padding: 1rem 0.875rem;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-in {
    background: rgba(40, 199, 111, 0.2);
    color: var(--green);
}

.badge-out {
    background: rgba(0, 201, 219, 0.2);
    color: var(--cyan);
}

.badge-check {
    background: rgba(255, 159, 67, 0.2);
    color: var(--orange);
}

.status-badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-complete {
    background: rgba(40, 199, 111, 0.2);
    color: var(--green);
}

.status-progress {
    background: rgba(74, 158, 255, 0.2);
    color: var(--blue);
    animation: pulse-glow 2s infinite;
}
