/* CABINET-r37 — first pass after onboarding closeout.
   Scope: visual/tablet-only hardening for client, master and STO cabinets.
   Does not change API, DB, onboarding routes or profile save logic. */

:root{
  --cab-r37-max:1280px;
  --cab-r37-radius:24px;
  --cab-r37-line:rgba(15,23,42,.08);
  --cab-r37-shadow:0 16px 44px rgba(15,23,42,.075);
  --cab-r37-orange:#ff6a00;
  --cab-r37-bg:#f6f7f8;
}

body:not(.entry-flow-active) .cab-hero,
body:not(.entry-flow-active) .master-cabinet-shell,
body:not(.entry-flow-active) .sto-dispatch-page{
  isolation:isolate;
}

/* Client cabinet after onboarding */
body[data-role="client"] .cab-hero{
  background:
    radial-gradient(circle at 14% 0%,rgba(255,106,0,.15),rgba(255,106,0,0) 34%),
    linear-gradient(180deg,#fff 0%,#f7f7f8 100%);
}
body[data-role="client"] .cab-hero .container,
body[data-role="client"] .cab-pane>.container{
  width:min(100% - 28px,var(--cab-r37-max));
  max-width:var(--cab-r37-max);
}
body[data-role="client"] .cab-profile-row{
  align-items:center;
}
body[data-role="client"] .profile-form-card,
body[data-role="client"] .cst-card,
body[data-role="client"] .loy-hero,
body[data-role="client"] .diag-account-card{
  position:relative;
  overflow:hidden;
}
body[data-role="client"] .profile-form-card::before,
body[data-role="client"] .cst-card::before,
body[data-role="client"] .diag-account-card::before{
  content:'';
  position:absolute;
  inset:0 0 auto 0;
  height:3px;
  background:linear-gradient(90deg,var(--cab-r37-orange),rgba(255,106,0,0));
  opacity:.75;
}

/* Master cabinet after onboarding */
body[data-role="master"] .master-cabinet-shell{
  width:min(100% - 28px,var(--cab-r37-max));
  max-width:var(--cab-r37-max);
}
body[data-role="master"] .master-cabinet-hero{
  position:relative;
  overflow:hidden;
}
body[data-role="master"] .master-cabinet-hero::after{
  content:'';
  position:absolute;
  right:-90px;
  top:-130px;
  width:300px;
  height:300px;
  border-radius:50%;
  background:radial-gradient(circle,rgba(255,106,0,.18),rgba(255,106,0,0) 68%);
  pointer-events:none;
}
body[data-role="master"] .master-cabinet-hero>*{
  position:relative;
  z-index:1;
}
body[data-role="master"] .master-cabinet-tile-nav .master-cabinet-tile{
  text-align:left;
  justify-content:flex-start;
}
body[data-role="master"] .master-cabinet-inline-panel{
  min-width:0;
}

/* STO dashboard after onboarding */
body[data-role="sto"] .sto-dispatch-page{
  width:min(100% - 28px,var(--cab-r37-max));
  max-width:var(--cab-r37-max)!important;
}
body[data-role="sto"] .sto-dispatch-head,
body[data-role="sto"] .sto-section,
body[data-role="sto"] .sto-stat-card{
  border-color:var(--cab-r37-line);
}
body[data-role="sto"] .sto-dispatch-head-actions{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  justify-content:flex-end;
}
body[data-role="sto"] .sto-dispatch-head-actions .btn{
  border-radius:16px!important;
}

@media (min-width:768px){
  body:not(.entry-flow-active) .page{
    overflow-x:hidden;
  }
  body[data-role="client"] .cab-profile-row{
    grid-template-columns:auto minmax(0,1fr) minmax(280px,360px);
  }
  body[data-role="client"] .cab-mini-stats{
    align-self:stretch;
    margin-top:0;
  }
  body[data-role="client"] .cab-ms-item{
    min-height:74px;
    display:flex;
    flex-direction:column;
    justify-content:center;
  }
  body[data-role="client"] .profile-form-card{
    max-width:1040px;
  }
  body[data-role="client"] .cab-pane-modal-card{
    width:min(92vw,860px);
  }

  body[data-role="master"] .master-cabinet-shell__main{
    grid-template-columns:minmax(240px,300px) minmax(0,1fr);
  }
  body[data-role="master"] .master-cabinet-tile-nav{
    top:calc(env(safe-area-inset-top,0px) + 16px);
    max-height:calc(100dvh - 32px);
    overflow:auto;
    scrollbar-width:thin;
  }
  body[data-role="master"] .master-cabinet-inline-panel .card{
    min-width:0;
  }

  body[data-role="sto"] .sto-dispatch-head{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
    gap:20px;
  }
  body[data-role="sto"] .sto-stat-grid{
    grid-template-columns:repeat(4,minmax(0,1fr));
  }
  body[data-role="sto"] .sto-master-row{
    grid-template-columns:48px minmax(0,1fr) auto auto;
  }
}

@media (min-width:1024px){
  body[data-role="client"] .cab-hero .container,
  body[data-role="client"] .cab-pane>.container,
  body[data-role="master"] .master-cabinet-shell,
  body[data-role="sto"] .sto-dispatch-page{
    width:min(100% - 72px,var(--cab-r37-max));
  }
  body[data-role="client"] .cab-profile-row,
  body[data-role="master"] .master-cabinet-hero,
  body[data-role="sto"] .sto-dispatch-head{
    border-radius:30px;
  }
  body[data-role="master"] .master-cabinet-shell__main{
    grid-template-columns:320px minmax(0,1fr);
  }
  body[data-role="master"] .master-cabinet-tile-nav .master-cabinet-tile{
    min-height:82px;
  }
}

@media (min-width:1200px){
  body[data-role="client"] .cab-hero .container,
  body[data-role="client"] .cab-pane>.container,
  body[data-role="master"] .master-cabinet-shell,
  body[data-role="sto"] .sto-dispatch-page{
    width:min(100% - 96px,1320px);
    max-width:1320px!important;
  }
  body[data-role="client"] .profile-form{
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
  body[data-role="client"] .profile-form .pf-group:nth-last-child(1),
  body[data-role="client"] .profile-form > div:last-child{
    grid-column:1 / -1;
  }
}

@media (min-width:768px) and (orientation:landscape) and (max-height:760px){
  body[data-role="client"] .cab-profile-row,
  body[data-role="master"] .master-cabinet-hero,
  body[data-role="sto"] .sto-dispatch-head{
    padding-top:14px!important;
    padding-bottom:14px!important;
  }
  body[data-role="client"] .cab-name,
  body[data-role="master"] .master-cabinet-hero .mch-title,
  body[data-role="sto"] .sto-dispatch-title{
    font-size:clamp(22px,2.4vw,30px)!important;
  }
  body[data-role="master"] .master-cabinet-shell__main{
    grid-template-columns:280px minmax(0,1fr);
  }
}

@media (max-width:767px){
  body[data-role="client"] .cab-hero .container,
  body[data-role="client"] .cab-pane>.container,
  body[data-role="master"] .master-cabinet-shell,
  body[data-role="sto"] .sto-dispatch-page{
    width:100%;
    max-width:100%!important;
  }
  body[data-role="sto"] .sto-dispatch-head-actions{
    justify-content:stretch;
  }
  body[data-role="sto"] .sto-dispatch-head-actions .btn{
    flex:1 1 140px;
  }
}
