:root {
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 0px;
    --topbar-height: 60px;
    --primary: #1a237e;
    --primary-dark: #0d1452;
    --primary-light: #534bae;
    --bg-light: #f4f5f7;
    --card-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --card-hover-shadow: 0 4px 16px rgba(0,0,0,0.12);
    --transition-speed: 0.3s;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-light);
    color: #333;
    overflow-x: hidden;
}

#wrapper {
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: transform var(--transition-speed) ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand i { font-size: 1.5rem; }

.sidebar-toggle {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s;
}

.sidebar-toggle:hover { color: #fff; }

.sidebar-divider {
    margin: 8px 16px;
    border-color: rgba(255,255,255,0.1);
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.sidebar-nav .nav-item { margin: 2px 8px; }

.sidebar-nav .nav-link {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.sidebar-nav .nav-link i { width: 20px; text-align: center; font-size: 1rem; }

.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-weight: 600;
}

#page-content-wrapper {
    width: 100%;
    margin-left: var(--sidebar-width);
    transition: margin var(--transition-speed) ease;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    padding: 12px 24px;
    border-bottom: 1px solid #e9ecef;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.avatar-circle-lg {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 2rem;
}

.footer-bar {
    background: #fff;
    padding: 12px 24px;
    border-top: 1px solid #e9ecef;
    margin-top: auto;
}

.stat-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-hover-shadow);
}

.stat-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card {
    border-radius: 12px;
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--card-hover-shadow);
}

.progress-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: conic-gradient(var(--primary) var(--pct, 0%), #e9ecef var(--pct, 0%));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.progress-circle::before {
    content: '';
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: #fff;
}

.progress-circle-text {
    position: relative;
    z-index: 1;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--primary);
}

/* Number grid */
.numbers-grid {
    user-select: none;
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(20, 1fr);
    gap: 3px;
}

.grid-row {
    display: contents;
}

.grid-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    background: #fff;
    color: #333;
    min-width: 0;
    min-height: 0;
}

.grid-cell.available:hover {
    background: #e3f2fd;
    border-color: var(--primary);
    transform: scale(1.05);
    z-index: 1;
    box-shadow: 0 2px 8px rgba(26,35,126,0.2);
}

.grid-cell.selected {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
}

.grid-cell.sold {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
    cursor: not-allowed;
    opacity: 0.85;
}

.grid-cell.reserved {
    background: #ffc107;
    color: #333;
    border-color: #ffc107;
    cursor: not-allowed;
}

.grid-cell.empty {
    visibility: hidden;
}

.selected-number-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary);
    color: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin: 2px;
}

.remove-number {
    cursor: pointer;
    opacity: 0.7;
    font-size: 0.7rem;
}

.remove-number:hover { opacity: 1; }

.selected-numbers-wrap {
    max-height: 200px;
    overflow-y: auto;
}

/* Auth */
.bg-auth {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-wrapper {
    width: 100%;
    padding: 20px;
}

.auth-container {
    max-width: 420px;
    margin: 0 auto;
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.auth-logo {
    width: 80px;
    height: 80px;
    background: rgba(26,35,126,0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.auth-form .form-control {
    border-radius: 8px;
    padding: 12px 16px;
}

.auth-form .input-group-text {
    border-radius: 8px 0 0 8px;
    background: transparent;
}

/* Table fixes */
.table > :not(caption) > * > * {
    vertical-align: middle;
}

.table-light th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #6c757d;
}

/* Pagination */
.page-link {
    border-radius: 8px !important;
    margin: 0 2px;
    color: var(--primary);
    border: none;
    font-size: 0.85rem;
}

.page-item.active .page-link {
    background: var(--primary);
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

    #page-content-wrapper {
        margin-left: 0;
    }
}

@media (max-width: 575.98px) {
    .topbar { padding: 10px 16px; }
    .grid-cell { font-size: 0.6rem; }
    .grid-container { gap: 2px; }
    .auth-container { padding: 24px 20px; }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
}

.sidebar-overlay.show {
    display: block;
}

/* Misc */
.btn { border-radius: 8px; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 0.2rem rgba(26,35,126,0.15);
}

.modal-content {
    border-radius: 12px;
    border: none;
}

.modal-header {
    border-bottom: 1px solid #e9ecef;
}

.badge {
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
}

/* Table sticky header */
.sticky-top {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Public grid */
.public-grid-container .grid-cell {
    font-size: 0.65rem;
}

@media (max-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(10, 1fr);
        gap: 2px;
    }
    .grid-cell { font-size: 0.55rem; }
}

@media (min-width: 769px) and (max-width: 991.98px) {
    .grid-container {
        grid-template-columns: repeat(10, 1fr);
    }
}

@media (min-width: 992px) and (max-width: 1199.98px) {
    .grid-container {
        grid-template-columns: repeat(15, 1fr);
    }
}
