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

:root {
    --primary: #667eea;
    --secondary: #764ba2;
    --success: #51cf66;
    --danger: #ff6b6b;
    --warning: #ffd93d;
    --light: #f8f9fa;
    --dark: #2d3748;
    --gray: #e2e8f0;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-size: 16px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
}

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

/* ========== SIDEBAR ========== */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg, #2d3748 0%, #1a202c 100%);
    color: white;
    padding: 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
    transition: var(--transition);
}

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

.close-sidebar {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo i {
    -webkit-text-fill-color: unset;
    color: var(--primary);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px 16px;
    border-radius: var(--border-radius);
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
    cursor: pointer;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.nav-item i {
    font-size: 18px;
    width: 24px;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    margin-left: 280px;
    background: var(--light);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-header {
    background: white;
    padding: 16px 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 15px;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--dark);
}

.top-header h1 {
    font-size: 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.content-wrapper {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
}

/* ========== TABS ========== */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-content h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--dark);
}

/* ========== STATS ========== */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    padding: 20px 16px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
    border-top: 4px solid var(--gray);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.stat-card-1 { border-top-color: var(--primary); }
.stat-card-2 { border-top-color: var(--warning); }
.stat-card-3 { border-top-color: var(--danger); }
.stat-card-4 { border-top-color: var(--success); }

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    flex-shrink: 0;
}

.stat-card-1 .stat-icon {
    background: linear-gradient(135deg, var(--primary) 0%, #7c8ff0 100%);
}

.stat-card-2 .stat-icon {
    background: linear-gradient(135deg, #ffd93d 0%, #ffed4e 100%);
    color: #333;
}

.stat-card-3 .stat-icon {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8c8c 100%);
}

.stat-card-4 .stat-icon {
    background: linear-gradient(135deg, #51cf66 0%, #69db7c 100%);
}

.stat-label {
    color: #999;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--dark);
}

/* ========== PENDING SECTION ========== */
.pending-section {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.pending-section h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--dark);
}

#pending-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pending-item {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe0e0 100%);
    padding: 16px;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--danger);
    flex-wrap: wrap;
    gap: 12px;
}

.pending-item-info {
    flex: 1;
    min-width: 150px;
}

.pending-item-info p {
    margin: 4px 0;
    color: var(--dark);
    font-size: 13px;
}

.pending-item-info p:first-child {
    font-weight: 700;
    font-size: 15px;
}

.pending-item-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.pending-item-amount {
    font-size: 20px;
    font-weight: 700;
    color: var(--danger);
    min-width: 70px;
    text-align: right;
}

/* ========== FORMS ========== */
.form-section {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
    font-size: 13px;
}

.form-group input,
.form-group textarea {
    padding: 12px;
    border: 2px solid var(--gray);
    border-radius: var(--border-radius);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
    background: #fafafa;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.photo-preview {
    margin-top: 12px;
    display: none;
    max-width: 120px;
    height: 120px;
    background-size: cover;
    background-position: center;
    border-radius: var(--border-radius);
    border: 3px solid var(--primary);
    margin-left: auto;
    margin-right: auto;
}

.photo-preview.show {
    display: block;
}

/* ========== BUTTONS ========== */
.btn {
    padding: 11px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-lg {
    width: 100%;
    padding: 14px 24px;
    font-size: 15px;
}

.btn-success {
    background: linear-gradient(135deg, var(--success) 0%, #69db7c 100%);
    color: white;
    padding: 8px 14px;
    font-size: 12px;
}

.btn-success:active {
    transform: scale(0.98);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger) 0%, #ff8c8c 100%);
    color: white;
    padding: 8px 14px;
    font-size: 12px;
}

.btn-danger:active {
    transform: scale(0.98);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning) 0%, #ffed4e 100%);
    color: #333;
    padding: 8px 14px;
    font-size: 12px;
}

.btn-warning:active {
    transform: scale(0.98);
}

.btn-info {
    background: linear-gradient(135deg, #4ecdc4 0%, #44b8a8 100%);
    color: white;
    padding: 8px 14px;
    font-size: 12px;
}

/* ========== SEARCH ========== */
.search-bar-wrapper {
    margin-bottom: 20px;
}

#search-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray);
    border-radius: var(--border-radius);
    font-size: 14px;
    background: white;
}

#search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

/* ========== STUDENTS GRID ========== */
.students-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.student-card {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: var(--transition);
    cursor: pointer;
}

.student-card:active {
    transform: scale(0.98);
}

.student-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.student-photo {
    width: 100%;
    height: 180px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    object-fit: cover;
}

.student-info {
    padding: 16px;
}

.student-info h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--dark);
}

.student-info p {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.student-info p i {
    color: var(--primary);
    width: 14px;
}

.student-status {
    margin: 12px 0;
    padding: 10px 0;
    border-top: 2px solid var(--gray);
    border-bottom: 2px solid var(--gray);
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
}

.status-paid {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
}

.status-pending {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
}

.student-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-top: 12px;
}

/* ========== MODAL ========== */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 20px 0;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    width: 95%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    position: relative;
    animation: slideUp 0.3s ease-in-out;
    margin: auto;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:active {
    background: #f0f0f0;
}

.detail-photo {
    width: 100%;
    max-height: 250px;
    object-fit: cover;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
}

.detail-info {
    margin-bottom: 16px;
}

.detail-info h2 {
    font-size: 24px;
    margin-bottom: 12px;
}

.detail-info label {
    font-weight: 700;
    color: var(--primary);
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
}

.detail-info p {
    color: var(--dark);
    font-size: 14px;
}

.detail-info ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.detail-info li {
    padding: 6px 0;
    color: var(--dark);
    font-size: 13px;
}

.detail-info li:before {
    content: '✓ ';
    color: var(--success);
    font-weight: 700;
    margin-right: 8px;
}

.detail-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 2px solid var(--gray);
}

.detail-actions .btn {
    padding: 10px 12px;
    font-size: 11px;
}

/* ========== FEE TRACKER ========== */
.fee-tracker {
    margin-top: 16px;
}

.fee-tracker h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--dark);
}

.month-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.month-box {
    padding: 12px 8px;
    border: 2px solid var(--gray);
    border-radius: var(--border-radius);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: white;
    font-size: 12px;
}

.month-box:active {
    transform: scale(0.95);
}

.month-box.paid {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #51cf66;
    color: #155724;
    font-weight: 700;
}

.month-box .month-name {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
}

.month-box .month-year {
    font-size: 10px;
    color: #999;
    margin-top: 3px;
}

.month-box.paid .month-name,
.month-box.paid .month-year {
    color: #155724;
}

.month-status {
    display: none;
    font-size: 18px;
    margin-top: 4px;
}

.month-box.paid .month-status {
    display: block;
}

.add-fee-btn {
    width: 100%;
    margin-top: 12px;
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: 20px;
    padding: 14px 16px;
    border-radius: var(--border-radius);
    background: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 3000;
    animation: slideInRight 0.3s ease-in-out;
    border-left: 4px solid var(--success);
    font-size: 13px;
    word-wrap: break-word;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.show {
    display: block;
}

/* ========== BACKUP SECTION ========== */
.backup-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 24px;
    border-radius: var(--border-radius);
    margin-top: 25px;
    color: white;
}

.backup-section h2 {
    margin-top: 0;
    color: white;
    font-size: 22px;
}

.backup-section p {
    opacity: 0.9;
    margin-bottom: 16px;
    font-size: 13px;
}

.backup-sub {
    background: rgba(255, 255, 255, 0.1);
    padding: 16px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
}

.backup-sub h3 {
    margin-top: 0;
    color: white;
    font-size: 16px;
}

.backup-sub p {
    font-size: 12px;
    margin-bottom: 12px;
}

#telegram-status {
    background: rgba(255, 255, 255, 0.15);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 12px;
}

.backup-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.backup-buttons .btn {
    flex: 1;
    min-width: 120px;
}

/* ========== RESPONSIVE - TABLET ========== */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }

    .main-content {
        margin-left: 240px;
    }

    .content-wrapper {
        padding: 20px;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .students-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* ========== RESPONSIVE - MOBILE ========== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        width: 100%;
        height: 100vh;
        left: -100%;
        transition: var(--transition);
        z-index: 999;
        padding: 16px;
        top: 0;
    }

    .sidebar.show {
        left: 0;
    }

    .close-sidebar {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }

    .hamburger {
        display: block;
    }

    .top-header {
        padding: 14px 16px;
    }

    .top-header h1 {
        font-size: 18px;
    }

    .content-wrapper {
        padding: 16px;
    }

    .tab-content h2 {
        font-size: 22px;
        margin-bottom: 16px;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        margin-bottom: 16px;
    }

    .stat-card {
        padding: 16px 12px;
        gap: 10px;
    }

    .stat-icon {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .stat-label {
        font-size: 10px;
        margin-bottom: 3px;
    }

    .stat-value {
        font-size: 18px;
    }

    .pending-section {
        padding: 16px;
        margin-bottom: 16px;
    }

    .pending-section h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .pending-item {
        padding: 12px;
        gap: 10px;
        flex-direction: column;
        align-items: flex-start;
    }

    .pending-item-info p {
        font-size: 12px;
    }

    .pending-item-right {
        width: 100%;
        justify-content: space-between;
    }

    .pending-item-amount {
        font-size: 18px;
    }

    .form-section {
        padding: 16px;
    }

    .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

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

    .student-card {
        display: flex;
        gap: 12px;
    }

    .student-photo {
        width: 100px;
        height: 100px;
        border-radius: var(--border-radius);
        flex-shrink: 0;
    }

    .student-info {
        padding: 12px;
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }

    .student-info h3 {
        font-size: 15px;
        margin-bottom: 6px;
    }

    .student-info p {
        font-size: 11px;
        margin-bottom: 3px;
    }

    .student-actions {
        grid-template-columns: 1fr 1fr;
        gap: 4px;
        margin-top: 8px;
    }

    .student-actions .btn {
        padding: 6px 10px;
        font-size: 11px;
    }

    #search-input {
        width: 100%;
    }

    .modal-content {
        width: 96%;
        max-width: 100%;
        padding: 20px;
        margin: 10px auto;
    }

    .detail-photo {
        max-height: 200px;
        margin-bottom: 16px;
    }

    .detail-actions {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .detail-actions .btn {
        padding: 10px 12px;
        font-size: 12px;
    }

    .month-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .month-box {
        padding: 10px 6px;
        font-size: 11px;
    }

    .backup-section {
        padding: 16px;
        margin-top: 16px;
    }

    .backup-section h2 {
        font-size: 18px;
    }

    .backup-sub {
        padding: 12px;
        margin-bottom: 12px;
    }

    .backup-sub h3 {
        font-size: 14px;
        margin-bottom: 8px;
    }

    .backup-buttons {
        gap: 6px;
    }

    .backup-buttons .btn {
        min-width: auto;
        padding: 10px 8px;
        font-size: 11px;
    }

    .toast {
        left: 10px;
        right: 10px;
        bottom: 10px;
        font-size: 12px;
    }
}

/* ========== SMALL MOBILE ========== */
@media (max-width: 480px) {
    .top-header {
        padding: 12px 12px;
        gap: 10px;
    }

    .top-header h1 {
        font-size: 16px;
    }

    .content-wrapper {
        padding: 12px;
    }

    .tab-content h2 {
        font-size: 20px;
        margin-bottom: 12px;
    }

    .stats-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 12px;
    }

    .stat-card {
        padding: 12px 10px;
    }

    .stat-icon {
        width: 45px;
        height: 45px;
        font-size: 18px;
    }

    .stat-value {
        font-size: 16px;
    }

    .pending-item {
        padding: 10px;
    }

    .pending-item-info p:first-child {
        font-size: 13px;
    }

    .pending-item-amount {
        font-size: 16px;
    }

    .pending-item .btn {
        padding: 6px 12px;
        font-size: 10px;
    }

    .form-group input,
    .form-group textarea {
        padding: 10px;
        font-size: 13px;
    }

    .btn-lg {
        padding: 12px 20px;
        font-size: 14px;
    }

    .student-card {
        flex-direction: column;
    }

    .student-photo {
        width: 100%;
        height: 150px;
    }

    .month-box {
        padding: 8px 4px;
        font-size: 10px;
    }

    .detail-info h2 {
        font-size: 20px;
        margin-bottom: 10px;
    }

    .detail-actions {
        gap: 4px;
    }

    .detail-actions .btn {
        padding: 8px 10px;
        font-size: 10px;
    }
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light);
}

::-webkit-scrollbar-thumb {
    background: var(--gray);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

/* ========== INPUT FOCUS ========== */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}
