/* ===== AF Invest — responsive layer (telefon / planshet / noutbuk / monitor) ===== */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%}
img,svg,canvas,video{max-width:100%}
.main,.section,.card,.cards>*,.grid2>*,.grid3>*,.formgrid>*,.settings-grid>*,
.dashboard-grid-main>*,.dashboard-bottom>*,.dashboard-kpis>*{min-width:0}
.tablewrap,.table-wrap,.table-container,.table-scroll{overflow-x:auto;max-width:100%;-webkit-overflow-scrolling:touch}
.sidebar{overflow-y:auto;overscroll-behavior:contain}
.top{flex-wrap:wrap;gap:10px 14px}
.actions{flex-wrap:wrap}
.actions .btn,.top .btn{white-space:nowrap}
.modal .box{max-width:100%}

/* Katta monitorlar: kontent juda cho'zilib ketmasin */
@media(min-width:1700px){
  .main{padding:28px 44px}
  .main>.section{max-width:1760px;margin-left:auto;margin-right:auto}
}
@media(min-width:2200px){
  .main>.section{max-width:2000px}
}

/* Planshet va kichik noutbuk (769–1100px): to'liq yozuvli ixcham menyu */
@media(min-width:769px) and (max-width:1100px){
  .sidebar{width:210px!important;padding:18px 10px!important}
  .brand{font-size:21px!important;text-align:left!important;padding:8px 10px 20px!important}
  .brand:after{content:none!important}
  .nav button{font-size:14px!important;text-align:left!important;padding:11px 11px!important}
  .nav i{font-size:inherit!important}
  .main{margin-left:210px!important;width:calc(100% - 210px)!important;padding:20px 18px!important}
  .cards{grid-template-columns:repeat(2,1fr)}
  .grid2{grid-template-columns:1fr}
}

/* Past balandlikdagi ekranlar (landshaft telefon / kichik noutbuk) */
@media(max-height:760px) and (min-width:769px){
  .nav button{padding-top:9px!important;padding-bottom:9px!important;margin:2px 0!important}
}

/* Telefon (≤768px) */
@media(max-width:768px){
  /* ochiladigan menyu: yozuvlari bilan */
  .sidebar{padding:18px 12px!important}
  .brand{font-size:21px!important;text-align:left!important;padding:8px 10px 18px!important}
  .brand:after{content:none!important}
  .nav button{font-size:15px!important;text-align:left!important;padding:13px 12px!important}
  .nav i{font-size:inherit!important}
  .main,main{padding-bottom:92px!important}
  .top{align-items:flex-start}
  .actions{width:100%}
  .actions .btn{flex:1 1 auto}
  .mobile-menu-btn{bottom:calc(18px + env(safe-area-inset-bottom,0px));right:calc(14px + env(safe-area-inset-right,0px))}
  #appToast{left:12px;right:12px;bottom:84px;text-align:center}
  .table th,.table td{padding-left:10px;padding-right:10px}
}
@media(max-width:400px){
  .title h1{font-size:19px!important}
  .card{padding:12px!important}
  .value{font-size:20px}
}
/* Sensorli qurilmalarda bosish oson bo'lsin */
@media(hover:none) and (pointer:coarse){
  .nav button{padding-top:13px;padding-bottom:13px}
  .btn{min-height:40px}
}

/* ======================================================================
   TELEFON — alohida mobil tajriba (≤768px)
   pastki navigatsiya, ixcham kartalar, jadval → kartochka, pastdan chiqadigan oynalar
   ====================================================================== */
.af-bottomnav{display:none}
/* "Profil" tanlagichi endi ma'noga ega emas (login bilan kiriladi) */
.sidebar > div:has(#profileRole){display:none!important}

@media(max-width:768px){
  :root{--af-nav-h:62px}
  body{background:#f3f5fa}
  .main,main{padding:12px 12px calc(var(--af-nav-h) + 22px + env(safe-area-inset-bottom,0px))!important}

  /* --- pastki navigatsiya --- */
  .mobile-menu-btn{display:none!important}
  .af-bottomnav{
    display:flex;position:fixed;left:0;right:0;bottom:0;z-index:99990;
    height:calc(var(--af-nav-h) + env(safe-area-inset-bottom,0px));
    padding:0 4px env(safe-area-inset-bottom,0px);
    background:rgba(255,255,255,.97);backdrop-filter:blur(8px);
    border-top:1px solid #e3e8f1;box-shadow:0 -6px 24px rgba(15,23,42,.08)}
  .af-bottomnav button{
    flex:1 1 0;min-width:0;border:0;background:transparent;color:#6b7a90;
    display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
    font-size:11px!important;font-weight:600;padding:6px 2px;position:relative;min-height:0!important;cursor:pointer}
  .af-bottomnav .ic{font-size:21px;line-height:1}
  .af-bottomnav .tx{max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .af-bottomnav button.active{color:var(--primary)}
  .af-bottomnav button.active:before{content:"";position:absolute;top:0;left:28%;right:28%;height:3px;border-radius:0 0 4px 4px;background:var(--primary)}
  body:has(.modal.show) .af-bottomnav,
  body.expense-modal-open .af-bottomnav,body.af-any-modal-open .af-bottomnav,body.af-modal-active .af-bottomnav{display:none}
  body:has(.modal.show) .main{padding-bottom:12px!important}

  /* --- sarlavha --- */
  .top{margin-bottom:14px!important;gap:10px!important}
  .title h1{font-size:21px!important;line-height:1.2}
  .title p{font-size:12.5px;margin-top:3px}
  .actions{display:grid!important;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:8px!important;width:100%}
  .actions .btn{width:100%;justify-content:center;min-height:44px;font-size:14px}

  /* --- statistika kartalari: 2 ustun, ixcham --- */
  .cards,.dashboard-kpis,.overall-stats,.employee-order-summary,.report-kpis{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important;margin-bottom:14px}
  .cards .card,.kpi-card,.overall-stats>*{padding:12px!important;border-radius:14px!important;min-height:0!important}
  .cards .label,.kpi-card .label{font-size:12px}
  .cards .value,.kpi-card .value{font-size:18px!important;margin-top:4px;letter-spacing:-.3px;word-break:break-word}
  .kpi-card:after,.kpi-tag,.kpi-foot{display:none}
  .kpi-top{margin-bottom:8px}
  .kpi-icon,.stat .icon{width:32px;height:32px;border-radius:9px;font-size:16px}
  .dashboard-grid-main,.dashboard-bottom{gap:12px!important}
  .chart-card{min-height:0!important}
  .dash-chart{height:200px!important}

  /* --- umumiy kartalar va qidiruv --- */
  .card{border-radius:14px!important}
  .section-tools,.quick-search{width:100%}
  .quick-search{min-height:44px}

  /* --- JADVAL → KARTOCHKALAR --- */
  .tablewrap,.table-wrap,.table-container,.table-scroll{overflow:visible!important}
  table.table:not(.keep-table){min-width:0!important;width:100%!important;display:block;border:0}
  table.table:not(.keep-table) thead,
  table.table:not(.keep-table) tr:has(>th){display:none!important}
  table.table:not(.keep-table) tbody,
  table.table:not(.keep-table) tr{display:block;width:100%}
  table.table:not(.keep-table) tr{
    background:#fff;border:1px solid var(--line);border-radius:14px;
    padding:6px 14px;margin:0 0 10px;box-shadow:0 2px 10px rgba(25,45,80,.05)}
  table.table:not(.keep-table) tr:hover td{background:transparent}
  table.table:not(.keep-table) td{
    display:flex;justify-content:space-between;align-items:center;gap:14px;
    padding:8px 0!important;border:0!important;border-bottom:1px dashed #edf0f5!important;
    text-align:right;font-size:14px;word-break:break-word;background:transparent!important}
  table.table:not(.keep-table) td:last-child{border-bottom:0!important}
  table.table:not(.keep-table) td:before{
    content:attr(data-label);flex:none;max-width:44%;text-align:left;
    color:var(--muted);font-size:12px;font-weight:600}
  table.table:not(.keep-table) td:not([data-label]):before,
  table.table:not(.keep-table) td[data-label=""]:before{content:none}
  table.table:not(.keep-table) td:not([data-label]),
  table.table:not(.keep-table) td[data-label=""]{justify-content:flex-end;flex-wrap:wrap}
  table.table:not(.keep-table) td[colspan]{display:block;text-align:center;color:var(--muted)}
  table.table:not(.keep-table) td .btn,table.table:not(.keep-table) td button{min-height:38px}

  /* --- OYNALAR: pastdan chiqadigan varaq --- */
  .modal.show{align-items:flex-end!important;padding:0!important;justify-content:center!important}
  .modal.show>.box,.modal.show .box{
    width:100%!important;max-width:100%!important;max-height:92vh!important;margin:0!important;
    border-radius:20px 20px 0 0!important;
    padding:16px 16px calc(14px + env(safe-area-inset-bottom,0px))!important;overflow-y:auto!important}
  .modal .box .actions{position:sticky;bottom:-16px;background:#fff;padding:12px 0 4px!important;margin-top:10px;z-index:3;
    grid-template-columns:1fr 1fr}
  .modal input,.modal select,.modal textarea{min-height:44px}

  #appToast{bottom:calc(var(--af-nav-h) + 16px + env(safe-area-inset-bottom,0px))!important}
}
@media(max-width:768px){.deadline-inline{min-width:0!important;width:100%}}
@media(max-width:768px){
  table.table:not(.keep-table) td{white-space:normal!important;flex-wrap:wrap}
  table.table:not(.keep-table) td>*{max-width:100%;min-width:0}
  .overall-stats>*,.overall-stats>* *{min-width:0}
  .overall-value{font-size:17px!important;word-break:break-word}
  .overall-stats>*{overflow:hidden}
}
@media(max-width:768px){
  /* jadval o'rab turgan tashqi kartani olib tashlaymiz — kartochkalar o'zi karta */
  .card:has(>table.table:not(.keep-table)),.card:has(>.tablewrap),.card:has(>.table-wrap),.card:has(>.table-scroll){
    background:transparent!important;border:0!important;box-shadow:none!important;padding:0!important}
}
@media(max-width:768px){
  table.table:not(.keep-table) td .btn,table.table:not(.keep-table) td button{font-size:13px!important;padding:8px 12px;font-weight:600}
}

/* Shablon qoidasi (display:block!important) xodimda "Ходимга пул бериш" tugmasini qayta ko'rsatib yuborardi */
body #expenses #employeeCashGiveBtn[style*="display: none"]{display:none!important}

/* Jadval sarlavhalari (sticky, z-index:2) menyu ustidan chiqib ketmasligi uchun */
@media(min-width:769px){.sidebar{z-index:50}}

/* iPhone (Bosh ekranga qo'shilgan ilova): status bar / notch ostida qolmasligi uchun */
@media(max-width:768px){.main,main{padding-top:calc(12px + env(safe-area-inset-top,0px))!important}}

/* =====================================================================
   OYNALAR (modal) — yagona qatlam. Shablondagi ko'p ziddiyatli qoidalar
   (overflow:visible, height:100vh, #id selectorlar) ustidan yuradi:
   :not(#_) hiylasi selektor og'irligini oshiradi.
   ===================================================================== */
.modal.show:not(#_a):not(#_b){
  position:fixed!important;inset:0!important;width:100%!important;height:100%!important;
  height:100dvh!important;box-sizing:border-box!important;
  display:flex!important;align-items:center!important;justify-content:center!important;
  padding:16px!important;overflow:hidden!important}
.modal.show:not(#_a):not(#_b)>.modalbox,
.modal.show:not(#_a):not(#_b)>.box{
  box-sizing:border-box!important;margin:0!important;
  max-width:100%!important;max-height:calc(100vh - 32px)!important;max-height:calc(100dvh - 32px)!important;
  overflow-y:auto!important;overflow-x:hidden!important;overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch}
.modal:not(#_a):not(#_b) .modalbox .modalhead{
  position:sticky;top:-22px;z-index:4;background:#fff;margin:-22px -22px 14px;padding:16px 22px 12px;
  border-bottom:1px solid rgba(100,116,139,.18)}
.modal:not(#_a):not(#_b) .modalbox :is(.formactions,.actions):last-child,
.modal:not(#_a):not(#_b) .modalbox form>:is(.formactions,.actions){
  position:sticky;bottom:-22px;z-index:4;background:#fff;margin:14px -22px -22px;padding:12px 22px;
  border-top:1px solid rgba(100,116,139,.18)}
.modal:not(#_a):not(#_b) .formgrid>*{min-width:0}
.modal:not(#_a):not(#_b) :is(input,select,textarea){max-width:100%;box-sizing:border-box}

@media(max-width:768px){
  .modal.show:not(#_a):not(#_b){align-items:flex-end!important;padding:0!important}
  .modal.show:not(#_a):not(#_b)>.modalbox,
  .modal.show:not(#_a):not(#_b)>.box{
    width:100%!important;border-radius:20px 20px 0 0!important;
    max-height:calc(100vh - 24px - env(safe-area-inset-top,0px))!important;
    max-height:calc(100dvh - 24px - env(safe-area-inset-top,0px))!important;
    padding:18px 16px calc(16px + env(safe-area-inset-bottom,0px))!important;
    box-shadow:0 -10px 40px rgba(0,0,0,.35)!important}
  .modal:not(#_a):not(#_b) .modalbox .modalhead{
    top:-18px;margin:-18px -16px 12px;padding:14px 16px 10px}
  .modal:not(#_a):not(#_b) .modalbox :is(.formactions,.actions):last-child,
  .modal:not(#_a):not(#_b) .modalbox form>:is(.formactions,.actions){
    bottom:calc(-16px - env(safe-area-inset-bottom,0px));
    margin:12px -16px calc(-16px - env(safe-area-inset-bottom,0px));
    padding:12px 16px calc(12px + env(safe-area-inset-bottom,0px));
    display:grid!important;grid-template-columns:1fr 1fr;gap:10px}
  .modal:not(#_a):not(#_b) .modalbox :is(.formactions,.actions) .btn{width:100%;min-height:46px;justify-content:center}
  .modal:not(#_a):not(#_b) :is(input,select,textarea){font-size:16px!important}  /* iOS zoom oldini oladi */
  .modal:not(#_a):not(#_b) .formgrid{grid-template-columns:1fr!important}
}
@media(min-width:769px) and (max-height:620px){
  .modal.show:not(#_a):not(#_b){padding:8px!important}
  .modal.show:not(#_a):not(#_b)>.modalbox{max-height:calc(100dvh - 16px)!important}
}

/* ===== 2026-10-05-b: telefonda ichma-ich jadvallar siqilib qolmasligi ===== */
@media(max-width:768px){
  /* shablondagi foizli ustun kengliklari (13%, 8% ...) kartochka qatorlarini siqardi */
  table.table:not(.keep-table) :is(td,th){width:auto!important;min-width:0!important;max-width:none}
  table.table:not(.keep-table) td[data-label]:before{max-width:46%}
  table.table:not(.keep-table) td>*{max-width:100%}
  .tablewrap:has(>table.table:not(.keep-table)),.table-wrap:has(>table.table:not(.keep-table)){max-width:100%;overflow:visible!important}
  /* faqat sarlavhali (qatorsiz) jadval o'rami bo'sh joy qoldirmasin */
  .tablewrap:has(>table.table>thead:only-child){display:none!important}
  /* ochiladigan guruhlar (oylik tarixi, xarajat guruhlari, xodim zakazlari) */
  .salary-group,.salary-month-group{border-radius:14px;overflow:visible}
  .salary-group-body{padding:0 8px 10px}
  .salary-month-body{padding:0 6px 8px}
  .salary-month-group{background:transparent;border:0;margin-top:10px}
  .salary-month-summary tr{margin-bottom:6px}
  .salary-month-body table.table tr{box-shadow:none;background:#f8fafc}
  .salary-group-head{padding:12px}
  .salary-group-head .btn{width:100%}
  /* jadval ichidagi ochiladigan qator (colspan) — to'liq kenglikda */
  table.table:not(.keep-table) tr[id]>td[colspan]{display:block;padding:0!important;text-align:left}
  tr[id]:has(>td[colspan]){background:transparent!important;border:0!important;box-shadow:none!important;padding:0!important}
  tr[id]>td[colspan]>div{padding:6px 0!important}
}

/* ===== 2026-10-05-e: modal sarlavha/tugmalar sticky ofsetlari (iPhone Safari'da pastga chiqib qirqilardi) =====
   Salbiy bottom/top ofsetlar o'rniga: quti padding'i 0, sticky 0 da turadi — barcha brauzerlarda bir xil. */
.modal.show:not(#_a):not(#_b)>.modalbox:has(>.modalhead){padding-top:0!important}
.modal.show:not(#_a):not(#_b)>.modalbox:has(:is(.formactions,.actions):last-child){padding-bottom:0!important}
.modal:not(#_a):not(#_b) .modalbox .modalhead{top:0;margin:0 -22px 14px;padding:16px 22px 12px}
.modal:not(#_a):not(#_b) .modalbox :is(.formactions,.actions):last-child,
.modal:not(#_a):not(#_b) .modalbox form>:is(.formactions,.actions){bottom:0;margin:14px -22px 0;padding:12px 22px}
@media(max-width:768px){
  .modal.show:not(#_a):not(#_b)>.modalbox:has(>.modalhead){padding-top:0!important}
  .modal.show:not(#_a):not(#_b)>.modalbox:has(:is(.formactions,.actions):last-child){padding-bottom:0!important}
  .modal:not(#_a):not(#_b) .modalbox .modalhead{top:0;margin:0 -16px 12px;padding:14px 16px 10px}
  .modal:not(#_a):not(#_b) .modalbox :is(.formactions,.actions):last-child,
  .modal:not(#_a):not(#_b) .modalbox form>:is(.formactions,.actions){
    bottom:0;margin:12px -16px 0;padding:12px 16px calc(14px + env(safe-area-inset-bottom,0px))}
}
