:root {
  --navy: #1b2a4a;
  --navy-light: #2a3d63;
  --red: #c8102e;
  --red-dark: #a10d25;
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e3e5ea;
  --text: #1f2430;
  --text-muted: #6b7280;
  --ok: #1a8754;
  --warn: #b8860b;
  --danger: #c8102e;
  --muted-badge: #9aa0ab;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Pretendard", "Malgun Gothic", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- Login ---------- */
#loginScreen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); }
.login-card { background: #fff; border-radius: 16px; padding: 36px 34px; width: 380px; max-width: 90vw; box-shadow: 0 20px 60px rgba(0,0,0,0.35); }
.login-card img { width: 170px; display: block; margin: 0 auto 22px; }
.login-card h1 { font-size: 16px; text-align: center; color: var(--navy); margin: 0 0 24px; }
.login-card .field-row { margin-bottom: 14px; }
.login-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; }
.login-card button.primary { width: 100%; padding: 12px; font-size: 14.5px; margin-top: 6px; }
.login-error { color: var(--danger); font-size: 12.5px; margin-top: 10px; text-align: center; min-height: 16px; }

#shell { display: flex; height: 100vh; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
}
#brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 6px 8px 18px; border-bottom: 1px solid rgba(255,255,255,0.12); margin-bottom: 10px; }
#logo { width: 150px; background: #fff; border-radius: 6px; padding: 8px 10px; }
#brandSub { font-size: 12.5px; color: #cfd6e6; font-weight: 600; letter-spacing: 0.2px; }

#nav { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 10px; border-radius: 8px; cursor: pointer;
  color: #dfe3ee; font-size: 13.5px; user-select: none;
  font-family: inherit; text-align: left; border: none; background: none; width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,0.08); }
.nav-item.active { background: var(--red); color: #fff; font-weight: 600; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }

#sidebarFooter { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,0.12); }
#userBadge { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; color: #dfe3ee; font-size: 12.5px; }
#userBadge .name { font-weight: 700; color: #fff; }
#userBadge .role-tag { display: inline-block; margin-top: 3px; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 1px 8px; width: fit-content; }
.ghost-btn {
  background: rgba(255,255,255,0.08); color: #fff; border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px; padding: 9px 10px; font-size: 12.5px; cursor: pointer; text-align: left; font-family: inherit;
}
.ghost-btn:hover { background: rgba(255,255,255,0.16); }

/* ---------- Main ---------- */
#content { flex: 1; overflow-y: auto; padding: 26px 34px 60px; }
#pageHeader { margin-bottom: 18px; }
#pageTitle { margin: 0 0 4px; font-size: 22px; color: var(--navy); }
#pageDesc { margin: 0; color: var(--text-muted); font-size: 13px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 8px; }

button.primary {
  background: var(--red); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 13.5px; font-weight: 600; cursor: pointer; font-family: inherit;
}
button.primary:hover { background: var(--red-dark); }
button.primary:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary {
  background: #fff; color: var(--navy); border: 1px solid var(--border); border-radius: 8px;
  padding: 9px 16px; font-size: 13.5px; cursor: pointer; font-family: inherit;
}
button.secondary:hover { background: #f0f1f4; }
button.danger-outline {
  background: #fff; color: var(--danger); border: 1px solid var(--danger); border-radius: 8px;
  padding: 6px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit;
}
button.link-btn { background: none; border: none; color: var(--navy); cursor: pointer; text-decoration: underline; font-size: 12.5px; padding: 0; font-family: inherit; }

/* ---------- Cards / Dashboard ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
.card h3 { margin: 0 0 10px; font-size: 15px; color: var(--navy); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat-num { font-size: 26px; font-weight: 800; color: var(--navy); }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.stat-num.danger { color: var(--danger); }
.stat-num.warn { color: var(--warn); }
.stat-num.ok { color: var(--ok); }

.alert-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; gap: 10px; }
.alert-row:last-child { border-bottom: none; }
.empty-hint { color: var(--text-muted); font-size: 13px; padding: 8px 0; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.badge.ok { background: #e3f6ea; color: var(--ok); }
.badge.warn { background: #fdf1d9; color: var(--warn); }
.badge.danger { background: #fbe2e6; color: var(--danger); }
.badge.muted { background: #eceef1; color: var(--muted-badge); }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; border: 1px solid var(--border); }
thead th { text-align: left; background: #f0f2f5; color: var(--navy); font-size: 12.5px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
tbody td { padding: 10px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8f9fb; }
.row-actions { display: flex; gap: 8px; }
.row-actions button { font-size: 12px; }
.table-wrap { overflow-x: auto; }

/* ---------- Form / Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,20,32,0.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: 640px; max-width: 92vw; max-height: 88vh; overflow-y: auto; padding: 22px 26px; }
.modal h2 { margin: 0 0 14px; font-size: 17px; color: var(--navy); }
.field-row { margin-bottom: 13px; }
.field-row label { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 5px; font-weight: 600; }
.field-row input[type=text], .field-row input[type=number], .field-row input[type=date], .field-row input[type=email], .field-row input[type=password], .field-row select, .field-row textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 13.5px; font-family: inherit; background: #fff;
}
.field-row textarea { min-height: 64px; resize: vertical; }
.field-row.checkbox-row { display: flex; align-items: center; gap: 8px; }
.field-row.checkbox-row label { margin: 0; }
.field-locked-note { font-size: 11.5px; color: var(--warn); margin-top: 3px; }
.multiselect-box { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid var(--border); border-radius: 7px; padding: 8px; max-height: 120px; overflow-y: auto; }
.chip-check { font-size: 12.5px; font-family: inherit; background: #f0f2f5; color: var(--text); border: none; padding: 4px 9px; border-radius: 999px; cursor: pointer; user-select: none; }
.chip-check.selected { background: var(--navy); color: #fff; }
.file-list { display: flex; flex-direction: column; gap: 5px; margin-top: 6px; }
.file-item { display: flex; align-items: center; justify-content: space-between; background: #f6f7f9; border-radius: 6px; padding: 6px 10px; font-size: 12.5px; gap: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.template-btn-row { margin-bottom: 16px; }
.template-btn-row a.secondary-link {
  display: inline-block; background: #eef2fb; color: var(--navy); border: 1px solid #d3ddf2; border-radius: 8px;
  padding: 9px 14px; font-size: 13px; text-decoration: none; font-weight: 600;
}

.detail-block { margin-bottom: 12px; }
.detail-block .k { font-size: 11.5px; color: var(--text-muted); font-weight: 600; margin-bottom: 3px; }
.detail-block .v { font-size: 13.5px; white-space: pre-wrap; }
.revision-note { background: #fff8ea; border: 1px solid #f0dca0; border-radius: 8px; padding: 10px 12px; font-size: 12px; margin-top: 10px; }

#toastRoot { position: fixed; bottom: 22px; right: 26px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; box-shadow: 0 6px 18px rgba(0,0,0,0.2); }
.toast.error { background: var(--danger); }
