/* ========================================
   MyAdmin - Light/Dark Theme
   ======================================== */

:root {
    /* Brand colours taken from the official O'zLiDeP logo */
    --navy: #253a60;
    --teal: #08678e;
    --cyan: #38a7cf;
    --ink: #0b1626;

    --bg: #f2f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #253a60;
    --bg-sidebar-hover: #32507f;
    --bg-input: #ffffff;
    --text: #1b2738;
    --text-muted: #62728a;
    --text-sidebar: #c3d0e2;
    --text-sidebar-active: #ffffff;
    --border: #d9e1ec;
    --primary: #08678e;
    --primary-hover: #075371;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.1);
    --radius: 8px;
}

[data-theme="dark"] {
    --bg: #0b1626;
    --bg-card: #142440;
    --bg-sidebar: #0b1626;
    --bg-sidebar-hover: #1d3157;
    --bg-input: #1b2c4a;
    --text: #e8eef6;
    --text-muted: #93a5bd;
    --border: #24385a;
    --primary: #38a7cf;
    --primary-hover: #63bcdd;
    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }

/* Menyu ikki qismga bo'lingan: tepasi joyida qoladi, faqat ro'yxat suriladi.
   Ilgari butun panel surilardi va logotip bilan yig'ish tugmasi ekrandan
   chiqib ketardi — 39 elementli menyuda bu tez-tez uchraydi. */
.sidebar {
    width: 256px;
    background: var(--bg-sidebar);
    padding: 1.25rem 0 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .2s, width .2s;

    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-top {
    flex: none;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0 1rem 1rem 1.25rem;
}

.sidebar nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 1.25rem;

    /* macOS da qoplama chizig'i faqat surish paytida ko'rinadi, ya'ni pastda
       yana narsa borligi bilinmaydi. `::-webkit-scrollbar` uni doimiy qiladi.
       `scrollbar-width`/`scrollbar-color` ATAYLAB qo'yilmagan: ulardan biri
       bo'lsa ham Chrome webkit qoidalarini butunlay e'tiborsiz qoldiradi va
       chiziq yana qoplama bo'lib qolardi. Firefox standart chizig'ini
       ko'rsatadi — u yerda u allaqachon doimiy. */
}

.sidebar nav::-webkit-scrollbar { width: 8px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar nav::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, .18);
    border: 2px solid transparent;
    background-clip: content-box;
    border-radius: 999px;
}
.sidebar nav::-webkit-scrollbar-thumb:hover { background-color: rgba(255, 255, 255, .34); }

/* Pastki qism: bot, profil, chiqish. Ro'yxat surilsa ham joyida qoladi. */
.sidebar-foot {
    flex: none;
    padding: .5rem 0 .75rem;
    border-top: 1px solid rgba(255, 255, 255, .12);
}

/* Menyu bo'yicha qidiruv (nav-search.js). Tepada, ro'yxat surilganda ham
   joyida qoladi. */
.sidebar-search {
    flex: none;
    position: relative;
    display: flex;
    align-items: center;
    margin: 0 1rem .5rem;
    color: var(--text-sidebar);
}

.sidebar-search svg {
    position: absolute;
    left: .6rem;
    pointer-events: none;
    opacity: .7;
}

.sidebar-search input {
    width: 100%;
    padding: .45rem 1.9rem .45rem 2rem;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 6px;
    background: rgba(255, 255, 255, .07);
    color: var(--text-sidebar-active);
    font: inherit;
    font-size: .82rem;
    outline: none;
    transition: border-color .15s, background .15s;
}

.sidebar-search input::placeholder { color: var(--text-sidebar); opacity: .7; }

.sidebar-search input:focus {
    border-color: var(--cyan);
    background: rgba(255, 255, 255, .11);
}

/* Brauzerning o'z «×» tugmasi qorong'i fonda ko'rinmaydi — Esc tozalaydi. */
.sidebar-search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.sidebar-search-key {
    position: absolute;
    right: .5rem;
    padding: 0 .35rem;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 4px;
    font-family: inherit;
    font-size: .68rem;
    font-weight: 600;
    line-height: 1.3;
    opacity: .7;
    pointer-events: none;
}

.sidebar-search input:focus ~ .sidebar-search-key,
.sidebar-search.has-query .sidebar-search-key { display: none; }

.sidebar-search-empty {
    padding: .75rem 1.25rem;
    font-size: .8rem;
    color: var(--text-sidebar);
    opacity: .75;
}

/* `hidden` atributi `.sidebar-nav` / `.sidebar-section` dagi display'dan
   ustun tursin — filtr aynan shu atribut bilan yashiradi. */
.sidebar nav [hidden] { display: none !important; }

.sidebar-top .sidebar-brand { flex: 1; min-width: 0; padding: 0; }
.sidebar-brand span { white-space: nowrap; overflow: hidden; }

/* Menyuni yig'ish tugmasi. Tor ekranda ko'rinmaydi: u yerda menyu butunlay
   yopiladi va buni yuqoridagi gamburger tugmasi qiladi. */
.sidebar-toggle {
    flex: none;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 8px;
    background: transparent;
    color: var(--text-sidebar);
    cursor: pointer;
    transition: background .15s, color .15s;
}

.sidebar-toggle:hover { background: var(--bg-sidebar-hover); color: #fff; }
.sidebar-toggle svg { transition: transform .2s; }

.sidebar-brand {
    padding: 0 1.25rem 1.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .6rem;
}

.sidebar-brand img { height: 30px; width: auto; flex-shrink: 0; }
.sidebar-brand b { font-weight: 700; color: var(--cyan); }

.sidebar-nav { list-style: none; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .48rem 1.25rem;
    color: var(--text-sidebar);
    font-size: .875rem;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--bg-sidebar-hover);
    color: var(--text-sidebar-active);
    border-left-color: var(--primary);
}

/* Yon menyudagi son (o'qilmagan xabar, do'stlik so'rovi). Chat sahifasidan
   tashqarida ham ko'rinadi, shuning uchun chat.css da emas, shu yerda. */
.nav-badge {
    margin-left: auto;
    min-width: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--cyan);
    color: #08243a;
    font-size: .68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

.nav-badge.is-hidden { display: none; }

/* Yorliq o'z elementida — menyu yig'ilganda uni yashirish uchun va uzun nom
   sonni siqib chiqarmasligi uchun. */
.nav-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hali yozilmagan modul. O'chirilgan emas — bosilsa reja sahifasi ochiladi,
   shuning uchun xira, lekin bosiladigan ko'rinishda. */
.sidebar-nav a.is-planned { opacity: .62; }
.sidebar-nav a.is-planned:hover { opacity: 1; }

.nav-soon {
    flex: none;
    padding: 0 .4rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .22);
    font-size: .6rem;
    font-weight: 600;
    line-height: 15px;
    letter-spacing: .02em;
    text-transform: lowercase;
    white-space: nowrap;
}

/* Rejadagi bo'lim sarlavhasi ham xira bo'lsin — bo'lim butunlay
   yozilmaganini bir qarashda ko'rsatadi. */
/* «Jarayonda» sahifasi — ekranning qoq o'rtasida (eni ham, bo'yi ham).
   8rem ≈ main-content padding'i + topbar balandligi va uning pastki chekkasi. */
.roadmap-stage {
    min-height: calc(100vh - 8rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

.roadmap-card {
    width: 100%;
    max-width: 720px;
    text-align: center;
}

.roadmap-note {
    padding: .75rem .9rem;
    border-top: 3px solid var(--primary);
    background: var(--bg);
    border-radius: 0 0 6px 6px;
}

/* Bo'lim sarlavhasi surilganda tepada yopishib turadi — 39 elementli
   ro'yxatda qaysi bo'limda ekaningiz ko'rinib tursin. */
.sidebar-section {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--bg-sidebar);
    padding: .8rem 1.25rem .3rem;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
}

.main-content {
    flex: 1;
    margin-left: 256px;
    padding: 1.5rem 2rem;
    min-width: 0;
    transition: margin-left .2s;
}

/* ---- Yig'ilgan yon menyu ----
   Faqat katta ekranda: 768px dan pastda menyu butunlay yopiladi va bu
   qoidalar unga xalaqit berardi. Holat `<html data-sidebar="collapsed">` da,
   uni `<head>` dagi kichik skript localStorage'dan tiklaydi. */
@media (min-width: 769px) {
    [data-sidebar="collapsed"] .sidebar { width: 68px; }
    [data-sidebar="collapsed"] .main-content { margin-left: 68px; }
    [data-sidebar="collapsed"] .sidebar-toggle svg { transform: rotate(180deg); }

    [data-sidebar="collapsed"] .sidebar-top {
        flex-direction: column;
        gap: .75rem;
        padding: 0 0 1rem;
    }

    [data-sidebar="collapsed"] .sidebar-brand { justify-content: center; }
    [data-sidebar="collapsed"] .sidebar-brand span { display: none; }

    /* Qidiruvdan faqat belgi qoladi; bosilsa menyu ochilib, maydonga o'tadi. */
    [data-sidebar="collapsed"] .sidebar-search {
        justify-content: center;
        margin: 0 0 .5rem;
        padding: .45rem 0;
        cursor: pointer;
    }
    [data-sidebar="collapsed"] .sidebar-search:hover { color: #fff; }
    [data-sidebar="collapsed"] .sidebar-search svg { position: static; opacity: 1; }
    [data-sidebar="collapsed"] .sidebar-search input,
    [data-sidebar="collapsed"] .sidebar-search-key { display: none; }

    /* Yorliqlar yashiriladi, belgilar qoladi. Matn tugunlarini <span> ga
       o'rash o'rniga shrift nolga tushiriladi — svg o'lchami atributdan
       keladi, shuning uchun belgi o'z holicha qolaveradi. */
    [data-sidebar="collapsed"] .sidebar-nav a {
        font-size: 0;
        justify-content: center;
        padding: .65rem 0;
    }

    /* Yorliq va «jarayonda» belgisi butunlay chiqib ketadi: `font-size: 0`
       joyni saqlab qolardi va belgi markazdan siljib turardi. */
    [data-sidebar="collapsed"] .nav-label,
    [data-sidebar="collapsed"] .nav-soon { display: none; }

    /* Bo'lim sarlavhasi o'rnida ingichka ajratgich. */
    [data-sidebar="collapsed"] .sidebar-section {
        font-size: 0;
        padding: .6rem 1.1rem .5rem;
    }

    [data-sidebar="collapsed"] .sidebar-section::after {
        content: "";
        display: block;
        height: 1px;
        background: rgba(255, 255, 255, .12);
    }

    /* Son belgi o'rniga belgining burchagiga o'tadi. */
    [data-sidebar="collapsed"] .sidebar-nav li { position: relative; }

    [data-sidebar="collapsed"] .nav-badge {
        position: absolute;
        top: 3px;
        right: 10px;
        margin: 0;
        min-width: 16px;
        font-size: .6rem;
        line-height: 16px;
    }
}

/* ---- Top Bar ---- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.topbar h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

/* ---- Theme Toggle ---- */
.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    font-size: 1.1rem;
    transition: background .15s;
    box-shadow: var(--shadow);
}
.theme-toggle:hover { background: var(--border); }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-body { padding: 1.25rem; }

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-icon.blue { background: #d9ecf5; color: #08678e; }
.stat-icon.green { background: #d1fae5; color: #059669; }
.stat-icon.amber { background: #fef3c7; color: #d97706; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }

[data-theme="dark"] .stat-icon.blue { background: #10344b; color: #7fc7e4; }
[data-theme="dark"] .stat-icon.green { background: #064e3b; }
[data-theme="dark"] .stat-icon.amber { background: #451a03; }
[data-theme="dark"] .stat-icon.purple { background: #2e1065; }

.stat-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-info p {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ---- Grid ---- */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .main-content { padding: 1rem; }

    /* Topbar stacks */
    .topbar { flex-wrap: wrap; gap: .5rem; }
    .topbar h1 { font-size: 1.15rem; }

    /* Search bar full width */
    .search-bar .form-input,
    .search-bar select.form-input { max-width: 100%; flex: 1 1 100%; }

    /* Table min-width for scroll */
    table { min-width: 600px; }

    /* Auth page less padding */
    .auth-page { padding: 1rem; }
    .auth-card .card-body { padding: 1.25rem; }
    .auth-header h1 { font-size: 1.25rem; }

    /* Pagination wrap */
    .pagination { flex-wrap: wrap; }
}

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

th {
    text-align: left;
    padding: .75rem 1rem;
    font-weight: 600;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

td {
    padding: .65rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover td { background: var(--bg); }
[data-theme="dark"] tr:hover td { background: #0f1e33; }

/* Tartib raqami ustuni. Sahifalangan ro'yxatlarda raqam sahifadan sahifaga
   davom etadi (`page.start_index`), shuning uchun u qatorning o'rnini emas,
   butun ro'yxatdagi o'rnini ko'rsatadi. Ustun tor va so'nik: u ma'lumot
   emas, mo'ljal. */
th.num, td.num {
    width: 1px;
    padding-right: .35rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 50px;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.5;
}

.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #d9ecf5; color: #075371; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-amber { background: #fef3c7; color: #92400e; }

[data-theme="dark"] .badge-green { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-red { background: #450a0a; color: #fca5a5; }
[data-theme="dark"] .badge-blue { background: #10344b; color: #7fc7e4; }
[data-theme="dark"] .badge-gray { background: #334155; color: #94a3b8; }
[data-theme="dark"] .badge-amber { background: #4a3208; color: #fcd34d; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1.1rem;
    border-radius: 8px;
    font-size: .8125rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, box-shadow .15s;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: .3rem .65rem; font-size: .75rem; }

/* ---- Language switcher (uz / uz-cyrl / ru) ---- */
.lang-switcher {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.lang-btn {
    padding: .25rem .6rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted, var(--text));
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.lang-btn:hover { background: var(--bg); color: var(--text); }

.lang-btn.is-active {
    background: var(--primary);
    color: #fff;
    cursor: default;
}

/* ---- Preferences cluster: language + theme in one pill ---- */
.prefs {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 36px;
    padding: 3px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

.prefs-sep { width: 1px; align-self: stretch; margin: 4px 3px; background: var(--border); }

.prefs .lang-switcher { border: 0; padding: 0; }
.prefs .lang-btn { display: inline-flex; align-items: center; height: 28px; }

.prefs .theme-toggle {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    box-shadow: none;
    font-size: .95rem;
    color: var(--text-muted, var(--text));
}
.prefs .theme-toggle:hover { background: var(--bg); color: var(--text); }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }

.form-label {
    display: block;
    font-size: .8125rem;
    font-weight: 500;
    margin-bottom: .35rem;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: .875rem;
    background: var(--bg-input);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.form-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .875rem;
}

/* ---- Segment almashtirgich ----
   Ilgari faqat tasks.css da edi; endi boshqaruv panelidagi xarita ham
   (viloyat / tuman) shuni ishlatadi, shuning uchun umumiy uslubga ko'chdi. */
.tk-seg {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 3px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.tk-seg-opt {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .7rem;
    border-radius: 7px;
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    transition: background .15s, color .15s;
}

.tk-seg-opt:hover { background: var(--card, #fff); color: var(--text); }

.tk-seg-opt.is-active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}

.tk-seg-badge {
    padding: 0 .35rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, .25);
    font-size: .7rem;
    font-weight: 600;
}
.tk-seg-opt:not(.is-active) .tk-seg-badge { background: var(--border); }

/* ---- Hududlar xaritasi ----
   Konturlar `regions/mapdata.py` da; viloyatlar bir-biriga tegmaydi, orasidagi
   bo'shliq ataylab — shakl aniq chegaraga da'vo qilmaydi. */
.uzmap-wrap {
    /* Tor ekranda xarita siqilib ketmasin — o'z ichida suriladi. */
    position: relative;
    overflow-x: auto;
    padding-bottom: .25rem;
}

.uzmap-bar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .75rem;
}

.uzmap-zoom { display: flex; gap: .3rem; }
.uzmap-zoom .btn { min-width: 34px; }

.uzmap {
    display: block;
    width: 100%;
    min-width: 620px;
    /* Balandlik cheklanadi — aks holda xarita butun ekranni egallaydi. */
    max-height: 420px;
    height: auto;
    touch-action: none;
}

.uzmap.is-zoomed { cursor: grab; }
.uzmap.is-dragging { cursor: grabbing; }

.uzmap-region path {
    stroke: var(--bg-card);
    stroke-width: 2;
    stroke-linejoin: round;
    transition: filter .12s;
}

.uzmap-region { cursor: pointer; }

.uzmap-region:hover path {
    filter: brightness(1.12);
    stroke: var(--text);
}

/* Yorliqlar bosishni to'smasin — bosish path ga tushsin. */
.uzmap-name,
.uzmap-count {
    pointer-events: none;
    text-anchor: middle;
    font-weight: 600;
}

.uzmap-count { font-size: 20px; font-weight: 700; }
/* Tuman ko'rinishida ~198 ta kontur — shrift kichikroq bo'lmasa sonlar
   bir-birining ustiga chiqib ketadi. */
.uzmap.is-district .uzmap-count { font-size: 11px; }

/* Konturga sig'magan son — yaqinlashtirilgandagina ko'rinadi. Shakl o'sadi,
   son esa `viewBox` bilan masshtablanmaydi, ya'ni o'shanda joy paydo bo'ladi. */
.uzmap-count.is-tiny { display: none; }
.uzmap.is-zoomed .uzmap-count.is-tiny { display: block; }
.uzmap.is-district .uzmap-region path { stroke-width: 1; }

/* Legenda: nomlar shu yerda, xaritada esa faqat son. */
.uzmap-legend {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: .15rem .8rem;
    margin-top: 1rem;
}

.uzmap-legend-item {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .2rem .25rem;
    border-radius: 5px;
    font-size: .8rem;
    color: var(--text);
    text-decoration: none;
}

.uzmap-legend-item:hover { background: var(--bg); }

.uzmap-swatch {
    flex: none;
    width: 11px;
    height: 11px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, .12);
}

.uzmap-legend-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uzmap-legend-count { font-weight: 600; }

/* Manba yozuvi — ODbL talabi. Xaritaning o'ng pastki burchagida, eng kichik
   ko'rinishda: odatdagi veb-xaritalardagidek, ko'zga tashlanmaydi. */
.uzmap-credit {
    position: absolute;
    right: .35rem;
    bottom: .1rem;
    font-size: .6rem;
    line-height: 1;
    color: var(--text-muted);
    opacity: .55;
    pointer-events: none;
}

/* Zichlik pog'onalari — brend ko'k rangining to'qlashib boruvchi qatori;
   `choropleth.level_for()` eng katta qiymatga nisbatan hisoblaydi. Matn rangi
   fon to'qlashgani sari oqarib boradi, aks holda o'qib bo'lmay qoladi. */
.uzmap-region.is-l0 path, .uzmap-swatch.is-l0 { fill: #e8edf3; background: #e8edf3; }
.uzmap-region.is-l1 path, .uzmap-swatch.is-l1 { fill: #cfe4f0; background: #cfe4f0; }
.uzmap-region.is-l2 path, .uzmap-swatch.is-l2 { fill: #94c6de; background: #94c6de; }
.uzmap-region.is-l3 path, .uzmap-swatch.is-l3 { fill: #4f9ec4; background: #4f9ec4; }
.uzmap-region.is-l4 path, .uzmap-swatch.is-l4 { fill: #08678e; background: #08678e; }

.uzmap-region.is-l0 text,
.uzmap-region.is-l1 text,
.uzmap-region.is-l2 text { fill: #12304a; }
.uzmap-region.is-l3 text,
.uzmap-region.is-l4 text { fill: #ffffff; }

[data-theme="dark"] .uzmap-region.is-l0 path,
[data-theme="dark"] .uzmap-swatch.is-l0 { fill: #1b2c46; background: #1b2c46; }
[data-theme="dark"] .uzmap-region.is-l1 path,
[data-theme="dark"] .uzmap-swatch.is-l1 { fill: #123b55; background: #123b55; }
[data-theme="dark"] .uzmap-region.is-l2 path,
[data-theme="dark"] .uzmap-swatch.is-l2 { fill: #17607f; background: #17607f; }
[data-theme="dark"] .uzmap-region.is-l3 path,
[data-theme="dark"] .uzmap-swatch.is-l3 { fill: #2489b6; background: #2489b6; }
[data-theme="dark"] .uzmap-region.is-l4 path,
[data-theme="dark"] .uzmap-swatch.is-l4 { fill: #4fb4d8; background: #4fb4d8; }

[data-theme="dark"] .uzmap-region.is-l0 text,
[data-theme="dark"] .uzmap-region.is-l1 text,
[data-theme="dark"] .uzmap-region.is-l2 text { fill: #dceaf5; }
[data-theme="dark"] .uzmap-region.is-l3 text,
[data-theme="dark"] .uzmap-region.is-l4 text { fill: #05202f; }

.tile-extra {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .4rem;
    margin-top: .8rem;
}

.tile-extra .badge { text-decoration: none; }

/* ---- Rol guruhlari ----
   Rollar ikki guruhga bo'linadi: kirish rollari (ruxsat beradi) va bo'limlar
   (tavsifiy). 16 ta checkbox aralash turganda birini ikkinchisidan ajratib
   bo'lmasdi. */
.role-groups {
    display: flex;
    flex-direction: column;
    gap: .85rem;
}

.role-group-title {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: .4rem;
}

.role-group-items {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1rem;
}

.form-check input[type="checkbox"] {
    width: 16px; height: 16px;
    accent-color: var(--primary);
}

select.form-input {
    appearance: auto;
}

.input-password-wrap {
    position: relative;
}

.input-password-wrap .form-input {
    padding-right: 2.5rem;
}

.password-toggle {
    position: absolute;
    right: .5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: .25rem;
    display: flex;
    align-items: center;
}

.password-toggle:hover {
    color: var(--text);
}

/* ---- Messages ---- */
.messages { list-style: none; margin-bottom: 1rem; }
.messages li {
    padding: .75rem 1rem;
    border-radius: 6px;
    font-size: .875rem;
    margin-bottom: .5rem;
}
.messages .success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.messages .error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.messages .info { background: #d9ecf5; color: #075371; border: 1px solid #b3d9ea; }
.messages .warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

[data-theme="dark"] .messages .success { background: #064e3b; color: #6ee7b7; border-color: #065f46; }
[data-theme="dark"] .messages .error { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .messages .info { background: #10344b; color: #7fc7e4; border-color: #1a5675; }
[data-theme="dark"] .messages .warning { background: #451a03; color: #fcd34d; border-color: #92400e; }

/* ---- Auth Pages (login, register, profile) ---- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg);
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.auth-card .card-body { padding: 2rem; }

.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: .25rem;
}

.auth-header p {
    color: var(--text-muted);
    font-size: .875rem;
}

.auth-logo {
    display: block;
    height: 52px;
    width: auto;
    margin: 0 auto 1rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.25rem;
    font-size: .8125rem;
    color: var(--text-muted);
}

.auth-footer a { font-weight: 500; }

.auth-theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    gap: .25rem;
    list-style: none;
    margin-top: 1rem;
    align-items: center;
}

.pagination a,
.pagination span {
    padding: .4rem .7rem;
    border-radius: 6px;
    font-size: .8125rem;
    border: 1px solid var(--border);
    color: var(--text);
}

.pagination a:hover { background: var(--bg); }
.pagination .current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ---- Utility ---- */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .8125rem; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }

/* ---- Avatar ---- */
.avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .75rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    flex-shrink: 0;
}

/* ---- Section titles inside tables ---- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ---- Search ---- */
.search-bar {
    display: flex;
    gap: .5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.search-bar .form-input { max-width: 280px; }
.search-bar select.form-input { max-width: 160px; }

/* ---- Sidebar Backdrop ---- */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}

/* ---- Mobile toggle ---- */
.mobile-toggle {
    display: none;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .5rem;
    cursor: pointer;
    color: var(--text);
    font-size: 1.2rem;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding: 1.25rem; }
    .mobile-toggle { display: flex; }
    /* Tor ekranda menyu butunlay yopiladi — yig'ish tugmasining ma'nosi yo'q. */
    .sidebar-toggle { display: none; }
    .sidebar-backdrop.active { display: block; }
    .grid-3 { grid-template-columns: 1fr; }
}


/* ---- Confirmation dialog ---- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal[hidden] { display: none; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(11, 22, 38, .55);
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 26rem;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
}

.modal-card h3 {
    font-size: 1.05rem;
    margin: 0 0 .5rem;
}

.modal-card p {
    color: var(--text-muted);
    font-size: .9rem;
    margin: 0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1.5rem;
}
