/* ========================================
   솜씨ONE 모바일 전용 스타일
   PC 화면과 완전히 분리된 mobile/ 템플릿에서만 로드된다.
   ======================================== */

:root {
    --m-header-h: 56px;
    --m-tabbar-h: 60px;
    --m-side-pad: 16px;
    --m-dark: #14161a;
    --m-dark2: #1e2228;
    --m-yellow: #FFD400;
}

html, body {
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

body.m-body {
    background: var(--nb-bg, #F9F9F9);
    font-size: 15px;
    padding-top: var(--m-header-h);
    padding-bottom: calc(var(--m-tabbar-h) + env(safe-area-inset-bottom, 0px));
}

.m-container {
    padding: 12px var(--m-side-pad) 24px;
    max-width: 100%;
}

/* ── 상단 헤더 ── */
.m-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--m-header-h);
    z-index: 1040;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--m-side-pad);
    background: linear-gradient(135deg, #14161a 0%, #1e2228 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.m-header .m-brand {
    font-size: 18px;
    font-weight: 900;
    color: #fff;
    text-decoration: none;
    letter-spacing: -0.04em;
}

.m-header .m-brand .m-one { color: var(--m-yellow); }

.m-header-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    font-size: 20px;
}

/* ── 하단 탭바 ── */
.m-tabbar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--m-tabbar-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    z-index: 1040;
    display: flex;
    background: #fff;
    border-top: 1px solid #e8e8e8;
}

.m-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 44px;
    text-decoration: none;
    color: #8E8E8E;
    font-size: 10.5px;
    font-weight: 600;
    background: none;
    border: none;
}

.m-tab i { font-size: 19px; }

.m-tab.active { color: #191919; }
.m-tab.active i { color: var(--m-yellow); text-shadow: 0 0 12px rgba(255, 212, 0, 0.35); }

/* ── 전체 메뉴 (풀스크린) ── */
.m-menu {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: var(--m-dark2);
    color: #fff;
    display: none;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.m-menu.open { display: flex; }

.m-menu-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px var(--m-side-pad);
    min-height: var(--m-header-h);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    position: sticky;
    top: 0;
    background: var(--m-dark2);
}

.m-menu-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px var(--m-side-pad);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-weight: 700;
}

.m-menu-user i { color: var(--m-yellow); font-size: 22px; }

.m-menu-group { border-bottom: 1px solid rgba(255, 255, 255, 0.06); }

.m-menu-group-title {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px var(--m-side-pad);
    min-height: 48px;
    background: none;
    border: none;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    text-align: left;
}

.m-menu-group-title > span i:first-child {
    color: var(--m-yellow);
    width: 24px;
    margin-right: 8px;
    opacity: 0.85;
}

.m-menu-group-title .m-caret { transition: transform 0.2s; color: rgba(255,255,255,0.4); }
.m-menu-group.open .m-caret { transform: rotate(180deg); }

.m-menu-items { display: none; padding: 0 0 8px; }
.m-menu-group.open .m-menu-items { display: block; }

.m-menu-item {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 12px var(--m-side-pad) 12px 48px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 14.5px;
}

.m-menu-item:active { background: rgba(255, 255, 255, 0.06); color: #fff; }
.m-menu-item i { width: 22px; margin-right: 10px; font-size: 13px; color: rgba(255, 212, 0, 0.7); }

.m-menu-header-label {
    padding: 12px var(--m-side-pad) 4px 48px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 212, 0, 0.85);
}

.m-menu-foot {
    margin-top: auto;
    padding: 16px var(--m-side-pad) calc(24px + env(safe-area-inset-bottom, 0px));
}

.m-menu-foot a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    font-size: 14.5px;
    margin-top: 10px;
}

.m-menu-foot .m-logout { background: rgba(220, 53, 69, 0.15); color: #ff8a95; }
.m-menu-foot .m-pcview { background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.8); }

/* ── 페이지 공통 ── */
.m-page-title {
    font-size: 20px;
    font-weight: 800;
    margin: 4px 0 2px;
    letter-spacing: -0.03em;
}

.m-page-sub {
    font-size: 12.5px;
    color: #8E8E8E;
    margin-bottom: 12px;
}

/* KPI 2x2 그리드 */
.m-kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}

.m-kpi {
    background: #fff;
    border-radius: 14px;
    padding: 12px 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    min-width: 0;
}

.m-kpi-label { font-size: 11.5px; color: #8E8E8E; font-weight: 600; margin-bottom: 2px; }
.m-kpi-value { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-kpi-value .m-unit { font-size: 12px; font-weight: 600; color: #8E8E8E; margin-left: 2px; }
.m-kpi-sub { font-size: 11px; color: #b0b0b0; margin-top: 1px; }

/* 필터 바 */
.m-filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.m-filter-chip {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    font-size: 13.5px;
    font-weight: 700;
    color: #333;
}

.m-filter-chip i { color: #8E8E8E; font-size: 13px; }

/* 상품 카드 리스트 */
.m-card-list { display: flex; flex-direction: column; gap: 8px; }

.m-prod-card {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border-radius: 14px;
    padding: 11px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    min-height: 44px;
}

.m-prod-card:active { background: #FFFDF0; }

.m-rank {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 800;
    background: #F2F2F2;
    color: #666;
}

.m-rank.r1 { background: #FFD400; color: #191919; }
.m-rank.r2 { background: #e2e8f0; color: #334155; }
.m-rank.r3 { background: #fde8d0; color: #9a5b13; }

.m-thumb {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    object-fit: cover;
    border: 1px solid #eee;
    background: #f6f6f6;
}

.m-thumb-none {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: #f2f2f2;
    color: #b5b5b5;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    text-align: center;
    line-height: 1.2;
}

.m-prod-main { flex: 1; min-width: 0; }

.m-prod-name {
    font-size: 13.5px;
    font-weight: 700;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.m-prod-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    margin-top: 3px;
    font-size: 11px;
    color: #8E8E8E;
}

.m-erp-tag {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 6px;
    background: #eef4ff;
    color: #2563eb;
    font-family: monospace;
}

.m-erp-tag.unmatched { background: #fdeaea; color: #dc2626; }

.m-badge-danger { color: #dc2626; font-weight: 700; }
.m-badge-warn { color: #d97706; font-weight: 700; }
.m-badge-ok { color: #16a34a; font-weight: 700; }

.m-prod-qty {
    flex-shrink: 0;
    text-align: right;
}

.m-prod-qty .m-qty { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; }
.m-prod-qty .m-qty-label { font-size: 10px; color: #b0b0b0; }

/* 더보기 버튼 */
.m-more-btn {
    width: 100%;
    min-height: 48px;
    margin-top: 12px;
    border: 1px dashed #d5d5d5;
    border-radius: 12px;
    background: none;
    color: #666;
    font-size: 14px;
    font-weight: 700;
}

/* ── 하단 시트 ── */
.m-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1060;
    background: rgba(0, 0, 0, 0.45);
    display: none;
}

.m-sheet-backdrop.open { display: block; }

.m-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1070;
    background: #fff;
    border-radius: 20px 20px 0 0;
    max-height: 85vh;
    display: none;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.25s ease;
}

.m-sheet.open { display: flex; transform: translateY(0); }

.m-sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: #ddd;
    margin: 10px auto 4px;
    flex-shrink: 0;
}

.m-sheet-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 6px var(--m-side-pad) 12px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.m-sheet-title { font-size: 16px; font-weight: 800; line-height: 1.35; }
.m-sheet-sub { font-size: 12px; color: #8E8E8E; margin-top: 2px; }

.m-sheet-close {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    margin: -8px -8px 0 0;
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
}

.m-sheet-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px var(--m-side-pad) calc(20px + env(safe-area-inset-bottom, 0px));
}

/* 시트 내부 리스트 행 */
.m-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 44px;
    padding: 10px 4px;
    border-bottom: 1px solid #f4f4f4;
    font-size: 14px;
}

.m-row .m-row-label { color: #555; }
.m-row .m-row-value { font-weight: 700; }

.m-row-tap { color: inherit; text-decoration: none; }
.m-row-tap:active { background: #FFFDF0; }

/* 시트 섹션 타이틀 */
.m-section-title {
    font-size: 12px;
    font-weight: 800;
    color: #8E8E8E;
    letter-spacing: 0.06em;
    margin: 16px 0 4px;
    text-transform: uppercase;
}

/* 폼 (필터 시트) */
.m-form-label { font-size: 13px; font-weight: 700; margin-bottom: 6px; display: block; }

.m-input {
    width: 100%;
    min-height: 48px;
    font-size: 16px;   /* iOS 확대 방지 */
    border: 1px solid #e2e2e2;
    border-radius: 12px;
    padding: 10px 14px;
    background: #fff;
}

.m-check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 4px 2px;
    font-size: 14.5px;
}

.m-check-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #191919;
}

.m-btn {
    width: 100%;
    min-height: 50px;
    border: none;
    border-radius: 12px;
    font-size: 15.5px;
    font-weight: 800;
}

.m-btn-primary { background: var(--m-yellow); color: #191919; }
.m-btn-secondary { background: #f0f0f0; color: #333; }

.m-btn + .m-btn { margin-top: 8px; }

/* 동기화 배지 */
.m-sync-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: #666;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 100px;
    padding: 4px 10px;
}

.m-sync-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

/* 로딩 스피너 중앙 정렬 */
.m-loading { text-align: center; padding: 40px 0; color: #8E8E8E; font-size: 13px; }

/* 이미지/미디어 오버플로 방지 */
.m-container img, .m-sheet img { max-width: 100%; }
