/* 셀픽 유료인화 정산 — 단정하고 여백 있는 관리 화면 */
:root {
  --bg: #f5f6f8; --card: #fff; --line: #e5e7eb; --line2: #d1d5db; --text: #111827; --muted: #6b7280;
  --brand: #1d4ed8; --brand-dark: #1e40af; --brand-soft: #eff4ff;
  --danger: #b91c1c; --danger-bg: #fef2f2; --ok: #047857; --ok-bg: #ecfdf5; --warn: #b45309; --warn-bg: #fffbeb;
  --radius: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
.hidden { display: none !important; }
header { background: #fff; border-bottom: 1px solid var(--line); padding: 0 32px; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
header .title { display: flex; align-items: center; gap: 18px; }
header .brand { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: var(--text); }
nav.apps { display: inline-flex; background: #f3f4f6; border-radius: 9px; padding: 3px; }
nav.apps a { text-decoration: none; color: var(--muted); font-size: 14px; font-weight: 600; padding: 7px 18px; border-radius: 7px; }
nav.apps a.on { background: var(--brand); color: #fff; }
nav.apps a:not(.on):hover { color: var(--text); }
header .user { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
header .user a, header .user button { background: #fff; border: 1px solid var(--line2); color: var(--text); font-size: 13px; padding: 6px 12px; border-radius: 8px; cursor: pointer; font-weight: 500; text-decoration: none; }
header .user a:hover, header .user button:hover { background: #f3f4f6; }
nav.tabs { display: flex; gap: 4px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 24px; overflow-x: auto; position: sticky; top: 0; z-index: 10; }
nav.tabs button { background: transparent; border: none; color: var(--muted); font-size: 14px; font-weight: 600; padding: 14px 14px 12px; cursor: pointer; white-space: nowrap; border-bottom: 2px solid transparent; }
nav.tabs button:hover { color: var(--text); }
nav.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.wrap { max-width: 1760px; margin: 0 auto; padding: 24px 28px 48px; }
@media (min-width: 1900px) { .wrap { max-width: calc(100vw - 96px); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px; }
.card h2 { margin: 0 0 16px; font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head h2 { margin: 0; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { padding: 9px 12px; font-size: 14px; border: 1px solid var(--line2); border-radius: 8px; background: #fff; color: var(--text); height: 38px; }
.toolbar input[type="text"], .toolbar input[type="search"] { min-width: 240px; }
.toolbar label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.btn { font-size: 13px; font-weight: 600; padding: 0 14px; height: 38px; border-radius: 8px; border: 1px solid var(--line2); background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f3f4f6; }
.btn.pri { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.pri:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #fca5a5; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.sm { font-size: 12px; padding: 0 10px; height: 30px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
th { background: #f9fafb; font-weight: 600; font-size: 12.5px; color: #4b5563; position: sticky; top: 0; letter-spacing: 0.01em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrapc { white-space: normal; min-width: 200px; }
tr.total td { font-weight: 700; background: #fafafa; border-top: 2px solid var(--line2); }
tr.inactive td { color: var(--muted); text-decoration: line-through; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: #f9fafb; }
tbody tr:hover td { background: #fafbfc; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; background: var(--brand-soft); color: var(--brand); padding: 3px 9px; border-radius: 6px; line-height: 1.3; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--danger-bg); color: var(--danger); }
.badge.gray { background: #f3f4f6; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.kpi .l { font-size: 13px; color: var(--muted); }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .s { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; line-height: 1.55; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #fde68a; }
.alert.bad { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert.ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #a7f3d0; }
.alert.info { background: var(--brand-soft); color: #1e3a8a; border: 1px solid #c7d2fe; }
.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 32px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: #374151; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; font-size: 14px; border: 1px solid var(--line2); border-radius: 8px; background: #fff; color: var(--text); }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus, .toolbar select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(29,78,216,0.12); }
.field textarea { min-height: 64px; resize: vertical; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.msg { font-size: 13.5px; padding: 10px 14px; border-radius: 8px; margin-top: 12px; display: none; }
.msg.ok { display: block; background: var(--ok-bg); color: var(--ok); }
.msg.err { display: block; background: var(--danger-bg); color: var(--danger); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
small.muted { font-size: 12.5px; display: inline-block; line-height: 1.5; }
p { margin: 8px 0; }
#gate { position: fixed; inset: 0; background: var(--bg); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
#gate .box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 36px 32px; max-width: 380px; width: 100%; text-align: center; }
#gate h2 { margin: 0 0 6px; font-size: 20px; }
#gate p { margin: 0 0 24px; font-size: 14px; color: var(--muted); }
#gate .gsign { width: 100%; padding: 13px; font-size: 15px; font-weight: 600; border-radius: 10px; border: 1px solid var(--line2); background: #fff; cursor: pointer; }
#gate .gerr { color: var(--danger); font-size: 13px; margin-top: 14px; min-height: 18px; }
#modal { position: fixed; inset: 0; background: rgba(17,24,39,0.45); display: flex; align-items: center; justify-content: center; z-index: 90; padding: 20px; }
#modal .sheet { background: #fff; border-radius: 14px; padding: 26px 28px; width: 100%; max-width: 900px; max-height: 92vh; overflow-y: auto; }
#modal h2 { margin: 0 0 18px; font-size: 17px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: #111827; color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 13.5px; opacity: 0; transition: all .2s; z-index: 200; pointer-events: none; max-width: 90vw; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(0,0,0,0.15); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.steps span { font-size: 12.5px; padding: 5px 12px; border-radius: 6px; background: #f3f4f6; color: var(--muted); }
.steps span.done { background: var(--ok-bg); color: var(--ok); }
.steps span.cur { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { background: #f3f4f6; color: var(--text); }
th .sortmark { color: var(--brand); font-size: 11px; }
tr.sel td { background: #fefce8; }
@media (max-width: 768px) { .wrap { padding: 14px; } header { padding: 0 14px; height: auto; min-height: 56px; flex-wrap: wrap; } header .title { flex-direction: column; gap: 0; } .card { padding: 14px; } nav.tabs { padding: 0 8px; } }
h3.sub { font-size: 14px; font-weight: 600; color: #374151; margin: 0 0 10px; }
.kpi .v.brand { color: var(--brand); } .kpi .v.ok { color: var(--ok); } .kpi .v.danger { color: var(--danger); }
.toolbar input[type="month"] { height: 38px; }
/* 주요 지수 강조: 나가는 돈(지급액·지급합계)은 볼드 + 블루, 정산대상은 볼드 */
td.key { font-weight: 700; color: var(--brand); }
th.key { color: var(--brand); }
td.sub { font-weight: 600; }
tr.total td.key { color: var(--brand); }
/* 지급대장: 엑셀 틀고정 — 표 영역 안에서만 스크롤, 헤더와 왼쪽 4열(선택·연·월·가맹점명) 고정 */
.tbl-wrap.frozen { max-height: calc(100vh - 330px); min-height: 320px; overflow: auto; }
.tbl-wrap.frozen thead th { position: sticky; top: 0; z-index: 3; background: #f9fafb; box-shadow: inset 0 -1px 0 var(--line); }
.tbl-wrap.frozen th:nth-child(-n+4), .tbl-wrap.frozen td:nth-child(-n+4) { position: sticky; background: #fff; z-index: 2; }
.tbl-wrap.frozen thead th:nth-child(-n+4) { z-index: 4; background: #f9fafb; }
.tbl-wrap.frozen th:nth-child(1), .tbl-wrap.frozen td:nth-child(1) { left: 0; width: 44px; min-width: 44px; }
.tbl-wrap.frozen th:nth-child(2), .tbl-wrap.frozen td:nth-child(2) { left: 44px; width: 64px; min-width: 64px; }
.tbl-wrap.frozen th:nth-child(3), .tbl-wrap.frozen td:nth-child(3) { left: 108px; width: 52px; min-width: 52px; }
.tbl-wrap.frozen th:nth-child(4), .tbl-wrap.frozen td:nth-child(4) { left: 160px; min-width: 190px; box-shadow: inset -1px 0 0 var(--line); }
.tbl-wrap.frozen tbody tr:hover td { background: #fafbfc; }
.tbl-wrap.frozen tr.sel td { background: #fefce8; }
tr.internal td { color: var(--muted); }
tr.internal td.key { color: var(--muted); font-weight: 600; }
tr.total.muted td { color: var(--muted); background: #fafafa; border-top: 1px solid var(--line); }
tr.total.muted td.key { color: var(--muted); }
/* 매출관리 원장 */
td.cell { cursor: pointer; line-height: 1.25; }
td.cell:hover { background: #eef2ff; }
td.cell.bad { background: #fff5f5; } td.cell.warn { background: #fffbeb; } td.cell.ok { background: #f0fdf4; }
td.cell small.bad { color: var(--danger); } td.cell small.warn { color: var(--warn); } td.cell small.ok { color: var(--ok); }
.tbl-wrap.frozen th.sticky-name, .tbl-wrap.frozen td.sticky-name { position: sticky; left: 0; background: #fff; z-index: 2; min-width: 220px; box-shadow: inset -1px 0 0 var(--line); white-space: normal; }
.tbl-wrap.frozen thead th.sticky-name { z-index: 4; background: #f9fafb; }
.kpi .v.warn { color: var(--warn); }
/* 헤더 티커 (날씨·환율) */
/* 거래처 검색 선택기 */
.picker { position: relative; }
.picker .picker-q { width: 100%; padding: 9px 12px; font-size: 14px; border: 1px solid var(--line2); border-radius: 8px; }
.picker-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: #fff; border: 1px solid var(--line2); border-radius: 8px; max-height: 320px; overflow: auto; box-shadow: 0 8px 24px rgba(0,0,0,.12); margin-top: 4px; }
.picker-item { padding: 8px 12px; cursor: pointer; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.picker-item:last-child { border-bottom: none; } .picker-item:hover, .picker-item.on { background: var(--brand-soft); }
