/* SAP 인력 소싱 · 수익성 관리 — 업무용 화면 스타일
   외부 폰트·CDN 을 쓰지 않는다(오프라인 단독 실행이 전제). */

:root {
  --brand: #12395f;
  --brand-2: #1c5183;
  --accent: #0a6ed1;
  --accent-soft: #eaf3fc;
  --pos: #107e3e;
  --neg: #bb0000;
  --warn: #b35309;
  --warn-bg: #fff4e5;
  --neg-bg: #fdeaea;
  --pos-bg: #eaf5ee;
  --ink: #1c2530;
  --ink-2: #5b6a7a;
  --ink-3: #8a97a5;
  --line: #dde3ea;
  --line-2: #eef2f6;
  --bg: #f2f5f8;
  --panel: #ffffff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(20, 40, 70, .09), 0 6px 18px rgba(20, 40, 70, .05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic",
        "Apple SD Gothic Neo", "Noto Sans KR", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ── 레이아웃 ───────────────────────────────────────────── */
#app { display: grid; grid-template-columns: 216px 1fr; height: 100vh; }

#sidebar {
  background: var(--brand); color: #cfe0ef;
  display: flex; flex-direction: column; overflow: hidden;
}
.brand { padding: 16px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand h1 { margin: 0; font-size: 14px; color: #fff; letter-spacing: -.2px; }
.brand small { display: block; margin-top: 3px; font-size: 11px; color: #8fb4d4; }

nav { flex: 1; overflow-y: auto; padding: 8px 0; }
nav .group { padding: 12px 16px 5px; font-size: 10.5px; letter-spacing: .8px;
             text-transform: uppercase; color: #6f96b8; }
nav button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  background: none; border: 0; padding: 8px 16px; cursor: pointer;
  color: #cfe0ef; font-size: 13px; border-left: 3px solid transparent;
}
nav button:hover { background: rgba(255,255,255,.07); color: #fff; }
nav button.active { background: rgba(255,255,255,.13); color: #fff;
                    border-left-color: #59a7f0; font-weight: 600; }
nav button .ico { width: 16px; text-align: center; opacity: .9; font-size: 13px; }
nav button .badge { margin-left: auto; background: rgba(255,255,255,.16);
                    border-radius: 9px; padding: 1px 7px; font-size: 11px; }

.side-foot { padding: 10px 16px 12px; border-top: 1px solid rgba(255,255,255,.1);
             font-size: 11px; color: #7ea4c6; }
.side-foot button.link { color: #8fb4d4; }
.side-foot button.link:hover { color: #fff; }
.side-foot code { font-family: var(--mono); font-size: 10px; word-break: break-all;
                  color: #6f96b8; display: block; margin-top: 4px; }

#main { display: flex; flex-direction: column; overflow: hidden; }

header.topbar {
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 10px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
header.topbar h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.2px; }
header.topbar .sub { color: var(--ink-2); font-size: 12px; }
.spacer { flex: 1; }

#content { flex: 1; overflow-y: auto; padding: 18px 20px 60px; }
.view { display: none; }
.view.active { display: block; animation: fade .16s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px);} to {opacity:1;transform:none;} }

/* ── 공통 요소 ───────────────────────────────────────────── */
.panel { background: var(--panel); border: 1px solid var(--line);
         border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; }
.panel > h3 { margin: 0; padding: 12px 16px; font-size: 13.5px; font-weight: 650;
              border-bottom: 1px solid var(--line-2); display: flex;
              align-items: center; gap: 10px; }
.panel > h3 .hint { font-weight: 400; color: var(--ink-3); font-size: 11.5px; }
.panel .body { padding: 14px 16px; }
.panel .body.tight { padding: 0; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
                             .g3 { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 820px)  { .g2,.g3,.g4 { grid-template-columns: 1fr; }
                             #app { grid-template-columns: 64px 1fr; }
                             .brand h1, .brand small, nav button span:not(.ico),
                             .side-foot { display: none; } }

button.btn {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: 6px 13px; border-radius: 6px; cursor: pointer; font-size: 12.5px;
  font-weight: 550; white-space: nowrap;
}
button.btn:hover { background: #0959ab; border-color: #0959ab; }
button.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line); }
button.btn.ghost:hover { background: #f5f8fb; border-color: #c3cedb; }
button.btn.danger { background: var(--neg); border-color: var(--neg); }
button.btn.danger:hover { background: #970000; }
button.btn.sm { padding: 3px 9px; font-size: 11.5px; }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer;
              padding: 0; font-size: 12.5px; }
button.link:hover { text-decoration: underline; }

input[type=text], input[type=number], input[type=date], input[type=month],
input[type=search], input[type=email], select, textarea {
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 9px;
  background: #fff; min-width: 0; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft);
}
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 11.5px;
          color: var(--ink-2); }
label.f > span { font-weight: 550; }
label.f .req { color: var(--neg); }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 760px) { .form-grid { grid-template-columns: 1fr; }
                            .form-grid .wide, .form-grid .full { grid-column: auto; } }

/* ── KPI ────────────────────────────────────────────────── */
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
       padding: 13px 15px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi .k-label { font-size: 11.5px; color: var(--ink-2); font-weight: 550; }
.kpi .k-value { font-size: 22px; font-weight: 680; letter-spacing: -.6px; margin-top: 5px;
                font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.kpi.accent { border-left: 3px solid var(--accent); }
.kpi.pos  .k-value { color: var(--pos); }
.kpi.neg  .k-value { color: var(--neg); }

/* ── 표 ─────────────────────────────────────────────────── */
.tablewrap { overflow: auto; max-height: 62vh; }
table.dt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
table.dt th, table.dt td { padding: 6px 10px; border-bottom: 1px solid var(--line-2);
                           text-align: left; white-space: nowrap; }
table.dt thead th {
  /* z-index 3: 히트맵 셀 내부의 .hv(z-index 1)보다 위여야 스크롤 시 글자가 겹치지 않는다 */
  position: sticky; top: 0; z-index: 3; background: #f7f9fc; color: var(--ink-2);
  font-weight: 600; font-size: 11.5px; border-bottom: 1px solid var(--line);
  cursor: pointer; user-select: none;
}
table.dt thead th:hover { background: #eef3f9; }
table.dt thead th.nosort { cursor: default; }
table.dt thead th .arw { color: var(--accent); font-size: 9px; margin-left: 3px; }
table.dt tbody tr:hover { background: #f7fafd; }
table.dt tbody tr.sel { background: var(--accent-soft); }
table.dt td.num, table.dt th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.dt td.mono { font-family: var(--mono); font-size: 11.5px; }
table.dt tfoot td { font-weight: 680; background: #f7f9fc; border-top: 2px solid var(--line);
                    position: sticky; bottom: 0; z-index: 3; }
table.dt .rowact { opacity: 0; }
table.dt tr:hover .rowact { opacity: 1; }
.empty { padding: 34px 16px; text-align: center; color: var(--ink-3); font-size: 13px; }
.empty b { display: block; color: var(--ink-2); margin-bottom: 5px; font-size: 14px; }

.pos { color: var(--pos); } .neg { color: var(--neg); } .muted { color: var(--ink-3); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px;
       background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.tag.b { background: var(--accent-soft); color: var(--accent); }
.tag.g { background: var(--pos-bg); color: var(--pos); }
.tag.r { background: var(--neg-bg); color: var(--neg); }
.tag.o { background: var(--warn-bg); color: var(--warn); }

/* 히트맵 셀 */
td.heat { position: relative; }
td.heat .hv { position: relative; z-index: 1; }
td.heat .hb { position: absolute; inset: 2px 3px; border-radius: 3px; z-index: 0; }

/* ── 차트 ───────────────────────────────────────────────── */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-size: 10.5px; fill: var(--ink-2); }
.chart .axis line, .chart .axis path { stroke: var(--line); }
.chart .grid line { stroke: var(--line-2); }
.chart .lbl-strong { fill: var(--ink); font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px;
          color: var(--ink-2); padding: 0 16px 12px; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block;
            margin-right: 5px; vertical-align: -1px; }

/* ── 모달 / 드로어 ──────────────────────────────────────── */
.backdrop { position: fixed; inset: 0; background: rgba(16,28,42,.45); z-index: 60;
            display: flex; align-items: flex-start; justify-content: center;
            padding: 40px 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 900px;
         box-shadow: 0 20px 60px rgba(10,25,45,.3); animation: pop .16s ease; }
.modal.narrow { max-width: 520px; }
.modal.wide { max-width: 1150px; }
@keyframes pop { from { opacity:0; transform: translateY(-8px) scale(.99);} to {opacity:1;} }
.modal header { padding: 14px 18px; border-bottom: 1px solid var(--line);
                display: flex; align-items: center; gap: 10px; }
.modal header h3 { margin: 0; font-size: 15px; }
.modal .mbody { padding: 16px 18px; max-height: 68vh; overflow-y: auto; }
.modal footer { padding: 12px 18px; border-top: 1px solid var(--line);
                display: flex; gap: 8px; justify-content: flex-end; background: #fafcfe;
                border-radius: 0 0 10px 10px; }
.x { margin-left: auto; background: none; border: 0; font-size: 20px; line-height: 1;
     cursor: pointer; color: var(--ink-3); padding: 0 4px; }
.x:hover { color: var(--ink); }

/* ── 알림 ───────────────────────────────────────────────── */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 90;
          display: flex; flex-direction: column; gap: 8px; }
.toast { background: #21313f; color: #fff; padding: 10px 15px; border-radius: 7px;
         box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 12.5px; max-width: 420px;
         animation: slide .2s ease; }
.toast.err { background: var(--neg); }
.toast.ok  { background: var(--pos); }
@keyframes slide { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; } }

.alertbox { padding: 9px 13px; border-radius: 7px; font-size: 12.5px; margin-bottom: 12px;
            border: 1px solid; }
.alertbox.warn { background: var(--warn-bg); border-color: #f3d3a8; color: var(--warn); }
.alertbox.err  { background: var(--neg-bg); border-color: #f2c3c3; color: var(--neg); }
.alertbox.info { background: var(--accent-soft); border-color: #c3ddf5; color: var(--brand-2); }

/* ── 업로드 마법사 ──────────────────────────────────────── */
.steps { display: flex; gap: 0; margin-bottom: 16px; }
.steps .st { flex: 1; padding: 8px 12px; background: #f4f7fa; color: var(--ink-3);
             font-size: 12px; text-align: center; border: 1px solid var(--line);
             border-right: 0; position: relative; }
.steps .st:last-child { border-right: 1px solid var(--line); border-radius: 0 6px 6px 0; }
.steps .st:first-child { border-radius: 6px 0 0 6px; }
.steps .st.on { background: var(--accent); color: #fff; border-color: var(--accent);
                font-weight: 600; }
.steps .st.done { background: var(--accent-soft); color: var(--accent);
                  border-color: #c3ddf5; }

.dropzone { border: 2px dashed var(--line); border-radius: 10px; padding: 34px 20px;
            text-align: center; background: #fafcfe; cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone .big { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.dropzone .sm { color: var(--ink-2); font-size: 12px; }

.maprow { display: grid; grid-template-columns: 1fr 24px 1fr; gap: 8px; align-items: center;
          padding: 5px 0; border-bottom: 1px solid var(--line-2); }
.maprow .src { font-weight: 550; }
.maprow .src small { display: block; color: var(--ink-3); font-weight: 400;
                     font-size: 11px; white-space: nowrap; overflow: hidden;
                     text-overflow: ellipsis; }
.maprow .arr { text-align: center; color: var(--ink-3); }

.filterchips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--accent-soft);
        color: var(--brand-2); border: 1px solid #c3ddf5; border-radius: 14px;
        padding: 2px 5px 2px 10px; font-size: 11.5px; }
.chip button { background: none; border: 0; cursor: pointer; color: var(--brand-2);
               font-size: 14px; line-height: 1; padding: 0 3px; }

.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.subtabs button { background: none; border: 0; border-bottom: 2px solid transparent;
                  padding: 7px 14px; cursor: pointer; color: var(--ink-2); font-size: 13px; }
.subtabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.kv { display: grid; grid-template-columns: 130px 1fr; gap: 5px 12px; font-size: 12.5px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 550; }

.hbar { display: flex; align-items: center; gap: 8px; }
.hbar .track { flex: 1; height: 7px; background: var(--line-2); border-radius: 4px;
               overflow: hidden; min-width: 40px; }
.hbar .fill { height: 100%; background: var(--accent); border-radius: 4px; }
.hbar .fill.neg { background: var(--neg); }

.loading { padding: 40px; text-align: center; color: var(--ink-3); }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line);
        border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite;
        vertical-align: -3px; margin-right: 7px; }
@keyframes sp { to { transform: rotate(360deg); } }

@media print {
  #sidebar, header.topbar .noprint, .noprint { display: none !important; }
  #app { grid-template-columns: 1fr; }
  #content { overflow: visible; padding: 0; }
  .panel { break-inside: avoid; box-shadow: none; }
  .tablewrap { max-height: none; overflow: visible; }
}
