/* RemoteRelayTool 관리 콘솔 스타일. 색은 모두 변수로 두고 어두운 테마는 브라우저 설정(prefers-color-scheme)을 따른다. */
:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f0f3f5;
  --text: #1c2630;
  --muted: #5d6b78;
  --border: #d9e0e6;
  --primary: #0f6e56;
  --primary-hover: #0b5a46;
  --primary-text: #ffffff;
  --danger: #b3261e;
  --danger-bg: #fdecea;
  --warn-bg: #fff4d6;
  --warn-text: #7a5a00;
  --ok-bg: #e3f5ec;
  --ok-text: #0b5a3c;
  --info-bg: #e6f0fb;
  --info-text: #174a85;
  --focus: #2b7de9;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 32, .06), 0 4px 14px rgba(16, 24, 32, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171c;
    --surface: #1b2229;
    --surface-2: #232c35;
    --text: #e6ebf0;
    --muted: #9aa8b5;
    --border: #2f3a45;
    --primary: #2fb58c;
    --primary-hover: #4cc9a0;
    --primary-text: #07261d;
    --danger: #ff8a80;
    --danger-bg: #3a1f1d;
    --warn-bg: #3a2f10;
    --warn-text: #f1cf75;
    --ok-bg: #123226;
    --ok-text: #7fe0b6;
    --info-bg: #14283f;
    --info-text: #8ec0f5;
    --focus: #6aa8ff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1 { font-size: 1.45rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); }
code, .mono { font-family: Consolas, "D2Coding", monospace; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ── 부팅 화면 ─────────────────────────────────────── */
.boot { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; color: var(--muted); }
.boot-spinner { width: 36px; height: 36px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.9s linear infinite; margin-bottom: 12px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 인증 화면(로그인/가입) ──────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; font-size: 1.15rem; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--primary); color: var(--primary-text); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 26px 24px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: .9rem; }
.auth-foot { margin-top: 18px; font-size: .8rem; color: var(--muted); text-align: center; }

/* ── 앱 틀 ─────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 56px 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.topbar .who { display: flex; align-items: center; gap: 12px; font-size: .9rem; min-width: 0; }
.topbar .who .org { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidenav { background: var(--surface); border-right: 1px solid var(--border); padding: 14px 10px; }
.sidenav a { display: block; padding: 9px 12px; border-radius: 8px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
.sidenav a:hover { background: var(--surface-2); }
.sidenav a.active { background: var(--primary); color: var(--primary-text); font-weight: 600; }
.content { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 56px auto 1fr; }
  .sidenav { display: flex; gap: 4px; overflow-x: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidenav a { white-space: nowrap; margin: 0; }
  .content { padding: 18px 16px 40px; }
  .topbar { padding: 0 12px; }
  .topbar .who .org { display: none; }
}

/* ── 카드·표 ───────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-head h2 { margin: 0; }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table td { min-width: 7em; word-break: keep-all; } /* 좁은 화면에서 한글이 글자 단위로 쪼개지지 않게 하고, 넘치면 표 안에서 가로로 스크롤한다 */
.table td.mono, .table td.right { min-width: 0; }
.table th { font-size: .8rem; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tr.dim td { color: var(--muted); }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

/* ── 폼 ────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 5px; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); font: inherit;
}
input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin: 0; min-width: 180px; flex: 1; }
.inline-form .field.narrow { flex: 0 0 200px; min-width: 150px; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.checks label { font-weight: 400; display: inline-flex; align-items: center; gap: 6px; margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger-bg); }
.btn.block { width: 100%; }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.btn.link { border: 0; background: none; color: var(--primary); padding: 0; }
strong + .btn.link, strong + .badge { margin-left: 8px; }

/* ── 배지·알림 ─────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok-text); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); }
.badge.bad { background: var(--danger-bg); color: var(--danger); }
.badge.info { background: var(--info-bg); color: var(--info-text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .92rem; }
.alert.error { background: var(--danger-bg); color: var(--danger); }
.alert.success { background: var(--ok-bg); color: var(--ok-text); }
.alert.info { background: var(--info-bg); color: var(--info-text); }
.alert.warn { background: var(--warn-bg); color: var(--warn-text); }

/* 새로 발급한 등록 코드 */
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--surface-2); border: 2px dashed var(--primary); border-radius: 10px; padding: 14px 18px; margin: 10px 0; }
.code-box .code { user-select: all; font-family: Consolas, "D2Coding", monospace; font-size: 1.5rem; letter-spacing: .06em; font-weight: 700; }

/* ── 모달 ──────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 12, 16, .55); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); width: 100%; max-width: 440px; padding: 22px; }
.modal h2 { margin-bottom: 8px; }
.modal .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search] { max-width: 280px; }
.spinner { width: 18px; height: 18px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
.loading { padding: 28px; text-align: center; color: var(--muted); }
.cell-edit { display: flex; gap: 6px; align-items: center; }
.cell-edit input { max-width: 240px; }

/* Blazor 기본 오류 표시 */
#blazor-error-ui { background: var(--warn-bg); color: var(--warn-text); bottom: 0; box-shadow: 0 -1px 4px rgba(0, 0, 0, .25); display: none; left: 0; padding: .6rem 1.25rem .7rem 1.25rem; position: fixed; width: 100%; z-index: 1000; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); font-size: .85rem; }


/* 감사 로그 상세 */
details > summary { cursor: pointer; color: var(--primary); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 8px 0 0; font-size: .85rem; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-all; }
.narrow-form { max-width: 420px; }
dl.kv.wide { font-size: .95rem; grid-template-columns: 110px 1fr; gap: 6px 14px; }