/* ============================================================
   SJ.Company Display — 관리자 설정 UI
   ============================================================ */
:root {
  --a-bg: #070912;
  --a-panel: rgba(255, 255, 255, .045);
  --a-panel-2: rgba(255, 255, 255, .075);
  --a-line: rgba(255, 255, 255, .12);
  --a-text: #eef1ff;
  --a-dim: rgba(238, 241, 255, .58);
  --a-accent: #7c5cff;
  --a-accent-2: #22d3ee;
  --a-ok: #34d399;
  --a-warn: #fbbf24;
  --a-danger: #fb7185;
  --a-radius: 16px;
}

html, body { height: 100%; overflow: hidden; background: var(--a-bg); color: var(--a-text); }
body { font-family: 'Noto Sans KR', -apple-system, 'Segoe UI', sans-serif; }

/* ── 로그인 ────────────────────────────────── */
.login-wrap {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  transition: opacity .5s var(--ease), visibility .5s;
}
.login-wrap.hide { opacity: 0; visibility: hidden; pointer-events: none; }

.login-card {
  position: relative;
  z-index: 10;
  width: min(420px, 90vw);
  padding: 44px 38px 34px;
  border-radius: 26px;
  background: rgba(18, 20, 38, .55);
  backdrop-filter: blur(26px) saturate(160%);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .6), inset 0 1px 0 rgba(255, 255, 255, .25);
  animation: sjPop .7s var(--ease) both;
}

@keyframes sjPop {
  from { opacity: 0; transform: translateY(24px) scale(.96); }
  to   { opacity: 1; transform: none; }
}

.login-badge {
  width: 62px; height: 62px;
  margin: 0 auto 18px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 20px;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, var(--a-accent), var(--a-accent-2));
  box-shadow: 0 14px 40px rgba(124, 92, 255, .5);
}

.login-title { text-align: center; font-size: 1.32rem; font-weight: 700; letter-spacing: .02em; }
.login-sub { text-align: center; font-size: .82rem; color: var(--a-dim); margin: 6px 0 26px; letter-spacing: .06em; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: .78rem; color: var(--a-dim); margin-bottom: 7px; letter-spacing: .04em; }

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .06);
  border: 1px solid var(--a-line);
  color: var(--a-text);
  font-size: .92rem;
  font-family: inherit;
  outline: none;
  transition: border-color .25s, background .25s, box-shadow .25s;
}
input:focus, textarea:focus, select:focus {
  border-color: rgba(124, 92, 255, .8);
  background: rgba(255, 255, 255, .1);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, .16);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.6; }
select option { background: #12142a; color: #fff; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid var(--a-line);
  background: rgba(255, 255, 255, .07);
  color: var(--a-text);
  font-size: .86rem;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: all .22s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, .14); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, var(--a-accent), #5b7cff);
  border-color: transparent;
  box-shadow: 0 10px 30px rgba(124, 92, 255, .38);
  font-weight: 600;
}
.btn-primary:hover { box-shadow: 0 14px 38px rgba(124, 92, 255, .55); }
.btn-danger { color: var(--a-danger); border-color: rgba(251, 113, 133, .35); }
.btn-danger:hover { background: rgba(251, 113, 133, .16); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: .78rem; border-radius: 10px; }

.login-error {
  margin-top: 12px;
  padding: 10px 13px;
  border-radius: 10px;
  background: rgba(251, 113, 133, .14);
  border: 1px solid rgba(251, 113, 133, .3);
  color: #ffc2cc;
  font-size: .8rem;
  display: none;
}
.login-error.show { display: block; animation: sjShake .4s; }
@keyframes sjShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  75% { transform: translateX(7px); }
}

.login-hint { margin-top: 20px; text-align: center; font-size: .72rem; color: rgba(238, 241, 255, .35); letter-spacing: .04em; }
.link { text-decoration: underline; }
.mt-8 { margin-top: 8px; }
.tint-strong { opacity: .62; }
.vignette-strong { opacity: .7; }

.offline-text { font-size: .84rem; line-height: 1.7; color: var(--a-dim); text-align: center; }
.code-block {
  margin: 14px 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .45);
  border: 1px solid var(--a-line);
  font-family: ui-monospace, 'Consolas', monospace;
  font-size: .82rem;
  color: var(--a-accent-2);
  text-align: center;
  overflow-x: auto;
}

/* ── 경고 표시 ─────────────────────────────── */
.alert-bar {
  padding: 11px 20px;
  background: linear-gradient(90deg, rgba(251, 113, 133, .22), rgba(251, 191, 36, .18));
  border-bottom: 1px solid rgba(251, 113, 133, .4);
  font-size: .84rem;
  text-align: center;
  z-index: 30;
}

.badge-insecure {
  padding: 3px 9px;
  border-radius: 7px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  background: rgba(251, 191, 36, .18);
  border: 1px solid rgba(251, 191, 36, .45);
  color: #fcd34d;
}

.warn-box {
  padding: 13px 16px;
  border-radius: 12px;
  background: rgba(251, 191, 36, .1);
  border: 1px solid rgba(251, 191, 36, .3);
  font-size: .8rem;
  line-height: 1.65;
  color: #fde68a;
  margin-bottom: 16px;
}
.warn-box b { color: #fcd34d; }

.sec-list { margin: 0; padding-left: 18px; font-size: .8rem; line-height: 1.9; color: var(--a-dim); }
.sec-list b { color: var(--a-text); font-weight: 600; }
.sec-list code {
  font-family: ui-monospace, 'Consolas', monospace;
  font-size: .76rem;
  background: rgba(255, 255, 255, .07);
  padding: 1px 6px;
  border-radius: 5px;
}

/* 팔레트 항목 */
.pal-item { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.pal-color { width: 58px; height: 40px; }
.pal-label { font-size: .68rem; color: var(--a-dim); }

.url-input { max-width: 260px; }

/* ── 앱 셸 ─────────────────────────────────── */
.app { position: fixed; inset: 0; display: flex; flex-direction: column; opacity: 0; transition: opacity .5s var(--ease); }
.app.show { opacity: 1; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--a-line);
  background: rgba(10, 12, 26, .8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 20;
}

.top-badge {
  width: 34px; height: 34px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-family: 'Orbitron', sans-serif; font-weight: 900; font-size: 12px;
  background: linear-gradient(135deg, var(--a-accent), var(--a-accent-2));
  box-shadow: 0 6px 20px rgba(124, 92, 255, .45);
}
.top-title { font-weight: 700; font-size: .98rem; letter-spacing: .02em; }
.top-title small { display: block; font-size: .68rem; color: var(--a-dim); font-weight: 400; letter-spacing: .1em; }
.top-spacer { flex: 1; }

/* ── 최상위 모드 탭 (디스플레이 / Caddy) ────── */
.mode-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  margin-left: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--a-line);
}
.mode-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--a-dim);
  font: inherit;
  font-size: .8rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s;
}
.mode-tab:hover { color: var(--a-text); background: rgba(255, 255, 255, .06); }
.mode-tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--a-accent), var(--a-accent-2));
  box-shadow: 0 4px 14px rgba(124, 92, 255, .35);
}

.display-only { display: flex; align-items: center; gap: 14px; }
.app.mode-caddy .display-only { display: none; }
.app.mode-caddy .preview-pane { display: none; }
/* 미리보기가 살아 있는 넓은 화면에서만 2단으로 줄인다.
   좁은 화면 규칙(아래 미디어쿼리)을 이기지 않도록 min-width 로 감싼다. */
@media (min-width: 1181px) {
  .app.mode-caddy .body { grid-template-columns: 214px minmax(0, 1fr); }
}

.save-state {
  font-size: .76rem;
  color: var(--a-dim);
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--a-line);
}
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--a-ok); box-shadow: 0 0 10px var(--a-ok); }
.save-state.dirty .save-dot { background: var(--a-warn); box-shadow: 0 0 10px var(--a-warn); }

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: .8rem; color: var(--a-dim); user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 40px; height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  border: 1px solid var(--a-line);
  position: relative;
  transition: background .28s var(--ease);
  flex: none;
}
.switch .track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform .28s var(--ease);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
}
.switch input:checked + .track { background: linear-gradient(135deg, var(--a-accent), var(--a-accent-2)); border-color: transparent; }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ── 본문 ──────────────────────────────────── */
.body { flex: 1; display: grid; grid-template-columns: 214px minmax(0, 1fr) minmax(320px, 30vw); min-height: 0; }

.sidebar {
  border-right: 1px solid var(--a-line);
  padding: 16px 12px;
  overflow-y: auto;
  background: rgba(255, 255, 255, .02);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border-radius: 12px;
  cursor: pointer;
  font-size: .88rem;
  color: var(--a-dim);
  transition: all .2s var(--ease);
  border: 1px solid transparent;
  margin-bottom: 3px;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: var(--a-text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, .28), rgba(34, 211, 238, .14));
  border-color: rgba(124, 92, 255, .45);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(124, 92, 255, .2);
}
.nav-ico { width: 20px; text-align: center; font-size: 1rem; }

.panel-area { overflow-y: auto; padding: 26px 30px 60px; min-width: 0; }
.panel { display: none; animation: sjSlide .4s var(--ease) both; max-width: 780px; }
.panel.active { display: block; }
@keyframes sjSlide { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.panel-head { margin-bottom: 22px; }
.panel-head h2 { font-size: 1.28rem; font-weight: 700; letter-spacing: .01em; }
.panel-head p { font-size: .82rem; color: var(--a-dim); margin-top: 5px; }

.group {
  background: var(--a-panel);
  border: 1px solid var(--a-line);
  border-radius: var(--a-radius);
  padding: 6px 18px;
  margin-bottom: 16px;
}

.row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.row:last-child { border-bottom: none; }
.row.stack { grid-template-columns: 1fr; gap: 10px; align-items: stretch; }

.row-label { font-size: .86rem; font-weight: 500; }
.row-label small { display: block; font-size: .72rem; color: var(--a-dim); font-weight: 400; margin-top: 3px; line-height: 1.45; }
.row-control { min-width: 0; }

.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* 레인지 */
.range-wrap { display: flex; align-items: center; gap: 12px; }
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--a-accent), var(--a-accent-2));
  outline: none;
  min-width: 90px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--a-accent);
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .5);
  transition: transform .18s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
.range-val {
  min-width: 62px;
  text-align: right;
  font-size: .8rem;
  color: var(--a-dim);
  font-variant-numeric: tabular-nums;
}

/* 색상 */
.color-wrap { display: flex; align-items: center; gap: 10px; }
input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 46px; height: 34px;
  border: 1px solid var(--a-line);
  border-radius: 10px;
  background: none;
  cursor: pointer;
  padding: 3px;
}
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 7px; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-hex { width: 104px !important; font-family: ui-monospace, monospace; font-size: .8rem !important; text-transform: uppercase; }

/* 카드 선택 */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.card-opt {
  position: relative;
  border-radius: 13px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all .25s var(--ease);
  background: rgba(255, 255, 255, .05);
}
.card-opt:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, .3); }
.card-opt.on { border-color: var(--a-accent); box-shadow: 0 8px 26px rgba(124, 92, 255, .42); }
.card-thumb { height: 58px; display: block; }
.card-name { display: block; padding: 7px 8px; font-size: .74rem; text-align: center; color: var(--a-dim); }
.card-opt.on .card-name { color: #fff; font-weight: 600; }

/* 팔레트 */
.palette { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pal-presets { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.pal-preset {
  width: 76px; height: 30px;
  border-radius: 9px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .16);
  transition: transform .2s var(--ease), box-shadow .2s;
  position: relative;
}
.pal-preset:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 8px 20px rgba(0, 0, 0, .5); }

/* 이미지 업로드 */
.upload {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.thumb-box {
  width: 96px; height: 62px;
  border-radius: 11px;
  border: 1px dashed var(--a-line);
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  font-size: .68rem;
  color: var(--a-dim);
  flex: none;
  overflow: hidden;
}
input[type="file"] { display: none; }

/* 도시 검색 결과 */
.geo-list { margin-top: 9px; display: flex; flex-direction: column; gap: 5px; }
.geo-item {
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--a-line);
  cursor: pointer;
  font-size: .82rem;
  transition: all .2s;
}
.geo-item:hover { background: rgba(124, 92, 255, .22); border-color: rgba(124, 92, 255, .5); }

.hint-box {
  padding: 13px 16px;
  border-radius: 12px;
  background: rgba(34, 211, 238, .08);
  border: 1px solid rgba(34, 211, 238, .22);
  font-size: .78rem;
  color: rgba(238, 241, 255, .78);
  line-height: 1.65;
  margin-bottom: 16px;
}
.hint-box b { color: var(--a-accent-2); }

/* ── 미리보기 ──────────────────────────────── */
.preview-pane {
  border-left: 1px solid var(--a-line);
  background: rgba(255, 255, 255, .02);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.preview-title {
  font-size: .78rem;
  color: var(--a-dim);
  letter-spacing: .14em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.preview-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--a-line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
  background: #05060f;
}
.preview-frame-wrap iframe {
  position: absolute;
  top: 0; left: 0;
  width: 1600px;
  height: 900px;
  border: 0;
  transform-origin: top left;
}
.preview-note { font-size: .72rem; color: var(--a-dim); line-height: 1.6; }

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 13px 22px;
  border-radius: 13px;
  background: rgba(20, 22, 42, .92);
  border: 1px solid var(--a-line);
  backdrop-filter: blur(16px);
  font-size: .85rem;
  box-shadow: 0 16px 46px rgba(0, 0, 0, .6);
  opacity: 0;
  pointer-events: none;
  transition: all .35s var(--ease);
  z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: rgba(52, 211, 153, .45); }
.toast.err { border-color: rgba(251, 113, 133, .45); }

/* ── 반응형 ────────────────────────────────── */


.geo-out {
  font-size: .8rem;
  color: var(--a-dim);
  line-height: 1.5;
}

.warn-box code,
.hint-box code {
  font-family: ui-monospace, 'Consolas', monospace;
  font-size: .76rem;
  background: rgba(0, 0, 0, .35);
  padding: 1px 6px;
  border-radius: 5px;
  color: var(--a-accent-2);
}

/* ── Caddy 패널 ────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 7px;
  font-size: .74rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge.ok { background: rgba(52, 211, 153, .15); border: 1px solid rgba(52, 211, 153, .4); color: #6ee7b7; }
.badge.err { background: rgba(251, 113, 133, .15); border: 1px solid rgba(251, 113, 133, .4); color: #fda4af; }

.caddy-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--a-line);
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.caddy-item.adv { border-style: dashed; opacity: .82; }
.caddy-item-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .84rem; min-width: 0; }
.caddy-domains { font-weight: 700; color: var(--a-text); overflow-wrap: anywhere; }
.caddy-arrow { color: var(--a-dim); }
.caddy-upstream { font-family: ui-monospace, 'Consolas', monospace; color: var(--a-accent-2); overflow-wrap: anywhere; }
.caddy-tag {
  font-size: .7rem;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(251, 191, 36, .12);
  border: 1px solid rgba(251, 191, 36, .3);
  color: #fcd34d;
}

.log-view {
  margin-top: 10px;
  max-height: 320px;
  overflow: auto;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, .45);
  border: 1px solid var(--a-line);
  font-family: ui-monospace, 'Consolas', monospace;
  font-size: .72rem;
  line-height: 1.6;
  color: rgba(238, 241, 255, .82);
  white-space: pre-wrap;
  word-break: break-all;
}

.badge.warn { background: rgba(251, 191, 36, .15); border: 1px solid rgba(251, 191, 36, .4); color: #fcd34d; }
.caddy-note { font-size: .72rem; color: var(--a-dim); }
.caddy-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.caddy-name {
  font-size: .72rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 7px;
  background: rgba(124, 92, 255, .18);
  border: 1px solid rgba(124, 92, 255, .42);
  color: #c4b5fd;
  white-space: nowrap;
}
.caddy-role { font-size: .74rem; color: var(--a-dim); line-height: 1.5; }
.role-input { flex: 1 1 340px; min-width: 220px; max-width: 460px; }
.txt-warn { color: #fcd34d; font-weight: 700; }
.txt-err { color: #fda4af; font-weight: 700; }

/* 통계 그리드 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}
.stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 13px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--a-line);
}
.stat-label { font-size: .74rem; color: var(--a-dim); }
/* break-all 은 "48.6 MB" 를 "48.6 M / B" 로 쪼개므로 쓰지 않는다 */
.stat-value { font-size: .82rem; font-weight: 600; text-align: right; overflow-wrap: anywhere; }

/* 코드 편집 영역 */
.code-area {
  width: 100%;
  font-family: ui-monospace, 'Consolas', monospace !important;
  font-size: .78rem !important;
  line-height: 1.65;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
  tab-size: 4;
}

/* 로그 목록 */
.log-list {
  max-height: 460px;
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--a-line);
  background: rgba(0, 0, 0, .35);
}
.log-row {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 6px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
  font-size: .74rem;
  line-height: 1.5;
}
.log-row:last-child { border-bottom: 0; }
.log-row:hover { background: rgba(255, 255, 255, .04); }
.log-time {
  flex: 0 0 auto;
  font-family: ui-monospace, 'Consolas', monospace;
  font-size: .7rem;
  color: var(--a-dim);
}
.log-level {
  flex: 0 0 46px;
  font-size: .64rem;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--a-dim);
}
.log-row.lv-warn .log-level { color: #fcd34d; }
.log-row.lv-error .log-level { color: #fda4af; }
.log-row.lv-warn { background: rgba(251, 191, 36, .06); }
.log-row.lv-error { background: rgba(251, 113, 133, .07); }
.log-msg { flex: 1 1 auto; min-width: 0; word-break: break-word; }
.log-extra { flex: 0 1 auto; font-size: .68rem; color: var(--a-dim); text-align: right; word-break: break-all; }
.log-raw {
  font-family: ui-monospace, 'Consolas', monospace;
  font-size: .68rem;
  word-break: break-all;
  color: rgba(238, 241, 255, .75);
}

.backup-preview { flex-basis: 100%; max-height: 220px; }

/* ── 반응형: 반드시 파일 맨 끝에 두어 위의 모든 규칙을 덮어쓰게 한다 ── */
@media (max-width: 1180px) {
  .body { grid-template-columns: 190px minmax(0, 1fr); }
  .preview-pane { display: none; }
}
@media (max-width: 720px) {
  .body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { display: flex; gap: 6px; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--a-line); padding: 10px; }
  .nav-item { margin-bottom: 0; white-space: nowrap; }
  .row { grid-template-columns: 1fr; gap: 9px; }
  .panel-area { padding: 18px 16px 60px; }
  .top-title small { display: none; }

  /* 상단바: 한 줄에 다 못 넣으므로 3단으로 접는다
     1행 = 로고·제목·로그아웃 / 2행 = 모드 탭 / 3행 = 저장 관련 */
  .topbar { flex-wrap: wrap; gap: 8px 10px; padding: 10px 12px; }
  .top-title { font-size: .88rem; }
  .mode-tabs { order: 2; width: 100%; margin-left: 0; }
  .mode-tab { flex: 1; padding: 10px 8px; }
  .display-only { order: 3; width: 100%; justify-content: flex-end; flex-wrap: wrap; gap: 8px 10px; }

  /* iOS 사파리는 16px 미만 입력칸에 포커스하면 화면을 확대해 버린다 */
  input[type="text"], input[type="password"], input[type="number"], textarea, select { font-size: 16px; }
  .btn-sm { padding: 9px 14px; font-size: .8rem; }

  .url-input, .role-input { max-width: 100%; min-width: 0; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
  /* 좁은 칸에서 라벨과 값이 한 줄에 같이 들어가면 글자가 잘린다 — 위아래로 쌓는다 */
  .stat { padding: 8px 11px; flex-direction: column; align-items: flex-start; gap: 2px; }
  .stat-value { text-align: left; }

  /* 도메인·업스트림 카드: 좌우 배치 대신 세로로 쌓는다 */
  .caddy-item { flex-direction: column; align-items: stretch; gap: 9px; }
  .caddy-item .inline { justify-content: flex-end; }

  /* 로그 한 줄: 시각·레벨은 위, 본문과 부가정보는 아래 전체 폭 */
  .log-list { max-height: 60vh; }
  .log-row { flex-wrap: wrap; gap: 3px 8px; }
  .log-msg { flex: 1 1 100%; }
  .log-extra { flex: 1 1 100%; text-align: left; }

  .login-card { padding: 34px 24px 26px; }
  .preview-pane { display: none; }
}

@media (max-width: 480px) {
  /* 상단바가 4줄까지 늘어나 본문 공간을 잡아먹는다.
     뷰어 열기는 "데이터" 탭에도 같은 버튼이 있으므로 여기서만 숨긴다. */
  #btnOpen { display: none; }
  .top-title { font-size: .82rem; }
  .mode-tab { font-size: .76rem; padding: 9px 6px; }
  .panel-head h2 { font-size: 1.05rem; }
}
