/* Membership Admin — dark ops-console theme.
   Dense, monochrome, decoration-free. Color is reserved for state and data. */

:root {
  --bg: #0e1014;
  --panel: #14171d;
  --panel-2: #191d24;
  --line: #262b35;
  --line-soft: #1d222b;
  --ink: #dde1e8;
  --ink-2: #aab1bd;
  --muted: #767e8d;
  --muted-2: #4d5563;
  --accent: #5a8cf5; /* 다크 서피스 검증 통과값(OKLCH L 0.48–0.67 밴드) */
  --accent-strong: #3563e9;
  --green: #3fb950;
  --amber: #d29922;
  --red: #f85149;
  --radius: 3px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Malgun Gothic", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
/* display 를 지정한 요소(.badge 등)에도 hidden 속성이 항상 이기게 한다. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
::selection { background: rgba(108, 155, 255, 0.25); }

/* ---- App shell ---- */
.layout { display: flex; min-height: 100%; }

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: #101318;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar__brand {
  padding: 18px 18px 16px;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--line-soft);
  text-transform: uppercase;
}
.sidebar__brand span { color: var(--muted); font-weight: 500; }
.sidebar__nav { padding: 10px 10px; display: flex; flex-direction: column; gap: 1px; flex: 1; }
.sidebar__link {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius);
  color: var(--ink-2);
  font-weight: 500;
  border-left: 2px solid transparent;
}
.sidebar__link:hover { background: var(--line-soft); color: var(--ink); text-decoration: none; }
.sidebar__link.is-active {
  background: rgba(108, 155, 255, 0.08);
  color: var(--accent);
  border-left-color: var(--accent);
}
.sidebar__user {
  border-top: 1px solid var(--line-soft);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
}
.sidebar__who { display: flex; align-items: center; gap: 9px; min-width: 0; color: var(--ink-2); font-weight: 500; }
.sidebar__signout {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 12px; font-family: inherit; padding: 2px;
}
.sidebar__signout:hover { color: var(--ink); }
.sidebar__id { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.role-pill {
  align-self: flex-start; font-family: var(--mono); font-size: 9px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); padding: 0 5px; border-radius: 2px;
}
.role-pill--super { color: var(--accent); border-color: rgba(108, 155, 255, 0.35); }

.content { flex: 1; min-width: 0; padding: 26px 32px 60px; max-width: 1220px; }
.content--auth {
  display: flex; align-items: center; justify-content: center;
  max-width: none; padding: 24px;
}

/* ---- Page header ---- */
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 18px; font-weight: 650; color: var(--ink); }
.page-head p { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.muted { color: var(--muted); }

/* ---- Cards ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.card > h2 {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 12px; display: flex; align-items: center; gap: 10px;
}
.card > h2 .muted { font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ---- Stat strip (stat tiles: label · value · optional sparkline) ---- */
.stats {
  display: flex;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 18px;
}
.stat { flex: 1; min-width: 0; padding: 13px 16px 11px; border-left: 1px solid var(--line-soft); }
.stat:first-child { border-left: 0; }
.stat__label {
  font-size: 10.5px; color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.stat__row { display: flex; align-items: flex-end; gap: 14px; margin-top: 6px; min-height: 30px; }
/* 큰 단독 숫자는 본문 sans + 비례 숫자(모노/tabular 는 표 컬럼 전용). */
.stat__num { font-size: 24px; font-weight: 650; line-height: 1.15; letter-spacing: -0.02em; color: var(--ink); }
.stat__num.is-warn { color: var(--amber); }
.stat__spark { flex: 1; min-width: 0; height: 30px; display: block; overflow: visible; }

/* ---- Tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-soft); }
thead th {
  font-size: 10.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  border-bottom: 1px solid var(--line);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #171b22; }
td.num, td.mono, .mono-cell { font-family: var(--mono); font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
td code, code.chip {
  font-family: var(--mono); font-size: 12px;
  background: var(--line-soft); padding: 2px 6px; border-radius: 2px; color: var(--ink);
}

/* ---- Status (dot + label) ---- */
.status { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; }
.status::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.status--active { color: var(--green); }
.status--expired { color: var(--amber); }
.status--disabled { color: var(--red); }
.status--used { color: var(--muted); }
.status--unused { color: var(--green); }

/* ---- Forms ---- */
.form-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
input, select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; background: #0f1218; color: var(--ink);
  transition: border-color .12s;
}
input::placeholder { color: var(--muted-2); }
input:focus, select:focus {
  outline: none; border-color: var(--accent);
}
input[type="number"] { width: 120px; }
.row-form { display: inline-flex; gap: 5px; align-items: center; margin: 0 6px 5px 0; }
.row-form input[type="number"] { width: 66px; padding: 4px 8px; }
.row-form > span { font-size: 12px; color: var(--muted); font-weight: 500; min-width: 78px; }
.actions { white-space: nowrap; }

/* 상세 페이지 관리 액션: 한 줄에 하나씩, 라벨 정렬. */
.action-grid { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.action-grid .row-form { margin: 0; }

/* ---- Buttons ---- */
.btn {
  border: 1px solid var(--line); background: transparent; color: var(--ink-2);
  padding: 6px 12px; border-radius: var(--radius); cursor: pointer;
  font-size: 12.5px; font-family: inherit; font-weight: 500;
  transition: background .1s, border-color .1s, color .1s;
}
.btn:hover { background: var(--panel-2); border-color: #323947; color: var(--ink); }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.primary:hover { background: #2b53c7; border-color: #2b53c7; color: #fff; }
.btn.danger { color: var(--red); border-color: rgba(248, 81, 73, 0.35); }
.btn.danger:hover { background: rgba(248, 81, 73, 0.08); border-color: rgba(248, 81, 73, 0.55); color: var(--red); }
.btn.small { padding: 3px 9px; font-size: 11.5px; }
.btn.block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---- Alerts ---- */
.alert { padding: 9px 12px; border-radius: var(--radius); margin-bottom: 14px; font-size: 12.5px; border: 1px solid transparent; }
.alert.error { background: rgba(248, 81, 73, 0.08); color: #ff7b72; border-color: rgba(248, 81, 73, 0.3); }
.alert.success { background: rgba(63, 185, 80, 0.08); color: #56d364; border-color: rgba(63, 185, 80, 0.3); }

/* ---- Connections monitor ---- */
.conn-toolbar { margin-left: auto; display: inline-flex; align-items: center; }
.conn-search { padding: 5px 9px; font-size: 12px; min-width: 240px; }
.actions-col { width: 1%; white-space: nowrap; }

/* 배지: 박스 없는 모노 마이크로 텍스트 — 색만 상태를 나른다. */
.badge {
  display: inline-block; font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted);
}
.badge--warn { color: var(--amber); }
.badge--multi { color: var(--accent); }

/* SSE stream status (Live / Reconnecting / Disconnected) — 텍스트 + 사각 점 */
.conn-status {
  display: inline-flex; align-items: center; gap: 6px; vertical-align: 3px;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-left: 6px;
}
.conn-status::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.conn-status--live { color: var(--green); }
.conn-status--reconnecting { color: var(--amber); }
.conn-status--offline { color: var(--red); }

/* 카드 헤더 카운터: 모노 텍스트 */
.count-chip {
  font-family: var(--mono); font-size: 11px; font-weight: 500;
  color: var(--muted); text-transform: none; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

/* Sortable table headers */
th.th-sort { cursor: pointer; user-select: none; white-space: nowrap; }
th.th-sort:hover { color: var(--ink-2); }
th.th-sort::after { content: "↕"; margin-left: 5px; opacity: 0; font-size: 10px; }
th.th-sort:hover::after { opacity: 0.5; }
th.th-sort[aria-sort="ascending"]::after { content: "↑"; opacity: 1; }
th.th-sort[aria-sort="descending"]::after { content: "↓"; opacity: 1; }

/* Row enter/exit (new connection highlight, disconnect fade) */
tr.row-enter > td { animation: row-flash 1s ease-out; }
@keyframes row-flash { from { background: rgba(63, 185, 80, 0.07); } to { background: transparent; } }
tr.row-exit { opacity: 0; transition: opacity 0.3s ease; }
tr.row-exit .btn { pointer-events: none; }

/* Two-tier empty state */
td.empty .empty-title { color: var(--ink-2); font-weight: 550; }
td.empty .empty-hint { margin-top: 3px; color: var(--muted-2); font-size: 12px; }

/* Detail modal */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); animation: modal-fade 0.1s ease-out; }
.modal__card {
  position: relative; width: 460px; max-width: calc(100vw - 32px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5); overflow: hidden;
  animation: modal-fade 0.1s ease-out;
}
@keyframes modal-fade { from { opacity: 0; } }
.modal__head { display: flex; align-items: center; justify-content: space-between; padding: 13px 18px; border-bottom: 1px solid var(--line-soft); }
.modal__head h3 { font-size: 13px; font-weight: 650; color: var(--ink); }
.modal__x { background: none; border: 0; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.modal__x:hover { color: var(--ink); }
.modal__body { padding: 6px 18px 12px; }
.modal__foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line-soft); background: var(--panel-2); }
table.kv th { width: 130px; color: var(--muted); font-weight: 500; vertical-align: top; }
table.kv td { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
table.kv td .muted { font-family: var(--font); }

/* ---- Generated codes ---- */
.generated { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.generated h3 { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.07em; }
.code-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }

/* ---- Pager ---- */
.pager { display: flex; gap: 14px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 13px; }
.pager .disabled { color: var(--muted-2); }
.pager .page-info { color: var(--muted); font-family: var(--mono); font-size: 12px; }

/* ---- Auth (login) ---- */
.auth-card {
  width: 340px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 4px; padding: 28px 26px;
}
.auth-card .auth-brand { font-size: 14px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.02em; }
.auth-card .auth-sub { color: var(--muted); margin: 4px 0 20px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card .field > span { color: var(--ink-2); }
.auth-card input { width: 100%; }

.empty { color: var(--muted); text-align: center; padding: 24px 0; }

/* 잔존 호환: 예전 라이브 점(사용처 없어도 안전하게 정적 점으로) */
.live-dot { width: 7px; height: 7px; background: var(--green); display: inline-block; }
