@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@latest/dist/web/variable/pretendardvariable.css');
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@400;500;700;800&display=swap');

:root {
  --font-sans: 'Pretendard Variable', Pretendard, 'Noto Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, sans-serif;
  --bg: #F5F5F8;
  --surface: #FFFFFF;
  --surface-alt: #EEEFF4;
  --border: #DDDFE7;
  --text: #1A1D29;
  --text-muted: #666C7D;
  --accent: #5B4FE0;
  --accent-fg: #FFFFFF;
  --accent-soft: #ECE9FC;
  --good-bg: #E4F4EC; --good-fg: #1E7A50;
  --warn-bg: #FBEEDD; --warn-fg: #A8631A;
  --crit-bg: #FBE8E4; --crit-fg: #B33A22;
  --info-bg: #E6EEFB; --info-fg: #2857A8;
  --shadow: 0 1px 2px rgba(20,20,30,0.06), 0 8px 24px rgba(20,20,30,0.05);
}

html[data-theme="dark"] {
  --bg: #0E121C;
  --surface: #161B28;
  --surface-alt: #1D2333;
  --border: #2A3142;
  --text: #E7E9F0;
  --text-muted: #8D93A6;
  --accent: #8577FF;
  --accent-fg: #12141F;
  --accent-soft: #241F3E;
  --good-bg: #163427; --good-fg: #5FCB98;
  --warn-bg: #3A2C16; --warn-fg: #E3A75C;
  --crit-bg: #3A1F19; --crit-fg: #E88F78;
  --info-bg: #1B2A42; --info-fg: #7CA6E8;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.35);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace;
}

a { color: inherit; text-decoration: none; }

/* ---- App shell ---- */
.app-shell {
  display: grid;
  grid-template-columns: 248px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}

.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar .brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
}

.topbar .meta {
  display: flex;
  gap: 18px;
  font-family: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.topbar .meta .ok { color: var(--good-fg); }
.topbar .meta .alert { color: var(--warn-fg); font-weight: 600; }

.topbar .spacer { flex: 1; }

.topbar .role-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
}

.theme-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 3px;
  gap: 2px;
  background: var(--surface-alt);
}

.theme-toggle button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 100px;
  cursor: pointer;
  font-family: inherit;
}

.theme-toggle button.active {
  background: var(--accent);
  color: var(--accent-fg);
}

/* ---- Sidebar ---- */
.sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  overflow-y: auto;
}

.nav-group {
  margin-bottom: 18px;
}

.nav-group-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 10px;
  margin-bottom: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text);
  margin-bottom: 2px;
}

.nav-link:hover { background: var(--surface-alt); }

.nav-link.active {
  background: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}

.nav-link.sub {
  padding-left: 26px;
  font-size: 13px;
  color: var(--text-muted);
}

.nav-link.sub.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

/* ---- Main ---- */
.main {
  grid-area: main;
  padding: 28px 32px 60px;
  overflow-x: auto;
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-head .crumb {
  font-family: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace;
  font-size: 11.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.page-head h1 {
  font-size: 21px;
  font-weight: 700;
  margin: 0;
}

.page-actions { display: flex; gap: 10px; }

.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

/* ---- Cards & grid ---- */
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: 1.3fr 1fr; }
@media (max-width: 1000px) {
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}

.card h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}

.stat-sub {
  font-size: 12.5px;
  color: var(--good-fg);
  font-family: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace;
}

/* ---- Alert list ---- */
.alert-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.alert-row:last-child { border-bottom: none; }

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace;
  flex-shrink: 0;
}
.pill.warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill.crit { background: var(--crit-bg); color: var(--crit-fg); }
.pill.info { background: var(--info-bg); color: var(--info-fg); }
.pill.good { background: var(--good-bg); color: var(--good-fg); }

/* ---- Form ---- */
.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.field .hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}
.field input[type=text],
.field input[type=date],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
}
.field textarea { min-height: 72px; resize: vertical; }

.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

.upload-box {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
  font-size: 13px;
  color: var(--text-muted);
  background: var(--surface-alt);
}

.color-swatches { display: flex; gap: 8px; align-items: center; }
.swatch {
  width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid var(--surface);
  outline: 1px solid var(--border);
  cursor: pointer;
}
.swatch.selected { outline: 2px solid var(--accent); }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .label { font-size: 13.5px; }
.toggle-row .desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.switch {
  position: relative;
  width: 40px; height: 22px;
  border-radius: 100px;
  background: var(--border);
  flex-shrink: 0;
  cursor: pointer;
}
.switch.on { background: var(--accent); }
.switch .knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--surface);
  transition: left .15s ease;
}
.switch.on .knob { left: 20px; }

.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
}
.tag {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 600;
  padding: 4px 8px 4px 10px;
  border-radius: 100px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tag button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
}

/* ---- Preview panel ---- */
.preview-frame {
  background: #12141F;
  border-radius: 10px;
  padding: 16px;
  color: #E7E9F0;
}
.preview-frame .ev-title { font-size: 13px; font-weight: 700; }
.preview-frame .ev-meta { font-size: 11px; color: #8D93A6; margin-top: 2px; }
.preview-stage {
  margin-top: 12px;
  aspect-ratio: 16/9;
  border-radius: 8px;
  background: linear-gradient(145deg, #1D2140, #14162A);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8577FF;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.preview-feed {
  margin-top: 12px;
  font-size: 12px;
  color: #8D93A6;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.preview-feed b { color: #E7E9F0; }

/* ---- Table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th {
  font-family: ui-monospace, "SF Mono", Consolas, "Roboto Mono", monospace;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); background: var(--surface-alt);
}
