/* 운영자 페이지 — 현황·사용자·틀 성과 탭과 편의 기능 (dash.js, 2026-11-06). admin.css 다음에 읽힙니다. */

/* 어두운 화면: 변수만 바꾸면 기존 화면(admin.css)도 따라옵니다. D 키나 위쪽 🌙 버튼, 처음에는 기기 설정을 따릅니다. */
:root[data-theme="dark"] {
  --canvas: #121316;
  --surface: #1b1d21;
  --soft: #25282d;
  --line: #34373d;
  --ink: #ececec;
  --ink-soft: #a3a7ae;
  --rose: #e0708e;
  --rose-deep: #f08aa5;
  --rose-soft: #3a2630;
  --danger: #ff7b6e;
  color-scheme: dark;
}
:root[data-theme="dark"] .badge.retired { background: #2b2d31; color: #9a9ea5; }
:root[data-theme="dark"] .notice.ok { background: #1e3222; color: #9fd8a8; }
:root[data-theme="dark"] .notice.warn { background: #3a2d12; color: #f0c168; }
:root[data-theme="dark"] .notice.danger { background: #3d1f1c; }
:root[data-theme="dark"] .quality.pass, :root[data-theme="dark"] .badge.pass { background: #1e3222; color: #9fd8a8; }
:root[data-theme="dark"] .quality.warn, :root[data-theme="dark"] .badge.warn { background: #3a2d12; color: #f0c168; }
:root[data-theme="dark"] .quality.fail, :root[data-theme="dark"] .badge.fail { background: #3d1f1c; }
:root[data-theme="dark"] .checker { background: repeating-conic-gradient(#2a2d32 0% 25%, #1f2226 0% 50%) 50% / 24px 24px; }
:root[data-theme="dark"] .message:not(:empty) { background: #f2f2f2; color: #111; }
:root[data-theme="dark"] .message.error:not(:empty) { background: var(--danger); color: #111; }
:root[data-theme="dark"] .qr { background: #fff; }
.theme-toggle { min-height: 36px; padding: 4px 10px; font-size: 18px; }
/* 폰 너비: 위쪽 버튼이 세로로 쪼개지지 않게, 새 탭의 제목이 한 글자씩 꺾이지 않게 */
.top > button { flex: none; white-space: nowrap; }
#stats h1, #users h1, #user-view h1, #perf h1 { white-space: nowrap; }
#stats-zone { flex: 1 1 100%; order: 3; }
@media (min-width: 601px) { #stats-zone { flex: 0 1 auto; order: 0; } }

/* 처리 중 막대 (화면 맨 위) */
.busy { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 20; background: linear-gradient(90deg, transparent, var(--rose), transparent); background-size: 50% 100%; animation: busy-slide 1s linear infinite; }
@keyframes busy-slide { from { background-position: -50% 0; } to { background-position: 150% 0; } }

/* 그림 크게 보기 */
.lightbox { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px; background: rgba(0, 0, 0, 0.78); cursor: zoom-out; }
.lightbox img { max-width: min(92vw, 720px); max-height: 88vh; border-radius: 16px; background: repeating-conic-gradient(#ececea 0% 25%, #fafaf8 0% 50%) 50% / 24px 24px; }
.zoomable { cursor: zoom-in; }

/* 도움말 */
.help { position: fixed; left: 50%; bottom: 72px; transform: translateX(-50%); z-index: 25; max-width: 520px; width: calc(100% - 24px); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; font: 600 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: center; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--soft); }

/* 현황 */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-bottom: 8px; }
.tile { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.tile.totals { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; }
.tile-label { font-size: 13px; color: var(--ink-soft); font-weight: 600; margin-bottom: 6px; }
.tile-row { display: flex; gap: 10px; }
.tile-val { flex: 1; min-width: 0; }
.tile-val strong { display: block; font-size: 18px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-val span { display: block; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
.chart { display: flex; gap: 4px; align-items: flex-end; height: 160px; padding-top: 6px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; min-width: 0; }
.chart .col .bars { display: flex; gap: 2px; align-items: flex-end; flex: 1; }
.chart .col .bar { display: block; flex: 1; min-height: 2px; border-radius: 3px 3px 0 0; background: var(--ink-soft); }
.chart .col .bar.b { background: var(--rose); }
.chart .col .bar.c { background: #3a9d5d; }
.chart .col small { display: block; margin-top: 4px; font-size: 10px; color: var(--ink-soft); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) { .chart .col:nth-child(odd) small { visibility: hidden; } }
.legend { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: middle; margin-right: 4px; background: var(--ink-soft); }
.legend.b { background: var(--rose); }
.legend.c { background: #3a9d5d; }
ol.plain { margin: 0; padding-left: 22px; }
ol.plain li, ul.plain li { margin: 4px 0; }

/* 사용자 */
#user-search input[type="search"], .toolbar input[type="search"] { flex: 1; min-width: 160px; margin: 0; padding: 9px 11px; font: inherit; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
#user-search { margin-bottom: 6px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.facts dt { color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.facts dd { margin: 0; min-width: 0; word-break: break-all; }
.facts dd.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.facts dd .tiny { min-height: 28px; padding: 2px 10px; margin-left: 6px; font-size: 12px; }
#user-credit-form input[type="number"] { display: block; width: 100%; margin-top: 4px; padding: 9px 11px; font: inherit; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.amount.plus { color: #1f7a3d; }
.amount.minus { color: var(--danger); }
:root[data-theme="dark"] .amount.plus { color: #9fd8a8; }
.badge.suspended { background: #fdecea; color: var(--danger); }
.badge.plus { background: #e8f0fe; color: #1a4fb3; }
:root[data-theme="dark"] .badge.plus { background: #1e2a44; color: #9bb8ff; }
:root[data-theme="dark"] .badge.suspended { background: #3d1f1c; }

/* 틀 성과 */
.toolbar { gap: 8px; }
.toolbar select { min-height: 40px; padding: 6px 10px; font: inherit; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); }
.actions.tight { margin-top: 8px; margin-bottom: 8px; }
.perf-row { cursor: default; }
.perf-row input[type="checkbox"] { width: 20px; height: 20px; margin: 0; accent-color: var(--rose); flex: none; }
.perf-row .thumb { width: 48px; height: 48px; flex: none; border-radius: 10px; object-fit: contain; background: var(--soft); }
.perf-row .thumb.empty { display: grid; place-items: center; font-size: 11px; color: var(--ink-soft); }
.perf-row .name { font-weight: 600; }
.perf-row .nums { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; color: var(--ink-soft); }
.perf-row .nums b { color: var(--ink); font-weight: 600; }
.perf-row .nums .bad { color: var(--danger); }
.perf-row button { flex: none; min-height: 36px; padding: 6px 12px; }
@media (max-width: 600px) {
  .perf-row { flex-wrap: wrap; }
  .perf-row .grow { flex-basis: calc(100% - 90px); }
  .perf-row button { flex: 1 1 100%; }
  .tile-val strong { font-size: 17px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dt { margin-top: 6px; }
}

/* 아이폰 누끼 비율 표 (2026-11-07) — 숫자 칸을 오른쪽 정렬하고 띄움 */
#stats-cutout table { border-collapse: collapse; margin: 8px 0; min-width: min(100%, 420px); }
#stats-cutout th, #stats-cutout td { padding: 4px 0; text-align: left; }
#stats-cutout th:not(:first-child), #stats-cutout td:not(:first-child) { text-align: right; padding-left: 20px; font-variant-numeric: tabular-nums; }
#stats-cutout tr + tr td { border-top: 1px solid var(--line, rgba(127, 127, 127, 0.18)); }

/* 손익 탭 (2026-11-07) */
.tile.fin-gain .tile-val strong { color: #2f7d4b; }
.tile.fin-loss .tile-val strong, .chart .col small.fin-loss { color: var(--danger); }
.fin-table { border-collapse: collapse; width: 100%; }
.fin-table th, .fin-table td { padding: 4px 0; text-align: left; vertical-align: top; }
.fin-table th:not(:first-child), .fin-table td:not(:first-child) { text-align: right; padding-left: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fin-table tr + tr td { border-top: 1px solid var(--line); }
.fin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.fin-field { display: flex; flex-direction: column; gap: 4px; }
.fin-fixed-row { display: grid; grid-template-columns: 1fr; gap: 4px; }
#fin-assume .row { margin-top: 12px; }
