:root {
    /* Shrift base.html'da <link> orqali yuklanadi. Yuklanmasa ham
       tizim shriftiga tabiiy tushadi — dizayn buzilmaydi. */
    --font-sans: 'Outfit', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --card-bg: rgba(30, 41, 59, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    --color-green-bg: rgba(16, 185, 129, 0.15);
    --color-green-text: #10b981;
    --color-green-border: rgba(16, 185, 129, 0.3);
    
    --color-yellow-bg: rgba(245, 158, 11, 0.15);
    --color-yellow-text: #f59e0b;
    --color-yellow-border: rgba(245, 158, 11, 0.3);
    
    --color-red-bg: rgba(239, 68, 68, 0.15);
    --color-red-text: #ef4444;
    --color-red-border: rgba(239, 68, 68, 0.3);
    
    --glow-green: 0 0 20px rgba(16, 185, 129, 0.2);
    --glow-yellow: 0 0 20px rgba(245, 158, 11, 0.2);
    --glow-red: 0 0 20px rgba(239, 68, 68, 0.2);
    
    --primary-btn: linear-gradient(90deg, #6366f1 0%, #4f46e5 100%);
    --primary-btn-hover: linear-gradient(90deg, #4f46e5 0%, #4338ca 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    padding: 1.5rem 1rem 3rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
}

/* Header Section */
header {
    margin-bottom: 1.5rem;
}

h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.2rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Controls Grid */
.controls-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1.5rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.date-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.date-label {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.date-input {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.date-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.btn-telegram {
    background: var(--primary-btn);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}

.btn-telegram:hover {
    background: var(--primary-btn-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-telegram:active {
    transform: translateY(0);
}

/* Ranking Table Section */
.table-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}

.table-responsive {
    width: 100%;
    /* Sticky sarlavha shu konteynerga nisbatan ishlaydi. max-height faqat
       ro'yxat uzun bo'lganda ta'sir qiladi. */
    max-height: 75vh;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background: rgba(15, 23, 42, 0.55);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--card-border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.95rem;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
}

/* Markazlangan raqam ustunlari — shablonlardagi takroriy inline style o'rniga */
th.num, td.num { text-align: center; }

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Badges and Badges status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.7rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Dynamic status styles */
.status-green {
    background-color: var(--color-green-bg);
    color: var(--color-green-text);
    border: 1px solid var(--color-green-border);
    box-shadow: var(--glow-green);
}

.status-yellow {
    background-color: var(--color-yellow-bg);
    color: var(--color-yellow-text);
    border: 1px solid var(--color-yellow-border);
    box-shadow: var(--glow-yellow);
}

.status-red {
    background-color: var(--color-red-bg);
    color: var(--color-red-text);
    border: 1px solid var(--color-red-border);
    box-shadow: var(--glow-red);
}

/* Table score columns styling */
.index-cell {
    font-weight: 500;
    color: var(--text-secondary);
    width: 48px;
    font-size: 0.85rem;
}

.name-cell {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
}

.score-badge {
    display: inline-block;
    min-width: 1.9rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    padding: 0.15rem 0.45rem;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
}

.percentage-text {
    font-weight: 600;
    font-size: 0.95rem;
}

.percentage-text.high {
    color: var(--color-green-text);
}
.percentage-text.medium {
    color: var(--color-yellow-text);
}
.percentage-text.low {
    color: var(--color-red-text);
}

/* Feedback messages style */
.messages-container {
    margin-bottom: 1.5rem;
}

.message {
    padding: 1rem 1.5rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.message.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--color-green-text);
    border: 1px solid var(--color-green-border);
}

.message.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--color-red-text);
    border: 1px solid var(--color-red-border);
}

/* Empty State */
.empty-state {
    padding: 4rem 2rem;
    text-align: center;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    body {
        padding: 1rem 0.5rem 2rem;
    }

    .controls-card {
        flex-direction: column;
        align-items: stretch;
    }

    .date-picker-wrapper {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-telegram {
        justify-content: center;
    }

    h1 {
        font-size: 1.4rem;
    }

    /* Telefonda jadval zichroq — 10 ustun uchun scroll baribir kerak,
       lekin ism ustuni chapda yopishib turadi, kim kimligi yo'qolmaydi */
    th, td {
        padding: 0.6rem 0.7rem;
        font-size: 0.9rem;
    }

    .index-cell { display: none; }

    .name-cell {
        position: sticky;
        left: 0;
        z-index: 1;
        background: #17203a;
    }

    .main-nav {
        padding: 0.75rem 1rem;
    }
    .nav-menu-panel {
        right: auto;
        left: 0;
    }
}

/* Clickable Student Link */
.student-name-link {
    color: var(--text-primary);
    text-decoration: none;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    transition: color 0.2s, border-color 0.2s;
    cursor: pointer;
}
.student-name-link:hover {
    color: #818cf8;
    border-bottom-color: #818cf8;
}

/* Modal styling */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.modal.show {
    display: flex;
    opacity: 1;
}
.modal-content {
    background: #1e1b4b;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 2rem;
    width: 90%;
    max-width: 650px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}
.modal.show .modal-content {
    transform: scale(1);
}
.close-modal {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    color: var(--text-secondary);
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}
.close-modal:hover {
    color: var(--text-primary);
}
.modal-title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 0.5rem;
}


/* ── Navigatsiya ── */
.main-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    /* backdrop-filter stacking context yaratadi — shuning uchun ochiluvchi
       menyuning z-index'i o'z-o'zidan yetmaydi, NAVNING O'ZI ko'tarilishi
       kerak, aks holda keyingi kartalar ustiga chiziladi. */
    position: relative;
    z-index: 100;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 0.85rem 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
}
.nav-brand {
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.nav-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.15rem;
}

/* ── Ochiluvchi "Ma'lumotlar" menyusi (JS'siz, <details>) ── */
.nav-menu {
    position: relative;
}
.nav-menu > summary {
    list-style: none;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
    user-select: none;
}
.nav-menu > summary::-webkit-details-marker { display: none; }
.nav-menu > summary::after {
    content: ' ▾';
    font-size: 0.75em;
    opacity: 0.7;
}
.nav-menu > summary:hover,
.nav-menu[open] > summary {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}
.nav-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 0.5rem);
    z-index: 50;
    min-width: 190px;
    display: flex;
    flex-direction: column;
    padding: 0.35rem;
    background: #1a2440;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.nav-menu-panel a {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    white-space: nowrap;
}
.nav-menu-sep {
    margin-top: 0.35rem;
    padding-top: 0.6rem !important;
    border-top: 1px solid var(--card-border);
    border-radius: 0 0 8px 8px !important;
}
.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    transition: color 0.2s, background 0.2s;
}
.nav-links a:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

/* ── Jadval amallari ── */
.row-action {
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.3rem 0.7rem;
    border-radius: 6px;
    border: 1px solid var(--card-border);
    transition: background 0.2s, color 0.2s;
}
.row-action.edit { color: #818cf8; }
.row-action.edit:hover { background: rgba(129, 140, 248, 0.12); }
.row-action.delete { color: var(--color-red-text); margin-left: 0.4rem; }
.row-action.delete:hover { background: var(--color-red-bg); }

/* ── CRUD forma ── */
.crud-form p { margin-bottom: 1.1rem; }
.crud-form label {
    display: block;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    margin-bottom: 0.4rem;
}
.crud-form input,
.crud-form select,
.crud-form textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.crud-form input:focus,
.crud-form select:focus,
.crud-form textarea:focus {
    border-color: #6366f1;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}
.crud-form input[type="checkbox"] { width: auto; }
.crud-form .helptext {
    display: block;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-top: 0.3rem;
    opacity: 0.7;
}
.crud-form ul.errorlist {
    list-style: none;
    color: var(--color-red-text);
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

/* ── Sahifalash ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--card-border);
}
.pagination a {
    color: #818cf8;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    transition: background 0.2s;
}
.pagination a:hover { background: rgba(129, 140, 248, 0.12); }
.pagination .disabled {
    color: var(--text-secondary);
    opacity: 0.35;
    font-size: 0.9rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid transparent;
}
.pagination .page-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ── Login sahifasi ── */
.login-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 65vh;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg, rgba(255, 255, 255, 0.03));
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 2.25rem 2rem;
}
.login-title {
    font-size: 1.6rem;
    margin: 0 0 0.35rem;
    text-align: center;
}
.login-sub {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: center;
    margin: 0 0 1.75rem;
}

/* ── Navdagi chiqish tugmasi ── */
.nav-logout {
    display: inline;
    margin-left: 0.35rem;
}
.nav-logout button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    padding: 0.45rem 0.8rem;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.2s, background 0.2s;
}
.nav-logout button:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

/* ── Dashboard (moliya) ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 1.1rem 1.25rem;
}
.stat-label {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
}
.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}
.stat-value.green { color: var(--color-green-text); }
.stat-value.yellow { color: var(--color-yellow-text); }
.stat-value.red { color: var(--color-red-text); }
.stat-value .cur {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    letter-spacing: 0;
}
.stat-footer {
    margin-top: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.9rem;
    color: var(--text-primary);
}
.amount-cell { font-variant-numeric: tabular-nums; }
td.money {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
td.money.green { color: var(--color-green-text); }
td.money.red { color: var(--color-red-text); }

/* ── Ro'yxat sahifasi asboblari (qidiruv + qo'shish) ── */
.list-tools {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.search-form {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.search-form input[type="search"] {
    min-width: 190px;
}

/* ── Kunlik kirish izohi ── */
.entry-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid var(--card-border);
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.entry-hint strong { color: var(--text-primary); font-weight: 500; }

/* ── Ma'lumot yo'q holati ── */
.status-none {
    background-color: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--card-border);
}
.no-data {
    color: var(--text-secondary);
    opacity: 0.4;
}
