:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #e0e7ff;
    --success: #16a34a;
    --warning: #f59e0b;
    --danger: #dc2626;
    --secondary: #6b7280;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #4f46e5;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --radius: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform .3s ease;
}

.sidebar-brand {
    padding: 20px 24px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand svg { flex-shrink: 0; }

.sidebar-nav { padding: 16px 0; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 24px;
    color: var(--sidebar-text);
    font-size: .9rem;
    transition: all .2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,.05);
    color: #fff;
}

.sidebar-nav a.active {
    background: rgba(79,70,229,.15);
    color: #fff;
    border-left-color: var(--sidebar-active);
}

.sidebar-nav a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: .7;
}

.sidebar-nav a.active svg,
.sidebar-nav a:hover svg { opacity: 1; }

.sidebar-section {
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: 20px 24px 8px;
    color: rgba(255,255,255,.35);
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

.topbar {
    background: var(--card);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.content { padding: 32px; }

/* Cards & Widgets */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
}

.card-body { padding: 24px; }

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.primary { background: var(--primary-light); color: var(--primary); }
.stat-icon.success { background: #dcfce7; color: var(--success); }
.stat-icon.warning { background: #fef3c7; color: var(--warning); }
.stat-icon.danger { background: #fee2e2; color: var(--danger); }

.stat-info h3 {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-info p {
    font-size: .85rem;
    color: var(--text-muted);
}

/* Tables */
.table-responsive { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
    vertical-align: middle;
}

tbody tr:hover { background: #f8fafc; }

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 6px;
    font-size: .88rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f8fafc; }

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: .88rem;
    font-weight: 500;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .9rem;
    background: #fff;
    color: var(--text);
    transition: border-color .2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* Alerts */
.alert {
    padding: 14px 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg { margin-bottom: 16px; opacity: .4; }
.empty-state p { font-size: .95rem; }

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: var(--card);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    width: 100%;
    max-width: 420px;
}

.login-card h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.login-card p {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 32px;
    font-size: .9rem;
}

.login-card .btn { width: 100%; justify-content: center; padding: 12px; }

/* Hamburger */
.hamburger {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--text);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 90;
}

/* Checkout Page (client side) */
.checkout-page {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.checkout-card {
    background: var(--card);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 500px;
    overflow: hidden;
}

.checkout-header {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    padding: 32px;
    color: #fff;
    text-align: center;
}

.checkout-header h1 { font-size: 1.3rem; margin-bottom: 4px; }
.checkout-header p { opacity: .85; font-size: .9rem; }

.checkout-body { padding: 32px; }

.checkout-detail {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
}

.checkout-detail:last-of-type { border-bottom: none; }
.checkout-detail .label { color: var(--text-muted); }
.checkout-detail .value { font-weight: 600; }

.checkout-total {
    margin-top: 20px;
    padding: 16px;
    background: #f8fafc;
    border-radius: var(--radius);
    text-align: center;
}

.checkout-total .amount {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.checkout-total .label {
    font-size: .85rem;
    color: var(--text-muted);
}

.checkout-actions {
    padding: 0 32px 32px;
    text-align: center;
}

.checkout-actions .btn { width: 100%; justify-content: center; padding: 14px; font-size: 1rem; }

.status-paid {
    text-align: center;
    padding: 40px;
}

.status-paid svg { color: var(--success); margin-bottom: 16px; }
.status-paid h2 { color: var(--success); margin-bottom: 8px; }

/* Pagination */
.pagination {
    display: flex;
    gap: 4px;
    justify-content: center;
    padding: 20px 0;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: 6px;
    font-size: .85rem;
    border: 1px solid var(--border);
    color: var(--text);
}

.pagination a:hover { background: #f1f5f9; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .hamburger { display: block; }
    .content { padding: 20px 16px; }
    .topbar { padding: 12px 16px; }
    .topbar h1 { font-size: 1.1rem; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-info h3 { font-size: 1.2rem; }
    .form-row { grid-template-columns: 1fr; }
    .card-body { padding: 16px; }
    .login-card { padding: 28px 24px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
}
