/* ============================================================
 * _components.css - shared Konny admin design-system classes
 * ============================================================
 * 일본식 고밀도 웹(design-reset, 2026-10-23): 값은 전부 _design-tokens.css 의 --ds-* 토큰.
 * 부품 계약 — 버튼 변형 4(default · primary · ghost · danger) × 크기 2(28 · 22, --ds-control-h*),
 * 입력 1종 28px, 모서리 0, 그림자 0, 상태 7종(default · hover · focus · active · disabled · loading · error).
 * 네임스페이스(.ds-*)와 셀렉터 구조는 CCL 때 그대로 — 바뀐 것은 값과 상태 정의뿐이다.
 * 눈검증 기준은 /admin/design/catalog/ (superuser 전용) 의 카탈로그 페이지다.
 * ============================================================ */

:where(.ds-page-header) {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ds-space-4);
    margin: 0;
}

/* KN-302 후속: changelist 상단 제목 밴드는 우측 액션 버튼이 바로 아래 리스트와 붙지 않도록
   하단 여백을 둔다(상단 헤더 바 여백과 균형). changelist 외 .ds-page-header 사용처는 미영향. */
body.change-list .ds-page-header {
    margin-bottom: var(--ds-space-6);
}

:where(.ds-page-header__breadcrumb) {
    margin: 0 0 var(--ds-space-1);
    color: var(--ds-text-muted);
    font-size: var(--ds-font-size-sm);
    line-height: var(--ds-line-height-normal);
}

:where(.ds-page-header__title) {
    margin: 0;
    color: var(--ds-text-strong);
    font-size: var(--ds-font-size-2xl);
    font-weight: var(--ds-font-weight-bold);
    line-height: var(--ds-line-height-tight);
    letter-spacing: -0.01em;
}

:where(.ds-page-header__subtitle) {
    margin: var(--ds-space-2) 0 0;
    color: var(--ds-text-muted);
    font-size: var(--ds-font-size-base);
    line-height: var(--ds-line-height-relaxed);
}

:where(.ds-page-header__actions),
:where(.ds-toolbar) {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
}

/* ── 버튼 — 기본 28px(--ds-control-h) · 12px/500 · hairline-strong 상자 · 모서리 0 ─────────── */
:where(.ds-btn:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button)) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ds-space-1-5);
    box-sizing: border-box;
    min-height: var(--ds-control-h);
    padding: 0 var(--ds-space-2-5);
    border: 1px solid var(--ds-border-strong);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface-card);
    color: var(--ds-text-default);
    font-family: var(--ds-font-sans);
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-medium);
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background var(--ds-transition-fast), border-color var(--ds-transition-fast), color var(--ds-transition-fast), box-shadow var(--ds-transition-fast);
}

/* hover — 테두리와 글자만 레드 잉크, 채움 없음 */
:where(.ds-btn:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button):hover) {
    border-color: var(--ds-color-accent);
    color: var(--ds-color-accent-ink);
    background: var(--ds-surface-card);
}

/* active(누르는 중) — 레드 소프트 채움 */
:where(.ds-btn:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button):active) {
    background: var(--ds-color-accent-bg);
    border-color: var(--ds-color-accent);
    color: var(--ds-color-accent-ink);
}

/* 포커스 링은 :where() 로 감싸면 안 된다. 특이도가 0 이라 Unfold(Tailwind) preflight 가
   `*` 에 거는 box-shadow 리셋과 동률이 되고, 로드 순서상 나중인 쪽이 이겨 링이 사라진다.
   box-shadow 와 함께 outline 도 그린다 — outline 은 Tailwind 리셋 대상이 아니고
   강제 색 모드(forced-colors)에서도 남는다. */
.ds-btn:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button):focus-visible,
.ds-input:focus,
.ds-select:focus,
.ds-textarea:focus,
.ds-tabs__tab:focus-visible {
    outline: 2px solid var(--ds-color-accent);
    outline-offset: 1px;
    box-shadow: var(--ds-ring-focus);
}

/* disabled — 흐리게 하지 않고 재질을 바꾼다: 회색 띠 채움 + hairline + muted 글자 (대비 7.5:1 유지) */
:where(.ds-btn:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button):disabled),
:where(.ds-btn:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button)[aria-disabled="true"]),
:where(.ds-btn:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button).is-disabled) {
    opacity: 1;
    background: var(--ds-surface-strong);
    border-color: var(--ds-border-default);
    color: var(--ds-text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* 채움 버튼(primary/danger)의 비활성도 같은 회색 띠 — 채움을 걷어 활성처럼 보이지 않게 한다. */
.ds-btn--primary:not(.styledeck-bulkbar-anchor):not(.unfold-button):disabled,
.ds-btn--primary:not(.styledeck-bulkbar-anchor):not(.unfold-button)[aria-disabled="true"],
.ds-btn--primary:not(.styledeck-bulkbar-anchor):not(.unfold-button).is-disabled,
.ds-btn--danger:not(.styledeck-bulkbar-anchor):not(.unfold-button):disabled,
.ds-btn--danger:not(.styledeck-bulkbar-anchor):not(.unfold-button)[aria-disabled="true"],
.ds-btn--danger:not(.styledeck-bulkbar-anchor):not(.unfold-button).is-disabled {
    opacity: 1;
    background: var(--ds-surface-strong);
    border-color: var(--ds-border-default);
    color: var(--ds-text-muted);
    cursor: not-allowed;
    box-shadow: none;
}

/* loading — 라벨을 숨기고 레드 스피너. 폭은 유지한다. 색 규칙은 변형(primary/danger) 뒤에 둔다(아래). */
:where(.ds-btn:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button).is-loading)::after {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid var(--ds-color-accent-bg);
    border-top-color: var(--ds-color-accent);
    border-radius: var(--ds-radius-pill);
    content: "";
    animation: ds-spin 800ms linear infinite;
}

/* primary — 유틸리티 레드 채움. 한 화면에 하나. */
:where(.ds-btn--primary:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button)) {
    border-color: var(--ds-color-accent);
    background: var(--ds-color-accent);
    color: var(--ds-text-inverse);
}

:where(.ds-btn--primary:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button):hover),
:where(.ds-btn--primary:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button):active) {
    border-color: var(--ds-color-accent-hover);
    background: var(--ds-color-accent-hover);
    color: var(--ds-text-inverse);
}

:where(.ds-btn--primary:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button).is-loading)::after {
    border-color: var(--ds-color-accent-bg);
    border-top-color: var(--ds-text-inverse);
}

/* ghost — 테두리 없음. hover 에서만 레드 테두리가 나타난다(기본 hover 상속). */
:where(.ds-btn--ghost:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button)) {
    border-color: transparent;
    background: transparent;
}

/* danger — 자주색 윤곽. 레드(액센트)와 섞이지 않는다. */
:where(.ds-btn--danger:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button)) {
    border-color: var(--ds-status-danger-border);
    background: var(--ds-status-danger-bg);
    color: var(--ds-status-danger-fg);
}

:where(.ds-btn--danger:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button):hover),
:where(.ds-btn--danger:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button):active) {
    border-color: var(--ds-status-danger-fg);
    background: var(--ds-status-danger-bg);
    color: var(--ds-status-danger-fg);
}

/* loading 색 — primary/danger 의 color 보다 뒤에 와야 라벨이 숨는다(:where 라 순서가 결정). */
:where(.ds-btn:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button).is-loading) {
    color: transparent;
    pointer-events: none;
    position: relative;
}

:where(.ds-btn--icon:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button)) {
    width: var(--ds-control-h);
    padding: 0;
}

/* 작은 크기 22px — 표 안 · 칩 옆. (_shell.css 의 :where(.ds-btn--sm) 과 같은 값, 여기서 먼저 정의) */
:where(.ds-btn--sm:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button)) {
    min-height: var(--ds-control-h-sm);
    padding: 0 var(--ds-space-1-5);
    font-size: var(--ds-font-size-xs);
}

:where(.ds-btn--icon.ds-btn--sm:not(.styledeck-bulkbar-anchor):not(.tabulator-row .tabulator-cell):not(.has-msku-data-action):not(.unfold-button)) {
    width: var(--ds-control-h-sm);
}

/* ── 입력 — 1종 28px · hairline-strong · 모서리 0 ────────────────────────────── */
:where(.ds-input),
:where(.ds-select),
:where(.ds-textarea) {
    box-sizing: border-box;
    width: 100%;
    min-height: var(--ds-control-h);
    border: 1px solid var(--ds-border-strong);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface-card);
    color: var(--ds-text-strong);
    font-family: var(--ds-font-sans);
    font-size: var(--ds-font-size-sm);
    line-height: var(--ds-line-height-tight);
    transition: border-color var(--ds-transition-fast), box-shadow var(--ds-transition-fast);
}

:where(.ds-input),
:where(.ds-select) {
    padding: 0 var(--ds-space-2);
}

:where(.ds-textarea) {
    min-height: 92px;
    padding: var(--ds-space-2);
    line-height: var(--ds-line-height-normal);
    resize: vertical;
}

:where(.ds-input:hover),
:where(.ds-select:hover),
:where(.ds-textarea:hover) {
    border-color: var(--ds-text-muted);
}

:where(.ds-input)::placeholder,
:where(.ds-textarea)::placeholder {
    color: var(--ds-text-faint);
}

:where(.ds-input:disabled),
:where(.ds-select:disabled),
:where(.ds-textarea:disabled),
:where(.ds-input[readonly]) {
    background: var(--ds-surface-strong);
    border-color: var(--ds-border-default);
    color: var(--ds-text-muted);
    cursor: not-allowed;
}

/* error — 자주색 테두리 2겹(1px 테두리 + 1px 링) */
:where(.ds-input[aria-invalid="true"]),
:where(.ds-select[aria-invalid="true"]),
:where(.ds-textarea[aria-invalid="true"]),
:where(.ds-form-row.is-error .ds-input),
:where(.ds-form-row.is-error .ds-select),
:where(.ds-form-row.is-error .ds-textarea) {
    border-color: var(--ds-status-danger-fg);
    box-shadow: 0 0 0 1px var(--ds-status-danger-fg);
}

:where(.ds-form-row) {
    display: grid;
    gap: var(--ds-space-3) var(--ds-space-4);
    align-items: start;
}

:where(.ds-form-row:has(.ds-form-row__label, .ds-form-row__control)) {
    grid-template-columns: minmax(140px, 220px) minmax(0, 1fr);
}

:where(.ds-form-row__label) {
    color: var(--ds-text-strong);
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-semibold);
    line-height: var(--ds-line-height-normal);
}

:where(.ds-form-row__control) {
    min-width: 0;
}

:where(.ds-form-row__help),
:where(.ds-form-row__error) {
    margin-top: var(--ds-space-1-5);
    font-size: var(--ds-font-size-sm);
    line-height: var(--ds-line-height-normal);
}

:where(.ds-form-row__help) {
    color: var(--ds-text-muted);
}

:where(.ds-form-row__error) {
    color: var(--ds-status-danger-fg);
}

/* ── 배지 — 투명 바탕 + currentColor 1px 윤곽 · 18px · 11px/600 · 모서리 0 ─────────────
   색은 상태 토큰 5종만. 채움 배지는 화면이 명시적으로 고를 때만(.ds-badge--fill). */
:where(.ds-badge:not(.msku-badge):not(.msku-queue__badge):not(.styledeck-status):not(.styledeck-badge)) {
    display: inline-flex;
    align-items: center;
    gap: var(--ds-space-1);
    box-sizing: border-box;
    min-height: 18px;
    padding: 0 var(--ds-space-1-5);
    border: 1px solid currentColor;
    border-radius: var(--ds-radius-sm);
    background: transparent;
    color: var(--ds-text-muted);
    font-size: var(--ds-font-size-xs);
    font-weight: var(--ds-font-weight-semibold);
    line-height: 1;
    white-space: nowrap;
}

:where(.ds-badge--green:not(.msku-badge):not(.msku-queue__badge):not(.styledeck-status):not(.styledeck-badge)) { color: var(--ds-status-success-fg); }
:where(.ds-badge--red:not(.msku-badge):not(.msku-queue__badge):not(.styledeck-status):not(.styledeck-badge)) { color: var(--ds-status-danger-fg); }
:where(.ds-badge--yellow:not(.msku-badge):not(.msku-queue__badge):not(.styledeck-status):not(.styledeck-badge)) { color: var(--ds-status-warning-fg); }
:where(.ds-badge--blue:not(.msku-badge):not(.msku-queue__badge):not(.styledeck-status):not(.styledeck-badge)) { color: var(--ds-status-info-fg); }
:where(.ds-badge--gray:not(.msku-badge):not(.msku-queue__badge):not(.styledeck-status):not(.styledeck-badge)) { color: var(--ds-text-muted); }
:where(.ds-badge--purple:not(.msku-badge):not(.msku-queue__badge):not(.styledeck-status):not(.styledeck-badge)) { color: var(--ds-status-info-fg); }

/* 채움 변형 — 「여기부터」 표식(레드) 과 확정 표식(검정). 윤곽 배지와 같은 치수. */
:where(.ds-badge--fill) {
    border-color: var(--ds-color-accent);
    background: var(--ds-color-accent);
    color: var(--ds-text-inverse);
}

:where(.ds-badge--fill-ink) {
    border-color: var(--ds-surface-inverse);
    background: var(--ds-surface-inverse);
    color: var(--ds-text-inverse);
}

:where(.ds-status-dot) {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: var(--ds-radius-pill);
    background: currentColor;
}

:where(.ds-counter-strip:not(.msku-counters):not(.msku-sla-counters)) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--ds-space-3);
    margin: 0 0 var(--ds-space-5);
}

:where(.ds-counter-strip__item:not(.msku-counter):not(.msku-sla-counter)) {
    min-height: 64px;
    padding: var(--ds-space-3) var(--ds-space-4);
    border: 1px solid var(--ds-border-default);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-card);
    color: var(--ds-text-default);
    text-decoration: none;
}

:where(.ds-counter-strip__num:not(.msku-counter__num)) {
    display: block;
    color: var(--ds-color-accent);
    font-family: var(--ds-font-mono);
    font-size: var(--ds-font-size-2xl);
    font-weight: var(--ds-font-weight-semibold);
    font-variant-numeric: tabular-nums lining-nums;
    font-feature-settings: "tnum" 1, "zero" 1;
    line-height: var(--ds-line-height-tight);
}

:where(.ds-counter-strip__label:not(.msku-counter__label)) {
    display: block;
    margin-top: var(--ds-space-1);
    color: var(--ds-text-muted);
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-medium);
}

:where(.ds-stepper) {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ds-space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

:where(.ds-stepper__step) {
    display: inline-flex;
    align-items: center;
    gap: var(--ds-space-2);
    color: var(--ds-text-muted);
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-semibold);
}

:where(.ds-stepper__step.is-current) {
    color: var(--ds-color-accent-ink);
}

:where(.ds-stepper__step.is-done) {
    color: var(--ds-status-success-fg);
}

/* ── 탭 — 36px · 활성은 레드 밑줄 2px + 잉크 글자 ───────────────────────────── */
:where(.ds-tabs:not(.msku-queue__tabs)) {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 1px solid var(--ds-border-strong);
}

:where(.ds-tabs__tab:not(.msku-queue__tab)) {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 var(--ds-space-3);
    border: 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    background: transparent;
    color: var(--ds-text-muted);
    font-family: var(--ds-font-sans);
    font-size: var(--ds-font-size-base);
    font-weight: var(--ds-font-weight-semibold);
    text-decoration: none;
    cursor: pointer;
}

:where(.ds-tabs__tab:not(.msku-queue__tab):hover) {
    color: var(--ds-text-strong);
}

.ds-tabs__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    margin-left: var(--ds-space-1-5);
    padding: 0 var(--ds-space-1);
    border-radius: var(--ds-radius-pill);
    font-family: var(--ds-font-mono);
    font-size: var(--ds-font-size-xs);
    font-weight: var(--ds-font-weight-semibold);
    line-height: 1;
    font-variant-numeric: tabular-nums;
    background: var(--ds-surface-strong);
    color: var(--ds-text-muted);
    border: 1px solid var(--ds-border-strong);
}

.ds-tabs__tab.is-current .ds-tabs__count,
.ds-tabs__tab[aria-current="page"] .ds-tabs__count,
.ds-tabs__tab[aria-selected="true"] .ds-tabs__count {
    background: var(--ds-color-accent);
    color: var(--ds-text-inverse);
    border-color: var(--ds-color-accent);
}

:where(.ds-tabs__tab:not(.msku-queue__tab).is-current),
:where(.ds-tabs__tab:not(.msku-queue__tab)[aria-selected="true"]),
:where(.ds-tabs__tab:not(.msku-queue__tab)[aria-current="page"]) {
    border-bottom-color: var(--ds-color-accent);
    color: var(--ds-text-strong);
}

/* ── 툴팁 — 검정 종이에 흰 글자, 모서리 0 ─────────────────────────────────── */
:where(.ds-tooltip) {
    position: relative;
}

:where(.ds-tooltip)::after {
    position: absolute;
    right: 0;
    bottom: calc(100% + var(--ds-space-1));
    z-index: var(--ds-z-dropdown);
    max-width: 220px;
    padding: var(--ds-space-1-5) var(--ds-space-2);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-inverse);
    color: var(--ds-text-inverse);
    font-size: var(--ds-font-size-sm);
    line-height: var(--ds-line-height-normal);
    opacity: 0;
    pointer-events: none;
    content: attr(data-tooltip);
    transform: translateY(4px);
    transition: opacity var(--ds-transition-fast), transform var(--ds-transition-fast);
}

:where(.ds-tooltip:hover)::after,
:where(.ds-tooltip:focus-within)::after {
    opacity: 1;
    transform: translateY(0);
}

/* ── 표 — 세로 · 가로 hairline 전체 격자 · 회색 띠 머리 ────────────────────── */
:where(.ds-table:not(.result-list):not(.sku-table):not(.styledeck-table):not(.sd-cmp-table):not(.bulk-import-table):not(.msku-comp-table):not(.um-table):not(.um-preview-table)) {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--ds-text-default);
    font-size: var(--ds-font-size-base);
}

:where(.ds-table--bordered:not(.result-list):not(.sku-table):not(.styledeck-table):not(.sd-cmp-table):not(.bulk-import-table):not(.msku-comp-table):not(.um-table):not(.um-preview-table)) {
    border: 1px solid var(--ds-border-default);
    border-radius: var(--ds-radius-lg);
    overflow: hidden;
}

:where(.ds-table--compact:not(.um-preview-table) .ds-table__cell),
:where(.ds-table--compact:not(.um-preview-table) td),
:where(.ds-table--compact:not(.um-preview-table) th) {
    padding: var(--ds-space-1) var(--ds-space-2);
}

:where(.ds-table__header),
:where(.ds-table:not(.result-list):not(.sku-table):not(.styledeck-table):not(.sd-cmp-table):not(.bulk-import-table):not(.msku-comp-table):not(.um-table):not(.um-preview-table) thead th) {
    background: var(--ds-tabulator-header-bg);
    color: var(--ds-text-strong);
    font-size: var(--ds-font-size-xs);
    font-weight: var(--ds-font-weight-semibold);
    letter-spacing: 0.02em;
}

:where(.ds-table__row),
:where(.ds-table:not(.result-list):not(.sku-table):not(.styledeck-table):not(.sd-cmp-table):not(.bulk-import-table):not(.msku-comp-table):not(.um-table):not(.um-preview-table) tbody tr) {
    background: var(--ds-surface-card);
}

:where(.ds-table__cell),
:where(.ds-table:not(.result-list):not(.sku-table):not(.styledeck-table):not(.sd-cmp-table):not(.bulk-import-table):not(.msku-comp-table):not(.um-table):not(.um-preview-table) td),
:where(.ds-table:not(.result-list):not(.sku-table):not(.styledeck-table):not(.sd-cmp-table):not(.bulk-import-table):not(.msku-comp-table):not(.um-table):not(.um-preview-table) th) {
    padding: var(--ds-space-1-5) var(--ds-space-2);
    border-bottom: 1px solid var(--ds-border-default);
    border-right: 1px solid var(--ds-border-default);
    text-align: left;
}

:where(.ds-table:not(.result-list):not(.sku-table):not(.styledeck-table):not(.sd-cmp-table):not(.bulk-import-table):not(.msku-comp-table):not(.um-table):not(.um-preview-table) td:last-child),
:where(.ds-table:not(.result-list):not(.sku-table):not(.styledeck-table):not(.sd-cmp-table):not(.bulk-import-table):not(.msku-comp-table):not(.um-table):not(.um-preview-table) th:last-child) {
    border-right: 0;
}

/* ── 빈 상태 — 상자 속 상자가 아니라 한 판: hairline 테두리 · 흰 바탕 · muted 글자 ── */
:where(.ds-empty-state:not(.msku-empty):not(.msku-comp-empty):not(.bulk-import-empty):not(.styledeck-empty)) {
    padding: var(--ds-space-8);
    border: 1px solid var(--ds-border-default);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-card);
    color: var(--ds-text-muted);
    text-align: center;
}

:where(.ds-empty-state__title) {
    margin: 0;
    color: var(--ds-text-strong);
    font-size: var(--ds-font-size-lg);
    font-weight: var(--ds-font-weight-semibold);
}

:where(.ds-empty-state__body) {
    margin: var(--ds-space-2) 0 0;
    line-height: var(--ds-line-height-relaxed);
}

:where(.ds-modal),
:where(.ds-drawer) {
    position: fixed;
    inset: 0;
    z-index: var(--ds-z-modal);
}

:where(.ds-modal__panel),
:where(.ds-drawer__panel) {
    border: 1px solid var(--ds-border-strong);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-card);
}

:where(.ds-help-panel) {
    border: 1px solid var(--ds-border-default);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-card);
    color: var(--ds-text-default);
}

:where(.ds-help-panel__title) {
    color: var(--ds-text-strong);
    font-weight: var(--ds-font-weight-semibold);
}

/* ── 알림 — 상태 토큰 윤곽 + 소프트 채움, 모서리 0 ────────────────────────── */
:where(.ds-alert) {
    padding: var(--ds-space-2) var(--ds-space-3);
    border: 1px solid var(--ds-border-strong);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-card);
    color: var(--ds-text-default);
    font-size: var(--ds-font-size-sm);
    line-height: var(--ds-line-height-normal);
}

:where(.ds-alert-stack) {
    display: grid;
    gap: var(--ds-space-2);
    margin: var(--ds-space-3) 0;
}

:where(.ds-alert--error) {
    border-color: var(--ds-status-danger-border);
    background: var(--ds-status-danger-bg);
    color: var(--ds-status-danger-fg);
}

:where(.ds-alert--warning) {
    border-color: var(--ds-status-warning-border);
    background: var(--ds-status-warning-bg);
    color: var(--ds-status-warning-fg);
}

:where(.ds-alert--info) {
    border-color: var(--ds-status-info-border);
    background: var(--ds-status-info-bg);
    color: var(--ds-status-info-fg);
}

:where(.ds-alert--success) {
    border-color: var(--ds-status-success-border);
    background: var(--ds-status-success-bg);
    color: var(--ds-status-success-fg);
}

@keyframes ds-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 767px) {
    :where(.ds-page-header) {
        flex-direction: column;
    }

    :where(.ds-form-row:has(.ds-form-row__label, .ds-form-row__control)) {
        grid-template-columns: 1fr;
    }
}

/* ────────────────────────────────────────────────────────────────
 * .ds-dropdown — KN-142
 * <details>/<summary> 기반 드롭다운. 트리거는 .ds-btn 모양, 메뉴는 강조 hairline 패널(그림자 없음).
 * 키보드(Enter/Space)·포커스는 <details> 네이티브, 외부 클릭/Esc 닫기는 msku_states.js 가 보강.
 * ──────────────────────────────────────────────────────────────── */
:where(.ds-dropdown) {
    position: relative;
    display: inline-block;
}

/* summary 기본 디스클로저 마커 제거 — 트리거는 .ds-btn 모양 유지 */
:where(.ds-dropdown__trigger) {
    list-style: none;
    cursor: pointer;
}

.ds-dropdown__trigger::-webkit-details-marker {
    display: none;
}

:where(.ds-dropdown[open] > .ds-dropdown__trigger) {
    border-color: var(--ds-color-accent);
    color: var(--ds-color-accent-ink);
}

:where(.ds-dropdown__caret) {
    margin-left: var(--ds-space-1);
    font-size: var(--ds-font-size-xs);
}

:where(.ds-dropdown__menu) {
    position: absolute;
    top: calc(100% + var(--ds-space-1));
    /* 툴바 우측 액션에 주로 쓰이므로 트리거 우측 기준 정렬(화면 밖으로 넘치지 않게). */
    right: 0;
    z-index: var(--ds-z-dropdown);
    min-width: 100%;
    padding: var(--ds-space-1);
    border: 1px solid var(--ds-border-strong);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface-card);
    white-space: nowrap;
}

:where(.ds-dropdown__item) {
    display: block;
    padding: var(--ds-space-1-5) var(--ds-space-2-5);
    border-radius: var(--ds-radius-sm);
    color: var(--ds-text-default);
    font-size: var(--ds-font-size-sm);
    text-decoration: none;
}

:where(.ds-dropdown__item:hover) {
    background: var(--ds-surface-soft);
    color: var(--ds-text-strong);
}

:where(.ds-dropdown__item:focus-visible) {
    outline: 2px solid var(--ds-color-accent);
    outline-offset: -2px;
}

/* ────────────────────────────────────────────────────────────────
 * .ds-num    : 측정 글씨(숫자·코드) — Red Hat Mono · tabular · 슬래시 제로 · 우측 정렬.
 * .ds-ledger : 원장 테이블 — 회색 띠 sticky 머리 + 세로·가로 hairline 전체 격자 + 행 hover 안개 +
 *              활성 행 레드 소프트 채움 + 좌측 2px 레드 커서. 줄무늬(zebra)는 없다 — 격자가 그 일을 한다.
 * ──────────────────────────────────────────────────────────────── */
:where(.ds-num) {
    font-family: var(--ds-font-mono);
    font-variant-numeric: tabular-nums lining-nums;
    font-feature-settings: "tnum" 1, "lnum" 1, "zero" 1;
    text-align: right;
}

/* 코드처럼 mono·tabular 는 쓰되 우측 정렬은 원치 않는 인라인 숫자용 */
:where(.ds-num--inline) {
    text-align: inherit;
}

:where(.ds-ledger) {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--ds-text-default);
    font-size: var(--ds-font-size-base);
}

:where(.ds-ledger thead th) {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: var(--ds-space-1-5) var(--ds-space-2);
    background: var(--ds-surface-strong);
    color: var(--ds-text-strong);
    font-size: var(--ds-font-size-xs);
    font-weight: var(--ds-font-weight-semibold);
    letter-spacing: 0.02em;
    text-align: left;
    border-bottom: 1px solid var(--ds-border-strong);
    border-right: 1px solid var(--ds-border-default);
}

:where(.ds-ledger tbody td),
:where(.ds-ledger tbody th) {
    height: var(--ds-row-h-list);
    padding: var(--ds-space-1) var(--ds-space-2);
    border-bottom: 1px solid var(--ds-border-default);
    border-right: 1px solid var(--ds-border-default);
}

:where(.ds-ledger th:last-child),
:where(.ds-ledger td:last-child) {
    border-right: 0;
}

:where(.ds-ledger tbody tr) {
    background: var(--ds-surface-card);
}

:where(.ds-ledger tbody tr:hover) {
    background: var(--ds-surface-soft);
}

/* 활성 행 = 레드 소프트 채움 + 좌측 2px 레드 커서 */
:where(.ds-ledger tbody tr.is-active),
:where(.ds-ledger tbody tr[aria-selected="true"]) {
    background: var(--ds-surface-selected);
    box-shadow: inset 2px 0 0 0 var(--ds-color-accent);
}

/* compact 변형 = 28px 행 */
:where(.ds-ledger--compact tbody td),
:where(.ds-ledger--compact tbody th) {
    height: var(--ds-row-h-sub);
    padding: var(--ds-space-0-5) var(--ds-space-2);
}

/* ────────────────────────────────────────────────────────────────
 * 표준 changelist(#result_list) 원장화 — Django/Unfold 기본 changelist 테이블은
 * .ds-ledger 클래스를 못 다므로 #result_list 를 직접 원장 처리. 전역 로드(base.html)라
 * 모든 표준 masters changelist 가 한 번에 격자 룩을 받는다.
 * - 매칭 SKU(matching_skus.css)는 동일 규칙을 자체 보유·후행 로드 → 우선.
 *   카테고리 트리(.category-tree-row)는 계층 색을 따로 쓰므로 행 단위 규칙에서 제외.
 * ──────────────────────────────────────────────────────────────── */
#changelist #result_list thead th {
    background: var(--ds-surface-strong);
    color: var(--ds-text-strong);
    font-size: var(--ds-font-size-xs);
    font-weight: var(--ds-font-weight-semibold);
    letter-spacing: 0.02em;
    border-bottom: 1px solid var(--ds-border-strong);
    border-right: 1px solid var(--ds-border-default);
}

#changelist #result_list tbody td,
#changelist #result_list tbody th {
    border-right: 1px solid var(--ds-border-default);
}

#changelist #result_list thead th:last-child,
#changelist #result_list tbody td:last-child,
#changelist #result_list tbody th:last-child {
    border-right: 0;
}

/* hover 행 = 안개 채움(커서 없음) */
#changelist #result_list tbody tr:not(.category-tree-row):hover {
    background: var(--ds-surface-soft);
}

/* 선택 행(액션 체크) = 레드 소프트 + 좌측 2px 레드 커서 */
#changelist #result_list tbody tr.selected:not(.category-tree-row) {
    background: var(--ds-surface-selected);
    box-shadow: inset 2px 0 0 0 var(--ds-color-accent);
}

/* 숫자·코드 셀 = Red Hat Mono(tabular + 슬래시 제로). 헤더 좌측정렬 유지를
   위해 정렬은 건드리지 않고 글꼴만 교체.
   td 한정 제거: Django 는 링크 컬럼(list_display 첫 열, 예: Size 의 code)을
   <th scope="row"> 로 렌더하므로 td 만 잡으면 코드열을 놓침. body 셀은 td/th
   모두 .field-* 를 달고, thead 는 .column-* 라 헤더와 충돌 없음. */
#changelist #result_list .field-code,
#changelist #result_list .field-style_code,
#changelist #result_list .field-category_code,
#changelist #result_list .field-sku_code,
#changelist #result_list .field-gtin13,
#changelist #result_list .field-id,
#changelist #result_list .field-sort_order,
#changelist #result_list .field-decimal_places,
#changelist #result_list .field-used_sku_count,
#changelist #result_list .field-rate_to_krw,
#changelist #result_list .field-start_at,
#changelist #result_list .field-end_at,
#changelist #result_list .field-effective_from,
#changelist #result_list .field-sequence,
#changelist #result_list .field-planned_qty,
#changelist #result_list .field-before_qty,
#changelist #result_list .field-after_qty {
    font-family: var(--ds-font-mono);
    font-variant-numeric: tabular-nums lining-nums;
    font-feature-settings: "tnum" 1, "lnum" 1, "zero" 1;
}

/* ────────────────────────────────────────────────────────────────
 * 행 31px · 셀 13px 전 changelist 강제 (기준정보 critique 2026-08-28)
 * 기준정보 관리 14개 changelist 가 45~73px 로 제각각이라 원장 규격을
 * #result_list 한 곳에서 못 박는다. 카테고리 트리행도 예외 없음.
 * ──────────────────────────────────────────────────────────────── */
#changelist #result_list tbody td,
#changelist #result_list tbody th {
    height: var(--ds-row-h-list);
    padding-top: var(--ds-space-1);
    padding-bottom: var(--ds-space-1);
    font-size: var(--ds-font-size-base);
    line-height: 1.45;
    vertical-align: middle;
    /* 원장 행은 한 줄 — 긴 값은 줄바꿈 대신 말줄임(전체 값은 상세 화면). 표 폭이
       뷰포트를 넘지 않도록 셀 상한 300px */
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}
#changelist #result_list thead th { padding-top: 5px; padding-bottom: 5px; }

/* list_editable 입력/셀렉트는 26px 로 축소해 편집 행도 31px 안에 */
#changelist #result_list tbody input:not([type="checkbox"]),
#changelist #result_list tbody select {
    height: 26px;
    min-height: 26px;
    padding-top: 2px;
    padding-bottom: 2px;
    font-size: var(--ds-font-size-base);
}

/* Unfold 불리언 아이콘(h-6 w-6)이 행 높이를 밀지 않게 */
#changelist #result_list tbody .field-is_active > div,
#changelist #result_list tbody [class*="field-"] > .inline-flex { height: 20px; width: 20px; }

/* 스타일/이름 계열 긴 텍스트 셀 — 한 줄 말줄임 */
#changelist #result_list .field-style,
#changelist #result_list .field-name_display,
#changelist #result_list .field-sku_name_display {
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 불리언 1종: 점 + 텍스트(색만으로 의미 전달 금지) */
.ds-bool { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ds-bool::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: var(--ds-radius-pill);
    background: var(--ds-status-neutral-fg);
    flex: none;
}
.ds-bool--on::before { background: var(--ds-status-success-fg); }

/* a11y: 아이콘 폰트 faint → muted. 정렬 화살표·검색·more 아이콘 */
#changelist .material-symbols-outlined.text-base-400,
#changelist .material-symbols-outlined.text-base-500 { color: var(--ds-text-muted); }

/* a11y: 전역 focus-visible 링 — 브라우저 기본 대신 레드 2px.
   ds-btn/ds-input 계열은 이미 --ds-ring-focus 를 쓰므로 제외(이중 링 방지). */
:where(a, button, input, select, textarea, summary, [tabindex]):where(:not(.ds-btn, .ds-input, .ds-select, .ds-textarea, .ds-tabs__tab)):focus-visible {
    outline: 2px solid var(--ds-color-accent);
    outline-offset: 1px;
}

/* ────────────────────────────────────────────────────────────────
 * .ds-op — 시트 작업 줄(sheet-operation-progress). 구글 시트 작업의 진행 · 결과 한 줄.
 * ds-sheet-op.js 가 그린다. 상태 4색의 글자 · 바탕 · 테두리 3값만 쓰고 레드(「여기부터」)는 쓰지 않는다.
 * 1행 = 28px 부품 + 6/6 padding(시트 바 높이), 2행 = 단계 칩 28px. 모서리 · 그림자 0.
 * ──────────────────────────────────────────────────────────────── */
:where(.ds-op) {
    --ds-op-fg: var(--ds-text-muted);
    --ds-op-bg: var(--ds-surface-card);
    --ds-op-border: var(--ds-border-default);
    border: 1px solid var(--ds-op-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-op-bg);
    color: var(--ds-text-default);
    font-size: var(--ds-font-size-sm);
    line-height: var(--ds-line-height-tight);
}

:where(.ds-op--idle) {
    --ds-op-bg: transparent;
    --ds-op-border: transparent;
    color: var(--ds-text-muted);
}

:where(.ds-op--idle:empty) {
    display: none;
}

:where(.ds-op--info) {
    --ds-op-fg: var(--ds-status-info-fg);
    --ds-op-bg: var(--ds-status-info-bg);
    --ds-op-border: var(--ds-status-info-border);
}

/* 다른 사람 작업 중 — 정보 윤곽만(종이 바탕) */
:where(.ds-op--other) {
    --ds-op-fg: var(--ds-status-info-fg);
    --ds-op-bg: var(--ds-surface-card);
    --ds-op-border: var(--ds-status-info-border);
}

:where(.ds-op--success) {
    --ds-op-fg: var(--ds-status-success-fg);
    --ds-op-bg: var(--ds-status-success-bg);
    --ds-op-border: var(--ds-status-success-border);
}

:where(.ds-op--warning) {
    --ds-op-fg: var(--ds-status-warning-fg);
    --ds-op-bg: var(--ds-status-warning-bg);
    --ds-op-border: var(--ds-status-warning-border);
}

:where(.ds-op--danger) {
    --ds-op-fg: var(--ds-status-danger-fg);
    --ds-op-bg: var(--ds-status-danger-bg);
    --ds-op-border: var(--ds-status-danger-border);
}

:where(.ds-op__row) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ds-space-1-5) var(--ds-space-2);
    min-height: calc(var(--ds-control-h) + 2 * var(--ds-space-1-5));
    padding: var(--ds-space-1-5) var(--ds-space-2);
}

:where(.ds-op--idle .ds-op__row) {
    min-height: var(--ds-row-h-sub);
    padding: 0;
}

:where(.ds-op__mark) {
    display: inline-block;
    flex: none;
    width: var(--ds-space-3-5);
    height: var(--ds-space-3-5);
}

:where(.ds-op__mark--spin) {
    border: 2px solid var(--ds-op-fg);
    border-right-color: transparent;
    border-radius: var(--ds-radius-pill);
    animation: ds-spin 800ms linear infinite;
}

:where(.ds-op__mark--dot) {
    width: var(--ds-space-2);
    height: var(--ds-space-2);
    margin: calc((var(--ds-space-3-5) - var(--ds-space-2)) / 2);
    border-radius: var(--ds-radius-pill);
    background: var(--ds-op-fg);
}

:where(.ds-op__name) {
    color: var(--ds-op-fg);
    font-size: var(--ds-font-size-base);
    font-weight: var(--ds-font-weight-bold);
}

:where(.ds-op__sep) {
    color: var(--ds-text-faint);
}

:where(.ds-op__step, .ds-op__msg) {
    font-size: var(--ds-font-size-sm);
    font-weight: var(--ds-font-weight-medium);
}

/* 막대 — <progress>. 220 × 8, 건수가 있는 단계에서만.
   preflight 의 progress 초기화를 이겨야 해서 :where() 로 감싸지 않는다. */
.ds-op__meter {
    flex: none;
    width: 220px;
    height: var(--ds-space-2);
    border: 1px solid var(--ds-op-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface-card);
    color: var(--ds-op-fg);
    vertical-align: middle;
    appearance: none;
    -webkit-appearance: none;
}

.ds-op__meter::-webkit-progress-bar {
    background: var(--ds-surface-card);
}

.ds-op__meter::-webkit-progress-value {
    background: var(--ds-op-fg);
}

.ds-op__meter::-moz-progress-bar {
    background: var(--ds-op-fg);
}

:where(.ds-op__num) {
    font-family: var(--ds-font-mono);
    font-size: var(--ds-font-size-base);
    font-weight: var(--ds-font-weight-semibold);
    font-feature-settings: "tnum", "zero";
}

:where(.ds-op__faint) {
    color: var(--ds-text-faint);
    font-size: var(--ds-font-size-xs);
    font-weight: var(--ds-font-weight-semibold);
}

:where(.ds-op__faint--end) {
    margin-left: auto;
}

:where(.ds-op__act) {
    display: flex;
    gap: var(--ds-space-1-5);
    margin-left: auto;
}

/* 단계 칩 — ul 초기화(preflight)를 이겨야 해서 :where() 로 감싸지 않는다. */
.ds-op__steps {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ds-space-1) var(--ds-space-3-5);
    min-height: var(--ds-row-h-sub);
    margin: 0;
    padding: 0 var(--ds-space-2) var(--ds-space-1-5) calc(2 * var(--ds-space-2) + var(--ds-space-3-5));
    list-style: none;
    font-size: var(--ds-font-size-xs);
    font-weight: var(--ds-font-weight-semibold);
}

.ds-op__steps[hidden] {
    display: none;
}

.ds-op__steps > li {
    color: var(--ds-text-faint);
}

.ds-op__steps > li.is-done {
    color: var(--ds-text-muted);
}

.ds-op__steps > li.is-now {
    color: var(--ds-text-default);
}

.ds-op__steps > li.is-done::before {
    content: "✓ ";
}

.ds-op__steps > li.is-now::before {
    content: "● ";
    color: var(--ds-op-fg);
}

.ds-op__steps > li.is-todo::before {
    content: "○ ";
}

/* 색 바탕 위에서는 faint 대비가 4.5:1 에 못 미쳐 muted 로 올린다(faint 는 종이 · ash 위 캡션까지). */
:where(.ds-op--info, .ds-op--success, .ds-op--warning, .ds-op--danger) :where(.ds-op__faint) {
    color: var(--ds-text-muted);
}

.ds-op:is(.ds-op--info, .ds-op--success, .ds-op--warning, .ds-op--danger) .ds-op__steps > li.is-todo {
    color: var(--ds-text-muted);
}

@media (max-width: 767px) {
    .ds-op__meter {
        width: 120px;
    }
}
