/* 일이야 공용 레이아웃 클래스 v1 (LAYOUTREF, runs/design/layoutref/LAYOUT_REFERENCE.md B·D4)
   값은 ui_tokens.css. 기존 화면은 값 치환으로 정돈하고, 새로 만들거나 다시 쓰는 화면만 이 클래스를 쓴다.
   모든 페이지 CSS 뒤에 불러온다. */

/* ── 줄바꿈 (B7) ───────────────────────────────────────────────
   한국어는 어절 단위로 꺾는다. overflow-wrap:anywhere 는 그래도 넘치는 긴 낱말·URL만 끊고,
   한글의 최소 폭(min-content)을 지금과 같게 유지해 flex·표 칸 폭이 넓어지지 않게 한다.
   (anywhere 미지원 브라우저는 앞의 break-word 를 쓴다.) */
html {
    word-break: keep-all;
    overflow-wrap: break-word;
    overflow-wrap: anywhere;
}

/* DES 15: 모바일 홈은 V4 그대로다. 소유자 결정(감사 M-4) 전까지 이 영역은 기존 줄바꿈을 유지한다.
   상단 아이콘 메뉴(header)는 메인 메뉴 계약 영역이라 모든 폭에서 기존 줄바꿈을 유지한다. */
header {
    word-break: normal;
    overflow-wrap: normal;
}

@media (max-width: 767px) {
    /* 모바일 홈 화면 영역 전체(메뉴·알림 안내·검색 줄·홈 모듈·광고). 그 위에 뜨는 대화상자는 제외하지 않는다. */
    body.unified-page :is(#appMenuRegion, #homeNoticeSlot, #searchBookmarkRow, #homeModules, #landscapeNoData, #appAdRegion, .service-footer) {
        word-break: normal;
        overflow-wrap: normal;
    }

    body.unified-page #homeModules #dashMoreDialog {
        word-break: keep-all;
        overflow-wrap: break-word;
        overflow-wrap: anywhere;
    }
}

/* 숫자+단위·날짜를 붙이고(33,000원, 365일), 한 줄 말줄임·두 줄 제한을 쓴다. */
.u-nowrap { white-space: nowrap; }
.u-ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.u-clamp-2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; }

/* ── 버튼 (B2·B3·B4) ─────────────────────────────────────────
   라벨은 한 줄이고 자르지 않는다. 모자라면 묶음을 다음 줄로 보내거나(데스크톱) 세로로 쌓는다(모바일). */
.ui-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    box-sizing: border-box;
    height: var(--control-h-md);
    min-width: var(--control-min-w);
    padding: 0 var(--control-px-md);
    border: 1px solid transparent;
    border-radius: var(--radius-control);
    font: inherit;
    font-size: var(--control-fs-md);
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
    word-break: keep-all;
    text-decoration: none;
    cursor: pointer;
}
.ui-btn--sm { height: var(--control-h-sm); padding: 0 var(--control-px-sm); font-size: var(--control-fs-sm); gap: var(--space-1); }
.ui-btn--lg { height: var(--control-h-lg); padding: 0 var(--control-px-lg); font-size: var(--control-fs-lg); }
.ui-btn--primary { background: var(--action-primary-bg); border-color: var(--action-primary-bg); color: var(--action-primary-fg); }
.ui-btn--primary:hover { background: var(--action-primary-bg-hover); border-color: var(--action-primary-bg-hover); }
.ui-btn--secondary { background: var(--action-secondary-bg); border-color: var(--action-secondary-border); color: var(--action-secondary-fg); }
.ui-btn--tertiary { min-width: 0; padding-inline: var(--space-2); background: transparent; color: var(--action-tertiary-fg); }
.ui-btn--danger { background: var(--action-danger-bg); border-color: var(--action-danger-bg); color: var(--action-danger-fg); }
.ui-btn--block { display: flex; width: 100%; }
.ui-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.ui-btn:disabled,
.ui-btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.ui-btn > svg { flex: none; width: var(--icon-size); height: var(--icon-size); }
.ui-btn--sm > svg { width: 16px; height: 16px; }
.ui-icon-btn { min-width: 0; inline-size: var(--icon-btn); block-size: var(--icon-btn); padding: 0; }

/* 보이는 크기는 그대로 두고 누르는 영역만 넓힌다 (B9) */
.ui-hit { position: relative; }
.ui-hit::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: max(100%, var(--hit-min));
    height: max(100%, var(--hit-min));
    transform: translate(-50%, -50%);
}

/* ── 버튼 묶음·대화상자 머리·하단 (B5-1·B8·B12) ───────────────────
   DOM 순서는 [보조…][주]: 주 버튼이 오른쪽 끝이고 한 묶음에 주 버튼은 1개다.
   초기화·도움말처럼 성격이 다른 동작은 .ui-actions__start 로 왼쪽 끝에 뗀다. */
.ui-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-inline); }
.ui-actions--end { justify-content: flex-end; }
.ui-actions__start { margin-inline-end: auto; }
@media (max-width: 767px) {
    .ui-actions--fill > * { flex: 1 1 0; min-width: 0; height: var(--control-h-lg); }
    /* DOM [보조][주] → 화면에서는 주 버튼이 맨 위 */
    .ui-actions--stack { flex-direction: column-reverse; align-items: stretch; }
    .ui-actions--stack > * { width: 100%; height: var(--control-h-lg); }
}

.ui-dialog__header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 56px;
    padding: 0 var(--space-2) 0 var(--dialog-pad);
}
.ui-dialog__title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    color: var(--color-text, #1e293b);
    font-size: 18px;
    font-weight: 800;
    word-break: keep-all;
}
.ui-dialog__close {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    inline-size: var(--icon-btn);
    block-size: var(--icon-btn);
    padding: 0;
    border: 0;
    border-radius: var(--radius-control);
    background: transparent;
    color: var(--color-text-secondary, #64748b);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.ui-dialog__close:hover { background: rgba(100, 116, 139, 0.12); }
.ui-dialog__close:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* LAYOUTREF batch 2: existing dialog close selectors use the shared values.
   These controls also have older responsive/inline declarations; only their
   shape is authoritative here. Modal headings retain their approved navy. */
body :is(.close-btn, .sfd-close-btn, .fsd-close-btn, .dialog-close,
    .modal-close, .dash-more-close, .cal-close-btn, .sched-dialog-close,
    .weather-dialog-close, .results-dialog-close-btn, .collab-close,
    .fiscal-dialog-close, .org-history-close, .related-companies-close,
    .notice-popup-close),
body #qnaModalCloseBtn {
    display: inline-flex !important;
    flex: 0 0 var(--icon-btn) !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box;
    width: var(--icon-btn) !important;
    min-width: var(--icon-btn) !important;
    height: var(--icon-btn) !important;
    min-height: var(--icon-btn) !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: var(--radius-control) !important;
    background: transparent !important;
    color: var(--color-text-secondary, #64748b);
    font-size: var(--icon-size) !important;
    line-height: 1 !important;
    cursor: pointer;
}
body .modal-header :is(.close-btn, .modal-close),
body .license-panel-header .close-btn { color: #ffffff; }
body .fiscal-dialog-header .fiscal-dialog-close { color: #cbd5e1; }
body :is(.close-btn, .sfd-close-btn, .fsd-close-btn, .dialog-close,
    .modal-close, .dash-more-close, .cal-close-btn, .sched-dialog-close,
    .weather-dialog-close, .results-dialog-close-btn, .collab-close,
    .fiscal-dialog-close, .org-history-close, .related-companies-close,
    .notice-popup-close):hover,
body #qnaModalCloseBtn:hover {
    background: rgba(100, 116, 139, 0.12) !important;
    color: var(--color-text-secondary, #64748b);
    transform: none;
}
body .modal-header :is(.close-btn, .modal-close):hover,
body .license-panel-header .close-btn:hover { color: #ffffff; }
body :is(.close-btn, .sfd-close-btn, .fsd-close-btn, .dialog-close,
    .modal-close, .dash-more-close, .cal-close-btn, .sched-dialog-close,
    .weather-dialog-close, .results-dialog-close-btn, .collab-close,
    .fiscal-dialog-close, .org-history-close, .related-companies-close,
    .notice-popup-close):focus-visible,
body #qnaModalCloseBtn:focus-visible,
body.unified-page .results-dialog .results-sort-menu > .result-sort-option:focus-visible,
body.unified-page .results-dialog .results-related-company-btn:focus-visible,
body.unified-page .results-dialog .result-card:focus-visible,
#detailModal .action-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring) !important;
}

.ui-dialog__footer {
    position: sticky;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: var(--gap-inline);
    padding: var(--space-3) var(--dialog-pad) calc(var(--space-3) + var(--app-dialog-safe-bottom, 0px));
    border-top: 1px solid var(--color-border, #e2e8f0);
    background: inherit;
}

/* 기존 공용 대화상자 하단 .modal-footer(요약·문서 보기)에는 지금까지 규칙이 없어
   버튼이 전체 폭으로 쌓이고 바탕이 브라우저 기본 회색이었다. 같은 규칙으로 정돈한다.
   [재변환(보조)][다운로드(주)]처럼 DOM 순서는 이미 보조→주다. */
.modal-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: var(--gap-inline);
    padding: var(--space-3) var(--dialog-pad);
    border-top: 1px solid var(--color-border, #e2e8f0);
}
.modal-footer > .action-btn {
    min-width: var(--control-min-w);
    min-height: var(--control-h-md);
    padding: 0 var(--control-px-md);
    border-radius: var(--radius-control);
    white-space: nowrap;
}
.modal-footer > .action-btn:not(.secondary) {
    border: 1px solid var(--action-primary-bg);
    background: var(--action-primary-bg);
    color: var(--action-primary-fg);
}
.modal-footer > .action-btn:not(.secondary):disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.modal-footer > .action-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
@media (max-width: 767px) {
    .modal-footer > .action-btn { flex: 1 1 0; min-height: var(--control-h-lg); }
}

/* ── 카드·목록 행·툴바 (B5-4·B5-5·B5-6) ─────────────────────── */
.ui-card { box-sizing: border-box; padding: var(--card-pad); border: 1px solid var(--color-border, #e2e8f0); border-radius: var(--radius-card); background: var(--color-surface, #fff); }
.ui-card__header { display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-h-sm); margin-bottom: var(--space-3); }
.ui-card__title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.ui-card__header-actions { display: flex; flex: none; gap: var(--space-1); }

.ui-row { display: flex; align-items: center; gap: var(--space-3); min-height: var(--control-h-md); padding: var(--space-2) var(--space-3); }
.ui-row__main { flex: 1 1 auto; min-width: 0; }
.ui-row__actions { display: flex; flex: none; gap: var(--space-2); }

.ui-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--gap-group); }
.ui-toolbar__group { display: flex; align-items: center; gap: var(--gap-inline); }
.ui-toolbar__spacer { flex: 1 1 auto; }
.ui-toolbar :is(input, select, button, .ui-btn) { height: var(--control-h-md); border-radius: var(--radius-control); }

/* 빈 상태 (B5-8) */
.ui-empty { display: grid; justify-items: center; gap: var(--space-2); padding: var(--space-8) var(--space-4); color: var(--color-text-secondary, #64748b); font-size: 13px; text-align: center; }

/* Flowboard S1: opt-in variants, activated on S2 surfaces. Frame/menu/ad/safe-area stay external. */
.ui-flow {
    color: var(--flow-text);
    background: var(--flow-canvas);
    font-family: var(--flow-font-family);
    font-size: var(--flow-font-body);
    line-height: var(--flow-line-body);
    word-break: keep-all;
    overflow-wrap: anywhere;
}
.ui-flow :where(.ui-flow-card, .ui-flow-empty, .ui-flow-table, .ui-flow-step,
    .ui-flow-status, .ui-flow-action) { box-sizing: border-box; min-inline-size: 0; }
.ui-flow .ui-flow-card {
    background: var(--flow-surface);
    border: var(--flow-border-width) solid var(--flow-border);
    border-radius: var(--flow-radius-card);
}
.ui-flow .ui-flow-card--raised { box-shadow: var(--flow-shadow); }
.ui-flow .ui-flow-card__header, .ui-flow .ui-flow-card__body {
    padding: var(--flow-space-4) var(--flow-space-5);
}
.ui-flow .ui-flow-card__header {
    word-break: keep-all; overflow-wrap: anywhere;
    display: flex; flex-wrap: wrap; align-items: center;
    justify-content: space-between; gap: var(--flow-space-3);
    border-block-end: var(--flow-border-width) solid var(--flow-border);
}
.ui-flow .ui-flow-title {
    margin: 0; color: var(--flow-text); font-size: var(--flow-font-title);
    font-weight: var(--flow-weight-heading); line-height: var(--flow-line-title); text-wrap: balance;
    word-break: keep-all; overflow-wrap: anywhere;
}
.ui-flow .ui-flow-section-title {
    margin: 0; color: var(--flow-text); font-size: var(--flow-font-section);
    font-weight: var(--flow-weight-heading); line-height: var(--flow-line-section); text-wrap: balance;
    word-break: keep-all; overflow-wrap: anywhere;
}
.ui-flow .ui-flow-note { color: var(--flow-text-secondary); font-size: var(--flow-font-note); }
.ui-flow .ui-flow-table { inline-size: 100%; border-collapse: collapse; table-layout: fixed; }
.ui-flow .ui-flow-table caption {
    text-align: start; padding-block: var(--flow-space-3);
    color: var(--flow-text); font-weight: 700;
}
.ui-flow .ui-flow-table :is(th, td) {
    padding: var(--flow-space-3); text-align: start; vertical-align: top;
    border-block-end: var(--flow-border-width) solid var(--flow-border);
    overflow-wrap: anywhere; word-break: keep-all;
}
.ui-flow .ui-flow-table th { background: var(--flow-surface-subtle); font-weight: 700; }
.ui-flow .ui-flow-table__number { font-variant-numeric: tabular-nums; }
.ui-flow .ui-flow-status {
    display: inline-flex; align-items: center; gap: var(--flow-space-1);
    max-inline-size: 100%; padding: var(--flow-space-1) var(--flow-space-2);
    border: var(--flow-border-width) solid currentColor;
    border-radius: var(--flow-radius-badge);
    background: var(--flow-surface); color: var(--flow-text-secondary);
    font-size: var(--flow-font-note); line-height: var(--flow-line-heading);
    white-space: normal;
}
.ui-flow .ui-flow-status--success { color: var(--flow-success); }
.ui-flow .ui-flow-status--attention { color: var(--flow-attention); }
.ui-flow .ui-flow-status--danger { color: var(--flow-danger); }
.ui-flow .ui-flow-status--info { color: var(--flow-action); }
.ui-flow .ui-flow-empty {
    display: grid; justify-items: start; gap: var(--flow-space-3);
    padding: var(--flow-space-6); background: var(--flow-surface);
    border: var(--flow-border-width) solid var(--flow-border);
    border-radius: var(--flow-radius-card);
}
.ui-flow .ui-flow-empty > :is(h2, h3, p) { margin: 0; }
.ui-flow .ui-flow-step {
    display: flex; align-items: start; gap: var(--flow-space-3);
    padding-block-end: var(--flow-space-3);
    border-block-end: 2px solid var(--flow-action);
}
.ui-flow .ui-flow-step__index {
    flex: none; color: var(--flow-action); font-size: var(--flow-font-title);
    font-weight: var(--flow-weight-heading); font-variant-numeric: tabular-nums; line-height: var(--flow-line-heading);
}
.ui-flow .ui-flow-step__content { min-inline-size: 0; }
.ui-flow .ui-flow-step__content > p { margin: var(--flow-space-1) 0 0; }
.ui-flow .ui-flow-actions { display: flex; flex-wrap: wrap; gap: var(--flow-space-2); }
.ui-flow .ui-flow-action {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--flow-space-2); min-block-size: var(--flow-control-min);
    min-inline-size: var(--flow-control-min); max-inline-size: 100%;
    padding: var(--flow-space-2) var(--flow-space-3);
    border: var(--flow-border-width) solid var(--flow-control-border);
    border-radius: var(--flow-radius-control);
    background: var(--flow-surface); color: var(--flow-action);
    font: inherit; line-height: var(--flow-line-heading);
    text-align: center; text-decoration: none;
    white-space: normal; word-break: keep-all; overflow-wrap: anywhere; cursor: pointer;
}
.ui-flow .ui-flow-action--primary {
    background: var(--flow-action); color: var(--flow-on-action); border-color: var(--flow-action);
}
.ui-flow .ui-flow-action:hover { box-shadow: inset 0 0 0 1px currentColor; }
.ui-flow .ui-flow-action:focus-visible { outline: var(--flow-focus-width) solid var(--flow-focus); outline-offset: var(--flow-focus-width); }
.ui-flow .ui-flow-action:disabled, .ui-flow .ui-flow-action[aria-disabled="true"] {
    background: var(--flow-surface-subtle); color: var(--flow-text-secondary);
    border-color: var(--flow-border); box-shadow: none; cursor: default;
}
/* Purely presentational: caller supplies an accessible name/status and read rules.
   No number, live announcement, service priority, position or badge counter is implied. */
.ui-flow .ui-flow-indicator {
    display: inline-block; flex: none; inline-size: 8px; block-size: 8px;
    border: 1px solid currentColor; border-radius: 50%;
    background: currentColor; color: var(--flow-action);
}
.ui-flow .ui-flow-indicator--soft { background: transparent; }
@media (max-width: 767px) {
    .ui-flow .ui-flow-card__header, .ui-flow .ui-flow-card__body { padding: var(--flow-space-4); }
    .ui-flow .ui-flow-table :is(th, td) { padding: var(--flow-space-2); }
    .ui-flow .ui-flow-empty { padding: var(--flow-space-4); }
}

/* Shared S2 variants. The consumer, never this kit, owns scrolling and placement. */
.ui-flow .ui-flow-prose { font-size: var(--flow-font-prose); line-height: var(--flow-line-prose); }
.ui-flow .ui-flow-label { font-size: var(--flow-font-label); line-height: var(--flow-line-label); color: var(--flow-text-secondary); }
.ui-flow .ui-flow-action--ghost { border-color: transparent; background: transparent; color: var(--flow-action); }
.ui-flow .ui-flow-table { --flow-row-size: var(--flow-row-default); }
.ui-flow .ui-flow-table--compact { --flow-row-size: var(--flow-row-compact); }
.ui-flow .ui-flow-table--comfortable { --flow-row-size: var(--flow-row-comfortable); }
.ui-flow .ui-flow-table tr { height: var(--flow-row-size); }
.ui-flow .ui-flow-table :is(th, td) {
    line-height: var(--flow-line-list);
    padding-block: calc((var(--flow-row-size) - var(--flow-line-list)) / 2);
}
.ui-flow .ui-flow-table__number { text-align: end; }
.ui-flow .ui-flow-skeleton {
    min-block-size: var(--flow-row-default); border-radius: var(--flow-radius-badge);
    background: var(--flow-surface-subtle); color: var(--flow-text-secondary);
}
.ui-flow .ui-flow-action { transition: background-color var(--flow-motion-fast), border-color var(--flow-motion-fast); }
@media (prefers-reduced-motion: reduce) {
    .ui-flow .ui-flow-action { transition: none; }
}
