@font-face {
  font-family: "Pretendard";
  src: url("/static/fonts/Pretendard-Regular.subset.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Pretendard";
  src: url("/static/fonts/Pretendard-SemiBold.subset.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Pretendard";
  src: url("/static/fonts/Pretendard-Bold.subset.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

* { box-sizing: border-box; }
:root {
  --navy: #16273f;
  --navy-light: #1f3554;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff4ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Pretendard", system-ui, "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 4px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; font-weight: 600; }
.muted { color: var(--muted); }

/* ---------- 탑바 ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 54px;
}
.brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.12rem;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  display: inline-block;
}
.brand:hover { text-decoration: none; }
.nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav a {
  color: #cbd5e1;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.95rem;
  position: relative;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.nav a.active { color: #fff; font-weight: 600; }
.nav a.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 2px;
  height: 2px;
  border-radius: 2px;
  background: #60a5fa;
}
.inline-form { margin: 0; }
.btn-link {
  background: none;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  padding: 7px 12px;
  font-size: 0.95rem;
  border-radius: 8px;
  font-family: inherit;
}
.btn-link:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }

/* ---------- 레이아웃 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.container.review-container { max-width: 1200px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-link { display: block; color: var(--text); transition: box-shadow 0.15s ease, transform 0.15s ease; }
.card-link:hover { box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08); transform: translateY(-2px); text-decoration: none; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.card-grid .card { margin-bottom: 0; }
.card-grid .card h2 { margin-bottom: 6px; color: var(--primary); }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.2;
  transition: background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  text-decoration: none;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-block { width: 100%; }
.btn-sm { min-height: 0; padding: 5px 11px; font-size: 0.85rem; border-radius: 8px; }
.btn-sm.btn-danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.btn-sm.btn-danger:hover { background: #fee2e2; }

/* ---------- 알림 ---------- */
.alert { padding: 11px 14px; border-radius: 10px; margin: 12px 0; font-size: 0.95rem; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-soft); color: #166534; border: 1px solid #bbf7d0; }

/* ---------- 폼 ---------- */
label { display: block; margin-bottom: 14px; font-weight: 600; font-size: 0.92rem; }
input[type="text"],
input[type="password"],
input[type="number"],
input[type="month"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
textarea { min-height: auto; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ---------- 테이블 ---------- */
.table-wrap {
  overflow-x: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}
th {
  background: #f8fafc;
  font-weight: 600;
  white-space: nowrap;
}
.sortable-th { padding: 0; }
.sortable-header {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 11px 12px;
  color: var(--text);
}
.sortable-header:hover { background: var(--primary-soft); text-decoration: none; }
.sortable-header:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.sort-indicator { color: var(--primary); font-size: 0.72rem; }
.sort-indicator-idle { color: #9ca3af; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* ---------- 배지 ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
  color: #fff;
  white-space: nowrap;
  font-weight: 500;
}
.badge-active { background: var(--success); }
.badge-inactive { background: #9aa3ad; }

/* ---------- 툴바/요약 ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.toolbar input, .toolbar select { width: auto; min-height: 42px; margin: 0; }
.month-label { font-weight: 700; font-size: 1.05rem; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.summary-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.summary-card .value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.summary-card .label { color: var(--muted); font-size: 0.82rem; font-weight: 500; }

/* ---------- 검수 화면 ---------- */
.row-input { width: 110px; min-height: 38px; padding: 7px 9px; margin: 0; }
.balance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.balance-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin: 0;
  transition: border-color 0.12s ease;
}
.balance-item span { display: block; margin-bottom: 8px; font-size: 0.9rem; font-weight: 500; }
.balance-item input { width: 100%; min-height: 42px; }
.inline-form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form-row label { margin-bottom: 0; }
.inline-form-row input { margin-top: 4px; }

/* ---------- 팀 색상 ---------- */
.swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
  vertical-align: middle;
}
.color-picker-field {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 16px;
}
.color-picker {
  width: 76px;
  height: 48px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}
.color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.color-picker::-webkit-color-swatch { border: 0; border-radius: 6px; }
.color-picker:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.team-color-form {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  white-space: nowrap;
}
.color-picker-compact {
  width: 48px;
  height: 34px;
  padding: 3px;
  border-radius: 8px;
}
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; }

/* ---------- 로그인 ---------- */
.login-wrap {
  max-width: 400px;
  margin: 10vh auto 0;
  text-align: center;
}
.login-wrap h1 { font-size: 1.8rem; margin-bottom: 2px; }
.login-card { text-align: left; padding: 26px; }
.login-card label { margin-bottom: 16px; }
body:has(.login-wrap) { background: linear-gradient(160deg, var(--navy) 0%, #1e3a5f 55%, var(--primary-dark) 100%); }
body:has(.login-wrap) .login-wrap h1 { color: #fff; }
body:has(.login-wrap) .login-wrap .muted { color: #cbd5e1; }

/* ---------- 푸터 ---------- */
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 18px 0 28px;
}

/* ---------- 페이지네이션 ---------- */
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-top: 14px;
}
.pagination .muted { font-size: 0.9rem; }

/* ---------- 모바일 ---------- */
@media (max-width: 640px) {
  body { font-size: 14px; }
  .topbar-inner { padding: 0 12px; min-height: 50px; }
  .container { padding: 16px 10px 56px; }
  .card { padding: 16px; }
  th, td { padding: 9px 8px; }
  .summary-card .value { font-size: 1.35rem; }
}

/* 월간 검수: 집중 입력과 스크롤 중 행 식별 */
.input-tools { padding: 12px; background: #f5f8fc; }
.input-tools label { display: inline-flex; align-items: center; gap: 8px; }
.input-tools p { flex-basis: 100%; margin: 4px 0; }
.input-tools select { width: auto; }
.review-input-table td:first-child, .review-input-table th:first-child {
  position: sticky; left: 0; background: #fff; z-index: 1;
}
.review-input-table th:first-child { background: #edf3f9; }
/* Compare choices stay within their field; one differing row must not widen the column. */
.review-input-table { table-layout: fixed; min-width: 1080px; }
.review-input-table th, .review-input-table td { padding: 8px 6px; vertical-align: top; }
.review-input-table th:nth-child(1) { width: 140px; }
.review-input-table th:nth-child(2) { width: 90px; }
.review-input-table th:nth-child(3) { width: 112px; }
.review-input-table th:nth-child(4) { width: 92px; }
.review-input-table th:nth-child(5) { width: 96px; }
.review-input-table th:nth-child(6), .review-input-table th:nth-child(7) { width: 132px; }
.review-input-table th:nth-child(8) { width: 180px; }
.review-input-table th:nth-child(9) { width: 82px; }
.review-input-table th:nth-child(10) { width: 64px; }
.review-input-table .row-input, .review-input-table select {
  width: 100%; min-width: 0; max-width: 100%; min-height: 38px; margin: 0; padding: 7px;
}
.review-input-table input[data-field="point_no"],
.review-input-table input[data-field="amount"],
.review-input-table input[data-field="carry"] { font-variant-numeric: tabular-nums; }
.review-input-table input[data-field="amount"],
.review-input-table input[data-field="carry"] { text-align: right; }
.review-input-table input[data-field="carry"]::placeholder { color: #536477; opacity: 1; }
.review-input-table th.money-carry, .review-input-table tr > td.money-carry { background: #e1efff; }
.review-input-table th.money-amount, .review-input-table tr > td.money-amount { background: #fff0d6; }
.review-input-table .money-carry input { border: 2px solid #3978b8; background: #f6faff; }
.review-input-table .money-amount input { border: 2px solid #a96612; background: #fffaf0; }
#review-floating-header { position: fixed; z-index: 9; overflow: hidden; pointer-events: none; box-shadow: 0 2px 5px #0003; }
#review-floating-header table { margin: 0; }
#review-floating-header th { background: #edf3f9; vertical-align: top; }
#review-floating-header th.money-carry { background: #e1efff; }
#review-floating-header th.money-amount { background: #fff0d6; }
#confirm-feedback p { margin: 0 0 8px; }
#confirm-feedback .review-error-link { color: inherit; text-align: left; text-decoration: underline; }
.review-input-table .row-del { width: 100%; padding-left: 4px; padding-right: 4px; }
.review-input-table.focus-input { min-width: 620px; }
.review-input-table.focus-input th:nth-child(2), .review-input-table.focus-input td:nth-child(2),
.review-input-table.focus-input th:nth-child(4), .review-input-table.focus-input td:nth-child(4),
.review-input-table.focus-input th:nth-child(5), .review-input-table.focus-input td:nth-child(5),
.review-input-table.focus-input th:nth-child(8), .review-input-table.focus-input td:nth-child(8),
.review-input-table.focus-input th:nth-child(9), .review-input-table.focus-input td:nth-child(9) { display: none; }
.draft-toolbar p { overflow-wrap: anywhere; }
[hidden] { display: none !important; }

.person-link-cell { overflow-wrap: anywhere; }
.person-name { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.person-name .badge { white-space: nowrap; margin: 0; padding: 2px 8px; }
.person-link-editor, .person-source { margin-top: 4px; font-size: .85rem; }
.person-link-editor > select { width: 100%; margin: 6px 0; }
.person-link-editor .btn { margin-bottom: 4px; }
.row-error { display: block; font-size: .85rem; overflow-wrap: anywhere; }
.review-input-table .review-row-auto > td { background: #f0faf3; }
.review-input-table .review-row-manual > td, .review-input-table .review-row-pending > td { background: #fff9e9; }
.review-input-table .review-row-new > td { background: #eff6ff; }
.link-state-auto { background: #d7efdf; color: #205e37; }
.link-state-manual, .link-state-pending { background: #fff0b9; color: #704e00; }
.link-state-new { background: #dbeaff; color: #244f89; }
.profile-choices { display: flex; flex-direction: column; gap: 5px; margin-top: 8px; min-width: 0; }
.profile-choice { width: 100%; min-width: 0; padding: 6px 3px; white-space: normal; border: 2px solid #b3becb; background: #fff; }
.profile-choice span, .profile-choice strong { display: block; }
.profile-choice span { font-size: .75rem; color: #526176; }
.profile-choice strong { margin-top: 4px; overflow-wrap: anywhere; }
.profile-choice.is-selected { border-color: #2463ac; background: #e6f0ff; }
.profile-choices small { white-space: normal; overflow-wrap: anywhere; }
