/* =====================================================
   MAKHZANY V3.5.6 RESPONSIVE FINAL LAYER
   هدف الطبقة: توحيد كل الشاشات والمنبثقات على الجوال/التابلت/الكمبيوتر
   بدون تغيير منطق البيانات أو API
   ===================================================== */
:root{
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --screen-pad: clamp(10px, 1.7vw, 24px);
  --touch: 44px;
}
html{font-size:16px;-webkit-text-size-adjust:100%;scroll-behavior:smooth}
body{min-width:0;max-width:100vw;overflow-x:hidden!important}
img,svg,canvas,video{max-width:100%;height:auto}
button,input,select,textarea{max-width:100%;min-width:0}
textarea{min-height:92px;resize:vertical}

/* Layout foundation */
.app{width:100%;max-width:100vw;overflow-x:hidden!important;background:var(--bg,#F8FAFC)}
.layout{width:100%;min-width:0}.main{min-width:0;width:100%;max-width:100%;padding:var(--screen-pad)!important}.main>*{max-width:100%}
.top{min-width:0;gap:10px}.brand,.top-actions{min-width:0}.brand small{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.top-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;justify-content:flex-start}.top-actions .smallbtn{margin:0!important;min-height:38px;padding:0 12px!important}

/* Universal responsive grids */
.cards,.kpi-grid,.quick-grid,.grid-icons,.pro-card-grid,.company-cards,.plan-cards,.health-grid,.label-grid,.mobile-ops-grid,.cycle-board,.phase-panel,.enterprise-strip,.saas-kpis{grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr))!important;gap:12px!important}
.row,.split-2,.screen-split,.smart-grid,.company-profile-grid,.saas-grid{grid-template-columns:repeat(auto-fit,minmax(min(100%,260px),1fr))!important;gap:12px!important}
.card,.kpi-card,.pro-card,.clean-panel,.phase-card,.statusbox,.big,.quick-btn,.company-card,.plan-card,.saas-panel,.saas-kpi{min-width:0;overflow:hidden}
.card .n,.kpi-val,.card-value{font-size:clamp(22px,4vw,34px)!important;overflow-wrap:anywhere}
.big,.quick-btn{min-height:104px!important;padding:16px!important;font-size:clamp(15px,2vw,20px)!important}.big .ico,.quick-btn span{font-size:clamp(26px,5vw,42px)!important}

/* Toolbars / page headers */
.toolbar,.pro-head,.clean-head,.saas-topbar,.section-title{display:flex!important;align-items:center!important;justify-content:space-between!important;gap:10px!important;flex-wrap:wrap!important;min-width:0!important}.toolbar>div,.pro-head>div,.clean-head>div{min-width:0}.toolbar h1,.toolbar h2,.pro-head h2,.clean-head h2{margin:0!important;font-size:clamp(19px,3vw,27px)!important;line-height:1.35!important}.toolbar>div:last-child,.pro-head>div:last-child,.clean-head>div:last-child{display:flex!important;gap:7px!important;flex-wrap:wrap!important;align-items:center!important}.toolbar .search,.pro-head .search,.clean-head .search{width:min(100%,330px)!important;max-width:100%!important}

/* Tables: desktop scroll, mobile cards */
.table-wrap,.responsive-table-wrap,.clean-panel:has(table),.table-box{width:100%;max-width:100%;overflow-x:auto!important;-webkit-overflow-scrolling:touch!important;border-radius:18px}.table,table{max-width:100%}.table th,.table td,table th,table td{white-space:normal;word-break:break-word;overflow-wrap:anywhere}.table-actions,.actions-col{min-width:190px;white-space:normal!important}.table-actions{display:flex!important;gap:6px!important;flex-wrap:wrap!important;align-items:center!important}.table-actions .smallbtn{margin:0!important;padding:8px 10px!important;min-height:36px!important;font-size:12px!important}

/* Forms */
.field{min-width:0}.field span{line-height:1.5}.field input,.field select,.field textarea,input,select,textarea{width:100%;min-height:var(--touch)!important;border-radius:13px!important}.opline,.op-line,.po-line,.prod-line{display:grid;grid-template-columns:minmax(180px,1fr) minmax(82px,.35fr) auto;gap:8px;align-items:end;min-width:0}.opline .smallbtn,.op-line .smallbtn,.po-line .smallbtn,.prod-line .smallbtn{min-width:44px}

/* Modal foundation */
.modal{padding:12px!important;align-items:center!important;justify-items:center!important}.modal .box{width:min(720px,96vw)!important;max-width:96vw!important;max-height:min(88dvh,760px)!important;overflow:auto!important;-webkit-overflow-scrolling:touch!important;padding:clamp(14px,2.5vw,24px)!important;border-radius:22px!important}.modal .box.wide-modal{width:min(1120px,97vw)!important;max-width:97vw!important}.modal h2,#mt{font-size:clamp(18px,3vw,25px)!important;margin:0 0 12px!important;line-height:1.45!important}.modal #mb{min-width:0}.modal #mb .cards{grid-template-columns:repeat(auto-fit,minmax(min(100%,150px),1fr))!important}.modal #ms,.modal .btn{width:auto!important;min-width:130px}.modal .danger.smallbtn{min-width:100px}

/* Bottom navigation */
.bottomnav{max-width:100vw;overflow-x:auto!important;-webkit-overflow-scrolling:touch!important;scrollbar-width:none}.bottomnav::-webkit-scrollbar{display:none}.bottomnav button{min-width:76px;min-height:54px;white-space:nowrap}

/* Tablet */
@media (max-width:1100px){
  .layout{grid-template-columns:220px 1fr!important}.side{width:220px!important}.top{height:auto!important;min-height:66px!important;padding:8px 14px!important}.main{padding:14px!important}.statusbar{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}

/* Mobile */
@media (max-width:900px){
  body{background:var(--bg,#F8FAFC)!important}.top{position:sticky!important;top:0!important;z-index:40!important;height:auto!important;min-height:58px!important;padding:8px 10px!important}.brand{gap:8px;max-width:100%}.brand .mark{width:34px!important;height:34px!important;border-radius:11px!important}.brand b{font-size:15px}.brand small{font-size:11px;max-width:170px}.menubtn{min-width:42px;min-height:42px;border:0;border-radius:12px;background:#DBEAFE;color:#163A70;font-weight:900}.top-actions{margin-inline-start:auto;gap:4px}.top-actions .user{display:none}.top-actions .smallbtn{min-height:36px!important;padding:0 9px!important;font-size:12px!important}.top-actions .top-refresh,.top-actions .top-home{display:none!important}
  .layout{display:block!important;min-height:0!important}.main{padding:10px!important;padding-bottom:calc(96px + var(--safe-bottom))!important;overflow:visible!important}.side{position:fixed!important;top:0!important;right:0!important;bottom:0!important;width:min(86vw,330px)!important;height:100dvh!important;z-index:60!important;transform:translateX(104%)!important;transition:transform .22s ease!important;padding-top:78px!important;border-left:1px solid var(--line,#E2E8F0)!important}.menu-open .side{transform:translateX(0)!important}.shade{display:none}.menu-open .shade{display:block!important;position:fixed;inset:0;background:rgba(15,23,42,.42);z-index:55}.nav button{min-height:48px!important;font-size:14px!important}
  .toolbar,.pro-head,.clean-head{position:relative!important;background:#fff!important;border:1px solid var(--line,#E2E8F0)!important;border-radius:18px!important;padding:12px!important;margin-bottom:12px!important}.toolbar>div:first-child,.pro-head>div:first-child,.clean-head>div:first-child{width:100%}.toolbar>div:last-child,.pro-head>div:last-child,.clean-head>div:last-child{width:100%;display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important}.toolbar .smallbtn,.pro-head .smallbtn,.clean-head .smallbtn,.toolbar .search{width:100%!important;margin:0!important}.toolbar .search{grid-column:1/-1!important}
  .cards,.kpi-grid,.quick-grid,.grid-icons,.pro-card-grid,.company-cards,.plan-cards,.health-grid,.mobile-ops-grid,.cycle-board,.phase-panel,.enterprise-strip,.saas-kpis{grid-template-columns:repeat(2,minmax(0,1fr))!important}.row,.split-2,.screen-split,.smart-grid,.company-profile-grid,.saas-grid,.statusbar{grid-template-columns:1fr!important}.card,.kpi-card,.pro-card,.clean-panel,.company-card,.plan-card,.saas-panel{border-radius:18px!important;padding:14px!important}.quick-btn,.big{min-height:96px!important;padding:13px!important}.section-title{align-items:flex-start!important}.tenant-bar{flex-wrap:wrap;text-align:center}.tenant-bar select{width:100%;min-width:0!important}
  .opline,.op-line,.po-line,.prod-line{grid-template-columns:1fr 92px 44px!important}.saas-tabs,.enterprise-tabs,.company-detail-tabs,.report-tabs-pro{display:flex!important;flex-wrap:nowrap!important;overflow-x:auto!important;padding-bottom:6px!important}.saas-tabs button,.enterprise-tabs button,.company-detail-tabs button,.report-tabs-pro button{white-space:nowrap!important;min-width:max-content!important}
  .modal{align-items:end!important;padding:0!important}.modal .box{width:100vw!important;max-width:100vw!important;max-height:92dvh!important;border-radius:24px 24px 0 0!important;padding:16px 12px calc(16px + var(--safe-bottom))!important}.modal .box.wide-modal{width:100vw!important;max-width:100vw!important}.modal #mb .row{grid-template-columns:1fr!important}.modal #ms,.modal .btn,.modal .smallbtn.danger{width:100%!important;margin:6px 0 0!important}.modal table{min-width:680px}.modal .table-actions{min-width:180px}
  .bottomnav{display:flex!important;position:fixed!important;right:0;left:0;bottom:0;z-index:45;background:#fff;border-top:1px solid var(--line,#E2E8F0);padding:7px 7px calc(7px + var(--safe-bottom));gap:6px;box-shadow:0 -10px 28px rgba(15,23,42,.08)}
}
@media (max-width:560px){
  .cards,.kpi-grid,.quick-grid,.grid-icons,.pro-card-grid,.company-cards,.plan-cards,.health-grid,.mobile-ops-grid,.cycle-board,.phase-panel,.enterprise-strip,.saas-kpis{grid-template-columns:1fr!important}.dashboard-admin-icons,.quick-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}.toolbar>div:last-child,.pro-head>div:last-child,.clean-head>div:last-child{grid-template-columns:1fr!important}.opline,.op-line,.po-line,.prod-line{grid-template-columns:1fr!important}.opline .smallbtn,.op-line .smallbtn,.po-line .smallbtn,.prod-line .smallbtn{width:100%!important}.table-actions{min-width:160px}.table-actions .smallbtn{width:100%!important}.brand small{max-width:125px}.login{padding:12px!important}.login-wrap{grid-template-columns:1fr!important;width:100%!important}.login-hero{display:none!important}.login-card{width:100%!important;border-radius:22px!important;padding:20px!important}
}
@media (max-width:380px){.dashboard-admin-icons,.quick-grid{grid-template-columns:1fr!important}.top-actions .danger{padding:0 8px!important}.brand small{display:none}}

/* Print remains official, not screen capture */
@media print{.top,.side,.bottomnav,.shade,.modal:not(.print-modal),#actionFab,#actionSheet{display:none!important}.layout,.main,.app{display:block!important;padding:0!important;margin:0!important;overflow:visible!important}.table-wrap,.responsive-table-wrap,.clean-panel:has(table){overflow:visible!important}.table-actions,.actions-col{display:none!important}}

/* =====================================================
   MAKHZANY V3.5.7 DESKTOP POLISH + REPORT CAIRO + DETAILS VIEW
   ===================================================== */
html,body,body *:not(svg):not(path){font-family:'Cairo',Tahoma,Arial,sans-serif!important}
.report-page,.reports-page,.print-page,.official-report,.clean-panel.report,.report-cards,.report-tabs-pro,
.report-page *,.reports-page *,.print-page *,.official-report *,.clean-panel.report *,.report-cards *,.report-tabs-pro *{
  font-family:'Cairo',Tahoma,Arial,sans-serif!important;
}
@media (min-width:1200px){
  .layout{grid-template-columns:280px minmax(0,1fr)!important;align-items:stretch!important}
  .side{width:280px!important}
  .main{padding:30px 34px!important;max-width:1680px!important;margin-inline:auto!important}
  .toolbar,.pro-head,.clean-head{padding:4px 2px 18px!important;margin-bottom:16px!important}
  .toolbar h2,.pro-head h2,.clean-head h2{font-size:30px!important}
  .kpi-grid,.cards{grid-template-columns:repeat(auto-fit,minmax(230px,1fr))!important;gap:18px!important}
  .quick-grid,.grid-icons,.module-grid,.report-cards{grid-template-columns:repeat(auto-fit,minmax(190px,1fr))!important;gap:16px!important}
  .screen-split,.split-2,.smart-grid,.saas-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:18px!important}
  .clean-panel{padding:22px!important;border-radius:24px!important}
  .table{font-size:14px!important;width:100%!important;table-layout:auto!important}
  .table th{font-size:13px!important;padding:13px 12px!important;white-space:nowrap!important}
  .table td{font-size:13px!important;padding:12px!important;vertical-align:middle!important}
  .table-actions{min-width:230px!important;justify-content:flex-start!important}
  .modal .box{width:min(860px,82vw)!important;max-width:82vw!important}
  .modal .box.wide-modal{width:min(1180px,86vw)!important;max-width:86vw!important}
}
@media (min-width:1600px){
  .main{max-width:1760px!important;padding-inline:42px!important}
  .kpi-grid,.cards{grid-template-columns:repeat(auto-fit,minmax(250px,1fr))!important}
}
.official-details-page{display:grid;gap:16px;direction:rtl;color:#0F172A}
.official-details-head{background:linear-gradient(135deg,#0F2C5C,#163A70);color:#fff;border-radius:22px;padding:18px 20px;box-shadow:0 14px 34px rgba(15,44,92,.16)}
.official-details-head h3{margin:0 0 4px!important;font-size:24px!important;color:#fff!important;font-weight:900!important}
.official-details-head small{color:#EAF2FF;font-weight:700}
.official-section{background:#fff;border:1px solid #D9E1EC;border-radius:22px;padding:18px;box-shadow:0 10px 26px rgba(15,44,92,.06)}
.official-section h4{margin:0 0 14px!important;font-size:17px!important;color:#0F2C5C!important;font-weight:900!important;border-bottom:1px solid #E5E7EB;padding-bottom:10px}
.details-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:10px}
.detail-field{background:#F8FAFC;border:1px solid #E2E8F0;border-radius:16px;padding:12px;min-width:0}
.detail-field span{display:block;color:#64748B;font-size:12px;font-weight:900;margin-bottom:6px}
.detail-field b{display:block;color:#0F172A;font-size:14px;font-weight:900;line-height:1.7;overflow-wrap:anywhere}
.empty-val{color:#94A3B8!important}
.details-list{display:grid;gap:12px}
.detail-line{background:#FBFDFF;border:1px solid #E2E8F0;border-radius:18px;padding:13px}
.detail-line-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px;color:#0F2C5C}
.detail-line-head span{background:#EAF3FF;color:#163A70;border-radius:999px;padding:4px 10px;font-weight:900;font-size:12px}
.details-timeline{display:grid;gap:12px;position:relative}
.timeline-row{display:grid;grid-template-columns:18px 1fr;gap:10px;align-items:start}
.timeline-row .dot{width:12px;height:12px;border-radius:99px;background:#163A70;margin-top:18px;box-shadow:0 0 0 5px #EAF3FF}
@media (max-width:700px){.details-grid{grid-template-columns:1fr}.official-details-head{border-radius:18px}.official-section{padding:14px;border-radius:18px}}
@media print{
  html,body,body *:not(svg):not(path){font-family:'Cairo',Tahoma,Arial,sans-serif!important}
  .official-details-head{background:#163A70!important;color:#fff!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .official-section,.detail-field,.detail-line{box-shadow:none!important;break-inside:avoid!important}
}

/* =====================================================
   MAKHZANY V3.5.14 MOBILE BOTTOM NAV FINAL FIX
   Fix: phone navigator spacing / old flex layout / hidden empty slot
   ===================================================== */
@media (max-width:900px){
  #bottomnav.bottomnav{
    direction:rtl!important;
    position:fixed!important;
    left:0!important;
    right:0!important;
    bottom:0!important;
    width:100vw!important;
    max-width:100vw!important;
    height:calc(66px + env(safe-area-inset-bottom,0px))!important;
    display:grid!important;
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    grid-auto-flow:column!important;
    align-items:stretch!important;
    justify-items:stretch!important;
    gap:0!important;
    margin:0!important;
    padding:6px 4px calc(6px + env(safe-area-inset-bottom,0px))!important;
    overflow:hidden!important;
    background:#fff!important;
    border-top:1px solid #E2E8F0!important;
    box-shadow:0 -8px 24px rgba(15,23,42,.10)!important;
    border-radius:18px 18px 0 0!important;
    z-index:9999!important;
    contain:layout paint!important;
  }
  #bottomnav.bottomnav button{
    width:100%!important;
    min-width:0!important;
    max-width:none!important;
    height:54px!important;
    min-height:54px!important;
    margin:0!important;
    padding:4px 2px!important;
    border:0!important;
    border-radius:14px!important;
    background:transparent!important;
    color:#64748B!important;
    display:flex!important;
    flex-direction:column!important;
    align-items:center!important;
    justify-content:center!important;
    gap:2px!important;
    text-align:center!important;
    overflow:hidden!important;
    white-space:nowrap!important;
    box-shadow:none!important;
    -webkit-tap-highlight-color:transparent!important;
    touch-action:manipulation!important;
  }
  #bottomnav.bottomnav button span{
    display:block!important;
    width:auto!important;
    height:auto!important;
    min-width:0!important;
    font-size:20px!important;
    line-height:1!important;
    margin:0!important;
    padding:0!important;
    background:transparent!important;
  }
  #bottomnav.bottomnav button b{
    display:block!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    font-size:10.5px!important;
    line-height:1.15!important;
    font-weight:900!important;
    white-space:nowrap!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
  }
  #bottomnav.bottomnav button.active{
    background:#DBEAFE!important;
    color:#163A70!important;
  }
  .main{padding-bottom:calc(92px + env(safe-area-inset-bottom,0px))!important;}
  #actionFab,.action-fab,#actionSheet,.action-sheet{display:none!important;visibility:hidden!important;pointer-events:none!important;}
}

/* =====================================================
   MAKHZANY V3.5.15 MOBILE MODULE ACTIONS + CUSTOM NAV
   ===================================================== */
.hub-actions-top{background:#fff;border:1px solid #E2E8F0;border-radius:24px;padding:14px;margin:12px 0 14px;box-shadow:0 12px 30px rgba(15,44,92,.06)}
.hub-actions-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px;color:#0F2C5C;font-weight:900}
.hub-actions-head button{border:1px solid #BFDBFE;background:#EFF6FF;color:#163A70;border-radius:14px;padding:8px 12px;font-weight:900;cursor:pointer}
.hub-action-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px}
.hub-action-btn{border:1px solid #D9E1EC;background:linear-gradient(180deg,#fff,#F8FAFC);border-radius:20px;min-height:92px;padding:12px;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:5px;color:#0F2C5C;font-weight:900;cursor:pointer;box-shadow:0 8px 18px rgba(15,44,92,.05)}
.hub-action-btn span{font-size:26px;line-height:1}.hub-action-btn b{font-size:14px}.hub-action-btn small{font-size:11px;color:#64748B;font-weight:800;line-height:1.25}
.bottom-nav-picker{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:10px;margin-top:12px}.bottom-nav-picker label{display:flex;align-items:center;gap:10px;border:1px solid #D9E1EC;border-radius:16px;padding:12px;background:#fff;font-weight:900;color:#0F2C5C}.bottom-nav-picker input{width:18px;height:18px}.bottom-nav-picker span{font-size:22px}.nav-customize-note{background:#EFF6FF;border:1px solid #BFDBFE;border-radius:16px;padding:12px;color:#163A70;font-weight:900;line-height:1.8}
@media (max-width:700px){
  .hub-actions-top{margin-top:8px;border-radius:20px;padding:11px}
  .hub-actions-head{font-size:13px}.hub-actions-head button{font-size:12px;padding:7px 9px}
  .hub-action-grid{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:8px!important;max-height:none!important;overflow:visible!important}
  .hub-action-btn{min-height:78px!important;border-radius:17px!important;padding:8px 5px!important}
  .hub-action-btn span{font-size:23px!important}.hub-action-btn b{font-size:11.5px!important;line-height:1.2}.hub-action-btn small{display:none!important}
  .kpi-grid,.cards{margin-top:12px!important}
  .bottom-nav-picker{grid-template-columns:1fr!important}.nav-customize-note{font-size:13px}
}
@media (max-width:380px){.hub-action-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}.hub-action-btn{min-height:74px!important}}
