:root {
    --bg-dark: #1e293b;
    --bg-light: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    --accent-yellow: #f59e0b;
    --sidebar-width: 260px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-light);
    height: 100vh;
    display: flex;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-dark);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: all 0.3s;
}

.brand {
    padding: 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 88px;
}

.brand img {
    height: 56px;
    width: auto;
    max-width: 100%;
    display: block;
}

.nav-menu {
    list-style: none;
    padding: 1rem 0;
    margin: 0;
}

.nav-item {
    padding: 0.8rem 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: background 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
    background-color: #334155;
    color: white;
}

.nav-item.active {
    border-left-color: var(--accent-blue);
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    font-size: 0.8rem;
    text-align: center;
    opacity: 0.5;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.topbar {
    background: white;
    padding: 1rem 2rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.balance-badge {
    background: #eff6ff;
    color: var(--accent-blue);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-weight: 600;
    border: 1px solid #dbeafe;
}

.container {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* --- Cards & Stats --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 4px solid transparent;
}

.stat-card.blue { border-left-color: var(--accent-blue); }
.stat-card.green { border-left-color: var(--accent-green); }
.stat-card.yellow { border-left-color: var(--accent-yellow); }
.stat-card.red { border-left-color: var(--accent-red); }

.stat-title {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

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

/* --- Tables --- */
.content-card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: opacity 0.2s;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: white;
}

.btn-success {
    background-color: var(--accent-green);
    color: white;
}

.btn:hover { opacity: 0.9; }

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

th, td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    color: var(--text-primary);
}

tr:last-child td {
    border-bottom: none;
}

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

/* --- Badges --- */
.status-badge {
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-active {
    background-color: #dcfce7;
    color: #166534;
}

.status-blocked {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-warning {
    background-color: #fef3c7;
    color: #b45309;
}

/* --- Animations --- */
@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-in {
    animation: slideInRight 0.4s ease-out forwards;
    opacity: 0; /* Initially hidden */
}

/* Add stagger delay for up to 20 items */
.animate-slide-in:nth-child(1) { animation-delay: 0.05s; }
.animate-slide-in:nth-child(2) { animation-delay: 0.1s; }
.animate-slide-in:nth-child(3) { animation-delay: 0.15s; }
.animate-slide-in:nth-child(4) { animation-delay: 0.2s; }
.animate-slide-in:nth-child(5) { animation-delay: 0.25s; }
.animate-slide-in:nth-child(6) { animation-delay: 0.3s; }
.animate-slide-in:nth-child(7) { animation-delay: 0.35s; }
.animate-slide-in:nth-child(8) { animation-delay: 0.4s; }
.animate-slide-in:nth-child(9) { animation-delay: 0.45s; }
.animate-slide-in:nth-child(10) { animation-delay: 0.5s; }
.animate-slide-in:nth-child(11) { animation-delay: 0.55s; }
.animate-slide-in:nth-child(12) { animation-delay: 0.6s; }
.animate-slide-in:nth-child(13) { animation-delay: 0.65s; }
.animate-slide-in:nth-child(14) { animation-delay: 0.7s; }
.animate-slide-in:nth-child(15) { animation-delay: 0.75s; }

/* --- Skeleton Loading --- */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    display: inline-block;
    color: transparent !important;
}

.skeleton-text {
    height: 1em;
    width: 80%;
}

.skeleton-badge {
    height: 1.5em;
    width: 60px;
    border-radius: 999px;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- Toast Notifications --- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    border-left: 4px solid #3b82f6;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    transform: translateX(100%);
    animation: toastSlideIn 0.3s forwards;
    color: var(--text-primary);
}

.toast.success { border-left-color: var(--accent-green); }
.toast.error { border-left-color: var(--accent-red); }
.toast.info { border-left-color: var(--accent-blue); }

@keyframes toastSlideIn {
    to { transform: translateX(0); }
}

@keyframes toastSlideOut {
    to { transform: translateX(100%); opacity: 0; }
}

/* --- Responsive --- */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0 1rem;
    }
    
    .brand {
        border-bottom: none;
        padding: 1rem 0;
    }

    .brand img {
        height: 40px;
    }
    
    .nav-menu {
        display: flex;
        padding: 0;
    }
    
    .nav-item {
        padding: 1rem;
        border-left: none;
        border-bottom: 3px solid transparent;
    }
    
    .nav-item.active {
        border-left: none;
        border-bottom-color: var(--accent-blue);
    }
    
    .nav-text {
        display: none;
    }
    
    .sidebar-footer {
        display: none;
    }
    
    .topbar {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }
    
    .user-info {
        justify-content: space-between;
    }
    
    .container {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .summary-stack {
        display: flex;
        flex-direction: column;
        gap: 18px;
    }

    .summary-telegram {
        order: -1;
        margin: 0 auto 0 !important;
    }
}

th {
    background: #f8fafc;
    padding: 1rem 1.5rem;
    text-align: left;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 1px solid #e2e8f0;
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    color: var(--text-primary);
    font-size: 0.9rem;
}

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

.status-active { background: #dcfce7; color: #166534; }
.status-blocked { background: #fee2e2; color: #991b1b; }

/* --- Blocked Screen Specifics --- */
.blocked-body {
    background: #fef2f2;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.blocked-card {
    background: white;
    padding: 3rem;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    text-align: center;
    max-width: 500px;
    width: 90%;
    border-top: 6px solid var(--accent-red);
}

.blocked-icon {
    font-size: 4rem;
    color: var(--accent-red);
    margin-bottom: 1rem;
}

.blocked-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #7f1d1d;
    margin-bottom: 1rem;
}

.blocked-message {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.5;
}

.amount-due {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 2rem;
}
