/* GemLooM Diamond Engine R5R7 - full-page readability and aligned field rows. */
:root{
  --gl-r5r7-panel-min: 940px;
  --gl-r5r7-gap: 12px;
}
html[data-diamond-theme] .container{
  grid-template-columns:minmax(920px,1000px) minmax(0,1fr) !important;
  gap:22px !important;
  padding:18px !important;
  align-items:start !important;
}
html[data-diamond-theme] .panel{
  top:0 !important;
  padding:18px !important;
  border-radius:16px !important;
}
.gl-panel-heading{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom:14px;
}
html[data-diamond-theme] .gl-panel-heading h3{
  margin:0 0 4px !important;
  font-size:24px !important;
  line-height:1.15 !important;
  letter-spacing:-.025em !important;
}
.gl-panel-subtitle{
  color:var(--gl-muted);
  font-size:13.5px;
  line-height:1.45;
  font-weight:550;
}
#glDisplaySettingsHost{flex:0 0 auto;min-width:0}
#glDiamondThemeControl{
  position:static !important;
  inset:auto !important;
  transform:none !important;
  z-index:auto !important;
  box-shadow:none !important;
  backdrop-filter:none !important;
  -webkit-backdrop-filter:none !important;
  max-width:none !important;
  flex-wrap:nowrap !important;
  padding:5px !important;
  border-radius:12px !important;
  background:var(--gl-surface-2) !important;
}
#glDiamondThemeControl .gl-theme-label{font-size:10.5px !important;padding:0 4px !important}
#glDiamondThemeControl .gl-theme-btn,#glDiamondThemeControl .gl-text-btn{
  min-width:48px !important;
  height:32px !important;
  min-height:32px !important;
  line-height:30px !important;
  padding:0 9px !important;
  font-size:11.5px !important;
}
#glDiamondThemeControl .gl-control-divider{height:20px !important;margin:0 2px !important}

html[data-diamond-theme] .form-section{
  padding:13px 14px !important;
  margin-bottom:12px !important;
  border-radius:13px !important;
}
html[data-diamond-theme] .form-section-title{
  margin-bottom:9px !important;
  font-size:15.5px !important;
  line-height:1.3 !important;
}
html[data-diamond-theme] .form-section-title span{
  font-size:12.5px !important;
  white-space:nowrap;
}
html[data-diamond-theme] .form-help,
html[data-diamond-theme] .gl-section-note{
  font-size:12.5px !important;
  line-height:1.5 !important;
  color:var(--gl-muted) !important;
  margin:0 0 10px !important;
}
.gl-section-note{margin:9px 0 0 !important}
.gl-form-grid{
  display:grid;
  gap:var(--gl-r5r7-gap);
  align-items:end;
  width:100%;
}
.gl-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}
.gl-cols-5{grid-template-columns:repeat(5,minmax(0,1fr))}
.gl-cols-7{grid-template-columns:repeat(7,minmax(0,1fr))}
.gl-secondary-row{margin-top:11px}
.gl-form-grid .field{
  margin:0 !important;
  min-width:0;
  align-self:end;
}
html[data-diamond-theme] .gl-form-grid label{
  display:flex;
  align-items:flex-end;
  min-height:30px;
  margin:0 0 5px !important;
  font-size:13.5px !important;
  line-height:1.2 !important;
  font-weight:700 !important;
  color:var(--gl-text-soft) !important;
}
html[data-diamond-theme] .gl-form-grid input,
html[data-diamond-theme] .gl-form-grid select{
  width:100% !important;
  height:42px !important;
  min-height:42px !important;
  padding:8px 10px !important;
  font-size:15px !important;
  line-height:1.25 !important;
  font-weight:600 !important;
  border-radius:8px !important;
}
html[data-diamond-text="large"] .gl-form-grid label{font-size:14.5px !important}
html[data-diamond-text="large"] .gl-form-grid input,
html[data-diamond-text="large"] .gl-form-grid select{font-size:16px !important;height:44px !important;min-height:44px !important}
.gl-required{font-size:9px;font-weight:800;color:#ef4444;margin-left:4px;text-transform:uppercase}

/* Keep score block readable without consuming unnecessary vertical space. */
html[data-diamond-theme] .diamond-result{margin-top:15px !important}
html[data-diamond-theme] .btn-group{margin-top:14px !important}
html[data-diamond-theme] .btn-group button{height:42px !important;font-size:14px !important;font-weight:750 !important}

/* Main result/readability alignment. */
html[data-diamond-theme] .kpis{grid-template-columns:repeat(4,minmax(0,1fr)) !important}
html[data-diamond-theme] .charts{grid-template-columns:repeat(2,minmax(0,1fr)) !important}
html[data-diamond-theme] .chart-box{min-height:360px !important;height:360px !important}
html[data-diamond-theme] #reportBox{margin-top:0 !important}

/* The scientific panel no longer duplicates primary data-entry fields. */
#r5IntelligenceMount .r5-identity-strip{display:grid !important;grid-template-columns:minmax(160px,1fr) auto !important;align-items:center !important;gap:12px !important}
#r5IntelligenceMount .r5-identity-strip > div:nth-child(2){display:none !important}
#r5IntelligenceMount .r5-controls-advanced{display:grid !important;grid-template-columns:minmax(280px,1fr) !important}

@media(max-width:1650px){
  html[data-diamond-theme] .container{grid-template-columns:minmax(800px,860px) minmax(0,1fr) !important}
  .gl-form-grid{gap:9px}
  html[data-diamond-theme] .gl-form-grid label{font-size:12.5px !important}
  html[data-diamond-theme] .gl-form-grid input,html[data-diamond-theme] .gl-form-grid select{font-size:14px !important;padding:7px 8px !important}
}
@media(max-width:1250px){
  html[data-diamond-theme] .container{grid-template-columns:1fr !important}
  .gl-panel-heading{align-items:center}
  html[data-diamond-theme] .gl-form-grid label{font-size:12.5px !important}
  html[data-diamond-theme] .gl-form-grid input,html[data-diamond-theme] .gl-form-grid select{font-size:14px !important}
}
@media(max-width:900px){
  .gl-cols-7{grid-template-columns:repeat(4,minmax(0,1fr))}
  .gl-cols-5{grid-template-columns:repeat(3,minmax(0,1fr))}
  .gl-cols-4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .gl-panel-heading{flex-direction:column}
  #glDiamondThemeControl{flex-wrap:wrap !important}
}
@media(max-width:620px){
  .gl-cols-7,.gl-cols-5,.gl-cols-4{grid-template-columns:1fr 1fr}
  html[data-diamond-theme] .charts{grid-template-columns:1fr !important}
}

/* Compatibility-only legacy composite is intentionally de-emphasised. */
.gl-legacy-note{
  margin-top:5px;
  font-size:11px;
  line-height:1.35;
  font-weight:600;
  color:var(--gl-muted);
  max-width:190px;
}
html[data-diamond-text="large"] .gl-legacy-note{font-size:12px}

/* ===== R5R7R1: PAGE-WIDTH CONTAINMENT / NO GLOBAL HORIZONTAL SCROLL =====
   The page itself must never create a horizontal scrollbar. Wide evidence tables
   remain contained within their own scroll region when necessary. */
html,
body{
  width:100%;
  max-width:100%;
  min-width:0;
  margin-left:0;
  margin-right:0;
  overflow-x:hidden;
}
@supports (overflow:clip){
  html,body{overflow-x:clip;}
}
*,*::before,*::after{box-sizing:border-box;}

html[data-diamond-theme] .container{
  width:100% !important;
  max-width:100% !important;
  min-width:0 !important;
  margin:0 auto !important;
  grid-template-columns:minmax(0,1.12fr) minmax(0,.88fr) !important;
}
html[data-diamond-theme] .container > *,
html[data-diamond-theme] .panel,
html[data-diamond-theme] .dashboard,
html[data-diamond-theme] #reportBox,
html[data-diamond-theme] #r5IntelligenceMount,
html[data-diamond-theme] .kpis,
html[data-diamond-theme] .charts,
html[data-diamond-theme] .chart-box,
html[data-diamond-theme] .form-section,
html[data-diamond-theme] .gl-form-grid,
html[data-diamond-theme] .gl-panel-heading,
html[data-diamond-theme] .gl-panel-heading > *,
html[data-diamond-theme] .r5-section,
html[data-diamond-theme] .r5-legacy-market{
  min-width:0 !important;
  max-width:100% !important;
}

/* Keep grouped controls on one row while there is genuinely enough room. */
.gl-form-grid > .field,
.gl-form-grid input,
.gl-form-grid select{
  min-width:0 !important;
  max-width:100% !important;
}
.gl-form-grid select,
.gl-form-grid input{
  text-overflow:ellipsis;
}

/* Header controls may compress/wrap inside their panel, never the viewport. */
.gl-panel-heading > :first-child{
  min-width:0 !important;
  overflow-wrap:anywhere;
}
#glDisplaySettingsHost{
  min-width:0 !important;
  max-width:100% !important;
}
#glDiamondThemeControl{
  max-width:100% !important;
}

/* Wide comparable tables are locally contained, never allowed to widen the page. */
#r5IntelligenceMount .r5-scroll,
#reportBox .r5-legacy-market .r5-scroll{
  display:block;
  width:100% !important;
  max-width:100% !important;
  min-width:0 !important;
  overflow-x:auto !important;
  overflow-y:hidden;
  overscroll-behavior-inline:contain;
  -webkit-overflow-scrolling:touch;
}
#r5IntelligenceMount .r5-table,
#reportBox .r5-legacy-market .r5-table{
  max-width:none !important;
}

/* At laptop widths, use the full viewport for the form so the grouped fields
   stay legible without forcing the whole document wider than the screen. */
@media(max-width:1450px){
  html[data-diamond-theme] .container{
    grid-template-columns:minmax(0,1fr) !important;
    width:100% !important;
    max-width:100% !important;
  }
  html[data-diamond-theme] .panel,
  html[data-diamond-theme] .dashboard{
    width:100% !important;
    max-width:100% !important;
  }
}

/* Small-screen containment: no child may establish a viewport-wide min-content width. */
@media(max-width:900px){
  html[data-diamond-theme] .container{padding:12px !important;gap:14px !important;}
  .gl-panel-heading{width:100%;max-width:100%;}
  #glDiamondThemeControl{width:auto !important;max-width:100% !important;}
}
@media(max-width:620px){
  html[data-diamond-theme] .container{padding:8px !important;}
  html[data-diamond-theme] .panel{padding:12px !important;}
}
