:root {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c222b;
    --surface-3: #222a35;
    --border: #30363d;
    --border-strong: #414b57;
    --text: #e6edf3;
    --muted: #8b949e;
    --green: #03c75a;
    --green-hover: #02b351;
    --green-soft: rgba(3, 199, 90, 0.12);
    --red: #f85149;
    --red-soft: rgba(248, 81, 73, 0.12);
    --amber: #d29922;
    --blue: #58a6ff;
    --shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
    --radius: 8px;
    font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
    margin: 0;
    min-width: 320px;
    min-height: 100vh;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

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

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.02em; }
.brand-mark {
    width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center;
    color: #07120b; background: var(--green); font-size: 13px; font-weight: 900;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-link { color: var(--muted); padding: 7px 10px; border-radius: 6px; }
.topbar-link:hover { color: var(--text); background: var(--surface-2); }

.app-shell { min-height: calc(100vh - 56px); display: grid; grid-template-columns: 224px minmax(0, 1fr); }
.sidebar {
    border-right: 1px solid var(--border);
    background: #10151c;
    padding: 18px 12px;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
}
.sidebar-label { padding: 5px 10px 8px; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.nav-list { display: grid; gap: 3px; }
.nav-item {
    width: 100%; border: 0; color: var(--muted); background: transparent; text-align: left;
    padding: 9px 10px; border-radius: 6px; display: flex; align-items: center; gap: 10px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { color: #dffbea; background: var(--green-soft); box-shadow: inset 2px 0 var(--green); }
.nav-icon { width: 20px; text-align: center; font-size: 12px; opacity: .9; }
.sidebar-footer { margin-top: 24px; padding: 12px 10px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }

.content { min-width: 0; padding: 28px clamp(18px, 3vw, 40px) 56px; }
.content-inner { max-width: 1280px; margin: 0 auto; }
.page-header { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.page-title { margin: 0; font-size: 24px; line-height: 1.25; letter-spacing: -0.025em; }
.page-description { margin: 7px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.card {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 0 rgba(255,255,255,.02);
}
.card-header { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; gap: 14px; align-items: center; }
.card-title { margin: 0; font-size: 15px; font-weight: 700; }
.card-subtitle { margin-top: 3px; color: var(--muted); font-size: 12px; }
.card-body { padding: 18px; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { padding: 16px; }
.metric-label { color: var(--muted); font-size: 12px; }
.metric-value { margin-top: 5px; font-size: 24px; line-height: 1.2; font-weight: 750; letter-spacing: -.03em; }
.metric-hint { margin-top: 5px; color: var(--muted); font-size: 11px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stack { display: grid; gap: 16px; min-width: 0; }
.section-view { display: none; }
.section-view.active { display: block; }

.btn {
    border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
    min-height: 36px; padding: 7px 13px; border-radius: 6px; font-weight: 650;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    transition: background .15s ease, border-color .15s ease, transform .08s ease;
}
.btn:hover { background: var(--surface-3); border-color: #596473; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .48; cursor: not-allowed; transform: none; }
.btn-primary { color: #05150b; background: var(--green); border-color: var(--green); }
.btn-primary:hover { background: var(--green-hover); border-color: var(--green-hover); }
.btn-naver { color: #fff; background: #03c75a; border-color: #03c75a; }
.btn-naver:hover { color: #fff; background: #02b351; border-color: #02b351; }
.btn-naver span { font-weight: 900; }
.btn-danger { color: #ffd7d5; background: var(--red-soft); border-color: rgba(248,81,73,.42); }
.btn-danger:hover { background: rgba(248,81,73,.2); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-small { min-height: 30px; padding: 4px 9px; font-size: 12px; }

.field { display: grid; gap: 6px; }
.field label { color: #c6d0da; font-size: 12px; font-weight: 650; }
.input, .select {
    width: 100%; height: 38px; padding: 8px 10px; color: var(--text);
    background: #0d1117; border: 1px solid var(--border-strong); border-radius: 6px; outline: none;
}
.input:focus, .select:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.input::placeholder { color: #66707c; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-actions { margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; }
.help { color: var(--muted); font-size: 12px; }

.auth-layout { min-height: calc(100vh - 56px); display: grid; place-items: center; padding: 32px 18px; }
.auth-panel { width: min(100%, 430px); box-shadow: var(--shadow); }
.auth-intro { margin-bottom: 22px; text-align: center; }
.auth-intro h1 { margin: 0 0 8px; font-size: 28px; }
.auth-intro p { color: var(--muted); margin: 0; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 7px; background: #0d1117; margin-bottom: 18px; }
.tab { border: 0; padding: 8px; border-radius: 5px; color: var(--muted); background: transparent; }
.tab.active { background: var(--surface-3); color: var(--text); }
.auth-form { display: grid; gap: 14px; }
.oauth-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; }
.oauth-divider::before, .oauth-divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.callback-panel { display: grid; justify-items: center; gap: 14px; text-align: center; padding: 34px 24px; }
.callback-panel h1 { margin: 0; font-size: 22px; }
.callback-panel p { margin: 0; }
.callback-mark { width: 42px; height: 42px; font-size: 20px; }

.table-wrap { width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 660px; }
.table th { padding: 10px 12px; text-align: left; color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--border); }
.table td { padding: 11px 12px; border-bottom: 1px solid rgba(48,54,61,.7); vertical-align: middle; }
.table tbody tr:hover { background: rgba(255,255,255,.018); }
.table tbody tr.selected { background: var(--green-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table-action { text-align: right; white-space: nowrap; }
.truncate { max-width: 260px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.badge { display: inline-flex; align-items: center; min-height: 23px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-3); color: #c8d2dc; }
.badge-active { color: #75e6a3; background: var(--green-soft); }
.badge-danger { color: #ff9a95; background: var(--red-soft); }
.badge-warning { color: #e9bd58; background: rgba(210,153,34,.13); }
.badge-admin { color: #99c8ff; background: rgba(88,166,255,.12); }

.detail-list { display: grid; gap: 0; }
.detail-row { display: grid; grid-template-columns: 135px minmax(0, 1fr); gap: 14px; padding: 10px 0; border-bottom: 1px solid rgba(48,54,61,.7); }
.detail-row:last-child { border-bottom: 0; }
.detail-label { color: var(--muted); }
.detail-value { overflow-wrap: anywhere; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.toolbar .field { min-width: 150px; flex: 1; }
.toolbar .field-grow { flex: 2 1 240px; }
.pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--muted); }
.pagination-actions { display: flex; gap: 6px; }

.split-workspace { display: grid; grid-template-columns: minmax(500px, 1.35fr) minmax(360px, .85fr); gap: 16px; align-items: start; }
.detail-panel { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
.action-group { padding: 14px 0; border-top: 1px solid var(--border); }
.action-group:first-child { border-top: 0; padding-top: 0; }
.action-title { font-size: 12px; font-weight: 700; margin-bottom: 9px; }
.inline-form { display: flex; gap: 7px; align-items: end; }
.inline-form .field { flex: 1; }

.empty-state { padding: 42px 18px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); margin-bottom: 5px; }
.notice { padding: 11px 13px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); }
.notice-success { border-color: rgba(3,199,90,.35); background: var(--green-soft); color: #9ce8ba; }
.notice-danger { border-color: rgba(248,81,73,.35); background: var(--red-soft); color: #ffaaa6; }

.toast-region { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast { padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: 7px; background: #202731; box-shadow: var(--shadow); animation: toast-in .18s ease-out; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.skeleton { color: transparent; border-radius: 5px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

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

@media (max-width: 760px) {
    .topbar { padding: 0 14px; }
    .app-shell { display: block; }
    .sidebar { position: sticky; top: 56px; z-index: 15; width: 100%; height: auto; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
    .sidebar-label, .sidebar-footer { display: none; }
    .nav-list { display: flex; min-width: max-content; }
    .nav-item { width: auto; padding: 8px 11px; }
    .nav-item.active { box-shadow: inset 0 -2px var(--green); }
    .content { padding: 20px 14px 40px; }
    .page-header { display: block; }
    .page-actions { margin-top: 14px; justify-content: flex-start; }
    .grid-2, .form-grid { grid-template-columns: 1fr; }
    .metrics { gap: 8px; }
    .metric { padding: 13px; }
    .metric-value { font-size: 20px; }
    .detail-row { grid-template-columns: 105px minmax(0, 1fr); }
}

@media (max-width: 460px) {
    .metrics { grid-template-columns: 1fr; }
    .topbar-link.optional { display: none; }
    .inline-form { align-items: stretch; flex-direction: column; }
}
