/* 한우리 정산 — 토스 TDS 기반 (성과관리 DESIGN.md 색의 헌법 준용, 2026-08-16)
   원칙: 순백 바탕 + 토스 그레이 + 토스 블루 하나. 색은 신호, 굵기 600 이하.
   고령 사용자 배려: 본문 스케일을 토스보다 한 단계 크게 (17~18px). */

:root {
  --accent: #3182F6;
  --accent-hover: #1B64DA;
  --accent-light: #E8F3FF;
  --accent-ink: #1B64DA;        /* 틴트 위 글자 */
  --text-1: #191F28;
  --text-2: #6B7684;
  --text-3: #8B95A1;
  --text-disabled: #B0B8C1;
  --bg: #FFFFFF;
  --surface: #F2F4F6;
  --surface-hover: #F9FAFB;
  --border-strong: #D1D6DB;
  --border: #E5E8EB;
  --hairline: #F2F4F6;
  --success: #15C47E;
  --success-light: #F0FAF6;
  --success-ink: #027648;
  --warning: #FFB331;
  --warning-light: #FFF9E7;
  --warning-ink: #B26E16;
  --danger: #F04452;
  --danger-light: #FDEBEC;      /* 파생: 오류 틴트 (토스 red 모사다리 스냅) */
  --danger-ink: #D91C29;
  --shadow-card: 0 1px 3px rgba(25, 31, 40, .06);
  --radius-card: 16px;
  --radius-btn: 12px;
  --radius-chip: 6px;
}

/* 글꼴은 프로젝트에 내장 — 외부 CDN 의존 없음 (보안 리뷰 반영, 인터넷 없어도 동작) */
@font-face {
  font-family: "Pretendard Variable";
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
  src: url("fonts/PretendardVariable.woff2") format("woff2-variations");
}

* { box-sizing: border-box; }

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo",
    "Malgun Gothic", sans-serif;
  font-size: 17px;
  line-height: 1.55;
  margin: 0;
  background: var(--bg);
  color: var(--text-1);
}

/* ---------- 크롬 (흰 상단바 + 헤어라인) ---------- */
header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 36px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}
header h1 { font-size: 19px; font-weight: 600; margin: 0; padding: 18px 0; }
nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
nav a {
  color: var(--text-2);
  text-decoration: none;
  padding: 20px 14px 17px;
  font-size: 16px;
  font-weight: 500;
  border-bottom: 3px solid transparent;
}
nav a:hover { color: var(--text-1); background: var(--surface-hover); }
nav a.active { color: var(--text-1); border-bottom-color: var(--accent); }
nav a.accent {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  border-radius: var(--radius-btn);
  padding: 10px 20px;
  margin-left: 8px;
  border-bottom: 0;
}
nav a.accent:hover { background: var(--accent-hover); color: #fff; }
nav a.muted { color: var(--text-3); margin-left: auto; }

main { max-width: 1150px; margin: 32px auto; padding: 0 20px 80px; }

h2 { font-size: 22px; font-weight: 600; margin: 8px 0 4px; }
h3 { font-size: 17px; font-weight: 600; margin: 32px 0 6px; }

/* ---------- 요약 카드 ---------- */
.cards { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 8px; }
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 20px 24px;
  flex: 1;
  min-width: 240px;
}
.card .label { font-size: 14px; font-weight: 500; color: var(--text-2); }
.card .num {
  font-size: 34px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
  letter-spacing: -0.5px;
}
.card.highlight { background: var(--accent-light); border-color: transparent; }
.card.highlight .label { color: var(--accent-ink); }
.card.highlight .num { color: var(--accent-ink); font-weight: 500; }

/* ---------- 알림 ---------- */
.notice {
  background: var(--warning-light);
  border-radius: 12px;
  padding: 12px 18px;
  margin: 16px 0 0;
}
.notice a { color: var(--warning-ink); text-decoration: none; font-weight: 600; }
.flash {
  background: var(--success-light);
  color: var(--success-ink);
  border-radius: 12px;
  padding: 12px 18px;
  margin-bottom: 16px;
  font-size: 16px;
}
.flash p { margin: 2px 0; }
.error { color: var(--danger); font-weight: 600; }

/* ---------- 조작 요소 ---------- */
select, input[type=text], input[type=number], input[type=password] {
  font-family: inherit;
  font-size: 16px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-1);
}
select:focus-visible, input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
button {
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  padding: 10px 20px;
  border: 0;
  border-radius: var(--radius-btn);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:hover { background: var(--accent-hover); }
button.small { font-size: 14px; padding: 6px 14px; border-radius: 9px; }
button.danger { background: var(--bg); color: var(--danger); border: 1px solid var(--border); }
button.danger:hover { background: var(--danger-light); }
button.muted-btn { background: var(--surface); color: var(--text-2); }
button.muted-btn:hover { background: var(--border); }

.filter { margin: 20px 0 4px; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.filter label { font-size: 15px; color: var(--text-2); display: flex; gap: 8px; align-items: center; }

/* ---------- 표 ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  margin-top: 14px;
  font-variant-numeric: tabular-nums;
}
th {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-hover);
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--hairline);
  font-size: 16px;
}
tbody tr:hover { background: var(--surface-hover); }
td.balance { font-weight: 600; }
td.empty { text-align: center; color: var(--text-3); padding: 48px; }
td a { color: var(--accent); text-decoration: none; font-weight: 500; }

/* 상태 칩 — 행 전체를 칠하지 않는다 (색은 신호, 화면은 조용히) */
.chip {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-chip);
  white-space: nowrap;
}
.chip-ok { background: var(--success-light); color: var(--success-ink); }
.chip-pending { background: var(--warning-light); color: var(--warning-ink); }
.chip-mismatch { background: var(--danger-light); color: var(--danger-ink); }

.muted { color: var(--text-2); font-size: 15px; }

/* ---------- 확인 필요함 그룹 ---------- */
.group {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 18px 22px;
  margin: 12px 0;
}
.group-head { margin-bottom: 12px; font-size: 16px; }
.group-head b { font-weight: 600; }
.inline-form {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 4px;
}
.inline-form span { font-size: 15px; color: var(--text-2); }

details summary {
  cursor: pointer;
  color: var(--text-2);
  font-size: 15px;
  padding: 6px 0;
}
details ul { font-size: 15px; color: var(--text-2); }
.other-details { margin-top: 36px; }
.footer-note { margin-top: 28px; font-size: 14px; color: var(--text-3); }

/* ---------- 올리기 ---------- */
.upload-form { margin: 20px 0; }
.dropzone {
  display: block;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-card);
  padding: 48px;
  text-align: center;
  background: var(--surface-hover);
  cursor: pointer;
  margin-bottom: 16px;
  font-size: 19px;
  color: var(--text-1);
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-light); }
.dropzone small { color: var(--text-2); font-size: 15px; }
.dropzone input { display: block; margin: 16px auto 0; font-size: 15px; }

/* ---------- 지점별 현황 막대 ---------- */
.barcell { width: 28%; }
.bar { background: var(--accent); height: 14px; border-radius: 4px; min-width: 2px; opacity: .85; }

/* ---------- 표 정돈 최소 추가 (2026-08-16 — 값은 전부 기존 토큰) ---------- */
th.num-col, td.num-col { text-align: right; }        /* 숫자 열 오른끝 정렬 (토스 표 문법) */
.quiet { color: var(--text-2); }                      /* 0건 등 비어있는 수치 — 크기 유지, 색만 물러남 */
tr.month-start td { border-top: 1px solid var(--border-strong); }  /* 달 경계선 */
td.month-cell { font-weight: 600; white-space: nowrap; }           /* 달 라벨 (그룹 첫 행에만 표기) */

/* ---------- 로그인 ---------- */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg);
  margin: 0;
}
.login-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(25, 31, 40, .08);
  padding: 48px 56px;
  text-align: center;
}
.login-box h1 { font-size: 24px; font-weight: 600; margin: 0 0 24px; }
.login-box input { display: block; width: 280px; margin: 0 auto 14px; font-size: 18px; text-align: center; }
.login-box button { width: 280px; font-size: 17px; padding: 12px; }

/* ---------- 확인 필요함 화면 보강 (review, 2026-08-16) ---------- */
.group-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  flex-wrap: wrap;
}
.group-meta {
  color: var(--text-2);
  font-size: 15px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.group details { margin-bottom: 8px; }
.inline-form {
  display: flex;          /* 줄바꿈 시에도 좌측 정렬 유지 */
  gap: 10px 8px;
}
.inline-form select,
.inline-form input[type=text],
.inline-form input[type=number] { max-width: 100%; }
.inline-form + .inline-form { margin-top: 8px; }
.empty-state { text-align: center; padding: 44px 24px; }
.empty-state .empty-title { font-size: 17px; font-weight: 600; margin: 0 0 6px; }
.empty-state .muted { margin: 0; }

/* 평소 차액과 다른 건 강조 (예측값 표시 대신 실측 이상만 — 2026-08-16) */
td.diff-unusual { background: var(--warning-light); color: var(--warning-ink); }

/* ---------- 지점 대사 펼침 목록 ---------- */
.site-head, .site-acc summary {
  display: grid;
  grid-template-columns: 1.4fr .6fr 1fr 1fr 1fr 1.6fr;
  gap: 10px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}
.site-head {
  font-size: 13px; font-weight: 500; color: var(--text-2);
  background: var(--surface-hover); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 18px; margin-top: 14px;
}
.site-head .r, .site-acc summary .r { text-align: right; }
.site-acc {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 12px; margin: 8px 0; box-shadow: var(--shadow-card);
}
.site-acc summary {
  cursor: pointer; padding: 13px 18px; font-size: 16px; list-style: none;
  color: var(--text-1);
}
.site-acc summary::-webkit-details-marker { display: none; }
.site-acc summary:hover { background: var(--surface-hover); border-radius: 12px; }
.site-acc[open] summary { border-bottom: 1px solid var(--hairline); }
.site-acc .site-name { font-weight: 600; color: var(--accent); }
.site-acc .acc-body { padding: 4px 18px 18px; }
.site-acc .acc-body h4 { font-size: 14px; color: var(--text-2); margin: 16px 0 0; }
.site-acc .acc-body table { box-shadow: none; border: 1px solid var(--hairline); border-radius: 10px; overflow: hidden; }
@media (max-width: 760px) {
  .site-head { display: none; }
  .site-acc summary { grid-template-columns: 1fr 1fr; }
}

/* ---------- 모바일·폴드 대응 (2026-08-16) ---------- */
@media (max-width: 840px) {
  header { padding: 0 12px; gap: 8px; }
  header h1 { font-size: 17px; padding: 12px 0; width: 100%; padding-bottom: 0; }
  nav { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  nav a { padding: 12px 10px 10px; font-size: 14.5px; white-space: nowrap; }
  nav a.accent { padding: 8px 14px; margin-left: 4px; }
  main { margin: 14px auto; padding: 0 10px 60px; }
  .cards { gap: 10px; }
  .card { min-width: 150px; padding: 14px 16px; }
  .card .num { font-size: 24px; }
  h2 { font-size: 19px; }
  /* 표는 제자리에서 옆으로 스크롤 (화면 전체가 밀리지 않게) */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { padding: 9px 10px; font-size: 14px; white-space: nowrap; }
  .filter { gap: 8px; }
  select, input[type=text], input[type=number], input[type=password] {
    font-size: 16px; /* 폰에서 자동 확대 방지 */ padding: 9px 10px; max-width: 60vw;
  }
  .inline-form { gap: 6px; }
  button { padding: 10px 16px; }
  .group { padding: 14px 14px; }
  .site-acc summary { padding: 12px 12px; font-size: 14.5px; gap: 6px; }
  .site-acc .acc-body { padding: 4px 10px 14px; }
  .dropzone { padding: 28px 14px; font-size: 18px; }
}

.dl-btn { background: var(--surface); color: var(--text-1); border-radius: var(--radius-btn);
  padding: 9px 16px; text-decoration: none; font-size: 15px; font-weight: 600; }
.dl-btn:hover { background: var(--border); }
