* {
  box-sizing: border-box;
}

:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-muted: #f7f9fb;
  --text: #17212b;
  --muted: #617180;
  --line: #d6e0ea;
  --brand: #1769aa;
  --brand-strong: #0e5288;
  --success: #167c5a;
  --danger: #bd3f3f;
  --warning: #a96f12;
  --info: #187a8f;
  --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: 20px;
}

.topbar,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

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

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

.status-stack,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.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: #41505f;
  background: #edf1f5;
  border-color: #d7e0e8;
}

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

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

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

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

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

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

.node-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}

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

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

.node-card input {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

.node-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.control-band {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  grid-column: span 2;
  min-width: 0;
}

.field.wide {
  grid-column: span 4;
}

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

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #c7d3df;
  border-radius: 7px;
  padding: 8px 10px;
  color: var(--text);
  font: inherit;
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid rgba(23, 105, 170, 0.18);
  border-color: var(--brand);
}

.actions {
  grid-column: span 3;
  justify-content: flex-end;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 14px;
  background: var(--brand);
  color: #fff;
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: var(--brand-strong);
}

button.secondary {
  background: #fff;
  border-color: #b8c7d6;
  color: #274056;
}

button.success {
  background: var(--success);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  padding: 14px;
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.metric strong {
  font-size: 22px;
  line-height: 1.25;
}

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

.camera-card {
  overflow: hidden;
}

.camera-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
}

.camera-title {
  font-weight: 800;
}

.camera-preview {
  aspect-ratio: 16 / 9;
  background: #202832;
  display: grid;
  place-items: center;
}

.camera-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.camera-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.stat {
  background: #fff;
  padding: 10px;
  min-width: 0;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.stat strong {
  display: block;
  font-size: 15px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.panel {
  padding: 14px;
  min-width: 0;
}

.section-head.compact {
  margin-bottom: 10px;
}

.edge-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 120px;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 10px 0;
}

.bar {
  height: 8px;
  border-radius: 999px;
  background: #dfe7ef;
  overflow: hidden;
  margin-top: 5px;
}

.bar > span {
  display: block;
  height: 100%;
  background: var(--info);
}

.logbox {
  margin: 0;
  min-height: 178px;
  max-height: 320px;
  overflow: auto;
  background: #111922;
  color: #d7e6f5;
  border-radius: 7px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.55;
}

@media (max-width: 1100px) {
  .control-band {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .field,
  .field.wide,
  .actions,
  .toggle {
    grid-column: span 3;
  }
  .metrics-grid,
  .camera-grid,
  .two-col,
  .node-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 12px;
  }
  .topbar,
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .control-band {
    grid-template-columns: 1fr;
  }
  .field,
  .field.wide,
  .actions,
  .toggle {
    grid-column: span 1;
  }
  .actions button {
    flex: 1 1 100%;
  }
  .camera-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
