/* TiKi Tax V5.5.1 accounting/mobile safety overrides */
@media(max-width:640px){
  [role="dialog"]{max-width:calc(100vw - 16px)!important;max-height:calc(100dvh - 16px)!important;overflow:auto!important}
  .rdp{--rdp-cell-size:40px}
  input[type="date"]{min-height:48px;font-size:16px}
  button,[role="button"],[role="combobox"]{min-height:44px}
  .tiki-scanner-active nav,.tiki-scanner-active [data-bottom-nav],.tiki-scanner-active .fixed.bottom-0{display:none!important}
}
html,body{max-width:100%;overflow-x:hidden}

/* V5.5.2: phone overlays must never be hidden behind app navigation/chat/install UI */
@media (max-width: 768px){
  body:has([role="dialog"][data-state="open"]) nav,
  body:has([role="dialog"][data-state="open"]) [data-bottom-nav],
  body:has([role="dialog"][data-state="open"]) .fixed.bottom-0,
  body:has([role="dialog"][data-state="open"]) [class*="fixed"][class*="bottom-"]{
    visibility:hidden!important;
    pointer-events:none!important;
  }
  body:has([role="dialog"][data-state="open"]) [role="dialog"],
  body:has([role="dialog"][data-state="open"]) [role="dialog"] *{
    visibility:visible!important;
  }
  [role="dialog"][data-state="open"]{
    width:calc(100vw - 16px)!important;
    max-width:calc(100vw - 16px)!important;
    max-height:calc(100dvh - 16px)!important;
    overflow-y:auto!important;
    overscroll-behavior:contain;
    padding-bottom:max(24px,env(safe-area-inset-bottom))!important;
  }
  [role="dialog"] [data-radix-scroll-area-viewport],
  [role="dialog"] [role="listbox"]{max-height:min(55dvh,420px)!important;overflow-y:auto!important}
}

/* V5.5.3: true mobile scanner + custom category sheet */
@media (max-width:768px){
  body.tiki-scanner-active nav,
  body.tiki-scanner-active [data-bottom-nav],
  body.tiki-scanner-active .fixed.bottom-0,
  body.tiki-scanner-active [class*="fixed"][class*="bottom-"]{display:none!important}
  body.tiki-scanner-active{overflow:hidden!important}
}
.tiki-custom-category-overlay{position:fixed;inset:0;z-index:2147483000;background:rgba(0,0,0,.55);display:flex;align-items:flex-end;justify-content:center}
.tiki-custom-category-sheet{width:100%;max-width:640px;background:#fff;border-radius:24px 24px 0 0;padding:22px 20px max(24px,env(safe-area-inset-bottom));max-height:94dvh;overflow:auto;box-shadow:0 -12px 40px rgba(0,0,0,.2)}
.tiki-custom-category-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:22px}.tiki-custom-category-head h2{font-size:24px;font-weight:750;margin:0 0 5px}.tiki-custom-category-head p,.tiki-category-help{color:#667085;font-size:14px;line-height:1.45;margin:0}.tiki-custom-category-head button{border:0;background:#f2f4f7;border-radius:12px;width:44px;height:44px;font-size:28px;line-height:1}.tiki-custom-category-sheet label{display:block;font-weight:650;margin:16px 0}.tiki-custom-category-sheet input,.tiki-custom-category-sheet select{display:block;width:100%;height:52px;margin-top:8px;border:1px solid #d0d5dd;border-radius:12px;padding:0 14px;background:#fff;font-size:16px}.tiki-custom-category-actions{display:grid;grid-template-columns:1fr 1.35fr;gap:10px;margin-top:24px}.tiki-custom-category-actions button{height:52px;border-radius:12px;border:1px solid #d0d5dd;background:#fff;font-size:16px;font-weight:700}.tiki-custom-category-actions [data-create]{background:#10b981;color:#fff;border-color:#10b981}
@media(min-width:769px){.tiki-custom-category-overlay{align-items:center;padding:24px}.tiki-custom-category-sheet{border-radius:20px;max-width:520px}}

/* TiKi Tax V5.5.4 targeted phone fixes */
@media (max-width: 1023px){
  aside.fixed.top-0.left-0.h-full{overflow-y:auto!important;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;padding-bottom:calc(96px + env(safe-area-inset-bottom))!important}
  body.tiki-scanner-active #tikitax-mobile-nav, body.tiki-scanner-active #tikitax-quick-scan, body.tiki-scanner-active .tikitax-chat-launcher{display:none!important}
}
