/* ============================================================
   VIOL CRM — 디자인 시스템
   레퍼런스: 상단 네이비 글로벌바 + 흰 헤더(브레드크럼/서브탭) +
   연회색 바탕 위 카드 컨테이너 + 밀도 높은 데이터 그리드
   ============================================================ */

:root {
  --navy: #0e3a66;            /* 글로벌 바 */
  --navy-deep: #0a2c4e;
  --accent: #00a4eb;          /* VIOL 메인 블루 — 링크·강조 숫자 */
  --accent-strong: #0b7fd4;
  --bg: #f4f6f9;              /* 페이지 바탕 */
  --card: #ffffff;
  --line: #e3e8ee;
  --line-strong: #cfd8e3;
  --text: #23303f;
  --text-sub: #6b7a8c;
  --green: #1e9e58;
  --red: #d94141;
  --amber: #e8a13a;
  --yellow-col: #fff7dc;      /* 입력열 하이라이트 */
  --green-col: #edf8f1;       /* 계산열 하이라이트 */
  --hover: #f2f7fd;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 42, 74, .07), 0 1px 2px rgba(16, 42, 74, .05);
  font-size: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }
body {
  font-family: "Pretendard Variable", Pretendard, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-strong); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------------- 글로벌 네비게이션 바 ---------------- */
.topbar {
  height: 52px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  display: flex; align-items: center;
  padding: 0 18px;
  position: sticky; top: 0; z-index: 100;
  color: #fff;
}
.topbar .brand {
  display: flex; align-items: center; gap: 11px;
  color: #fff;
  margin-right: 28px; white-space: nowrap;
}
.topbar .brand-logo { height: 19px; width: auto; display: block; }
.topbar .brand-sep { width: 1px; height: 18px; background: rgba(255,255,255,.28); }
.topbar .brand-suffix {
  font-size: 14px; font-weight: 800; letter-spacing: .5px; color: var(--accent);
  background: rgba(0,164,235,.14); border: 1px solid rgba(0,164,235,.35);
  padding: 2.5px 9px; border-radius: 6px;
}

.gnb { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.gnb a {
  color: rgba(255,255,255,.82);
  padding: 7px 13px; border-radius: 7px;
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.gnb a:hover { background: rgba(255,255,255,.10); color: #fff; }
.gnb a.active { background: rgba(255,255,255,.16); color: #fff; }

.topbar .right { display: flex; align-items: center; gap: 14px; margin-left: 16px; }
.topbar .bell { position: relative; font-size: 17px; opacity: .9; cursor: pointer; }
.topbar .bell .dot {
  position: absolute; top: -3px; right: -5px;
  min-width: 15px; height: 15px; padding: 0 3px;
  background: var(--red); border-radius: 8px;
  font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}
.topbar .who { text-align: right; line-height: 1.25; }
.topbar .who .nm { font-size: 13px; font-weight: 700; }
.topbar .who .tm { font-size: 10.5px; opacity: .7; }
.topbar .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 800;
}

/* ---------------- 페이지 헤더 (브레드크럼 + 서브탭 + 상태) ---------------- */
.page-head {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
}
.page-head .crumb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 0 9px;
}
.page-head .crumb { font-size: 13.5px; font-weight: 700; }
.page-head .crumb a { color: var(--text); }
.page-head .crumb a:hover { color: var(--accent-strong); }
.page-head .crumb .sep { color: var(--text-sub); margin: 0 6px; font-weight: 400; }
.page-head .crumb .here { color: var(--text-sub); font-weight: 600; }

.page-head .status { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-sub); white-space: nowrap; }
.badge-edit {
  background: #e7f6ec; color: var(--green);
  border: 1px solid #bfe6cd; border-radius: 5px;
  padding: 2px 8px; font-size: 11.5px; font-weight: 700;
}
.badge-readonly { background: #fdf3e0; color: #b07818; border: 1px solid #f0dcb0; border-radius: 5px; padding: 2px 8px; font-size: 11.5px; font-weight: 700; }
.live { display: inline-flex; align-items: center; gap: 5px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(30,158,88,.15); }

.page-title-row { display: flex; align-items: baseline; gap: 12px; padding: 4px 0 14px; }
.page-title { font-size: 22px; font-weight: 800; }
.page-title-row .desc { font-size: 12.5px; color: var(--text-sub); }

.subtabs { display: flex; gap: 2px; overflow-x: auto; }
.subtabs .tab {
  padding: 9px 14px 10px; font-size: 13.5px; font-weight: 600;
  color: var(--text-sub); border-bottom: 2.5px solid transparent;
  white-space: nowrap; background: none; border-top: 0; border-left: 0; border-right: 0;
}
.subtabs .tab:hover { color: var(--text); }
.subtabs .tab.active { color: var(--accent-strong); border-bottom-color: var(--accent-strong); font-weight: 700; }

/* ---------------- 본문 레이아웃 ---------------- */
.content { padding: 20px 22px 46px; max-width: 1920px; margin: 0 auto; }
.grid-cols { display: grid; gap: 16px; }

/* ---------------- KPI 카드 ---------------- */
.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 15px 17px 13px;
  min-width: 0;
}
.kpi .k-title { font-size: 12.5px; color: var(--text-sub); font-weight: 600; margin-bottom: 7px; }
.kpi .k-value { font-size: 27px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }
.kpi .k-value small { font-size: 14px; font-weight: 700; color: var(--text-sub); margin-left: 2px; }
.kpi .k-sub { font-size: 11.5px; color: var(--text-sub); margin-top: 7px; }
.kpi.blue .k-value { color: var(--accent-strong); }
.kpi.green .k-value { color: var(--green); }
.kpi.red .k-value { color: var(--red); }
.kpi.navy .k-value { color: var(--navy); }
.kpi .k-sub .up { color: var(--green); font-weight: 700; }
.kpi .k-sub .down { color: var(--red); font-weight: 700; }

/* ---------------- 카드 컨테이너 ---------------- */
.card-box {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-box + .card-box { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px 12px; border-bottom: 1px solid var(--line);
}
.card-head h3 { font-size: 15px; font-weight: 800; }
.card-head .hint { font-size: 12px; color: var(--text-sub); margin-left: auto; }

/* ---------------- 요약 집계표 (Overview 3분할) ---------------- */
.sum-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sum-table th {
  padding: 9px 10px; font-size: 12.5px; color: var(--text-sub); font-weight: 700;
  border-bottom: 1.5px solid var(--line-strong); text-align: right; white-space: nowrap;
}
.sum-table th:first-child { text-align: left; }
.sum-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.sum-table td:first-child { text-align: left; font-weight: 600; }
.sum-table tr.total td { font-weight: 800; background: #f7f9fc; border-bottom: 1.5px solid var(--line-strong); }
.sum-table tbody tr:not(.total):hover { background: var(--hover); }
.sum-table td .lbl-team { font-size: 11px; color: var(--text-sub); margin-right: 5px; }
.sum-table .num { color: var(--accent-strong); font-weight: 700; }
.sum-table .zero { color: #b9c3ce; }

/* ---------------- 데이터 그리드 ---------------- */
.grid-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.tbtn {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--text);
  border-radius: 7px; padding: 5px 11px; font-size: 12.5px; font-weight: 600;
}
.tbtn:hover { background: var(--hover); border-color: var(--accent); }
.tbtn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.tbtn:disabled { opacity: .45; cursor: default; }
.tbtn:disabled:hover { background: #fff; border-color: var(--line-strong); }
.grid-search {
  flex: 0 1 300px; min-width: 170px;
  border: 1px solid var(--line-strong); border-radius: 7px;
  padding: 6px 11px; font-size: 13px; font-family: inherit;
}
.grid-search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,164,235,.12); }
.grid-toolbar .spacer { flex: 1; }
.grid-toolbar .rowcount { font-size: 12px; color: var(--text-sub); white-space: nowrap; }

.grid-wrap { overflow: auto; max-height: calc(100vh - 260px); }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.grid thead th {
  position: sticky; top: 0; z-index: 5;
  background: #f7f9fc; color: var(--text);
  font-size: 12.5px; font-weight: 700;
  border-bottom: 1.5px solid var(--line-strong);
  border-right: 1px solid var(--line);
  padding: 9px 10px; text-align: left; white-space: nowrap;
  user-select: none;
}
table.grid thead th .th-inner { display: flex; align-items: center; gap: 5px; }
table.grid thead th .flt {
  border: 0; background: none; color: #9fb0c1; font-size: 10px; padding: 1px 2px; border-radius: 3px;
}
table.grid thead th .flt:hover { color: var(--accent-strong); background: #e8f2fb; }
table.grid thead th .flt.on { color: var(--accent-strong); }
table.grid thead th.sorted { color: var(--accent-strong); }
table.grid td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid #eef2f6;
  padding: 7px 10px; white-space: nowrap; background: #fff;
}
table.grid tbody tr:hover td { background: var(--hover); }
table.grid td.num, table.grid th.num .th-inner { justify-content: flex-end; }
table.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.center { text-align: center; }
table.grid td.col-yellow { background: var(--yellow-col); }
table.grid td.col-green { background: var(--green-col); }
table.grid tbody tr:hover td.col-yellow { background: #fdf0c0; }
table.grid tbody tr:hover td.col-green { background: #ddf1e5; }
table.grid td.editable { cursor: text; }
table.grid td.editable:hover { outline: 1.5px dashed var(--accent-strong); outline-offset: -2px; background: #f0f8fe; }
table.grid thead th .th-lbl { user-select: none; }
table.grid td .code { color: var(--text); font-weight: 700; }
table.grid td .pos { color: var(--green); font-weight: 700; }
table.grid td .neg { color: var(--red); font-weight: 700; }
table.grid td.rownum { color: #a6b2bf; font-size: 11.5px; text-align: right; background: #fbfcfe; }
table.grid .chk { accent-color: var(--accent-strong); }

/* 상태 칩 */
.chip {
  display: inline-block; padding: 2.5px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 700; line-height: 1.4;
}
.chip.blue   { background: #e5f4fd; color: #0b7fd4; }
.chip.green  { background: #e7f6ec; color: #17854a; }
.chip.amber  { background: #fdf3e0; color: #b07818; }
.chip.red    { background: #fdeaea; color: #c33; }
.chip.gray   { background: #eef1f5; color: #66788c; }
.chip.navy   { background: #e8edf5; color: #0e3a66; }
.chip.violet { background: #efeafb; color: #6d4fc4; }

/* 필터 팝업 */
.flt-pop {
  position: absolute; z-index: 50;
  background: #fff; border: 1px solid var(--line-strong); border-radius: 9px;
  box-shadow: 0 8px 24px rgba(16,42,74,.16);
  min-width: 190px; max-width: 270px; max-height: 320px;
  display: flex; flex-direction: column;
}
.flt-pop .fp-head { padding: 8px 11px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; font-size: 12px; }
.flt-pop .fp-head button { border: 0; background: none; color: var(--accent-strong); font-weight: 700; font-size: 12px; }
.flt-pop .fp-list { overflow: auto; padding: 6px 4px; }
.flt-pop label {
  display: flex; align-items: center; gap: 7px;
  padding: 4.5px 9px; font-size: 12.5px; border-radius: 6px; cursor: pointer;
}
.flt-pop label:hover { background: var(--hover); }

/* ---------------- 카테고리/스테이지 카드 그리드 ---------------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 13px; margin-bottom: 18px; }
.cat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px 12px; cursor: pointer;
  transition: border-color .12s, transform .12s;
}
.cat-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.cat-card.selected { border-color: var(--accent-strong); box-shadow: 0 0 0 2px rgba(0,164,235,.18); }
.cat-card .c-name { font-size: 14px; font-weight: 800; margin-bottom: 6px; }
.cat-card .c-count { font-size: 15px; font-weight: 800; color: var(--accent-strong); }
.cat-card .c-count small { font-size: 11.5px; color: var(--text-sub); font-weight: 600; margin-left: 4px; }
.cat-card .c-sub { font-size: 11.5px; color: var(--text-sub); margin-top: 3px; }

/* ---------------- 좌측 사이드 + 본문 (게시판형) ---------------- */
.split { display: grid; grid-template-columns: 210px 1fr; gap: 16px; align-items: start; }
.side-menu { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 9px 7px; }
.side-menu .sm-title { font-size: 11.5px; color: var(--text-sub); padding: 6px 10px; }
.side-menu a {
  display: block; padding: 8px 11px; border-radius: 7px;
  font-size: 13.5px; font-weight: 600; color: var(--text);
}
.side-menu a:hover { background: var(--hover); }
.side-menu a.active { background: #e5f4fd; color: var(--accent-strong); font-weight: 700; }

/* ---------------- 상세 슬라이드 패널 ---------------- */
.detail-mask { position: fixed; inset: 0; background: rgba(10,30,55,.35); z-index: 190; }
.detail-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 480px; max-width: 92vw;
  background: #fff; z-index: 200; box-shadow: -12px 0 34px rgba(10,30,55,.25);
  display: flex; flex-direction: column;
}
.detail-panel .dp-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.detail-panel .dp-head h3 { font-size: 17px; font-weight: 800; }
.detail-panel .dp-head .x { margin-left: auto; border: 0; background: none; font-size: 20px; color: var(--text-sub); }
.detail-panel .dp-body { padding: 16px 20px; overflow: auto; }
.dp-body .dl { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13.5px; }
.dp-body .dl dt { color: var(--text-sub); font-weight: 600; }
.dp-body .dl dd { font-weight: 600; }
.dp-body h4 { font-size: 13.5px; font-weight: 800; margin: 20px 0 8px; color: var(--navy); }

/* ---------------- 플로팅 버튼 ---------------- */
.fab {
  position: fixed; right: 26px; bottom: 26px; z-index: 150;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-strong); color: #fff; border: 0;
  font-size: 21px; box-shadow: 0 6px 18px rgba(11,127,212,.4);
  display: flex; align-items: center; justify-content: center;
}
.fab:hover { background: var(--accent); }

/* ---------------- 진행 미니바 ---------------- */
.mini-track { display: inline-block; width: 84px; height: 7px; background: #e8edf3; border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 7px; }
.mini-fill { height: 100%; border-radius: 4px; background: var(--accent-strong); }
.mini-fill.warn { background: var(--amber); }
.mini-fill.bad { background: var(--red); }

/* ---------------- 반응형 ---------------- */
@media (max-width: 1500px) { .kpi-row { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1100px) {
  .grid-cols.three { grid-template-columns: 1fr !important; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 14px 12px 40px; }
  .page-head { padding: 0 12px; }
  .topbar .who { display: none; }
}
