/* 관리자 페이지 (docs/ADMIN_PAGE_PLAN.md §3·§7) — 단독 스타일시트(common.css 미사용).
   matching_studio.css 의 다크·컴팩트 운영자 팔레트를 그대로 쓴다. 노트북 폭(≥1024) 기준, 모바일은 표 가로 스크롤로만 버틴다. */

:root {
  --bg: #14161a; --bg-2: #1b1e24; --bg-3: #22262e; --line: #2c313a; --line-2: #3a404b;
  --fg: #e6e8ec; --fg-2: #aab1bd; --fg-3: #737b88;
  --accent: #5b9cf6; --accent-2: #3b76d0; --ok: #46b36b; --warn: #f0a63a; --err: #e5534b; --violet: #a78bfa; --pink: #f472b6;
}
* { box-sizing: border-box; }
.hidden { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 13px/1.45 -apple-system, "Segoe UI", "Malgun Gothic", Roboto, sans-serif; }
a { color: var(--accent); }
button {
  font: inherit; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 6px; cursor: pointer;
  background: var(--bg-3); color: var(--fg); border: 1px solid var(--line-2);
}
button:hover { background: #2a2f38; border-color: #4a5160; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
button.primary:hover { background: var(--accent); }
button.danger { color: #ff8a80; border-color: #6b3a37; }
button.danger:hover { background: #3a2321; }
button.link { background: none; border: none; color: var(--accent); padding: 0; font-weight: 600; }
button.link:hover { text-decoration: underline; }
input, textarea, select {
  font: inherit; font-size: 12px; color: var(--fg); background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 6px; padding: 4px 6px;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12px; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 11.5px; }
.muted { color: var(--fg-3); font-size: 11px; }
.err { color: #ff8a80; }
.warn-text { color: #ffd28a; }
.up { color: #8be0a8; }
h3 { margin: 0 0 8px; font-size: 13px; color: var(--fg-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
h3 .muted { font-weight: 400; }

/* ── 헤더 ── */
.admin-header {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 14px; background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.admin-header-left, .admin-header-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-header h1 { margin: 0; font-size: 16px; white-space: nowrap; }
.admin-back { text-decoration: none; font-size: 18px; color: var(--fg-2); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--bg-3); color: var(--fg-2); }
.badge.ok { background: #1f3a2a; color: #8be0a8; }
.badge.warn { background: #3d2e12; color: #ffd28a; }
.badge.bad { background: #4a1f1d; color: #ff8a80; }
.badge.grey { background: #2a2e36; color: #90a4ae; }
.badge.violet { background: #2a2350; color: #c4b5fd; }
.collector-line { font-size: 11px; color: var(--fg-3); }
.collector-line b { color: var(--fg-2); font-weight: 600; }
.collector-line.bad b.fail { color: #ff8a80; }

/* ── 게이트 ── */
.gate-panel { max-width: 520px; margin: 60px auto; padding: 24px 28px; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; text-align: center; }
.gate-panel h2 { margin: 0 0 8px; font-size: 18px; }
.gate-panel p { margin: 6px 0; color: var(--fg-2); }
.gate-links { font-size: 14px; }

/* ── 탭 ── */
.admin-main { padding: 10px 16px 60px; max-width: 1600px; margin: 0 auto; }
.tab-bar { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; position: sticky; top: 46px; background: var(--bg); z-index: 10; }
.tab-bar button {
  background: none; border: none; border-bottom: 2px solid transparent; margin-bottom: -2px; border-radius: 0;
  padding: 8px 12px; color: var(--fg-2); font-weight: 500; white-space: nowrap;
}
.tab-bar button:hover { background: var(--bg-3); }
.tab-bar button.active { border-bottom-color: var(--accent); color: #fff; font-weight: 700; }
.tab-pane { display: flex; flex-direction: column; gap: 12px; }

/* ── 공용 블록 ── */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; }
.toolbar label { display: inline-flex; align-items: center; gap: 4px; color: var(--fg-2); }
.toolbar .spacer { flex: 1; }
.card { border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); padding: 10px 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.notice { font-size: 12px; color: var(--fg-2); background: var(--bg-2); border: 1px dashed var(--line-2); border-radius: 6px; padding: 6px 10px; }
.notice.warn { border-color: #7a5a1e; color: #ffd28a; }
.empty-note { color: var(--fg-3); font-size: 12px; padding: 14px 0; text-align: center; }
details.collapsible { border: 1px solid var(--line); border-radius: 8px; background: var(--bg-2); }
details.collapsible > summary { cursor: pointer; padding: 8px 12px; font-weight: 700; list-style: none; display: flex; align-items: center; gap: 8px; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before { content: "▸"; color: var(--fg-3); }
details.collapsible[open] > summary::before { content: "▾"; }
details.collapsible > div { padding: 0 12px 12px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 표 */
.tbl-wrap { overflow-x: auto; max-width: 100%; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.tbl th, .tbl td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: middle; }
.tbl th { background: var(--bg-3); color: var(--fg-2); font-weight: 600; position: sticky; top: 0; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.wrap { white-space: normal; min-width: 200px; }
.tbl td.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.tbl tr.row-err td { background: #2e1a19; }
.tbl tr.row-warn td { background: #2c2415; }
.tbl tr.group-row td { background: #1f2a3d; color: #90caf9; font-weight: 700; }
.tbl tbody tr:hover td { background: #22262e; }
.tbl tr.row-err:hover td { background: #3a2321; }
.tbl tr.row-warn:hover td { background: #3a2f18; }
details.excerpt summary { cursor: pointer; color: #ff8a80; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.excerpt pre { margin-top: 4px; max-width: 520px; background: var(--bg-3); padding: 6px; border-radius: 4px; }

/* 상태 알약 */
.pill { display: inline-block; padding: 1px 8px; border-radius: 8px; font-size: 11px; font-weight: 700; background: var(--bg-3); color: var(--fg-2); }
.st-ok, .st-success, .st-enabled, .st-completed { background: #1f3a2a; color: #8be0a8; }
.st-warn, .st-neutral, .st-fallback { background: #3d2e12; color: #ffd28a; }
.st-error, .st-failure, .st-timeout, .st-failed { background: #4a1f1d; color: #ff8a80; }
.st-missing { background: transparent; color: #ff8a80; border: 1px dashed #6b3a37; }
.st-running, .st-in_progress, .st-queued { background: #16324f; color: #90caf9; }
.st-cancelled, .st-skipped, .st-disabled, .st-gone { background: #2a2e36; color: #90a4ae; }
.pill.ctl-env { background: #16324f; color: #90caf9; }
.pill.ctl-db { background: #2a2350; color: #c4b5fd; }
.pill.ctl-ghvar { background: #1f3a2a; color: #8be0a8; }
.pill.ctl-code, .pill.ctl-local { background: #2a2e36; color: #90a4ae; }
.pill.drift { background: #3d2e12; color: #ffd28a; }
.pill.default { background: #2a2e36; color: #90a4ae; }
.pill.promote { background: #2a2350; color: #c4b5fd; }
.tag { display: inline-block; padding: 0 6px; border-radius: 8px; font-size: 10px; font-weight: 700; background: var(--bg-3); color: var(--fg-2); vertical-align: middle; }

/* 타일 */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.tile { background: var(--bg-3); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.tile .t-label { font-size: 11px; color: var(--fg-3); }
.tile .t-value { font-size: 20px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .t-sub { font-size: 11px; color: var(--fg-2); }
.tile.clickable { cursor: pointer; }
.tile.clickable:hover { border-color: var(--accent); }
.tile.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

/* 히트맵 · 차트 · 막대 */
.heat { border-collapse: collapse; font-size: 11px; }
.heat th { position: sticky; left: 0; background: var(--bg-3); color: var(--fg-2); padding: 2px 6px; text-align: left; white-space: nowrap; font-weight: 600; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.heat thead th { position: static; text-align: center; font-weight: 400; color: var(--fg-3); }
.heat td { width: 34px; min-width: 34px; height: 22px; text-align: center; border: 1px solid var(--bg); color: #fff; font-variant-numeric: tabular-nums; }
.chart-box { position: relative; height: 260px; }
.chart-box.small { height: 200px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 90px; padding-top: 4px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar-col .bar { width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; min-height: 1px; }
.bar-col span { font-size: 9px; color: var(--fg-3); margin-top: 2px; }
.mix-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 3px 0; }
.mix-label { width: 90px; flex: 0 0 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mix-bar { flex: 1; height: 10px; background: var(--bg-3); border-radius: 5px; overflow: hidden; }
.mix-bar > div { height: 100%; background: var(--accent); }
.mix-bar.violet > div { background: var(--violet); }
.mix-bar.ok > div { background: var(--ok); }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 140px; align-items: center; gap: 8px; margin: 4px 0; font-size: 12px; }
.funnel-bar { height: 16px; background: var(--bg-3); border-radius: 4px; overflow: hidden; }
.funnel-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.cloud { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; line-height: 1.2; }
.cloud span { color: var(--fg-2); cursor: default; }
.cloud span:hover { color: #fff; }
.kv-list { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.kv-list div { display: flex; justify-content: space-between; gap: 8px; }
.kv-list div span:first-child { color: var(--fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 접속 — 시간별 칩 */
.hour-row { border-top: 1px solid var(--line); padding: 6px 0; }
.hour-row:first-child { border-top: none; }
.hour-head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font: inherit; font-size: 11px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-3); color: var(--fg); cursor: pointer; }
.chip:hover { border-color: var(--accent); color: #fff; }
.chip.anon { color: var(--fg-3); cursor: default; border-style: dashed; }
.chip.anon:hover { border-color: var(--line-2); color: var(--fg-3); }

/* 유저 활동 */
.search-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-row input { min-width: 260px; }
.search-results { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.user-card { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.kv-grid { display: grid; grid-template-columns: max-content 1fr; gap: 2px 10px; font-size: 12px; align-content: start; }
.kv-grid b { color: var(--fg-3); font-weight: 600; }
.kv-grid span { word-break: break-all; }
.filters { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; align-items: center; }
.filters label { display: inline-flex; align-items: center; gap: 3px; color: var(--fg-2); cursor: pointer; }
.timeline { display: flex; flex-direction: column; gap: 4px; max-height: 70vh; overflow-y: auto; padding-right: 4px; }
.tl-item { display: grid; grid-template-columns: 96px 64px 1fr; gap: 8px; align-items: start; padding: 5px 6px; border-radius: 6px; background: var(--bg-3); }
.tl-item.no-thumb { grid-template-columns: 96px 1fr; }
.tl-ts { font-size: 11px; color: var(--fg-3); font-variant-numeric: tabular-nums; padding-top: 2px; }
.tl-thumb { width: 64px; height: 64px; border-radius: 4px; background: #0d0f12; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 26px; }
.tl-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tl-body { min-width: 0; }
.tl-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--fg-3); }
.tl-title { font-size: 12px; margin-top: 2px; word-break: break-word; }
.tl-detail { font-size: 11px; color: var(--fg-2); margin-top: 2px; word-break: break-word; }
.tl-detail b { color: var(--fg-3); font-weight: 600; }
.asset-thumb { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; display: block; background: #0d0f12; }

/* 엔진 */
.live-val { font-weight: 700; }
.swap-info { display: grid; grid-template-columns: max-content 1fr; gap: 3px 10px; font-size: 12px; margin-bottom: 10px; }
.swap-info b { color: var(--fg-3); }
.swap-form { display: flex; flex-direction: column; gap: 8px; }
.swap-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--fg-2); }
.swap-form input, .swap-form select { width: 100%; }
.swap-actions { display: flex; gap: 8px; justify-content: flex-end; }
.result-box { background: var(--bg-3); border-radius: 6px; padding: 8px; font-size: 12px; }
.result-box.ok { border: 1px solid #2e7d4a; }
.result-box.err { border: 1px solid #6b3a37; color: #ff8a80; }

/* ⓪ 운영 — 모듈 카드 (docs/ADMIN_OPS_TAB_PLAN.md §2) */
.ops-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(560px, 1fr)); gap: 12px; }
.ops-card.wide { grid-column: 1 / -1; }
.ops-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.ops-head h3 { margin: 0; }
.ops-head .btn-card-refresh { margin-left: auto; padding: 2px 8px; }
.sw-row { display: flex; gap: 4px; flex-wrap: wrap; }
.sw-pill { font-size: 11px; font-weight: 500; padding: 1px 8px; border-radius: 10px; background: var(--bg-3); border: 1px solid var(--line-2); color: var(--fg-2); }
.sw-pill b { font-weight: 700; color: var(--fg); }
/* 숏폼↔성경처럼 두 카드가 한 값을 공유하는 스위치 — 읽기 전용 카드에 붙는 배지 */
.sw-pill .sw-shared { margin-left: 5px; background: transparent; border: 1px solid var(--line-2); color: var(--fg-2); font-weight: 600; }
.sw-pill.sw-on { border-color: #2e7d4a; } .sw-pill.sw-on b { color: #8be0a8; }
.sw-pill.sw-off { border-color: #6b3a37; } .sw-pill.sw-off b { color: #ff8a80; }
.sw-pill.sw-err { border-style: dashed; border-color: var(--warn); }
.sw-pill:disabled { opacity: .7; cursor: default; }
.ops-cols { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.ops-card.wide .ops-cols { grid-template-columns: 1fr 2fr 1fr; }
.ops-card.wide .ops-col:empty { display: none; }
.ops-col h4 { margin: 0 0 6px; font-size: 12px; color: var(--fg-3); text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.op-row { background: var(--bg-3); border-radius: 6px; padding: 6px 8px; margin-bottom: 6px; font-size: 12px; }
.op-row.row-dim { opacity: .6; }
.op-row.next { border: 1px dashed var(--line-2); background: transparent; }
.op-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.op-head button, .op-sub button { padding: 1px 7px; font-size: 11px; }
.op-sub { color: var(--fg-2); font-size: 11.5px; margin-top: 3px; word-break: break-word; }
.op-sub b { color: var(--fg); }
.pill.coupled { background: #3d2e12; color: #ffd28a; border: 1px dashed #7a5a1e; }
.pill.held { background: #4a1f1d; color: #ff8a80; }
.couple-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px; margin-top: 6px; }
.couple { display: flex; gap: 8px; align-items: center; background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 12px; }
.couple-body { min-width: 0; }
.couple-body > div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 러너(EC2) 자원 카드 — 모듈 그리드 위 전폭 한 줄 (docs/ADMIN_OPS_TAB_PLAN.md §9) */
.runner-card { margin-bottom: 12px; }
.runner-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.rmetric { background: var(--bg-3); border-radius: 6px; padding: 8px 10px; border: 1px solid transparent; }
.rmetric.rwarn { border-color: var(--warn); }
.rmetric h4 { margin: 0 0 4px; font-size: 11px; color: var(--fg-3); text-transform: uppercase; letter-spacing: .04em; }
.rbig { font-size: 20px; font-weight: 700; line-height: 1.2; }
.rbig .rof { font-size: 12px; font-weight: 400; color: var(--fg-2); }
.rsub { color: var(--fg-2); font-size: 11.5px; margin-top: 3px; }
.rsub b { color: var(--fg); }
.rbar { display: block; height: 5px; border-radius: 3px; background: var(--bg-2); margin: 6px 0 2px; overflow: hidden; }
.rbar i { display: block; height: 100%; background: #4a7dbd; }
.rbar.rbar-warn i { background: #c0622f; }
@media (max-width: 1100px) { .ops-grid { grid-template-columns: 1fr; } .ops-cols, .ops-card.wide .ops-cols { grid-template-columns: 1fr; } .runner-grid { grid-template-columns: 1fr; } }

/* 모달 · 토스트 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; width: min(720px, 100%); max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 14px; color: var(--fg); }
.modal-close { background: none; border: none; font-size: 22px; color: var(--fg-2); padding: 0 4px; }
.modal-body { padding: 12px 14px; overflow-y: auto; }
.modal-body pre { background: var(--bg-3); padding: 8px; border-radius: 6px; max-height: 50vh; overflow: auto; }
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 200;
  background: #263246; color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 12px; border: 1px solid var(--accent-2);
  transition: opacity .2s, transform .2s; max-width: 80vw;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #3a2321; border-color: #6b3a37; }
.toast.ok { background: #1f3a2a; border-color: #2e7d4a; }

@media (max-width: 900px) {
  .admin-main { padding: 8px 8px 60px; }
  .tab-bar { top: 0; position: static; }
  .tl-item { grid-template-columns: 80px 48px 1fr; }
  .tl-item.no-thumb { grid-template-columns: 80px 1fr; }
  .tl-thumb { width: 48px; height: 48px; }
  .funnel-row { grid-template-columns: 90px 1fr 110px; }
  .modal { padding: 8px; }
}
