/* Unified compact modal density — content dialogs only. */
:root{
  --modal-radius:12px;
  --modal-header-height:46px;
  --modal-control-height:36px;
  --modal-pad-x:16px;
  --modal-pad-y:12px;
  --modal-field-gap:8px;
}
dialog:not(:has(>iframe)){
  max-height:min(86vh,780px);
  border:0!important;
  border-radius:var(--modal-radius)!important;
  box-shadow:0 20px 60px rgb(15 38 28 / 24%)!important;
}
dialog:not(:has(>iframe))::backdrop{
  background:rgb(15 31 24 / 48%);
  backdrop-filter:blur(2px);
}
/* Let the amount and shape of the content choose the dialog width. */
dialog:not(:has(>iframe)){
  width:fit-content!important;
  min-width:min(360px,calc(100vw - 28px));
  max-width:calc(100vw - 28px);
}
.ui-modal:not(.ui-modal--large):not(.ui-modal--frame),
dialog:not(:has(>iframe)):has(.form-grid),
dialog:not(:has(>iframe)):has(.dialog-grid){
  width:min(620px,calc(100vw - 28px))!important;
}
dialog:not(:has(>iframe)):has(table),
dialog:not(:has(>iframe)):has(.ui-table-wrap),
dialog:not(:has(>iframe)):has(.table-wrap){
  width:min(1120px,calc(100vw - 28px))!important;
}
dialog.ui-modal--small:not(:has(>iframe)),
dialog:not(:has(>iframe)):has(.completion-help-list){
  width:min(460px,calc(100vw - 28px))!important;
}
dialog:not(:has(>iframe)) :where(.ui-modal__header,.modal-head,.dialog-head,.login-notice-head,header:first-child){
  box-sizing:border-box;
  min-height:var(--modal-header-height)!important;
  padding:8px var(--modal-pad-x)!important;
}
dialog:not(:has(>iframe)) :where(.ui-modal__header,.modal-head,.dialog-head,.login-notice-head,header:first-child) h2{
  margin:0!important;
  font-size:1.02rem!important;
  line-height:1.3;
}
dialog:not(:has(>iframe)) :where(.ui-modal__header,.modal-head,.dialog-head,header:first-child)>button{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:30px;
  min-width:30px;
  height:30px!important;
  min-height:30px!important;
  padding:0!important;
  border-radius:7px!important;
  font-size:1.1rem;
}
dialog:not(:has(>iframe)) :where(.ui-modal__body,.modal-body,.participant-body,.login-notice-body,[data-bank-alert-body]){
  max-height:calc(86vh - 98px)!important;
  overflow:auto;
  padding:var(--modal-pad-y) var(--modal-pad-x)!important;
}
dialog:not(:has(>iframe)) :where(.ui-modal__footer,.modal-actions,.dialog-actions,.login-notice-actions,footer:last-child){
  box-sizing:border-box;
  min-height:50px!important;
  margin-top:0!important;
  padding:8px var(--modal-pad-x)!important;
  gap:7px!important;
}
dialog:not(:has(>iframe)) .form-grid{
  gap:var(--modal-field-gap) 12px!important;
}
dialog:not(:has(>iframe)) label{
  margin:0 0 3px!important;
  line-height:1.3;
}
dialog:not(:has(>iframe)) .form-grid>label{
  display:grid;
  align-content:start;
  gap:4px!important;
}
dialog:not(:has(>iframe)) :where(input:not([type="checkbox"]):not([type="radio"]),select){
  box-sizing:border-box;
  min-height:var(--modal-control-height);
  height:var(--modal-control-height);
  padding:6px 9px;
}
dialog:not(:has(>iframe)) textarea{
  box-sizing:border-box;
  min-height:76px;
  padding:8px 9px;
  resize:vertical;
}
dialog:not(:has(>iframe)) :where(p,.notice){
  margin-top:4px;
  margin-bottom:8px;
}
dialog:not(:has(>iframe)) :where(button,.ui-button){
  min-height:34px;
  padding:6px 11px;
}
dialog:not(:has(>iframe)) .ui-table-wrap{
  max-height:54vh;
}
dialog.ui-modal--large:not(:has(>iframe)),dialog.wide:not(:has(>iframe)),dialog.tree-dialog:not(:has(>iframe)){
  max-height:90vh;
}
@media(max-width:700px){
  dialog:not(:has(>iframe)){
    width:calc(100vw - 18px)!important;
    max-height:92vh;
  }
  dialog:not(:has(>iframe)) .form-grid{
    grid-template-columns:1fr!important;
  }
  dialog:not(:has(>iframe)) .form-grid .wide{
    grid-column:auto!important;
  }
}

/* Keep the compact density authoritative over older per-screen modal rules. */
dialog.ui-modal:not(:has(>iframe)) .ui-modal__header{
  min-height:var(--modal-header-height)!important;
  padding:8px var(--modal-pad-x)!important;
}
dialog.ui-modal:not(:has(>iframe)) .ui-modal__body{
  max-height:calc(86vh - 98px)!important;
  padding:var(--modal-pad-y) var(--modal-pad-x)!important;
}
dialog.ui-modal:not(:has(>iframe)) .ui-modal__footer{
  min-height:50px!important;
  padding:8px var(--modal-pad-x)!important;
}

/* Native select text needs vertical breathing room, especially for bold Korean text.
   Keep this rule authoritative over per-screen compact form styles. */
html body dialog[open]:not(:has(>iframe)) select:not([multiple]){
  box-sizing:border-box!important;
  display:block;
  height:38px!important;
  min-height:38px!important;
  padding:0 34px 0 10px!important;
  line-height:normal!important;
  font-family:inherit!important;
  font-size:max(.88rem,14px)!important;
  color:#17251f!important;
  background-color:#fff!important;
  vertical-align:middle;
}
html body dialog[open]:not(:has(>iframe)) select:not([multiple]) option{
  color:#17251f;
  background:#fff;
  font:inherit;
}
html body dialog[open]:not(:has(>iframe)) select:not([multiple]):disabled{
  color:#66776e!important;
  background-color:#edf2ef!important;
  opacity:1;
}
