:root {
  --bg: #0f1216;
  --panel: #161b22;
  --panel-2: #1c222b;
  --line: #2a313c;
  --text: #e6e9ee;
  --muted: #8b95a3;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, .14);
  --up: #3fb950;
  --error: #d29922;
  --down: #f85149;
  --unknown: #6e7681;
  --radius: 10px;
  --side-w: 248px;
  font-family: "Pretendard", "Noto Sans KR", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 8px;
  padding: 6px 12px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: #3b4452; background: #222a35; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { color: var(--down); }
.btn.icon { padding: 6px 9px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--unknown); flex: none; }
.dot.up { background: var(--up); box-shadow: 0 0 0 3px rgba(63, 185, 80, .15); }
.dot.error { background: var(--error); }
.dot.down { background: var(--down); }

/* ------------------------------------------------ layout */
.app { display: flex; height: 100vh; height: 100dvh; }
.side {
  width: var(--side-w); flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px; cursor: pointer; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: -.5px;
}
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { color: var(--muted); font-size: 11px; }
.search { margin: 0 12px 8px; }
.search input {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
}
.search input:focus { outline: none; border-color: var(--accent); }
.menu { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.menu-group { margin-top: 10px; }
.menu-group-title { color: var(--muted); font-size: 11px; font-weight: 600; padding: 6px 8px; letter-spacing: .3px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: none; border-radius: 8px; padding: 8px 10px; color: var(--text);
}
.menu-item:hover { background: var(--panel-2); }
.menu-item.active { background: var(--accent-soft); color: #fff; }
.menu-item.active .mi-name { font-weight: 600; }
.mi-icon { width: 20px; text-align: center; flex: none; }
.mi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-tag { color: var(--muted); font-size: 11px; }
.side-foot { border-top: 1px solid var(--line); padding: 10px 12px; display: flex; align-items: center; gap: 8px; }
.side-foot .who { flex: 1; min-width: 0; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 14px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.topbar .title { font-weight: 600; font-size: 15px; white-space: nowrap; }
.topbar .url { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.topbar .actions { display: flex; gap: 6px; }
.hamburger { display: none; }

.stage { flex: 1; position: relative; min-height: 0; }
.stage iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }
.stage iframe[hidden] { display: none; }

/* ------------------------------------------------ home */
.home { position: absolute; inset: 0; overflow-y: auto; padding: 24px; }
.home h1 { margin: 0 0 4px; font-size: 20px; }
.home .lead { color: var(--muted); margin: 0 0 20px; }
.home h2 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 22px 0 10px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 6px; min-height: 112px;
}
.card:hover { border-color: var(--accent); }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-icon { font-size: 20px; }
.card-name { font-weight: 600; flex: 1; }
.card-desc { color: var(--muted); font-size: 12px; line-height: 1.5; flex: 1; }
.card-foot { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 11px; }
.pill { border: 1px solid var(--line); border-radius: 99px; padding: 1px 7px; font-size: 11px; color: var(--muted); }

.notice {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center;
}
.notice .box { max-width: 440px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.notice .big { font-size: 34px; }
.notice p { color: var(--muted); line-height: 1.6; }

/* ------------------------------------------------ forms / login / admin */
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 28px;
}
.login h1 { font-size: 18px; margin: 12px 0 4px; }
.login .sub { color: var(--muted); font-size: 12px; margin: 0 0 20px; }
label.f { display: block; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
label.f input, label.f select, label.f textarea {
  display: block; width: 100%; margin-top: 5px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; color: var(--text);
}
label.f input:focus, label.f select:focus, label.f textarea:focus { outline: none; border-color: var(--accent); }
.err { color: var(--down); font-size: 12px; min-height: 18px; margin: 4px 0 8px; }

.admin { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.admin header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.admin header h1 { font-size: 18px; margin: 0; flex: 1; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 12px 0 16px; }
.tabs button { background: none; border: 0; padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: var(--panel); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.muted, .muted { color: var(--muted); }
td.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 4px; }
dialog {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
  padding: 0; width: min(640px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog form { padding: 20px; }
dialog h2 { margin: 0 0 14px; font-size: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 .wide { grid-column: 1 / -1; }
.checks { display: flex; gap: 16px; margin: 4px 0 12px; flex-wrap: wrap; }
.checks label { display: flex; gap: 6px; align-items: center; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.svc-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; max-height: 220px; overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: 8px; margin: 5px 0 12px; }
.svc-checks label { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--text); }

/* ------------------------------------------------ mobile */
@media (max-width: 760px) {
  .side { position: fixed; z-index: 20; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s; }
  .app.menu-open .side { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .5); }
  .hamburger { display: inline-flex; }
  .topbar .url { display: none; }
  .topbar .btn .lbl { display: none; }
  .home { padding: 16px; }
  .grid2 { grid-template-columns: 1fr; }
}
