:root {
  --bg: #f4f6fb; --panel: #ffffff; --text: #1f2633; --muted: #6b7486; --line: #e3e7ef;
  --brand: #5b7cfa; --brand-2: #8fa6ff; --ok: #19a974; --warn: #e8a317; --bad: #e5484d;
  --nav: #1d2333; --nav-text: #c9d0e0; --nav-active: #2c3550; --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .05);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151d; --panel: #1b1f2a; --text: #e6e9f0; --muted: #949db0; --line: #2a3040; --nav: #0d1016; --nav-active: #232a3d; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; }
.hidden { display: none !important; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
h3 { margin: 0 0 12px; font-size: 16px; }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.err { color: var(--bad); min-height: 1.5em; margin: 8px 0 0; }
.hint { color: var(--muted); font-size: 13px; }

/* 로그인 */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, #dfe6ff, #f6e8ff); }
@media (prefers-color-scheme: dark) { .login { background: linear-gradient(135deg, #1a2140, #2a1a3a); } }
.login-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-card .brand { color: var(--text); margin-bottom: 20px; font-size: 18px; }
.qr { display: grid; place-items: center; padding: 12px; background: #fff; border-radius: 8px; margin: 8px 0; }
.secret { display: block; word-break: break-all; padding: 8px; background: var(--bg); border-radius: 6px; user-select: all; }

/* 레이아웃 */
.app { display: flex; min-height: 100vh; }
.nav { width: 220px; flex: none; background: var(--nav); color: var(--nav-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 16px; padding: 18px 18px 12px; color: #fff; display: flex; align-items: center; gap: 8px; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), #c08bff); color: #fff; }
nav#menu { flex: 1; padding: 4px 8px; }
nav#menu a { display: flex; align-items: center; gap: 10px; color: var(--nav-text); padding: 9px 12px; border-radius: 8px; margin: 1px 0; }
nav#menu a:hover { background: var(--nav-active); text-decoration: none; }
nav#menu a.active { background: var(--nav-active); color: #fff; font-weight: 600; }
nav#menu .ico { width: 18px; text-align: center; opacity: .9; }
nav#menu .count { margin-left: auto; background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; }
.me { padding: 12px 16px; border-top: 1px solid rgba(255, 255, 255, .08); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.top-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.top .menu-btn { display: none; }
.page { padding: 20px 24px 60px; max-width: 1400px; width: 100%; }

@media (max-width: 860px) {
  .nav { position: fixed; z-index: 20; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 24px rgba(0, 0, 0, .3); }
  .nav.open { transform: none; }
  .top .menu-btn { display: inline-flex; }
  .top { padding: 10px 16px; }
  .page { padding: 14px 16px 60px; }
}

/* 카드 / 그리드 */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 16px; }
.grid2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-bottom: 16px; }
.card { background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.stat .label { color: var(--muted); font-size: 12px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.stat .sub { color: var(--muted); font-size: 12px; }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--bad); }
.bar { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.bar > i { display: block; height: 100%; background: var(--brand); }
.bar.hot > i { background: var(--bad); }

/* 표 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: top; }
td.wrap { white-space: normal; min-width: 180px; max-width: 420px; word-break: break-word; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--panel); position: sticky; top: 0; }
tbody tr:hover { background: rgba(91, 124, 250, .05); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 24px; }

/* 폼 */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-2); border-color: transparent; }
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { display: inline; width: auto; margin: 0 6px 0 0; }
.form { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form .full { grid-column: 1 / -1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 12px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar label { margin: 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: inherit; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: var(--line); color: var(--text); }
.tag.ok { background: rgba(25, 169, 116, .15); color: var(--ok); }
.tag.warn { background: rgba(232, 163, 23, .18); color: #b77c00; }
.tag.bad { background: rgba(229, 72, 77, .15); color: var(--bad); }
.tag.info { background: rgba(91, 124, 250, .15); color: var(--brand); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: none; padding: 8px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--brand); border-color: var(--brand); font-weight: 600; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.reward-row { display: grid; grid-template-columns: 1fr 1.5fr 1fr auto; gap: 6px; margin-bottom: 6px; }
.reward-row select, .reward-row input { margin: 0; }

/* 차트 */
.chart svg { width: 100%; height: 180px; display: block; }
.chart .axis { stroke: var(--line); }
.chart text { fill: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }

/* 모달 / 토스트 */
.modal { position: fixed; inset: 0; background: rgba(10, 14, 25, .5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--panel); border-radius: 14px; padding: 20px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222a3d; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 60; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); }

.warnbox{background:#fff1e6;border:2px solid #e9893a;color:#7a3a10;font-weight:600;margin-bottom:12px}
@media (prefers-color-scheme:dark){.warnbox{background:#3a2414;color:#ffd2ad}}
