:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-2: #172033;
  --line: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --gold: #f5c451;
  --gold-2: #d9a82e;
  --emerald: #34d399;
  --amber: #fbbf24;
  --sky: #38bdf8;
  --rose: #fb7185;
  --shadow: 0 18px 50px rgb(0 0 0 / 28%);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, Pretendard, "Noto Sans KR", system-ui, sans-serif; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
a { color: var(--sky); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 1.55rem; }
h2 { margin-bottom: 6px; font-size: 1.3rem; }
h3 { margin-bottom: 12px; font-size: 1rem; }
p { color: var(--muted); }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 268px 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; display: flex; flex-direction: column; background: #0b1220; border-right: 1px solid #263349; z-index: 30; }
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 24px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; background: linear-gradient(145deg, var(--gold), #9b6b0d); color: #172033; font-weight: 900; box-shadow: 0 8px 24px rgb(245 196 81 / 20%); }
.brand strong, .brand small { display: block; }
.brand small { margin-top: 3px; color: var(--gold); font-size: .64rem; letter-spacing: .13em; }
.brand .icon-btn { margin-left: auto; }
.main-nav { display: grid; gap: 5px; }
.main-nav button { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 0; border-radius: 9px; background: transparent; color: #cbd5e1; text-align: left; cursor: pointer; }
.main-nav button span { width: 20px; color: var(--muted); text-align: center; }
.main-nav button:hover { background: #172033; color: #fff; }
.main-nav button.active { background: rgb(245 196 81 / 12%); color: var(--gold); font-weight: 700; }
.sidebar-bottom { margin-top: auto; }
details { border: 1px solid var(--line); border-radius: 9px; padding: 10px; }
summary { color: #cbd5e1; cursor: pointer; font-size: .88rem; }
details label { margin-top: 10px; }
.auth-summary { display: flex; align-items: center; gap: 8px; padding: 14px 5px 0; color: var(--muted); font-size: .82rem; }
.auth-summary i { width: 8px; height: 8px; border-radius: 50%; background: var(--rose); }
.auth-summary.ok i { background: var(--emerald); box-shadow: 0 0 10px var(--emerald); }

.main { min-width: 0; }
.topbar { min-height: 88px; padding: 18px 28px; display: flex; align-items: center; gap: 15px; border-bottom: 1px solid #263349; background: rgb(15 23 42 / 88%); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 20; }
.topbar p { margin: 0; font-size: .86rem; }
.top-actions { display: flex; gap: 8px; margin-left: auto; }
.content { padding: 26px 28px 50px; max-width: 1600px; margin: 0 auto; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { min-width: 0; padding: 20px; background: linear-gradient(145deg, var(--panel), #19263a); border: 1px solid #2d3b51; border-radius: 13px; box-shadow: 0 8px 25px rgb(0 0 0 / 12%); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 15px; }
.card-head h2, .card-head h3, .card-head p { margin: 0; }
.kpi { position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; width: 80px; height: 80px; right: -25px; bottom: -35px; border-radius: 50%; background: rgb(245 196 81 / 8%); }
.kpi-label { color: var(--muted); font-size: .82rem; }
.kpi-value { margin: 10px 0 3px; font-size: 1.8rem; font-weight: 800; letter-spacing: -.03em; }
.kpi-note { color: var(--muted); font-size: .75rem; }

.btn, .icon-btn { border: 1px solid transparent; border-radius: 8px; cursor: pointer; transition: .16s ease; }
.btn { padding: 9px 13px; font-size: .86rem; font-weight: 700; white-space: nowrap; }
.btn:hover, .icon-btn:hover { filter: brightness(1.12); transform: translateY(-1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--gold); color: #172033; }
.btn.secondary { background: #26364c; border-color: #3a4c64; color: #e2e8f0; }
.btn.danger { background: rgb(251 113 133 / 14%); border-color: rgb(251 113 133 / 40%); color: #fda4af; }
.btn.success { background: rgb(52 211 153 / 15%); border-color: rgb(52 211 153 / 36%); color: #6ee7b7; }
.btn.small { padding: 6px 9px; font-size: .76rem; }
.btn.full { width: 100%; }
.icon-btn { width: 36px; height: 36px; padding: 0; background: transparent; font-size: 1.3rem; }

label { display: grid; gap: 6px; color: #cbd5e1; font-size: .8rem; font-weight: 650; }
input, textarea, select { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; outline: 0; background: #0f192b; color: var(--text); resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--gold-2); box-shadow: 0 0 0 3px rgb(245 196 81 / 10%); }
input[type="checkbox"] { width: auto; accent-color: var(--gold); }
.inline { display: flex; align-items: end; gap: 10px; }
.inline > label { flex: 1; }
.stack { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.form-grid .span-2 { grid-column: span 2; }
.check-label { display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.code-editor { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .78rem; line-height: 1.5; tab-size: 2; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 9px; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th { padding: 10px 12px; background: #172236; color: var(--muted); font-size: .72rem; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 11px 12px; border-top: 1px solid #2b394e; vertical-align: middle; }
tr:hover td { background: rgb(255 255 255 / 1.5%); }
.empty { padding: 35px 16px; color: var(--muted); text-align: center; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; font-size: .7rem; font-weight: 800; white-space: nowrap; }
.badge.emerald, .badge.resolved, .badge.active { color: #6ee7b7; background: rgb(52 211 153 / 13%); }
.badge.amber, .badge.in_progress { color: #fcd34d; background: rgb(251 191 36 / 13%); }
.badge.sky, .badge.open { color: #7dd3fc; background: rgb(56 189 248 / 13%); }
.badge.rose, .badge.banned, .badge.maintenance { color: #fda4af; background: rgb(251 113 133 / 13%); }
.badge.gray, .badge.closed, .badge.inactive { color: #cbd5e1; background: rgb(148 163 184 / 13%); }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tabs button { padding: 10px 13px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--gold); border-bottom-color: var(--gold); }

.modal { width: min(520px, calc(100vw - 24px)); padding: 20px; border: 1px solid #475569; border-radius: 14px; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.modal.wide { width: min(850px, calc(100vw - 24px)); }
.modal::backdrop { background: rgb(2 6 23 / 78%); backdrop-filter: blur(3px); }
.modal-head { display: flex; align-items: start; justify-content: space-between; margin-bottom: 15px; }
.modal-head p { margin-bottom: 0; font-size: .82rem; }
.diagnose-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 15px 0; }
.diagnose-row { display: flex; justify-content: space-between; padding: 10px; border-radius: 8px; background: #111b2d; font-size: .8rem; }
.notice { padding: 11px 13px; border-radius: 8px; font-size: .8rem; }
.notice.warning { color: #fde68a; background: rgb(251 191 36 / 10%); border: 1px solid rgb(251 191 36 / 25%); }

.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 16px; }
.detail-panel { position: sticky; top: 110px; max-height: calc(100vh - 135px); overflow-y: auto; }
.summary-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.summary-item { padding: 11px; border-radius: 8px; background: #111b2d; }
.summary-item small { display: block; color: var(--muted); margin-bottom: 5px; }
.json-view { max-height: 480px; overflow: auto; padding: 12px; background: #0a1220; border-radius: 8px; color: #cbd5e1; font-size: .74rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.pill-list { display: flex; flex-wrap: wrap; gap: 7px; }
.item-pill { padding: 7px 9px; background: #111b2d; border: 1px solid var(--line); border-radius: 7px; font-size: .76rem; }
.toast-root { position: fixed; z-index: 100; right: 20px; bottom: 20px; display: grid; gap: 8px; }
.toast { min-width: 260px; max-width: 420px; padding: 12px 14px; border-radius: 9px; background: #26364c; border-left: 4px solid var(--sky); box-shadow: var(--shadow); font-size: .83rem; }
.toast.error { border-color: var(--rose); }
.toast.success { border-color: var(--emerald); }
.hidden { display: none !important; }
.mobile-only { display: none; }
.backdrop { position: fixed; inset: 0; z-index: 25; background: rgb(2 6 23 / 70%); }

@media (max-width: 1050px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
  .detail-panel { position: static; max-height: none; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-102%); width: min(290px, 88vw); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-grid; place-items: center; }
  .topbar { min-height: 74px; padding: 13px 14px; }
  .topbar h1 { font-size: 1.15rem; }
  .topbar p { display: none; }
  .top-actions .btn { padding: 8px; font-size: .72rem; }
  .content { padding: 16px 13px 40px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4, .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
  .card { padding: 15px; }
  .inline { align-items: stretch; flex-direction: column; }
  .diagnose-grid { grid-template-columns: 1fr; }
  .summary-list { grid-template-columns: 1fr; }
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tr { padding: 9px; border-top: 1px solid var(--line); }
  table.responsive tr:first-child { border-top: 0; }
  table.responsive td { display: flex; justify-content: space-between; gap: 12px; padding: 6px; border: 0; text-align: right; overflow-wrap: anywhere; }
  table.responsive td::before { content: attr(data-label); flex: 0 0 38%; color: var(--muted); text-align: left; font-size: .72rem; }
}
