:root {
  --sg-brand: #1f7a5c;
  --sg-brand-dark: #155640;
  --sg-accent: #d97706;
  --sg-danger: #b42318;
  --sg-info: #2563eb;
  --sg-muted: #667085;
  /* 상단바 공통 폰트 (Tabler/AdminLTE 프레임워크와 무관하게 동일하게 렌더) */
  --sg-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
             "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
}

html {
  margin-inline-start: 0 !important;
}

body {
  letter-spacing: 0;
}

.sg-brand-mark {
  align-items: center;
  background: var(--sg-brand);
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-weight: 700;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.sg-metric-icon {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.sg-metric-icon.good {
  background: #e8f6ef;
  color: var(--sg-brand);
}

.sg-metric-icon.warn {
  background: #fff3dc;
  color: var(--sg-accent);
}

.sg-metric-icon.danger {
  background: #fdecec;
  color: var(--sg-danger);
}

.sg-metric-icon.info {
  background: #eaf1ff;
  color: var(--sg-info);
}

.sg-reading-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.sg-reading-tile {
  border: 1px solid rgba(98, 105, 118, 0.16);
  border-radius: 8px;
  padding: 14px;
}

.sg-reading-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
}

.sg-chart-bars {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(12, 1fr);
  height: 180px;
}

.sg-chart-bars span {
  background: linear-gradient(180deg, #2f80ed 0%, #1f7a5c 100%);
  border-radius: 4px 4px 0 0;
  min-height: 16px;
}

.sg-admin-shell .app-main {
  background: #f5f7fb;
}

.sg-empty-state {
  align-items: center;
  border: 1px dashed rgba(98, 105, 118, 0.35);
  border-radius: 8px;
  color: var(--sg-muted);
  display: flex;
  min-height: 120px;
  justify-content: center;
  text-align: center;
}

.sg-board-title-link {
  display: inline-block;
  max-width: min(720px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.sg-board-content {
  color: #344054;
  font-size: 15px;
  line-height: 1.7;
  min-height: 120px;
  white-space: pre-wrap;
  word-break: break-word;
}

.sg-board-image {
  border: 1px solid rgba(98, 105, 118, 0.16);
  border-radius: 8px;
  display: block;
  max-height: 360px;
  max-width: 100%;
  object-fit: contain;
}

.sg-risk-label {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1;
  padding: 7px 11px;
}

.sg-risk-label.is-normal {
  background: #e8f6ef;
  color: #18794e;
}

.sg-risk-label.is-warning {
  background: #fff4de;
  color: #b45309;
}

.sg-risk-label.is-danger {
  background: #fdecec;
  color: #b42318;
}

.sg-risk-label.is-empty {
  background: #eef1f5;
  color: #667085;
}

.sg-risk-cell.is-normal {
  background: #e8f6ef;
  color: #18794e;
  font-weight: 800;
}

.sg-risk-cell.is-warning {
  background: #fff8e6;
  color: #b45309;
  font-weight: 800;
}

.sg-risk-cell.is-danger {
  background: #fff1f1;
  color: #b42318;
  font-weight: 800;
}

.sg-dashboard-page {
  background: #f4f6fa;
}

.sg-layout-canvas-wrap {
  background: #eef6ff;
  border: 1px solid rgba(37, 99, 235, 0.22);
  border-radius: 8px;
  padding: 16px;
}

.sg-layout-canvas-frame {
  background-color: #fff;
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.13) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 3px solid #1f2937;
  border-radius: 6px;
  height: min(62vh, 560px);
  min-height: 420px;
  overflow: hidden;
  position: relative;
}

.sg-layout-canvas {
  cursor: crosshair;
  display: block;
  height: 100%;
  touch-action: none;
  width: 100%;
}

.sg-layout-canvas:not(canvas) {
  background-color: #fff;
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.13) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 3px solid #1f2937;
  border-radius: 6px;
  height: min(62vh, 560px);
  min-height: 420px;
  overflow: hidden;
  position: relative;
}

.sg-layout-canvas:not(canvas).sg-install-location-canvas {
  height: 320px;
  min-height: 260px;
}

.sg-layout-guide {
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 6px 12px;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.sg-install-location-canvas-frame {
  height: 320px;
  min-height: 260px;
}

.sg-layout-guide-window {
  background: #dbeafe;
  color: #1d4ed8;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
}

.sg-layout-guide-door {
  background: #fef3c7;
  color: #92400e;
  bottom: 10px;
  left: 18px;
}

.sg-layout-sensor-marker {
  align-items: center;
  background: #f97316;
  border: 3px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
  color: #ffffff;
  display: inline-flex;
  font-size: 0.7rem;
  font-weight: 800;
  height: 24px;
  justify-content: center;
  pointer-events: none;
  position: absolute;
  transform: translate(-50%, -50%);
  width: 24px;
  z-index: 6;
}

.sg-layout-sensor-marker span {
  background: rgba(15, 23, 42, 0.78);
  border-radius: 999px;
  color: #ffffff;
  font-size: 0.68rem;
  left: 50%;
  max-width: 132px;
  overflow: hidden;
  padding: 3px 7px;
  position: absolute;
  text-overflow: ellipsis;
  top: 26px;
  transform: translateX(-50%);
  white-space: nowrap;
}

.sg-layout-sensor-marker.is-approved {
  background: #16a34a;
}

.sg-layout-sensor-marker.is-pending {
  background: #f59e0b;
}

.sg-layout-sensor-marker.is-rejected,
.sg-layout-sensor-marker.is-disabled {
  background: #64748b;
}

.sg-layout-object {
  align-items: center;
  border: 2px solid rgba(15, 23, 42, 0.25);
  border-radius: 2px;
  cursor: grab;
  display: inline-flex;
  font-size: 0.75rem;
  font-weight: 800;
  justify-content: center;
  min-height: 24px;
  min-width: 28px;
  overflow: hidden;
  padding: 2px 5px;
  position: absolute;
  text-align: center;
  touch-action: none;
  user-select: none;
  z-index: 3;
}

.sg-layout-object:active {
  cursor: grabbing;
}

.sg-layout-object.is-selected {
  outline: 3px solid rgba(37, 99, 235, 0.42);
  outline-offset: 3px;
  z-index: 4;
}

.sg-layout-wall {
  background: #050505;
  border-color: #050505;
  border-radius: 0;
  box-shadow: none;
  color: transparent;
}

.sg-layout-door {
  background:
    linear-gradient(135deg, transparent 46%, #475569 47%, #475569 52%, transparent 53%),
    #ffffff;
  border-color: #111827;
  color: #111827;
}

.sg-layout-window {
  background: #ffffff;
  border-color: #111827;
  border-left: 0;
  border-right: 0;
  border-radius: 0;
  box-shadow: inset 0 0 0 2px #bfdbfe;
  color: transparent;
}

.sg-layout-bed,
.sg-layout-table,
.sg-layout-kitchen,
.sg-layout-sofa,
.sg-layout-storage,
.sg-layout-toilet {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #334155;
}

.sg-layout-bed {
  background:
    linear-gradient(135deg, transparent 48%, #94a3b8 49%, #94a3b8 51%, transparent 52%),
    linear-gradient(45deg, transparent 48%, #94a3b8 49%, #94a3b8 51%, transparent 52%),
    #ffffff;
}

.sg-layout-table {
  border-radius: 4px;
  overflow: visible;
}

.sg-layout-table::before,
.sg-layout-table::after {
  background: #ffffff;
  border: 1px solid #94a3b8;
  border-radius: 4px;
  content: "";
  height: 42%;
  position: absolute;
  top: 28%;
  width: 18%;
}

.sg-layout-table::before {
  left: -24%;
}

.sg-layout-table::after {
  right: -24%;
}

.sg-layout-kitchen {
  background:
    radial-gradient(circle at 72% 50%, transparent 0 10%, #94a3b8 11% 14%, transparent 15%),
    radial-gradient(circle at 52% 50%, transparent 0 10%, #94a3b8 11% 14%, transparent 15%),
    #ffffff;
}

.sg-layout-sofa {
  background: #eef2ff;
  border-radius: 10px;
}

.sg-layout-storage {
  background: #f8fafc;
}

.sg-layout-toilet {
  background:
    radial-gradient(ellipse at 50% 62%, #ffffff 0 28%, #94a3b8 30% 34%, transparent 35%),
    #f8fafc;
}

.sg-layout-decor {
  background: #ef4444;
  border-color: #ffffff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px #b91c1c;
  color: transparent;
  min-height: 14px;
  min-width: 14px;
}

.sg-layout-sensor {
  background: #dc2626;
  border-color: #ffffff;
  border-radius: 999px;
  box-shadow: 0 0 0 1px #991b1b;
  color: transparent;
  min-height: 14px;
  min-width: 14px;
}

.sg-layout-label {
  background: rgba(255, 255, 255, 0.72);
  border-color: transparent;
  box-shadow: none;
  color: #52525b;
  font-size: 1rem;
  font-weight: 700;
}

.sg-dashboard-shell {
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
  min-height: 100vh;
}

.sg-sensor-rail {
  background: #ffffff;
  border-right: 1px solid rgba(98, 105, 118, 0.16);
  display: flex;
  flex-direction: column;
  gap: 3px;
  height: 100vh;
  overflow: hidden;
  padding: 7px 8px 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.sg-sensor-rail-header {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  grid-template-rows: 36px 28px;
  min-height: 72px;
}

.sg-sensor-rail-header > div:first-of-type {
  grid-column: 2;
  grid-row: 1;
  flex: 1 1 auto;
  min-width: 0;
}

.sg-sensor-rail-actions {
  align-items: center;
  display: flex;
  flex-shrink: 0;
  gap: 6px;
  grid-column: 3;
  grid-row: 1;
}

.sg-rail-menu-button {
  background: #ffffff;
  border-color: rgba(98, 105, 118, 0.22);
  color: #344054;
  font-size: 18px;
  height: 34px;
  min-height: 34px;
  min-width: 34px;
  padding: 0;
  width: 34px;
  grid-column: 1;
  grid-row: 1;
}

.sg-sensor-filter-inline {
  align-content: center;
  color: var(--sg-muted);
  display: grid;
  font-size: 11px;
  grid-column: 1 / 4;
  grid-row: 2;
  grid-template-columns: 1fr;
  grid-template-rows: 14px 14px;
  line-height: 14px;
  margin-top: 0;
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
}

.sg-sensor-filter-inline span {
  min-width: 0;
  overflow: hidden;
}

.sg-sensor-filter-inline span:nth-child(2) {
  display: none;
}

.sg-sensor-filter-inline span:nth-child(3) {
  padding-left: 0;
}

.sg-sensor-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}

.sg-sensor-row {
  align-content: center;
  border-bottom: 1px solid rgba(98, 105, 118, 0.14);
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  flex: 0 0 calc((100vh - 86px) / 13);
  gap: 4px 8px;
  grid-template-columns: 42px minmax(0, 1fr) 64px;
  grid-template-rows: 16px 18px;
  min-height: 0;
  padding: 2px 2px;
  position: relative;
  transition: background-color 0.14s ease;
}

.sg-sensor-row.is-hidden {
  display: none;
}

.sg-sensor-row:first-child {
  border-top: 1px solid rgba(98, 105, 118, 0.14);
}

.sg-sensor-row:hover,
.sg-sensor-row:focus-visible,
.sg-sensor-row.is-active {
  background: #f6f7f9;
}

.sg-sensor-row:focus-visible {
  outline: 2px solid rgba(98, 105, 118, 0.22);
  outline-offset: -2px;
}

.sg-sensor-row::after {
  align-self: center;
  background:
          linear-gradient(135deg, transparent 0 18%, #98a2b3 19% 21%, transparent 22% 38%, #98a2b3 39% 41%, transparent 42% 58%, #98a2b3 59% 61%, transparent 62% 78%, #98a2b3 79% 81%, transparent 82% 100%);
  content: "";
  grid-column: 3;
  grid-row: 1 / 3;
  height: 15px;
  justify-self: end;
  opacity: 0.65;
  width: 60px;
}

.sg-sensor-row:hover::after,
.sg-sensor-row.is-active::after {
  background:
          linear-gradient(135deg, transparent 0 18%, #667085 19% 21%, transparent 22% 38%, #667085 39% 41%, transparent 42% 58%, #667085 59% 61%, transparent 62% 78%, #667085 79% 81%, transparent 82% 100%);
  opacity: 0.82;
}

.sg-sensor-row.is-empty::after {
  display: none;
}

.sg-sensor-main {
  align-items: center;
  display: grid;
  gap: 0 5px;
  grid-column: 1 / 4;
  grid-row: 1;
  grid-template-columns: 42px minmax(0, max-content) auto 64px;
  min-width: 0;
}

.sg-sensor-reading {
  align-items: center;
  display: flex;
  gap: 6px;
  grid-column: 2;
  grid-row: 2;
  justify-content: flex-start;
  min-width: 0;
}

.sg-sensor-icon {
  align-items: center;
  background: transparent;
  border-radius: 0;
  color: #344054;
  display: inline-flex;
  font-size: 29px;
  font-weight: 700;
  height: 38px;
  justify-content: center;
  left: 2px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
}

.sg-sensor-row:hover .sg-sensor-icon,
.sg-sensor-row.is-active .sg-sensor-icon {
  background: transparent;
}

.sg-sensor-row[data-metric="TEMPERATURE"] .sg-sensor-icon,
.sg-sensor-row[data-metric="PT100_TEMPERATURE_1"] .sg-sensor-icon,
.sg-sensor-row[data-metric="PT100_TEMPERATURE_2"] .sg-sensor-icon,
.sg-sensor-row[data-metric="PT100_TEMPERATURE_3"] .sg-sensor-icon,
.sg-sensor-row[data-metric="NON_CONTACT_TEMPERATURE"] .sg-sensor-icon {
  color: #ef4444;
}

.sg-sensor-row[data-metric="HUMIDITY"] .sg-sensor-icon {
  color: #2563eb;
}

.sg-sensor-row[data-metric="CO2"] .sg-sensor-icon {
  color: #0f766e;
}

.sg-sensor-row[data-metric="VOC"] .sg-sensor-icon {
  color: #7c3aed;
}

.sg-sensor-row[data-metric="PM1_0"] .sg-sensor-icon,
.sg-sensor-row[data-metric="PM2_5"] .sg-sensor-icon,
.sg-sensor-row[data-metric="PM10"] .sg-sensor-icon {
  color: #475569;
}

.sg-sensor-row[data-metric="NOISE_LEVEL"] .sg-sensor-icon {
  color: #f97316;
}

.sg-sensor-row[data-metric="ILLUMINANCE"] .sg-sensor-icon {
  color: #eab308;
}

.sg-sensor-name {
  color: #182230;
  font-size: 12px;
  font-weight: 800;
  grid-column: 2;
  line-height: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-sensor-row:hover .sg-sensor-name,
.sg-sensor-row.is-active .sg-sensor-name {
  color: #101828;
}

.sg-sensor-value {
  color: #101828;
  font-size: 15px;
  font-weight: 600;
  line-height: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-sensor-row.is-empty .sg-sensor-value {
  color: var(--sg-muted);
  font-size: 12px;
  font-weight: 600;
}

.sg-sensor-time {
  color: var(--sg-muted);
  display: none;
  font-size: 11px;
}

.sg-sensor-main > .badge {
  align-self: center;
  font-size: 10px;
  grid-column: 3;
  justify-self: start;
  line-height: 12px;
  max-width: 68px;
  overflow: hidden;
  padding: 1px 5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-sensor-empty-message {
  align-items: center;
  border: 1px dashed rgba(98, 105, 118, 0.24);
  border-radius: 6px;
  color: var(--sg-muted);
  display: flex;
  font-size: 12px;
  font-weight: 600;
  justify-content: center;
  min-height: 74px;
  padding: 12px;
  text-align: center;
}

.sg-dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

/* 대시보드 상단바: 다른 페이지(.sg-topbar)와 동일한 풀폭 바 디자인 */
.sg-dashboard-topbar {
  align-items: center;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  min-height: 64px;
  background: #ffffff;
  border-bottom: 1px solid rgba(98, 105, 118, 0.14);
  padding: 0 clamp(16px, 3vw, 34px);
}

/* 이력 페이지처럼 .container-xl 로 한 번 감싼 경우: 일반 .sg-topbar 페이지와
   동일한 flex 중첩 구조로 맞춰 우측 버튼 세로 위치를 픽셀 단위까지 일치시킨다 */
.sg-dashboard-topbar > .container-xl {
  flex: 1 1 auto;
  min-width: 0;
  max-width: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 0;
}

/* 풀폭 상단바 아래 본문 콘텐츠 공통 여백 (대시보드 카드/이력 카드 공통) */
.sg-dashboard-main > :not(.sg-dashboard-topbar) {
  margin-left: clamp(16px, 3vw, 34px);
  margin-right: clamp(16px, 3vw, 34px);
}
.sg-dashboard-topbar + :not(.sg-dashboard-topbar) {
  margin-top: 20px;
}
.sg-dashboard-main > :not(.sg-dashboard-topbar) + :not(.sg-dashboard-topbar) {
  margin-top: 16px;
}

.sg-dashboard-title {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.sg-dashboard-title h1 {
  font-family: var(--sg-font);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin: 0;
  color: #101828;
}

.sg-dashboard-header-controls {
  align-items: center;
  display: flex;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  gap: 10px;
  justify-content: flex-end;
  min-width: 0;
}

.sg-dashboard-filter-group {
  display: grid;
  gap: 8px;
  flex: 0 1 520px;
  grid-template-columns: 1fr 1fr;
  min-width: 360px;
}

.sg-dashboard-control-meta {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 8px;
  justify-content: flex-end;
  white-space: nowrap;
}

.sg-status-strip {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 8px;
  justify-content: flex-end;
}

.sg-chart-card {
  min-height: 620px;
}

.sg-chart-card .card-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.sg-chart-tabs {
  border-bottom: 1px solid rgba(98, 105, 118, 0.16);
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  overflow-x: auto;
}

.sg-chart-tabs button {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: #475467;
  font-size: 13px;
  font-weight: 700;
  padding: 0 10px 10px;
}

.sg-chart-tabs button.active {
  border-color: var(--sg-info);
  color: var(--sg-info);
}

.sg-chart-placeholder {
  align-items: center;
  border: 1px solid rgba(98, 105, 118, 0.14);
  border-radius: 8px;
  display: flex;
  height: clamp(440px, 58vh, 560px);
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.sg-chart-grid {
  background-image:
          linear-gradient(rgba(98, 105, 118, 0.12) 1px, transparent 1px),
          linear-gradient(90deg, rgba(98, 105, 118, 0.1) 1px, transparent 1px);
  background-size: 100% 62px, 88px 100%;
  inset: 0;
  position: absolute;
}

.sg-chart-empty {
  background: rgba(255, 255, 255, 0.86);
  border: 1px dashed rgba(98, 105, 118, 0.28);
  border-radius: 8px;
  color: var(--sg-muted);
  font-weight: 700;
  padding: 14px 18px;
  position: relative;
}

.sg-dashboard-panels {
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr);
}

.sg-menu-backdrop {
  background: rgba(15, 23, 42, 0.08);
  inset: 0;
  opacity: 0;
  pointer-events: none;
  position: fixed;
  transition: opacity 0.15s ease;
  z-index: 998;
}

.sg-menu-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sg-offcanvas-menu {
  background: #ffffff;
  border-right: 1px solid rgba(98, 105, 118, 0.2);
  box-shadow: 16px 0 28px rgba(15, 23, 42, 0.18);
  height: 100vh;
  left: 0;
  padding: 16px;
  position: fixed;
  top: 0;
  transform: translateX(-105%);
  transition: transform 0.18s ease;
  width: 246px;
  z-index: 999;
}

.sg-offcanvas-menu.is-open {
  transform: translateX(0);
}

.sg-offcanvas-header {
  align-items: center;
  border-bottom: 1px solid rgba(98, 105, 118, 0.16);
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 10px;
}

.sg-offcanvas-links {
  display: grid;
  gap: 4px;
}

.sg-offcanvas-links a,
.sg-offcanvas-links button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #344054;
  display: flex;
  font-size: 14px;
  font-weight: 700;
  min-height: 38px;
  padding: 9px 10px;
  text-align: left;
  text-decoration: none;
  width: 100%;
}

.sg-offcanvas-links a:hover,
.sg-offcanvas-links button:hover,
.sg-offcanvas-links a.active {
  background: #f2f4f7;
  color: #101828;
}

.sg-offcanvas-links form {
  border-top: 1px solid rgba(98, 105, 118, 0.16);
  margin: 8px 0 0;
  padding-top: 8px;
}

/* ===== 카드형 대시보드 (리뉴얼) ===== */
.sg-dashboard-layout {
  display: flex;
  min-height: 100vh;
}

.sg-drawer-layout {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  width: 100%;
}

.sg-drawer-layout > .page-wrapper,
.sg-drawer-layout > .sg-dashboard-main,
.sg-drawer-content {
  flex: 1 1 auto;
  min-width: 0;
}

.sg-drawer-layout > .page-wrapper {
  margin-left: 0;
}

.sg-drawer-content {
  display: flex;
  flex-direction: column;
}

.sg-drawer-content > .app-main {
  flex: 1 1 auto;
  margin-inline-start: 0 !important;
  min-width: 0;
}

.sg-drawer-content > .app-header {
  margin-inline-start: 0 !important;
  position: sticky;
  top: 0;
  z-index: 19;
}

.sg-dashboard-layout .sg-dashboard-main {
  flex: 1 1 auto;
  min-width: 0;
}

/* 사이드바 (아이콘 레일 + 펼치기) */
.sg-sidebar {
  background: #ffffff;
  border-right: 1px solid rgba(98, 105, 118, 0.16);
  /* 프레임워크(Tabler/AdminLTE)와 무관하게 사이드 메뉴 폰트를 동일하게 렌더 */
  font-family: var(--sg-font);
  display: flex;
  flex: 0 0 57px;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: sticky;
  top: 0;
  transition: flex-basis 0.18s ease, width 0.18s ease;
  width: 57px;
  z-index: 20;
}

.sg-drawer-layout.is-sidebar-expanded .sg-sidebar {
  flex-basis: 224px;
  width: 224px;
}

/* 초기 로드 시 펼침 상태 미리 적용 (깜빡임 방지, 애니메이션 없이) */
html.sg-sidebar-init .sg-drawer-layout .sg-sidebar {
  flex-basis: 224px;
  width: 224px;
  transition: none;
}

.sg-sidebar-top {
  display: flex;
  justify-content: flex-end;
  padding: 10px;
}

/* 토글 화살표: 클래스 교체 대신 CSS 회전으로 방향 표시 (깜빡임 방지) */
.sg-sidebar-toggle [data-drawer-toggle-icon] {
  transition: transform 0.18s ease;
}
.sg-drawer-layout.is-sidebar-expanded .sg-sidebar-toggle [data-drawer-toggle-icon],
html.sg-sidebar-init .sg-sidebar-toggle [data-drawer-toggle-icon] {
  transform: rotate(180deg);
}

.sg-sidebar-toggle {
  align-items: center;
  background: #ffffff;
  border: 1px solid rgba(98, 105, 118, 0.22);
  border-radius: 6px;
  color: #344054;
  cursor: pointer;
  display: inline-flex;
  font-size: 18px;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.sg-sidebar-toggle:hover {
  background: #f2f4f7;
}

.sg-sidebar-links {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}

.sg-sidebar-links a,
.sg-sidebar-logout button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: #344054;
  display: flex;
  font-size: 14px;
  font-weight: 700;
  /* 프레임워크별 line-height 상속으로 텍스트가 위/아래로 밀리는 것을 방지 */
  line-height: 1;
  gap: 12px;
  min-height: 42px;
  overflow: hidden;
  padding: 0 11px;
  text-decoration: none;
  white-space: nowrap;
  width: 100%;
}

/* 아이콘은 항상 같은 위치에 고정 (접힐 때 들썩이지 않도록) */
.sg-sidebar-links a i,
.sg-sidebar-logout button i {
  flex: 0 0 22px;
  font-size: 21px;
  text-align: center;
  /* 아이콘 글리프마다 다른 폰트 메트릭으로 1~2px 어긋나는 것을 방지.
     너비와 동일한 짝수(22px) 정사각형으로 두어 행 중앙에 0.5px 오차 없이 정렬되게 한다. */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  line-height: 1;
}

/* 글씨는 사라지지 않고 사이드바 폭이 줄어들면서 잘려나가듯(클리핑) 보이게 함 */
.sg-sidebar-text {
  overflow: hidden;
  text-overflow: clip;
}

.sg-sidebar-links a:hover,
.sg-sidebar-logout button:hover,
.sg-sidebar-links a.active {
  background: #f2f4f7;
  color: #101828;
}

/* 알림 종 배지/상태색: Tabler 전용 유틸(bg-red 등)이 없는 AdminLTE(관리자) 페이지에서도
   동일하게 빨간 배지/상태 점이 보이도록 프레임워크와 무관하게 색을 지정한다. */
#notificationBadge {
  background-color: #d63939 !important;
  color: #fff !important;
}
#notificationList .status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #d63939;
}
#notificationList .status-dot.bg-red { background-color: #d63939; }
#notificationList .status-dot.bg-yellow { background-color: #f59f00; }
#notificationList .status-dot.bg-secondary { background-color: #adb5bd; }
#notificationList .bg-blue-lt { background-color: #e7f1ff; color: #1d6fdb; }
#notificationList .bg-secondary-lt { background-color: #eef0f2; color: #6c757d; }

.sg-sidebar-logout {
  border-top: 1px solid rgba(98, 105, 118, 0.16);
  margin-top: 6px;
  padding-top: 6px;
}

.sg-sidebar-section {
  border-top: 1px solid rgba(98, 105, 118, 0.16);
  color: #667085;
  font-size: 11px;
  font-weight: 800;
  /* 프레임워크별 상속 line-height로 라벨 높이가 달라져(29.7px vs 30.5px)
     아래 관리자 메뉴 전체가 밀려나는 것을 방지하기 위해 고정한다. */
  line-height: 16px;
  letter-spacing: 0.04em;
  margin-top: 6px;
  overflow: hidden;
  padding: 10px 11px 3px;
  text-transform: uppercase;
  white-space: nowrap;
}

/* 사이드바가 접혀 있을 때만 '관리자' 섹션 라벨 왼쪽 패딩 조절
   (펼침 상태 및 초기 로드 깜빡임 방지 init 상태에는 영향 없음)
   - 아이콘(왼쪽 11px 시작)과 정렬하려면 16~18px 권장 */
html:not(.sg-sidebar-init) .sg-drawer-layout:not(.is-sidebar-expanded) .sg-sidebar-section {
  padding-left: 5px;
}

.sg-sidebar-auth {
  display: contents;
}

/* ===== 공개 페이지 상단 내비 (사이드바 없이 가운데 메뉴 하이라이트+밑줄) ===== */
.sg-pubnav {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid rgba(98, 105, 118, 0.14);
}
.sg-pubnav-inner {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 64px; padding: 0 clamp(16px, 3vw, 34px);
}
.sg-pubnav-logo {
  justify-self: start; display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--sg-font); font-weight: 700; font-size: 1.18rem;
  letter-spacing: -0.02em; color: #101828; text-decoration: none; white-space: nowrap;
}
.sg-pubnav-logo:hover, .sg-pubnav-logo:focus { color: #101828; text-decoration: none; }
.sg-pubnav-logo b { font-weight: 900; }
.sg-pubnav-logo .mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px; color: #fff; font-size: 1.05rem;
  background: linear-gradient(135deg, #2f63e6 0%, #4f86ff 100%);
}
.sg-pubnav-menu { justify-self: center; display: flex; align-items: center; gap: clamp(14px, 2.6vw, 38px); }
.sg-pubnav-menu a {
  font-family: var(--sg-font); color: #475467; font-weight: 600; font-size: 0.95rem;
  text-decoration: none; padding: 6px 4px; border-bottom: 2px solid transparent;
  transition: color .14s ease, border-color .14s ease; white-space: nowrap;
}
.sg-pubnav-menu a:hover { color: #2f63e6; border-bottom-color: #2f63e6; }
.sg-pubnav-menu a.active { color: #2f63e6; border-bottom-color: #2f63e6; }
.sg-pubnav .sg-topbar-actions { justify-self: end; }

@media (max-width: 820px) {
  .sg-pubnav-menu { display: none; }
}

/* ===== 임계값 변경 이력 ===== */
.sg-history-main {
  max-width: 100%;
}

.sg-history-filter-card,
.sg-history-card {
  margin: 0;
}

.sg-history-filter-card {
  border: 1px solid rgba(98, 105, 118, 0.14);
  margin-bottom: 14px;
}

.sg-history-card {
  border: 1px solid rgba(98, 105, 118, 0.14);
  overflow: hidden;
}

.sg-history-filter {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
}

.sg-history-filter--admin {
  grid-template-columns:
    minmax(180px, 1.05fr)
    minmax(160px, 1fr)
    minmax(170px, 1fr)
    minmax(170px, 1fr)
    minmax(170px, 1fr)
    auto;
}

.sg-history-filter--user {
  grid-template-columns:
    minmax(180px, 1fr)
    minmax(180px, 1fr)
    minmax(170px, 1fr)
    minmax(170px, 1fr)
    auto;
}

.sg-history-field {
  min-width: 0;
}

.sg-history-field .form-label {
  color: #344054;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
}

.sg-history-combo {
  position: relative;
}

.sg-history-combo-input {
  padding-right: 38px;
}

.sg-history-combo-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  color: #667085;
  display: flex;
  height: 100%;
  justify-content: center;
  padding: 0;
  position: absolute;
  right: 0;
  top: 0;
  width: 38px;
}

.sg-history-combo-toggle:hover,
.sg-history-combo-toggle:focus-visible {
  color: #1f2937;
}

.sg-history-combo-toggle:focus-visible {
  outline: 2px solid rgba(32, 107, 196, 0.24);
  outline-offset: -3px;
}

/* 직접 그리는 콤보박스 드롭다운 (네이티브 datalist 대체) */
.sg-combo-menu {
  background: #ffffff;
  border: 1px solid #dfe4ec;
  border-radius: 9px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.12);
  display: none;
  left: 0;
  list-style: none;
  margin: 4px 0 0;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 1000;
}

.sg-combo-menu.is-open {
  display: block;
}

.sg-combo-option {
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 7px 10px;
}

.sg-combo-option:hover,
.sg-combo-option.is-active {
  background: #eef2f7;
}

.sg-combo-option-primary {
  color: #1f2937;
  font-size: 13px;
  font-weight: 700;
}

.sg-combo-option-meta {
  color: #667085;
  font-size: 12px;
}

.sg-combo-empty {
  color: #98a2b3;
  font-size: 13px;
  padding: 10px;
  text-align: center;
}

.sg-history-actions {
  align-self: end;
  display: flex;
  gap: 8px;
  justify-content: flex-start;
  white-space: nowrap;
}

.sg-history-actions .btn {
  min-height: 38px;
}

.sg-history-card-header,
.sg-history-footer {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.sg-history-card-header {
  background: #ffffff;
  min-height: 62px;
}

.sg-history-card-header > div {
  min-width: 0;
}

.sg-history-page-size {
  margin-left: auto;
  width: 105px;
}

.sg-history-table {
  margin-bottom: 0;
  min-width: 1480px;
}

.sg-history-table th {
  background: #f8fafc;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.sg-history-table tbody tr:hover > td {
  background: #f9fafb;
}

.sg-history-table td {
  vertical-align: middle;
}

.sg-history-col-date {
  width: 220px;
}

.sg-history-col-member {
  width: 260px;
}

.sg-history-col-place {
  width: 240px;
}

.sg-history-col-sensor {
  width: 310px;
}

.sg-history-col-change {
  width: clamp(560px, 38vw, 680px);
}

.sg-history-date-cell {
  white-space: nowrap;
}

.sg-history-info {
  align-items: center;
  display: inline-flex;
  gap: 7px;
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
}

.sg-history-info-primary {
  color: #101828;
  font-weight: 800;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sg-history-info-meta {
  background: #ffffff;
  border: 1px solid rgba(152, 162, 179, 0.28);
  border-radius: 6px;
  color: #475467;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  max-width: 160px;
  overflow: hidden;
  padding: 3px 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-history-change {
  min-width: 0;
  overflow-x: auto;
  vertical-align: middle;
}

.sg-history-change-list {
  font-variant-numeric: tabular-nums;
  min-width: max-content;
  max-width: 100%;
  width: 100%;
}

.sg-history-change-row {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: flex-start;
  min-height: 30px;
  min-width: max-content;
  max-width: 100%;
  width: 100%;
}

.sg-history-change-segments {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 16px;
}

.sg-history-change-badges {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 8px;
  margin-left: auto;
}

.sg-history-change-segment {
  align-items: center;
  background: #f8fafc;
  border: 1px solid rgba(152, 162, 179, 0.2);
  border-radius: 7px;
  display: grid;
  flex: 0 0 auto;
  gap: 5px;
  grid-template-columns: 34px 72px 12px 72px 10px 64px;
  padding: 3px 7px;
}

.sg-history-change-segment.is-danger,
.sg-history-change-segment.is-upper {
  background: #fff8f7;
  border-color: rgba(180, 35, 24, 0.14);
}

.sg-history-change-segment.is-warning,
.sg-history-change-segment.is-lower {
  background: #fffbf2;
  border-color: rgba(217, 119, 6, 0.16);
}

.sg-history-change-label {
  align-items: center;
  background: #ffffff;
  border: 1px solid rgba(152, 162, 179, 0.28);
  border-radius: 5px;
  color: #475467;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  justify-content: center;
  min-height: 22px;
  padding: 1px 5px;
}

.sg-history-bound {
  align-items: center;
  background: #ffffff;
  border: 1px solid rgba(152, 162, 179, 0.24);
  border-radius: 6px;
  color: #182230;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  justify-content: flex-end;
  max-width: 100%;
  min-height: 22px;
  min-width: 0;
  overflow: hidden;
  padding: 1px 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-history-bound.is-before {
  color: #475467;
}

.sg-history-bound.is-after {
  background: #eef6ff;
  border-color: rgba(32, 107, 196, 0.22);
  color: #0f4a8a;
}

.sg-history-change-arrow {
  color: #98a2b3;
  font-size: 15px;
  justify-self: center;
}

.sg-history-delta {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  grid-column: 6;
  justify-content: center;
  justify-self: end;
  max-width: 100%;
  min-height: 22px;
  min-width: 64px;
  overflow: hidden;
  padding: 1px 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-history-delta.is-up {
  background: #eef6ff;
  color: #0f4a8a;
}

.sg-history-delta.is-down {
  background: #fef3f2;
  color: #b42318;
}

.sg-history-delta.is-neutral {
  background: #f2f4f7;
  color: #667085;
}

.sg-history-change-summary {
  align-items: center;
  background: #ffffff;
  border: 1px solid rgba(152, 162, 179, 0.28);
  border-radius: 999px;
  color: #475467;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  justify-content: center;
  min-height: 24px;
  min-width: 76px;
  padding: 2px 10px;
  white-space: nowrap;
}

.sg-history-change-summary.is-up {
  background: #eef6ff;
  border-color: rgba(32, 107, 196, 0.18);
  color: #0f4a8a;
}

.sg-history-change-summary.is-down {
  background: #fef3f2;
  border-color: rgba(180, 35, 24, 0.14);
  color: #b42318;
}

.sg-history-change-summary.is-mixed {
  background: #fff7ed;
  border-color: rgba(217, 119, 6, 0.18);
  color: #b45309;
}

@media (max-width: 1200px) {
  .sg-history-filter {
    align-items: stretch;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .sg-history-actions {
    align-items: end;
    grid-column: 1 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 768px) {
  .sg-history-filter {
    grid-template-columns: 1fr;
  }

  .sg-history-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .sg-history-actions .btn {
    flex: 0 1 auto;
    min-width: 96px;
  }

  .sg-history-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .sg-history-col-change {
    width: 430px;
  }

  .sg-history-change-segment {
    grid-template-columns: 32px 68px 12px 68px 8px 60px;
  }
}

/* 장소 카드: 가로 스크롤 (줄바꿈 대신) */
.sg-place-grid {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.sg-place-card {
  flex: 0 0 320px;
  max-width: 320px;
}

.sg-place-measured {
  margin-top: 2px;
}

.sg-place-card {
  display: flex;
  flex-direction: column;
  margin: 0;
  overflow: hidden;
}

.sg-place-card-header {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.sg-place-card-title {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.sg-place-card-heading {
  min-width: 0;
}

.sg-place-name {
  color: #182230;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-place-status-dot {
  border-radius: 50%;
  flex-shrink: 0;
  height: 12px;
  width: 12px;
}

.sg-place-status-dot.is-normal {
  background: #2fb344;
}

.sg-place-status-dot.is-warning {
  background: #f59f00;
}

.sg-place-status-dot.is-danger {
  background: #d63939;
  box-shadow: 0 0 0 4px rgba(214, 57, 57, 0.18);
}

.sg-place-status-dot.is-empty {
  background: #adb5bd;
}

.sg-place-card-body {
  display: flex;
  flex-direction: column;
}

.sg-pcard-sensor {
  align-items: center;
  border-bottom: 1px solid rgba(98, 105, 118, 0.12);
  display: grid;
  gap: 0 10px;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  padding: 8px 14px;
}

.sg-pcard-sensor:last-child {
  border-bottom: 0;
}

.sg-pcard-icon {
  align-items: center;
  display: inline-flex;
  font-size: 22px;
  grid-column: 1;
  grid-row: 1 / 3;
  justify-content: center;
}

.sg-pcard-name {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  grid-column: 2;
  grid-row: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-pcard-sensor .badge {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.sg-pcard-value {
  color: #101828;
  font-size: 15px;
  font-weight: 600;
  grid-column: 2 / 4;
  grid-row: 2;
}

.sg-pcard-empty {
  color: var(--sg-muted);
  font-size: 13px;
  padding: 20px 14px;
  text-align: center;
}

.sg-place-empty {
  align-items: center;
  color: var(--sg-muted);
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  justify-content: center;
  padding: 60px 20px;
}

.sg-place-empty i {
  font-size: 38px;
}

/* ===== 상세 다이얼로그 ===== */
.sg-detail-layout {
  align-items: stretch;
  display: grid;
  gap: 16px;
  grid-template-columns: 300px minmax(0, 1fr);
}

.sg-detail-sensor-list {
  border: 1px solid rgba(98, 105, 118, 0.16);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sg-detail-sensor {
  align-items: center;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(98, 105, 118, 0.12);
  cursor: pointer;
  display: grid;
  gap: 0 8px;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  padding: 8px 12px;
  text-align: left;
  transition: background-color 0.14s ease;
}

.sg-detail-sensor:last-child {
  border-bottom: 0;
}

.sg-detail-sensor:hover {
  background: #f6f7f9;
}

.sg-detail-sensor.is-active {
  background: #eef4ff;
  box-shadow: inset 3px 0 0 var(--sg-info);
}

.sg-detail-sensor .sg-pcard-icon {
  grid-column: 1;
  grid-row: 1 / 3;
  font-size: 20px;
}

.sg-detail-sensor-name {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  grid-column: 2;
  grid-row: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-detail-sensor .badge {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
}

.sg-detail-sensor-value {
  color: #101828;
  font-size: 14px;
  font-weight: 600;
  grid-column: 2 / 4;
  grid-row: 2;
}

/* 센서 수가 적을 때 마지막 항목 아래 남는 공간은 빈 여백으로 둔다 */
.sg-detail-sensor-filler {
  flex: 1 1 auto;
  min-height: 0;
}

.sg-detail-chart-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sg-detail-chart-header {
  align-items: baseline;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 12px;
}

.sg-detail-chart-header strong {
  font-size: 16px;
}

.sg-detail-range {
  align-self: center;
  width: auto;
  min-width: 120px;
  flex: 0 0 auto;
}

.sg-detail-chart-canvas-wrap {
  align-items: center;
  display: flex;
  flex: 1 1 auto;
  justify-content: center;
  min-height: 620px;
  position: relative;
}

.sg-detail-chart-canvas-wrap canvas {
  cursor: grab;
  max-height: 100%;
  user-select: none;
}

.sg-detail-chart-canvas-wrap canvas:active {
  cursor: grabbing;
}

.sg-detail-chart-empty {
  color: var(--sg-muted);
  font-weight: 600;
  position: absolute;
}

/* ===== 자체 구현 모달 ===== */
.sg-modal {
  align-items: center;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 1050;
}

.sg-modal[hidden] {
  display: none;
}

.sg-modal-backdrop {
  background: rgba(15, 23, 42, 0.45);
  inset: 0;
  position: absolute;
}

.sg-modal-dialog {
  max-width: 1700px;
  position: relative;
  width: 96vw;
}

.sg-modal-content {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.28);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  overflow: hidden;
}

.sg-modal-header {
  align-items: flex-start;
  border-bottom: 1px solid rgba(98, 105, 118, 0.16);
  display: flex;
  justify-content: space-between;
  padding: 16px 20px;
}

.sg-modal-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
}

.sg-modal-body {
  overflow-y: auto;
  padding: 18px 20px;
}

body.sg-modal-open {
  overflow: hidden;
}

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

  .sg-detail-sensor-list {
    max-height: 220px;
  }
}

@media (max-width: 992px) {
  .sg-dashboard-shell {
    grid-template-columns: 1fr;
  }

  .sg-sensor-rail {
    height: auto;
    max-height: none;
    position: static;
  }

  .sg-dashboard-panels {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sg-dashboard-main {
    padding: 0 0 24px;
  }

  .sg-dashboard-topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px clamp(16px, 3vw, 34px);
  }

  .sg-dashboard-header-controls {
    align-items: stretch;
    flex-direction: column;
    justify-content: stretch;
  }

  .sg-dashboard-filter-group {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .sg-dashboard-control-meta {
    justify-content: flex-start;
  }
}

/* ===== 임계값 설정 ===== */
html:has(body.sg-threshold-page) {
  scrollbar-gutter: stable;
}

.sg-threshold-page .page-wrapper > header .container-xl {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
  width: 100%;
}

.sg-threshold-page .page-body > .container-xl {
  max-width: 100%;
  padding-left: clamp(14px, 2vw, 30px);
  padding-right: clamp(14px, 2vw, 30px);
}

.sg-threshold-card {
  background: #ffffff;
  border: 1px solid #e7ebf2;
  border-radius: 18px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.sg-threshold-header {
  align-items: flex-start;
  display: flex;
  padding: clamp(20px, 2.2vw, 30px) clamp(18px, 2.4vw, 34px)
    clamp(18px, 1.8vw, 24px);
}

.sg-threshold-eyebrow {
  color: #2563eb;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin-bottom: 5px;
}

.sg-threshold-title {
  color: #172033;
  font-size: clamp(21px, 1.7vw, 26px);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin: 0;
}

.sg-threshold-description {
  color: #667085;
  font-size: clamp(12px, 1vw, 14px);
  margin: 7px 0 0;
}

.sg-threshold-edit-all {
  border-radius: 9px;
  font-weight: 700;
  min-width: 112px;
  white-space: nowrap;
}

.sg-threshold-place-panel {
  align-items: center;
  background: #f7f9fc;
  border: 1px solid #e7ebf2;
  border-radius: 14px;
  display: grid;
  gap: clamp(10px, 1.2vw, 16px);
  grid-template-columns: 42px minmax(280px, 1fr) auto;
  margin: 0 clamp(18px, 2.4vw, 34px) clamp(18px, 1.8vw, 24px);
  padding: clamp(13px, 1.3vw, 17px) clamp(14px, 1.5vw, 20px);
}

.sg-threshold-place-icon {
  align-items: center;
  background: #e8f0ff;
  border-radius: 11px;
  color: #2563eb;
  display: flex;
  font-size: 21px;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.sg-threshold-place-field .form-label {
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 5px;
}

.sg-threshold-place-field .form-select {
  background-color: #ffffff;
  border-color: #dfe4ec;
  border-radius: 9px;
  min-height: 42px;
}

.sg-threshold-place-meta {
  align-items: center;
  display: flex;
  flex-direction: column;
  min-width: 92px;
}

.sg-threshold-place-meta span {
  color: #2563eb;
  font-size: 14px;
  font-weight: 800;
}

.sg-threshold-place-meta small {
  color: #98a2b3;
  font-size: 11px;
  margin-top: 3px;
}

.sg-threshold-place-actions {
  align-items: center;
  align-self: end;
  display: flex;
  gap: clamp(8px, 1vw, 14px);
  justify-content: flex-end;
}

.sg-threshold-table-wrap {
  border-top: 1px solid #edf0f5;
  overflow-x: auto;
}

.sg-threshold-table {
  table-layout: fixed;
  margin: 0;
  min-width: min(980px, 100%);
  width: 100%;
}

.sg-threshold-col-item {
  width: 11%;
}

.sg-threshold-col-sensor {
  width: 19%;
}

.sg-threshold-col-type {
  width: 9%;
}

.sg-threshold-col-value {
  width: 10%;
}

.sg-threshold-col-actions {
  width: 21%;
}

.sg-threshold-table thead th {
  background: #fafbfc;
  border-bottom: 1px solid #e7ebf2;
  color: #667085;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  padding: 12px clamp(10px, 1vw, 14px);
  text-transform: uppercase;
  white-space: nowrap;
}

.sg-threshold-row td {
  border-bottom-color: #edf0f5;
  height: 62px;
  padding: 12px clamp(10px, 1vw, 14px);
  transition: background-color 0.15s ease;
  vertical-align: middle;
}

.sg-threshold-row:hover td {
  background: #fbfcfe;
}

.sg-threshold-row.is-editing td {
  background: #f8fbff;
}

.sg-threshold-row.is-reset td {
  background: #fff9ed;
}

.sg-threshold-row.is-reset .sg-threshold-item-name {
  color: #b54708;
}

.sg-threshold-item-name {
  color: #1d2939;
  font-size: 13px;
  white-space: nowrap;
}

.sg-threshold-sensor {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.sg-threshold-sensor strong {
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-threshold-sensor span {
  color: #98a2b3;
  font-size: 11px;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sg-threshold-type {
  border-radius: 999px;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  justify-content: center;
  min-width: 54px;
  padding: 5px 9px;
}

.sg-threshold-type.is-range {
  background: #ecfdf3;
  color: #027a48;
}

.sg-threshold-type.is-level {
  background: #fff7e6;
  color: #b54708;
}

.sg-threshold-value {
  color: #344054;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.sg-threshold-value.is-disabled {
  color: #c0c6d0;
  font-weight: 500;
}

.sg-threshold-input {
  border-color: #b8cdf8;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  margin: 0 auto;
  max-width: clamp(78px, 7vw, 112px);
  height: 36px;
  min-width: 0;
  text-align: right;
  width: 100%;
}

.sg-threshold-input-cell {
  padding-left: 12px !important;
  padding-right: 12px !important;
  text-align: center;
}

.sg-threshold-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.sg-threshold-reset {
  border-color: #d7dce5;
  border-radius: 8px;
  color: #667085;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.sg-threshold-row-actions {
  align-items: center;
  display: inline-flex;
  gap: 5px;
  justify-content: center;
  white-space: nowrap;
}

.sg-threshold-actions-cell {
  text-align: center;
}

.sg-threshold-edit,
.sg-threshold-save-one,
.sg-threshold-cancel-one {
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.sg-threshold-row-actions .btn {
  height: 32px;
  min-width: 62px;
}

.sg-threshold-reset:hover {
  background: #fff7e6;
  border-color: #f5c46b;
  color: #b54708;
}

.sg-threshold-group-row td {
  background: #f1f5fb;
  border-bottom: 1px solid #dfe6f1;
  color: #344054;
  height: 38px;
  padding: 8px 14px;
}

.sg-threshold-group-label {
  align-items: center;
  display: flex;
  gap: 7px;
}

.sg-threshold-group-label i {
  color: #2563eb;
  font-size: 15px;
}

.sg-threshold-group-label span {
  font-size: 12px;
  font-weight: 800;
}

.sg-threshold-group-label small {
  color: #7c8799;
  font-size: 11px;
  margin-left: 2px;
}

.sg-threshold-empty {
  color: #98a2b3;
  padding: 54px 20px !important;
  text-align: center;
}

.sg-threshold-empty i {
  display: block;
  font-size: 28px;
  margin-bottom: 8px;
}

.sg-threshold-savebar {
  align-items: center;
  background: #172033;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  bottom: 0;
  box-shadow: 0 -12px 30px rgba(15, 23, 42, 0.18);
  color: #ffffff;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  left: 57px;
  padding: 14px clamp(18px, 2.4vw, 34px);
  position: fixed;
  right: 0;
  transition: left 0.18s ease;
  z-index: 30;
}

.sg-threshold-savebar[hidden] {
  display: none;
}

.sg-drawer-layout.is-sidebar-expanded .sg-threshold-savebar,
html.sg-sidebar-init .sg-drawer-layout .sg-threshold-savebar {
  left: 224px;
}

body.sg-threshold-bulk-editing .page-body {
  padding-bottom: 92px;
}

.sg-threshold-savebar > div:first-child {
  display: flex;
  flex-direction: column;
}

.sg-threshold-savebar strong {
  font-size: 13px;
}

.sg-threshold-savebar span {
  color: #b7c0cf;
  font-size: 11px;
  margin-top: 2px;
}

.sg-threshold-save-actions {
  display: flex;
  gap: 8px;
}

.sg-threshold-save-actions .btn {
  border-radius: 9px;
  font-weight: 700;
  min-width: 92px;
}

@media (max-width: 1200px) {
  .sg-threshold-place-panel {
    grid-template-columns: 42px minmax(220px, 1fr) auto;
  }

  .sg-threshold-place-meta {
    min-width: 78px;
  }

  .sg-threshold-table {
    min-width: 900px;
  }

  .sg-threshold-table thead th,
  .sg-threshold-row td {
    padding-left: 10px;
    padding-right: 10px;
  }

  .sg-threshold-row-actions .btn {
    min-width: 58px;
    padding-left: 8px;
    padding-right: 8px;
  }
}

@media (max-width: 992px) {
  .sg-threshold-card {
    border-radius: 14px;
  }

  .sg-threshold-place-panel {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .sg-threshold-place-actions {
    align-items: center;
    flex-direction: row;
    grid-column: 2;
    justify-content: space-between;
  }

  .sg-threshold-place-meta {
    align-items: flex-start;
    min-width: 0;
  }

  .sg-threshold-edit-all {
    min-width: 104px;
  }

  .sg-threshold-table {
    min-width: 880px;
  }

  .sg-threshold-savebar {
    left: 57px;
  }

  .sg-drawer-layout.is-sidebar-expanded .sg-threshold-savebar,
  html.sg-sidebar-init .sg-drawer-layout .sg-threshold-savebar {
    left: 224px;
  }
}

@media (max-width: 768px) {
  .sg-threshold-page .page-body > .container-xl {
    padding-left: 10px;
    padding-right: 10px;
  }

  .sg-threshold-card {
    border-radius: 12px;
  }

  .sg-threshold-header {
    align-items: stretch;
    flex-direction: column;
    padding: 20px 16px 16px;
  }

  .sg-threshold-place-panel {
    grid-template-columns: 36px minmax(0, 1fr);
    margin: 0 12px 16px;
    padding: 12px;
  }

  .sg-threshold-place-icon {
    border-radius: 9px;
    font-size: 18px;
    height: 36px;
    width: 36px;
  }

  .sg-threshold-place-field .form-select {
    min-height: 40px;
  }

  .sg-threshold-place-meta {
    align-items: flex-start;
  }

  .sg-threshold-place-actions {
    align-items: center;
    flex-direction: row;
    grid-column: 2;
  }

  .sg-threshold-place-panel .sg-threshold-edit-all {
    min-width: 96px;
    width: auto;
  }

  .sg-threshold-table {
    min-width: 840px;
  }

  .sg-threshold-table thead th {
    font-size: 10px;
    padding-bottom: 10px;
    padding-top: 10px;
  }

  .sg-threshold-row td {
    height: 58px;
    padding-bottom: 10px;
    padding-top: 10px;
  }

  .sg-threshold-group-row td {
    height: 36px;
  }

  .sg-threshold-input {
    height: 34px;
  }

  .sg-threshold-savebar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    left: 57px;
    padding: 14px 20px;
  }

  .sg-drawer-layout.is-sidebar-expanded .sg-threshold-savebar,
  html.sg-sidebar-init .sg-drawer-layout .sg-threshold-savebar {
    left: 57px;
  }

  .sg-threshold-save-actions .btn {
    flex: 1 1 0;
  }

  body.sg-threshold-bulk-editing .page-body {
    padding-bottom: 132px;
  }
}

@media (max-width: 480px) {
  .sg-threshold-eyebrow {
    font-size: 10px;
  }

  .sg-threshold-description {
    line-height: 1.5;
  }

  .sg-threshold-place-panel {
    display: block;
  }

  .sg-threshold-place-icon {
    display: none;
  }

  .sg-threshold-place-actions {
    margin-top: 12px;
    width: 100%;
  }

  .sg-threshold-place-panel .sg-threshold-edit-all {
    flex: 0 0 auto;
  }

  .sg-threshold-savebar {
    left: 57px;
    padding: 12px;
  }

  .sg-threshold-savebar span {
    line-height: 1.4;
  }

  .sg-threshold-save-actions {
    width: 100%;
  }
}

/* =========================================================
   공통 상단바 (홈/대시보드/센서/관리자 등 전 페이지 통일)
   - 높이 64px, 우측 액션(환영/벨/마이페이지/로그아웃) 동일 디자인
   ========================================================= */
.sg-topbar {
  min-height: 64px;
  background: #ffffff;
  border-bottom: 1px solid rgba(98, 105, 118, 0.14);
  padding: 0 clamp(16px, 3vw, 34px);
}
.sg-topbar > .container-xl,
.sg-topbar > .container-fluid {
  max-width: none;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-left: 0;
  padding-right: 0;
}
/* 좌측 페이지 제목 (홈은 로고, 나머지 페이지는 제목) — 전 페이지 동일 폰트/크기 */
.sg-topbar .page-title,
.sg-topbar .sg-topbar-title h1,
.sg-topbar .sg-topbar-title h2 {
  margin: 0;
  font-family: var(--sg-font);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #101828;
  line-height: 1.2;
}
.sg-topbar .sg-topbar-title .text-secondary { font-size: 0.78rem; }

/* 상단바 전체 공통 폰트 (좌측 제목 + 우측 환영/마이페이지/로그아웃 버튼까지 동일) */
.sg-topbar,
.sg-dashboard-topbar,
.sg-home-nav,
.sg-topbar-welcome,
.sg-home-welcome,
.sg-home-logo,
.sg-home-menu,
.sg-btn {
  font-family: var(--sg-font);
}

/* 우측 액션 묶음 */
.sg-topbar-actions { display: flex; align-items: center; gap: 10px; }
.sg-topbar-welcome { color: #475467; font-size: 0.9rem; white-space: nowrap; }
.sg-topbar-welcome strong { color: #101828; font-weight: 700; }

/* 공통 버튼 (홈과 동일) */
.sg-btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0;
  font-weight: 700;
  font-size: 0.98rem;
  line-height: 1.2;
  padding: 12px 22px;
  border-radius: 11px;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, border-color .12s ease;
}
.sg-btn-primary { background: #2f63e6; color: #fff; box-shadow: 0 10px 22px -12px rgba(47, 99, 230, 0.85); }
.sg-btn-primary:hover { background: #1d4fcc; color: #fff; transform: translateY(-1px); }
.sg-btn-ghost { background: #fff; color: #344054; border-color: #d0d5dd; }
.sg-btn-ghost:hover { border-color: #2f63e6; color: #fff; background: #2f63e6; text-decoration: none; }
/* 작은 버튼: 높이를 고정해 프레임워크와 무관하게 항상 동일한 높이로 렌더 */
.sg-btn-sm { height: 36px; padding: 0 14px; font-size: 0.875rem; border-radius: 9px; }
.sg-btn-danger { color: #b42318; border-color: #f1aeaa; }
.sg-btn-danger:hover { color: #fff; background: #b42318; border-color: #b42318; }

/* AdminLTE/Tabler 프레임워크 기본값 차이로 생기는 1~2px 정렬·색상 편차 제거 */
.sg-topbar { box-shadow: none; }
.sg-topbar-actions { line-height: 1.2; }
.sg-topbar-welcome { line-height: 1.2; vertical-align: middle; }
.sg-btn { line-height: 1.2; vertical-align: middle; }
.sg-topbar-actions .ti { vertical-align: middle; line-height: 1; }

/* 알림 종: 두 프레임워크에서 동일한 색/높이로 고정 (.nav-link 기본 색 차이 제거) */
.sg-topbar-bell {
  color: #344054 !important;
  line-height: 1 !important;
  min-height: 0 !important;
}
.sg-topbar-bell:hover,
.sg-topbar-bell:focus { color: #2f63e6 !important; }
.sg-topbar-bell .ti { color: inherit; }

/* 버튼 안 아이콘: Tabler 코어가 .ti 에 주는 line-height/정렬을 무력화해
   Tabler 페이지(.sg-dashboard-topbar 포함)와 Admin 페이지의 글자 Y 위치를 일치시킨다 */
.sg-btn .ti {
  line-height: 1;
  vertical-align: middle;
  font-size: 1.05em;
}

/* 상단바 좌측 제목/부제목 색상 통일 (프레임워크 기본 제목색 차이 제거) */
.sg-topbar .page-title,
.sg-topbar .sg-topbar-title h1,
.sg-topbar .sg-topbar-title h2,
.sg-dashboard-title h1 {
  color: #101828;
}
.sg-topbar .sg-topbar-title .text-secondary,
.sg-dashboard-title .text-secondary {
  color: #667085 !important;
}
