/* ==========================================================================
   CON TII — 경영 대시보드 (STEP 22)

   base.css 의 변수만 씁니다. 새 색 체계를 만들지 않았습니다.
   admin.css 와 분리한 이유는 하나입니다 — admin.css 가 이미 1800줄이라
   대시보드까지 넣으면 무엇이 어느 화면 것인지 찾을 수 없습니다.
   ========================================================================== */

/* --------------------------------------------------------------------------
   왜 대시보드만 폭이 다른가

   매장 비교표는 열이 여덟 개입니다. 오른쪽 설명 패널(300px)까지
   띄우면 1920 화면에서도 표가 눌려 가로 스크롤이 생깁니다. 대표가
   보는 첫 화면에서 표를 옆으로 밀어 읽게 만들 수는 없습니다.

   그래서 대시보드에서는 붙박이 설명 패널을 접고 본문이 폭을 다
   쓰게 합니다. 설명 자체는 지우지 않았습니다 — 헤더의 ? 버튼으로
   서랍에서 열립니다.
   -------------------------------------------------------------------------- */

body[data-view="dashboard"] .admin-body {
  /* 기존 1640px 은 설명 패널 300px 을 포함한 값이라 본문은 ~1310px
     이었습니다. 패널을 접고 1720px 로 넓히면 본문이 ~1680px 이 되어
     8열 표가 눌리지 않습니다. */
  --admin-max: 1720px;
  grid-template-columns: minmax(0, 1fr);
}

body[data-view="dashboard"] .help-panel:not([data-drawer="1"]) {
  display: none;
}

/* --------------------------------------------------------------------------
   기간 · 매장 필터
   -------------------------------------------------------------------------- */

.dash-filter {
  margin-bottom: 16px;
}

.dash-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.dash-filter-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dash-range {
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.dash-store {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
}

.dash-custom {
  margin-top: 10px;
  justify-content: flex-start;
}

.dash-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

.dash-date input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-family: var(--font-num);
  font-size: 12.5px;
}

/* 기간 버튼 묶음 */
.seg {
  display: inline-flex;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface);
}

.seg-btn {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  border-right: 1px solid var(--line);
  transition: background 0.13s ease, color 0.13s ease;
}

.seg-btn:last-child {
  border-right: 0;
}

.seg-btn:hover:not([disabled]) {
  background: var(--bg-sunken);
}

.seg-btn[aria-pressed="true"] {
  background: var(--gold-soft);
  color: var(--gold);
}

.seg-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.seg-sm .seg-btn {
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
}

/* --------------------------------------------------------------------------
   KPI 4장

   금액이 가장 크고 제목이 가장 작습니다. 대표가 첫눈에 보는 것은
   '매출' 이라는 글자가 아니라 숫자입니다.
   -------------------------------------------------------------------------- */

.dash-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.dash-kpi {
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 150px;
  display: flex;
  flex-direction: column;
}

.dash-kpi[data-go] {
  cursor: pointer;
  transition: border-color 0.13s ease, background 0.13s ease;
}

.dash-kpi[data-go]:hover {
  background: var(--bg-sunken);
  border-top-color: var(--gold);
}

.dash-kpi[data-go]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

/* 색은 근거가 있을 때만 씁니다. 전부 칠하면 아무 것도 눈에 안 띕니다. */
.dash-kpi[data-tone="warn"] {
  border-top-color: var(--warn);
}

.dash-kpi[data-tone="missing"] {
  border-top-color: var(--line-strong);
  background: var(--bg-sunken);
}

.dash-kpi-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  min-height: 20px;
}

.dash-kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.dash-kpi-value {
  font-family: var(--font-num);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.dash-kpi-value em {
  font-family: var(--font-sans);
  font-style: normal;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  margin-left: 3px;
}

/* 없는 값. 숫자와 확실히 달라 보여야 0원으로 오해하지 않습니다. */
.dash-kpi-missing {
  font-family: var(--font-sans);
  font-size: 19px;
  font-weight: 600;
  color: var(--muted);
}

.dash-kpi-foot {
  margin-top: auto;
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dash-kpi-note {
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

.dash-kpi-note.warnish,
.warnish {
  color: var(--warn);
}

.dash-kpi-foot .btn {
  align-self: flex-start;
  margin-top: 6px;
  height: 30px;
}

.kpi-delta {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.kpi-delta[data-dir="up"] {
  color: var(--down);
}

.kpi-delta[data-dir="down"] {
  color: var(--up);
}

.kpi-delta[data-dir="flat"],
.kpi-delta.muted {
  color: var(--muted);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   2단 배치
   -------------------------------------------------------------------------- */

.dash-split {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.dash-split-wide {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
}

.dash-split > .panel {
  margin: 0 0 14px;
}

.panel-note {
  padding: 0 18px 16px;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--muted);
}

.panel-quiet {
  background: var(--bg-sunken);
}

.dash-store-table tfoot td {
  padding: 11px 12px;
  border-top: 1px solid var(--line-strong);
  font-weight: 700;
  font-size: 13px;
  color: var(--ink);
}

.dash-store-table tfoot td.num {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   도넛
   -------------------------------------------------------------------------- */

.mix-body {
  padding: 8px 18px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* 패널이 넓으면 도넛 옆에 범례를 둡니다. 세로로만 쌓으면 양옆이
   비고 패널만 길어집니다. */
@media (min-width: 1440px) {
  .mix-body {
    flex-direction: row;
    align-items: center;
    gap: 20px;
  }

  .donut-legend {
    flex: 1;
    min-width: 0;
  }
}

.donut-wrap {
  position: relative;
  display: inline-flex;
}

.donut-arc {
  cursor: pointer;
  transition: opacity 0.13s ease;
}

.donut-arc:hover {
  opacity: 0.82;
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
}

.donut-center-label {
  font-size: 11px;
  color: var(--muted);
}

.donut-center-value {
  font-family: var(--font-num);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.donut-legend {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.donut-legend-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  cursor: pointer;
}

.donut-legend-item:hover {
  background: var(--bg-sunken);
}

.donut-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.donut-legend-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

.donut-legend-pct {
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.donut-legend-val {
  font-size: 11.5px;
  color: var(--muted);
  min-width: 76px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   막대 추이

   기록이 없는 날은 막대를 세우지 않습니다. 0 으로 그리면 그날
   한 병도 못 판 것처럼 보입니다.
   -------------------------------------------------------------------------- */

.bar-chart {
  position: relative;
  margin: 6px 18px 0;
  border-bottom: 1px solid var(--line);
}

.bar-slot {
  position: absolute;
  bottom: 0;
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.bar-slot .bar {
  display: block;
  width: 100%;
  border-radius: 2px 2px 0 0;
  background: var(--gold);
  opacity: 0.85;
}

.bar-slot:hover .bar {
  opacity: 1;
}

/* 기록이 없는 날. 바닥에 점만 찍어 '자리는 있다' 를 보입니다. */
.bar-missing::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 2px;
  height: 3px;
  background: var(--line-strong);
  transform: translateX(-50%);
}

.bar-axis {
  display: flex;
  justify-content: space-between;
  padding: 6px 18px 14px;
  font-size: 11px;
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   일마감
   -------------------------------------------------------------------------- */

.close-body {
  padding: 12px 18px 6px;
}

.close-date {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.close-sections {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.close-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--ink-2);
}

.close-chip em {
  font-style: normal;
  font-size: 11px;
  font-weight: 600;
}

.close-chip[data-ok="1"] {
  border-color: var(--down);
  color: var(--down);
}

.close-chip[data-ok="0"] {
  border-color: var(--warn);
  color: var(--warn);
}

.close-blocking {
  margin: 10px 18px 0;
  padding: 10px 12px;
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink-2);
}

.close-blocking li + li {
  margin-top: 3px;
}

.close-actions {
  display: flex;
  gap: 8px;
  padding: 14px 18px 18px;
}

/* --------------------------------------------------------------------------
   데이터 신선도
   -------------------------------------------------------------------------- */

.fresh-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  padding: 6px 18px 8px;
}

.fresh-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.fresh-item[data-state="stale"] {
  border-left-color: var(--warn);
}

.fresh-item[data-state="never"] {
  border-left-color: var(--up);
}

.fresh-item[data-state="fresh"] {
  border-left-color: var(--down);
}

/* 운영 상태 줄. 손볼 것이 있을 때만 색을 씁니다. */
.fresh-item[data-tone="warn"] {
  border-left-color: var(--warn);
}

.fresh-item[data-go] {
  cursor: pointer;
}

.fresh-item[data-go]:hover {
  background: var(--bg-sunken);
}

.fresh-item[data-go]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
}

/* 한 패널 안의 두 번째 이후 제목. 위 묶음과 구분만 합니다. */
.panel-head-sub {
  border-top: 1px solid var(--line);
  margin-top: 4px;
}

.fresh-label {
  font-size: 11.5px;
  color: var(--muted);
}

.fresh-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

/* 0건인 업무는 약하게. 남은 것만 눈에 띄어야 합니다. */
.todo-card[data-tone="done"] {
  opacity: 0.5;
}

.todo-card[data-tone="done"] .todo-count {
  color: var(--muted);
}

/* --------------------------------------------------------------------------
   좁은 화면

   핵심은 1920 관리자 PC 이지만, 노트북에서도 표가 깨지지 않아야
   합니다.
   -------------------------------------------------------------------------- */

@media (max-width: 1439px) {
  .dash-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dash-split,
  .dash-split-wide {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 719px) {
  .dash-kpis {
    grid-template-columns: minmax(0, 1fr);
  }

  .dash-kpi-value {
    font-size: 28px;
  }

  .dash-filter-row {
    align-items: flex-start;
  }

  .seg {
    flex-wrap: wrap;
  }
}
