/* JKA Dealer Portal v1.6.22 — release-gate visual hardening
   Final visual pass loaded after all feature/theme CSS. Keeps layouts compact,
   aligned, overflow-safe, and consistent across desktop, tablet, mobile, cards,
   forms, tables, alerts, and modal surfaces. */

/* Page rhythm */
body.homeaid-system main > .dashboard,
body.homeaid-system main > .container,
body.homeaid-system main > .container-fluid{
  min-width:0;
}
body.homeaid-system .premium-page-head{
  gap:1rem!important;
  margin-bottom:.9rem!important;
}
body.homeaid-system .premium-page-title{min-width:0!important}
body.homeaid-system .premium-page-title h1{margin-bottom:.28rem!important}
body.homeaid-system .premium-page-title p{margin-bottom:0!important;max-width:72rem}
body.homeaid-system .premium-page-actions{
  gap:.55rem!important;
  align-items:center!important;
}
body.homeaid-system .premium-page-actions form{margin:0!important}

/* Standard section rhythm: prevent compounded utility margins from creating dead bands. */
body.homeaid-system .dashboard > .premium-card,
body.homeaid-system .dashboard > .detail-grid,
body.homeaid-system .dashboard > .premium-metrics,
body.homeaid-system .dashboard > .premium-lower-grid,
body.homeaid-system .dashboard > .dealer-dashboard-grid,
body.homeaid-system .dashboard > .request-detail-grid{
  margin-top:.82rem!important;
  margin-bottom:0!important;
}
body.homeaid-system .dashboard > .premium-page-head + .premium-card,
body.homeaid-system .dashboard > .premium-page-head + .detail-grid,
body.homeaid-system .dashboard > .premium-page-head + .premium-metrics,
body.homeaid-system .dashboard > .premium-page-head + .premium-lower-grid,
body.homeaid-system .dashboard > .premium-page-head + .dealer-dashboard-grid,
body.homeaid-system .dashboard > .premium-page-head + .request-detail-grid{
  margin-top:0!important;
}

/* Cards */
body.homeaid-system .premium-card,
body.homeaid-system .card,
body.homeaid-system .panel-card,
body.homeaid-system .table-card{
  min-width:0!important;
  overflow:hidden;
}
body.homeaid-system .premium-card-head{
  min-width:0!important;
  align-items:center!important;
}
body.homeaid-system .premium-card-head > div:first-child{
  min-width:0!important;
  align-items:center!important;
}
body.homeaid-system .premium-card-head > div:first-child > div:last-child{min-width:0!important}
body.homeaid-system .premium-card-head h2,
body.homeaid-system .premium-card-head h3,
body.homeaid-system .premium-card-head p{
  overflow-wrap:anywhere;
}
body.homeaid-system .premium-card-body > :first-child{margin-top:0!important}
body.homeaid-system .premium-card-body > :last-child{margin-bottom:0!important}
body.homeaid-system .premium-card-body hr{margin:.85rem 0!important}

/* All sibling-card grids get predictable spacing and equal-height rows. */
body.homeaid-system .detail-grid,
body.homeaid-system .premium-lower-grid,
body.homeaid-system .dealer-dashboard-grid,
body.homeaid-system .request-detail-grid,
body.homeaid-system .role-card-grid,
body.homeaid-system .settings-grid{
  gap:.82rem!important;
  align-items:stretch!important;
}
body.homeaid-system .detail-grid > *,
body.homeaid-system .premium-lower-grid > *,
body.homeaid-system .dealer-dashboard-grid > *,
body.homeaid-system .request-detail-grid > *,
body.homeaid-system .role-card-grid > *,
body.homeaid-system .settings-grid > *{
  min-width:0!important;
}

/* Forms */
body.homeaid-system .premium-card-body form{min-width:0}
body.homeaid-system .form-label{
  margin-bottom:.72rem!important;
  width:100%;
}
body.homeaid-system .form-label > .form-control,
body.homeaid-system .form-label > .form-select,
body.homeaid-system .form-label > textarea{
  margin-top:.3rem!important;
}
body.homeaid-system .form-label > .fine,
body.homeaid-system .form-label > small{
  display:block;
  margin-top:.28rem!important;
  line-height:1.35;
}
body.homeaid-system .row.g-3{--bs-gutter-x:.82rem;--bs-gutter-y:.82rem}
body.homeaid-system .save-actions,
body.homeaid-system .danger-zone-actions,
body.homeaid-system .smtp-diagnostic-actions,
body.homeaid-system .email-pref-actions{
  gap:.55rem!important;
  flex-wrap:wrap;
}

/* KPI rows stay compact, fill the row, and keep uniform sibling height. */
body.homeaid-system .premium-metrics{
  width:100%!important;
  grid-template-columns:repeat(auto-fit,minmax(min(220px,100%),1fr))!important;
  align-items:stretch!important;
  grid-auto-rows:1fr!important;
}
body.homeaid-system .premium-metric{
  width:100%!important;
  height:100%!important;
  align-self:stretch!important;
}
body.homeaid-system .premium-metric > div{overflow:hidden}

/* Tables and DataTables */
body.homeaid-system .dealer-table-wrap,
body.homeaid-system .table-responsive{
  width:100%;
  max-width:100%;
  overflow-x:auto!important;
  -webkit-overflow-scrolling:touch;
}
body.homeaid-system .dealer-table-wrap{padding-bottom:.8rem!important}
body.homeaid-system .premium-table{margin-bottom:0!important}
body.homeaid-system .premium-table td,
body.homeaid-system .premium-table th{vertical-align:middle!important}
body.homeaid-system .dataTables_wrapper,
body.homeaid-system .dt-container{min-width:0!important;width:100%!important}
body.homeaid-system .dataTables_wrapper .row,
body.homeaid-system .dt-container .dt-layout-row{margin-left:0!important;margin-right:0!important}

/* Alerts, diagnostic/result blocks, list rows */
body.homeaid-system .alert{margin-bottom:.75rem!important}
body.homeaid-system .alert:last-child{margin-bottom:0!important}
body.homeaid-system .smtp-config-summary,
body.homeaid-system .smtp-evidence-grid,
body.homeaid-system .term-chip-grid,
body.homeaid-system .notification-grid{
  gap:.65rem!important;
}
body.homeaid-system .smtp-diagnostic-step,
body.homeaid-system .email-pref-row,
body.homeaid-system .term-chip-row{
  min-width:0;
}

/* Buttons: keep icons and labels aligned without forcing oversized widths. */
body.homeaid-system .btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:.42rem;
}
body.homeaid-system .btn > i{flex:0 0 auto}

/* Modals: always viewport-safe and internally scrollable. */
body.homeaid-system .modal-dialog{
  max-height:calc(100dvh - 1rem)!important;
}
body.homeaid-system .modal-content{
  max-height:calc(100dvh - 1rem)!important;
  overflow:hidden!important;
}
body.homeaid-system .modal-body{
  overflow-y:auto!important;
  overscroll-behavior:contain;
  min-height:0!important;
}
body.homeaid-system .modal-header,
body.homeaid-system .modal-footer{flex:0 0 auto!important}

/* Tablet */
@media(max-width:991.98px){
  body.homeaid-system .premium-page-head{margin-bottom:.75rem!important}
  body.homeaid-system .dashboard > .premium-card,
  body.homeaid-system .dashboard > .detail-grid,
  body.homeaid-system .dashboard > .premium-metrics,
  body.homeaid-system .dashboard > .premium-lower-grid,
  body.homeaid-system .dashboard > .dealer-dashboard-grid,
  body.homeaid-system .dashboard > .request-detail-grid{margin-top:.72rem!important}
  body.homeaid-system .premium-metrics{grid-template-columns:repeat(auto-fit,minmax(min(200px,100%),1fr))!important}
}

/* Phone */
@media(max-width:575.98px){
  body.homeaid-system .premium-page-head{gap:.65rem!important;margin-bottom:.65rem!important}
  body.homeaid-system .premium-page-actions{width:100%;display:grid!important;grid-template-columns:1fr!important}
  body.homeaid-system .premium-page-actions > *,
  body.homeaid-system .premium-page-actions form,
  body.homeaid-system .premium-page-actions .btn{width:100%!important}
  body.homeaid-system .dashboard > .premium-card,
  body.homeaid-system .dashboard > .detail-grid,
  body.homeaid-system .dashboard > .premium-metrics,
  body.homeaid-system .dashboard > .premium-lower-grid,
  body.homeaid-system .dashboard > .dealer-dashboard-grid,
  body.homeaid-system .dashboard > .request-detail-grid{margin-top:.62rem!important}
  body.homeaid-system .detail-grid,
  body.homeaid-system .premium-lower-grid,
  body.homeaid-system .dealer-dashboard-grid,
  body.homeaid-system .request-detail-grid,
  body.homeaid-system .role-card-grid,
  body.homeaid-system .settings-grid{gap:.62rem!important}
  body.homeaid-system .premium-card-head{padding:.7rem .76rem!important;align-items:flex-start!important}
  body.homeaid-system .premium-card-body{padding:.76rem!important}
  body.homeaid-system .premium-metrics{grid-template-columns:1fr!important;grid-auto-rows:auto!important;gap:.48rem!important}
  body.homeaid-system .premium-metric{height:auto!important;min-height:0!important}
  body.homeaid-system .modal-dialog{margin:.35rem!important;max-height:calc(100dvh - .7rem)!important}
  body.homeaid-system .modal-content{max-height:calc(100dvh - .7rem)!important}
  body.homeaid-system .modal-footer{gap:.45rem!important}
  body.homeaid-system .modal-footer .btn{width:100%!important}
}
