:root {
  --font-display: 'Gabarito', 'Noto Sans KR', sans-serif;
  --font-body: 'Noto Sans KR', 'Gabarito', sans-serif;
  --bg: #eef4f3;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --surface-muted: #edf4f4;
  --text: #142326;
  --muted: #5e7378;
  --faint: #8ba0a5;
  --border: #c8d9dc;
  --primary: #2196F3;
  --primary-hover: #085e69;
  --success: #1f8f45;
  --success-soft: #dcf3e3;
  --error: #c53a52;
  --error-soft: #f8dde3;
  --unknown: #78878c;
  --unknown-soft: #e7ecee;
  --shadow: 0 24px 70px rgba(23, 45, 50, 0.14);
  --radius-lg: 18px;
  --radius-xl: 26px;
  --radius-pill: 999px;

  /* 장비 마커 표시 영역 — 도면 이미지 기준 퍼센트 좌표 */
  --hotspot-left: 7.5%;
  --hotspot-top: 5.5%;
  --hotspot-width: 50%;
  --hotspot-height: 57%;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 10% 8%, rgba(11, 114, 128, 0.16), transparent 28rem),
    radial-gradient(circle at 90% 6%, rgba(31, 143, 69, 0.1), transparent 24rem),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

img,
svg {
  display: block;
}

:focus-visible {
  outline: 3px solid rgba(11, 114, 128, 0.35);
  outline-offset: 3px;
}

.page {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.map-panel,
.control-panel {
  border: 1px solid rgba(200, 217, 220, 0.8);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 16px 18px;
  border-radius: var(--radius-xl);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  color: var(--primary);
  flex: 0 0 auto;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--font-display);
  font-size: clamp(18px, 1.5vw, 23px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.brand small {
  color: var(--muted);
  font-size: 14px;
}

.status-summary,
.legend {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.summary-chip,
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.summary-chip i,
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.online i,
.legend-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 5px rgba(31, 143, 69, 0.13);
}

.offline i,
.legend-dot.offline {
  background: var(--error);
  box-shadow: 0 0 0 5px rgba(197, 58, 82, 0.13);
}

.unknown i,
.legend-dot.unknown {
  background: var(--unknown);
  box-shadow: 0 0 0 5px rgba(120, 135, 140, 0.13);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 440px);
  gap: 18px;
  align-items: start;
}

.map-panel,
.control-panel {
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.map-panel {
  padding: 18px;
}

.control-panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel-head-control {
  margin-bottom: 14px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--primary);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  letter-spacing: -0.035em;
}

h1 { font-size: clamp(28px, 2.2vw, 38px); }
h2 { font-size: 23px; }
h3 { font-size: 17px; }

.map-stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: #f9fbfb;
  isolation: isolate;
}

.map-canvas {
  position: relative;
  width: 100%;
}

.map-image {
  width: 100%;
  height: auto;
  user-select: none;
}

.hotspot-zone {
  position: absolute;
  left: var(--hotspot-left);
  top: var(--hotspot-top);
  width: var(--hotspot-width);
  height: var(--hotspot-height);
  border: 2px dashed rgba(11, 114, 128, 0.26);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(11, 114, 128, 0.07), rgba(31, 143, 69, 0.04)),
    rgba(255, 255, 255, 0.04);
  pointer-events: none;
  z-index: 2;
}

.hotspot-zone span {
  position: absolute;
  left: 12px;
  top: 10px;
  padding: 5px 9px;
  border: 1px solid rgba(11, 114, 128, 0.22);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.82);
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
}

.markers-layer {
  position: absolute;
  left: var(--hotspot-left);
  top: var(--hotspot-top);
  width: var(--hotspot-width);
  height: var(--hotspot-height);
  z-index: 5;
  pointer-events: none;
}

.device-marker {
  --marker-color: var(--unknown);
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: 44px;
  height: 44px;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #122126;
  pointer-events: auto;
  appearance: none;
  -webkit-appearance: none;
}

.device-marker.online  { --marker-color: var(--success); }
.device-marker.offline { --marker-color: var(--error); }
.device-marker.unknown { --marker-color: var(--unknown); }

.marker-core {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #ffffff 0 30%, var(--marker-color) 31% 56%, rgba(255, 255, 255, 0.94) 57% 100%);
  box-shadow:
    0 14px 32px rgba(17, 32, 36, 0.28),
    0 0 0 9px color-mix(in srgb, var(--marker-color), transparent 80%),
    0 0 34px color-mix(in srgb, var(--marker-color), transparent 38%);
}

.device-marker.unknown .marker-core {
  background:
    radial-gradient(circle at 50% 50%, #f7fafb 0 28%, #8f9da2 29% 56%, #dfe7ea 57% 100%);
  border-color: #b6c3c7;
  box-shadow:
    0 14px 32px rgba(17, 32, 36, 0.22),
    0 0 0 9px rgba(120, 135, 140, 0.2);
}

.device-marker.online .marker-core::before,
.device-marker.offline .marker-core::before {
  content: '';
  position: absolute;
  inset: -9px;
  border: 2px solid var(--marker-color);
  border-radius: inherit;
  animation: blink 1.4s ease-out infinite;
}

.device-marker strong {
  position: relative;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 900;
}

.device-marker small {
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  width: max-content;
  max-width: 170px;
  padding: 5px 10px;
  border: 1px solid rgba(200, 217, 220, 0.86);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(17, 32, 36, 0.16);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.device-marker.unknown small {
  background: #e7ecee;
  border-color: #b6c3c7;
  color: #4d5b60;
}

.map-help {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
}

code {
  padding: 0.1em 0.35em;
  border-radius: 6px;
  background: rgba(11, 114, 128, 0.1);
  color: var(--primary);
  font-family: var(--font-display);
  font-weight: 800;
}

.device-list {
  display: grid;
  gap: 14px;
}

.device-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-muted);
}

.device-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.device-head p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 14px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 900;
}

.status-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.online  { color: var(--success); background: var(--success-soft); }
.status-badge.offline { color: var(--error);   background: var(--error-soft); }
.status-badge.unknown { color: var(--unknown); background: var(--unknown-soft); }

.coordinate-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
}

input::placeholder {
  color: var(--faint);
}

input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(11, 114, 128, 0.14);
  outline: 0;
}

.apply-button {
  min-height: 46px;
  border-radius: 12px;
  background: var(--primary);
  color: #ffffff;
  font-weight: 900;
}

.apply-button:hover {
  background: var(--primary-hover);
}

@keyframes blink {
  0%   { opacity: 0.9; transform: scale(0.76); }
  100% { opacity: 0;   transform: scale(1.38); }
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page {
    padding: 14px;
  }

  .topbar,
  .panel-head,
  .map-help {
    align-items: stretch;
    flex-direction: column;
  }

  .status-summary,
  .legend {
    justify-content: flex-start;
  }

  .map-panel,
  .control-panel {
    padding: 14px;
  }

  .map-stage {
    overflow-x: auto;
  }

  .map-canvas {
    min-width: 760px;
  }
}

@media (max-width: 460px) {
  .coordinate-grid {
    grid-template-columns: 1fr;
  }

  .summary-chip {
    flex: 1 1 auto;
    justify-content: center;
  }

  .device-marker {
    width: 60px;
    height: 60px;
  }

  .marker-core {
    width: 54px;
    height: 54px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}