/* === CLYVON ERP Theme === */
/* 네이비 다크: #0d1b2a | 네이비 미드: #1b2a40 | 네이비 라이트: #243447 */
/* 골드 메인: #c9a96e | 골드 라이트: #dcc99a | 골드 다크: #a8893f */

/* === 기본 리셋 === */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', -apple-system, sans-serif; background: #f5f5f0; color: #1a1a2e; display: flex; min-height: 100vh; }
a { color: #c9a96e; text-decoration: none; }
button, .btn { cursor: pointer; border: none; border-radius: 6px; padding: 8px 16px; font-size: 14px; transition: all 0.2s; }

/* === v3: 좁은 레일 === */
.rail { width: 88px; background: #0d1b2a; color: #fff; display: flex; flex-direction: column; align-items: center; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100; padding: 10px 0; border-right: 1px solid #1f2e44; }
.brand-mark { width: 72px; height: 72px; border-radius: 12px; display: block; margin-bottom: 10px; text-decoration: none; flex-shrink: 0; overflow: hidden; transition: transform 0.15s, box-shadow 0.15s; background-image: url('../img/CLYVON-LOGO.jpg'); background-size: contain; background-position: center; background-repeat: no-repeat; background-color: #0d1b2a; }
.brand-mark:hover { transform: scale(1.05); box-shadow: 0 0 0 1px #c9a96e; }
.brand-mark.active { box-shadow: 0 0 0 2px #c9a96e; }
.brand-mark img { display: none; }

.rail-list { list-style: none; flex: 1; width: 100%; overflow-y: auto; padding: 4px 0; margin: 0; }
.rail-list::-webkit-scrollbar { width: 0; }
.rail-divider { width: 36px; height: 1px; background: #243447; margin: 8px auto; }

.rail-item { position: relative; width: 100%; }
.rail-btn { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px; cursor: pointer; color: #8da3c0; transition: all 0.15s; border-left: 3px solid transparent; text-decoration: none; user-select: none; }
.rail-btn:hover { color: #dcc99a; background: rgba(255,255,255,0.04); }
.rail-icon { font-size: 19px; line-height: 1; }
.rail-label { font-size: 10px; font-weight: 600; text-align: center; line-height: 1.15; white-space: nowrap; max-width: 80px; overflow: hidden; text-overflow: ellipsis; }

/* 활성/플라이아웃-오픈 상태 — 색상으로만 묶음 표현 (테두리 없음) */
.rail-item.active .rail-btn,
.rail-item.flyout-current .rail-btn {
    color: #c9a96e;
    background: #27384f;
    border-left: 3px solid transparent;
}

/* === 플라이아웃 패널 === */
/* 폭 200px — 실측 최소 필요폭 179px(헤더 '쿠팡데일리작업서')·148px(본문 '└ 스마트스토어') 기준 여유 확보 (26-07-28) */
/* 화면이 뜨는 동안(html.booting)은 모든 움직임 잠금 — 뜨는 도중 미끄러짐·밀림 차단 (26-07-31) */
html.booting *, html.booting *::before, html.booting *::after { transition: none !important; animation: none !important; }

/* 세로 3단 구성: 머리(고정) · 목록(스크롤) · 접기 단추(맨 아래 고정) — 26-07-31 */
.flyout { position: fixed; top: 0; left: 88px; bottom: 0; width: 200px; background: #27384f; box-shadow: 6px 0 20px rgba(0,0,0,0.3); z-index: 99; padding: 14px 0 0; transform: translateX(-100%); opacity: 0; pointer-events: none; transition: transform 0.2s ease, opacity 0.2s; display: flex; flex-direction: column; overflow: hidden; }
.flyout.open { transform: translateX(0); opacity: 1; pointer-events: auto; }
.flyout-header { flex-shrink: 0; padding: 0 14px 12px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #243447; margin-bottom: 8px; }
/* 헤더 클릭 → 모듈 첫 화면 이동 (26-07-28) */
a.flyout-header-link { text-decoration: none; cursor: pointer; transition: opacity .12s; }
a.flyout-header-link:hover .flyout-nm { color: #e8cfa0; text-decoration: underline; }
.flyout-header .flyout-ic { font-size: 22px; }
.flyout-header .flyout-nm { color: #c9a96e; font-weight: 700; font-size: 15px; }
/* 메뉴 접기 버튼 — 사이드바는 항상 펼침이므로 닫는 길은 이 버튼뿐 (26-07-31) */
/* 접기 단추 — 목록 맨 아래 가로 전체. 사이드바를 닫는 유일한 길이라 눈에 띄어야 한다 (26-07-31 임대표 지시) */
.flyout-collapse { flex: 0 0 auto; width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 12px 0; margin-top: 6px; background: #223349; border: none; border-top: 1px solid #1c2c40; color: #8fa3bd; font-size: 12px; font-weight: 600; line-height: 1; cursor: pointer; transition: all 0.15s; }
.flyout-collapse:hover { background: #2c4160; color: #e8cfa0; }
.flyout-collapse .fc-ar { font-size: 10px; }
.flyout-body { padding: 0 6px 10px; flex: 1 1 auto; overflow-y: auto; }

.fly-link { display: block; padding: 9px 14px; color: #cfd8e5; font-size: 13px; text-decoration: none; border-radius: 6px; transition: all 0.15s; border-left: 3px solid transparent; margin: 1px 0; }
.fly-link:hover { background: #213450; color: #fff; }
.fly-link.active { background: #1a2a42; border-left-color: transparent; }
.fly-link-child { padding-left: 28px; font-size: 12px; color: #90a3bf; }

.fly-section-label { padding: 8px 14px 4px; font-size: 10px; font-weight: 700; color: #c9a96e; text-transform: uppercase; letter-spacing: 1.2px; opacity: 0.7; }

.fly-children { padding-left: 14px; border-left: 1px solid #243447; margin: 2px 0 4px 14px; }

.fly-group { margin-bottom: 4px; }
.fly-group-toggle { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; color: #b0c0d8; font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 6px; transition: all 0.15s; }
.fly-group-toggle:hover { background: #213450; color: #fff; }
.fly-group-toggle .fly-arrow { font-size: 9px; color: #5a7090; transition: transform 0.2s; }
.fly-group-toggle.open .fly-arrow { transform: rotate(90deg); color: #c9a96e; }
.fly-group-body { display: none; padding-left: 12px; }
.fly-group-toggle.open + .fly-group-body { display: block; }
/* link_header 묶음 — 제목은 화면으로 가는 링크, 화살표만 접기/펴기 (26-08-01) */
.fly-group-name { flex: 1; color: inherit; text-decoration: none; }
.fly-group-name.active { color: #c9a96e; }
.fly-group-name + .fly-arrow { padding: 4px 2px 4px 10px; margin: -4px -2px -4px 0; }

/* ★ 26-08-01 버그 수정 — 이 규칙이 없어서 하위묶음을 펼쳐도 안이 안 보였다.
   지난번 펼쳐 둔 것만 base.html의 기억 CSS로 우연히 보였을 뿐이다. */
.fly-subgroup-toggle.open + .fly-group-body { display: block; }

/* 압축 줄 (26-08-01) — 4차 이상은 '이름 + 아이콘 단추'를 한 줄에 붙인다.
   그냥 펼치면 사업자 3명이 27줄을 잡아먹어 목록이 세로로 폭주한다. */
.fly-crow { display: flex; align-items: center; gap: 4px; padding-top: 3px; padding-bottom: 3px; padding-right: 4px; border-radius: 6px; }
.fly-crow:hover { background: #1c2c44; }
/* flex:1 + min-width:0 이 없으면 아이콘에 밀려 이름칸이 0px로 찌그러진다 */
.fly-cname { flex: 1 1 auto; min-width: 0; font-size: 12px; color: #90a3bf; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fly-cname:hover { color: #fff; }
.fly-cname.active { color: #c9a96e; font-weight: 600; }
.fly-chips { display: flex; gap: 0; flex-shrink: 0; }
.fly-chip { font-size: 11px; line-height: 1; padding: 3px 2px; border-radius: 4px; text-decoration: none; opacity: .55; filter: grayscale(60%); transition: all .12s; }
.fly-chip:hover { opacity: 1; filter: none; background: #2a4160; }
.fly-chip.active { opacity: 1; filter: none; background: #c9a96e; }

.fly-subgroup { margin-bottom: 2px; }
.fly-subgroup-toggle { display: flex; justify-content: space-between; align-items: center; padding: 6px 14px 6px 18px; color: #98aac4; font-size: 12px; font-weight: 600; cursor: pointer; border-radius: 6px; transition: all 0.15s; }
.fly-subgroup-toggle:hover { background: #213450; color: #fff; }
.fly-subgroup-toggle .fly-arrow { font-size: 8px; color: #5a7090; transition: transform 0.2s; }
.fly-subgroup-toggle.open .fly-arrow { transform: rotate(90deg); color: #c9a96e; }

/* 시계 (레일 하단) */
.rail-clock { width: 78px; background: linear-gradient(180deg,#0a1422,#162638); border-radius: 8px; padding: 7px 4px; text-align: center; margin: 6px 0 4px; flex-shrink: 0; border: 1px solid #1f2e44; }
.rail-clock-date { display: block; font-size: 11px; color: #8899aa; font-weight: 700; line-height: 1.3; letter-spacing: 0; font-family: 'Consolas', 'Courier New', monospace; }
.rail-clock-time { display: block; font-size: 14px; color: #c9a96e; font-weight: 700; font-family: 'Consolas', 'Courier New', monospace; line-height: 1.3; letter-spacing: 0; margin-top: 1px; }

/* 호환용 — 시계 ID 그대로 사용하기 위한 alias */
#sidebar-clock-date { display: block; }
#sidebar-clock-time { display: block; }

/* 상단 바 (사용자명) — sticky 고정 */
.top-bar { display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 50; background: #f5f5f0; margin: -24px -24px 0 -24px; padding: 10px 24px; }
.top-bar-left { display: flex; align-items: baseline; gap: 12px; min-height: 1px; }
.top-bar-left h1 { font-size: 20px; font-weight: 700; color: #0d1b2a; white-space: nowrap; line-height: 1; }
.top-bar-left .page-desc { color: #666; font-size: 13px; white-space: nowrap; }
.top-bar-right { display: flex; align-items: center; gap: 12px; }
.top-user-wrapper { position: relative; }
.top-user { font-size: 15px; font-weight: 700; color: #0d1b2a; background: #fff; padding: 10px 20px; border-radius: 24px; box-shadow: 0 2px 6px rgba(0,0,0,0.1); cursor: pointer; user-select: none; }
.top-user:hover { background: #f5f5f0; }
.user-dropdown { display: none; position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); min-width: 140px; z-index: 60; overflow: hidden; }
.user-dropdown.open { display: block; }
.user-dropdown-item { display: block; padding: 10px 16px; font-size: 14px; color: #1a1a2e; text-decoration: none; transition: background 0.15s; }
.user-dropdown-item:hover { background: #f5f5f0; color: #c9a96e; }

/* === 콘텐츠 (v3 레일 + 플라이아웃 대응) === */
.content { margin-left: 88px; padding: 24px; flex: 1; min-height: 100vh; transition: margin-left 0.2s ease; }
body.flyout-open .content { margin-left: 288px; }
.content-full { padding: 0; flex: 1; margin-left: 88px; transition: margin-left 0.2s ease; }
body.flyout-open .content-full { margin-left: 288px; }

/* === 페이지 헤더 (flex 한줄 + sticky) === */
.page-header { margin-bottom: 16px; display: flex; align-items: baseline; gap: 12px; position: sticky; top: 42px; z-index: 40; background: #f5f5f0; padding: 6px 0; }
.page-header h1 { font-size: 28px; font-weight: 700; color: #0d1b2a; white-space: nowrap; }
.page-desc { color: #666; font-size: 13px; }

/* === 카드 === */
.card { background: #fff; border-radius: 10px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); margin-bottom: 16px; }
.dashboard-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { display: flex; align-items: center; gap: 16px; }
.stat-card.warning .stat-value { color: #e74c3c; }
.stat-icon { font-size: 32px; }
.stat-value { font-size: 28px; font-weight: 700; display: block; color: #0d1b2a; }
.stat-label { font-size: 13px; color: #666; }
.stat-change { font-size: 11px; margin-top: 2px; }
.stat-change.up { color: #27ae60; }
.stat-change.down { color: #e74c3c; }
.dashboard-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* === 버튼 === */
.btn-primary { background: #c9a96e; color: #fff; }
.btn-primary:hover { background: #a8893f; }
.btn-secondary { background: #e9ecef; color: #333; }
.btn-secondary:hover { background: #dee2e6; }
.btn-outline { background: transparent; border: 1px solid #c9a96e; color: #c9a96e; }
.btn-outline:hover { background: #c9a96e; color: #fff; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-success { background: #27ae60; color: #fff; }
.btn-success:hover { background: #219a52; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; padding: 12px; font-size: 16px; }

/* === 폼 === */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: #333; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: #c9a96e; box-shadow: 0 0 0 3px rgba(201,169,110,0.15); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-inline { display: flex; gap: 8px; align-items: end; }

/* === 로그인 === */
.login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, #0d1b2a, #1b2a40); }
.login-box { background: #fff; padding: 40px; border-radius: 12px; width: 400px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.login-box h1 { text-align: center; margin-bottom: 8px; font-size: 22px; color: #0d1b2a; }
.login-logo { display: block; margin: 0 auto 16px; width: 100px; }
.login-subtitle { text-align: center; color: #666; margin-bottom: 24px; font-size: 14px; }
.login-hint { text-align: center; color: #999; font-size: 12px; margin-top: 16px; }

/* === 테이블 === */
.table-container { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: #f8f9fa; padding: 10px 8px; text-align: left; font-weight: 600; border-bottom: 2px solid #dee2e6; position: sticky; top: 0; white-space: nowrap; z-index: 5; }
tbody td { padding: 8px; border-bottom: 1px solid #eee; vertical-align: middle; }
tbody tr:hover { background: #faf8f4; }
tbody tr.selected { background: #f5edd8; }
tbody tr.group-header { background: #fff3cd; font-weight: 600; }
td input[type="number"], td input[type="text"], td input[type="date"], td select {
    padding: 4px 6px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; width: 100%;
}
td input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* === 알림 === */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: #ffeaea; color: #c0392b; border: 1px solid #f5c6cb; }
.alert-success { background: #eafff0; color: #27ae60; border: 1px solid #c3e6cb; }

/* === 토스트 === */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; }
.toast { background: #0d1b2a; color: #fff; padding: 12px 20px; border-radius: 8px; margin-bottom: 8px; font-size: 14px; animation: slideIn 0.3s ease; min-width: 250px; }
.toast.success { background: #27ae60; }
.toast.error { background: #e74c3c; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* === 탭 === */
.tabs { display: flex; gap: 0; border-bottom: 2px solid #eee; margin-bottom: 20px; }
.tab { padding: 10px 20px; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; color: #666; background: none; }
.tab.active { color: #c9a96e; border-bottom-color: #c9a96e; font-weight: 600; }

/* === 모달 === */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; justify-content: center; align-items: center; }
.modal { background: #fff; border-radius: 12px; padding: 24px; width: 500px; max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal h2 { margin-bottom: 16px; font-size: 18px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* === 그룹 표시 === */
.group-badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.group-badge.g1 { background: #e8f5e9; color: #2e7d32; }
.group-badge.g2 { background: #e3f2fd; color: #1565c0; }
.group-badge.g3 { background: #fff3e0; color: #e65100; }
.group-badge.g4 { background: #fce4ec; color: #c62828; }

/* === 도구바 === */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-right { margin-left: auto; display: flex; gap: 8px; }

/* === 빈 상태 === */
.empty-state { text-align: center; padding: 60px 20px; color: #999; }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* === 유틸리티 === */
.text-muted { color: #999; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* === 허브 그리드 === */
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.hub-card { display: flex; align-items: center; gap: 16px; background: #fff; border-radius: 12px; padding: 20px 24px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); transition: all 0.2s; text-decoration: none; color: inherit; }
.hub-card:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.hub-icon { width: 52px; height: 52px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: #fff; flex-shrink: 0; }
.hub-info h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; color: #0d1b2a; }
.hub-info p { font-size: 13px; color: #888; line-height: 1.4; }
.hub-badge { display: inline-block; background: #f0f0f0; color: #999; font-size: 11px; padding: 2px 8px; border-radius: 10px; margin-top: 4px; }

/* === 대시보드 전용 === */
.dash-stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.dash-stat { background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.dash-stat .ds-icon { font-size: 28px; margin-bottom: 8px; }
.dash-stat .ds-value { font-size: 24px; font-weight: 700; color: #0d1b2a; }
.dash-stat .ds-label { font-size: 12px; color: #888; margin-top: 4px; }
.dash-stat .ds-change { font-size: 11px; margin-top: 4px; }
.dash-stat .ds-change.up { color: #27ae60; }
.dash-stat .ds-change.down { color: #e74c3c; }

.seller-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 12px; }
.seller-table th { background: #f8f9fa; padding: 10px 12px; text-align: right; font-weight: 600; border-bottom: 2px solid #dee2e6; }
.seller-table th:first-child { text-align: left; }
.seller-table td { padding: 10px 12px; border-bottom: 1px solid #eee; text-align: right; }
.seller-table td:first-child { text-align: left; font-weight: 600; }
.seller-table tr.total-row { background: #faf7f0; }
.seller-table tr.total-row td { font-weight: 700; color: #c9a96e; border-top: 2px solid #c9a96e; }

.progress-bar-wrap { background: #eee; border-radius: 20px; height: 24px; overflow: hidden; display: flex; margin: 8px 0; }
.progress-fill { height: 100%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #fff; }
.progress-fill.done { background: #27ae60; }
.progress-fill.wait { background: #f39c12; }

.dash-shortcut-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 12px; }
.dash-shortcut { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: #f8f9fa; border-radius: 8px; text-decoration: none; color: #333; transition: all 0.15s; }
.dash-shortcut:hover { background: #f0ede5; transform: translateY(-1px); }
.dash-shortcut .sc-icon { font-size: 22px; }
.dash-shortcut .sc-name { font-size: 13px; font-weight: 600; }

.mini-chart { display: flex; align-items: flex-end; gap: 3px; height: 60px; margin-top: 12px; }
.mini-bar { flex: 1; background: #c9a96e; border-radius: 2px 2px 0 0; min-height: 4px; position: relative; }
.mini-bar-label { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); font-size: 9px; color: #888; white-space: nowrap; }

/* === 인쇄 === */
@media print {
    .sidebar, .toolbar, .btn, .no-print { display: none !important; }
    .content { margin-left: 0; padding: 0; }
    table { font-size: 11px; }
}
