/* Sumon Enterprise V2 — UI alignment repair V7
   Scoped layout fixes for Products, Dashboard and Invoice Management. */

/* Shared shell: keep header, sidebar, content and footer on one consistent grid. */
body.mf-classic-v4.sidebar-collapsed .top-bar{left:0!important;right:0!important}
body.mf-classic-v4.sidebar-collapsed .main-area{width:100%!important;margin-left:0!important}
body.mf-classic-v4:not(.sidebar-collapsed) .main-area{width:calc(100% - var(--sidebar-width))!important;min-width:0}
body.mf-classic-v4 #sidebar .mf-sidebar-scroll{flex:1 1 auto;min-height:0;overflow-y:auto!important;overflow-x:hidden!important}
body.mf-classic-v4 #sidebar .mf-sidebar-footer{position:relative;z-index:2;flex:0 0 auto}
body.mf-classic-v4 .site-footer{flex:0 0 auto;line-height:1.6}
body.mf-classic-v4 .content-area{min-width:0}

/* Products: compact, single-row desktop filters; remove sticky KPI overlap. */
body.mf-classic-v4.products .stats-grid{
 position:static!important;top:auto!important;z-index:auto!important;padding:0!important;
 grid-template-columns:repeat(4,minmax(0,1fr));gap:14px;margin:0 0 20px!important;
}
body.mf-classic-v4.products .stat-card{min-width:0;min-height:82px;padding:16px!important}
body.mf-classic-v4.products .stat-card .stat-info{min-width:0;flex:1}
body.mf-classic-v4.products .stat-card .stat-info h3{font-size:clamp(16px,1.35vw,21px);max-width:100%}
body.mf-classic-v4.products .search-filter-bar{
 display:grid!important;
 grid-template-columns:minmax(240px,1fr) minmax(165px,220px) minmax(145px,185px) auto;
 align-items:center;gap:12px;padding:14px 16px!important;margin:0 0 20px!important;
}
body.mf-classic-v4.products .search-filter-bar>*{min-width:0;max-width:100%;width:100%}
body.mf-classic-v4.products .search-filter-bar .search-box{width:100%;min-width:0}
body.mf-classic-v4.products .search-filter-bar .search-box input{
 width:100%!important;max-width:100%;height:44px;min-height:44px;padding:9px 12px 9px 40px!important;
}
body.mf-classic-v4.products .search-filter-bar select.filter-select{
 width:100%!important;min-width:0;max-width:100%;height:44px;min-height:44px;padding:9px 12px!important;
}
body.mf-classic-v4.products .search-filter-bar .badge-count{width:auto;justify-self:end;white-space:nowrap}
body.mf-classic-v4.products .products-grid{
 grid-template-columns:repeat(auto-fill,minmax(min(100%,220px),1fr))!important;
 gap:16px!important;padding:0!important;overflow:visible!important;
}
body.mf-classic-v4.products .product-card{min-width:0}
body.mf-classic-v4.products .product-card .product-image{height:170px}
body.mf-classic-v4.products .product-card .product-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* Dashboard: balanced 3-by-2 KPI and shortcut grids at ordinary desktop widths. */
body.mf-classic-v4.dashboard .phase5-dashboard{width:100%;min-width:0;gap:16px}
body.mf-classic-v4.dashboard .dash-kpi-grid,
body.mf-classic-v4.dashboard .dash-quick-actions{
 grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:12px!important;min-width:0;
}
body.mf-classic-v4.dashboard .dash-kpi,
body.mf-classic-v4.dashboard .dash-quick-actions>a{min-width:0;max-width:100%}
body.mf-classic-v4.dashboard .dash-kpi strong{
 max-width:100%;white-space:normal;overflow-wrap:anywhere;word-break:normal;
}
body.mf-classic-v4.dashboard .dash-main-grid,
body.mf-classic-v4.dashboard .dash-bottom-grid{min-width:0;align-items:start}
body.mf-classic-v4.dashboard .dash-panel{min-width:0}
body.mf-classic-v4.dashboard .dash-panel .table-responsive{width:100%;max-width:100%;overflow-x:auto}

/* Invoices: predictable table columns, proper horizontal/vertical scrolling, no sticky title overlap. */
body.mf-classic-v4.invoices .card-modern{min-width:0;max-width:100%}
body.mf-classic-v4.invoices .card-modern>.card-header{
 position:relative!important;top:auto!important;z-index:1!important;
 display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;
 box-shadow:none!important;
}
body.mf-classic-v4.invoices .card-modern>.card-body{
 max-height:none!important;overflow:visible!important;min-width:0;
}
body.mf-classic-v4.invoices .invoice-table-scroll{
 width:100%;max-width:100%;max-height:70vh;overflow:auto!important;
 overscroll-behavior:contain;-webkit-overflow-scrolling:touch;position:relative;
 scrollbar-width:thin;scrollbar-color:#b9a8df #f3f0fa;
}
body.mf-classic-v4.invoices .invoice-table-scroll::-webkit-scrollbar{width:9px;height:9px}
body.mf-classic-v4.invoices .invoice-table-scroll::-webkit-scrollbar-track{background:#f3f0fa;border-radius:8px}
body.mf-classic-v4.invoices .invoice-table-scroll::-webkit-scrollbar-thumb{background:#b9a8df;border:2px solid #f3f0fa;border-radius:8px}
body.mf-classic-v4.invoices table.table-dark{
 width:100%;min-width:1000px;table-layout:fixed;border-collapse:separate;border-spacing:0;
}
body.mf-classic-v4.invoices table.table-dark th,
body.mf-classic-v4.invoices table.table-dark td{
 padding:8px 7px!important;white-space:nowrap;overflow-wrap:normal;word-break:normal;
 vertical-align:middle;
}
body.mf-classic-v4.invoices table.table-dark thead th{
 position:sticky;top:0;z-index:5;white-space:nowrap;
}
body.mf-classic-v4.invoices table.table-dark th:nth-child(1),
body.mf-classic-v4.invoices table.table-dark td:nth-child(1){width:50px;text-align:center}
body.mf-classic-v4.invoices table.table-dark th:nth-child(2),
body.mf-classic-v4.invoices table.table-dark td:nth-child(2){width:135px}
body.mf-classic-v4.invoices table.table-dark th:nth-child(3),
body.mf-classic-v4.invoices table.table-dark td:nth-child(3){width:85px}
body.mf-classic-v4.invoices table.table-dark th:nth-child(4),
body.mf-classic-v4.invoices table.table-dark td:nth-child(4){width:125px}
body.mf-classic-v4.invoices table.table-dark th:nth-child(5),
body.mf-classic-v4.invoices table.table-dark td:nth-child(5){width:110px}
body.mf-classic-v4.invoices table.table-dark th:nth-child(6),
body.mf-classic-v4.invoices table.table-dark td:nth-child(6){width:90px}
body.mf-classic-v4.invoices table.table-dark th:nth-child(7),
body.mf-classic-v4.invoices table.table-dark td:nth-child(7),
body.mf-classic-v4.invoices table.table-dark th:nth-child(8),
body.mf-classic-v4.invoices table.table-dark td:nth-child(8){width:85px}
body.mf-classic-v4.invoices table.table-dark th:nth-child(9),
body.mf-classic-v4.invoices table.table-dark td:nth-child(9){width:100px}
body.mf-classic-v4.invoices table.table-dark th:nth-child(10),
body.mf-classic-v4.invoices table.table-dark td:nth-child(10){width:130px}
body.mf-classic-v4.invoices .invoice-number{
 display:inline-block;max-width:100%;white-space:nowrap;overflow-wrap:normal;word-break:keep-all;
 font-size:13px;line-height:1.4;
}
body.mf-classic-v4.invoices table.table-dark td:nth-child(4)>a,
body.mf-classic-v4.invoices table.table-dark td:nth-child(5)>span{
 display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;vertical-align:middle;
}
body.mf-classic-v4.invoices .status-badge{white-space:nowrap}
body.mf-classic-v4.invoices .btn-action{flex-shrink:0}
body.mf-classic-v4.invoices .filter-bar .date-input{
 width:auto!important;min-width:140px;max-width:190px;flex:1 1 145px;
}
body.mf-classic-v4.invoices .filter-bar form.d-flex{display:flex;align-items:center;flex-wrap:wrap;min-width:0}
body.mf-classic-v4.invoices .filter-bar .search-box{width:100%;min-width:0}
body.mf-classic-v4.invoices .filter-bar .search-box input{width:100%!important}

/* Wide desktop gets more columns; smaller screens use compact, balanced grids. */
@media(min-width:1600px){
 body.mf-classic-v4.dashboard .dash-kpi-grid,
 body.mf-classic-v4.dashboard .dash-quick-actions{grid-template-columns:repeat(6,minmax(0,1fr))!important}
}
@media(max-width:1200px){
 body.mf-classic-v4.products .search-filter-bar{
  grid-template-columns:minmax(0,1fr) minmax(170px,220px) minmax(145px,185px);
 }
 body.mf-classic-v4.products .search-filter-bar .search-box{grid-column:1/-1}
 body.mf-classic-v4.products .search-filter-bar .badge-count{justify-self:start}
}
@media(max-width:992px){
 body.mf-classic-v4.products .stats-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
 body.mf-classic-v4.products .search-filter-bar{grid-template-columns:repeat(2,minmax(0,1fr))}
 body.mf-classic-v4.products .search-filter-bar .search-box{grid-column:1/-1}
 body.mf-classic-v4.products .search-filter-bar .badge-count{grid-column:1/-1;justify-self:start}
 body.mf-classic-v4.dashboard .dash-kpi-grid,
 body.mf-classic-v4.dashboard .dash-quick-actions{grid-template-columns:repeat(2,minmax(0,1fr))!important}
 body.mf-classic-v4.invoices .invoice-table-scroll{max-height:65vh}
}
@media(max-width:600px){
 body.mf-classic-v4.products .stats-grid{grid-template-columns:1fr}
 body.mf-classic-v4.products .search-filter-bar{grid-template-columns:1fr;gap:9px;padding:12px!important}
 body.mf-classic-v4.products .search-filter-bar .search-box,
 body.mf-classic-v4.products .search-filter-bar .badge-count{grid-column:auto}
 body.mf-classic-v4.products .search-filter-bar .badge-count{justify-self:start}
 body.mf-classic-v4.products .products-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:10px!important}
 body.mf-classic-v4.products .product-card .product-image{height:135px}
 body.mf-classic-v4.dashboard .dash-kpi-grid,
 body.mf-classic-v4.dashboard .dash-quick-actions{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important}
 body.mf-classic-v4.dashboard .dash-welcome{min-width:0}
 body.mf-classic-v4.dashboard .dash-welcome h1{overflow-wrap:anywhere}
 body.mf-classic-v4.invoices .invoice-table-scroll{max-height:60vh}
 body.mf-classic-v4.invoices .filter-bar .d-flex{min-width:0}
 body.mf-classic-v4.invoices .filter-bar .date-input{min-width:0;max-width:none}
}
