:root {
  --bg: #0f1216;
  --panel: #171b21;
  --panel2: #1e242c;
  --border: #2a323c;
  --text: #e6eaef;
  --muted: #8b97a6;
  --accent: #4f9dff;
  --green: #3fb950;
  --red: #f45b5b;
  --amber: #e3b341;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "Malgun Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
}

/* 로그인 */
.login-body { display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 36px 32px;
  width: min(360px, 92vw);
  display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0; font-size: 20px; text-align: center; }
.login-card .sub { margin: 0 0 8px; color: var(--muted); text-align: center; font-size: 13px; }
.login-card input {
  background: var(--panel2); border: 1px solid var(--border); color: var(--text);
  padding: 11px 12px; border-radius: 8px; font-size: 14px;
}
.err { color: var(--red); font-size: 13px; min-height: 18px; text-align: center; }

/* 레이아웃 */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; }
.layout { display: flex; height: calc(100vh - 53px); }
.sidebar {
  width: 240px; background: var(--panel); border-right: 1px solid var(--border);
  padding: 14px; overflow-y: auto;
}
.sidebar h2, .content h2 { font-size: 14px; color: var(--muted); margin: 4px 0 12px; font-weight: 600; }
.server-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.server-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.server-item.active { border-color: var(--accent); }
.server-item .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.server-item.on .dot { background: var(--green); }
.server-item.off .dot { background: var(--red); }
.server-item .nm { font-size: 13px; }

.content { flex: 1; display: flex; flex-direction: column; padding: 16px 20px; overflow: hidden; }
.content-head { display: flex; align-items: center; gap: 12px; }
.content-head h2 { margin: 0; font-size: 18px; color: var(--text); }
.spacer { flex: 1; }
.badge { font-size: 12px; padding: 3px 10px; border-radius: 20px; background: var(--panel2); border: 1px solid var(--border); color: var(--muted); }
.badge.on { color: var(--green); border-color: var(--green); }
.badge.off { color: var(--red); border-color: var(--red); }

.controls { display: flex; gap: 8px; }
.btn {
  background: var(--accent); color: #fff; border: none; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.start { background: var(--green); }
.btn.stop { background: var(--red); }
.btn.restart { background: var(--amber); color: #1a1a1a; }
.btn.mini { padding: 5px 9px; font-size: 12px; }

.tabs { display: flex; gap: 6px; margin: 16px 0 12px; border-bottom: 1px solid var(--border); }
.tab { background: none; border: none; color: var(--muted); padding: 8px 12px; cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tabpanel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
/* hidden 속성이 display:flex 를 이기도록 (탭/버튼 표시 토글) */
.tabpanel[hidden], .controls[hidden], [hidden] { display: none !important; }

.log {
  flex: 1; margin: 0; background: #0a0d10; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; overflow-y: auto; font-family: "Consolas", "D2Coding", monospace;
  font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-all; color: #cdd6e0;
}
.cmd-form { display: flex; gap: 8px; margin-top: 10px; }
.cmd-form input { flex: 1; background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 9px 12px; border-radius: 8px; font-size: 13px; }

.row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.hint { color: var(--muted); font-size: 12px; }
.hint code { background: var(--panel2); padding: 1px 6px; border-radius: 4px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; }
.sched-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.sched-form input, .sched-form select { background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel2); border: 1px solid var(--border); padding: 12px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .2s; }
.toast.show { opacity: 1; }
.toast.ok { border-color: var(--green); }
.toast.bad { border-color: var(--red); }

/* ---- 뷰 컨테이너 ---- */
#serverView, #metricsView { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---- 사이드바 지표 버튼 ---- */
.nav-metrics {
  display: block; box-sizing: border-box; text-decoration: none;
  width: 100%; text-align: left; background: var(--panel2); border: 1px solid var(--border);
  color: var(--text); padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
  font-weight: 600; margin-bottom: 14px;
}
.nav-metrics:hover { border-color: var(--accent); }

/* 지표 페이지(독립) */
.back-link { color: var(--accent); text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.brand .sep { color: var(--muted); margin: 0 8px; }
.metrics-page { height: calc(100vh - 53px); display: flex; flex-direction: column; padding: 16px 20px; overflow: hidden; }
.metrics-toolbar { flex: none; flex-wrap: wrap; }
.next-run { color: var(--accent); }

/* ---- 지표 대시보드 ---- */
.m-ctl { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.m-ctl select { background: var(--panel2); border: 1px solid var(--border); color: var(--text); padding: 5px 8px; border-radius: 6px; }
.m-error { background: #2a1416; border: 1px solid var(--red); color: #ffb4b4; padding: 10px 12px; border-radius: 8px; margin-bottom: 10px; font-size: 13px; }
.m-grid { flex: 1; overflow-y: auto; padding-right: 4px; margin-top: 12px; }
.m-grid-inner { display: grid; grid-template-columns: repeat(12, 1fr); gap: 12px; align-content: start; }
.m-row { grid-column: 1 / -1; font-size: 13px; font-weight: 700; color: var(--muted); padding: 6px 2px 0; border-bottom: 1px solid var(--border); }
.m-panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; }
.span-3 { grid-column: span 3; }
.span-6 { grid-column: span 6; }
.m-title { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.m-body { flex: 1; }
.m-stat { font-size: 34px; font-weight: 800; line-height: 1.6; }
.m-gauge { width: 100%; max-height: 92px; }
.m-gauge-val { font-size: 15px; font-weight: 800; }
.m-chart { width: 100%; height: 210px; display: block; }
.m-axis { fill: #6b7684; font-size: 10px; font-family: "Segoe UI", sans-serif; }
.m-empty { color: var(--muted); font-size: 13px; padding: 24px 0; text-align: center; }
.m-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.m-leg-item i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.m-leg-item b { color: var(--text); font-weight: 700; }
.m-tip { position: fixed; z-index: 50; background: #0b0e12; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; color: var(--text); pointer-events: none; box-shadow: 0 6px 20px rgba(0,0,0,.4); display: none; }
.m-tip .tt-time { color: var(--muted); margin-bottom: 4px; font-size: 11px; }
.m-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }
.m-tip b { font-weight: 700; }
@media (max-width: 900px) { .span-3 { grid-column: span 6; } .span-6 { grid-column: 1 / -1; } }
