/* Native Gnuboard customer/admin shells only; static public pages use their own layout. */
/* Status labels are button text so submitted Korean status values stay unchanged. */
body.agency-admin button[type="submit"][name="ct_status"] {
  background: var(--ag-red) !important;
  color: white !important;
  border-color: var(--ag-red) !important;
  border-radius: 6px;
}

:is(body.agency-customer, body.agency-admin) .agency-brand .sound_only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

html:not([lang^="ko"]) :is(body.agency-customer, body.agency-admin) :is(h1, h2, h3, p, label, button, .agency-muted, .ym-muted, .agency-kpi-label, .ym-metric > span, .agency-button, .agency-consult-button, .ym-member-button, .ym-extra-secondary, .ym-primary, .ym-secondary, .ym-row-action, .ym-auth-primary, .ym-auth-secondary) {
  overflow-wrap: anywhere;
  word-break: normal;
}

@media (max-width: 1100px) {
  :is(body.agency-customer, body.agency-admin) :is(.agency-main, .agency-legacy-content, #wrapper, .container_wr, .ym-workspace) {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  :is(body.agency-customer, body.agency-admin) :is(.agency-table-scroll, .ym-table-wrap, .tbl_wrap, .tbl_frm01, .ym-data-scroll, .ym-history-scroll, .order_data, .ym-action-table-wrap) {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overscroll-behavior-x: contain;
  }
}

@media (max-width: 760px) {
  :is(body.agency-customer, body.agency-admin) {
    min-width: 0;
    max-width: 100%;
  }

  :is(body.agency-customer, body.agency-admin) :is(h1, h2, h3, p, label, legend, dt, dd, summary) {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  :is(body.agency-customer, body.agency-admin) :is(.agency-page-heading, .agency-admin-page-heading, .ym-member-section-title, .ym-panel-title, .ym-extra-heading) > * {
    min-width: 0;
    max-width: 100%;
  }

  :is(body.agency-customer, body.agency-admin) :is(.agency-button, .agency-consult-button, .ym-member-button, .ym-extra-secondary, .ym-primary, .ym-secondary, .ym-row-action, .ym-auth-primary, .ym-auth-secondary, .ym-detail-jump a, .ym-filter-actions > *, .btn_fixed_top > .btn) {
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    height: auto;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.4;
    text-align: center;
  }

  body.agency-customer .agency-header-inner {
    min-width: 0;
    max-width: 100%;
  }

  body.agency-customer .agency-header .agency-brand {
    min-width: 0;
    flex: 0 1 174px;
  }

  body.agency-customer .agency-header .agency-brand > img {
    max-width: 100%;
    object-fit: contain;
  }

  body.agency-customer .agency-account {
    flex: none;
    min-width: 0;
    max-width: 100%;
  }

  body.agency-customer .agency-account > a:has(> .agency-icon):not(.agency-consult-button),
  body.agency-customer.ym-mobile-member .agency-account > a:not(.agency-admin-link):not(.agency-logout):not(.agency-consult-button) {
    width: 44px !important;
    min-width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }

  body.agency-customer .agency-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 12px;
  }

  body.agency-customer .agency-nav a {
    display: flex;
    align-items: center;
    min-width: 0;
    min-height: 44px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  body.agency-customer.ym-mobile-member .agency-nav { display: none; }

  /* Locale changes aria-label, so navigation layout must depend on stable classes. */
  body.agency-customer #agency-main .agency-tabs,
  .ym-mobile-member .agency-tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
    min-width: 0;
    max-width: 100%;
    gap: 5px;
    overflow: visible;
    box-sizing: border-box;
  }

  body.agency-customer #agency-main .agency-tabs a,
  .ym-mobile-member .agency-tabs a {
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    padding: 10px 7px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.4;
    text-align: center;
  }

  body.agency-customer #agency-main .agency-tabs .ym-member-overview-tab { display: none; }

  body.agency-customer .agency-progress {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  body.agency-customer .agency-progress li {
    min-width: 0;
    white-space: normal;
    align-items: flex-start;
    overflow-wrap: anywhere;
  }

  body.agency-customer .ym-member-section-title {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  body.agency-customer .ym-member-text-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  body.agency-customer :is(.ym-member-periods a, .ym-mobile-quick strong, .ym-mobile-quick small, .ym-order-route li > b, .ym-order-route li > em) {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.4;
    text-align: center;
  }

  body.agency-customer :is(.ym-order-top, .ym-order-status, .ym-mobile-help, .ym-point-entry, .ym-address-toolbar, .ym-address-card-head, .ym-postcode-control, .ym-address-form-actions) {
    flex-wrap: wrap;
  }

  body.agency-customer :is(.ym-order-top > .agency-badge, .ym-mobile-help > a, .ym-point-entry > strong, .ym-point-totals dd, .ym-order-amount > strong) {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  body.agency-customer .ym-order-product h2 {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
  }

  body.agency-customer .ym-postcode-control input { flex-basis: 100%; }
  body.agency-customer .ym-postcode-control button { width: 100%; }

  body.agency-customer .ym-point-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.agency-customer :is(.ym-point-balance, .ym-point-totals, .ym-point-totals dt, .ym-point-totals dd) { min-width: 0; }
  body.agency-customer .ym-point-balance strong { overflow-wrap: anywhere; }
  body.agency-customer .ym-point-totals dl > div { flex-wrap: wrap; }

  :is(body.agency-customer, body.agency-admin) :is(.agency-kpi, .ym-metric) {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  :is(body.agency-customer, body.agency-admin) :is(.agency-kpi strong, .ym-metric > strong) {
    max-width: 100%;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  :is(body.agency-customer, body.agency-admin) :is(.agency-kpi strong small, .ym-metric > strong small) {
    display: inline-block;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  body.agency-admin .agency-kpi-label { max-width: calc(100% - 38px); }
  body.agency-customer.ym-mobile-member .agency-kpi-label { max-width: 100%; }

  body.agency-customer.ym-mobile-member { padding-bottom: calc(110px + env(safe-area-inset-bottom, 0px)); }

  body.agency-customer .ym-mobile-bottom-nav a {
    min-width: 0;
    min-height: 58px;
    justify-content: flex-start;
    text-align: center;
  }

  body.agency-customer .ym-mobile-bottom-nav a > span {
    display: block;
    width: 100%;
    min-width: 0;
    min-height: 2.6em;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
    line-height: 1.3;
  }

  body.agency-admin .agency-admin-top { grid-template-columns: 44px minmax(0, 1fr) 44px; }
  body.agency-admin :is(.agency-menu-toggle, .agency-admin-profile) { width: 44px; min-width: 44px; min-height: 44px; }

  body.agency-admin .agency-sidebar { max-width: calc(100vw - 24px); }
  body.agency-admin :is(.agency-menu-group summary, .agency-submenu a, .agency-sidebar-bottom a) {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.5;
  }

  body.agency-admin .agency-menu-group summary > span { min-width: 0; }
  body.agency-admin .agency-menu-group summary > b { flex: none; }

  body.agency-admin :is(.ym-service-nav a, .ym-status-strip a, .ym-period-links a, .ym-admin-links span, .ym-legend, .ym-mix-labels > div, .agency-badge) {
    min-width: 0;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.5;
  }

  body.agency-admin :is(.ym-filter-actions, .ym-sheet-header, .agency-admin-footer) { flex-wrap: wrap; }
  body.agency-admin .ym-sheet-header > div { min-width: 0; flex-wrap: wrap; }
  body.agency-admin .ym-sheet-header button { min-height: 44px; white-space: normal; overflow-wrap: anywhere; }
  body.agency-admin .ym-sheet-close { min-width: 44px; }
  body.agency-admin .ym-mobile-admin-brand { min-width: 0; white-space: normal; overflow-wrap: anywhere; }
  body.agency-admin .ym-order-table .ym-money { white-space: normal; overflow-wrap: anywhere; }
  body.agency-admin .ym-bar-row { grid-template-columns: minmax(0, 85px) minmax(20px, 1fr) minmax(0, 42px); }
  body.agency-admin .ym-bar-row > span, body.agency-admin .ym-bar-row strong { overflow-wrap: anywhere; }
  body.agency-admin .ym-legend { flex-wrap: wrap; }

  body.agency-admin :is(.tbl_wrap, .tbl_frm01, .agency-table-scroll, .ym-data-scroll) {
    overflow-x: auto;
  }

  /* Existing enhanced member/order cards remain cards instead of becoming scrollers. */
  body.agency-admin #fmemberlist > .tbl_wrap,
  body.agency-admin [data-page="member_form"] .tbl_frm01 { overflow: visible; }
}

@media (min-width: 480px) and (max-width: 760px) {
  body.agency-customer #agency-main .agency-tabs,
  .ym-mobile-member .agency-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  /* Native select controls cannot wrap their selected label; give each filter a full row. */
  body.agency-admin #container .agency-admin-search {
    grid-template-columns: minmax(0, 1fr);
  }

  body.agency-admin #container .agency-admin-search :is(.ym-search-text, .ym-filter-actions) {
    grid-column: 1 / -1;
  }
}
