:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #dfe4ec;
  --text: #1c2431;
  --muted: #6b7686;
  --primary: #cc2229;      /* Fortinet red */
  --primary-dark: #a81b21;
  --danger: #d43a3a;
  --ok: #1f9d63;
  --warn: #c9860a;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 20px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Malgun Gothic", "맑은 고딕", -apple-system, Segoe UI, Roboto, sans-serif;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0 0 6px; font-weight: 700; letter-spacing: -.2px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.muted { color: var(--muted); font-size: 13px; margin: 0; }
.text-error { color: var(--danger); }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }

/* ── 상단바 ─────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 10px 22px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.logo {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--primary); color: #fff; font-size: 12px; font-weight: 800;
}
.logo-lg { width: 44px; height: 44px; font-size: 16px; border-radius: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.user-chip { display: flex; align-items: center; gap: 6px; margin-right: 4px; }
.user-name { font-weight: 600; }
.inline-form { display: inline; margin: 0; }

.role-badge {
  font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: #eef1f6; color: var(--muted); font-weight: 600;
}
.role-super { background: #fdecec; color: var(--primary); }

/* ── 레이아웃 ───────────────────────────────────── */
.page { max-width: 1180px; margin: 0 auto; padding: 22px; }
.centered { display: grid; place-items: center; min-height: 100vh; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; margin-bottom: 18px;
}
.card.narrow { max-width: 460px; margin: 40px auto; }
.center-card { max-width: 420px; margin: 60px auto; text-align: center; }
.error-code { font-size: 42px; color: var(--primary); }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ── 폼 ─────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13px; font-weight: 600; }
.field small { font-size: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }

input[type=text], input[type=password], input[type=email], input[type=search], select {
  width: 100%; padding: 9px 11px; font-size: 14px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(204, 34, 41, .25); border-color: var(--primary); }
.input-sm { width: 200px; padding: 7px 10px; font-size: 13px; }

/* ── 버튼 ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; font-size: 13px; font-family: inherit; font-weight: 600;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  background: #eef1f6; color: var(--text); transition: filter .12s, background .12s;
}
.btn:hover:not(:disabled) { filter: brightness(.96); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; padding: 11px; font-size: 14px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); filter: none; }
.btn-danger { background: #fdecec; color: var(--danger); border-color: #f6d5d5; }
.btn-outline { background: #fff; border-color: var(--border); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: #eef1f6; color: var(--text); }

/* ── 표 ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: #f7f9fc; font-size: 12px; color: var(--muted); font-weight: 700; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfd; }
.table-compact th, .table-compact td { padding: 7px 10px; font-size: 12px; }
.col-actions { text-align: right; white-space: nowrap; }
.col-actions .btn + .btn { margin-left: 5px; }
.empty { text-align: center; color: var(--muted); padding: 26px 0; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; background: #eef1f6; color: var(--muted);
}
.badge-on { background: #e6f6ee; color: var(--ok); }
.badge-off { background: #f0f1f4; color: var(--muted); }
.badge-warn { background: #fdf3e2; color: var(--warn); }

/* ── 알림 ───────────────────────────────────────── */
.alert { padding: 10px 13px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.alert-error { background: #fdecec; color: #9c2020; }
.alert-info { background: #eaf2fd; color: #1d4f96; }
.alert-warning { background: #fdf3e2; color: #8a5c05; }
.alert-success { background: #e6f6ee; color: #12693f; }

.toast-area { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  min-width: 240px; max-width: 380px; padding: 11px 14px; border-radius: 8px;
  background: #22293a; color: #fff; font-size: 13px; box-shadow: var(--shadow);
  animation: toast-in .18s ease-out;
}
.toast-success { background: #14663f; }
.toast-error { background: #a51f1f; }
.toast-out { opacity: 0; transform: translateY(6px); transition: .35s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── 모달 ───────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(19, 24, 33, .45);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--surface); border-radius: 12px; padding: 20px 22px;
  width: 100%; max-width: 520px; box-shadow: 0 18px 50px rgba(16, 24, 40, .22);
  max-height: 90vh; overflow-y: auto;
}
.modal-sm { max-width: 400px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

/* ── 로그인 ─────────────────────────────────────── */
.login-card {
  width: 360px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); padding: 30px 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 4px; }
.login-head h1 { font-size: 18px; }

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .input-sm { width: 100%; }
}

/* ── 로그인 화면 하단 안내 ──────────────────────── */
.login-foot { margin-top: 14px; text-align: center; }
.login-foot a { color: var(--primary); text-decoration: underline; }
