:root {
  --bg: #f3f5f8;
  --sidebar: #0f1724;
  --sidebar-2: #162033;
  --line: #e6eaf0;
  --text: #152033;
  --muted: #6b778c;
  --blue: #1d6fe9;
  --blue-2: #1558c0;
  --card: #ffffff;
  --danger: #dc3b4a;
  --ok: #17824a;
  --warn: #c47a00;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.sidebar {
  width: 236px;
  background: linear-gradient(180deg, var(--sidebar) 0%, #0c1320 100%);
  color: #d7deea;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 18px 16px 14px;
}
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800;
  letter-spacing: .3px;
}
.brand-title { font-weight: 700; color: #fff; }
.brand-sub { font-size: 11px; color: #8b97ab; }
.sidebar nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  color: #c5cedc;
  text-decoration: none;
  border: 0;
  background: transparent;
  text-align: left;
  width: 100%;
}
.nav-item svg { opacity: .9; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item.soon { opacity: .45; }

.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
}
.top-selects { display: flex; gap: 8px; }
.select-btn {
  display: flex; align-items: center; gap: 8px;
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  max-width: 240px;
}
.select-btn span:not(.avatar) {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px;
}
.search-wrap { flex: 1; }
.search-wrap input {
  width: 100%;
  border: 1px solid var(--line);
  background: #f7f9fc;
  border-radius: 12px;
  padding: 10px 14px;
}
.userbox { display: flex; align-items: center; gap: 10px; }
.user-meta { text-align: right; }
.user-name { font-size: 13px; font-weight: 650; }
.user-role { font-size: 11px; color: var(--muted); }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: #dbe7fb; color: var(--blue);
  display: grid; place-items: center; font-weight: 700;
}
.avatar.sm { width: 26px; height: 26px; font-size: 12px; }

.page { padding: 22px 24px 40px; overflow: auto; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.page-head h1 { margin: 0; font-size: 28px; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

.btn {
  border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 650;
  background: #eef2f7; color: var(--text);
}
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-2); }
.btn.danger { background: #fde8ea; color: var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.seg { display: flex; background: #eef2f7; border-radius: 10px; padding: 3px; }
.seg button {
  border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; color: #546173;
}
.seg button.active { background: #fff; color: var(--text); font-weight: 650; box-shadow: 0 1px 2px rgba(16,24,40,.08); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.card .k { color: var(--muted); font-size: 12px; }
.card .v { font-size: 22px; font-weight: 750; margin-top: 6px; }

.table-wrap {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid #eef1f5; text-align: left; font-size: 13.5px; }
th { color: #7a8699; font-weight: 650; background: #fbfcfe; white-space: nowrap; }
td { vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.empty {
  padding: 56px 20px; text-align: center; color: var(--muted);
}
.badge {
  display: inline-flex; align-items: center;
  border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 650;
}
.badge.blue { background: #e8f0fe; color: #1d4ed8; }
.badge.green { background: #e7f7ee; color: var(--ok); }
.badge.orange { background: #fff4de; color: var(--warn); }
.badge.gray { background: #eef2f7; color: #546173; }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.right { text-align: right; }
.muted { color: var(--muted); }
.note-cell {
  max-width: 220px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.btn.sm { padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff;
  display: grid; place-items: center;
}

.menu {
  position: absolute; z-index: 30;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 40px rgba(15,23,42,.12); min-width: 240px; padding: 6px;
}
.menu button {
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 9px 10px; border-radius: 8px;
}
.menu button:hover { background: #f3f6fb; }
.hidden { display: none !important; }
.choice-list { display: grid; gap: 8px; }
.choice {
  display: flex; gap: 10px; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
  cursor: pointer;
}
.choice:has(input:checked) { border-color: var(--blue); background: #eef5ff; }
.sale-forgive { margin: 0; color: var(--text); }
.field .sale-forgive input[type="checkbox"] { width: 19px; height: 19px; padding: 0; flex: 0 0 auto; }
.sale-forgive span { display: grid; gap: 3px; }
.sale-forgive small { color: var(--muted); font-weight: 400; }

.modal-back {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: grid; place-items: center; z-index: 40; padding: 20px;
}
.modal {
  width: min(680px, 100%);
  background: #fff; border-radius: 16px; padding: 20px;
  max-height: 90vh; overflow: auto;
}
.modal-wide { width: min(760px, 100%); }
.percent-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.percent-presets button {
  border: 1px solid var(--line); background: #f4f7fb; border-radius: 8px;
  padding: 6px 10px; font-weight: 650;
}
.percent-presets button.active { background: #e8f0fe; border-color: #c9daf8; color: var(--blue); }
.calc-preview {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-top: 12px;
}
.calc-preview .card { margin: 0; }
.calc-preview .v.ok { color: var(--ok); }
.calc-preview .v.warn { color: var(--warn); }
.drawer-back {
  position: fixed; inset: 0; width: 100%; height: 100%;
  background: rgba(15,23,42,.45);
  z-index: 45; display: flex; justify-content: flex-end; align-items: stretch;
}
.drawer {
  width: calc(100vw - 236px);
  max-width: 100%;
  height: 100%;
  min-height: 100%;
  align-self: stretch;
  background: var(--bg);
  display: flex; flex-direction: column;
  box-shadow: -18px 0 50px rgba(15,23,42,.18);
}
.drawer-head {
  background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 16px 22px;
  display: flex; justify-content: space-between; gap: 16px; align-items: flex-start;
  flex-shrink: 0;
}
.drawer-head h2 { margin: 0; font-size: 22px; }
.drawer-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 18px 22px 22px;
  display: flex;
  flex-direction: column;
}
.drawer .table-wrap { flex: 1; min-height: 0; }
.drawer .toolbar { flex-direction: column; align-items: stretch; flex-shrink: 0; }
.drawer .toolbar .row { justify-content: flex-start; }
.drawer .cards, .drawer .hint { flex-shrink: 0; }
.signed.pos { color: var(--danger); }
.signed.neg { color: var(--ok); }
.clickable-row { cursor: pointer; user-select: none; }
.clickable-row:hover td { background: #f5f8fc; }
.modal h2 { margin: 0 0 14px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid .full { grid-column: 1 / -1; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff;
}
.field input[readonly], .field select:disabled {
  background: #f4f7fb;
  color: var(--text);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.repeat-section {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: #f8fafc;
}
.repeat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.repeat-head b { font-size: 14px; }
.repeat-list { display: grid; gap: 8px; }
.repeat-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: end; }
.repeat-row .field input { background: #fff; }
.repeat-empty { color: var(--muted); font-size: 13px; padding: 4px 0; }
.switch {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
}
.switch b { display: block; }
.tog {
  width: 44px; height: 26px; border-radius: 999px; background: #c9d3e0; position: relative; border: 0;
}
.tog.on { background: var(--blue); }
.tog i {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%;
  transition: left .15s;
}
.tog.on i { left: 21px; }
.search-pick { position: relative; }
.search-pick-list {
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  max-height: 220px;
  overflow: auto;
  box-shadow: 0 10px 24px rgba(15,23,42,.08);
}
.search-pick-list button {
  width: 100%; text-align: left; border: 0; background: transparent;
  padding: 9px 12px; display: flex; justify-content: space-between; gap: 10px;
}
.search-pick-list button span { color: var(--muted); font-size: 12px; }
.search-pick-list button:hover,
.search-pick-list button.active { background: #eef5ff; }
.search-pick-empty { padding: 10px 12px; color: var(--muted); font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.hint.warn { color: var(--danger); }
.file-btn input { display: none; }
.pager { display: flex; justify-content: flex-end; gap: 8px; padding: 12px; }
.toast {
  position: fixed; right: 18px; bottom: 18px; background: #122033; color: #fff;
  padding: 12px 14px; border-radius: 10px; z-index: 50;
}
.filter-input { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; }
@media (max-width: 900px) {
  .sidebar { display: none; }
  .drawer { width: 100%; }
  .grid { grid-template-columns: 1fr; }
  .repeat-row { grid-template-columns: 1fr; }
}

/* ---------- Tashqaridan kirish uchun parol ekrani ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: linear-gradient(180deg, var(--sidebar) 0%, #0a1018 100%);
  display: grid;
  place-items: center;
  padding: 24px;
}
.gate-box {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.gate-mark {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px; letter-spacing: .5px;
}
.gate-box h1 { margin: 6px 0 0; color: #fff; font-size: 25px; }
.gate-box p { margin: 0 0 6px; color: #8b97ab; font-size: 14px; line-height: 1.5; }
.gate-box input {
  width: 100%;
  background: #182437;
  border: 1px solid #24344c;
  border-radius: 10px;
  color: #fff;
  padding: 12px;
  font-size: 15px;
}
.gate-box input:focus { outline: none; border-color: var(--blue); }
.gate-box .btn.primary { justify-content: center; padding: 12px; }
.gate-err {
  background: rgba(220,59,74,.16);
  border: 1px solid rgba(220,59,74,.4);
  color: #ffb3bb;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}
.gate-hint { color: #66768e; font-size: 12px; text-align: center; }
