/* gw.pinksky.kr 디자인 토큰과 같은 값(gw/erp/frontend/src/styles/tokens.css) */
:root {
  --bg: #f3f5f9; --surface: #ffffff; --surface-subtle: #f7f9fc; --popover: #ffffff;
  --border: #dce2ec; --border-strong: #c2ccd9;
  --text: #111827; --text-secondary: #475569; --text-muted: #5b6779;
  --primary: #1e5bd8; --primary-hover: #1749b2; --primary-soft: rgba(30, 91, 216, 0.1); --primary-solid: #1e5bd8;
  --ok: #13703a; --ok-soft: rgba(21, 128, 61, 0.12); --ok-solid: #13703a;
  --warn: #9a4a0a; --warn-soft: rgba(180, 83, 9, 0.12); --warn-solid: #9a4a0a;
  --danger: #b91c1c; --danger-soft: rgba(185, 28, 28, 0.12); --danger-solid: #b91c1c;
  --info: #1d4ed8; --info-soft: rgba(29, 78, 216, 0.12);
  --accent-vm: #0e7490; --accent-vm-soft: rgba(14, 116, 144, 0.12);
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.12), 0 2px 6px rgba(15, 23, 42, 0.06);
  --modal-shadow: 0 16px 36px rgba(15, 23, 42, 0.22);
  --radius: 10px;
  color-scheme: light;
}
html.dark {
  --bg: #0e1013; --surface: #121418; --surface-subtle: #181b21; --popover: #15181d;
  --border: #232830; --border-strong: #343c48;
  --text: #e6ebf2; --text-secondary: #a8b3c4; --text-muted: #8a96a8;
  --primary: #6b9bf5; --primary-hover: #427bf0; --primary-soft: rgba(47, 106, 224, 0.18); --primary-solid: #2f6ae0;
  --ok: #34d399; --ok-soft: rgba(52, 211, 153, 0.15); --ok-solid: #047857;
  --warn: #fbbf24; --warn-soft: rgba(251, 191, 36, 0.16); --warn-solid: #b45309;
  --danger: #f87171; --danger-soft: rgba(248, 113, 113, 0.16); --danger-solid: #dc2626;
  --info: #60a5fa; --info-soft: rgba(96, 165, 250, 0.16);
  --accent-vm: #22d3ee; --accent-vm-soft: rgba(34, 211, 238, 0.14);
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.35);
  --modal-shadow: 0 18px 42px rgba(0, 0, 0, 0.65);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: Pretendard, "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.5; min-height: 100vh; overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); }
[hidden] { display: none !important; }

/* 헤더 */
.hdr {
  position: sticky; top: 0; z-index: 20; height: 56px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.hdr-l, .hdr-r { display: flex; align-items: center; gap: 10px; min-width: 0; }
.hdr h1 { font-size: 18px; margin: 0; letter-spacing: -0.01em; }
.hdr-sub { color: var(--text-muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo { width: 22px; height: 16px; border-radius: 4px; background: var(--primary-solid); position: relative; }
.logo::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: -5px; height: 3px; border-radius: 2px; background: var(--primary-solid); }
.badge-user {
  padding: 4px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary);
  font-weight: 600; font-size: 13px; white-space: nowrap;
}

main { max-width: 1680px; margin: 0 auto; padding: 20px 24px 48px; }
.loading { padding: 80px 0; text-align: center; color: var(--text-muted); }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap;
  font-weight: 500;
}
.btn:hover { background: var(--surface-subtle); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.primary { background: var(--primary-solid); border-color: var(--primary-solid); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger-solid { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.btn.warn { color: var(--warn); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-subtle); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}

/* 탭 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 10px 18px; border: 0; background: none; cursor: pointer; color: var(--text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; font-size: 15px;
}
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { margin-left: 6px; font-size: 12px; padding: 1px 7px; border-radius: 999px; background: var(--surface-subtle); color: var(--text-muted); }
.subtabs { display: inline-flex; padding: 3px; gap: 3px; border-radius: 9px; background: var(--surface-subtle); border: 1px solid var(--border); }
.subtab { border: 0; background: none; padding: 6px 16px; border-radius: 7px; cursor: pointer; color: var(--text-secondary); font-weight: 600; }
.subtab[aria-selected="true"] { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12); }

/* 툴바·섹션 */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar-l, .toolbar-r { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-title { font-size: 16px; font-weight: 700; margin: 0; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel-pad { padding: 16px 18px; }
.empty { padding: 48px 20px; text-align: center; color: var(--text-muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }

/* 우선순위 안내 */
.prio { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.prio .step { padding: 4px 10px; border-radius: 999px; font-weight: 600; }
.prio .p1 { background: var(--ok-soft); color: var(--ok); }
.prio .p2 { background: var(--info-soft); color: var(--info); }
.prio .p3 { background: var(--warn-soft); color: var(--warn); }
.prio .arrow { color: var(--text-muted); }

/* VM 카드 */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 14px; }
.vm-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.vm-card.off { opacity: 0.72; }
.vm-card.paused { border-color: var(--warn); box-shadow: inset 3px 0 0 var(--warn); }
.vm-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.vm-title { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vm-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--text-muted); }
.vm-meta { display: grid; grid-template-columns: 88px 1fr; gap: 3px 10px; font-size: 13px; }
.vm-meta dt { color: var(--text-muted); }
.vm-meta dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vm-opts { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 8px; background: var(--surface-subtle); border: 1px solid var(--border); }
.vm-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pause-note { font-size: 12px; padding: 6px 10px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }

.chk { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.chk input { width: 16px; height: 16px; accent-color: var(--primary-solid); margin: 0; }
.chk .hint { color: var(--text-muted); font-size: 12px; }

/* 스위치 */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; font-weight: 600; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background 0.15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,.25); }
.switch input:checked + .track { background: var(--ok-solid); }
.switch input:checked + .track::after { left: 19px; }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* 상태 배지 */
.st { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.st::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st.online, .st.done { background: var(--ok-soft); color: var(--ok); }
.st.busy, .st.running { background: var(--info-soft); color: var(--info); }
.st.paused, .st.queued { background: var(--warn-soft); color: var(--warn); }
.st.error, .st.failed { background: var(--danger-soft); color: var(--danger); }
.st.offline, .st.cancelled { background: var(--surface-subtle); color: var(--text-muted); border: 1px solid var(--border); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--surface-subtle); border: 1px solid var(--border); color: var(--text-secondary); white-space: nowrap; }
.tag.pub { background: var(--info-soft); color: var(--info); border-color: transparent; }
.tag.bg { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.tag.prio100 { background: var(--ok-soft); color: var(--ok); border-color: transparent; }

/* 6단계 바 */
.stages { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; }
.stages span { height: 6px; border-radius: 3px; background: var(--border); }
.stages span.on { background: var(--ok-solid); }
.stage-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* 표 */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-subtle); color: var(--text-secondary); font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; }
td .clip { display: block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.kpi .k { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.kpi .v { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi.ok .v { color: var(--ok); } .kpi.info .v { color: var(--info); } .kpi.warn .v { color: var(--warn); } .kpi.vm .v { color: var(--accent-vm); }

.tower { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.tower-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.slot {
  height: 96px; border-radius: 8px; border: 1px dashed var(--border-strong); background:
  repeating-linear-gradient(135deg, var(--surface-subtle) 0 10px, var(--surface) 10px 20px);
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 12px; text-align: center;
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.audit { max-height: 760px; overflow-y: auto; }
.audit-item { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.audit-item:last-child { border-bottom: 0; }
.audit-item .when { color: var(--text-muted); font-size: 12px; }

/* 폼 */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.field .help { font-size: 12px; color: var(--text-muted); }
input[type=text], input[type=password], input[type=number], select, textarea {
  height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); min-width: 0;
}
textarea { height: auto; min-height: 72px; padding: 8px 10px; resize: vertical; }
select.sm, input.sm { height: 30px; font-size: 13px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.radio-row { display: flex; gap: 8px; }
.radio-card { flex: 1; display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border-strong); cursor: pointer; }
.radio-card:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.radio-card input { margin-top: 3px; accent-color: var(--primary-solid); }
.err-text { color: var(--danger); font-size: 13px; min-height: 18px; }

/* 모달 */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal { width: 100%; max-width: 620px; max-height: calc(100vh - 40px); overflow-y: auto; background: var(--popover); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--modal-shadow); }
.modal.narrow { max-width: 440px; }
.modal-h { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-h h2 { font-size: 16px; margin: 0; }
.modal-b { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }

/* 토스트 */
#toast-root { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { min-width: 260px; max-width: 420px; padding: 10px 14px; border-radius: 8px; background: var(--popover); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 13px; border-left: 4px solid var(--primary); }
.toast.ok { border-left-color: var(--ok-solid); } .toast.err { border-left-color: var(--danger-solid); } .toast.warn { border-left-color: var(--warn-solid); }

/* 로그인·차단 화면 */
.gate { max-width: 440px; margin: 64px auto; }
.gate .panel { padding: 26px 28px; display: flex; flex-direction: column; gap: 14px; }
.gate h2 { margin: 0; font-size: 20px; }
.gate .or { text-align: center; color: var(--text-muted); font-size: 12px; }

.match-note { padding: 10px 12px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-size: 13px; font-weight: 600; }
.match-note.t0 { background: var(--warn-soft); color: var(--warn); }
.match-note.t1 { background: var(--ok-soft); color: var(--ok); }
.m0 { margin: 0; }
.minw0 { min-width: 0; }
.row-c { display: flex; gap: 10px; align-items: center; }
.tags-row { display: flex; gap: 6px; flex-wrap: wrap; }
.info-bar { margin-bottom: 14px; display: flex; gap: 24px; flex-wrap: wrap; font-size: 13px; }
