/* 중앙 관리 화면 스타일 (업체 프로그램과 같은 어두운 디자인 토큰, Pretendard) */
@font-face {
  font-family: "Pretendard Variable";
  font-weight: 45 920;
  font-style: normal;
  font-display: swap;
  src: url("/vendor/PretendardVariable.woff2") format("woff2-variations");
}

:root {
  color-scheme: dark;
  --bg: #121a23;
  --surface: #17212c;
  --raised: #1d2935;
  --hover: #223142;
  --line: #2a3746;
  --line-soft: #212d3a;
  --text: #e8eef4;
  --text-2: #9aa8b8;
  --text-3: #6e7e90;
  --gold: #e8b84a;
  --gold-2: #a8853a;
  --gold-3: #6f5a33;
  --gold-soft: rgba(232, 184, 74, .12);
  --pc: #a99bff;
  --mobile: #45d6c0;
  --up: #ff6464;
  --down: #5ea1ff;
  --none: #3a4858;
  --none-text: #7b8a9b;
  --fail: #f29a4a;
  --topbar-h: 60px;
  --r-s: 6px;
  --r-m: 10px;
  --font: "Pretendard Variable", Pretendard, "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: #cfd9ff; text-decoration: none; }
a:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(232, 184, 74, .35); }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
[hidden] { display: none !important; }

/* 스크롤바 */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2c3a4a; border: 3px solid var(--bg); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #3a4b5e; }

/* ---------- 상단 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 28px;
  padding: 0 28px;
  background: rgba(18, 26, 35, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand:hover { color: var(--text); text-decoration: none; }
.brand svg { flex: none; }
.topbar nav { display: flex; gap: 2px; height: 100%; }
.topbar nav a {
  display: flex; align-items: center; padding: 0 14px; color: var(--text-2); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.topbar nav a:hover { color: var(--text); text-decoration: none; }
.topbar nav a.active { color: var(--text); border-bottom-color: var(--gold); }

.notices { max-width: 1320px; margin: 0 auto; padding: 0 28px; }
.notice {
  margin-top: 14px; padding: 10px 14px; border-radius: var(--r-s);
  display: flex; gap: 10px; align-items: flex-start;
  background: rgba(242, 154, 74, .08); border: 1px solid rgba(242, 154, 74, .35); color: #f5c79c; font-size: 13px;
}
.notice::before { content: "!"; flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--fail); color: #1b1208; font-weight: 800; font-size: 12px; display: grid; place-items: center; margin-top: 1px; }
.notice.info { background: rgba(169, 155, 255, .07); border-color: rgba(169, 155, 255, .3); color: #cfc8ff; }
.notice.info::before { content: "i"; background: var(--pc); }

main { max-width: 1320px; margin: 0 auto; padding: 22px 28px 80px; }

/* ---------- 공통 요소 ---------- */
.panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-m); padding: 20px 22px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.panel h2 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.panel h2 .count { color: var(--text-3); font-weight: 500; margin-left: 6px; }
.panel h3 { margin: 18px 0 8px; font-size: 14px; font-weight: 600; }
.note { margin: -6px 0 14px; font-size: 13px; color: var(--text-2); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--r-s);
  border: 1px solid var(--line); background: var(--raised); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--hover); border-color: #36475a; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1d1606; font-weight: 650; }
.btn.primary:hover { background: #f1c45d; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff9b9b; }
.btn.danger:hover { border-color: rgba(255, 100, 100, .5); }
.btn.on { border-color: var(--gold); color: var(--gold); background: var(--gold-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { flex: none; }

input[type=text], input[type=password], input[type=search], input[type=date], textarea, select {
  font: inherit; color: var(--text);
  height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
textarea { width: 100%; min-height: 96px; padding: 9px 11px; resize: vertical; height: auto; }
select { padding-right: 8px; }
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.form-row + .form-row { margin-top: 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--gold); }

.seg-ctl { display: inline-flex; padding: 3px; gap: 2px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line-soft); }
.seg-ctl button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2);
  font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seg-ctl button:hover { color: var(--text); }
.seg-ctl button[aria-pressed=true] { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.seg-ctl button .n { color: var(--text-3); font-size: 12px; }
.seg-ctl button[aria-pressed=true] .n { color: var(--gold); }

.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 4px; background: var(--raised); color: var(--text-2); border: 1px solid var(--line); }
.acct { display: inline-block; font-size: 11.5px; color: var(--text-2); background: var(--raised); border-radius: 4px; padding: 0 6px; margin-left: 6px; }
.empty { color: var(--text-2); padding: 36px 0; text-align: center; }

/* 표 */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: middle; }
th { font-size: 12.5px; font-weight: 600; color: var(--text-3); background: var(--surface); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--raised); }
td.num { white-space: nowrap; }
.sticky-head thead th { position: sticky; top: var(--topbar-h); z-index: 5; box-shadow: inset 0 -1px 0 var(--line); }

/* 알림 */
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 50; max-width: 420px;
  padding: 12px 16px; border-radius: 8px; background: var(--raised); border: 1px solid var(--line);
  color: var(--text); box-shadow: 0 10px 30px rgba(0, 0, 0, .35); font-size: 13.5px;
  opacity: 0; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.error { border-color: rgba(255, 100, 100, .5); color: #ffc2c2; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 로그인, 계정, 백업·복제 */
.user-box { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: 13px; }
.login-box { max-width: 360px; margin: 72px auto 0; display: flex; flex-direction: column; gap: 14px; }
.login-box h1 { margin: 0; font-size: 20px; font-weight: 650; }
.login-box label { display: flex; flex-direction: column; gap: 6px; color: var(--text-2); font-size: 13px; }
.login-box input { height: 38px; }
.login-box .btn { height: 38px; justify-content: center; }
.login-err { padding: 9px 12px; border-radius: var(--r-s); background: rgba(242, 154, 74, .1); border: 1px solid rgba(242, 154, 74, .35); color: var(--fail); font-size: 13px; }
.cmd { margin: 0; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line-soft); border-radius: var(--r-s); color: var(--text); font: 13px/1.6 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.version-line { margin: 4px 0 0; text-align: center; font-size: 12.5px; color: var(--text-3); }


/* ---------- 중앙 관리 화면 ---------- */
.login-mode .topbar nav, .login-mode .user-box { display: none; }
.topbar nav { overflow-x: auto; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a { white-space: nowrap; }
.user-box { flex: none; }

input[type=number], input[type=month], input[type=file], input[type=email], input[type=tel], input[type=url] {
  font: inherit; color: var(--text);
  height: 34px; padding: 0 11px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--bg);
}
input[type=file] { height: auto; padding: 6px 8px; max-width: 100%; }
input[type=number]:focus, input[type=month]:focus, input[type=file]:focus, input[type=email]:focus, input[type=tel]:focus, input[type=url]:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft);
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin: 2px 0 18px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { font-size: 13px; color: var(--text-2); }
.back:hover { color: var(--text); text-decoration: none; }
.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: 760px; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin-right: 4px; }

/* 입력 칸 */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; color: var(--text-2); }
.field input, .field select, .field textarea { width: 100%; }
.field small { color: var(--text-3); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

/* 상태 표시 */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--raised); color: var(--text-2); white-space: nowrap; }
.badge.ok { color: var(--mobile); border-color: rgba(69, 214, 192, .4); background: rgba(69, 214, 192, .08); }
.badge.warn { color: var(--fail); border-color: rgba(242, 154, 74, .45); background: rgba(242, 154, 74, .08); }
.badge.bad { color: #ff9b9b; border-color: rgba(255, 100, 100, .45); background: rgba(255, 100, 100, .08); }
.badge.gold { color: var(--gold); border-color: rgba(232, 184, 74, .45); background: var(--gold-soft); }
.stale { color: var(--fail); }
.money { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
th.money { text-align: right; }

/* 요약 칸 */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r-m); padding: 16px 18px; }
.stat span { display: block; font-size: 12.5px; color: var(--text-3); }
.stat b { display: block; margin-top: 4px; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.stat.warn b { color: var(--fail); }
.stat.ok b { color: var(--mobile); }

/* 이상 업체, 설명 목록 */
.anomaly { display: block; padding: 12px 4px; border-bottom: 1px solid var(--line-soft); color: var(--text); }
.anomaly:last-child { border-bottom: 0; }
.anomaly:hover { text-decoration: none; background: var(--raised); }
.anomaly b { font-weight: 650; }
.anomaly ul { margin: 4px 0 0; padding-left: 18px; color: var(--fail); font-size: 13px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; }
.kv dt { color: var(--text-2); font-size: 13px; }
.kv dd { margin: 0; word-break: break-all; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin-bottom: 18px; }
.two-col .panel { margin-bottom: 0; }
.err-box { padding: 12px 14px; border-radius: var(--r-s); background: rgba(255, 100, 100, .08); border: 1px solid rgba(255, 100, 100, .35); color: #ffc2c2; font-size: 13.5px; }
.err-box .btn { margin-left: 10px; }
.hint { font-size: 12.5px; color: var(--text-3); margin: 8px 0 0; }
.pick-list { max-height: 260px; overflow: auto; border: 1px solid var(--line-soft); border-radius: var(--r-s); padding: 6px 10px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.pick-list .check { padding: 3px 0; }
.bar-mini { display: inline-block; width: 90px; height: 6px; border-radius: 4px; background: var(--line); vertical-align: middle; overflow: hidden; }
.bar-mini i { display: block; height: 100%; background: var(--gold); }
.bar-mini.bad i { background: var(--fail); }

/* 대화상자 */
dialog.dlg { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; padding: 0; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
dialog.dlg::backdrop { background: rgba(5, 9, 14, .65); }
.dlg-body { padding: 20px 22px; }
.dlg-body h2 { margin: 0 0 10px; font-size: 17px; font-weight: 650; }
.dlg-body p { margin: 0 0 12px; color: var(--text-2); line-height: 1.6; white-space: pre-wrap; }
.dlg-err { margin-top: 12px; }
.secret { margin: 10px 0 14px; }
.secret-label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; font-size: 12.5px; color: var(--text-2); }
.notice.billing { background: var(--gold-soft); border-color: rgba(232, 184, 74, .4); color: #f3dca6; }
.notice.billing::before { background: var(--gold); }

@media (max-width: 860px) {
  .topbar { position: static; height: auto; flex-wrap: wrap; gap: 4px 14px; padding: 8px 16px 0; }
  .topbar nav { order: 3; width: 100%; height: auto; flex-wrap: wrap; overflow: visible; }
  .topbar nav a { padding: 8px 12px; margin-bottom: 0; }
  .user-box { margin-left: auto; }
  main, .notices { padding-left: 16px; padding-right: 16px; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .brand span { display: none; }
  .stat-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .panel { padding: 16px 14px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
  .page-head h1 { font-size: 19px; }
}
.two-col > div > .panel { margin-bottom: 18px; }
tr.attempt-row > td { background: var(--bg); padding: 8px 12px 12px; }
tr.attempt-row table { min-width: 560px; }
