:root {
  --brand: #0f4c81;
  --brand-2: #1565c0;
  --brand-soft: #e8f1fb;
  --accent: #f08a24;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7689;
  --line: #e3e8ef;
  --red: #d64545;  --red-soft: #fdecec;
  --amber: #d98a00; --amber-soft: #fff5dd;
  --green: #1f9d62; --green-soft: #e3f6ec;
  --gray: #7a8597;  --gray-soft: #eef1f5;
  --violet: #6d4fc2; --violet-soft: #efeafb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.18);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, #0c3f6c 0%, #0f4c81 100%);
  color: #dbe7f5; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 18px 16px; display: flex; gap: 11px; align-items: center; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: .5px; flex: none;
}
.brand b { color: #fff; display: block; font-size: 14.5px; line-height: 1.2; }
.brand span { font-size: 11.5px; opacity: .75; }
.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px;
  color: #cddcee; font-weight: 500; text-decoration: none; position: relative;
}
.nav a svg { width: 19px; height: 19px; flex: none; opacity: .9; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); }
.nav .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600; }
.nav-sep { margin: 12px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; opacity: .55; }
.side-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; }
.side-foot .user { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.18); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.side-foot b { color: #fff; display: block; font-size: 13px; }
.side-foot .links { margin-top: 10px; display: flex; gap: 14px; }
.side-foot .links a { color: #cddcee; cursor: pointer; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 28px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; margin-left: -6px; cursor: pointer; color: var(--text); }
.menu-btn svg { width: 24px; height: 24px; }
.content { padding: 24px 28px 48px; max-width: 1500px; width: 100%; }

/* ---------- Cards / KPI ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 0; }
.card-h h3 { font-size: 15px; }
.card-h .spacer { flex: 1; }
.card-b { padding: 16px 18px 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi { padding: 16px 18px; cursor: pointer; transition: transform .12s, box-shadow .12s; position: relative; overflow: hidden; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi .lbl { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 7px; }
.kpi .val { font-size: 30px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi .dot { width: 8px; height: 8px; border-radius: 50%; }
.kpi.red .val { color: var(--red); } .kpi.red .dot { background: var(--red); }
.kpi.amber .val { color: var(--amber); } .kpi.amber .dot { background: var(--amber); }
.kpi.green .val { color: var(--green); } .kpi.green .dot { background: var(--green); }
.kpi.blue .val { color: var(--brand); } .kpi.blue .dot { background: var(--brand); }
.kpi.violet .val { color: var(--violet); } .kpi.violet .dot { background: var(--violet); }
.kpi.gray .val { color: var(--gray); } .kpi.gray .dot { background: var(--gray); }
.two { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.grid > * { min-width: 0; }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.alert {
  display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius);
  background: var(--amber-soft); border: 1px solid #f3d48a; color: #7a4d00; margin-bottom: 16px;
}
.alert.info { background: var(--brand-soft); border-color: #c4dbf3; color: #0d3a63; }
.alert.danger { background: var(--red-soft); border-color: #f5c2c2; color: #8b1f1f; }
.alert.warn { background: var(--amber-soft); border-color: #f3d79b; color: #7a4d00; }
.alert .spacer { flex: 1; }
.alert svg { width: 22px; height: 22px; flex: none; }

/* ---------- Chart ---------- */
.bars { overflow-x: auto; display: flex; align-items: flex-end; gap: 8px; height: 200px; padding-top: 18px; }
.bar { flex: 1 0 30px; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar .col { width: 100%; max-width: 38px; background: var(--brand-2); border-radius: 6px 6px 2px 2px; min-height: 2px; position: relative; transition: opacity .15s; }
.bar:first-child .col { background: var(--amber); }
.bar:hover .col { opacity: .8; }
.bar .v { font-size: 11.5px; font-weight: 600; color: var(--text); }
.bar .l { font-size: 11px; color: var(--muted); white-space: nowrap; }
.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar .top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 5px; gap: 10px; }
.hbar .top span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 8px; background: var(--gray-soft); border-radius: 6px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--red); border-radius: 6px; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed .ic { width: 30px; height: 30px; border-radius: 8px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.feed .ic svg { width: 16px; height: 16px; }
.feed .t { font-size: 13px; }
.feed .w { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.search { position: relative; min-width: 260px; flex: 0 1 340px; }
.search input[type=search] { padding-left: 36px; width: 100%; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 20px; padding: 6px 13px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: #3d4757; display: inline-flex; gap: 7px; align-items: center;
}
.chip:hover { border-color: #c5cfdc; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { font-size: 11.5px; opacity: .75; }

input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], input[type=time], select, textarea {
  height: 38px; border: 1px solid #d3dae4; border-radius: 9px; padding: 0 12px; background: #fff; outline: none;
  transition: border-color .12s, box-shadow .12s; min-width: 0;
}
textarea { height: auto; padding: 9px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(21,101,192,.14); }

.btn {
  height: 38px; padding: 0 15px; border-radius: 9px; border: 1px solid #d3dae4; background: #fff; cursor: pointer;
  font-weight: 600; font-size: 13.5px; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; color: #2b3445;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: #f6f8fb; border-color: #c5cfdc; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0c4170; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.accent:hover { background: #db7a18; }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn.green { background: var(--green); border-color: var(--green); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--gray-soft); }
.btn.sm { height: 31px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn .spin { width: 15px; height: 15px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em;
  padding: 11px 14px; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0;
}
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tbody tr { transition: background .1s; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr:hover { background: #f7faff; }
.t tbody tr.sel { background: #eef5ff; }
.t td.chk, .t th.chk { width: 40px; padding-right: 0; }
.t .name { font-weight: 600; max-width: 380px; }
.t .name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 2px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; opacity: .4; margin-bottom: 10px; }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: #a86b00; }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.gray { background: var(--gray-soft); color: var(--gray); }
.pill.blue { background: var(--brand-soft); color: var(--brand-2); }
.pill.violet { background: var(--violet-soft); color: var(--violet); }
.days { font-weight: 700; font-variant-numeric: tabular-nums; }
.days.red { color: var(--red); } .days.amber { color: var(--amber); } .days.green { color: var(--green); }

.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px; justify-content: space-between; flex-wrap: wrap; }
.pager .btns { display: flex; gap: 6px; }

.bulk {
  position: sticky; bottom: 16px; margin-top: 14px; z-index: 15; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #10233d; color: #fff; padding: 10px 14px 10px 18px; border-radius: 12px; box-shadow: var(--shadow-lg);
}
.bulk .btn { background: rgba(255,255,255,.1); border-color: transparent; color: #fff; }
.bulk .btn:hover { background: rgba(255,255,255,.2); }
.bulk .btn.accent { background: var(--accent); }
.bulk .spacer { flex: 1; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 10px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 7px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.tab .n { background: var(--gray-soft); color: var(--muted); border-radius: 10px; padding: 0 7px; font-size: 11.5px; }
.tab.on .n { background: var(--brand-soft); color: var(--brand); }

/* ---------- Drawer / Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50; display: flex; justify-content: flex-end; animation: fade .15s; }
.overlay.center { justify-content: center; align-items: center; padding: 16px; }
@keyframes fade { from { opacity: 0; } }
.drawer { width: min(620px, 100%); height: 100%; background: var(--bg); display: flex; flex-direction: column; animation: slide .2s ease-out; }
@keyframes slide { from { transform: translateX(40px); opacity: .4; } }
.drawer-h { background: var(--card); padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer-h h2 { font-size: 17px; line-height: 1.3; }
.drawer-h .x { margin-left: auto; }
.drawer-b { padding: 18px 22px 30px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.modal { width: min(520px, 100%); background: var(--card); border-radius: 14px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop .16s ease-out; }
.modal.wide { width: min(760px, 100%); }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
.modal-h { padding: 18px 22px 6px; display: flex; align-items: center; }
.modal-h h2 { font-size: 17px; }
.modal-h .x { margin-left: auto; }
.modal-b { padding: 12px 22px; overflow-y: auto; }
.modal-f { padding: 14px 22px 18px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 6px; }

.dl { display: grid; grid-template-columns: 170px 1fr; gap: 0; }
.dl > div { padding: 9px 0; border-bottom: 1px solid var(--line); }
.dl > div:nth-child(odd) { color: var(--muted); }
.dl > div:nth-last-child(-n+2) { border-bottom: 0; }

.form { display: grid; gap: 14px; }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: #46516a; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { display: none; }
.switch span { width: 40px; height: 22px; border-radius: 12px; background: #cbd3de; position: relative; transition: background .15s; flex: none; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #fff; top: 2px; left: 2px; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { left: 20px; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-2); }
.timeline li::after { content: ""; position: absolute; left: 8.5px; top: 18px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }

/* ---------- Upload ---------- */
.drop { display: block;
  border: 2px dashed #b9c6d6; border-radius: 14px; padding: 46px 20px; text-align: center; background: #fbfcfe; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--brand-2); background: var(--brand-soft); }
.drop svg { width: 46px; height: 46px; color: var(--brand-2); }
.drop h3 { margin-top: 10px; font-size: 16px; }
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat-row > div { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat-row b { display: block; font-size: 22px; margin-top: 2px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art {
  background: radial-gradient(1200px 600px at 10% 10%, #1d6bb5 0%, #0f4c81 45%, #0a335a 100%); color: #fff;
  padding: 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.login-art::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(240,138,36,.18); }
.login-art h1 { font-size: 34px; line-height: 1.2; max-width: 460px; margin-top: 40px; }
.login-art p { opacity: .8; max-width: 440px; line-height: 1.6; font-size: 15px; }
.login-art ul { padding: 0; list-style: none; display: grid; gap: 12px; margin-top: 28px; }
.login-art li { display: flex; gap: 10px; align-items: center; opacity: .92; }
.login-art li svg { width: 20px; height: 20px; color: var(--accent); flex: none; }
.login-box { display: grid; place-items: center; padding: 32px; background: #fff; }
.login-card { width: min(380px, 100%); }
.login-card img { max-width: 240px; margin-bottom: 26px; }
.login-card h2 { font-size: 24px; margin-bottom: 6px; }
.login-card .form { margin-top: 24px; }
.login-card .btn { width: 100%; justify-content: center; height: 44px; font-size: 15px; }
.err { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------- Toast ---------- */
.toasts { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #10233d; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: 380px;
  display: flex; gap: 10px; align-items: flex-start; animation: pop .18s ease-out; font-size: 13.5px;
}
.toast.ok { background: #136b45; } .toast.bad { background: #a32929; }

.loading { padding: 60px; text-align: center; color: var(--muted); }
.loading .spin { display: inline-block; width: 26px; height: 26px; border: 3px solid var(--brand-2); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
code { background: var(--gray-soft); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 1024px) {
  .two, .three { grid-template-columns: minmax(0, 1fr); }
  .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 55; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px 40px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .val { font-size: 25px; }
  .search { min-width: 0; flex: 1 1 100%; }
  .form .row { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 130px 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .hide-sm { display: none; }
  .topbar .btn .lbl { display: none; }
}
@media print {
  .sidebar, .topbar, .toolbar, .bulk, .pager { display: none !important; }
  .app { display: block; }
}

/* ---------- Mahalla tanlash ---------- */
.mfy-pick { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.field .mfy-pick label { display: flex; gap: 10px; align-items: center; padding: 8px 12px; margin: 0; cursor: pointer; border-bottom: 1px solid var(--line); font-weight: 400; font-size: 13.5px; color: var(--text); }
.field .mfy-pick label:hover { background: #f7faff; }
.field .mfy-pick input[type=checkbox] { width: 16px; height: 16px; flex: none; }

/* ---------- Fayl tanlash ---------- */
.filepick { display: flex !important; align-items: center; gap: 10px; padding: 12px 14px; margin: 0 !important; border: 1.5px dashed #b9c6d6;
  border-radius: 10px; cursor: pointer; background: #fbfcfe; color: var(--muted) !important; font-weight: 500 !important; font-size: 13.5px !important; }
.filepick:hover { border-color: var(--brand-2); background: var(--brand-soft); }
.filepick svg { width: 20px; height: 20px; color: var(--brand-2); flex: none; }
.filepick.chosen { border-style: solid; border-color: var(--green); background: var(--green-soft); color: #136b45 !important; }
.filepick.chosen svg { color: var(--green); }
