:root {
  --bg: #0d0d10;
  --surface: #17171c;
  --surface2: #1e1e25;
  --text: #ececf0;
  --muted: #9a9aa6;
  --accent: #e50914;
  --line: #2a2a32;
  --ok: #2f9e6a;
  --warn: #b8862b;
  --danger: #c23b3b;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; }
a { color: inherit; text-decoration: none; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 12px; }
h4 { font-size: 13px; margin: 0 0 6px; color: var(--muted); }

/* Layout: fixed sidebar + scrollable content (data-dense console, desktop only). */
.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { border-right: 1px solid var(--line); background: var(--surface); padding: 18px 14px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 800; font-size: 18px; color: var(--accent); margin-bottom: 18px; display: flex; align-items: baseline; gap: 6px; }
.brand span { color: var(--muted); font-weight: 600; font-size: 12px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { padding: 9px 12px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.sidebar nav a:hover { background: var(--surface2); color: var(--text); }
.sidebar nav a.active { background: var(--surface2); color: var(--text); font-weight: 600; }
.sidebar-foot { margin-top: auto; line-height: 1.5; }
.nav-group { padding: 12px 12px 4px; text-transform: uppercase; letter-spacing: .04em; font-size: 10px; }

.content { padding: 24px 28px; max-width: 1200px; overflow-x: auto; }

.stack { display: flex; flex-direction: column; gap: 18px; }
.stack.narrow { max-width: 640px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr.priority td { background: rgba(194, 59, 59, .08); }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.kpi { background: var(--surface2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; cursor: default; }
.kpi[role="link"] { cursor: pointer; }
.kpi[role="link"]:hover { border-color: var(--accent); }
.kpi-value { font-size: 26px; font-weight: 800; }
.kpi-label { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; font-size: 13px; }
.tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Badges */
.badge { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #2b2b33; color: #cfcfe0; white-space: nowrap; }
.badge.ok { background: rgba(47,158,106,.18); color: #7fe0ad; }
.badge.warn { background: rgba(184,134,43,.18); color: #f0c878; }
.badge.danger { background: rgba(194,59,59,.2); color: #ff9c9c; }

/* Buttons */
.btn { display: inline-block; padding: 9px 15px; border-radius: 9px; background: var(--accent); color: #fff; border: none; font-weight: 600; cursor: pointer; font-size: 14px; }
.btn.secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 12px; }

/* Forms */
.field { display: block; width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--line); background: #101015; color: var(--text); font-size: 14px; }
select.field { cursor: pointer; }
textarea.field { width: 100%; resize: vertical; font-family: inherit; line-height: 1.5; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small.danger, .btn.danger.small { padding: 6px 10px; font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.lbl { display: block; color: var(--muted); font-size: 12px; margin: 6px 0; }

/* Definition lists */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* States */
.state { padding: 24px 8px; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.ok { color: #7fe0ad; }
.error { color: #ff9c9c; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.back { color: var(--muted); font-size: 13px; }
.back:hover { color: var(--text); }

/* Dialog */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.dialog { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; max-width: 420px; width: 100%; }
.dialog.wide { max-width: 720px; }
.dialog .row { margin-top: 16px; }

/* Standalone preformatted (audit/DSR logs) */
.dialog pre { background: #101015; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font-size: 12px; max-height: 360px; margin: 0 0 4px; white-space: pre-wrap; word-break: break-word; }

/* Diff view */
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.diff pre { background: #101015; border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; font-size: 12px; max-height: 360px; margin: 0; }
