:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-soft: #f2eee6;
  --ink: #182330;
  --muted: #506072;
  --line: #ddd6c8;
  --brand: #284768;
  --brand-deep: #101d2e;
  --brand-mid: #1c3048;
  --gold: #e9d9b5;
  --ok-bg: #e7f3ec;
  --ok-fg: #1b5e3b;
  --warn-bg: #fbf2de;
  --warn-fg: #8a5612;
  --err-bg: #fbe9e7;
  --err-fg: #9c2b23;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(16, 29, 46, 0.05);
}

@media (prefers-color-scheme: dark) {
  [data-theme="dark"] {
    --bg: #0e1621;
    --surface: #152130;
    --surface-soft: #1b2a3d;
    --ink: #f2eee6;
    --muted: #9eb0c4;
    --line: #27394f;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(247, 245, 240, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.brand-seal {
  border-radius: 8px;
  display: block;
  box-shadow: 0 2px 6px rgba(16, 29, 46, 0.16);
}
.brand-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 12px;
  color: var(--muted);
}
.top-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.nav-pill {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 15px;
  border-radius: 999px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.nav-pill:hover {
  border-color: var(--brand);
}
.nav-pill.active {
  background: linear-gradient(135deg, var(--brand-mid), var(--brand-deep));
  color: var(--gold);
  border-color: var(--brand-deep);
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 120px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.loading-card {
  text-align: center;
  color: var(--muted);
  padding: 40px;
}

.hero {
  background: linear-gradient(135deg, var(--brand-mid) 0%, var(--brand-deep) 100%);
  color: #f7f5f0;
  border-color: var(--brand-deep);
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 24px;
  align-items: center;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 3vw, 30px);
  line-height: 1.2;
  color: #ffffff;
}
.hero p {
  margin: 0;
  color: rgba(247, 245, 240, 0.84);
  font-size: 14.5px;
}
.hero-kicker {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}
.hero-stat-box {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(233, 217, 181, 0.22);
  border-radius: 12px;
  padding: 16px;
}
.hero-stat-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.1;
}
.hero-stat-lbl {
  font-size: 12.5px;
  color: rgba(247, 245, 240, 0.78);
  margin-top: 4px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}
.section-desc {
  margin: 3px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}
.chip {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink);
  padding: 6px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { border-color: var(--brand); }
.chip.selected {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field label {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
}
.field input, .field select, .field textarea {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid rgba(40, 71, 104, 0.25);
  border-color: var(--brand);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 9px 15px;
  border-radius: 10px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s, border-color 0.15s, background 0.15s;
}
.btn:hover { border-color: var(--brand); }
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand-mid), var(--brand-deep));
  color: var(--gold);
  border-color: var(--brand-deep);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-lg {
  padding: 13px 22px;
  font-size: 15.5px;
  border-radius: 12px;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 8px;
}
.btn-danger {
  background: var(--err-bg);
  color: var(--err-fg);
  border-color: #ebc2bd;
}

.join-result {
  margin-top: 18px;
  border: 1.5px solid var(--brand);
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 18px;
}
.cmd-box {
  background: #101d2e;
  color: #e9d9b5;
  padding: 13px 14px;
  border-radius: 10px;
  font-size: 13px;
  word-break: break-all;
  margin: 10px 0 12px;
  border: 1px solid rgba(233, 217, 181, 0.2);
}
.steps-mini {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.step-item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
}
.step-num {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: 11.5px;
  margin-right: 6px;
}

.status-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.status-wait {
  background: var(--warn-bg);
  color: var(--warn-fg);
}
.status-ok {
  background: var(--ok-bg);
  color: var(--ok-fg);
}
.status-err {
  background: var(--err-bg);
  color: var(--err-fg);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi-label {
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kpi-val {
  font-size: 26px;
  font-weight: 750;
  margin-top: 4px;
}
.kpi-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 14px;
}
.dev-card {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 13px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dev-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(40, 71, 104, 0.12);
}
.dev-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  white-space: nowrap;
}
.pill-ok { background: var(--ok-bg); color: var(--ok-fg); }
.pill-warn { background: var(--warn-bg); color: var(--warn-fg); }
.pill-off { background: var(--surface-soft); color: var(--muted); }
.pill-brand { background: #e6edf5; color: var(--brand); }

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--muted);
}
.dev-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.bulk-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.bulk-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.bulk-row input {
  flex: 1;
  min-width: 220px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  background: var(--surface);
}

.job-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.job-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 13px;
  background: var(--surface-soft);
}
.job-out {
  margin: 8px 0 0;
  background: #101d2e;
  color: #f2eee6;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  max-height: 240px;
}
.job-shot {
  margin-top: 8px;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--line);
  display: block;
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: #101d2e;
  color: #e9d9b5;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  z-index: 90;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 780px) {
  .hero { grid-template-columns: 1fr; }
  .device-grid { grid-template-columns: 1fr; }
}
