* {
  box-sizing: border-box;
}

:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-muted: #f6f8fa;
  --canvas: #101418;
  --text: #17212b;
  --muted: #607080;
  --line: #d6e0ea;
  --blue: #1769aa;
  --teal: #167c6b;
  --amber: #a96f12;
  --red: #bd3f3f;
  --violet: #6a5acd;
  --shadow: 0 1px 3px rgba(15, 28, 44, 0.08);
  --radius: 8px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", "SUIT", "Noto Sans KR", "Apple SD Gothic Neo", Arial, sans-serif;
}

.shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar,
.section-head,
.control-band,
.card-head,
.status-stack,
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar,
.section-head,
.card-head {
  justify-content: space-between;
}

.topbar {
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
}

.badge.neutral {
  color: #425263;
  background: #edf1f5;
  border-color: #d7e0e8;
}

.badge.good {
  color: #0f5b48;
  background: #e5f4ef;
  border-color: #b7ded1;
}

.badge.bad {
  color: #843030;
  background: #fbe8e8;
  border-color: #efc5c5;
}

.badge.warn {
  color: #76510e;
  background: #fff4dc;
  border-color: #ecd295;
}

.panel,
.control-band,
.metric,
.camera-card,
.node-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.node-panel {
  margin-bottom: 14px;
}

.node-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.alert-stack {
  margin-top: 12px;
}

.alert {
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
}

.alert.success {
  color: #0f5b42;
  background: #e5f4ef;
  border-color: #b7ded1;
}

.alert.error {
  color: #843030;
  background: #fbe8e8;
  border-color: #efc5c5;
}

.node-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.node-card {
  padding: 12px;
  box-shadow: none;
}

.node-card.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(23, 105, 170, 0.12);
}

.node-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.node-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.node-link {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.node-link:hover {
  text-decoration: underline;
}

.node-card label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--text);
  font-size: 14px;
}

.node-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: 18px;
  flex: 0 0 auto;
}

.node-card label span,
.node-meta strong,
.node-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-meta {
  display: grid;
  gap: 3px;
  margin-top: 9px;
}

.node-meta strong {
  font-size: 13px;
}

.node-meta span,
.node-stats {
  color: var(--muted);
  font-size: 12px;
}

.node-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 9px;
}

.node-stats .badge {
  min-height: 22px;
  padding: 3px 7px;
  font-size: 11px;
}

.text-button {
  min-height: 28px;
  margin-top: 10px;
  padding: 0;
  color: var(--red);
  background: transparent;
  border: 0;
  font-size: 12px;
}

.node-actions .text-button {
  min-height: auto;
  margin-top: 0;
}

.control-band {
  flex-wrap: wrap;
  padding: 10px;
  margin-bottom: 16px;
}

.metric {
  min-width: 118px;
  padding: 9px 11px;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 160px;
}

.field.compact {
  min-width: 130px;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select,
input,
button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
}

select,
input {
  background: #fff;
  color: var(--text);
  padding: 0 9px;
}

button {
  padding: 0 12px;
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  font-weight: 700;
  cursor: pointer;
}

button.secondary {
  color: var(--text);
  background: #fff;
  border-color: var(--line);
}

.camera-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
  margin-bottom: 16px;
}

.camera-card {
  overflow: hidden;
}

.card-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}

.card-title {
  min-width: 0;
}

.card-title strong,
.card-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--canvas);
}

.pose-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.card-foot {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.foot-cell {
  min-width: 0;
  padding: 8px 10px;
  background: #fff;
}

.foot-cell span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.foot-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.panel {
  padding: 12px;
}

.logbox {
  min-height: 92px;
  max-height: 220px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #111820;
  color: #dce7f2;
  font-size: 12px;
  line-height: 1.45;
}

.empty {
  grid-column: 1 / -1;
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px dashed #b8c6d4;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  font-weight: 700;
}

.compact-empty {
  min-height: 92px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 28, 44, 0.45);
}

.modal.hidden {
  display: none;
}

.modal-content {
  width: min(520px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 60px rgba(15, 28, 44, 0.24);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.modal-form .field {
  min-width: 0;
}

.modal-footer {
  justify-content: flex-end;
  padding-top: 4px;
}

.icon-button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  color: var(--text);
  background: #fff;
  border-color: var(--line);
  font-size: 20px;
  line-height: 1;
}

@media (max-width: 980px) {
  .node-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .camera-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .card-foot {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .node-list {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
