/* ── Design tokens ─────────────────────────────────── */
:root {
  --bg: #0f1117;
  --bg-raised: #181b24;
  --bg-card: #1e2230;
  --bg-input: #252938;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 134, 255, 0.5);
  --text: #e4e6ed;
  --text-muted: #8b90a0;
  --text-dim: #5c6070;
  --accent: #6386ff;
  --accent-glow: rgba(99, 134, 255, 0.15);
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.12);
  --orange: #fb923c;
  --orange-bg: rgba(251, 146, 60, 0.12);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.12);
  --yellow: #fbbf24;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --sidebar-w: 220px;
  --topbar-h: 56px;
  --font-sans: "Inter", "Pretendard", "Noto Sans KR", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Fira Code", monospace;
  --font-serif: "Source Serif 4", "Noto Serif KR", Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

#root {
  width: 100%;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ──────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  text-decoration: none;
  color: var(--text);
  margin-bottom: 28px;
}

.sidebar-brand:hover { text-decoration: none; }

.brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
}

.brand-text {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.brand-text small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-item:hover { background: var(--bg-card); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-glow); color: var(--accent); }

.nav-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.nav-item-badge {
  margin-left: auto;
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 400;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.version-tag {
  font-size: 11px;
  color: var(--text-dim);
}

/* ── Main area ────────────────────────────────────── */
.app-shell {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: rgba(15, 17, 23, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-serif);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-user {
  font-size: 13px;
  color: var(--text-muted);
}

.main-content {
  flex: 1;
  padding: 24px 28px;
}

.page {
  max-width: 1400px;
  display: grid;
  gap: 20px;
}

/* ── Stats row ────────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-card.accent { border-color: rgba(52, 211, 153, 0.2); }
.stat-card.warn { border-color: rgba(251, 146, 60, 0.2); }

.stat-number {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card.accent .stat-number { color: var(--green); }
.stat-card.warn .stat-number { color: var(--orange); }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Cards ────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.card-header h2 {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ── Grid ─────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* ── Badge ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--accent-glow);
  color: var(--accent);
}

.badge.muted {
  background: rgba(139, 144, 160, 0.12);
  color: var(--text-muted);
}

.badge.green {
  background: var(--green-bg);
  color: var(--green);
}

.badge.orange {
  background: var(--orange-bg);
  color: var(--orange);
}

.badge.red {
  background: var(--red-bg);
  color: var(--red);
}

.badge.pulse {
  background: var(--orange-bg);
  color: var(--orange);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ── Status pills ─────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-pill.active { background: var(--green-bg); color: var(--green); }
.status-pill.archived { background: rgba(139, 144, 160, 0.12); color: var(--text-muted); }
.status-pill.deleted { background: var(--red-bg); color: var(--red); }
.status-pill.admin { background: var(--accent-glow); color: var(--accent); }
.status-pill.creator { background: var(--green-bg); color: var(--green); }
.status-pill.owner { background: var(--orange-bg); color: var(--orange); }
.status-pill.member { background: rgba(139, 144, 160, 0.12); color: var(--text-muted); }

/* ── Forms ────────────────────────────────────────── */
.form-stack {
  display: grid;
  gap: 16px;
}

.field { display: grid; gap: 6px; }

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input::placeholder, textarea::placeholder {
  color: var(--text-dim);
}

textarea { resize: vertical; font-size: 13px; }

/* ── Buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: #5070e0; text-decoration: none; }

.btn-secondary { background: rgba(99, 134, 255, 0.12); color: var(--accent); }
.btn-secondary:hover:not(:disabled) { background: rgba(99, 134, 255, 0.2); text-decoration: none; }

.btn-warning { background: var(--orange-bg); color: var(--orange); }
.btn-warning:hover:not(:disabled) { background: rgba(251, 146, 60, 0.2); text-decoration: none; }

.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(248, 113, 113, 0.2); text-decoration: none; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 6px 12px;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-input); color: var(--text); text-decoration: none; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; }

/* ── Table ────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13px;
}

.data-table .clickable-row { cursor: pointer; transition: background 0.1s; }
.data-table .clickable-row:hover { background: rgba(99, 134, 255, 0.06); }

.mono { font-family: var(--font-mono); font-size: 12px; }
.center { text-align: center; }
.truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-dim);
}

.help-text {
  font-size: 12px;
  color: var(--text-dim);
}

/* ── Modal ────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 40px;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-large {
  max-width: 90vw;
}

.modal-fullscreen {
  max-width: 95vw;
  max-height: 95vh;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-serif);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.modal-close-btn:hover { background: var(--bg-input); color: var(--text); }

.modal-body {
  padding: 0 24px 24px;
}

/* ── Tabs ─────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Filter bar ───────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.filter-btn {
  padding: 5px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover { border-color: var(--accent); color: var(--text); }
.filter-btn.active { background: var(--accent-glow); border-color: var(--accent); color: var(--accent); }

/* ── Info bar ─────────────────────────────────────── */
.info-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.info-item {
  flex: 1;
  min-width: 140px;
  padding: 14px 18px;
  border-right: 1px solid var(--border);
}

.info-item:last-child { border-right: none; }

.info-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.info-value {
  font-size: 13px;
  color: var(--text);
}

/* ── Term tooltip ─────────────────────────────────── */
.term-tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.term-tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  cursor: help;
  flex-shrink: 0;
  line-height: 1;
}

.term-tooltip-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.term-tooltip-popup {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
  white-space: normal;
  width: max-content;
  max-width: 280px;
  line-height: 1.5;
  box-shadow: var(--shadow);
  z-index: 200;
  pointer-events: none;
  text-transform: none;
  letter-spacing: normal;
}

/* ── Progress bars ────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-input);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-fill.completed { background: var(--green); }
.progress-fill.error { background: var(--red); }

/* ── Variation cards ──────────────────────────────── */
.variation-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

.variation-col {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.variation-col.recommended {
  border-color: var(--accent);
}

.variation-col.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 2px var(--green-bg);
}

.variation-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar { display: none; }
  .main-area { margin-left: 0; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .info-bar { flex-direction: column; }
  .info-item { border-right: none; border-bottom: 1px solid var(--border); }
  .variation-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .stats-row { grid-template-columns: 1fr; }
  .main-content { padding: 16px; }
  .tab-bar { gap: 0; }
  .tab { padding: 8px 10px; font-size: 12px; }
  .variation-grid { grid-template-columns: 1fr; }
}
