/* ===== 리셋 & 기본 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif; background: #f4f5f7; color: #1a1a2e; line-height: 1.5; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ===== 레이아웃 ===== */
.app-layout { display: flex; height: 100vh; overflow: hidden; }

/* ===== 사이드바 ===== */
.sidebar {
  width: 220px; min-width: 220px;
  background: #ffffff;
  border-right: 1px solid #e8eaed;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 16px;
  border-bottom: 1px solid #e8eaed;
}
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: #1a73e8; color: #fff;
  font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.logo-mark-img {
  width: 30px; height: 30px; object-fit: contain;
  flex-shrink: 0;
}
.logo-name { font-size: 13px; font-weight: 700; color: #1a1a2e; line-height: 1.25; }
.logo-sub { font-size: 10px; color: #80868b; margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 10px 8px; }
.nav-section { margin-bottom: 16px; }
.nav-label {
  font-size: 10px; font-weight: 600; color: #80868b;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0 8px; margin-bottom: 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px; border-radius: 8px;
  font-size: 13px; color: #444746;
  margin-bottom: 1px; transition: background 0.1s;
}
.nav-item:hover { background: #f1f3f4; color: #1a1a2e; }
.nav-item.active { background: #e8f0fe; color: #1a73e8; font-weight: 600; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: #ea4335; color: #fff;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center;
}

.sidebar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-top: 1px solid #e8eaed;
}
.user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #e8f0fe; color: #1a73e8;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.user-name { font-size: 12px; font-weight: 600; color: #1a1a2e; }
.user-role { font-size: 10px; color: #80868b; }
.logout-btn {
  background: none; border: none; color: #80868b; padding: 4px;
  border-radius: 6px; display: flex; align-items: center;
}
.logout-btn:hover { background: #f1f3f4; color: #ea4335; }

/* ===== 메인 콘텐츠 ===== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 52px; background: #fff;
  border-bottom: 1px solid #e8eaed;
  display: flex; align-items: center;
  padding: 0 24px; gap: 12px; flex-shrink: 0;
}
.page-title { font-size: 15px; font-weight: 600; color: #1a1a2e; flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.menu-toggle {
  display: none; background: none; border: none; padding: 6px;
  border-radius: 6px; color: #444746; flex-shrink: 0; margin-right: 4px;
}
.menu-toggle:hover { background: #f1f3f4; }
.menu-toggle svg { width: 20px; height: 20px; }

.sidebar-overlay { display: none; }

.content-body {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  max-width: 1440px; width: 100%; margin: 0 auto;
}

/* ===== 버튼 ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  border: 1px solid #dadce0; background: #fff; color: #444746;
  transition: background 0.1s, border-color 0.1s, transform 0.06s ease, box-shadow 0.1s;
}
.btn:hover { background: #f8f9fa; }
.btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.985);
  box-shadow: inset 0 1px 3px rgba(60,64,67,0.18);
}
.btn-primary { background: #1a73e8; color: #fff; border-color: #1a73e8; }
.btn-primary:hover { background: #1557b0; }
.btn-primary:active:not(:disabled) { background: #0f4593; }
.btn-danger { background: #ea4335; color: #fff; border-color: #ea4335; }
.btn-danger:hover { background: #c5221f; }
.btn-danger:active:not(:disabled) { background: #a50e0e; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn svg { width: 14px; height: 14px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* 클래스 없는 인라인 버튼(날짜기준 탭·연도·그룹 등)·클릭 카드 공통 누름 피드백 */
button { transition: transform 0.06s ease, filter 0.1s ease; }
button:active:not(:disabled) { transform: translateY(1px); }
.metric-card[onclick] { transition: transform 0.06s ease, box-shadow 0.1s; }
.metric-card[onclick]:active { transform: translateY(1px) scale(0.99); }

/* ===== 필터 패널 ===== */
.filter-card {
  display: flex; flex-direction: column; gap: 12px;
  background: #fff; border: 1px solid #e8eaed; border-radius: 14px;
  padding: 14px 18px; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(60,64,67,.06);
}
.ftrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ftlabel {
  font-size: 11px; font-weight: 700; color: #9aa0a6;
  letter-spacing: .04em; text-transform: uppercase; flex: 0 0 auto;
}
.ftdiv { width: 1px; align-self: stretch; min-height: 26px; background: #e8eaed; margin: 0 4px; }
.fc-sep { height: 1px; background: #eceff1; margin: 2px 0; }
.ftspacer { flex: 1 1 auto; }

/* 입력 공통 */
.fc-input {
  height: 36px; font-size: 13px; color: #3c4043;
  border: 1px solid #dadce0; border-radius: 9px; padding: 0 12px;
  background: #fff; transition: border-color .12s, box-shadow .12s;
}
.fc-input:hover { border-color: #bdc1c6; }
.fc-input:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 3px rgba(26,115,232,.15); }
input[type="date"].fc-input { width: 150px; }
select.fc-input {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%235f6368' stroke-width='2'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

/* 세그먼트 컨트롤 (트랙 + 흰 활성 알약) */
.seg { display: inline-flex; gap: 2px; background: #f1f3f4; border-radius: 10px; padding: 3px; }
.seg button {
  padding: 6px 15px; font-size: 12px; font-weight: 500; color: #5f6368;
  border: none; background: transparent; border-radius: 7px; cursor: pointer;
  transition: background .12s, color .12s, box-shadow .12s;
}
.seg button:not(.on):hover { color: #202124; }
.seg button.on { background: #fff; color: #1a73e8; font-weight: 600; box-shadow: 0 1px 2px rgba(60,64,67,.2); }

/* 빠른기간 / 연도 칩 */
.preset-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.preset {
  padding: 6px 14px; font-size: 12px; font-weight: 500; color: #444746;
  border: 1px solid #dadce0; border-radius: 18px; background: #fff; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.preset:hover { background: #f8f9fa; border-color: #bdc1c6; }
.preset.active {
  background: #1a73e8; border-color: #1a73e8; color: #fff;
  box-shadow: 0 1px 3px rgba(26,115,232,.4);
}

/* 검색창 */
.search-box { position: relative; display: inline-flex; align-items: center; flex: 1 1 220px; max-width: 300px; }
.search-box svg { position: absolute; left: 12px; width: 16px; height: 16px; color: #9aa0a6; pointer-events: none; }
.search-box .fc-input { width: 100%; padding-left: 38px; }

/* 필터 적용중 배지 */
.filter-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: #1a73e8;
  background: #e8f0fe; padding: 5px 11px; border-radius: 14px;
}

/* 요약 통계 */
.fc-stats { display: inline-flex; align-items: center; gap: 22px; }
.fc-stat { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.fc-stat .lbl { font-size: 11px; color: #80868b; }
.fc-stat .val { font-size: 17px; font-weight: 700; }
.fc-warn {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #7d5c00;
  background: #fef7e0; border: 1px solid #fde293; border-radius: 9px; padding: 6px 12px;
}

@media (max-width: 768px) {
  .filter-card { padding: 12px 14px; }
  .search-box { max-width: none; }
  .fc-stats { gap: 14px; }
  .ftlabel { display: none; }
}

/* ===== 카드 ===== */
.card {
  background: #fff; border: 1px solid #e8eaed;
  border-radius: 12px; padding: 16px 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.card-title { font-size: 13px; font-weight: 600; color: #1a1a2e; }
.card-link { font-size: 12px; color: #1a73e8; }

/* ===== 메트릭 카드 ===== */
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.metric-card {
  background: #fff; border: 1px solid #e8eaed; border-radius: 12px;
  padding: 16px 18px;
}
.metric-label { font-size: 11px; color: #80868b; margin-bottom: 6px; }
.metric-value { font-size: 24px; font-weight: 700; color: #1a1a2e; }
.metric-sub { font-size: 11px; color: #80868b; margin-top: 4px; }
.text-up { color: #137333; }
.text-down { color: #c5221f; }
.text-warn { color: #b06000; }

/* ===== 테이블 ===== */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid #e8eaed; background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  padding: 10px 14px; background: #f8f9fa;
  color: #80868b; font-size: 11px; font-weight: 600;
  text-align: left; border-bottom: 1px solid #e8eaed;
  white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid #f1f3f4; color: #1a1a2e; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8f9fa; }
tbody tr.selected { background: #e8f0fe; }
input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; accent-color: #1a73e8; }

/* ===== 배지 ===== */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 10px; white-space: nowrap;
}
.badge-new     { background: #e8f0fe; color: #1a73e8; }
.badge-preparing { background: #fce8e6; color: #c5221f; }
.badge-shipped { background: #e6f4ea; color: #137333; }
.badge-issue   { background: #fce8e6; color: #c5221f; }
.badge-frozen  { background: #e8f0fe; color: #0d47a1; }
.badge-cold    { background: #e6f9f4; color: #00695c; }
.badge-room    { background: #fef3e2; color: #8a5000; }
.badge-set     { background: #f0ebff; color: #4a148c; }
.badge-bundle  { background: #fce4ec; color: #880e4f; }
.badge-single  { background: #e6f4ea; color: #1b5e20; }
.badge-mapped  { background: #e6f4ea; color: #137333; }
.badge-unmapped { background: #fce8e6; color: #c5221f; }

/* ===== 필터 바 ===== */
.filter-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 0; margin-bottom: 12px; flex-wrap: wrap;
}
.filter-bar input,
.filter-bar select {
  padding: 7px 10px; font-size: 13px;
  border: 1px solid #dadce0; border-radius: 8px;
  background: #fff; color: #1a1a2e;
  outline: none;
}
.filter-bar input:focus,
.filter-bar select:focus { border-color: #1a73e8; }
.filter-bar input { width: 220px; }

/* ===== 요약 바 ===== */
.summary-bar {
  display: flex; gap: 10px; align-items: center;
  background: #fff; border: 1px solid #e8eaed;
  border-radius: 12px; padding: 12px 18px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.summary-item { display: flex; flex-direction: column; align-items: center; min-width: 60px; }
.summary-num { font-size: 20px; font-weight: 700; color: #1a1a2e; }
.summary-label { font-size: 10px; color: #80868b; margin-top: 2px; }
.summary-divider { width: 1px; height: 32px; background: #e8eaed; margin: 0 4px; }

/* ===== 하단 액션 바 ===== */
.action-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; background: #fff;
  border-top: 1px solid #e8eaed; border-radius: 0 0 12px 12px;
}
.action-info { font-size: 12px; color: #80868b; flex: 1; }

/* ===== 알림 배너 ===== */
.flash {
  padding: 10px 16px; border-radius: 8px; font-size: 13px;
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.flash-info    { background: #e8f0fe; color: #1a73e8; border: 1px solid #c5d9f7; }
.flash-success { background: #e6f4ea; color: #137333; border: 1px solid #b7dfbc; }
.flash-warning { background: #fef3e2; color: #8a5000; border: 1px solid #fddcaa; }
.flash-error   { background: #fce8e6; color: #c5221f; border: 1px solid #f5c6c2; }

/* ===== 폼 ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: span 2; }
.form-label { font-size: 11px; font-weight: 600; color: #444746; }
.form-control {
  padding: 8px 12px; font-size: 13px;
  border: 1px solid #dadce0; border-radius: 8px;
  background: #fff; color: #1a1a2e; outline: none;
}
.form-control:focus { border-color: #1a73e8; }
.form-control[readonly] { background: #f8f9fa; color: #80868b; }

/* ===== 섹션 구분 ===== */
.section { margin-bottom: 24px; }
.section-title {
  font-size: 12px; font-weight: 600; color: #80868b;
  padding-bottom: 8px; margin-bottom: 12px;
  border-bottom: 1px solid #e8eaed;
  display: flex; align-items: center; justify-content: space-between;
}

/* ===== 로그인 ===== */
.login-page {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: #f4f5f7;
}
.login-card {
  background: #fff; border: 1px solid #e8eaed; border-radius: 16px;
  padding: 40px 36px; width: 380px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-mark { margin: 0 auto 10px; width: 44px; height: 44px; font-size: 22px; }
.login-logo .logo-mark-img { margin: 0 auto 10px; width: 44px; height: 44px; }
.login-logo h1 { font-size: 20px; font-weight: 700; }
.login-logo p { font-size: 12px; color: #80868b; margin-top: 4px; }
.login-error { background: #fce8e6; color: #c5221f; border-radius: 8px; padding: 8px 14px; font-size: 13px; margin-bottom: 14px; }

/* ===== 대시보드 그리드 ===== */
.dashboard-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }

/* ===== 바 차트 (순수 CSS) ===== */
.bar-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid #f1f3f4; font-size: 12px; }
.bar-row:last-child { border-bottom: none; }
.bar-label { width: 70px; color: #80868b; }
.bar-bg { flex: 1; height: 7px; background: #f1f3f4; border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-val { width: 30px; text-align: right; font-weight: 600; color: #1a1a2e; }

/* ===== 매핑 박스 ===== */
.mapping-box { border: 1px solid #e8eaed; border-radius: 10px; overflow: hidden; }
.mapping-header { background: #f8f9fa; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; }
.mapping-row { display: flex; align-items: stretch; }
.mapping-col { flex: 1; padding: 10px 14px; border-bottom: 1px solid #f1f3f4; }
.mapping-col:first-child { border-right: 1px solid #f1f3f4; }
.mapping-col-label { font-size: 10px; color: #80868b; margin-bottom: 3px; }
.mapping-col-val { font-size: 13px; color: #1a1a2e; }
.mapping-arrow { width: 36px; display: flex; align-items: center; justify-content: center; color: #80868b; border-bottom: 1px solid #f1f3f4; }
.mapping-row.unmapped { background: #fef9f0; }
.mapping-row.unmapped .mapping-col-val { color: #c5221f; }

/* ===== 반응형 ===== */
@media (max-width: 1200px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* 태블릿 / 모바일: 사이드바를 오프캔버스 메뉴로 전환 */
@media (max-width: 968px) {
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }

  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 200;
    width: 260px; min-width: 260px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.08);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,0.4); z-index: 190;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s ease;
  }
  .sidebar-overlay.open { opacity: 1; pointer-events: auto; }

  .content-body { padding: 16px; }
  .topbar { padding: 0 16px; }
}

/* 모바일: 한눈에 보이도록 단일 컬럼 + 여백/폰트 축소 */
@media (max-width: 640px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .metric-card { padding: 12px 14px; }
  .metric-value { font-size: 19px; }
  .metric-label { font-size: 10px; }

  .card { padding: 14px 16px; }
  .content-body { padding: 12px; }
  .page-title { font-size: 14px; }

  .filter-bar { gap: 6px; }
  .filter-bar input,
  .filter-bar select { flex: 1 1 auto; min-width: 120px; width: auto; }

  .summary-bar { padding: 10px 12px; gap: 8px; }

  .table-wrap table { font-size: 12px; }
  thead th, tbody td { padding: 8px 10px; }

  .bar-label { width: 56px !important; font-size: 11px; }

  .btn-sm { padding: 6px 9px; font-size: 11px; white-space: nowrap; }
  .topbar-actions {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    max-width: 56vw; padding-bottom: 1px;
  }
  .topbar-actions::-webkit-scrollbar { display: none; }
}

@media (max-width: 420px) {
  .metric-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .login-card { width: 92vw; padding: 32px 24px; }
}
