/* PKE 원격 접속 */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1d2127;
  --sub: #5d6672;
  --faint: #8b939e;
  --line: #e3e6ea;
  --accent: #1f6feb;
  --accent-ink: #ffffff;
  --accent-soft: #e8f0fe;
  --ok: #1a7f37;
  --ok-soft: #e6f4ea;
  --warn: #9a6700;
  --warn-soft: #fff4d6;
  --danger: #cf222e;
  --danger-soft: #ffebe9;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --font: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, "D2Coding", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --text: #e6e9ed;
    --sub: #a1a9b4;
    --faint: #737c88;
    --line: #2a3038;
    --accent: #4c8dff;
    --accent-ink: #ffffff;
    --accent-soft: #1b2a45;
    --ok: #3fb950;
    --ok-soft: #12261a;
    --warn: #d29922;
    --warn-soft: #2a2110;
    --danger: #f85149;
    --danger-soft: #2d1416;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
h1 { font-size: 20px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 14px; }
p { margin: 0; }
a { color: var(--accent); }
.sub { color: var(--sub); font-size: 13px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.grow { flex: 1 1 auto; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.msg { color: var(--danger); font-size: 13px; min-height: 1em; }
.msg:empty { display: none; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; text-decoration: none;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .55; cursor: default; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger-text { color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--sub); }
.field.port { width: 110px; flex: none; }
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 15px; font-weight: 400;
}
textarea { resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 16px; height: 16px; }
.field small { font-weight: 400; }

.box { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0; }
fieldset.box legend { padding: 0 6px; font-size: 13px; font-weight: 700; color: var(--sub); }

/* ---------- login ---------- */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); padding: 28px 24px;
  display: flex; flex-direction: column; gap: 22px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .sub { margin-top: 2px; }
.brand-mark {
  width: 36px; height: 36px; flex: none; border-radius: 9px;
  background: var(--accent) url("/static/img/favicon.svg") center / 26px no-repeat;
  background-color: var(--accent-soft);
}
.brand.small .brand-mark { width: 28px; height: 28px; background-size: 20px; }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar strong { font-size: 15px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  height: 34px; padding: 0 12px; border: 0; border-radius: 8px;
  background: transparent; color: var(--sub); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
}
.tab:hover { background: var(--accent-soft); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); }
.me { display: flex; gap: 4px; }

.page { max-width: 1080px; margin: 0 auto; padding: 28px 24px 60px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.section-head .sub { margin-top: 4px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.card {
  display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card.is-on { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.card-main { display: flex; flex-direction: column; gap: 6px; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card .notes { white-space: pre-wrap; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600;
}
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.plain { background: transparent; color: var(--faint); padding: 0; font-weight: 500; }
td .tag { margin-left: 6px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.on { color: var(--ok); }
.status.off { color: var(--faint); }
.status.unknown { color: var(--warn); }

.empty {
  padding: 40px 20px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 6px;
}

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12px; color: var(--sub); font-weight: 700; background: color-mix(in srgb, var(--bg) 60%, var(--surface)); }
.table tr:last-child td { border-bottom: 0; }
.table tr.bad td { background: var(--danger-soft); }
.table td .btn + .btn { margin-left: 4px; }

/* ---------- dialogs ---------- */
.dialog {
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); overflow: auto;
  padding: 22px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.dialog::backdrop { background: rgba(15, 18, 22, .45); }
.actions { display: flex; justify-content: flex-end; gap: 8px; }
.actions.center { justify-content: center; }
.qr { width: 180px; height: 180px; align-self: center; background: #fff; border-radius: 8px; padding: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 10px;
  background: var(--text); color: var(--bg); font-size: 14px; box-shadow: var(--shadow);
}
.toast.error { background: var(--danger); color: #fff; }

/* ---------- viewer ---------- */
body.viewer { background: #111418; color: #e6e9ed; overflow: hidden; height: 100vh; }
.vbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px;
  background: rgba(23, 27, 33, .92); border-bottom: 1px solid #2a3038; backdrop-filter: blur(6px);
  transition: transform .2s ease;
}
body.bar-hidden .vbar { transform: translateY(-100%); }
.vtitle { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.vstatus { font-size: 12px; color: #a1a9b4; white-space: nowrap; }
.vdot { width: 8px; height: 8px; border-radius: 50%; background: #737c88; flex: none; }
.vdot.ok { background: #3fb950; }
.vdot.busy { background: #d29922; }
.vdot.off { background: #f85149; }
.vtools { margin-left: auto; display: flex; gap: 4px; overflow-x: auto; }
.vbtn {
  height: 30px; padding: 0 10px; border: 1px solid #2f3640; border-radius: 7px;
  background: #1d232b; color: #e6e9ed; font: inherit; font-size: 13px; font-weight: 600;
  text-decoration: none; display: inline-flex; align-items: center; white-space: nowrap; cursor: pointer;
}
.vbtn:hover { background: #262d37; }
.vbtn[aria-pressed="true"] { background: #1b2a45; border-color: #4c8dff; color: #cfe0ff; }
.vbtn.danger { border-color: #5a2328; color: #ffb4ae; }
.vscreen { position: fixed; inset: 44px 0 0 0; background: #111418; }
body.bar-hidden .vscreen { top: 0; }
body.native .vscreen { overflow: auto; }
.voverlay { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; padding: 16px; background: rgba(17, 20, 24, .82); }
.vcard {
  width: min(440px, 100%); padding: 24px; border-radius: 14px; text-align: center;
  background: #171b21; border: 1px solid #2a3038; display: flex; flex-direction: column; gap: 10px;
}
.vcard .sub { color: #a1a9b4; }
.vmsg { font-size: 17px; font-weight: 700; }
.vcard .actions { margin-top: 8px; }
.vcard .btn { background: #1d232b; border-color: #2f3640; color: #e6e9ed; }
.vcard .btn.primary { background: #1f6feb; border-color: #1f6feb; color: #fff; }
.vclip {
  position: fixed; top: 54px; right: 12px; z-index: 25; width: min(420px, calc(100vw - 24px));
  padding: 14px; border-radius: 12px; background: #171b21; border: 1px solid #2a3038;
  display: flex; flex-direction: column; gap: 10px;
}
.vclip textarea { background: #0f1216; color: #e6e9ed; border-color: #2a3038; font-family: var(--mono); font-size: 13px; }
.vclip .btn { background: #1d232b; border-color: #2f3640; color: #e6e9ed; }
.vclip .btn.primary { background: #1f6feb; border-color: #1f6feb; color: #fff; }
.vclip .sub { color: #a1a9b4; }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .me { margin-left: auto; }
  .page { padding: 20px 16px 48px; }
  .section-head { flex-direction: column; align-items: stretch; }
  .cards { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .field.port { width: 100%; }
  .vtitle { max-width: 40vw; }
  .vstatus { display: none; }
}

.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
