/* ===== Workstation shell ===== */
html,body{max-width:100%;overflow-x:hidden}
body{min-height:100vh;background:#eef3f7}
.topbar{
  position:sticky;top:0;z-index:500;
  width:100%;box-sizing:border-box;
  min-height:68px;padding:9px 16px;
  display:flex;align-items:center;gap:12px;flex-wrap:nowrap
}
.topbar .brandtext{min-width:0;flex:1}
.topbar .brandtext h1{font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topbar .brandtext p{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top-actions{flex:0 0 auto;display:flex;align-items:center;gap:8px}

.workstation-layout{
  display:grid!important;
  grid-template-columns:248px minmax(0,1fr)!important;
  width:100%!important;max-width:100%!important;
  min-height:calc(100vh - 68px);
  align-items:start
}
.workstation-sidebar{
  width:248px!important;min-width:0!important;
  height:calc(100vh - 68px);
  position:sticky;top:68px;
  overflow-y:auto;overflow-x:hidden;
  box-sizing:border-box;
  padding:10px 9px 22px
}
.workstation-sidebar .navbtn{
  width:100%;box-sizing:border-box;
  white-space:normal;text-align:left;line-height:1.25;
  padding:9px 10px
}
.workstation-sidebar .menu-title{margin-top:12px;padding-left:8px}
.workstation-main{
  min-width:0!important;width:100%!important;max-width:100%!important;
  box-sizing:border-box;padding:16px 18px 30px!important;
  overflow-x:hidden
}
.page{width:100%;max-width:100%;min-width:0;box-sizing:border-box}
.card{min-width:0;max-width:100%;box-sizing:border-box}
.header-row{min-width:0;gap:12px;flex-wrap:wrap}
.header-row>div:first-child{min-width:0;flex:1}
.actions{flex-wrap:wrap}
.grid,.grid.two,.grid.kpis{min-width:0;max-width:100%}
.grid.two{grid-template-columns:repeat(2,minmax(0,1fr))}
.tablewrap{
  width:100%;max-width:100%;min-width:0;
  overflow-x:auto!important;overflow-y:visible;
  -webkit-overflow-scrolling:touch;
  border-radius:8px
}
.tablewrap table{width:100%;max-width:none}
input,select,textarea{max-width:100%;box-sizing:border-box}

/* Masters are workstation panels stacked vertically, not two oversized side-by-side databases. */
#masters>.grid.two{
  display:grid!important;
  grid-template-columns:minmax(0,1fr)!important;
  gap:14px!important
}
#masters .card{width:100%}
#masters .master-filter-grid{
  grid-template-columns:repeat(4,minmax(150px,1fr))!important
}
#masters .tablewrap table{min-width:760px}
#masters #bankMasterTable td:nth-child(1){font-weight:700}
#masters #bankMasterTable td:nth-child(3){font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-weight:700;white-space:nowrap}
#masters #bankMasterTable th:nth-child(1){width:32%}
#masters #bankMasterTable th:nth-child(2){width:32%}
#masters #bankMasterTable th:nth-child(3){width:22%}
#masters #bankMasterTable th:nth-child(4){width:14%}

/* General workstation tables should scroll inside content area, never push the application outside viewport. */
.page .tablewrap{contain:inline-size}
.page table{border-collapse:collapse}
.page th,.page td{overflow-wrap:anywhere}

/* A little denser for real office use. */
.card{padding:14px!important}
.section-title{font-size:14px}
.notice{max-width:100%;box-sizing:border-box}
.formgrid{grid-template-columns:repeat(2,minmax(0,1fr))}
.field{min-width:0}

/* Medium desktop / laptop */
@media(max-width:1180px){
  .workstation-layout{grid-template-columns:218px minmax(0,1fr)!important}
  .workstation-sidebar{width:218px!important}
  .workstation-main{padding:13px!important}
  #masters .master-filter-grid{grid-template-columns:repeat(2,minmax(160px,1fr))!important}
  .grid.two{grid-template-columns:minmax(0,1fr)}
}

/* Tablet / narrow workstation */
@media(max-width:820px){
  .topbar{position:relative;min-height:auto;flex-wrap:wrap}
  .topbar .brandtext h1,.topbar .brandtext p{white-space:normal}
  .workstation-layout{display:block!important}
  .workstation-sidebar{
    position:relative;top:auto;width:100%!important;height:auto!important;
    display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px;
    padding:9px
  }
  .workstation-sidebar .menu-title{grid-column:1/-1;margin:8px 0 2px}
  .workstation-main{padding:10px!important}
  .grid.kpis{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .formgrid,#masters .master-filter-grid{grid-template-columns:1fr!important}
}

/* Phone */
@media(max-width:540px){
  .workstation-sidebar{grid-template-columns:1fr}
  .grid.kpis{grid-template-columns:1fr!important}
  .top-actions{width:100%;justify-content:space-between}
  .header-row .actions{width:100%}
  .header-row .actions .btn{flex:1 1 auto}
}
