/* =========================================
   전기용품 도소매 업무앱 — 공통 스타일
   색상: #1a56a0(파랑) #c62828(빨강) #ffd600(노랑)
   ========================================= */

:root {
    --blue: #1a56a0;
    --blue-dark: #0d3d7a;
    --blue-light: #e8f0fc;
    --red: #c62828;
    --red-light: #fde8e8;
    --yellow: #ffd600;
    --yellow-light: #fffde7;
    --green: #1b5e20;
    --green-bg: #e8f5e9;
    --gray: #666;
    --gray-light: #f5f5f5;
    --border: #ddd;
    --text: #222;
    --white: #fff;
    --shadow: 0 2px 8px rgba(0,0,0,0.12);
    --radius: 6px;
    --header-h: 130px;
    --tab-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: 'Malgun Gothic', '맑은 고딕', sans-serif;
    font-size: 16px;
    color: var(--text);
    background: var(--gray-light);
    min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 헤더 ── */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    background: var(--blue);
    color: var(--white);
    z-index: 1000;
    box-shadow: var(--shadow);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    min-height: 48px;
}

.site-title {
    color: var(--white);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-decoration: none;
}
.site-title:hover { text-decoration: none; opacity: 0.9; }

.header-user {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.user-name { font-weight: 600; }

.user-role {
    background: rgba(255,255,255,0.2);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
}

.btn-logout {
    background: rgba(255,255,255,0.15);
    color: var(--white);
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: var(--radius);
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}
.btn-logout:hover { background: rgba(255,255,255,0.25); text-decoration: none; }

/* ── 바코드 바 ── */
.barcode-bar {
    background: var(--blue-dark);
    padding: 8px 16px;
}

.barcode-form {
    display: flex;
    gap: 8px;
    max-width: 600px;
    margin: 0 auto;
}

.barcode-input {
    flex: 1;
    height: 44px;
    font-size: 16px;
    padding: 0 12px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.95);
    color: var(--text);
    outline: none;
}
.barcode-input:focus { border-color: var(--yellow); }

.btn-scan {
    height: 44px;
    padding: 0 18px;
    background: var(--yellow);
    color: #333;
    font-size: 15px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    white-space: nowrap;
}
.btn-scan:hover { background: #e6c000; }

/* ── 바코드 검색 결과 ── */
.barcode-result {
    position: absolute;
    left: 0; right: 0;
    background: var(--white);
    border-bottom: 3px solid var(--blue);
    box-shadow: var(--shadow);
    z-index: 1001;
    max-height: 300px;
    overflow-y: auto;
}

.barcode-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.barcode-result-item:hover { background: var(--blue-light); }

.result-name { font-size: 16px; font-weight: 600; flex: 1; }
.result-stock { color: var(--gray); font-size: 14px; }
.result-price { color: var(--blue); font-weight: 700; font-size: 16px; }

.result-actions { display: flex; gap: 6px; }

/* ── PC 네비 ── */
.nav-pc {
    display: flex;
    background: var(--blue-dark);
    overflow-x: auto;
}

.nav-item {
    color: rgba(255,255,255,0.8);
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    border-bottom: 3px solid transparent;
    transition: all 0.15s;
}
.nav-item:hover { color: var(--white); background: rgba(255,255,255,0.1); text-decoration: none; }
.nav-item.active { color: var(--yellow); border-bottom-color: var(--yellow); }

/* ── 헤더 스페이서 ── */
.header-spacer { height: var(--header-h); }

/* ── 메인 콘텐츠 ── */
.main-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 16px;
}

/* ── 카드 ── */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--blue-light);
}

/* ── 대시보드 그리드 ── */
.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.dash-stat {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 16px;
    text-align: center;
}

.dash-stat-num {
    font-size: 32px;
    font-weight: 700;
    color: var(--blue);
    display: block;
}

.dash-stat-label {
    font-size: 14px;
    color: var(--gray);
    margin-top: 4px;
}

.dash-stat.warn .dash-stat-num { color: var(--red); }
.dash-stat.ok .dash-stat-num { color: var(--green); }

/* ── 테이블 ── */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
}

th {
    background: var(--blue);
    color: var(--white);
    padding: 11px 12px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover td { background: var(--blue-light); }

.td-right { text-align: right; }
.td-center { text-align: center; }

/* ── 버튼 ── */
.btn {
    display: inline-block;
    height: 44px;
    padding: 0 18px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    line-height: 44px;
    text-decoration: none;
    white-space: nowrap;
    transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn:active { transform: scale(0.98); }

.btn-primary { background: var(--blue); color: var(--white); }
.btn-danger  { background: var(--red);  color: var(--white); }
.btn-warn    { background: var(--yellow); color: #333; }
.btn-success { background: #2e7d32; color: var(--white); }
.btn-gray    { background: #888; color: var(--white); }
.btn-outline { background: var(--white); color: var(--blue); border: 2px solid var(--blue); line-height: 40px; }
.btn-sm      { height: 34px; line-height: 34px; padding: 0 12px; font-size: 13px; }
.btn-lg      { height: 52px; line-height: 52px; padding: 0 24px; font-size: 17px; }
.btn-block   { display: block; width: 100%; }

/* ── 폼 ── */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray);
    margin-bottom: 6px;
}

.form-label .required { color: var(--red); margin-left: 2px; }

.form-control {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    font-size: 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}
.form-control:focus { border-color: var(--blue); }

textarea.form-control {
    height: auto;
    min-height: 80px;
    padding: 10px 12px;
    resize: vertical;
}

select.form-control { cursor: pointer; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
}

/* ── 접기/펼치기 ── */
.section-toggle {
    background: var(--blue-light);
    border: 1px solid var(--blue);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--blue);
    cursor: pointer;
    display: block;
    width: 100%;
    text-align: left;
    margin-bottom: 4px;
}

.section-body { display: none; padding: 12px 0; }
.section-body.open { display: block; }

/* ── 알림 ── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 15px;
    font-weight: 500;
}
.alert-error   { background: var(--red-light); color: var(--red); border-left: 4px solid var(--red); }
.alert-success { background: var(--green-bg); color: var(--green); border-left: 4px solid var(--green); }
.alert-warn    { background: var(--yellow-light); color: #7a6000; border-left: 4px solid var(--yellow); }
.alert-info    { background: var(--blue-light); color: var(--blue); border-left: 4px solid var(--blue); }

/* ── 뱃지 ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
}
.badge-blue   { background: var(--blue-light); color: var(--blue); }
.badge-red    { background: var(--red-light); color: var(--red); }
.badge-green  { background: var(--green-bg); color: var(--green); }
.badge-yellow { background: var(--yellow-light); color: #7a6000; }
.badge-gray   { background: #eee; color: #555; }

/* ── 재고 상태 ── */
.stock-ok   { color: var(--green); font-weight: 700; }
.stock-warn { color: var(--red); font-weight: 700; }

/* ── 페이지 헤더 ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}
.page-title { font-size: 22px; font-weight: 700; color: var(--blue); }

/* ── 검색 바 ── */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.search-bar .form-control { flex: 1; min-width: 200px; }

/* ── 가격 표시 ── */
.price { font-weight: 700; font-variant-numeric: tabular-nums; }
.price-buy       { color: var(--gray); }
.price-wholesale { color: var(--blue); }
.price-retail    { color: var(--red); }

/* ── 위치 표시 ── */
.location-badge {
    background: var(--yellow-light);
    color: #5d4500;
    border: 1px solid var(--yellow);
    border-radius: var(--radius);
    padding: 2px 8px;
    font-size: 13px;
}

/* ── 판매 처리 ── */
.cart-table th { font-size: 14px; }
.cart-table td { font-size: 15px; }
.cart-total {
    background: var(--blue);
    color: var(--white);
    padding: 16px 20px;
    border-radius: var(--radius);
    font-size: 20px;
    font-weight: 700;
    text-align: right;
}

/* ── 모바일 하단 탭바 ── */
.nav-mobile {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--white);
    border-top: 2px solid var(--border);
    height: var(--tab-h);
    z-index: 1000;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.tab-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    color: var(--gray);
    text-decoration: none;
    font-size: 11px;
    gap: 2px;
    border-top: 3px solid transparent;
}
.tab-item:hover { text-decoration: none; color: var(--blue); }
.tab-item.active { color: var(--blue); border-top-color: var(--blue); }

.tab-icon-text {
    font-size: 13px;
    font-weight: 700;
    background: var(--gray-light);
    border-radius: 4px;
    padding: 2px 6px;
}
.tab-item.active .tab-icon-text { background: var(--blue-light); color: var(--blue); }
.tab-icon-text.tab-main { background: var(--blue); color: var(--white); }

.tab-label { font-size: 11px; }

.mobile-bottom-spacer { height: 0; }

/* ── 입고/판매 처리 화면 ── */
.sale-layout {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 16px;
    align-items: start;
}

.sale-left, .sale-right {}

/* ── 수량 조절 ── */
.qty-control {
    display: flex;
    align-items: center;
    gap: 6px;
}
.qty-btn {
    width: 36px; height: 36px;
    font-size: 20px; font-weight: 700;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.qty-input {
    width: 60px; height: 36px;
    text-align: center;
    font-size: 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
}

/* ── 로그인 ── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--blue);
    padding: 20px;
}
.login-box {
    background: var(--white);
    border-radius: 10px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
}
.login-title {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--blue);
    margin-bottom: 8px;
}
.login-sub {
    text-align: center;
    color: var(--gray);
    font-size: 14px;
    margin-bottom: 28px;
}

/* ── 반응형 ── */
@media (max-width: 768px) {
    :root { --header-h: 120px; }

    .nav-pc { display: none; }
    .nav-mobile { display: flex; }
    .mobile-bottom-spacer { height: var(--tab-h); }

    .main-content { padding: 12px 10px; }

    .dash-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .dash-stat-num { font-size: 26px; }

    .form-row, .form-row-3 { grid-template-columns: 1fr; }

    .sale-layout { grid-template-columns: 1fr; }

    table { font-size: 14px; }
    th, td { padding: 8px 10px; }

    .btn-lg { height: 48px; line-height: 48px; font-size: 16px; }
    .page-title { font-size: 19px; }

    .header-user .user-role { display: none; }
}

@media (max-width: 480px) {
    .site-title { font-size: 15px; }
    .user-name { font-size: 13px; }
    .barcode-input { font-size: 15px; }
    .dash-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── 유틸 ── */
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray); font-size: 14px; }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-light); }
::-webkit-scrollbar-thumb { background: #bbb; border-radius: 3px; }
