/* 리셋 + 레이아웃 (사이드바 / 상단바 / 콘텐츠) */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.28px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
h1, h2, h3, h4, p { margin: 0; }
img { display: block; }
[hidden] { display: none !important; }
::selection { background: var(--orange-100); }

.app { display: flex; min-height: 100vh; }

/* ── 사이드바 ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: var(--s-8);
  height: var(--topbar-h);
  padding: 0 var(--s-24);
  border-bottom: 1px solid var(--border);
}
.brand-wordmark { height: 22px; width: auto; }
.brand-tag {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--primary); background: var(--primary-tint);
  padding: 2px 6px; border-radius: var(--radius-full);
}
.nav { padding: var(--s-12); flex: 1; overflow-y: auto; }
.nav-group { margin-bottom: var(--s-4); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background .15s ease, color .15s ease;
}
.nav-item:hover { background: var(--gray-50); color: var(--text); }
.nav-item.active { background: var(--primary-tint); color: var(--primary); font-weight: 700; }
.nav-icon { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.nav-icon svg { width: 18px; height: 18px; }
.nav-icon svg path, .nav-icon svg circle, .nav-icon svg rect { fill: currentColor; }
.nav-item.active .nav-icon { color: var(--primary); }
.nav-badge + .nav-chevron { margin-left: 6px; }
.nav-chevron { margin-left: auto; width: 14px; height: 14px; color: var(--gray-400); transition: transform .15s ease; }
.nav-chevron svg { width: 14px; height: 14px; }
.nav-chevron svg path { fill: currentColor; }
.nav-group.open .nav-chevron { transform: rotate(90deg); }
.nav-sub { display: none; padding: 2px 0 4px 0; }
.nav-group.open .nav-sub { display: block; }
.nav-sub-item {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px 7px 42px;
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.nav-sub-item:hover { background: var(--gray-50); color: var(--text); }
.nav-sub-item.active { color: var(--primary); font-weight: 700; background: var(--primary-tint); }
.nav-badge {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 6px;
  border-radius: var(--radius-full);
  background: var(--primary); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}
.sidebar-foot {
  display: flex; align-items: center; gap: 10px;
  padding: var(--s-12) var(--s-16);
  border-top: 1px solid var(--border);
}
.sidebar-mascot { width: 30px; height: 30px; opacity: .9; }
.sidebar-foot-text { min-width: 0; }
.sidebar-foot-text div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── 메인 ── */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s-32);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: var(--s-12); }
.topbar-title { font-size: 18px; font-weight: 700; letter-spacing: -0.18px; }
.topbar-right { display: flex; align-items: center; gap: var(--s-8); }
.env-badge {
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
  padding: 3px 8px; border-radius: var(--radius-full);
  background: var(--gray-100); color: var(--text-2);
}
.env-badge[data-env="production"] { background: var(--error-tint); color: var(--error); }
.env-badge[data-env="staging"] { background: var(--info-tint); color: #1F86AD; }
.env-badge[data-env="development"] { background: var(--success-tint); color: #6E8A00; }
.key-box {
  display: flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface);
}
.key-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--orange-50); }
.key-box input { border: 0; outline: 0; background: transparent; width: 220px; font-size: 13px; }
.key-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-300); }
.key-dot.ok { background: var(--success); }
.key-dot.bad { background: var(--error); }

.content {
  padding: var(--s-24) var(--s-32) 80px;
  max-width: calc(var(--content-max) + var(--s-32) * 2);
  width: 100%;
}
.panel { display: none; flex-direction: column; gap: var(--s-16); }
.panel.active { display: flex; }
.panel-lead { color: var(--text-muted); font-size: 13px; margin-top: -4px; }

@media (max-width: 960px) {
  .sidebar { display: none; }
  .content { padding: var(--s-16); }
}
