:root {
  --navy: #0e2a47;
  --navy-dark: #0a1f36;
  --navy-light: #eaf0f7;
  --bg: #f7f9fb;
  --surface: #ffffff;
  --card-bg: #ffffff;
  --border: #e2e6ea;
  --text: #16212c;
  --text-muted: #78838c;
  --accent-red: #d64545;
  --ok-bg: #eaf3de;
  --ok-text: #3b6d11;
  --warn-bg: #faeeda;
  --warn-text: #854f0b;
  --danger-bg: #fce6e6;
  --danger-text: #a02525;
  --input-bg: #ffffff;
  --row-border: #f0f0ee;
  --count-bg: #f1e9fb;
  --count-text: #7c3aed;
  --danger-border: #f3c8c8;
  --info-border: #d5e0ec;
}

/* ── 다크 모드 팔레트 - js/theme.js가 <html data-theme="dark">를 붙이면 적용.
   네이비 브랜드 톤을 유지한 어두운 배색. color-scheme: dark로 브라우저 기본
   위젯(스크롤바/체크박스 등)도 어둡게 렌더링된다. ── */
:root[data-theme="dark"] {
  --navy: #4478b8;
  --navy-dark: #35619a;
  --navy-light: #1b2a40;
  --bg: #0d1420;
  --surface: #141d2c;
  --card-bg: #141d2c;
  --border: #263650;
  --text: #e7ecf3;
  --text-muted: #93a1b3;
  --accent-red: #e07070;
  --ok-bg: #1c2e18;
  --ok-text: #a3cf82;
  --warn-bg: #352913;
  --warn-text: #ddab5e;
  --danger-bg: #3a1d1d;
  --danger-text: #e79090;
  --input-bg: #0f1826;
  --row-border: #1e2c42;
  --count-bg: #2b2347;
  --count-text: #bfa8f7;
  --danger-border: #5c2e2e;
  --info-border: #2b3d5c;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; }
button { font-family: inherit; }

/* ── App shell: sidebar + main ─────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 18px 14px; position: sticky; top: 0; height: 100vh;
}
.sidebar .logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); padding: 6px 8px 20px; }
.sidebar .logo .mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.sidebar .logo .word { font-size: 15.5px; font-weight: 700; line-height: 1.2; }
.sidebar .logo .sub { font-size: 10px; color: var(--text-muted); font-weight: 500; }

.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600; color: var(--text-muted); text-decoration: none;
}
.side-nav a i { width: 16px; text-align: center; font-size: 14px; }
.side-nav a:hover { background: var(--navy-light); color: var(--navy); }
.side-nav a.active { background: var(--navy); color: #fff; }

/* ── Main column ───────────────────────────────────────────────── */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

header.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 16px 26px; background: var(--surface); border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.header-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.header-title h1 { font-size: 18px; font-weight: 700; }
.status-chip {
  font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 20px;
  display: inline-flex; align-items: center; gap: 5px;
}
.status-chip.ok { background: var(--ok-bg); color: var(--ok-text); }
.status-chip.ok i { font-size: 7px; }
.status-chip.engine { background: var(--navy-light); color: var(--navy); }

.header-right { display: flex; align-items: center; gap: 16px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); cursor: pointer; font-size: 13px;
}
.user-menu { display: flex; align-items: center; gap: 9px; cursor: pointer; position: relative; }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.user-menu .name { font-size: 13px; font-weight: 600; }
.user-dropdown {
  position: absolute; top: 42px; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(14,42,71,.12); min-width: 150px; padding: 6px; display: none; z-index: 20;
}
.user-dropdown.open { display: block; }
.user-dropdown button {
  width: 100%; text-align: left; background: none; border: none; padding: 9px 10px; border-radius: 7px;
  font-size: 13px; color: var(--text); cursor: pointer;
}
.user-dropdown button:hover { background: var(--navy-light); color: var(--navy); }

main.page { flex: 1; max-width: 1200px; width: 100%; margin: 0 auto; padding: 24px 26px 60px; }
@media (max-width: 880px) {
  .sidebar { position: fixed; left: -240px; z-index: 30; transition: left .2s; box-shadow: 0 0 0 9999px rgba(0,0,0,0); }
  .app-shell { flex-direction: column; }
}

.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-head p { font-size: 13.5px; color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn-ghost {
  background: none; border: 1px solid var(--border); color: var(--navy);
  font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-family: inherit;
}
.btn-navy {
  background: var(--navy); border: 1px solid var(--navy); color: #fff;
  font-size: 13px; font-weight: 600; padding: 8px 16px; border-radius: 8px; cursor: pointer; font-family: inherit;
}
.btn-navy:disabled, .btn-ghost:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; height: 44px; }
.btn-danger { background: var(--accent-red); border-color: var(--accent-red); color: #fff; }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px;
}
.card + .card { margin-top: 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 720px) { .stat-grid { grid-template-columns: 1fr 1fr; } }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 16px; }
.stat-label { font-size: 11.5px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }
.stat-value { font-size: 21px; font-weight: 700; }
.progress-track { height: 6px; border-radius: 4px; background: var(--navy-light); margin-top: 10px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--navy); border-radius: 4px; }

/* ── Engine card ────────────────────────────────────────────────── */
.engine-card {
  display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px; background: var(--card-bg);
}
.engine-card .engine-icon {
  width: 34px; height: 34px; border-radius: 9px; background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0;
}
.engine-card .engine-name { font-size: 13.5px; font-weight: 700; }
.engine-card .engine-desc { font-size: 11.5px; color: var(--text-muted); }
.engine-card .engine-badge {
  margin-left: auto; font-size: 10.5px; font-weight: 700; color: var(--ok-text); background: var(--ok-bg);
  padding: 3px 9px; border-radius: 20px; white-space: nowrap;
}

/* ── Forms ──────────────────────────────────────────────────────── */
label { font-size: 12px; color: var(--text-muted); display: block; margin-bottom: 6px; font-weight: 600; }
.field { margin-bottom: 16px; }
input, select {
  width: 100%; height: 42px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text); padding: 0 12px; font-size: 14px; font-family: inherit; outline: none;
}
input:focus, select:focus { border-color: var(--navy); }

/* ── Toggle switch ──────────────────────────────────────────────── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; font-size: 13px; }
.toggle {
  position: relative; width: 40px; height: 22px; border-radius: 20px; background: var(--border);
  cursor: pointer; flex-shrink: 0; transition: background .15s;
}
.toggle.on { background: var(--navy); }
.toggle .knob {
  position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: left .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.on .knob { left: 20px; }

/* ── Tables ─────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; color: var(--text-muted); font-weight: 700; padding: 10px 14px; text-transform: uppercase; letter-spacing: .02em; border-bottom: 1px solid var(--border); }
td { padding: 11px 14px; border-top: 1px solid var(--row-border); }
.pill { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 600; display: inline-block; }
.pill.ok { background: var(--ok-bg); color: var(--ok-text); }
.pill.warn { background: var(--warn-bg); color: var(--warn-text); }
.pill.danger { background: var(--danger-bg); color: var(--danger-text); }
.pill.plan { background: var(--navy-light); color: var(--navy); }
.pill.count { background: var(--count-bg); color: var(--count-text); }

.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.table-toolbar h2 { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.search-box { position: relative; width: 240px; max-width: 100%; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 12px; }
.search-box input { padding-left: 32px; height: 38px; }
.icon-btn-square {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--input-bg);
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); cursor: pointer;
}
.icon-btn-square:hover { color: var(--accent-red); border-color: var(--accent-red); background: var(--danger-bg); }
.icon-btn-square:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn-square:disabled:hover { color: var(--text-muted); border-color: var(--border); background: var(--input-bg); }

/* ── Theme toggle (다크/라이트 전환 버튼) ────────────────────────── */
.theme-toggle-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
  flex-shrink: 0; transition: color .15s, border-color .15s;
}
.theme-toggle-btn:hover { color: var(--navy); border-color: var(--navy); }

/* ── Alerts ─────────────────────────────────────────────────────── */
.alert { font-size: 13px; padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; }
.alert.error { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }
.alert.info { background: var(--navy-light); color: var(--navy); border: 1px solid var(--info-border); }

/* ── Auth pages (no sidebar) ────────────────────────────────────── */
header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 28px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); }
.logo .mark {
  width: 32px; height: 32px; border-radius: 8px; background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
}
.logo .word { font-size: 16px; font-weight: 700; }
.logo .sub { font-size: 10.5px; color: var(--text-muted); font-weight: 500; margin-top: 1px; }
/* ── 브랜드 워드마크 - 네모 이니셜(.mark) 대신 쓰는 로고 타입.
   "So"(진남색) + "Ri"(블루→퍼플 그라데이션) + 웨이브폼 아이콘 + "Vom"(진남색)
   구성으로, 로고 이미지 원본을 이미지 파일 없이 텍스트+인라인 SVG로 재현한다
   (다크 모드에서 --navy가 밝은 색으로 바뀌어도 그대로 따라간다). */
.logo .brandmark { display: inline-flex; align-items: center; font-weight: 800; letter-spacing: -0.02em; }
/* 워드마크는 일반 .word보다 10px 크게 - 이니셜 아이콘이 빠진 만큼 존재감 보강 */
.logo .word.brandmark { font-size: 26px; }
.sidebar .logo .word.brandmark { font-size: 25.5px; }
.logo .brandmark .bm-grad {
  background: linear-gradient(100deg, #3b4fe0, #7a3ff0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo .brandmark .bm-wave { height: 0.9em; width: auto; margin: 0 3px; flex-shrink: 0; }
main.center { display: flex; align-items: center; justify-content: center; padding: 64px 24px; min-height: calc(100vh - 68px); background: var(--bg); }
.card.auth { width: 100%; max-width: 380px; background: var(--surface); }
.card.auth h1 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.card.auth .tagline { font-size: 13px; color: var(--text-muted); margin-bottom: 22px; }
.foot { text-align: center; font-size: 12.5px; color: var(--text-muted); margin-top: 16px; }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(14,42,71,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.modal-box {
  background: var(--surface); border-radius: 14px; padding: 24px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(14,42,71,.25);
}
.modal-box h2 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.modal-box .tagline { font-size: 12.5px; color: var(--text-muted); margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; margin-top: 4px; }
.modal-actions .btn-ghost, .modal-actions .btn-navy { flex: 1; }

/* ── Feature footer strip ───────────────────────────────────────── */
.feature-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-top: 20px; }
@media (max-width: 880px) { .feature-strip { grid-template-columns: repeat(2, 1fr); } }
.feature-item { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-muted); }
.feature-item i { color: var(--navy); font-size: 15px; width: 20px; text-align: center; }
.feature-item b { display: block; font-size: 12.5px; color: var(--text); font-weight: 700; }
