/* ============================================================
   farmn dashboard — base styles
   ============================================================ */

/* ── Light mode (default) ──────────────────────────────── */
:root {
  --color-bg:         #f8fafc;
  --color-surface:    #ffffff;
  --color-border:     #e2e8f0;
  --color-text:       #1e293b;
  --color-text-muted: #64748b;
  --color-accent:     #4f46e5;

  --color-online:  #22c55e;
  --color-warning: #f59e0b;
  --color-offline: #ef4444;
  --color-no-data: #64748b;

  --color-hover-bg: rgba(0,0,0,0.04);

  /* Rack-specific — rack bodies always dark regardless of page theme */
  --rack-body-bg:       rgba(13,17,30,0.95);
  --rack-tier-bg:       rgba(15,23,42,0.85);
  --rack-tier-border:   #1e293b;
  --rack-detail-bg:     #f1f5f9;
  --tier-metric-bg:     rgba(248,250,252,0.9);
  --tier-metric-border: rgba(203,213,225,0.8);
  --rack-side-start:    #334155;
  --rack-side-end:      #475569;
  --ghost-rack-bg:      rgba(13,17,30,0.18);
  --rack-tank-label-bg: #374151;

  --radius: 8px;
  --transition: 0.2s ease;
}

/* ── Dark mode ─────────────────────────────────────────── */
html.dark {
  --color-bg:         #0f1117;
  --color-surface:    #1a1d27;
  --color-border:     #2a2d3a;
  --color-text:       #e2e8f0;
  --color-text-muted: #94a3b8;
  --color-accent:     #4f46e5;

  --color-hover-bg: rgba(255,255,255,0.04);

  --rack-body-bg:       rgba(10,12,18,0.96);
  --rack-tier-bg:       rgba(15,23,42,0.8);
  --rack-tier-border:   #1e293b;
  --rack-detail-bg:     #13151e;
  --tier-metric-bg:     rgba(10,12,18,0.7);
  --tier-metric-border: rgba(42,45,58,0.8);
  --rack-side-start:    #334155;
  --rack-side-end:      #475569;
  --ghost-rack-bg:      rgba(10,12,18,0.4);
  --rack-tank-label-bg: #374151;
}

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

html, body {
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--color-accent); text-decoration: none; }

/* ── Layout ─────────────────────────────────────────────── */

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar nav ─────────────────────────────────────────── */

.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 16px 0;
}

.sidebar-logo {
  padding: 12px 16px 16px;
  margin-bottom: 8px;
  display: flex;
  justify-content: center;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  color: var(--color-text);
  border-left: 3px solid transparent;
  transition: color var(--transition), background var(--transition);
  user-select: none;
}

.nav-item:hover {
  color: var(--color-text);
  background: var(--color-hover-bg);
}

.nav-item.active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  background: rgba(79,70,229,0.1);
}

.nav-item .icon { font-size: 18px; width: 20px; text-align: center; }

/* ── 서브 네비 (실시간 개요 하위 항목) ──────────────────────── */
.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px 7px 36px;
  cursor: pointer;
  color: var(--color-text);
  font-size: 12px;
  border-left: 3px solid transparent;
  transition: color var(--transition), background var(--transition);
  user-select: none;
  position: relative;
}

.nav-sub-item::before {
  content: '';
  position: absolute;
  left: 24px;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--color-border);
}

.nav-sub-item:hover {
  color: var(--color-text);
  background: var(--color-hover-bg);
}

.nav-sub-item.active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  background: rgba(79,70,229,0.08);
}

.nav-sub-item .sub-icon { font-size: 14px; width: 16px; text-align: center; }

/* ── Main content ─────────────────────────────────────────── */

.main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
  gap: 16px;
  overflow-x: auto;
}

.topbar-title { display: none; }
.topbar-meta  { display: none; }

/* ── Logo (Plant OS) ─────────────────────────────────────── */
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-logo-icon {
  width: 40px;
  height: 40px;
  background: #4f46e5;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(79,70,229,0.45);
  flex-shrink: 0;
}

.topbar-logo-name {
  font-size: 22px;
  font-weight: 900;
  color: var(--color-text);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

.topbar-logo-sub {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ── Right side: nav group + metric pills ─────────────────── */
.topbar-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* ── 3-뷰 네비게이션 버튼 그룹 ───────────────────────────── */
.topbar-nav {
  display: flex;
  gap: 4px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 5px;
}

.topbar-nav-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.topbar-nav-btn:hover {
  color: var(--color-text);
  background: var(--color-hover-bg);
}

.topbar-nav-btn.active {
  background: var(--color-accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,0.4);
}

/* ── Topbar metric pills (rack_chart / global_chart 진입 시) */
.topbar-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 5px;
}

.topbar-metric-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.topbar-metric-pill:hover { color: var(--color-text); }

.topbar-metric-pill.active {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ── 우하단 시간 표시 ──────────────────────────────────────── */
.corner-time {
  position: fixed;
  bottom: 10px;
  right: 16px;
  font-size: 11px;
  color: var(--color-text-muted);
  z-index: 50;
  pointer-events: none;
  opacity: 0.7;
}

/* ── 다크/라이트 테마 토글 버튼 ───────────────────────────── */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle-btn:hover {
  color: var(--color-text);
  background: var(--color-hover-bg);
  opacity: 1;
}
.theme-icon-sun  { display: none; }
.theme-icon-moon { display: block; }
html.dark .theme-icon-sun  { display: block; }
html.dark .theme-icon-moon { display: none; }

/* ── Farm& CI 로고 ────────────────────────────────────────── */
/* Light mode: 검정 텍스트-on-흰 배경 */
.sidebar-logo-ci {
  display: block;
  width: 112px;
  height: 44px;
  background-image: url('/img/farmn_ci_white.png');
  background-repeat: no-repeat;
  background-size: contain;
  background-position: center center;
  mix-blend-mode: multiply;   /* 흰 배경을 사이드바에 녹임 */
}
/* Dark mode: 흰 텍스트-on-검정 배경 */
html.dark .sidebar-logo-ci {
  background-image: url('/img/farmn_ci_black.png');
  mix-blend-mode: screen;     /* 검정 배경을 다크 사이드바에 녹임 */
}

.content {
  padding: 24px;
  flex: 1;
}

/* ── Banner (stale / error) ──────────────────────────────── */

.banner {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  min-width: 280px;
  max-width: calc(100vw - 48px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}

.banner.show { display: flex; justify-content: space-between; align-items: center; }
.banner.warn  { background: rgba(245,158,11,0.15); border: 1px solid var(--color-warning); color: var(--color-warning); }
.banner.error { background: rgba(239,68,68,0.15);  border: 1px solid var(--color-offline); color: var(--color-offline); }
.banner-close {
  background: none; border: none; cursor: pointer; padding: 2px;
  color: inherit; opacity: 0.7; line-height: 1; flex-shrink: 0;
}
.banner-close:hover { opacity: 1; }

/* ── Cards ───────────────────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  transition: border-color var(--transition);
}

.card.status-online  { border-left: 3px solid var(--color-online); }
.card.status-warning { border-left: 3px solid var(--color-warning); }
.card.status-offline { border-left: 3px solid var(--color-offline); }
.card.status-no_data { border-left: 3px solid var(--color-no-data); }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card-title { font-weight: 600; font-size: 14px; }
.card-zone  { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.status-dot.online  { background: var(--color-online); }
.status-dot.warning { background: var(--color-warning); }
.status-dot.offline { background: var(--color-offline); }
.status-dot.no_data { background: var(--color-no-data); }

.metric-list { display: flex; flex-direction: column; gap: 6px; }

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-label { color: var(--color-text-muted); font-size: 12px; }
.metric-value { font-size: 15px; font-weight: 600; }
.metric-unit  { font-size: 11px; color: var(--color-text-muted); margin-left: 2px; }

.no-data-msg {
  color: var(--color-text-muted);
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
}

/* ── Chart container ─────────────────────────────────────── */

.chart-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
}

.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 12px; color: var(--color-text-muted); }

.chart-canvas-wrap { position: relative; height: 200px; }

/* ── Table ───────────────────────────────────────────────── */

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

th { color: var(--color-text-muted); font-weight: 500; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--color-hover-bg); }

.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── Status badge ────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
}

.badge.online  { background: rgba(34,197,94,0.15);  color: var(--color-online); }
.badge.warning { background: rgba(245,158,11,0.15); color: var(--color-warning); }
.badge.offline { background: rgba(239,68,68,0.15);  color: var(--color-offline); }
.badge.no_data { background: rgba(100,116,139,0.15);color: var(--color-no-data); }

/* ── Form controls ───────────────────────────────────────── */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 20px;
}

.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 11px; color: var(--color-text-muted); }

input[type="date"],
select {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  padding: 7px 10px;
  font-size: 13px;
  outline: none;
}

input[type="date"]:focus,
select:focus {
  border-color: var(--color-accent);
}

button {
  background: var(--color-accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  transition: opacity var(--transition);
}

button:hover { opacity: 0.85; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button.secondary {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
}

/* ── System status ───────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-label { font-size: 11px; color: var(--color-text-muted); margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-sub   { font-size: 11px; color: var(--color-text-muted); margin-top: 4px; }

.service-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.service-row:last-child { border-bottom: none; }

/* ── Device selector ─────────────────────────────────────── */

.device-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.device-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--radius);
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}

.device-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

/* ── Utility ─────────────────────────────────────────────── */

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  margin-top: 24px;
}

.section-title:first-child { margin-top: 0; }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes chartReveal {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0% 0 0); }
}
#rc-chart-wrap > div,
#gc-chart-wrap > div {
  animation: chartReveal 1.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ── Chart zoom ─────────────────────────────────────────── */
.chart-zoom-sel {
  position: absolute;
  pointer-events: none;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.5);
  border-radius: 3px;
  z-index: 10;
}
.chart-zoom-reset {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 20;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-accent);
  background: var(--color-surface);
  border: 1px solid var(--color-accent);
  border-radius: 5px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.chart-zoom-reset:hover { opacity: 0.8; }

.last-update {
  font-size: 11px;
  color: var(--color-text-muted);
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--color-text-muted);
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 640px) {
  .sidebar { width: 56px; }
  .sidebar-logo, .nav-item span, .nav-sub-item span { display: none; }
  .nav-sub-item { padding-left: 16px; }
  .nav-sub-item::before { display: none; }
  .content { padding: 16px; }
  .card-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   SCADA 전용 스타일
   ============================================================ */

/* ── 전체 레이아웃 ─────────────────────────────────────── */
.scada-wrap { display: flex; flex-direction: column; height: 100%; gap: 16px; }

/* ── Facility Ambient 바 ───────────────────────────────── */
.ambient-bar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
}
.ambient-label { flex-shrink: 0; }
.ambient-title { font-size: 13px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; }
.ambient-sub   { font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }
.ambient-metrics { display: flex; gap: 10px; flex: 1; overflow-x: auto; }
.ambient-metric {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: all 0.25s ease;
  flex: 1;
  min-width: 90px;
}
.ambient-metric-label { font-size: 10px; font-weight: 700; margin-bottom: 4px; }
.ambient-metric-value { font-size: 20px; font-weight: 800; }
.ambient-metric-unit  { font-size: 10px; color: var(--color-text-muted); margin-left: 2px; }

/* ── SCADA 본문 ────────────────────────────────────────── */
.scada-body { flex: 1; display: flex; gap: 20px; min-height: 0; overflow: hidden; }

/* ── 3D 랙 스테이지 ────────────────────────────────────── */
.rack-stage {
  flex: 2;
  position: relative;
  overflow: hidden;
  min-height: 320px;
}
.rack-stage-grid {
  display: none;
}
.rack-stage-glow {
  display: none;
}
/* HUD 장식 요소 */
.rack-hud {
  position: absolute;
  z-index: 2;
  opacity: 0.35;
  pointer-events: none;
  user-select: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}
.rack-hud-tl { font-size: 11px; }
.rack-hud-tl { top: 10px; left: 14px; display: flex; flex-direction: column; gap: 4px; }
.rack-hud-tr { top: 10px; right: 14px; text-align: right; }
.rack-hud-bl { bottom: 8px; left: 14px; display: flex; align-items: center; gap: 5px; }
.rack-hud-row { display: flex; align-items: center; gap: 5px; color: #6366f1; }
.rack-hud-row-end { justify-content: flex-end; }
.rack-hud-bar { display: flex; gap: 3px; margin-top: 3px; }
.rack-hud-bar::before { content:''; width:28px; height:3px; background:#64748b; border-radius:1px; }
.rack-hud-bar::after  { content:''; width:10px; height:3px; background:#475569; border-radius:1px; }

/* 스케일 캔버스 */
.rack-stage-canvas {
  position: absolute;
  width: 1080px;
  height: 780px;
  left: 50%;
  top: 50%;
  margin-left: -540px;
  margin-top: -390px;
  transform-origin: center center;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.rack-stage-items {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 랙 행 (유닛 그룹 + 복도) */
.rack-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  justify-content: flex-end;
}

/* 복도 */
.rack-aisle {
  width: 44px;
  flex-shrink: 0;
  position: relative;
  align-self: stretch;
}
.rack-aisle-line {
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 1px;
  border-left: 1px dashed rgba(100,116,139,0.25);
  transform: perspective(1000px) rotateX(70deg);
  transform-origin: bottom;
}

/* ── 3D 랙 카드 ────────────────────────────────────────── */
.rack-3d {
  cursor: pointer;
  transition: transform 0.75s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.4s ease;
  transform-style: preserve-3d;
  will-change: transform;
}
.rack-3d.inactive {
  transform: perspective(1000px) rotateY(-25deg) rotateX(10deg) scale(0.9);
  opacity: 0.82;
}
.rack-3d.active {
  transform: perspective(1000px) rotateY(-25deg) rotateX(10deg) translateZ(60px) scale(1.1);
  opacity: 1;
  z-index: 10;
}
.rack-3d.inactive:hover {
  opacity: 0.9;
  transform: perspective(1000px) rotateY(-25deg) rotateX(10deg) scale(0.96);
}
/* Ghost 랙 (데이터 미연결) */
.rack-3d.ghost {
  opacity: 0.6;
}
.rack-3d.ghost.inactive { opacity: 0.55; }
.rack-3d.ghost:hover { opacity: 0.8; }
.rack-3d.ghost .rack-3d-body {
  border-style: dashed;
  background: var(--ghost-rack-bg);
}
.rack-3d.ghost .rack-3d-tier::before,
.rack-3d.ghost .rack-3d-tier::after { display: none; }
.rack-3d.ghost .rack-3d-tier {
  background: var(--rack-tier-bg);
  position: relative;
  overflow: hidden;
}
.rack-3d.ghost .rack-3d-tier::before {
  display: block;
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(100,116,139,0.08) 4px,
    rgba(100,116,139,0.08) 5px
  );
}

.rack-3d-body {
  width: 82px;
  height: 168px;
  background: var(--rack-body-bg);
  border: 2px solid #334155;
  border-radius: 8px 8px 3px 3px;
  padding: 8px 6px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.4s, box-shadow 0.4s;
}
.rack-3d-body::before,
.rack-3d-body::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 4px;
  background: linear-gradient(to right, var(--rack-side-start), var(--rack-side-end));
  z-index: 2;
}
.rack-3d-body::before { left: 0;  border-radius: 8px 0 0 3px; }
.rack-3d-body::after  { right: 0; border-radius: 0 8px 3px 0; }
.rack-3d.active .rack-3d-body {
  border-color: #6366f1;
  box-shadow: 0 0 32px rgba(99,102,241,0.65), 0 0 64px rgba(99,102,241,0.18);
}
/* ── 유닛 그룹 ─────────────────────────────────────────── */
.rack-unit-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.rack-unit-label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #64748b;
  opacity: 0.9;
  transform: perspective(1000px) rotateY(-25deg) rotateX(8deg);
  transform-origin: left bottom;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  padding-left: 4px;
}
.rack-unit-racks {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

/* ── 랙 번호 워터마크 ───────────────────────────────────── */
.rack-3d-watermark {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
  pointer-events: none;
}
.rack-3d-watermark span {
  font-size: 82px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.06em;
  transform: translateY(14px);
  user-select: none;
  color: rgba(148,163,184,0.07);
}
.rack-3d.active .rack-3d-watermark span {
  color: rgba(99,102,241,0.14);
}

/* ── 랙 번호 라벨 ───────────────────────────────────────── */
.rack-3d-label {
  background: rgba(15,23,42,0.7);
  border: 1px solid #475569;
  border-radius: 3px;
  padding: 3px 4px;
  text-align: center;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #94a3b8;
  flex-shrink: 0;
  position: relative;
  z-index: 3;
}
.rack-3d.active .rack-3d-label { color: #818cf8; border-color: rgba(99,102,241,0.5); }
.rack-3d-tier {
  flex: 1;
  background: var(--rack-tier-bg);
  border-radius: 2px;
  border-bottom: 2px solid var(--rack-tier-border);
  position: relative;
  overflow: hidden;
  z-index: 3;
}
.rack-3d-tier::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: #ec4899;
  box-shadow: 0 3px 8px rgba(236,72,153,0.7);
}
.rack-3d-tier::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 30%;
  background: rgba(16,185,129,0.35);
}

/* ── 오프라인 오버레이 ──────────────────────────────────── */

/* 배경에 깔리는 dimmed 콘텐츠 래퍼 */
.rack-offline-content {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  opacity: 0.2;
  filter: blur(1.5px) grayscale(50%);
  pointer-events: none;
  user-select: none;
}

/* 절대 위치 오버레이 */
.rack-offline-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(2px);
  border-radius: calc(var(--radius) - 3px);
  border: 2px dashed rgba(100,116,139,0.45);
}
.rack-offline-badge {
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.5);
  color: #f59e0b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.15em;
  padding: 6px 16px;
  border-radius: 6px;
}
.rack-offline-msg {
  font-size: 11px;
  color: var(--color-text-muted);
  margin: 0;
}

/* ── 랙 상세 패널 ──────────────────────────────────────── */
.rack-detail-panel {
  width: 400px;
  flex-shrink: 0;
  overflow-y: auto;
  padding-right: 2px;
}
.rack-detail-card { display: flex; flex-direction: column; }
.rack-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px 10px;
}
.rack-detail-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.rack-detail-body {
  position: relative;
  background: var(--rack-detail-bg);
  border: 3px solid var(--color-border);
  border-radius: var(--radius);
  padding: 8px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

/* ── RACK TANK ─────────────────────────────────────────── */
.rack-tank {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 12px 16px 10px;
  position: relative;
  display: flex;
  justify-content: space-around;
  margin: 0 4px 2px;
}
.rack-tank-label {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--rack-tank-label-bg);
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 3px;
  white-space: nowrap;
}
.rack-tank-metric { display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: all 0.25s ease; }
.rack-tank-key    { font-size: 10px; font-weight: 700; color: var(--color-text-muted); margin-bottom: 3px; }
.rack-tank-value  { font-size: 20px; font-weight: 800; line-height: 1; }
.rack-tank-unit   { font-size: 9px; color: var(--color-text-muted); }

/* ── Tier 카드 ─────────────────────────────────────────── */
.tier-card {
  background: var(--color-surface);
  border-radius: 4px;
  border-bottom: 3px solid var(--color-border);
  padding: 8px 10px;
  position: relative;
  overflow: hidden;
  margin: 0 4px;
}
.tier-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: #ec4899;
  box-shadow: 0 3px 8px rgba(236,72,153,0.5);
}
.tier-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 5px;
  background: rgba(16,185,129,0.45);
}
.tier-label {
  font-size: 9px;
  font-weight: 800;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 5px;
  margin-bottom: 7px;
}
.tier-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tier-metric {
  background: var(--tier-metric-bg);
  border: 1px solid var(--tier-metric-border);
  border-radius: 4px;
  padding: 5px 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.25s ease;
}
.tier-metric:hover { background: var(--color-surface); }
.tier-metric-top    { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.tier-metric-val    { font-size: 13px; font-weight: 800; line-height: 1; }
.tier-metric-bottom { display: flex; justify-content: space-between; align-items: flex-end; }
.tier-metric-key    { font-size: 7px; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tier-metric-sensors{ font-size: 7px; color: rgba(148,163,184,0.5); }

/* ── Metric Focus / Dim ─────────────────────────────── */
.tier-metric.focused,
.ambient-metric.focused,
.rack-tank-metric.focused {
  transform: scale(1.05);
  border-color: #6366f1;
  box-shadow: 0 0 0 1px #6366f1;
  z-index: 1;
  position: relative;
}
.tier-metric.dimmed,
.ambient-metric.dimmed,
.rack-tank-metric.dimmed {
  opacity: 0.3;
  filter: grayscale(80%);
  transform: scale(0.95);
}
.tier-metric.dimmed:hover,
.ambient-metric.dimmed:hover,
.rack-tank-metric.dimmed:hover {
  opacity: 0.75;
  filter: grayscale(20%);
  transform: scale(1);
}

/* ── SCADA Mode Bar ──────────────────────────────────── */
.scada-mode-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px;
  flex-shrink: 0;
}

/* ── Grid Mode ────────────────────────────────────────── */
.grid-mode-wrap {
  display: flex;
  gap: 20px;
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 8px;
  align-items: flex-start;
}

.grid-rack-card {
  min-width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* ── Analysis screens ─────────────────────────────────── */
.analysis-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.metric-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.metric-pill {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: 9999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.metric-pill:hover { color: var(--color-text); border-color: var(--color-text-muted); }

.metric-pill.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.analysis-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.rack-sel-btn {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  border-radius: var(--radius);
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.rack-sel-btn:hover { color: var(--color-text); }
.rack-sel-btn.active {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}

.toggle-group {
  display: flex;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.toggle-btn {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  border-radius: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-btn:hover { color: var(--color-text); }
.toggle-btn.active {
  background: var(--color-accent);
  color: #fff;
}

.analysis-chart-header {
  padding: 0 2px;
}

/* ============================================================
   데이터 분석 화면 공통 (env_explorer / vision_explorer)
   ============================================================ */

.an-screen {
  display: flex;
  flex-direction: column;
  gap: 20px;
  height: 100%;
  padding: 0 0 24px;
}

/* ── 상단 행 (Unit3DMap + 패널) ─────────────────────────── */
.an-top-row {
  display: flex;
  gap: 16px;
  height: 280px;
  flex-shrink: 0;
}

/* ── Unit3DMap ──────────────────────────────────────────── */
.an-map-container {
  flex: 1;
  display: flex;
  background: #0f1117;
  border-radius: 12px;
  border: 1px solid #2a2d3a;
  overflow: hidden;
  min-width: 0;
}

.an-map-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 40px 12px 12px;
}

.an-map-badge {
  position: absolute;
  top: 10px;
  left: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(16,185,129,.15);
  border: 1px solid rgba(16,185,129,.4);
  color: #6ee7b7;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 8px;
  backdrop-filter: blur(4px);
  z-index: 10;
}

.an-map-phase-name {
  color: #fff;
  text-decoration: underline;
}

.an-map-unit-label {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .25em;
  color: #475569;
  pointer-events: none;
}

.an-map-racks {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

/* ── Rack 3D ────────────────────────────────────────────── */
.an-rack-wrap {
  position: relative;
  transform: perspective(800px) rotateY(-20deg) rotateX(8deg);
  transition: transform .3s;
}

.an-rack-wrap:hover { transform: perspective(800px) rotateY(-20deg) rotateX(8deg) translateZ(8px); }

.an-rack-offline { opacity: .5; filter: grayscale(60%); }

.an-rack-body {
  position: relative;
  width: 64px;
  height: 160px;
  background: rgba(10,12,18,.96);
  border: 2px solid #1e293b;
  border-radius: 8px 8px 4px 4px;
  display: flex;
  flex-direction: column;
  padding: 6px 6px 4px;
  gap: 3px;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}

.an-rack-body:hover { border-color: #475569 !important; }

.an-rack-side-l,
.an-rack-side-r {
  position: absolute;
  top: 0; bottom: 0;
  width: 5px;
  border-radius: 8px 0 0 4px;
  z-index: 2;
  pointer-events: none;
}
.an-rack-side-l { left: 0; border-radius: 8px 0 0 4px; }
.an-rack-side-r { right: 0; border-radius: 0 8px 4px 0; }

.an-rack-bg-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  font-weight: 900;
  color: rgba(255,255,255,.04);
  pointer-events: none;
  z-index: 0;
  line-height: 1;
}

.an-rack-header {
  text-align: center;
  font-size: 15px;
  font-weight: 900;
  background: rgba(15,23,42,.9);
  border: 1px solid #1e293b;
  border-radius: 4px;
  padding: 2px 0;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

/* ── Tier ───────────────────────────────────────────────── */
.an-tier {
  flex: 1;
  border-radius: 3px;
  border: 1px solid;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.an-tier-linked {
  background: rgba(15,23,42,.85);
  border-color: #1e293b;
}
.an-tier-linked::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: #ec4899;
  box-shadow: 0 3px 8px rgba(236,72,153,.6);
}
.an-tier-linked::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 30%;
  background: rgba(16,185,129,.4);
}

.an-tier-ghost {
  background: rgba(15,23,42,.2);
  border-color: #475569;
  border-style: dashed;
}

.an-tier-sel {
  background: rgba(16,185,129,.8) !important;
  border-color: #6ee7b7 !important;
  box-shadow: 0 0 12px rgba(16,185,129,.5);
}

.an-tier-lbl {
  font-size: 10px;
  font-weight: 900;
  color: #064e3b;
  position: relative;
  z-index: 2;
}

.an-tier-linked:hover { background: rgba(30,41,59,.9); }

/* ── Map panel (유닛 목록) ──────────────────────────────── */
.an-map-panel {
  width: 120px;
  flex-shrink: 0;
  background: rgba(15,23,42,.8);
  border-left: 1px solid #2a2d3a;
  display: flex;
  flex-direction: column;
}

.an-map-panel-hdr {
  padding: 10px 10px 8px;
  border-bottom: 1px solid #2a2d3a;
  background: rgba(10,12,18,.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.an-map-panel-lbl {
  font-size: 9px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.an-map-panel-cnt {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 16px;
  font-weight: 900;
  color: #fff;
}

.an-map-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #334155;
  flex-shrink: 0;
}
.an-map-dot.on { background: #10b981; box-shadow: 0 0 6px rgba(16,185,129,.6); }

.an-map-panel-nodes {
  font-size: 10px;
  font-weight: 500;
  color: #475569;
}

.an-map-unit-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.an-unit-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #64748b;
  background: rgba(15,23,42,.5);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, color .15s;
  width: 100%;
  text-align: left;
  gap: 4px;
}

.an-unit-btn span { display: flex; align-items: center; gap: 4px; }
.an-unit-btn:hover { background: #1e293b; color: #e2e8f0; }
.an-unit-btn.active { background: rgba(79,70,229,.2); border-color: #6366f1; color: #fff; }

.an-unit-cnt {
  background: rgba(16,185,129,.2);
  color: #10b981;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  min-width: 18px;
  text-align: center;
}

.an-unit-empty { color: #334155; font-size: 10px; }

/* ── 우측 패널 (댓글 / 가이드) ─────────────────────────── */
.an-comment-panel {
  flex: 1;
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.an-panel-hdr {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text);
  flex-shrink: 0;
}

.an-phase-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  background: var(--color-hover-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-muted);
  padding: 2px 7px;
  border-radius: 5px;
}

.an-comment-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.an-comment-sys {
  display: flex;
  justify-content: center;
}
.an-comment-sys span {
  font-size: 10px;
  font-weight: 700;
  color: var(--color-text-muted);
  background: var(--color-hover-bg);
  border: 1px solid var(--color-border);
  padding: 4px 12px;
  border-radius: 20px;
  text-align: center;
}

.an-comment-item { display: flex; flex-direction: column; gap: 3px; }

.an-comment-meta { display: flex; align-items: center; gap: 6px; }

.an-comment-author { font-size: 11px; font-weight: 900; color: var(--color-text); }
.an-comment-ts     { font-size: 10px; color: var(--color-text-muted); }

.an-comment-body {
  font-size: 12px;
  color: var(--color-text);
  background: rgba(99,102,241,.07);
  border: 1px solid rgba(99,102,241,.15);
  padding: 7px 10px;
  border-radius: 0 8px 8px 8px;
}

html.dark .an-comment-body {
  background: rgba(30,27,75,.3);
  border-color: rgba(99,102,241,.2);
}

.an-comment-input-row {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.an-comment-input {
  flex: 1;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--color-text);
  outline: none;
}
.an-comment-input:focus { border-color: var(--color-accent); }

.an-comment-send {
  width: 32px; height: 32px;
  background: var(--color-accent);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.an-comment-send:hover { background: #4338ca; }

/* 비전 가이드 패널 */
.an-vision-guide {
  flex: 1;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--color-text);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  line-height: 1.6;
}

.an-vision-tip {
  background: rgba(245,158,11,.07);
  border: 1px solid rgba(245,158,11,.25);
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
}

html.dark .an-vision-tip {
  background: rgba(120,53,15,.15);
  border-color: rgba(245,158,11,.2);
}

.an-vision-tip strong { color: #b45309; display: block; }
html.dark .an-vision-tip strong { color: #f59e0b; }
.an-vision-tip code {
  background: rgba(245,158,11,.1);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10px;
}

/* ── 스테이지 타임라인 ──────────────────────────────────── */
.an-stages-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  flex: 1;
  padding-bottom: 16px;
}

.an-timeline-item {
  position: relative;
  padding-left: 36px;
}

.an-timeline-item-line::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 28px;
  bottom: -16px;
  width: 2px;
  background: var(--color-border);
}

.an-timeline-dot {
  position: absolute;
  left: 9px;
  top: 18px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  z-index: 1;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.an-timeline-dot:hover {
  transform: scale(1.3);
  border-color: #10b981;
}

.an-timeline-dot.active {
  border-color: #10b981;
  box-shadow: 0 0 10px rgba(16,185,129,.5);
}

/* ── 스테이지 카드 ──────────────────────────────────────── */
.an-stage-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
  transition: border-color .2s, opacity .2s;
}

.an-stage-card.active {
  border-color: #10b981;
  box-shadow: 0 2px 20px rgba(16,185,129,.1);
}

.an-stage-card.inactive {
  opacity: .8;
  cursor: pointer;
}
.an-stage-card.inactive:hover { opacity: 1; border-color: #475569; }

.an-stage-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.an-stage-header.active {
  background: rgba(16,185,129,.04);
  border-color: rgba(16,185,129,.2);
}

html.dark .an-stage-header.active {
  background: rgba(6,78,59,.08);
}

.an-stage-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 220px;
}

.an-active-icon { flex-shrink: 0; animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

.an-stage-name-input {
  font-size: 15px;
  font-weight: 900;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text-muted);
  width: 100%;
  cursor: default;
}

.an-stage-name-input.active {
  color: #059669;
  cursor: text;
}
.an-stage-name-input.active:focus {
  box-shadow: 0 0 0 2px rgba(16,185,129,.3);
  border-radius: 4px;
}
html.dark .an-stage-name-input.active { color: #34d399; }

.an-date-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
}

.an-date-input {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 11px;
  color: var(--color-text);
}
.an-date-input:disabled { opacity: .5; }

.an-date-sep { color: var(--color-text-muted); font-size: 11px; }

/* ── 스테이지 컨트롤 ────────────────────────────────────── */
.an-stage-controls {
  padding: 10px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.an-stage-controls.hidden { display: none; }

.an-ctrl-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.an-ctrl-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.an-ctrl-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  display: flex;
  align-items: center;
  gap: 4px;
}

.an-btn-reset {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 5px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.an-btn-reset:hover { color: #ef4444; border-color: #ef4444; }

.an-metric-pills { display: flex; flex-wrap: wrap; gap: 5px; }

.an-metric-pill {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}

.an-metric-pill.active {
  background: rgba(16,185,129,.12);
  color: #059669;
  border-color: #10b981;
}
html.dark .an-metric-pill.active { color: #34d399; border-color: #34d399; }

/* ── 스테이지 컨텐츠 (차트 + 테이블) ───────────────────── */
.an-stage-content {
  display: flex;
  gap: 12px;
  padding: 12px;
  height: 270px;
}

.an-chart-area {
  flex: 2;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px;
  position: relative;
  min-height: 200px;
}

.an-chart-area canvas { width: 100% !important; height: 100% !important; }

.an-table-area {
  flex: 1;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.an-table-scroll { flex: 1; overflow: auto; }

.an-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  white-space: nowrap;
}

.an-tbl-th-time,
.an-tbl-th {
  padding: 6px 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 2;
}

.an-tbl-th-time {
  position: sticky;
  left: 0;
  z-index: 3;
  box-shadow: 1px 0 0 var(--color-border);
}

.an-tbl-th-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.an-tbl-metric { font-size: 9px; color: var(--color-text-muted); font-weight: 500; }

.an-tbl-row:hover { background: var(--color-hover-bg); }

.an-tbl-td-time {
  padding: 4px 10px;
  font-weight: 600;
  font-size: 10px;
  color: var(--color-text);
  background: var(--color-surface);
  position: sticky;
  left: 0;
  z-index: 1;
  box-shadow: 1px 0 0 var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.an-tbl-td-num {
  padding: 4px 10px;
  text-align: right;
  font-family: monospace;
  font-weight: 700;
  font-size: 11px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border);
}

.an-tbl-unit {
  font-size: 8px;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-left: 2px;
}

/* ── 비전 탐색 plant panel ──────────────────────────────── */
.an-vis-plant-panel {
  flex: 1;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 200px;
  max-width: 300px;
  position: relative;
}

.an-vis-plant-hdr {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.65), transparent);
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,.9);
  z-index: 5;
  pointer-events: none;
  letter-spacing: .08em;
}

.an-vis-plant-body {
  flex: 1;
  overflow-y: auto;
  background: #e2e8f0;
  padding: 8px;
  padding-top: 36px;
}

html.dark .an-vis-plant-body { background: rgba(15,23,42,.5); }

.an-plant-grid { display: grid; gap: 8px; }
.an-plant-grid-1 { grid-template-columns: 1fr; }
.an-plant-grid-2 { grid-template-columns: 1fr 1fr; }

.an-plant-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.an-plant-card-comp {
  background: rgba(245,158,11,.06);
  border-color: rgba(245,158,11,.3);
}
html.dark .an-plant-card-comp { background: rgba(120,53,15,.12); }

.an-plant-card-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.an-plant-label {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
}

.an-plant-cover {
  font-size: 10px;
  font-weight: 900;
  color: var(--color-text);
}

.an-plant-svg { width: 100%; height: 64px; }

/* ── 벤치마킹 select ────────────────────────────────────── */
.an-bench-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.an-bench-select {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--color-text);
  min-width: 220px;
  max-width: 100%;
}

.an-bench-badge {
  font-size: 10px;
  font-weight: 700;
  color: #92400e;
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.3);
  padding: 2px 8px;
  border-radius: 5px;
}
html.dark .an-bench-badge { color: #f59e0b; background: rgba(120,53,15,.2); }

/* ── 공통 유틸 ──────────────────────────────────────────── */
.an-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--color-text-muted);
  font-size: 12px;
  font-weight: 500;
}

/* ── Light mode overrides: 단일 랙 편집기 (overview 3D 색상 기준) ── */
html:not(.dark) .an-map-container {
  background: var(--color-surface);
  border-color: var(--color-border);
}

html:not(.dark) .an-map-badge {
  background: rgba(16,185,129,.08);
  border-color: rgba(16,185,129,.25);
  color: #059669;
}

html:not(.dark) .an-map-phase-name {
  color: #064e3b;
}

html:not(.dark) .an-map-unit-label {
  color: var(--color-text-muted);
}

html:not(.dark) .an-map-panel {
  background: var(--color-bg);
  border-left-color: var(--color-border);
}

html:not(.dark) .an-map-panel-hdr {
  background: var(--color-surface);
  border-bottom-color: var(--color-border);
}

html:not(.dark) .an-map-panel-lbl {
  color: var(--color-text-muted);
}

html:not(.dark) .an-map-panel-cnt {
  color: var(--color-text);
}

html:not(.dark) .an-map-dot {
  background: #cbd5e1;
}

html:not(.dark) .an-map-dot.on {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16,185,129,.4);
}

html:not(.dark) .an-map-panel-nodes {
  color: var(--color-text-muted);
}

html:not(.dark) .an-unit-btn {
  background: var(--color-surface);
  border-color: transparent;
  color: var(--color-text-muted);
}

html:not(.dark) .an-unit-btn:hover {
  background: var(--color-hover-bg);
  color: var(--color-text);
}

html:not(.dark) .an-unit-btn.active {
  background: rgba(79,70,229,.08);
  border-color: rgba(99,102,241,.4);
  color: var(--color-accent);
}

html:not(.dark) .an-unit-cnt {
  background: rgba(16,185,129,.12);
  color: #059669;
}

html:not(.dark) .an-unit-empty {
  color: var(--color-text-muted);
}

