/* ============================================================
   로젠 지점운영 앱 — 디자인 시스템
   (디자인 시트: design/DESIGN-SHEET.html 참조)
   ============================================================ */

/* ---------- 토큰 ---------- */
:root {
  --on-brand: #1A1D21;      /* 노랑 배경 위 텍스트 */
  --brand-ink: #7A5C00;     /* 흰 배경 위 브랜드 텍스트 */
  /* 브랜드 */
  --red-600: #FFC400;   /* 주 브랜드(로젠 옐로) */
  --red-700: #EFB000;
  --red-50:  #FFF7DC;
  --red-100: #FFE9A8;

  /* 중립 */
  --gray-900: #1A1D21;
  --gray-700: #3E444C;
  --gray-500: #6B727C;
  --gray-400: #9AA1AB;
  --gray-300: #C9CED6;
  --gray-200: #E4E7EC;
  --gray-100: #F1F3F6;
  --gray-50:  #F8F9FB;
  --white: #FFFFFF;

  /* 의미색 */
  --blue-600: #1D5BD6;  /* 정보/배송중 */
  --blue-50:  #EAF0FC;
  --green-600:#0E7A3C;  /* 완료 */
  --green-50: #E8F5EE;
  --amber-700:#945E00;  /* 대기/주의 */
  --amber-50: #FBF3E0;
  --redst-600:#C22A1F;  /* 미배송/반품(상태) */
  --redst-50: #FCEBEA;

  /* 타이포 */
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
          "Malgun Gothic", "Apple SD Gothic Neo", system-ui, Roboto, sans-serif;
  --fs-xxl: 24px; --fs-xl: 20px; --fs-lg: 17px;
  --fs-md: 15px;  --fs-sm: 13px; --fs-xs: 12px;

  /* 간격/모서리/그림자 */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-full: 999px;
  --shadow-1: 0 1px 3px rgba(26,29,33,.08);
  --shadow-2: 0 4px 16px rgba(26,29,33,.12);

  --tabbar-h: 60px;
  --topbar-h: 52px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--fs-md);
  color: var(--gray-900);
  background: var(--gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: var(--fs-md); }

/* ---------- 레이아웃 ---------- */
#app { display: flex; min-height: 100vh; }
.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.view {
  flex: 1;
  padding: var(--sp-4);
  padding-bottom: calc(var(--tabbar-h) + var(--sp-6) + env(safe-area-inset-bottom));
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* 상단바 */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding-left: var(--sp-4); padding-right: var(--sp-3);
}
.topbar h1 { font-size: var(--fs-lg); font-weight: 700; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: var(--sp-2); }

.icon-btn {
  position: relative;
  width: 38px; height: 38px; border: none; background: none;
  border-radius: var(--r-full); font-size: 19px; color: var(--gray-700);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: var(--gray-100); }
.dot {
  position: absolute; top: 7px; right: 7px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--redst-600); border: 1.5px solid var(--white);
}

/* 하단 탭바 (모바일) */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
}
.tab-item {
  flex: 1; border: none; background: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: var(--fs-xs); color: var(--gray-500); font-weight: 500;
}
.tab-item .ti { font-size: 21px; line-height: 1; }
.tab-item.active { color: var(--brand-ink); font-weight: 700; }

/* 사이드바 (데스크톱 = 웹 대시보드) */
.sidebar { display: none; }

@media (min-width: 1024px) {
  .sidebar {
    display: flex; flex-direction: column;
    width: 240px; flex-shrink: 0;
    background: var(--gray-900); color: var(--white);
    position: sticky; top: 0; height: 100vh;
  }
  .sidebar-brand { display: flex; gap: var(--sp-3); align-items: center; padding: var(--sp-5) var(--sp-4); }
  .brand-logo {
    width: 40px; height: 40px; border-radius: var(--r-md);
    background: var(--red-600); color: var(--on-brand);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 22px;
  }
  .brand-name { font-weight: 700; font-size: var(--fs-md); }
  .brand-sub { font-size: var(--fs-xs); color: var(--gray-400); }
  .sidebar-nav { flex: 1; padding: var(--sp-2); display: flex; flex-direction: column; gap: 2px; }
  .side-item {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 11px var(--sp-3); border: none; background: none; width: 100%;
    color: var(--gray-300); font-size: var(--fs-md); border-radius: var(--r-sm);
    text-align: left;
  }
  .side-item .ti { font-size: 18px; width: 24px; text-align: center; }
  .side-item:hover { background: rgba(255,255,255,.07); color: var(--white); }
  .side-item.active { background: var(--red-600); color: var(--on-brand); font-weight: 700; }
  .sidebar-foot { padding: var(--sp-4); border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
  .sidebar-user { font-size: var(--fs-sm); color: var(--gray-300); }
  .sidebar-user b { color: var(--white); display: block; }

  .tabbar { display: none; }
  #backBtn { display: none !important; }
  .view { padding: var(--sp-6); padding-bottom: var(--sp-6); }
}

/* ---------- 공통 컴포넌트 ---------- */
.hidden { display: none !important; }

.card {
  background: var(--white); border-radius: var(--r-md);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-1);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.card-title { font-size: var(--fs-md); font-weight: 700; margin-bottom: var(--sp-3); display:flex; align-items:center; justify-content:space-between; gap: var(--sp-2); }
.card-title .more { font-size: var(--fs-sm); color: var(--gray-500); font-weight: 500; background:none; border:none; }

.section-label { font-size: var(--fs-sm); font-weight: 700; color: var(--gray-500); margin: var(--sp-4) 0 var(--sp-2); }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--r-sm);
  font-size: var(--fs-md); font-weight: 600;
  padding: 12px 18px; min-height: 46px;
  background: var(--red-600); color: var(--on-brand);
}
.btn:active { background: var(--red-700); }
.btn-outline { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-outline:active { background: var(--gray-100); }
.btn-ghost { background: none; color: var(--gray-400); border: 1px solid var(--gray-500); }
.btn-sm { min-height: 36px; padding: 7px 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; }

/* 배지 */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 700; white-space: nowrap;
}
.badge-role { background: var(--red-50); color: var(--brand-ink); }
.bg-wait  { background: var(--amber-50); color: var(--amber-700); }
.bg-move  { background: var(--blue-50);  color: var(--blue-600); }
.bg-done  { background: var(--green-50); color: var(--green-600); }
.bg-fail  { background: var(--redst-50); color: var(--redst-600); }
.bg-etc   { background: var(--gray-100); color: var(--gray-500); }

/* KPI 통계 타일 */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
@media (min-width: 720px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--r-md);
  padding: var(--sp-4); box-shadow: var(--shadow-1);
}
.kpi .k-label { font-size: var(--fs-sm); color: var(--gray-500); font-weight: 600; }
.kpi .k-value { font-size: var(--fs-xxl); font-weight: 800; margin-top: 2px; letter-spacing: -0.5px; }
.kpi .k-sub { font-size: var(--fs-xs); color: var(--gray-400); margin-top: 2px; }
.kpi.accent { border-top: 3px solid var(--red-600); }

/* 리스트 행 */
.row-item {
  display: flex; align-items: center; gap: var(--sp-3);
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-2); width: 100%; text-align: left;
}
.row-item:active { background: var(--gray-50); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: var(--fs-sm); color: var(--gray-500); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row-meta { font-size: var(--fs-xs); color: var(--gray-400); }

/* 필터 칩 */
.chips { display: flex; gap: var(--sp-2); overflow-x: auto; padding-bottom: var(--sp-2); margin-bottom: var(--sp-2); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--gray-300); background: var(--white);
  border-radius: var(--r-full); padding: 7px 14px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--gray-700);
  white-space: nowrap; flex-shrink: 0;
}
.chip.active { background: var(--gray-900); border-color: var(--gray-900); color: var(--white); }
.chip.chip-red.active { background: var(--red-600); border-color: var(--red-600); color: var(--on-brand); }

/* 폼 */
.form-group { margin-bottom: var(--sp-4); }
.form-label { display: block; font-size: var(--fs-sm); font-weight: 700; color: var(--gray-700); margin-bottom: 6px; }
.form-label .req { color: var(--red-600); }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px;
  border: 1px solid var(--gray-300); border-radius: var(--r-sm);
  padding: 11px 13px; background: var(--white); color: var(--gray-900);
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { outline: 2px solid var(--red-600); outline-offset: -1px; border-color: transparent; }
.input::placeholder { color: var(--gray-400); }
.form-row { display: flex; gap: var(--sp-3); }
.form-row > * { flex: 1; }
.form-hint { font-size: var(--fs-xs); color: var(--gray-400); margin-top: 4px; }

/* 검색바 */
.searchbar { display: flex; gap: var(--sp-2); margin-bottom: var(--sp-3); }
.searchbar .input { flex: 1; }

/* 모달 */
.modal-wrap {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(26,29,33,.5);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--white); width: 100%; max-width: 560px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: var(--sp-5) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
  animation: slideUp .22s ease;
}
@media (min-width: 720px) {
  .modal-wrap { align-items: center; }
  .modal { border-radius: var(--r-lg); padding: var(--sp-6); }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal-title { font-size: var(--fs-xl); font-weight: 800; margin-bottom: var(--sp-4); }
.modal-actions { display: flex; gap: var(--sp-3); margin-top: var(--sp-5); }
.modal-actions .btn { flex: 1; }

/* 토스트 */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  background: var(--gray-900); color: var(--white);
  padding: 11px 20px; border-radius: var(--r-full);
  font-size: var(--fs-sm); font-weight: 600;
  z-index: 60; box-shadow: var(--shadow-2);
  max-width: 90vw; text-align: center;
}

/* 상세 정의 리스트 */
.dl { display: grid; grid-template-columns: 92px 1fr; row-gap: 9px; column-gap: var(--sp-3); font-size: var(--fs-md); }
.dl dt { color: var(--gray-500); font-size: var(--fs-sm); padding-top: 2px; }
.dl dd { font-weight: 500; word-break: break-all; }

/* 타임라인 */
.timeline { list-style: none; margin-top: var(--sp-2); }
.timeline li { position: relative; padding: 0 0 var(--sp-3) var(--sp-5); }
.timeline li::before {
  content: ""; position: absolute; left: 6px; top: 6px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--gray-300);
}
.timeline li:first-child::before { background: var(--red-600); }
.timeline li::after {
  content: ""; position: absolute; left: 9.5px; top: 16px; bottom: 0;
  width: 1px; background: var(--gray-200);
}
.timeline li:last-child::after { display: none; }
.tl-text { font-size: var(--fs-sm); font-weight: 600; }
.tl-time { font-size: var(--fs-xs); color: var(--gray-400); }

/* 로그인 */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  justify-content: center; padding: var(--sp-6); max-width: 440px; margin: 0 auto;
}
.login-logo {
  width: 64px; height: 64px; border-radius: 18px; background: var(--red-600);
  color: var(--on-brand); font-size: 36px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; margin-bottom: var(--sp-4);
}
.login-title { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.login-sub { color: var(--gray-500); margin: var(--sp-2) 0 var(--sp-6); }
.role-grid { display: grid; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.role-card {
  display: flex; align-items: center; gap: var(--sp-4); text-align: left;
  background: var(--white); border: 1.5px solid var(--gray-200); border-radius: var(--r-md);
  padding: var(--sp-4);
}
.role-card.active { border-color: var(--red-600); background: var(--red-50); }
.role-icon { font-size: 28px; }
.role-name { font-weight: 700; font-size: var(--fs-lg); }
.role-desc { font-size: var(--fs-sm); color: var(--gray-500); }

/* 차트 */
.chart-box { width: 100%; overflow: hidden; }
.chart-legend { display: flex; gap: var(--sp-4); font-size: var(--fs-xs); color: var(--gray-500); margin-top: var(--sp-2); flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; }

/* 진행률 바 */
.progress { height: 8px; background: var(--gray-100); border-radius: var(--r-full); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--red-600); border-radius: var(--r-full); }

/* 랭킹 */
.rank-num { width: 28px; height: 28px; border-radius: 50%; background: var(--gray-100); color: var(--gray-500); font-size: var(--fs-sm); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.rank-num.top { background: var(--red-600); color: var(--on-brand); }

/* 빈 상태 */
.empty { text-align: center; padding: 48px 16px; color: var(--gray-400); }
.empty .e-icon { font-size: 40px; margin-bottom: var(--sp-2); }
.empty .e-text { font-size: var(--fs-md); font-weight: 600; color: var(--gray-500); }
.empty .e-sub { font-size: var(--fs-sm); margin-top: 4px; }

/* 유틸 */
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); }
.mb-0 { margin-bottom: 0; }
.text-sm { font-size: var(--fs-sm); } .text-muted { color: var(--gray-500); }
.flex { display: flex; align-items: center; gap: var(--sp-2); }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
@media (min-width: 900px) { .grid-2-desk { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); align-items: start; } }

/* 터치 스테퍼 (숫자 키보드 대신 알람 설정식 터치 입력) */
.stepper { display: flex; align-items: center; gap: var(--sp-2); }
.stepper .st-btn {
  width: 52px; height: 52px; border-radius: var(--r-md);
  border: 1.5px solid var(--gray-300); background: var(--white);
  font-size: 18px; font-weight: 800; color: var(--gray-700);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0; user-select: none;
}
.stepper .st-btn:active { background: var(--red-50); border-color: var(--red-600); color: var(--red-600); }
.stepper .st-val {
  flex: 1; text-align: center; font-size: 30px; font-weight: 800;
  color: var(--gray-900); letter-spacing: -0.5px; min-width: 70px;
}
.stepper .st-val small { font-size: 14px; color: var(--gray-400); font-weight: 600; }
.step-presets { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }
.step-presets .chip { flex: 1; text-align: center; justify-content: center; display: inline-flex; }


/* 근무표: 모바일=일별 리스트, 데스크톱(웹)=주간 종합 그리드 */
.sched-grid { display: none; }
@media (min-width: 1024px) {
  .sched-grid { display: block; }
  .sched-daylist { display: none; }
}
.sg-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.sg-table th, .sg-table td { border: 1px solid var(--gray-200); padding: 6px 8px; text-align: center; }
.sg-table th { background: var(--gray-50); font-size: var(--fs-xs); color: var(--gray-500); }
.sg-table th.red, .sg-table td.red-head { color: var(--redst-600); }
.sg-table td.name { text-align: left; white-space: nowrap; font-weight: 600; }
.sg-table td.name small { color: var(--gray-400); font-weight: 400; }
.sg-cell {
  width: 100%; border: none; border-radius: 6px; padding: 5px 0;
  font-size: var(--fs-xs); font-weight: 700; cursor: pointer;
}
.sg-cell.work { background: var(--green-50); color: var(--green-600); }
.sg-cell.off  { background: var(--redst-50); color: var(--redst-600); }
.sg-cell.leave { background: var(--blue-50); color: var(--blue-600); }
.sg-sum td { background: var(--gray-50); font-weight: 700; font-size: var(--fs-xs); }

/* 근무표 월간 달력 (PC) */
.cal-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: var(--sp-4); align-items: start; }
.cal-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-table th { padding: 6px 0; font-size: var(--fs-xs); color: var(--gray-500); border-bottom: 1px solid var(--gray-200); }
.cal-table th.red { color: var(--redst-600); }
.cal-cell {
  border: 1px solid var(--gray-100); vertical-align: top;
  height: 86px; padding: 6px; cursor: pointer; border-radius: 4px;
  transition: background .12s;
}
.cal-cell:hover { background: var(--red-50); }
.cal-cell.cal-sel { background: var(--red-50); outline: 2px solid var(--red-600); outline-offset: -2px; }
.cal-cell.cal-empty { background: var(--gray-50); cursor: default; }
.cal-top { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; }
.cal-num { font-size: var(--fs-sm); font-weight: 700; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.cal-num.red { color: var(--redst-600); }
.cal-num.cal-today { background: var(--gray-900); color: var(--white); }
.cal-hol { font-size: 10px; color: var(--redst-600); font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-badges { display: flex; flex-direction: column; gap: 2px; }
.cal-b { font-size: 10.5px; font-weight: 700; border-radius: 4px; padding: 1px 5px; width: fit-content; }
.cal-b.work { background: var(--green-50); color: var(--green-600); }
.cal-b.off { background: var(--redst-50); color: var(--redst-600); }
.cal-b.leave { background: var(--blue-50); color: var(--blue-600); }
