/* ──────────────────────────────────────────────────────────────
   dashboard.css — TREX ERP 공통 컴포넌트
   청회색 캔버스 위에 흰 업무 패널을 얹는 구조.
   컴포넌트: .panel / .panel-head / .panel-body / .stat-row / .kv-list
             .panel-grid
   ※ palette.css 이후, 각 페이지 CSS 이전에 로드된다.
   ────────────────────────────────────────────────────────────── */

/* ※ 캔버스(회색 바탕) 자체는 layout.css / window-layout.css 에서 지정한다. */

/* ── 아이콘 (icon/sprite.html) ───────────────────────────────
   이모지 대신 라인 SVG 를 쓴다. 색은 currentColor, 크기는 em 기준. */
.icon {
    width: 1.35em;
    height: 1.35em;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: -.15em;
    overflow: visible;
}

.icon.is-fill {
    fill: currentColor;
    stroke: none;
}

/* 버튼·상태바·뱃지 안의 아이콘 */
.control-btn .icon,
.status-bar .icon,
.toolbar-btn .icon,
.btn .icon,
button .icon,
.menu-item .icon {
    width: 1.8rem;
    height: 1.8rem;
    vertical-align: -.4rem;
}

.status-bar .status-item .icon {
    color: var(--dot-green);
}

/* 도구 카드 아이콘 타일 */
.tool-icon .icon {
    width: 2.4rem;
    height: 2.4rem;
    color: var(--accent-blue);
    vertical-align: 0;
}

/* 개발중 배지 */
.tool-badge-wip .icon {
    width: 1.4rem;
    height: 1.4rem;
    margin-right: .3rem;
    vertical-align: -.2rem;
}

/* 페이지 상단 타이틀 바 · 섹션 제목 */
.window-title .icon,
h1 .icon,
h2 .icon,
.tmb-head .icon,
.tmb-title .icon {
    vertical-align: -.2rem;
}

.tmb-head .icon,
.tmb-title .icon {
    width: 1.9rem;
    height: 1.9rem;
    margin-right: .2rem;
}

/* ── 페이지 헤더 ─────────────────────────────────────────────── */
.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.2rem;
    margin: .4rem 0 1.6rem;
}

.page-head-left {
    display: flex;
    flex-direction: column;
    gap: .4rem;
    min-width: 0;
}

/* Q&A형 헤더: [뒤로가기] [제목] | [설명] — 세로 쌓임·가운데 정렬이 되지 않게 row로 고정 */
.page-header-row,
.page-head-left:has(> .page-back),
.content-header:has(> .page-back),
.iar-header:has(> .page-back) {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    min-width: 0;
    flex: 1 1 auto;
    text-align: left;
}
.page-header-row h1,
.page-head-left:has(> .page-back) h1,
.content-header:has(> .page-back) h1,
.iar-header:has(> .page-back) h1 {
    flex: 0 0 auto;
    margin: 0;
    white-space: nowrap;
}
.page-header-row > p,
.page-head-left:has(> .page-back) > p,
.content-header:has(> .page-back) > p,
.iar-header:has(> .page-back) > p {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    border-left: 1px solid var(--panel-border, var(--border-primary));
    padding-left: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    :where(html[data-layout="mobile"]) .page-header-row, :where(html[data-layout="mobile"]) .page-head-left:has(> .page-back), :where(html[data-layout="mobile"]) .content-header:has(> .page-back), :where(html[data-layout="mobile"]) .iar-header:has(> .page-back){
        flex-wrap: wrap;
        align-items: flex-start;
    }
    :where(html[data-layout="mobile"]) .page-header-row > p, :where(html[data-layout="mobile"]) .page-head-left:has(> .page-back) > p, :where(html[data-layout="mobile"]) .content-header:has(> .page-back) > p, :where(html[data-layout="mobile"]) .iar-header:has(> .page-back) > p{
        flex: 1 1 100%;
        border-left: none;
        padding-left: 0;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }


.page-head h1 {
    display: flex;
    align-items: center;
    gap: .8rem;
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -.03em;
    color: var(--text-primary);
}

.page-head h1 img {
    width: 2.8rem;
}

.page-head h1 .icon {
    width: 2.8rem;
    height: 2.8rem;
    stroke-width: 1.8;
    color: var(--accent-blue);
    vertical-align: -.2rem;
}

.page-head p {
    font-size: 1.35rem;
    color: var(--text-secondary);
}

:root[data-theme="dark"] .page-head h1 img {
    filter: brightness(7);
}

/* ── 패널 ───────────────────────────────────────────────────── */
.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--panel-radius);
    box-shadow: var(--panel-shadow);
    overflow: hidden;
}

.panel + .panel,
.panel-grid + .panel,
.panel + .panel-grid {
    margin-top: 1.6rem;
}

/* 패널 헤더 — 컬러 도트 아이콘 + 제목 + 우측 메타 */
.panel-head {
    display: flex;
    align-items: center;
    gap: .9rem;
    min-height: var(--panel-head-h);
    padding: 1rem 1.6rem;
    border-bottom: 1px solid var(--panel-divider);
    background: var(--bg-tertiary-light);
}

.panel-head.is-plain {
    border-bottom: none;
    padding-bottom: 0;
}

.panel-icon {
    width: 2.8rem;
    height: 2.8rem;
    border-radius: var(--radius-sm, 4px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #fff;
    background: var(--dot-blue);
}

.panel-icon .icon {
    width: 1.9rem;
    height: 1.9rem;
    stroke-width: 2;
    vertical-align: 0;
}

.panel-icon.is-green  { background: var(--dot-green); }
.panel-icon.is-red    { background: var(--dot-red); }
.panel-icon.is-orange { background: var(--dot-orange); }
.panel-icon.is-purple { background: var(--dot-purple); }
.panel-icon.is-teal   { background: var(--dot-teal); }
.panel-icon.is-gray   { background: var(--dot-gray); }

.panel-title {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -.02em;
    color: var(--text-primary);
    white-space: nowrap;
}

.panel-desc {
    font-size: 1.25rem;
    color: var(--text-secondary);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.panel-meta {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .8rem;
    font-size: 1.2rem;
    color: var(--text-tertiary);
    flex: none;
}

.panel-meta .badge {
    display: inline-flex;
    align-items: center;
    height: 2.2rem;
    padding: 0 .8rem;
    border-radius: 0;
    border: 1px solid var(--panel-border);
    background: var(--panel);
    color: var(--text-secondary);
    font-size: 1.15rem;
    font-weight: 600;
}

.panel-meta .badge.is-accent {
    background: color-mix(in srgb, var(--accent-blue) 12%, transparent);
    color: var(--accent-blue);
}

.panel-body {
    padding: 2rem;
}

.panel-body.is-tight {
    padding: 1.4rem 2rem;
}

.panel-body.is-flush {
    padding: 0;
}

.panel-foot {
    padding: 1.2rem 2rem;
    border-top: 1px solid var(--panel-divider);
    font-size: 1.2rem;
    color: var(--text-tertiary);
}

/* 패널 나란히 배치 */
.panel-grid {
    display: grid;
    gap: 1.6rem;
    grid-template-columns: repeat(auto-fit, minmax(32rem, 1fr));
}

.panel-grid.is-2 { grid-template-columns: repeat(auto-fit, minmax(38rem, 1fr)); }
.panel-grid.is-3 { grid-template-columns: repeat(auto-fit, minmax(28rem, 1fr)); }

/* ── 통계 행 (신규주문 0건 › 배송준비 0건 …) ───────────────── */
.stat-row {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    padding: 1.6rem 1rem 1.8rem;
}

.stat-cell {
    flex: 1 1 0;
    min-width: 14rem;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .8rem;
    padding: .6rem 1.6rem;
    text-decoration: none;
    color: inherit;
}

/* 셀 사이 › 화살표 */
.stat-cell + .stat-cell::before {
    content: '';
    position: absolute;
    left: -.5rem;
    top: 50%;
    width: .9rem;
    height: .9rem;
    border-top: 2px solid var(--chevron);
    border-right: 2px solid var(--chevron);
    transform: translateY(-50%) rotate(45deg);
}

.stat-row.no-chevron .stat-cell + .stat-cell::before {
    display: none;
}

.stat-label {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--stat-label);
}

.stat-value {
    display: flex;
    align-items: baseline;
    gap: .3rem;
    font-size: 2.6rem;
    font-weight: 700;
    letter-spacing: -.03em;
    color: var(--stat-num);
    line-height: 1.1;
}

.stat-value .unit {
    font-size: 1.5rem;
    font-weight: 600;
}

.stat-value.is-zero {
    color: var(--text-tertiary);
}

.stat-value.is-accent { color: var(--accent-blue); }
.stat-value.is-red    { color: var(--red); }
.stat-value.is-green  { color: var(--dot-green); }

a.stat-cell:hover .stat-value {
    color: var(--accent-blue);
}

/* 패널 하단 보조 지표 줄 (오늘출발 0 | 예약구매 0 …) */
.stat-substrip {
    display: flex;
    flex-wrap: wrap;
    border-top: 1px solid var(--panel-divider);
    padding: 1.2rem 2rem;
    gap: 1.2rem 3.2rem;
}

.stat-substrip .sub-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.3rem;
    color: var(--text-secondary);
    flex: 1 1 auto;
}

.stat-substrip .sub-item strong {
    margin-left: auto;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* ── 라벨-값 리스트 (취소요청 0 / 반품요청 0 …) ─────────────── */
.kv-list {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    padding: 1.8rem 2rem;
}

.kv-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.2rem;
    font-size: 1.35rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.kv-row .kv-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.kv-row .kv-value.is-zero { color: var(--text-tertiary); }
.kv-row .kv-value.is-red  { color: var(--red); }

a.kv-row:hover .kv-value { color: var(--accent-blue); }

/* ── 공지 스트립 (상단 안내 바) ─────────────────────────────── */
.notice-strip {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.1rem 1.8rem;
    margin-bottom: 1.6rem;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 0;
    font-size: 1.3rem;
    color: var(--text-secondary);
}

.notice-strip .icon {
    width: 1.9rem;
    height: 1.9rem;
    color: var(--accent-blue);
    flex: none;
}

.notice-strip .tag {
    display: inline-flex;
    align-items: center;
    height: 2.2rem;
    padding: 0 .9rem;
    border-radius: 0;
    border: 1px solid var(--panel-border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 1.15rem;
    font-weight: 600;
    flex: none;
}

.notice-strip .date {
    margin-left: auto;
    color: var(--text-tertiary);
    font-size: 1.2rem;
    flex: none;
}

/* ── 기존 카드 컴포넌트를 패널 톤에 맞춤 ────────────────────── */
.tool-card,
.service-card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 0;
    box-shadow: none;
}

.tool-card:hover,
.service-card:hover {
    border-color: var(--accent-blue);
    box-shadow: none;
    background: var(--bg-tertiary-light);
}

/* 패널 안에 들어간 카드 그리드는 테두리 없이 가볍게 */
.panel .tool-grid,
.panel .services-grid {
    gap: 1.2rem;
}

.panel .tool-card,
.panel .service-card {
    background: var(--bg-tertiary-light);
    border-color: var(--panel-border);
}

.panel .tool-card:hover,
.panel .service-card:hover {
    background: var(--panel);
    border-color: var(--accent-blue);
}

/* ── 반응형 ─────────────────────────────────────────────────── */

    :where(html[data-layout="mobile"]) .stat-cell{
        flex: 1 1 45%;
        min-width: 12rem;
    }



    :where(html[data-layout="mobile"]) .content{
        padding: 1.4rem 1.2rem 3rem;
    }

    :where(html[data-layout="mobile"]) .panel-head{
        padding: 1.1rem 1.4rem;
        flex-wrap: wrap;
        row-gap: .4rem;
    }

    :where(html[data-layout="mobile"]) .panel-desc{ display: none; }

    :where(html[data-layout="mobile"]) .panel-body, :where(html[data-layout="mobile"]) .kv-list, :where(html[data-layout="mobile"]) .stat-substrip{
        padding-left: 1.4rem;
        padding-right: 1.4rem;
    }

    :where(html[data-layout="mobile"]) .stat-row{
        padding: 1.2rem .4rem 1.4rem;
    }

    :where(html[data-layout="mobile"]) .stat-cell{
        flex: 1 1 50%;
        min-width: 0;
        padding: .8rem 1rem;
    }

    :where(html[data-layout="mobile"]) .stat-cell + .stat-cell::before{ display: none; }

    :where(html[data-layout="mobile"]) .stat-value{ font-size: 2.2rem; }

    :where(html[data-layout="mobile"]) .page-head h1{ font-size: 1.9rem; }


/* 창 제목 표시줄 · 상태바 아이콘 */
.window-title .icon {
    width: 1.7rem;
    height: 1.7rem;
}

.status-bar .icon {
    width: 1.6rem;
    height: 1.6rem;
}
