/* Shared responsive corrections. Root scope keeps lazy legacy styles from
   reintroducing fixed widths after navigating between workspaces. */
@media (min-width: 768px) {
  #root .ds-app-shell {
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  #root .ds-app-shell__sidebar {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  #root .ds-app-shell__main {
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scroll-padding-block: 20px 96px;
  }

  #root .app-layout {
    min-height: 100%;
  }

  #root .app-sidebar {
    height: 100%;
    min-height: 0;
    padding-block: 12px;
  }

  #root .app-sidebar__brand,
  #root .app-sidebar__store,
  #root .app-sidebar__user,
  #root .app-sidebar__logout {
    flex-shrink: 0;
  }

  #root .app-sidebar__nav-scroll {
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    scrollbar-width: none;
    -ms-overflow-style: none;
    touch-action: pan-y;
  }

  #root .app-sidebar__nav-scroll::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }

  #root .app-sidebar__nav-scroll .ds-sidebar-nav {
    overflow: visible;
  }
}

/* Preserve comfortable targets while spending less height on branding and
   group labels in a tablet's landscape viewport. Shorter windows can scroll. */
@media (min-width: 768px) and (orientation: landscape) and (max-height: 900px) {
  #root .app-sidebar {
    padding-block: 8px;
  }

  #root .app-sidebar__brand {
    padding-bottom: 7px;
    font-size: 17px;
    line-height: 1.2;
  }

  #root .app-sidebar__brand small {
    display: none;
  }

  #root .app-sidebar__store {
    padding-block: 7px;
  }

  #root .app-sidebar__store .ds-store-switcher__desktop > span,
  #root .app-sidebar__store label > span {
    display: none;
  }

  #root .ds-sidebar-nav__label {
    padding-block: 5px 3px;
    font-size: 10px;
    line-height: 1.2;
  }

  #root .ds-sidebar-nav__section {
    gap: 1px;
  }

  #root .app-sidebar__user {
    gap: 7px;
    padding-block: 5px;
  }

  #root .app-sidebar__avatar {
    width: 26px;
    height: 26px;
  }

  #root .app-sidebar__logout {
    margin-top: 4px;
  }
}

@media (min-width: 768px) and (orientation: landscape) and (max-height: 760px) {
  #root .ds-sidebar-nav__label {
    display: none;
  }

  #root .ds-sidebar-nav__section + .ds-sidebar-nav__section {
    padding-top: 5px;
  }
}

/* Management chrome and forms must fit their card, not inherit the ledger's
   former 780px minimum. Switch the side panel before it squeezes the ledger. */
#root .management-products__title-row,
#root .management-products__section-label,
#root .management-products__filters,
#root .management-products__new-form,
#root .management-products__new-help,
#root .management-products__derived-form,
#root .management-products__error,
#root .management-products__head,
#root .management-products__list {
  min-width: 0;
  max-width: 100%;
}

#root .management-products__title-row {
  gap: 12px;
  flex-wrap: wrap;
}

#root .management-products__new-toggle,
#root .management-products__row-actions > button {
  flex-shrink: 0;
  white-space: nowrap;
}

#root .management-products__filters > *,
#root .management-products__new-form > *,
#root .management-products__derived-form > * {
  min-width: 0;
  max-width: 100%;
}

#root .management-products__ledger-scroll {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 1439px) {
  #root .management-page__catalog {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 1023px) {
  #root .management-products__filters,
  #root .management-products__new-form,
  #root .management-products__derived-form,
  #root .management-products__details-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #root .management-products__new-form > .ds-checkbox-field {
    white-space: normal;
  }
}

@media (max-width: 639px) {
  #root .management-products__filters,
  #root .management-products__new-form,
  #root .management-products__derived-form,
  #root .management-products__details-fields {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Keep a useful detail width on tablets. Ledger cards depend on the actual
   detail container, including when a wider viewport has a list beside it. */
#root .prepaid-page,
#root .prepaid-page__detail,
#root .prepaid-page__detail-card,
#root .prepaid-page__ledger {
  min-width: 0;
}

#root .prepaid-page__ledger {
  container: prepaid-ledger / inline-size;
  max-width: 100%;
  max-height: none;
}

#root .prepaid-page__transaction-form,
#root .prepaid-page__detail-actions {
  flex-wrap: wrap;
}

/* The account list has a bounded scroll area; keep two-line cards from
   shrinking below their name and phone number when many accounts are loaded. */
#root .prepaid-page__account-list > * {
  flex-shrink: 0;
}

#root .prepaid-page__import-note {
  overflow-wrap: anywhere;
  white-space: normal;
}

@media (max-width: 1359px) {
  #root .prepaid-page--selected {
    grid-template-columns: minmax(0, 1fr);
  }

  #root .prepaid-page--selected .prepaid-page__account-list {
    max-height: 220px;
  }
}

@container prepaid-ledger (max-width: 1100px) {
  #root .prepaid-page__ledger-scroll {
    min-width: 0;
    overflow-x: visible;
  }

  #root .prepaid-page__ledger-head {
    display: none;
  }

  #root .prepaid-page__ledger-row {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) minmax(100px, auto);
    gap: 10px 16px;
    align-items: start;
    padding: 16px 18px;
  }

  #root .prepaid-page__ledger-row > div:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
    font-size: 12px;
  }

  #root .prepaid-page__ledger-row > div:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
    text-align: right;
  }

  #root .prepaid-page__ledger-row > div:nth-child(3) {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  #root .prepaid-page__ledger-row > div:nth-child(4) {
    grid-column: 1;
    grid-row: 2;
    text-align: left;
    font-size: 17px;
  }

  #root .prepaid-page__ledger-row > div:nth-child(5) {
    grid-column: 2;
    grid-row: 2;
    text-align: right;
    font-size: 13px;
  }

  #root .prepaid-page__ledger-row > div:nth-child(5)::before {
    content: '거래 당시 잔액';
    display: block;
    margin-bottom: 4px;
    color: var(--ds-color-text-muted);
    font-size: 11px;
    font-weight: 400;
  }

  #root .prepaid-page__ledger-row > div:nth-child(6) {
    grid-column: 1 / -1;
    grid-row: 4;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  #root .prepaid-history__changed-amount {
    justify-content: flex-start;
  }

  #root .prepaid-history__refunds {
    min-width: 0;
    padding-inline: 18px;
  }

  #root .prepaid-history__form {
    max-width: none;
  }

  #root .prepaid-page__charge-points label {
    justify-content: flex-end;
  }
}

/* Tables that retain columns advertise their internal horizontal scroll. */
@media (max-width: 820px) {
  #root .daily-ops__product-scroll::before {
    content: '가로로 밀어 전체 수량 항목을 확인하세요';
    display: block;
    position: sticky;
    left: 0;
    padding: 10px 12px;
    color: var(--ds-color-text-muted);
    font-size: 12px;
  }
}

@media (max-width: 900px) {
  #root .sales-page__flow-card::before {
    content: '가로로 밀어 전체 월을 확인하세요';
    display: block;
    position: sticky;
    left: 0;
    margin-bottom: 10px;
    color: var(--ds-color-text-muted);
    font-size: 12px;
  }
}

@media (max-width: 1279px) {
  #root .regulars-page__ledger-card::before {
    content: '가로로 밀어 전체 항목을 확인하세요';
    display: block;
    position: sticky;
    left: 0;
    padding: 10px 16px;
    color: var(--ds-color-text-muted);
    font-size: 12px;
  }
}

@media (max-width: 1023px) {
  #root .feedback-records::before {
    content: '가로로 밀어 상세 기록을 확인하세요';
    display: block;
    position: sticky;
    left: 0;
    padding: 10px 16px;
    color: var(--ds-color-text-muted);
    font-size: 12px;
  }
}

/* A landscape tablet is still a touch device even above desktop breakpoints. */
@media (pointer: coarse), (any-pointer: coarse) {
  #root .ds-app-shell button,
  #root .ds-app-shell select,
  #root .ds-app-shell input:not([type='checkbox']):not([type='radio']):not([type='hidden']),
  #root .ds-sidebar-nav a {
    min-height: 44px;
  }

  #root .ds-app-shell button {
    min-width: 44px;
  }

  #root .ds-app-shell input:not([type='checkbox']):not([type='radio']),
  #root .ds-app-shell select,
  #root .ds-app-shell textarea {
    font-size: 14px;
  }

  #root .ds-app-shell textarea {
    min-height: 88px;
  }

  #root .ds-app-shell label:has(> input[type='checkbox']),
  #root .ds-app-shell label:has(> input[type='radio']) {
    min-height: 44px;
    align-items: center;
  }

  #root .ds-app-shell input[type='checkbox'],
  #root .ds-app-shell input[type='radio'] {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

  #root .reservations-page__item-row {
    grid-template-columns: minmax(0, 1fr) 60px 44px;
  }

  #root .reservations-page__item-row--cutting {
    grid-template-columns: minmax(0, 1fr) 60px 82px 44px;
  }

  #root .reservations-page__item-row > * {
    min-width: 0;
  }
}
