:root {
  --sariq: #f5c400;
  --sariq-q: #d9a400;
  --sariq-och: #fff4c2;
  --sariq-tanlov: #fbe7a1;
  --fon: #ffffff;
  --fon-2: #f6f5f0;
  --fon-3: #ecebe5;
  --panel: #3d3d3d;
  --panel-2: #4a4a4a;
  --chiziq: #d6d4cc;
  --chiziq-och: #e8e7e1;
  --matn: #222;
  --matn-2: #666;
  --matn-3: #999;
  --yashil: #2e8b3e;
  --yashil-och: #e3f3e5;
  --qizil: #c8352b;
  --qizil-och: #fbe5e3;
  --kok: #2f6db5;
  --kok-och: #e4eefa;
  --kulrang-och: #efefef;
  --soya: 0 6px 24px rgba(0, 0, 0, .18);
  --r: 4px;
}

* { box-sizing: border-box; }
html, body, #ilova { height: 100%; margin: 0; }
body {
  font: 13px/1.35 Arial, "Helvetica Neue", Helvetica, sans-serif;
  color: var(--matn);
  background: var(--fon-2);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--kok); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
.yashirin { display: none !important; }
.raqam { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.markaz { text-align: center; }
.kulrang { color: var(--matn-2); }
.qizil { color: var(--qizil); }
.yashil { color: var(--yashil); }
.qalin { font-weight: 700; }
.kichik { font-size: 12px; }

/* ---------- Ishga tushirish oynasi (bazani tanlash) ---------- */
.ishga {
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #f8f1d2 0%, #efe9d6 45%, #e4e2da 100%);
  padding: 16px;
}
.ishga-oyna {
  width: 680px; max-width: 100%;
  background: var(--fon); border: 1px solid var(--chiziq); border-radius: 6px; box-shadow: var(--soya);
  overflow: hidden;
}
.ishga-bosh {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; background: var(--fon-2); border-bottom: 1px solid var(--chiziq);
}
.logo {
  width: 38px; height: 38px; border-radius: 8px; background: var(--sariq-q); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex: none;
}
.ishga-bosh h1 { font-size: 17px; margin: 0; }
.ishga-bosh p { margin: 2px 0 0; color: var(--matn-2); font-size: 12px; }
.ishga-tana { display: flex; gap: 14px; padding: 16px 18px; }
.bazalar { flex: 1; border: 1px solid var(--chiziq); border-radius: var(--r); min-height: 210px; overflow: auto; }
.baza {
  padding: 9px 12px; border-bottom: 1px solid var(--chiziq-och); cursor: default; user-select: none;
  display: flex; gap: 10px; align-items: center;
}
.baza:last-child { border-bottom: 0; }
.baza.tanlangan { background: var(--sariq-tanlov); }
.baza .b-nomi { font-weight: 700; }
.baza .b-tavsif { color: var(--matn-2); font-size: 12px; }
.baza.ochiq { opacity: .45; }
.baza-ikon { width: 30px; height: 30px; flex: none; color: var(--sariq-q); }
.ishga-tugmalar { width: 150px; display: flex; flex-direction: column; gap: 8px; }
.ishga-tugmalar .tugma { width: 100%; justify-content: center; }
.ishga-pastki { padding: 8px 18px 12px; color: var(--matn-3); font-size: 11px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

/* ---------- Tugmalar, maydonlar ---------- */
.tugma {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 11px; border-radius: 3px;
  border: 1px solid #c3c1b8; background: linear-gradient(#fff, #f1f0ea);
  cursor: pointer; white-space: nowrap; user-select: none;
}
.tugma:hover { border-color: #a9a69a; background: linear-gradient(#fff, #e9e7de); }
.tugma:active { background: #e3e1d8; }
.tugma:disabled { opacity: .5; cursor: default; }
.tugma.asosiy { background: linear-gradient(#ffd83a, #f5c400); border-color: #cfa300; font-weight: 700; }
.tugma.asosiy:hover { background: linear-gradient(#ffdf5c, #edbc00); }
.tugma.xavfli { color: var(--qizil); }
.tugma.kichik { height: 22px; padding: 0 7px; font-size: 12px; }
.tugma svg { width: 14px; height: 14px; flex: none; }
.ajratgich { width: 1px; height: 20px; background: var(--chiziq); margin: 0 3px; }

.maydon {
  height: 24px; border: 1px solid #bdbbb2; border-radius: 2px; padding: 0 6px; background: #fff; min-width: 0;
}
.maydon:focus, textarea.maydon:focus { outline: none; border-color: var(--sariq-q); box-shadow: 0 0 0 2px rgba(245, 196, 0, .25); }
textarea.maydon { height: auto; min-height: 44px; padding: 4px 6px; resize: vertical; }
select.maydon { padding: 0 4px; }
.maydon[readonly] { background: var(--fon-2); }
label.yorliq { color: var(--matn-2); white-space: nowrap; }

/* ---------- Asosiy oyna ---------- */
.oyna { display: grid; grid-template-rows: 40px 1fr; grid-template-columns: 172px 1fr; height: 100vh; }
.sarlavha {
  grid-column: 1 / 3; display: flex; align-items: center; gap: 10px; padding: 0 10px;
  background: var(--fon); border-bottom: 1px solid var(--chiziq);
}
.sarlavha .logo { width: 28px; height: 28px; font-size: 12px; border-radius: 6px; }
.sarlavha .dastur-nomi { font-weight: 700; }
.sarlavha .baza-nomi { color: var(--matn-2); padding-left: 10px; border-left: 1px solid var(--chiziq); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sarlavha .bosh-joy { flex: 1; }
.qidiruv { width: 260px; max-width: 30vw; height: 26px; border-radius: 13px; padding: 0 12px; border: 1px solid var(--chiziq); background: var(--fon-2); }
.qidiruv:focus { outline: none; border-color: var(--sariq-q); background: #fff; }
.foydalanuvchi { display: flex; align-items: center; gap: 6px; color: var(--matn-2); white-space: nowrap; }
.ulanish-belgi { width: 8px; height: 8px; border-radius: 50%; background: var(--yashil); display: inline-block; }
.ulanish-belgi.yoq { background: var(--qizil); }
.ikon-tugma { width: 28px; height: 28px; border-radius: 4px; border: 0; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--matn-2); }
.ikon-tugma:hover { background: var(--fon-3); color: var(--matn); }
.ikon-tugma svg { width: 17px; height: 17px; }

.bolimlar-panel { background: var(--panel); color: #eee; overflow-y: auto; padding: 6px 0; }
.bolim-t {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer; user-select: none;
  border-left: 3px solid transparent;
}
.bolim-t:hover { background: var(--panel-2); }
.bolim-t.faol { background: #555; border-left-color: var(--sariq); color: #fff; }
.bolim-t svg { width: 20px; height: 20px; flex: none; color: var(--sariq); }
.bolim-t .bt-badge { margin-left: auto; background: var(--sariq); color: #222; border-radius: 9px; font-size: 11px; font-weight: 700; padding: 0 6px; }

.ish-joyi { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.varaqlar {
  display: flex; gap: 2px; padding: 5px 6px 0; background: var(--fon-3); border-bottom: 1px solid var(--chiziq);
  overflow-x: auto; flex: none; scrollbar-width: thin;
}
.varaq {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px 5px 11px; max-width: 230px;
  background: #e2e0d8; border: 1px solid var(--chiziq); border-bottom: 0; border-radius: 4px 4px 0 0;
  cursor: pointer; white-space: nowrap; user-select: none; color: #444;
}
.varaq span { overflow: hidden; text-overflow: ellipsis; }
.varaq.faol { background: var(--fon); color: var(--matn); position: relative; top: 1px; font-weight: 700; }
.varaq .yop { border: 0; background: transparent; cursor: pointer; color: var(--matn-3); padding: 0 2px; font-size: 14px; line-height: 1; }
.varaq .yop:hover { color: var(--qizil); }
.varaq-tana { flex: 1; overflow: auto; background: var(--fon); min-height: 0; }
.forma { padding: 12px 16px 24px; min-height: 100%; }
.forma-sarlavha { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.forma-sarlavha h2 { font-size: 18px; margin: 0; font-weight: 400; }
.forma-sarlavha .bosh-joy { flex: 1; }
.asboblar { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-bottom: 8px; }
.asboblar .bosh-joy { flex: 1; }
.filtrlar { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; padding: 7px 9px; background: var(--fon-2); border: 1px solid var(--chiziq-och); border-radius: var(--r); margin-bottom: 8px; }
.filtrlar .guruh { display: flex; align-items: center; gap: 5px; }

/* Funksiyalar paneli (bo'lim buyruqlari) */
.funk-panel {
  position: absolute; left: 0; top: 0; bottom: 0; width: min(560px, 100%); z-index: 30;
  background: var(--fon); border-right: 1px solid var(--chiziq); box-shadow: var(--soya);
  padding: 16px 20px; overflow-y: auto;
}
.funk-panel h3 { margin: 0 0 12px; font-size: 18px; font-weight: 400; display: flex; align-items: center; gap: 8px; }
.funk-panel h3 svg { width: 22px; height: 22px; flex: none; color: var(--sariq-q); }
.funk-panel .ustunlar { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px 24px; }
.funk-panel h4 { margin: 0 0 6px; font-size: 13px; color: var(--matn-2); font-weight: 700; }
.funk-panel a { display: block; padding: 3px 0; }
.funk-panel a.muhim { font-weight: 700; }
.parda { position: absolute; inset: 0; z-index: 29; background: rgba(0, 0, 0, .06); }

/* ---------- Jadval (ro'yxat) ---------- */
.jadval-qobiq { border: 1px solid var(--chiziq); border-radius: 2px; overflow: auto; background: #fff; max-height: calc(100vh - 210px); min-height: 120px; position: relative; }
.jadval-qobiq.erkin { max-height: none; }
table.jadval { border-collapse: separate; border-spacing: 0; width: 100%; }
.jadval th {
  position: sticky; top: 0; z-index: 2; background: var(--fon-3); text-align: left; font-weight: 400; color: #444;
  padding: 5px 7px; border-bottom: 1px solid var(--chiziq); border-right: 1px solid var(--chiziq-och); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.jadval th.raqam { text-align: right; }
.jadval th:hover { background: #e3e1d9; }
.jadval th .sort { color: var(--sariq-q); font-size: 10px; margin-left: 3px; }
.jadval td { padding: 4px 7px; border-bottom: 1px solid var(--chiziq-och); border-right: 1px solid #f3f2ee; vertical-align: top; }
.jadval td { white-space: nowrap; }
.jadval .qisqa-ich { max-width: 340px; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jadval td.keng-matn { white-space: normal; }
.jadval tbody tr:nth-child(even) td { background: #fbfbf9; }
.jadval tbody tr:hover td { background: #fff9df; }
.jadval tbody tr.tanlangan td { background: var(--sariq-tanlov); }
.jadval tbody tr.bekor td { color: var(--matn-3); text-decoration: line-through; }
.jadval tbody tr.manfiy td { background: var(--qizil-och); }
.jadval tfoot td { white-space: normal; position: sticky; bottom: 0; background: var(--fon-2); font-weight: 700; border-top: 1px solid var(--chiziq); padding: 5px 7px; }
.jadval .bosh-qator td { text-align: center; color: var(--matn-3); padding: 24px; background: #fff !important; }
.jadval tr.guruh td { background: var(--fon-2) !important; font-weight: 700; }

/* Holat belgilari */
.holat { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 10px; font-size: 11px; white-space: nowrap; font-weight: 700; }
.holat.tasdiqlandi, .holat.faol { background: var(--yashil-och); color: var(--yashil); }
.holat.kutilmoqda { background: #fff1c4; color: #8a6400; }
.holat.rad { background: var(--qizil-och); color: var(--qizil); }
.holat.bekor { background: var(--kulrang-och); color: #777; }
.holat.nakladnoy, .holat.kundalik { background: var(--kok-och); color: var(--kok); }
.hujjat-ikon { width: 16px; height: 16px; vertical-align: -3px; }
.turi-belgi { font-size: 11px; padding: 0 5px; border-radius: 3px; border: 1px solid; white-space: nowrap; }
.turi-belgi.kirim { color: var(--yashil); border-color: #9fd0a7; }
.turi-belgi.chiqim { color: var(--qizil); border-color: #eab0ab; }
.turi-belgi.boshqa { color: var(--kok); border-color: #a9c4e8; }

/* ---------- Bosh sahifa: ko'rsatkichlar ---------- */
.kartalar { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 14px; }
.karta { border: 1px solid var(--chiziq); border-radius: 5px; padding: 10px 12px; background: #fff; position: relative; overflow: hidden; }
.karta::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--sariq); }
.karta.yashil::before { background: var(--yashil); }
.karta.qizil::before { background: var(--qizil); }
.karta.kok::before { background: var(--kok); }
.karta .k-nomi { color: var(--matn-2); font-size: 12px; }
.karta .k-qiymat { font-size: 20px; font-weight: 700; margin-top: 3px; font-variant-numeric: tabular-nums; }
.karta .k-izoh { color: var(--matn-3); font-size: 11px; margin-top: 2px; }
.karta.bosiladi { cursor: pointer; }
.karta.bosiladi:hover { border-color: var(--sariq-q); }
.blok { border: 1px solid var(--chiziq); border-radius: 5px; background: #fff; margin-bottom: 14px; overflow: hidden; }
.blok-bosh { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--fon-2); border-bottom: 1px solid var(--chiziq-och); font-weight: 700; flex-wrap: wrap; }
.blok-bosh .bosh-joy { flex: 1; }
.blok-tana { padding: 10px 12px; }
.blok-tana.tor { padding: 0; }
.blok .jadval-qobiq { border: 0; max-height: none; }
.ikki { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ikki > .blok { margin-bottom: 0; }
.ikki { margin-bottom: 14px; }

/* Grafik */
.grafik { width: 100%; height: auto; display: block; }
.grafik text { font-size: 11px; fill: #666; }
.grafik .ox { stroke: #ddd; }
.grafik rect.ust:hover { opacity: .8; }
.afsona { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--matn-2); margin-top: 4px; }
.afsona i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.chiziqli { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.chiziqli .c-nomi { width: 40%; min-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chiziqli .c-bar { flex: 1; height: 14px; background: var(--fon-3); border-radius: 2px; overflow: hidden; }
.chiziqli .c-bar i { display: block; height: 100%; background: var(--sariq); }
.chiziqli .c-qiymat { width: 130px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Hujjat formasi ---------- */
.hujjat-bosh { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 18px; margin-bottom: 10px; }
.hujjat-bosh .qator { display: flex; align-items: center; gap: 8px; }
.hujjat-bosh .qator label { width: 76px; flex: none; }
.hujjat-bosh .qator .maydon { flex: 1; }
.hujjat-bosh .keng { grid-column: 1 / -1; }
.ichki-varaqlar { display: flex; gap: 0; border-bottom: 1px solid var(--chiziq); margin: 10px 0 8px; }
.ichki-varaq { padding: 6px 14px; cursor: pointer; border: 1px solid transparent; border-bottom: 0; border-radius: 4px 4px 0 0; color: var(--matn-2); position: relative; top: 1px; }
.ichki-varaq.faol { border-color: var(--chiziq); background: #fff; color: var(--matn); font-weight: 700; }
.tahrir td { padding: 0; }
.tahrir td input, .tahrir td select { width: 100%; border: 0; height: 26px; padding: 0 6px; background: transparent; }
.tahrir td input:focus, .tahrir td select:focus { outline: 2px solid var(--sariq); outline-offset: -2px; background: #fffdf3; }
.tahrir td.raqam input { text-align: right; }
.tahrir td.n { width: 34px; text-align: center; color: var(--matn-3); padding: 5px 0; }
.tahrir td.hisob { padding: 4px 7px; color: var(--matn-2); text-align: right; white-space: nowrap; }
.tahrir td.del { width: 28px; text-align: center; }
.tahrir td.del button { border: 0; background: transparent; cursor: pointer; color: var(--matn-3); font-size: 15px; }
.tahrir td.del button:hover { color: var(--qizil); }
.jami-qator { display: flex; justify-content: flex-end; gap: 18px; padding: 8px 4px; font-size: 14px; }
.jami-qator b { font-variant-numeric: tabular-nums; }
.ogohlar { border: 1px solid #f0cf73; background: #fffaea; border-radius: 4px; padding: 8px 12px; margin: 8px 0; }
.ogohlar.qizil { border-color: #eab0ab; background: var(--qizil-och); }
.ogohlar.yashil { border-color: #9fd0a7; background: var(--yashil-och); }
.ogohlar ul { margin: 4px 0 0; padding-left: 18px; }
.ma-lumot { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 18px; margin-bottom: 8px; }
.ma-lumot div span { color: var(--matn-2); margin-right: 6px; }
.pastki-tugmalar { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- Modal, xabarlar ---------- */
.modal-fon { position: fixed; inset: 0; background: rgba(30, 30, 30, .35); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: #fff; border-radius: 6px; box-shadow: var(--soya); width: 460px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column; border: 1px solid var(--chiziq); }
.modal.keng { width: 760px; }
.modal-bosh { padding: 10px 14px; border-bottom: 1px solid var(--chiziq-och); font-weight: 700; font-size: 14px; display: flex; align-items: center; background: var(--fon-2); border-radius: 6px 6px 0 0; }
.modal-bosh .bosh-joy { flex: 1; }
.modal-tana { padding: 14px; overflow: auto; }
.modal-tana .maydon { width: 100%; }
.modal-tana p:first-child { margin-top: 0; }
.modal-tugmalar { padding: 10px 14px; border-top: 1px solid var(--chiziq-och); display: flex; justify-content: flex-end; gap: 6px; }
#xabarlar { position: fixed; right: 16px; bottom: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.xabar { background: #333; color: #fff; padding: 9px 14px; border-radius: 5px; box-shadow: var(--soya); max-width: 420px; animation: chiq .18s ease-out; }
.xabar.xato { background: var(--qizil); }
.xabar.yaxshi { background: var(--yashil); }
@keyframes chiq { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.yuklanmoqda { padding: 30px; text-align: center; color: var(--matn-3); }
.yuklanmoqda::before { content: ""; display: inline-block; width: 14px; height: 14px; border: 2px solid var(--sariq); border-right-color: transparent; border-radius: 50%; animation: aylan .7s linear infinite; vertical-align: -2px; margin-right: 8px; }
@keyframes aylan { to { transform: rotate(360deg); } }
.bosh-holat { padding: 40px 20px; text-align: center; color: var(--matn-2); }
.kod { font-family: Menlo, Consolas, monospace; font-size: 12px; background: var(--fon-2); border: 1px solid var(--chiziq-och); border-radius: 3px; padding: 1px 5px; }
pre.kod { padding: 8px 10px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.api-qator { display: grid; grid-template-columns: 52px 1fr; gap: 6px; padding: 5px 0; border-bottom: 1px solid var(--chiziq-och); }
.metod { font-weight: 700; font-size: 11px; color: var(--kok); }
.metod.post { color: var(--yashil); }

@media (max-width: 760px) {
  /* Telefon: bo'limlar pastki panelda (ilovadagi kabi), bitta ustun */
  .oyna { grid-template-columns: 1fr; grid-template-rows: 44px 1fr auto; height: 100vh; height: 100dvh; }
  .sarlavha { grid-column: 1; grid-row: 1; gap: 6px; }
  .ish-joyi { grid-column: 1; grid-row: 2; }
  .bolimlar-panel {
    grid-column: 1; grid-row: 3; display: flex; overflow-x: auto; padding: 0 0 env(safe-area-inset-bottom);
    scrollbar-width: none;
  }
  .bolimlar-panel::-webkit-scrollbar { display: none; }
  .bolim-t {
    flex: 1 0 auto; min-width: 66px; flex-direction: column; justify-content: center; gap: 3px;
    padding: 7px 6px 6px; border-left: 0; border-top: 3px solid transparent; font-size: 10.5px; position: relative;
  }
  .bolim-t.faol { border-top-color: var(--sariq); }
  .bolim-t span { white-space: nowrap; }
  .bolim-t .bt-badge { position: absolute; top: 3px; right: 8px; margin: 0; }
  .qidiruv, .sarlavha .baza-nomi, .foydalanuvchi span { display: none; }
  .kartalar { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
  .filtrlar { max-width: 100%; }
  .filtrlar .guruh { flex-wrap: wrap; }
  .filtrlar input[type=date].maydon { width: 150px; }
  .forma-sarlavha > .filtrlar { width: 100%; }
  .karta .k-qiymat { font-size: 17px; }
  .ikki { grid-template-columns: 1fr; }
  .ishga-tana { flex-direction: column; }
  .ishga-tugmalar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .ishga-tugmalar .tugma { width: auto; flex: 1; height: 36px; }
  .forma { padding: 10px; }
  .forma-sarlavha h2 { font-size: 16px; }
  .tugma { height: 32px; }
  .maydon, .qidiruv, .tahrir td input, .tahrir td select, textarea.maydon { font-size: 16px; } /* iPhone kattalashtirmasin */
  .maydon { height: 32px; }
  .jadval-qobiq { max-height: none; }
  .modal-fon { align-items: flex-end; padding: 0; }
  .modal { width: 100%; max-height: 85vh; border-radius: 12px 12px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
@media print {
  .sarlavha, .bolimlar-panel, .varaqlar, .asboblar, .filtrlar, .pastki-tugmalar { display: none !important; }
  .oyna { display: block; height: auto; }
  .jadval-qobiq { max-height: none; overflow: visible; }
}
