/* KiwisIoT Live Anomaly Detection — full-screen dashboard panel */

#anomaly-detection-panel {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: none;
  background: #f8fafc;
}

#anomaly-detection-panel.open {
  display: block;
}

.anomaly-panel-shell {
  position: relative;
  width: 100%;
  height: 100%;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  animation: anomalyFadeIn 0.22s ease-out;
}

@keyframes anomalyFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.anomaly-panel-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  background: linear-gradient(135deg, #ffffff 0%, #f5f3ff 55%, #f8fafc 100%);
  box-shadow: 0 1px 0 rgba(124, 58, 237, 0.06);
}

.anomaly-panel-title {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.anomaly-panel-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.anomaly-panel-icon i {
  font-size: 1.35rem;
  color: #fff;
  line-height: 1;
}

.anomaly-panel-title-text {
  min-width: 0;
}

.anomaly-panel-title h2 {
  font-size: 1.125rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  line-height: 1.25;
}

.anomaly-panel-title p {
  font-size: 0.75rem;
  color: #64748b;
  margin: 0.2rem 0 0;
  line-height: 1.35;
}

.anomaly-panel-header-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.anomaly-panel-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.55rem;
  background: #fff;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.anomaly-panel-close-btn:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.anomaly-phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  white-space: nowrap;
}

.anomaly-phase-badge.idle { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.anomaly-phase-badge.collecting { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.anomaly-phase-badge.training { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.anomaly-phase-badge.detecting { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.anomaly-phase-badge.error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }

.anomaly-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.anomaly-sidebar {
  position: relative;
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
  width: 300px;
  min-width: 300px;
  max-width: 300px;
  border-right: 1px solid #e2e8f0;
  background: #fff;
  overflow: hidden;
  transition: width 0.3s ease, min-width 0.3s ease, max-width 0.3s ease;
}

.anomaly-sidebar-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.anomaly-sidebar-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem 0.65rem;
  border-bottom: 1px solid #f1f5f9;
  background: #fafafa;
  flex-shrink: 0;
}

.anomaly-sidebar-toolbar-text {
  min-width: 0;
}

.anomaly-sidebar-toolbar-text strong {
  display: block;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.25;
}

.anomaly-sidebar-toolbar-text span {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.6875rem;
  color: #64748b;
  line-height: 1.3;
}

.anomaly-sidebar-toggle-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem;
  border: none;
  border-radius: 0.5rem;
  background: #f5f3ff;
  color: #7c3aed;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.anomaly-sidebar-toggle-btn:hover {
  background: #ede9fe;
  color: #6d28d9;
}

.anomaly-sidebar-content {
  flex: 1;
  min-height: 0;
  padding: 1rem;
  overflow-y: auto;
}

.anomaly-sidebar-expand {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 48px;
  min-width: 48px;
  padding-top: 1.25rem;
  flex-shrink: 0;
}

.anomaly-sidebar.anomaly-sidebar-collapsed {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
}

.anomaly-sidebar.anomaly-sidebar-collapsed .anomaly-sidebar-inner {
  display: none;
}

.anomaly-sidebar.anomaly-sidebar-collapsed .anomaly-sidebar-expand {
  display: flex;
}

.anomaly-main {
  flex: 1;
  min-width: 0;
  padding: 1rem 1.25rem 1.25rem;
  overflow-y: auto;
  background: #f8fafc;
}

.anomaly-workflow-card {
  margin-bottom: 1rem;
  padding: 1rem 1.1rem;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, #f5f3ff 0%, #eff6ff 100%);
  border: 1px solid #ddd6fe;
}

.anomaly-workflow-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: #5b21b6;
}

.anomaly-workflow-header i {
  font-size: 1.05rem;
}

.anomaly-workflow-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 1fr;
  gap: 0.65rem;
  width: 100%;
}

.anomaly-workflow-step {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  min-height: 4.5rem;
  padding: 0.7rem 0.75rem;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 0.65rem;
  border: 1px solid rgba(196, 181, 253, 0.5);
  box-shadow: 0 1px 2px rgba(91, 33, 182, 0.05);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.anomaly-workflow-step-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.anomaly-workflow-step-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.25;
}

.anomaly-workflow-step-desc {
  font-size: 0.6875rem;
  line-height: 1.45;
  color: #64748b;
}

.anomaly-workflow-num {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: #e9d5ff;
  color: #6d28d9;
  font-size: 0.6875rem;
  font-weight: 800;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.anomaly-workflow-step.is-active {
  border-color: #a78bfa;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.12), 0 4px 14px rgba(124, 58, 237, 0.1);
}

.anomaly-workflow-step.is-active .anomaly-workflow-num {
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}

.anomaly-workflow-step.is-active .anomaly-workflow-step-title {
  color: #5b21b6;
}

.anomaly-workflow-step.is-done {
  border-color: #bbf7d0;
  background: rgba(255, 255, 255, 0.95);
}

.anomaly-workflow-step.is-done .anomaly-workflow-num {
  background: #059669;
  color: #fff;
}

.anomaly-workflow-step.is-done .anomaly-workflow-step-title {
  color: #047857;
}

@media (max-width: 900px) {
  .anomaly-workflow-steps {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
  }

  .anomaly-workflow-step {
    min-height: 0;
  }
}

.anomaly-control-block {
  margin-bottom: 1rem;
}

.anomaly-control-block > label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin-bottom: 0.4rem;
}

.anomaly-control-block input[type="number"] {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  color: #0f172a;
  background: #fff;
}

.anomaly-control-block input[type="number"]:focus {
  outline: none;
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.anomaly-channel-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 180px;
  overflow-y: auto;
  padding: 0.35rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.65rem;
  background: #fafafa;
}

.anomaly-channel-check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.5rem 0.55rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  border: 1px solid transparent;
}

.anomaly-channel-check:hover {
  background: #f5f3ff;
}

.anomaly-channel-check.is-selected {
  background: #ede9fe;
  border-color: #c4b5fd;
}

.anomaly-channel-check input[type="checkbox"] {
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: #7c3aed;
  width: 0.9rem;
  height: 0.9rem;
  cursor: pointer;
}

.anomaly-channel-check-body {
  min-width: 0;
  flex: 1;
}

.anomaly-channel-check-title {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
}

.anomaly-channel-check-meta {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.625rem;
  color: #64748b;
  line-height: 1.35;
}

.anomaly-channel-monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.anomaly-channel-monitor-grid:empty {
  display: none;
}

.anomaly-channel-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.75rem 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.anomaly-channel-card:hover {
  border-color: #c4b5fd;
}

.anomaly-channel-card.is-focused {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.anomaly-channel-card.is-anomaly {
  border-color: #fca5a5;
  background: linear-gradient(180deg, #fff 0%, #fef2f2 100%);
}

.anomaly-channel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.45rem;
}

.anomaly-channel-card-name {
  font-size: 0.6875rem;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anomaly-channel-card-badge {
  flex-shrink: 0;
  font-size: 0.5625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.4rem;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #64748b;
}

.anomaly-channel-card-badge.ready { background: #ecfdf5; color: #047857; }
.anomaly-channel-card-badge.collecting { background: #eff6ff; color: #1d4ed8; }
.anomaly-channel-card-badge.monitoring { background: #f5f3ff; color: #6d28d9; }
.anomaly-channel-card-badge.anomaly { background: #fef2f2; color: #b91c1c; }

.anomaly-channel-card-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
  margin-bottom: 0.35rem;
}

.anomaly-channel-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  font-size: 0.625rem;
  color: #64748b;
}

.anomaly-channel-card-progress {
  margin-top: 0.45rem;
  height: 0.35rem;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.anomaly-channel-card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #3b82f6);
  border-radius: 9999px;
  transition: width 0.25s ease;
}

.anomaly-chart-focus-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #7c3aed;
  margin-left: 0.35rem;
}

/* Hidden native selects — synced by custom dropdown UI */
.anomaly-native-select {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.anomaly-custom-select {
  position: relative;
  width: 100%;
}

.anomaly-custom-select-grow {
  flex: 1;
  min-width: 0;
}

.anomaly-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.55rem;
  background: #fff;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #0f172a;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.anomaly-select-trigger:hover {
  border-color: #a78bfa;
}

.anomaly-custom-select.open .anomaly-select-trigger {
  border-color: #7c3aed;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

.anomaly-select-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.anomaly-select-caret {
  font-size: 0.875rem;
  color: #94a3b8;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.anomaly-custom-select.open .anomaly-select-caret {
  transform: rotate(180deg);
  color: #7c3aed;
}

.anomaly-select-menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 20;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.65rem;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  max-height: 220px;
  overflow-y: auto;
}

.anomaly-select-option {
  padding: 0.5rem 0.65rem;
  border-radius: 0.45rem;
  font-size: 0.8125rem;
  color: #334155;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.anomaly-select-option:hover {
  background: #f5f3ff;
  color: #5b21b6;
}

.anomaly-select-option.selected {
  background: #ede9fe;
  color: #5b21b6;
  font-weight: 600;
}

.anomaly-colors-block {
  padding: 0.75rem;
  border-radius: 0.65rem;
  background: #fafafa;
  border: 1px solid #e2e8f0;
}

.anomaly-color-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.anomaly-color-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  min-width: 0;
}

.anomaly-color-item span {
  font-size: 0.625rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.3;
}

.anomaly-color-item input[type="color"] {
  width: 100%;
  height: 2rem;
  padding: 0.15rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.45rem;
  background: #fff;
  cursor: pointer;
}

.anomaly-color-actions {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
}

.anomaly-color-reset-btn {
  flex-shrink: 0;
  padding: 0.5rem 0.65rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  border-radius: 0.55rem;
  background: #fff;
  color: #475569;
  cursor: pointer;
  align-self: stretch;
}

.anomaly-color-reset-btn:hover {
  background: #f1f5f9;
}

.anomaly-collection-preview {
  margin-bottom: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.65rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  font-size: 0.75rem;
  color: #1e40af;
  display: none;
}

.anomaly-collection-preview.visible {
  display: block;
}

.anomaly-no-data-notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 0.65rem;
  background: #fff7ed;
  border: 1px solid #fdba74;
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.08);
}

.anomaly-no-data-notice.hidden {
  display: none;
}

.anomaly-no-data-notice-content {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  min-width: 0;
}

.anomaly-no-data-notice-content i {
  flex-shrink: 0;
  font-size: 1.15rem;
  color: #ea580c;
  margin-top: 0.05rem;
}

.anomaly-no-data-notice-content p {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.5;
  color: #9a3412;
}

.anomaly-no-data-dismiss {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 0.45rem;
  background: transparent;
  color: #c2410c;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.anomaly-no-data-dismiss:hover {
  background: rgba(234, 88, 12, 0.12);
  color: #9a3412;
}

.anomaly-alert-modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.anomaly-alert-modal.hidden {
  display: none;
}

.anomaly-alert-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  margin: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  cursor: pointer;
}

.anomaly-alert-card {
  position: relative;
  z-index: 1;
  width: min(100%, 22rem);
  padding: 1.35rem 1.35rem 1.15rem;
  border-radius: 1rem;
  background: #fff;
  border: 1px solid #e9d5ff;
  box-shadow: 0 20px 40px rgba(91, 33, 182, 0.18);
  text-align: center;
  animation: anomalyAlertIn 0.2s ease-out;
}

@keyframes anomalyAlertIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.anomaly-alert-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.85rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #d97706;
  font-size: 1.6rem;
}

.anomaly-alert-title {
  margin: 0 0 0.45rem;
  font-size: 1rem;
  font-weight: 700;
  color: #0f172a;
}

.anomaly-alert-message {
  margin: 0 0 1.1rem;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: #64748b;
}

.anomaly-alert-ok-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 0.65rem;
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  color: #fff;
  font-size: 0.8125rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
}

.anomaly-alert-ok-btn:hover {
  background: linear-gradient(135deg, #6d28d9 0%, #5b21b6 100%);
}

.anomaly-chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 220px;
  color: #94a3b8;
  font-size: 0.8125rem;
  text-align: center;
  padding: 1rem;
}

.anomaly-progress-wrap {
  margin-top: 0.5rem;
}

.anomaly-progress-bar {
  height: 0.5rem;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.anomaly-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #7c3aed, #dc2626);
  border-radius: 9999px;
  transition: width 0.25s ease;
}

.anomaly-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.35rem;
}

.anomaly-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.anomaly-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.55rem 0.75rem;
  border-radius: 0.55rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}

.anomaly-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.anomaly-btn-primary { background: #7c3aed; color: #fff; }
.anomaly-btn-primary:hover:not(:disabled) { background: #6d28d9; }

.anomaly-btn-secondary { background: #fff; color: #334155; border-color: #cbd5e1; }
.anomaly-btn-secondary:hover:not(:disabled) { background: #f8fafc; }

.anomaly-btn-ghost { background: #f1f5f9; color: #475569; }
.anomaly-btn-ghost:hover:not(:disabled) { background: #e2e8f0; }

.anomaly-info-card {
  padding: 0.75rem;
  border-radius: 0.65rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-size: 0.75rem;
  color: #475569;
  line-height: 1.5;
}

.anomaly-info-card strong { color: #0f172a; }

.anomaly-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.anomaly-stat-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.anomaly-stat-card .label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.anomaly-stat-card .value {
  font-size: 1.35rem;
  font-weight: 800;
  color: #0f172a;
  margin-top: 0.2rem;
  line-height: 1.1;
}

.anomaly-stat-card.normal-highlight .value { color: var(--anomaly-color-normal, #059669); }
.anomaly-stat-card.anomaly-highlight .value { color: var(--anomaly-color-anomaly, #dc2626); }

.anomaly-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.anomaly-chart-card-stream {
  grid-column: 1 / -1;
  min-height: 360px;
}

.anomaly-chart-card-stream .anomaly-chart-canvas {
  min-height: 300px;
}

.anomaly-chart-card-secondary {
  min-height: 260px;
}

.anomaly-chart-card-secondary .anomaly-chart-canvas {
  min-height: 200px;
}

.anomaly-chart-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 0.85rem;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  min-height: 280px;
}

.anomaly-chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-bottom: 1px solid #f1f5f9;
  background: #fafafa;
}

.anomaly-chart-card-header h3 {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.anomaly-chart-card-header h3 i { color: #7c3aed; }

.anomaly-chart-canvas {
  flex: 1;
  min-height: 220px;
  width: 100%;
}

.anomaly-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.6875rem;
  color: #64748b;
  padding: 0 0.9rem 0.65rem;
}

.anomaly-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.anomaly-legend i {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 9999px;
  display: inline-block;
}

.anomaly-legend .dot-normal { background: var(--anomaly-color-sensor, #3b82f6); }
.anomaly-legend .dot-anomaly { background: var(--anomaly-color-anomaly, #dc2626); }
.anomaly-legend .dot-score { background: var(--anomaly-color-score, #8b5cf6); }

.anomaly-python-banner.hidden {
  display: none;
}

.anomaly-python-banner {
  margin-top: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 0.55rem;
  background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
  border: 1px dashed #c4b5fd;
  font-size: 0.6875rem;
  color: #5b21b6;
  line-height: 1.45;
}

.anomaly-python-banner.warn {
  background: linear-gradient(135deg, #fff7ed 0%, #fef2f2 100%);
  border-color: #fdba74;
  color: #9a3412;
}

.anomaly-field-hint {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.625rem;
  color: #64748b;
  line-height: 1.4;
}

@media (max-width: 1024px) {
  .anomaly-panel-body { flex-direction: column; }
  .anomaly-sidebar {
    width: 100%;
    min-width: 0;
    max-width: none;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
  }
  .anomaly-sidebar.anomaly-sidebar-collapsed {
    width: 100%;
    min-width: 0;
    max-width: none;
  }
  .anomaly-sidebar.anomaly-sidebar-collapsed .anomaly-sidebar-inner { display: none; }
  .anomaly-sidebar.anomaly-sidebar-collapsed .anomaly-sidebar-expand {
    display: flex;
    flex-direction: row;
    width: 100%;
    min-width: 0;
    padding: 0.65rem 1rem;
    justify-content: flex-start;
  }
  .anomaly-charts-grid { grid-template-columns: 1fr; }
  .anomaly-chart-card-stream,
  .anomaly-chart-card-secondary {
    grid-column: auto;
  }
}

@media (max-width: 480px) {
  .anomaly-panel-header { padding: 0.75rem 1rem; }
  .anomaly-panel-title h2 { font-size: 1rem; }
  .anomaly-stats-grid,
  .anomaly-color-grid {
    grid-template-columns: 1fr;
  }
}
