/* JPlay Console — docs/console-plan.md §7 시안에서 옮김.
   레이아웃: 왼쪽 고정 사이드바 + 본문(요약 → 상세). 760px 이하에서는 사이드바가 상단 가로 메뉴.
   색: 앱 테마의 남색을 강조색으로, 남색 쪽으로 기운 중립색. 상태색(정상/주의/오류)은 강조색과 별도.
   CSP(style-src 'self') 때문에 인라인 style 속성을 쓰지 않는다. 막대는 <progress class="meter">. */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eaeef4;
  --border: #d6dde7;
  --fg: #16202b;
  --muted: #5a6778;
  --accent: #35618e;
  --accent-fg: #ffffff;
  --accent-soft: #dce7f4;
  --ok: #1d7448;
  --ok-soft: #d9efe3;
  --warn: #8f5b00;
  --warn-soft: #f8e9c9;
  --bad: #b3261e;
  --bad-soft: #f8dcd8;
  --bar-4xx: #d39a2c;
  --font-ui: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Consolas, "D2Coding", "Courier New", monospace;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141a; --surface: #161d26; --surface-2: #1d2632; --border: #2b3645;
    --fg: #e2e8ef; --muted: #94a2b3; --accent: #9fcaff; --accent-fg: #0b2540; --accent-soft: #1d3350;
    --ok: #74d3a3; --ok-soft: #133024; --warn: #efbb5c; --warn-soft: #382a10; --bad: #ff8f85; --bad-soft: #3c1814;
    --bar-4xx: #e0a940;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 14px; line-height: 1.5; }
h1, h2, h3 { margin: 0; text-wrap: balance; font-weight: 600; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
p { margin: 0; }
code, .mono { font-family: var(--font-mono); font-size: 12.5px; }
.num, td.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
form { margin: 0; }

/* ── 셸 ── */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 16px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; flex-direction: column; gap: 6px; }
.brand b { font-size: 16px; letter-spacing: -0.01em; }
.env { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.env::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  text-decoration: none; border-radius: 6px; padding: 8px 10px; color: var(--muted);
  display: flex; justify-content: space-between; align-items: center;
}
.nav a:hover { background: var(--surface-2); color: var(--fg); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--fg); font-weight: 600; }
.sidebar footer { margin-top: auto; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.freshness { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.linkish { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; text-align: left; }

main { min-width: 0; padding: 24px 28px 40px; max-width: 1180px; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.pagehead p { margin-top: 4px; }

/* ── 부품 ── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.panel > header { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 16px 0; flex-wrap: wrap; }
.panel .body { padding: 12px 16px 16px; }
.btn { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; border-radius: 999px; padding: 1px 9px; white-space: nowrap; }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }
.pill.bad { color: var(--bad); background: var(--bad-soft); }
.pill.neutral { color: var(--muted); background: var(--surface-2); }

progress.meter { appearance: none; -webkit-appearance: none; width: 100%; height: 6px; border: 0; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
progress.meter::-webkit-progress-bar { background: var(--surface-2); border-radius: 3px; }
progress.meter::-webkit-progress-value { background: var(--accent); border-radius: 3px; }
progress.meter::-moz-progress-bar { background: var(--accent); border-radius: 3px; }

.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0.02em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; }

/* ── 개요 ── */
.status { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.status > div { padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.status > div + div { border-left: 1px solid var(--border); }
.status .label { font-size: 12px; color: var(--muted); letter-spacing: 0.02em; }
.status .value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi .delta { font-size: 12px; color: var(--muted); }
.cols { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }

/* ── 요청 지표 ── */
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--font-mono); }
.chart .bar-ok { fill: var(--accent); }
.chart .bar-4xx { fill: var(--bar-4xx); }
.chart .bar-5xx { fill: var(--bad); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend .lg-ok::before { background: var(--accent); }
.legend .lg-4xx::before { background: var(--bar-4xx); }
.legend .lg-5xx::before { background: var(--bad); }
.figures { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 12px; font-size: 13px; font-variant-numeric: tabular-nums; }
.small { font-size: 12px; }
p.small { margin-top: 6px; }

/* ── 단어장 ── */
.crumbs { font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.deckmeta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 13px; margin-top: 6px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.searchform { flex: 1 1 260px; display: flex; min-width: 0; }
.search { flex: 1; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 7px 10px; min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.segbtn { background: var(--surface); padding: 6px 12px; color: var(--muted); text-decoration: none; }
.segbtn + .segbtn { border-left: 1px solid var(--border); }
.segbtn[aria-pressed="true"] { background: var(--surface-2); color: var(--fg); font-weight: 600; }
.pending { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); border-radius: var(--radius); padding: 12px 16px; }
a.btn { text-decoration: none; color: inherit; display: inline-block; }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn.disabled { opacity: 0.45; cursor: default; }
table.words td.word { font-weight: 600; }
table.words td.actions { white-space: nowrap; text-align: right; }
table.words td.actions .btn + .btn { margin-left: 6px; }
tr.is-pending td { background: color-mix(in srgb, var(--warn-soft) 60%, transparent); }
tr.is-editing td { background: var(--accent-soft); }
del { color: var(--muted); }
ins { text-decoration: none; font-weight: 500; }
.edit { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.edit input { flex: 1 1 240px; min-width: 0; border: 1px solid var(--accent); border-radius: 6px; padding: 5px 8px; background: var(--surface); }
.error.inline { padding: 3px 8px; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.htmx-request { opacity: 0.6; transition: opacity 0.2s; }

/* ── 단어장 C3: 추가·숨김·가져오기 ── */
tr.is-hidden td:not(.actions) { color: var(--muted); }
tr.is-hidden td.word { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.btn.danger { color: var(--bad); }
details.panel > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; list-style-position: inside; }
details.panel[open] > summary { border-bottom: 1px solid var(--border); }
.addword .error { margin: 12px 16px 0; }
.addform { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 12px 16px 4px; }
.addform .field input { border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; background: var(--surface); }
.addform .field.narrow { width: 96px; }
.addform .field.grow { flex: 1 1 220px; }
.addword > p { padding: 0 16px 12px; }
.uploadform, .applyform { padding: 16px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.uploadform input[type=file] { font-size: 13px; }
label.check { display: flex; gap: 6px; align-items: center; }
ul.rules { margin: 0; padding: 12px 16px 16px 34px; display: flex; flex-direction: column; gap: 4px; }
details.changes .tablewrap { padding: 4px 16px 12px; }
details.changes > p { padding: 0 16px 12px; }
td.nowrap { white-space: nowrap; }
td.detail { font-size: 13px; }

/* ── 로그인 ── */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; max-width: none; }
.login .panel { width: min(380px, 100%); padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-size: 19px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 13px; font-weight: 500; }
.field input { border: 1px solid var(--border); border-radius: 6px; padding: 9px 10px; background: var(--surface); }
.login .btn.primary { padding: 9px; }
.error { color: var(--bad); background: var(--bad-soft); border-radius: 6px; padding: 8px 10px; font-size: 13px; }

/* ── 반응형 ── */
@media (max-width: 1000px) {
  .status { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .status > div:nth-child(4) { border-left: 0; }
  .status > div:nth-child(n+4) { border-top: 1px solid var(--border); }
  .cols { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border);
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px;
  }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; }
  .sidebar footer { margin-top: 0; margin-left: auto; flex-direction: row; gap: 12px; }
  main { padding: 18px 16px 32px; }
  .status { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status > div:nth-child(odd) { border-left: 0; }
  .status > div:nth-child(4) { border-left: 1px solid var(--border); }
  .status > div:nth-child(n+3) { border-top: 1px solid var(--border); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
