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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    Cantarell, sans-serif;
  background: #f5f5f5;
  color: #2c3e50;
  padding-top: 80px;
}

/* Extra padding for two-row header with config info (portal admin) */
body:has(.header .header-top:not(.system-admin-header)) {
  padding-top: 100px;
}

/* Padding for two-row header without config info (system admin) */
body:has(.header .header-top.system-admin-header) {
  padding-top: 100px;
}

.header {
  background: linear-gradient(135deg, #061c2f 0%, #a72468 100%);
  color: white;
  display: flex;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

/* System admin symmetric gradient - pink center, blue edges */
.header:has(.system-admin-header) {
  background: linear-gradient(135deg, #061c2f 0%, #a72468 50%, #061c2f 100%);
}

/* Single-row header (Telemetry, etc) — uses grid for true center */
.header:not(:has(.header-top)) {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px 30px;
  gap: 15px;
  min-height: 56px;
}

.header:not(:has(.header-top)) .header-left {
  justify-self: start;
}

.header:not(:has(.header-top)) .header-config-info {
  justify-self: center;
  min-width: 0;
}

.header:not(:has(.header-top)) .user-info {
  justify-self: end;
}

/* Two-row header (Portal Admin, Module Management) */
.header:has(.header-top) {
  flex-direction: column;
  padding: 0;
  gap: 0;
}

/* header-top — uses grid for true center */
.header-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px 30px;
  gap: 15px;
  min-height: 56px;
}

.header-top .header-left {
  justify-self: start;
}

.header-top .header-config-info {
  justify-self: center;
  min-width: 0;
}

.header-top .user-info {
  justify-self: end;
}

/* Two-column layout for system admin header-top (no middle section) */
.header-top.system-admin-header {
  grid-template-columns: 1fr auto;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.header h1 {
  font-size: 20px;
  font-weight: 600;
  white-space: nowrap;
  margin: 0;
  flex-shrink: 0;
}

/* Header collapse toggle */
.header-collapse-toggle {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 10px;
  cursor: pointer;
  padding: 4px 10px;
  line-height: 1;
  transition: color 0.2s;
  flex-shrink: 0;
}

.header-collapse-toggle:hover {
  color: rgba(255, 255, 255, 0.9);
}

.header.header-collapsed .header-top {
  display: none;
}

.header.header-collapsed .header-tabs .header-tab {
  display: none;
}

.header.header-collapsed .header-collapse-toggle {
  padding: 8px 14px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
}

body:has(.header.header-collapsed) {
  padding-top: 36px !important;
}

/* Header Tabs (Second Row) */
.header-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.15);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  overflow-x: auto;
  padding: 0 30px;
}

.header-tab {
  padding: 12px 20px;
  cursor: pointer;
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.8);
  transition: all 0.3s;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
  position: relative;
}

.header-tab.active {
  color: white;
  background: rgba(255, 255, 255, 0.1);
  border-bottom-color: white;
}

.header-tab:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.header-config-info {
  display: flex;
  align-items: center;
  gap: 15px;
  background: rgba(255, 255, 255, 0.15);
  padding: 8px 16px;
  border-radius: 8px;
  flex-shrink: 1;
  flex-wrap: wrap;
}

.config-status-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition:
    opacity 0.2s ease,
    max-width 0.3s ease;
}

.config-label {
  font-size: 11px;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.config-value {
  font-size: 13px;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hash value - shorter max-width */
#configHash {
  max-width: 80px;
  font-size: 11px;
}

/* Telemetry/System Admin dashboard - no max-width restriction on config values */
.header:not(:has(.header-top)) .config-value {
  max-width: none;
}

/* Pending changes indicator */
.pending-changes-indicator {
  display: none;
  margin-left: 10px;
  padding: 5px 10px;
  background: #fff3cd;
  color: #856404;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-shrink: 0;
}

.header-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}

.btn-telemetry.nav-current {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
}

.user-info span {
  font-size: 14px;
}

/* ========== HEADER RESPONSIVE STYLES ========== */

/* Large screens - show everything */
@media (max-width: 1400px) {
  .header-config-info {
    gap: 12px;
    padding: 6px 12px;
  }
}

/* Hide Updated first (priority 4) */
@media (max-width: 1200px) {
  .config-status-item[data-priority="4"] {
    display: none;
  }
}

/* Hide Hash (priority 3) */
@media (max-width: 1000px) {
  .config-status-item[data-priority="3"] {
    display: none;
  }
  .header {
    padding: 12px 20px;
  }
  .header-top {
    padding: 12px 20px;
  }
  .header-tabs {
    padding: 0 20px;
  }
}

/* Hide Status (priority 2) */
@media (max-width: 850px) {
  .config-status-item[data-priority="2"] {
    display: none;
  }
  .header h1 {
    font-size: 18px;
  }
  .header-tab {
    padding: 10px 16px;
    font-size: 13px;
  }
}

/* Compact header */
@media (max-width: 700px) {
  body {
    padding-top: 70px;
  }
  body:has(.header .header-top) {
    padding-top: 90px;
  }
  .header {
    padding: 10px 15px;
  }
  .header-top {
    padding: 10px 15px;
    gap: 10px;
  }
  .header-tabs {
    padding: 0 15px;
  }
  .header h1 {
    font-size: 16px;
  }
  .header-config-info {
    padding: 5px 10px;
    gap: 8px;
  }
  .config-label {
    font-size: 10px;
  }
  .config-value {
    font-size: 12px;
  }
  .user-info {
    gap: 10px;
  }
  .header-tab {
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* Hide Version (priority 1) - only config info container hidden */
@media (max-width: 600px) {
  .header-config-info {
    display: none;
  }
  .header h1 {
    font-size: 15px;
  }
  body {
    padding-top: 65px;
  }
  body:has(.header .header-top) {
    padding-top: 80px;
  }
}

/* Very small screens */
@media (max-width: 480px) {
  body {
    padding-top: 60px;
  }
  body:has(.header .header-top) {
    padding-top: 75px;
  }
  .header {
    padding: 8px 12px;
  }
  .header-top {
    padding: 8px 12px;
  }
  .header-tabs {
    padding: 0 12px;
  }
  .header h1 {
    font-size: 14px;
  }
  .user-info .btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  /* Hide username on very small screens */
  .user-info > span:first-child {
    display: none;
  }
  .header-tab {
    padding: 8px 10px;
    font-size: 11px;
  }
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s;
}

.btn-primary {
  background: #3498db;
  color: white;
}

.btn-primary:hover {
  background: #2980b9;
}

.btn-success {
  background: #27ae60;
  color: white;
}

.btn-success:hover {
  background: #229954;
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-secondary {
  background: #95a5a6;
  color: white;
}

.btn-secondary:hover {
  background: #7f8c8d;
}

.btn-user {
  background: rgba(167, 36, 104, 0.7);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
}

.btn-user:hover {
  background: rgba(167, 36, 104, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-user svg {
  width: 20px;
  height: 20px;
}

.btn-user::after {
  content: attr(data-email);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 12px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
}

.btn-user::before {
  content: "";
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1001;
}

.btn-user:hover::after,
.btn-user:hover::before {
  opacity: 1;
}

.btn-logout {
  background: rgba(167, 36, 104, 0.7);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
}

.btn-logout:hover {
  background: rgba(167, 36, 104, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-logout svg {
  width: 20px;
  height: 20px;
}

.btn-logout::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 12px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
}

.btn-logout::before {
  content: "";
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1001;
}

.btn-logout:hover::after,
.btn-logout:hover::before {
  opacity: 1;
}

.btn-telemetry {
  background: rgba(167, 36, 104, 0.7);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  text-decoration: none;
}

.btn-telemetry:hover {
  background: rgba(167, 36, 104, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-telemetry svg {
  width: 20px;
  height: 20px;
}

.btn-telemetry::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 12px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
}

.btn-telemetry::before {
  content: "";
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1001;
}

.btn-telemetry:hover::after,
.btn-telemetry:hover::before {
  opacity: 1;
}

.btn-view {
  background: rgba(6, 28, 47, 0.7);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.3s,
    box-shadow 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  font-size: 14px;
}

.btn-view:hover:not(:disabled) {
  background: rgba(10, 37, 64, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-view:disabled {
  background: rgba(167, 36, 104, 0.3);
  cursor: not-allowed;
  opacity: 1;
}

.btn-view:disabled:hover {
  background: rgba(167, 36, 104, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-merge {
  background: rgba(6, 28, 47, 0.7);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.3s,
    box-shadow 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  font-size: 14px;
}

.btn-merge:hover:not(:disabled) {
  background: rgba(10, 37, 64, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-merge:disabled {
  background: rgba(167, 36, 104, 0.3);
  cursor: not-allowed;
  opacity: 1;
}

.btn-merge:disabled:hover {
  background: rgba(167, 36, 104, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-merge::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 12px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
}

.btn-merge::before {
  content: "";
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1001;
}

.btn-merge:hover::after,
.btn-merge:hover::before {
  opacity: 1;
}

.btn-save {
  background: rgba(39, 174, 96, 0.7);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.3s,
    box-shadow 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  font-size: 14px;
}

.btn-save:hover:not(:disabled) {
  background: rgba(46, 204, 113, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-save:disabled {
  background: rgba(167, 36, 104, 0.3);
  cursor: not-allowed;
  opacity: 1;
}

.btn-save:disabled:hover {
  background: rgba(167, 36, 104, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-save::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 12px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
}

.btn-save::before {
  content: "";
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1001;
}

.btn-save:hover::after,
.btn-save:hover::before {
  opacity: 1;
}

.btn-discard {
  background: rgba(243, 156, 18, 0.7);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background 0.3s,
    box-shadow 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  position: relative;
  font-size: 14px;
}

.btn-discard:hover:not(:disabled) {
  background: rgba(241, 196, 15, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-discard:disabled {
  background: rgba(167, 36, 104, 0.3);
  cursor: not-allowed;
  opacity: 1;
}

.btn-discard:disabled:hover {
  background: rgba(167, 36, 104, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-discard::after {
  content: attr(title);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  font-size: 12px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1000;
}

.btn-discard::before {
  content: "";
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 5px solid rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 1001;
}

.btn-discard:hover::after,
.btn-discard:hover::before {
  opacity: 1;
}

.btn-warning {
  background: #f39c12;
  color: white;
}

.btn-warning:hover {
  background: #e67e22;
}

.btn:disabled,
.btn.btn-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn:disabled:hover,
.btn.btn-disabled:hover {
  background: inherit;
}

.tree-node.invalid-category {
  border-left: 4px solid #e74c3c;
  background: #fee;
}

.tree-node.invalid-category .tree-node-header {
  background: #fee;
}

.invalid-badge {
  background: #e74c3c;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  margin-left: 5px;
}

.tree-node.pending-item {
  border-left: 4px dashed #f39c12;
  background: #fff9e6;
  opacity: 0.9;
}

.pending-badge {
  background: #f39c12;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  margin-left: 5px;
  font-weight: 600;
}

/* Pending deletion styles */
.tree-node.pending-deletion {
  border-left: 4px solid #e74c3c;
  background: #fdecea;
  opacity: 0.7;
}

.tree-node.pending-deletion .tree-node-label {
  text-decoration: line-through;
  color: #e74c3c;
}

.deletion-badge {
  background: #e74c3c;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  margin-left: 5px;
  font-weight: 600;
}

.container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1% 1%;
}

.toolbar {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.search-box {
  padding: 10px 15px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-size: 14px;
  width: 300px;
  max-width: 100%;
}

.search-box:focus {
  outline: none;
  border-color: #061c2f;
}

.info-card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

.info-card h3 {
  margin-bottom: 15px;
  color: #2c3e50;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.info-item {
  padding: 10px;
  background: #f8f9fa;
  border-radius: 4px;
}

.info-item label {
  font-size: 12px;
  color: #7f8c8d;
  display: block;
  margin-bottom: 5px;
}

.info-item value {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
}

.tab-content {
  display: none;
  background: white;
  padding: 2%;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tab-content.active {
  display: block;
}

.config-viewer {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 20px;
  max-height: 600px;
  overflow-y: auto;
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
}

.json-key {
  color: #8e44ad;
  font-weight: 600;
}

.json-string {
  color: #27ae60;
}

.json-number {
  color: #e67e22;
}

.json-boolean {
  color: #3498db;
}

.json-null {
  color: #95a5a6;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding: 20px;
}

.pagination-btn {
  padding: 8px 12px;
  border: 1px solid #bdc3c7;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.pagination-btn:hover:not(:disabled) {
  background: #f8f9fa;
  border-color: #061c2f;
}

.pagination-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-info {
  padding: 8px 15px;
  font-size: 14px;
  color: #7f8c8d;
}

.editor-container {
  margin-top: 20px;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 10px;
}

textarea {
  width: 100%;
  min-height: 250px;
  padding: 15px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: #061c2f;
}

.alert {
  padding: 12px 15px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.alert-success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.alert-error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.alert-warning {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10004;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  pointer-events: none;
}

.toast {
  background: white;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideInRight 0.3s ease-out;
  min-width: 300px;
  max-width: 400px;
  pointer-events: auto;
  position: relative;
}

.toast-success {
  border-left: 4px solid #27ae60;
}

.toast-error {
  border-left: 4px solid #e74c3c;
}

.toast-warning {
  border-left: 4px solid #f39c12;
}

.toast-info {
  border-left: 4px solid #3498db;
}

.toast-icon {
  font-size: 20px;
  flex-shrink: 0;
  font-weight: bold;
}

.toast-success .toast-icon {
  color: #27ae60;
}

.toast-error .toast-icon {
  color: #e74c3c;
}

.toast-warning .toast-icon {
  color: #f39c12;
}

.toast-info .toast-icon {
  color: #3498db;
}

.toast-message {
  flex: 1;
  font-size: 14px;
  color: #2c3e50;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #7f8c8d;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 4px;
  transition: background 0.2s;
  line-height: 1;
}

.toast-close:hover {
  background: #f0f0f0;
  color: #2c3e50;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast.fade-out {
  animation: slideOutRight 0.3s ease-out forwards;
}

.version-list {
  list-style: none;
}

.version-item {
  padding: 15px;
  background: #f8f9fa;
  border-radius: 4px;
  margin-bottom: 10px;
  border-left: 4px solid #bdc3c7;
  cursor: pointer;
  transition: all 0.3s;
}

.version-item:hover {
  background: #e9ecef;
  border-left-color: #061c2f;
}

.version-item.active {
  background: #e3f2fd;
  border-left-color: #3498db;
}

.version-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.version-number {
  font-weight: 600;
  font-size: 16px;
  color: #2c3e50;
}

.version-badge {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.badge-active {
  background: #d4edda;
  color: #155724;
}

.version-meta {
  font-size: 12px;
  color: #7f8c8d;
}

.modal {
  display: none;
  position: fixed;
  z-index: 10001;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}

.modal-content {
  background: white;
  margin: 3% auto;
  padding: 30px;
  border-radius: 8px;
  width: 90%;
  max-width: 800px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.close {
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: #aaa;
}

.close:hover {
  color: #000;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #2c3e50;
}

.form-group select,
.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-size: 14px;
}

.form-group textarea {
  min-height: 150px;
}

.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #061c2f;
}

.loading {
  text-align: center;
  padding: 40px;
  color: #7f8c8d;
}

/* Global Loading Overlay */
.global-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10002;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
}

.global-loading-overlay .loading-content {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  text-align: center;
  min-width: 300px;
  max-width: 500px;
}

.global-loading-overlay .loading-message {
  margin-top: 20px;
  font-size: 16px;
  font-weight: 500;
  color: #2c3e50;
  margin-bottom: 20px;
}

/* Section Loading Overlay */
.section-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  z-index: 10001;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 8px;
}

.section-loading-overlay .loading-content {
  text-align: center;
  padding: 20px;
}

.section-loading-overlay .loading-message {
  margin-top: 15px;
  font-size: 14px;
  color: #7f8c8d;
}

/* Loading Spinner */
.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #a72468;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

.section-loading-overlay .loading-spinner {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Skeleton Loading */
.skeleton-container {
  padding: 20px;
}

.skeleton-item {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 4px;
  margin-bottom: 12px;
}

.skeleton-card {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 15px;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  margin-bottom: 10px;
}

.skeleton-text {
  height: 14px;
  width: 100%;
  margin-bottom: 8px;
}

.skeleton-text.short {
  width: 40%;
}

.skeleton-text.medium {
  width: 70%;
}

.skeleton-badge {
  display: inline-block;
  height: 20px;
  width: 60px;
  border-radius: 10px;
  margin-right: 8px;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Progress Bar */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 20px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #061c2f 0%, #a72468 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Indeterminate progress bar - animated sliding effect */
.progress-bar.indeterminate {
  width: 30% !important;
  animation: indeterminate-slide 1.5s ease-in-out infinite;
}

@keyframes indeterminate-slide {
  0% {
    margin-left: 0%;
    opacity: 0.9;
  }
  50% {
    margin-left: 70%;
    opacity: 1;
  }
  100% {
    margin-left: 0%;
    opacity: 0.9;
  }
}

.progress-percentage {
  margin-top: 10px;
  font-size: 12px;
  color: #7f8c8d;
}

/* Button Loading State */
.button-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.button-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid #ffffff;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Container with relative positioning for section loading */
.loading-container {
  position: relative;
}

.diff-view {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 4px;
  margin-top: 10px;
  max-height: 400px;
  overflow-y: auto;
}

.diff-item {
  padding: 8px;
  margin-bottom: 8px;
  border-radius: 4px;
  border-left: 4px solid #bdc3c7;
}

.diff-added {
  background: #d4edda;
  border-left-color: #27ae60;
}

.diff-modified {
  background: #fff3cd;
  border-left-color: #f39c12;
}

.diff-deleted {
  background: #f8d7da;
  border-left-color: #e74c3c;
}

.diff-path {
  font-weight: 600;
  font-size: 12px;
  color: #2c3e50;
  margin-bottom: 5px;
}

.diff-value {
  font-size: 12px;
  font-family: "Courier New", monospace;
}

.diff-old {
  color: #e74c3c;
  text-decoration: line-through;
}

.diff-new {
  color: #27ae60;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 600;
  color: #061c2f;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 12px;
  color: #7f8c8d;
  text-transform: uppercase;
}

/* Test Editor Styles */
.config-panels-container {
  display: grid;
  grid-template-columns: 25% 75%;
  gap: 20px;
  margin-top: 10px;
}

@media (max-width: 768px) {
  .config-panels-container {
    grid-template-columns: 1fr;
  }
}

.test-list-panel {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 12px 16px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}

.config-structure-panel {
  background: white;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}

/* The .test-tree-view inside .config-structure-panel must NOT create its own
   scroll container — the panel itself already scrolls. Having two nested
   overflow:auto elements breaks scrollIntoView and manual scroll calculations. */
.config-structure-panel .test-tree-view {
  max-height: none;
  overflow-y: visible;
}

/* Sticky header inside the config-structure-panel scroll container */
.config-structure-sticky-header {
  position: sticky;
  top: -12px;
  z-index: 5;
  background: white;
  padding-top: 12px;
  padding-bottom: 8px;
  margin-bottom: 6px;
  border-bottom: 1px solid #e9ecef;
  flex-shrink: 0;
}

.config-structure-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 0;
}

.config-structure-toolbar h3 {
  margin: 0;
  flex: 1;
}

.config-structure-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tree-expand-btn {
  padding: 4px 10px;
  background: #f8f9fa;
  color: #495057;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.tree-expand-btn:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.test-list-header {
  position: sticky;
  top: -12px;
  z-index: 5;
  background: #f8f9fa;
  padding-top: 12px;
  padding-bottom: 8px;
  margin-bottom: 0;
}

.test-list-header h3 {
  margin-bottom: 10px;
  color: #2c3e50;
}

.test-filter-group {
  margin-bottom: 15px;
}

.test-filter-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #7f8c8d;
}

.test-item-card {
  background: white;
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.3s;
  border: 2px solid transparent;
}

.test-item-card:hover {
  border-color: #061c2f;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.test-item-card.active {
  border-color: #061c2f;
  background: #e3f2fd;
}

.test-item-name {
  font-weight: 600;
  font-size: 15px;
  color: #2c3e50;
  margin-bottom: 5px;
}

.test-item-meta {
  font-size: 12px;
  color: #7f8c8d;
}

.test-item-category {
  display: inline-block;
  background: #e9ecef;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  margin-top: 5px;
}

.test-editor-panel {
  background: white;
  border-radius: 8px;
  padding: 30px;
  max-height: 800px;
  overflow-y: auto;
}

.test-editor-header {
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e9ecef;
}

.test-editor-unpublished-badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 4px;
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffc107;
  margin-left: 10px;
}

.test-editor-diff-indicator {
  display: inline-block;
  font-size: 11px;
  color: #856404;
  margin-left: 6px;
  white-space: nowrap;
}

.test-editor-diff-highlight {
  border: 2px solid #f0ad4e !important;
  box-shadow: 0 0 4px rgba(240, 173, 78, 0.4);
  border-radius: 4px;
}

.test-editor-diff-highlight-label {
  color: #856404 !important;
}

.test-editor-header h3 {
  color: #2c3e50;
  margin-bottom: 10px;
}

.read-only-field {
  background: #f8f9fa;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
  color: #7f8c8d;
  font-size: 13px;
}

.form-section {
  margin-bottom: 30px;
  padding: 20px;
  background: #f8f9fa;
  border-radius: 6px;
}

.form-section h4 {
  color: #2c3e50;
  margin-bottom: 15px;
  font-size: 16px;
  border-bottom: 1px solid #dee2e6;
  padding-bottom: 8px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.form-row.full-width {
  grid-template-columns: 1fr;
}

.form-field {
  margin-bottom: 15px;
}

.form-field label {
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
  color: #2c3e50;
  font-size: 14px;
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field select {
  width: 100%;
  padding: 10px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-size: 14px;
}

.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: #061c2f;
}

.form-textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  background: white;
  margin-bottom: 10px;
  min-height: 120px;
  max-height: 250px;
  overflow-y: auto;
}

.form-textarea:focus {
  outline: none;
  border-color: #3498db;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.dynamic-list {
  margin-top: 10px;
}

.dynamic-list-item {
  background: white;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 10px;
  border: 1px solid #e0e0e0;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.dynamic-list-drag-handle {
  cursor: grab;
  opacity: 0.35;
  padding: 2px 4px;
  font-size: 16px;
  user-select: none;
  line-height: 1;
  margin-top: 2px;
  flex-shrink: 0;
}

.dynamic-list-drag-handle:hover {
  opacity: 1;
}

.dynamic-list-item-content {
  flex: 1;
}

.dynamic-list-item-remove {
  padding: 5px 10px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.dynamic-list-item-remove:hover {
  background: #c0392b;
}

.add-item-btn {
  padding: 8px 15px;
  background: #3498db;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 10px;
}

.add-item-btn:hover {
  background: #2980b9;
}

.editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 30px;
  padding-top: 20px;
  border-top: 2px solid #e9ecef;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #7f8c8d;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 15px;
}

/* Hierarchical Test View Styles */
.test-tree-view {
  background: white;
  border-radius: 8px;
  padding: 20px;
  max-height: 800px;
  overflow-y: auto;
}

.tree-node {
  margin: 5px 0;
}

.tree-node-header {
  display: flex;
  align-items: center;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.2s;
  user-select: none;
}

.tree-node-header:hover {
  background: #f8f9fa;
}

.tree-sticky-parent {
  position: sticky;
  top: min(calc(var(--node-level, 0) * 36px), 108px); /* cap at 3 levels deep */
  z-index: max(1, calc(4 - var(--node-level, 0)));
  background: #fff;
}

.config-structure-panel .tree-sticky-parent {
  top: min(calc(40px + var(--node-level, 0) * 36px), 148px);
}

.tree-sticky-parent.expanded {
  background: #e3f2fd;
}

.tree-sticky-parent:hover {
  background: #f8f9fa;
}

.tree-node.invalid-category > .tree-sticky-parent {
  background: #fee;
}

.tree-node.pending-item > .tree-sticky-parent {
  background: #fff9e6;
}

.tree-node.pending-deletion > .tree-sticky-parent {
  background: #fdecea;
}

.unified-requirements-tree .tree-sticky-parent {
  position: relative;
  top: auto;
  z-index: auto;
}

.tree-node-header.expanded {
  background: #e3f2fd;
}

.tree-node-header.selected {
  background: #bbdefb;
  border-left: 3px solid #2196f3;
}

.tree-toggle {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  border-radius: 3px;
  background: #e9ecef;
  color: #495057;
  font-size: 12px;
  font-weight: bold;
  flex-shrink: 0;
}

.tree-toggle:hover {
  background: #dee2e6;
}

.tree-toggle.no-children {
  visibility: hidden;
}

.tree-node-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tree-node-icon {
  font-size: 18px;
}

.tree-node-label {
  font-weight: 500;
  color: #2c3e50;
}

.tree-node-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: #e9ecef;
  color: #495057;
}

.tree-node-badge.test {
  background: #d4edda;
  color: #155724;
}

.tree-node-badge.category {
  background: #cfe2ff;
  color: #084298;
}

.tree-node-badge.bundle {
  background: #fff3cd;
  color: #856404;
}

.tree-node-info-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e9ecef;
  color: #6c757d;
  font-size: 11px;
  font-style: normal;
  cursor: default;
  flex-shrink: 0;
}

.tree-info-popup-global {
  position: fixed;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  white-space: nowrap;
  /* Above test editor (10000) and formula editor (10001) */
  z-index: 10100;
  gap: 5px;
  align-items: center;
  pointer-events: none;
}

.tree-info-popup-global.tree-info-popup-global--multiline {
  white-space: normal;
  max-width: min(320px, calc(100vw - 16px));
  align-items: stretch;
}

.field-help-popup-body {
  display: block;
  font-size: 13px;
  line-height: 1.4;
  color: #212529;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  word-break: break-word;
}

.tree-node-breadcrumb {
  font-size: 10px;
  color: #6c757d;
  border-left: 1px solid #dee2e6;
  padding-left: 8px;
  margin-left: 3px;
}

.tree-node-route {
  font-size: 10px;
  color: #0d6efd;
  font-family: monospace;
}

/* Bundle dual-list selector */
.bundle-dual-list {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 10px;
  align-items: stretch;
  min-height: 0;
}

.bundle-dual-list .dual-list-panel {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 150px;
}

.bundle-dual-list .dual-list-panel-header {
  padding: 8px 12px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  font-weight: 600;
  font-size: 13px;
  color: #495057;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bundle-dual-list .dual-list-panel-header .count {
  font-weight: normal;
  color: #6c757d;
  font-size: 12px;
}

.bundle-dual-list .dual-list-search {
  padding: 6px 10px;
  border: none;
  border-bottom: 1px solid #dee2e6;
  font-size: 13px;
  outline: none;
  width: 100%;
  box-sizing: border-box;
}

.bundle-dual-list .dual-list-items {
  overflow-y: auto;
  flex: 1;
  min-height: 120px;
}

.bundle-dual-list .dual-list-item {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}

.bundle-dual-list .dual-list-item:hover {
  background: #e8f4fd;
}

.bundle-dual-list .dual-list-item.selected {
  background: #d4edda;
}

.bundle-dual-list .dual-list-item .item-name {
  font-weight: 500;
  color: #212529;
}

.bundle-dual-list .dual-list-item .item-route {
  font-size: 11px;
  color: #6c757d;
  margin-left: 8px;
}

.bundle-dual-list .dual-list-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: center;
  padding: 0 4px;
}

.bundle-dual-list .dual-list-controls button {
  padding: 6px 12px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #495057;
  transition: background 0.15s, border-color 0.15s;
}

.bundle-dual-list .dual-list-controls button:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.tree-children {
  margin-left: 28px;
  border-left: 2px solid #e9ecef;
  padding-left: 10px;
  display: none;
}

.tree-children.expanded {
  display: block;
}

.tree-children[data-empty-category="true"] {
  min-height: 8px;
  margin-left: 28px;
  border-left: 2px dashed #ccc;
  padding-left: 10px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.cut-move-btn {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  opacity: 0.35;
  font-size: 15px;
  padding: 2px 5px;
  margin-left: 8px;
  line-height: 1;
  border-radius: 4px;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.cut-move-btn:hover {
  opacity: 1;
  background: #fff3e0;
  border-color: #ff9800;
}

.cut-node {
  opacity: 0.45;
  background: #fff8e1;
  border: 2px dashed #ff9800;
  border-radius: 6px;
}

.cut-node > .tree-node-header .cut-move-btn {
  display: none;
}

.cut-mode-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff3e0;
  border: 1px solid #ffcc80;
  border-radius: 6px;
  padding: 8px 16px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: #e65100;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.paste-slot {
  height: 6px;
  margin: 2px 0;
  border: 2px dashed #4caf50;
  border-radius: 4px;
  background: #e8f5e9;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.paste-slot:hover {
  height: 28px;
  background: #c8e6c9;
  border-color: #2e7d32;
}

.paste-slot::after {
  content: "⊕ Paste here";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #2e7d32;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.paste-slot:hover::after {
  opacity: 1;
}

.test-details {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 15px;
  margin: 10px 0;
  border-left: 4px solid #061c2f;
}

.test-details-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 15px;
}

.test-details-title {
  font-size: 18px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 5px;
}

.test-details-meta {
  font-size: 13px;
  color: #7f8c8d;
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.test-details-meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.test-details-section {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #dee2e6;
}

.test-details-section-title {
  font-size: 14px;
  font-weight: 600;
  color: #495057;
  margin-bottom: 8px;
}

.test-details-section-content {
  font-size: 13px;
  color: #6c757d;
  line-height: 1.6;
}

.view-mode-toggle {
  display: flex;
  gap: 10px;
}

.view-mode-btn {
  padding: 8px 16px;
  border: 2px solid #dee2e6;
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #6c757d;
  transition: all 0.2s;
}

.view-mode-btn.active {
  border-color: #061c2f;
  background: #061c2f;
  color: white;
}

.view-mode-btn:hover {
  border-color: #061c2f;
}

.tree-stats {
  display: flex;
  gap: 20px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 20px;
  font-size: 13px;
}

.tree-stat-item {
  display: flex;
  flex-direction: column;
}

.tree-stat-label {
  color: #7f8c8d;
  font-size: 11px;
  text-transform: uppercase;
}

.tree-stat-value {
  color: #2c3e50;
  font-size: 18px;
  font-weight: 600;
  margin-top: 2px;
}

.tree-node-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
  align-items: center;
}

.tree-edit-btn {
  padding: 4px 12px;
  background: #061c2f;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.2s;
}

.tree-edit-btn:hover {
  background: #5568d3;
}

/* Bookmark button in tree nodes */
.tree-bookmark-btn {
  padding: 3px 7px;
  background: transparent;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, filter 0.15s, opacity 0.15s;
  flex-shrink: 0;
  filter: grayscale(1);
  opacity: 0.45;
}

.tree-bookmark-btn:hover {
  background: #fff3cd;
  border-color: #ffc107;
  filter: grayscale(0);
  opacity: 1;
}

.tree-bookmark-btn.bm-active {
  background: #fff3cd;
  border-color: #ffc107;
  filter: grayscale(0);
  opacity: 1;
}

/* Bookmark banner above the edit tree */
/* Compact inline bookmark — lives inside the config-structure toolbar */
.bookmark-banner {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #fff8e1;
  border: 1px solid #ffc107;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 12px;
  color: #5f4900;
  white-space: nowrap;
  max-width: 260px;
  flex-shrink: 1;
  min-width: 0;
}

.bookmark-banner-icon {
  font-size: 12px;
  flex-shrink: 0;
}

.bookmark-banner-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.bookmark-banner-goto {
  padding: 2px 6px;
  background: #ffc107;
  color: #3d2e00;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1.4;
}

.bookmark-banner-goto:hover {
  background: #e0a800;
}

.bookmark-banner-clear {
  padding: 1px 5px;
  background: transparent;
  color: #856404;
  border: 1px solid #ffc107;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  flex-shrink: 0;
  transition: background 0.15s;
  line-height: 1.4;
}

.bookmark-banner-clear:hover {
  background: #ffe08a;
}

/* Floating bookmark button */
.bookmark-floating-btn {
  position: fixed;
  bottom: 80px;
  right: 24px;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #ffc107;
  color: #3d2e00;
  border: none;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: background 0.15s, transform 0.15s;
}

.bookmark-floating-btn:hover {
  background: #e0a800;
  transform: scale(1.08);
}

/* Levels and Norms Editor Styles */
.level-item {
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 10px;
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.level-item-content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 15px;
}

.level-color-display {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 2px solid #dee2e6;
  cursor: pointer;
  flex-shrink: 0;
}

.color-input-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.color-picker-input {
  width: 60px;
  height: 40px;
  border: 2px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
}

input[type="color"] {
  -webkit-appearance: none;
  border: none;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: 2px solid #dee2e6;
  border-radius: 4px;
}

.color-text-input {
  flex: 1;
  padding: 8px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-size: 12px;
}

.level-remove-btn {
  padding: 5px 10px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.level-remove-btn:hover {
  background: #c0392b;
}

.norm-description-item {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  padding: 10px;
  margin-bottom: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.norm-description-label {
  font-weight: 600;
  color: #495057;
  min-width: 150px;
}

.norm-description-input {
  flex: 1;
  padding: 8px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
}

.race-gender-section {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 15px;
  margin-bottom: 15px;
  border: 1px solid #dee2e6;
}

.race-gender-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #dee2e6;
}

.race-gender-title {
  font-weight: 600;
  color: #2c3e50;
  font-size: 15px;
}

.sort-order-selector {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
  padding: 10px;
  background: #e3f2fd;
  border-radius: 4px;
}

.sort-order-selector label {
  font-weight: 500;
  color: #495057;
}

.sort-order-selector select {
  padding: 5px 10px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
}

.validation-message {
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 13px;
}

.validation-message.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.validation-message.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.create-norms-btn {
  padding: 10px 20px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 500;
  margin-top: 10px;
}

.create-norms-btn:hover {
  background: #218838;
}

.norm-description-item.new-field {
  animation: pulseHighlight 2s ease-in-out;
  border: 2px solid #061c2f;
  background: #e3f2fd;
}

@keyframes pulseHighlight {
  0% {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0);
  }
}

.new-field-indicator {
  display: inline-block;
  padding: 2px 8px;
  background: #061c2f;
  color: white;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  margin-left: 8px;
  animation: pulseHighlight 2s ease-in-out;
}

.format-selection-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.2s;
}

.format-selection-modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.format-selection-content {
  background-color: white;
  padding: 30px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  max-width: 500px;
  width: 90%;
  animation: slideDown 0.3s;
}

.format-selection-content h3 {
  margin-top: 0;
  margin-bottom: 15px;
  color: #333;
  font-size: 20px;
}

.format-selection-content p {
  margin-bottom: 25px;
  color: #666;
  line-height: 1.5;
}

.format-selection-buttons {
  display: flex;
  gap: 15px;
  justify-content: flex-end;
}

.format-selection-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
}

.format-selection-btn.standard {
  background-color: #28a745;
  color: white;
}

.format-selection-btn.standard:hover {
  background-color: #218838;
}

.format-selection-btn.gender-based {
  background-color: #007bff;
  color: white;
}

.format-selection-btn.gender-based:hover {
  background-color: #0056b3;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

#raceSelectionDropdown option:disabled {
  color: #999;
  font-style: italic;
}

/* Fullscreen Formula Editor Modal */
.formula-editor-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #f5f6fa;
  z-index: 10001; /* Higher than test-editor-modal to appear on top */
  overflow: hidden;
}

.formula-editor-modal.active {
  display: flex;
  flex-direction: column;
}

/*
 * Blockly appends .blocklyDropDownDiv to document.body. Default theme uses z-index: 1000,
 * so FieldDropdown menus render behind the formula editor modal (10001) and appear broken.
 */
.blocklyDropDownDiv {
  z-index: 10500 !important;
}

.formula-editor-header {
  background: linear-gradient(135deg, #061c2f 0%, #a72468 100%);
  color: white;
  padding: 15px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.formula-editor-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.formula-editor-header .close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
}

.formula-editor-header .close-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.formula-editor-header .btn-primary {
  background: rgba(6, 28, 47, 0.7);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition:
    background 0.3s,
    box-shadow 0.3s;
}

.formula-editor-header .btn-primary:hover {
  background: rgba(10, 37, 64, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.formula-editor-header .btn-primary:disabled {
  background: rgba(6, 28, 47, 0.4);
  cursor: not-allowed;
  opacity: 0.7;
}

.formula-editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.formula-editor-left {
  width: 320px;
  background: white;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.formula-editor-form {
  padding: 15px 20px;
  border-bottom: 1px solid #e0e0e0;
  overflow-y: auto;
  max-height: 180px;
  min-height: 120px;
}

.formula-editor-form .form-group {
  margin-bottom: 12px;
}

.formula-editor-form .form-group:last-child {
  margin-bottom: 0;
}

.formula-editor-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  color: #495057;
  font-size: 13px;
}

.formula-editor-form input,
.formula-editor-form select,
.formula-editor-form textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
}

.formula-editor-form input:focus,
.formula-editor-form select:focus,
.formula-editor-form textarea:focus {
  outline: none;
  border-color: #061c2f;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Description textarea - smaller height */
.formula-editor-form #formulaDescription {
  height: 60px;
  min-height: 60px;
  max-height: 120px;
  resize: vertical;
}

.formula-type-selector {
  display: flex;
  gap: 10px;
  margin-top: 5px;
}

.formula-type-selector label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 8px 16px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.3s;
}

.formula-type-selector input[type="radio"] {
  width: auto;
}

.formula-type-selector label:has(input:checked) {
  border-color: #061c2f;
  background: #f0f3ff;
}

.formula-editor-toolbox {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  background: #fafafa;
}

.toolbox-section {
  margin-bottom: 15px;
}

.toolbox-section-header {
  font-weight: 600;
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #e0e0e0;
}

.toolbox-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 10px;
  font-size: 13px;
}

.toolbox-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Measurements items should be vertical, not horizontal */
#measurementItems {
  flex-direction: column;
  flex-wrap: nowrap;
  max-height: 400px;
  overflow-y: auto;
  overflow-x: hidden;
}

.toolbox-item {
  padding: 6px 12px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  cursor: grab;
  transition: all 0.2s;
  user-select: none;
}

/* Measurement items should be full width and not wrap */
#measurementItems .toolbox-item {
  width: 100%;
  box-sizing: border-box;
}

.toolbox-item:hover {
  background: #061c2f;
  color: white;
  border-color: #061c2f;
}

.toolbox-item.measurement {
  background: #e3f2fd;
  border-color: #90caf9;
  color: #1565c0;
}

.toolbox-item.measurement:hover {
  background: #1976d2;
  color: white;
}

.toolbox-item.operator {
  background: #fff3e0;
  border-color: #ffcc80;
  color: #e65100;
  font-family: monospace;
  font-weight: bold;
}

.toolbox-item.operator:hover {
  background: #ff9800;
  color: white;
}

.toolbox-item.function {
  background: #f3e5f5;
  border-color: #ce93d8;
  color: #7b1fa2;
  font-family: monospace;
}

.toolbox-item.function:hover {
  background: #9c27b0;
  color: white;
}

.toolbox-item.snippet {
  background: #e8f5e9;
  border-color: #a5d6a7;
  color: #2e7d32;
  font-family: monospace;
  font-size: 11px;
}

.toolbox-item.snippet:hover {
  background: #4caf50;
  color: white;
}

.toolbox-item.builtin {
  background: #fce4ec;
  border-color: #f48fb1;
  color: #c2185b;
}

.toolbox-item.builtin:hover {
  background: #e91e63;
  color: white;
}

.toolbox-category {
  margin-bottom: 8px;
}

.toolbox-category-header {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  padding: 4px 8px;
  background: #f0f0f0;
  border-radius: 4px;
  margin-bottom: 6px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toolbox-category-header:hover {
  background: #e8e8e8;
}

.toolbox-category-items {
  padding-left: 10px;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: hidden;
}

.formula-editor-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.formula-editor-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px;
}

.editor-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 15px;
}

.editor-tab {
  padding: 10px 20px;
  background: #e0e0e0;
  border: none;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s;
}

.editor-tab.active {
  background: white;
  color: #061c2f;
}

.editor-panel {
  flex: 1;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.editor-panel.active {
  display: flex;
}

.monaco-container {
  flex: 1;
  min-height: 300px;
}

.formula-editor-test {
  background: white;
  border-top: 1px solid #e0e0e0;
  padding: 20px;
  max-height: 35%;
  overflow-y: auto;
}

.test-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.test-panel-header h3 {
  margin: 0;
  font-size: 16px;
  color: #333;
}

.test-inputs {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.test-params {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.test-param {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.test-param label {
  font-size: 11px;
  color: #666;
  font-weight: 600;
}

.test-param input,
.test-param select {
  padding: 6px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
}

.test-measurements {
  flex: 1;
  min-width: 300px;
}

.test-measurements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  max-height: 120px;
  overflow-y: auto;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 6px;
}

.test-measurement-input {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.test-measurement-input label {
  font-size: 11px;
  color: #666;
}

.test-measurement-input input {
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
}

.test-results {
  margin-top: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  max-height: 150px;
  overflow-y: auto;
}

.test-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: white;
  border-radius: 4px;
  margin-bottom: 6px;
  font-size: 13px;
}

.test-result-item.success {
  border-left: 3px solid #4caf50;
}

.test-result-item.error {
  border-left: 3px solid #f44336;
  background: #ffebee;
}

.test-result-value {
  font-weight: 600;
  font-family: monospace;
}

.required-measurements-section {
  margin-top: 15px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
}

.required-measurements-tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 10px;
}

.required-measurements-tab {
  padding: 6px 12px;
  background: #e0e0e0;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.3s;
}

.required-measurements-tab.active {
  background: #061c2f;
  color: white;
}

.required-measurements-content {
  display: none;
}

.required-measurements-content.active {
  display: block;
}

/* Unified Requirements Tree Styles */
.unified-requirements-tree {
  font-size: 14px;
}

.unified-requirements-tree .tree-node {
  margin-bottom: 8px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: white;
}

.unified-requirements-tree .tree-node-header {
  padding: 10px 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  user-select: none;
}

.unified-requirements-tree .tree-node-header:hover {
  background: #e9ecef;
}

.unified-requirements-tree .tree-node-toggle {
  display: inline-block;
  width: 16px;
  text-align: center;
  font-size: 10px;
  color: #6c757d;
  transition: transform 0.2s;
}

.unified-requirements-tree .tree-node-label {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

.unified-requirements-tree .tree-node-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  background: #e3f2fd;
  color: #1976d2;
}

.unified-requirements-tree .tree-node-badge.default {
  background: #fff3cd;
  color: #856404;
}

.unified-requirements-tree .tree-node-children {
  padding-left: 20px;
  border-left: 2px solid #e0e0e0;
  margin-left: 15px;
}

.unified-requirements-tree .race-node {
  margin-bottom: 15px;
}

.unified-requirements-tree .gender-node {
  margin-bottom: 10px;
  margin-left: 10px;
}

.unified-requirements-tree .age-node {
  margin-bottom: 8px;
  margin-left: 10px;
}

.unified-requirements-tree .measurements-list {
  padding: 10px;
  background: #f8f9fa;
  border-radius: 4px;
  margin: 8px 0;
}

.unified-requirements-tree .measurement-item {
  padding: 6px 10px;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.unified-requirements-tree .measurement-item:hover {
  background: #f8f9fa;
}

/* Wizard Modal Styles */
.requirement-wizard-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10010; /* Higher than formula-editor-modal (10001) to appear on top */
  align-items: center;
  justify-content: center;
}

.requirement-wizard-modal.active {
  display: flex;
}

/* Measurement selector: right-aligned, lighter overlay so graph stays visible */
.measurement-selector-modal.active {
  justify-content: flex-end;
  padding-right: 20px;
  background: rgba(0, 0, 0, 0.2);
}

.requirement-wizard-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.requirement-wizard-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.requirement-wizard-body {
  padding: 20px;
}

.requirement-wizard-step {
  display: none;
}

.requirement-wizard-step.active {
  display: block;
}

.requirement-wizard-footer {
  padding: 15px 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.requirement-wizard-progress {
  padding: 15px 20px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.requirement-wizard-progress-step {
  flex: 1;
  padding: 8px;
  text-align: center;
  border-radius: 4px;
  background: #e9ecef;
  color: #6c757d;
  font-size: 12px;
  font-weight: 600;
}

.requirement-wizard-progress-step.active {
  background: #007bff;
  color: white;
}

.requirement-wizard-progress-step.completed {
  background: #28a745;
  color: white;
}

.measurement-checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 150px;
  overflow-y: auto;
}

.measurement-checkbox {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}

.measurement-checkbox:has(input:checked) {
  background: #e3f2fd;
  border-color: #2196f3;
}

.formula-editor-footer {
  background: white;
  border-top: 1px solid #e0e0e0;
  padding: 15px 25px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.formula-editor-footer .btn {
  padding: 10px 25px;
  font-size: 14px;
}

/* ========== NORMLEVELS EDITOR STYLES ========== */

#normLevelsEditorContainer {
  margin-top: 15px;
}

/* NormLevels Tree-Based Editor */
.nl-tree {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nl-tree-node {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
}

.nl-race-node {
  background: #fff;
}

.nl-gender-node {
  background: #fafafa;
  margin: 0 0 6px 0;
}

.nl-age-node {
  background: #fff;
  margin: 0 0 6px 0;
}

.nl-node-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
  cursor: pointer;
  user-select: none;
}

.nl-node-header:hover {
  background: #e9ecef;
}

.nl-race-node > .nl-node-header {
  background: #eef2f7;
}

.nl-gender-node > .nl-node-header {
  background: #f0f4f0;
  padding: 6px 12px;
}

.nl-age-node > .nl-node-header {
  background: #f5f5f0;
  padding: 5px 12px;
}

.nl-node-toggle {
  font-size: 10px;
  width: 16px;
  text-align: center;
  color: #666;
  flex-shrink: 0;
}

.nl-node-label {
  flex: 1;
  font-size: 13px;
  color: #2c3e50;
}

.nl-node-label strong {
  font-weight: 600;
}

.nl-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  margin-left: 6px;
  vertical-align: middle;
}

.nl-badge.default {
  background: #d4edda;
  color: #155724;
}

.nl-badge.race {
  background: #cce5ff;
  color: #004085;
}

.nl-summary {
  color: #888;
  font-size: 11px;
  font-weight: normal;
}

.nl-node-children {
  padding: 8px 8px 8px 20px;
}

.nl-race-node > .nl-node-children {
  padding: 10px 10px 10px 24px;
}

.nl-remove-btn {
  padding: 2px 8px !important;
  font-size: 11px !important;
  flex-shrink: 0;
}

.nl-reverse-btn {
  padding: 2px 6px !important;
  font-size: 13px !important;
  background: #e9ecef;
  border: 1px solid #ccc;
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
}

.nl-reverse-btn:hover {
  background: #ddd;
}

.nl-add-btn {
  margin-top: 4px;
  font-size: 12px;
}

.nl-tree-add-race {
  margin-top: 8px;
}

/* Level items inside tree */
.nl-levels-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}

.normlevels-level-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}

.nl-level-field {
  margin-bottom: 0;
}

.nl-level-min {
  flex: 0 0 70px;
}

.nl-level-max {
  flex: 0 0 70px;
}

.nl-level-label {
  flex: 1;
  min-width: 80px;
}

.nl-level-color {
  flex: 0 0 auto;
}

.nl-level-desc {
  flex: 1;
  min-width: 100px;
}

.normlevels-level-item input[type="number"],
.normlevels-level-item input[type="text"] {
  padding: 5px 6px;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  width: 100%;
}

.normlevels-level-item .color-input-group {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.normlevels-level-item .level-color-display {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid #ccc;
  cursor: pointer;
  flex-shrink: 0;
}

.normlevels-level-item .level-color-display:hover {
  border-color: #888;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.2);
}

.normlevels-level-item .color-picker-input {
  display: none;
}

.normlevels-level-item .normlevels-color {
  width: 85px;
  font-size: 11px;
  font-family: monospace;
  padding: 4px 5px;
  border: 1px solid #ddd;
  border-radius: 3px;
}

.normlevels-empty {
  color: #999;
  font-size: 12px;
  font-style: italic;
  padding: 10px;
  text-align: center;
}

/* Color Preset Popover */
.color-preset-popover {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  background: white;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 8px;
  margin-top: 4px;
  min-width: 160px;
}

.color-preset-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}

.color-preset-swatch {
  width: 26px;
  height: 26px;
  border-radius: 4px;
  border: 2px solid transparent;
  cursor: pointer;
  transition:
    transform 0.1s,
    border-color 0.1s;
}

.color-preset-swatch:hover {
  transform: scale(1.15);
  border-color: #333;
}

.color-preset-swatch.active {
  border-color: #007bff;
  box-shadow: 0 0 0 1px #007bff;
}

.color-preset-custom-btn {
  width: 100%;
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid #ddd;
  border-radius: 3px;
  background: #f8f9fa;
  cursor: pointer;
  color: #555;
}

.color-preset-custom-btn:hover {
  background: #e9ecef;
}

/* Direction Toggle */
.nl-direction-toggle {
  display: flex;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
}

.nl-direction-btn {
  flex: 1;
  padding: 6px 10px;
  border: none;
  background: #f8f9fa;
  cursor: pointer;
  font-size: 12px;
  color: #555;
  transition:
    background 0.15s,
    color 0.15s;
}

.nl-direction-btn:first-child {
  border-right: 1px solid #ddd;
}

.nl-direction-btn.active {
  background: #007bff;
  color: white;
}

.nl-direction-btn:hover:not(.active) {
  background: #e9ecef;
}

.nl-direction-btn small {
  display: block;
  font-size: 10px;
  opacity: 0.8;
}

/* Wizard level items */
.nl-wizard-level {
  margin-bottom: 4px;
}

/* ========== END NORMLEVELS EDITOR STYLES ========== */

/* Fullscreen Test Editor Modal */
.test-editor-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #f5f6fa;
  z-index: 10000;
  overflow: hidden;
}

.test-editor-modal.active {
  display: flex;
  flex-direction: column;
}

.test-editor-header {
  background: linear-gradient(135deg, #061c2f 0%, #a72468 100%);
  color: white;
  padding: 10px 25px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.test-editor-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.test-editor-header .close-btn {
  background: rgba(6, 28, 47, 0.7);
  border: none;
  color: white;
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.test-editor-header .close-btn:hover {
  background: rgba(10, 37, 64, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.test-editor-header .btn-primary {
  background: rgba(6, 28, 47, 0.7);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.test-editor-header .btn-primary:hover {
  background: rgba(10, 37, 64, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.test-editor-toc {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 6px 25px;
  background: #f0f1f5;
  border-bottom: 1px solid #ddd;
  overflow-x: auto;
  flex-shrink: 0;
}

.test-editor-toc:empty {
  display: none;
}

.test-editor-toc .toc-item {
  padding: 5px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: #495057;
  background: white;
  border: 1.5px solid #d0d4da;
  border-radius: 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.test-editor-toc .toc-item:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

.test-editor-toc .toc-item-changed {
  border-color: #f0ad4e;
  background: #fff8ec;
  color: #856404;
  box-shadow: 0 0 4px rgba(240, 173, 78, 0.35);
}

.test-editor-toc .toc-item-changed:hover {
  background: #fff3d6;
  border-color: #e09b3d;
}

.test-editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  background: #f5f6fa;
}

.test-editor-content {
  padding: 30px;
  max-width: 1400px;
  margin: 0 auto;
  background: white;
  min-height: 100%;
}

.test-editor-content .test-editor-header {
  display: flex;
  align-items: center;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 2px solid #e9ecef;
}

.test-editor-content .test-editor-header h3 {
  color: white;
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

/* Inner header: editable name + route name (gradient area) */
.test-editor-content .test-editor-inner-header {
  background: linear-gradient(135deg, #061c2f 0%, #a72468 100%);
  color: white;
  padding: 12px 20px;
  border-radius: 6px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.test-editor-name-input {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: white;
  font-size: 20px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  width: 25%;
  min-width: 120px;
  max-width: 25%;
}

.test-editor-name-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.test-editor-name-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.8);
}

.test-editor-route-display {
  color: rgba(255, 255, 255, 0.85);
  font-size: 16px;
  font-weight: 500;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.test-editor-header-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  color: white;
  font-size: 12px;
  font-weight: bold;
  cursor: help;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.test-editor-header-info:hover {
  background: rgba(255, 255, 255, 0.4);
}

/* Basic Information: left = image + Upload + Unit, right = Introduction etc. */
.test-editor-image-intro-row {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.test-editor-left-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  gap: 12px;
}

.test-editor-upload-unit-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-top: 8px;
}

.test-editor-upload-wrap {
  text-align: center;
  flex: 1;
  min-width: 0;
  max-width: 168px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.test-editor-upload-wrap label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

.test-editor-file-input-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin-top: 2px;
}

.test-editor-field-help-btn {
  appearance: none;
  margin: 0;
  padding: 0;
  border: none;
  box-sizing: border-box;
  cursor: help;
  position: relative;
  z-index: 2;
  line-height: 1;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.test-editor-field-help-btn:focus {
  outline: none;
}

.test-editor-field-help-btn:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
}

.test-editor-label-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #6c757d;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
  vertical-align: middle;
}

.test-editor-label-info:hover {
  background: #5a6268;
}

.test-editor-file-input {
  display: none;
}

.test-editor-unit-wrap-left {
  flex: 0 0 auto;
  width: auto;
  max-width: 104px;
  min-width: 0;
  text-align: center;
}

.test-editor-unit-wrap-left label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
}

.test-editor-unit-input-wrap {
  margin-top: 2px;
  width: 100%;
  min-width: 0;
}

.test-editor-unit-field {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 6px 8px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-size: 13px;
}


.test-editor-image-wrap {
  flex-shrink: 0;
  position: relative;
  display: inline-block;
}

/* Image slot: fixed dimensions, logo placeholder while MinIO image loads */
.test-editor-image-frame {
  display: inline-block;
  width: min(100%, 400px);
  max-width: 400px;
  aspect-ratio: 4 / 3;
  vertical-align: top;
}

.test-editor-image-frame .test-editor-current-image {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  border: 1px solid #ddd;
  border-radius: 4px;
  display: block;
  transition: opacity 0.25s ease;
}

.test-editor-image-frame .test-editor-current-image.is-loading {
  opacity: 0.15;
}

.test-editor-current-image {
  max-width: 400px;
  max-height: 300px;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid #ddd;
  border-radius: 4px;
  display: block;
}

.test-editor-no-image {
  width: 200px;
  height: 150px;
  background: #f0f0f0;
  border: 1px dashed #ccc;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 14px;
}

.test-editor-placeholder-image {
  opacity: 0.5;
  border: 1px dashed #ccc !important;
}

/* Right column: Introduction at top, then Category / Current Image Path / Upload / Full Path */
.test-editor-right-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.test-editor-intro-block {
  min-width: 0;
}

.test-editor-patient-instructions {
  margin-top: -12px;
}

.test-editor-patient-instructions-textarea {
  min-height: 6em;
  height: 6em;
  resize: vertical;
}

.test-editor-intro-block .form-textarea {
  width: 100%;
  box-sizing: border-box;
}

.test-editor-intro-row.form-row {
  display: flex;
  gap: 16px;
}

.test-editor-intro-row .form-field {
  flex: 1;
  min-width: 0;
}

.test-editor-path-row-wrap {
  overflow-x: auto;
  min-width: 0;
}

.test-editor-path-row {
  display: flex;
  gap: 16px;
  min-width: min-content;
}

.test-editor-path-row .form-field {
  flex: 0 0 auto;
  min-width: 180px;
}

.test-editor-path-row .read-only-field {
  word-break: break-all;
}

.test-editor-suggested-config-row {
  display: flex;
  gap: 12px;
  flex-wrap: nowrap;
}

.test-editor-suggested-config-row .form-field {
  flex: 1;
  min-width: 0;
}

.test-editor-suggested-config-row .form-field input {
  width: 100%;
  box-sizing: border-box;
}

.test-editor-section-heading-lg h4 {
  font-size: 18px;
}

.test-editor-delete-image-btn,
.test-editor-fullscreen-btn {
  position: absolute;
  right: 8px;
  margin: 0;
  padding: 5px 7px;
  line-height: 1;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.test-editor-delete-image-btn {
  bottom: 42px;
  color: #f87171;
}

.test-editor-fullscreen-btn {
  bottom: 8px;
  color: white;
}

.test-editor-delete-image-btn:hover {
  background: rgba(0, 0, 0, 0.78);
  color: #ef4444;
}

.test-editor-fullscreen-btn:hover {
  background: rgba(0, 0, 0, 0.78);
  color: white;
}

/* Fullscreen image overlay */
.test-image-fullscreen-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  box-sizing: border-box;
}

.test-image-fullscreen-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
}

.test-image-fullscreen-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.test-image-fullscreen-close:hover {
  background: rgba(255, 255, 255, 0.25);
}

.test-editor-footer {
  background: white;
  padding: 15px 25px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
  .test-editor-content {
    padding: 15px;
  }

  .test-editor-header {
    padding: 12px 15px;
  }

  .test-editor-header h2 {
    font-size: 18px;
  }

  .test-editor-footer {
    padding: 12px 15px;
    flex-direction: column-reverse;
  }

  .test-editor-footer .btn {
    width: 100%;
  }

  .config-structure-panel,
  .test-list-panel {
    max-height: calc(100vh - 180px);
  }
}

/* ========== REQUIRED MEASUREMENTS HIGHLIGHTING ========== */

/* Required Measurements Section */
.required-measurements-section {
  margin-bottom: 15px;
}

.required-measurements-section .toolbox-category-header {
  background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%) !important;
  color: #856404 !important;
  font-weight: 700 !important;
  border: 2px solid #ffc107;
  box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

.toolbox-item.required-measurement {
  background: #fff3cd !important;
  border: 2px solid #ffc107 !important;
  font-weight: 600 !important;
  color: #856404 !important;
  box-shadow: 0 2px 4px rgba(255, 193, 7, 0.2);
  animation: pulse-required 2s ease-in-out infinite;
}

.toolbox-item.required-measurement:hover {
  background: #ffeaa7 !important;
  border-color: #ff9800 !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(255, 152, 0, 0.4);
}

/* Green styling for measurements that are USED in code */
.toolbox-item.measurement-used {
  background: #d4edda !important;
  border: 2px solid #28a745 !important;
  color: #155724 !important;
  animation: none !important; /* No pulsing for used measurements */
}

.toolbox-item.measurement-used:hover {
  background: #c3e6cb !important;
  border-color: #1e7e34 !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

/* Yellow styling for measurements that are NOT used in code */
.toolbox-item.measurement-unused {
  background: #fff3cd !important;
  border: 2px solid #ffc107 !important;
  color: #856404 !important;
  animation: pulse-unused 2s ease-in-out infinite;
}

.toolbox-item.measurement-unused:hover {
  background: #ffeaa7 !important;
  border-color: #ff9800 !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(255, 152, 0, 0.4);
}

@keyframes pulse-unused {
  0%,
  100% {
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
  }
  50% {
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.5);
  }
}

@keyframes pulse-required {
  0%,
  100% {
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.2);
  }
  50% {
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
  }
}

/* All Measurements Section */
.all-measurements-section {
  margin-top: 10px;
}

.all-measurements-section .toolbox-category-header {
  background: #e9ecef;
  color: #495057;
}

/* Subcategory Styles */
.toolbox-subcategory {
  margin-left: 10px;
  margin-bottom: 5px;
}

.toolbox-subcategory-header {
  font-size: 11px;
  font-weight: 600;
  color: #6c757d;
  padding: 6px 10px;
  background: #f8f9fa;
  border-radius: 3px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}

.toolbox-subcategory-header:hover {
  background: #e9ecef;
}

.toolbox-subcategory-items {
  padding: 4px 0;
  padding-left: 10px;
}

/* ========== BROWSE SERVER MODAL ========== */

.browse-server-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.browse-server-modal {
  background: #fff;
  border-radius: 8px;
  width: 90vw;
  max-width: 900px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.browse-server-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #dee2e6;
}

.browse-server-header h3 {
  margin: 0;
  font-size: 18px;
}

.browse-server-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6c757d;
  line-height: 1;
  padding: 0 4px;
}

.browse-server-close:hover {
  color: #333;
}

.browse-server-search {
  padding: 12px 20px;
  border-bottom: 1px solid #f0f0f0;
}

.browse-server-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 14px;
}

.browse-server-grid {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: min-content;
  gap: 12px;
  align-content: start;
}

.browse-server-card {
  border: 2px solid #e9ecef;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.browse-server-card:hover {
  border-color: #007bff;
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.15);
}

.browse-server-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  background: #f8f9fa;
}

.browse-server-card-name {
  padding: 6px 8px;
  font-size: 11px;
  color: #495057;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.browse-server-loading,
.browse-server-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: #7f8c8d;
  padding: 40px 20px;
  font-size: 14px;
}

.browse-server-footer {
  padding: 12px 20px;
  border-top: 1px solid #dee2e6;
  display: flex;
  justify-content: center;
}

/* ========== BULK UPDATE DIALOG ========== */

.bulk-update-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10002;
}

.bulk-update-modal {
  background: #fff;
  border-radius: 8px;
  width: 480px;
  max-width: 90vw;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.bulk-update-header {
  padding: 16px 20px;
  border-bottom: 1px solid #dee2e6;
}

.bulk-update-header h3 {
  margin: 0;
  font-size: 16px;
}

.bulk-update-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.bulk-update-body p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.5;
}

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

.bulk-update-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #f8f9fa;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
}

.bulk-update-item:hover {
  background: #e9ecef;
}

.bulk-update-footer {
  padding: 12px 20px;
  border-top: 1px solid #dee2e6;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ========== IMAGE MANAGER TAB ========== */

.image-manager-sync-warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 6px;
  padding: 12px 16px;
  margin-top: 10px;
  color: #856404;
  font-size: 14px;
}

.image-manager-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #495057;
  cursor: pointer;
  margin-left: 10px;
}

.image-manager-stats {
  font-size: 13px;
  color: #6c757d;
}

.image-manager-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-height: calc(100vh - 350px);
  overflow-y: auto;
  padding: 4px;
}

.image-manager-card {
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  transition: box-shadow 0.15s;
}

.image-manager-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.image-manager-card-thumb {
  height: 140px;
  background: #f8f9fa;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-manager-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-manager-card-info {
  padding: 8px 10px;
}

.image-manager-card-name {
  font-size: 12px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-manager-card-meta {
  font-size: 11px;
  color: #6c757d;
  margin-top: 2px;
}

.image-manager-badge-unused {
  display: inline-block;
  background: #dc3545;
  color: #fff;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-top: 4px;
  font-weight: 600;
}

.image-manager-card-actions {
  padding: 6px 10px 10px;
  display: flex;
  gap: 6px;
}

.image-manager-card-actions .btn-sm {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 3px;
}

.image-manager-footer {
  padding: 12px 0;
  display: flex;
  justify-content: center;
}

.test-editor-image-actions {
  display: flex;
  gap: 5px;
  margin-top: 5px;
  width: 100%;
}

.test-editor-browse-server-btn,
.test-editor-upload-trigger-btn {
  flex: 1;
  font-size: 12px;
  padding: 4px 8px;
  margin: 0;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .browse-server-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .image-manager-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =============================================
   Copy From Section Modal
   ============================================= */

.copy-from-section-btn {
  padding: 3px 5px;
  margin-left: 8px;
  background: none;
  color: #adb5bd;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}

.copy-from-section-btn:hover {
  background: rgba(6, 28, 47, 0.1);
  color: #495057;
}

.test-editor-formula-copy-btn {
  padding: 6px 8px;
  background: #fff;
  color: #495057;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.test-editor-formula-copy-btn:hover {
  background: #f8f9fa;
  border-color: #061c2f;
  color: #061c2f;
}

.copy-from-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10020;
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy-from-modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.copy-from-modal-header {
  padding: 20px;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.copy-from-modal-header h4 {
  font-size: 16px;
  color: #212529;
}

.copy-from-search-wrap {
  padding: 12px 20px 8px;
}

.copy-from-search-wrap input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 13px;
  box-sizing: border-box;
}

.copy-from-search-wrap input:focus {
  outline: none;
  border-color: #061c2f;
  box-shadow: 0 0 0 2px rgba(6, 28, 47, 0.12);
}

.copy-from-test-list {
  padding: 0 20px 8px;
  max-height: 200px;
  overflow-y: auto;
  border-bottom: 1px solid #e9ecef;
}

.copy-from-test-item {
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  color: #495057;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.1s;
}

.copy-from-test-item:hover {
  background: #f1f3f5;
}

.copy-from-test-item.selected {
  background: rgba(6, 28, 47, 0.1);
  color: #061c2f;
  font-weight: 600;
}

.copy-from-test-item .route-hint {
  font-size: 11px;
  color: #adb5bd;
  font-weight: 400;
}

.copy-from-test-empty {
  padding: 16px 12px;
  text-align: center;
  color: #adb5bd;
  font-size: 13px;
  font-style: italic;
}

.copy-from-preview {
  padding: 12px 20px;
  max-height: 160px;
  overflow-y: auto;
}

.copy-from-preview-card {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 12px;
  color: #495057;
}

.copy-from-preview-card h5 {
  margin: 0 0 8px;
  font-size: 12px;
  color: #868e96;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.copy-from-preview-card .preview-field {
  margin-bottom: 6px;
}

.copy-from-preview-card .preview-label {
  font-weight: 600;
  color: #495057;
  margin-right: 4px;
}

.copy-from-preview-card .preview-value {
  color: #6c757d;
}

.copy-from-preview-card .preview-empty {
  color: #adb5bd;
  font-style: italic;
}

.copy-from-preview-warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  padding: 8px 12px;
  margin-top: 8px;
  font-size: 12px;
  color: #856404;
}

.copy-from-options {
  padding: 12px 20px;
}

.copy-from-strategy-group {
  margin-bottom: 10px;
}

.copy-from-strategy-group label {
  font-size: 12px;
  font-weight: 600;
  color: #495057;
  display: block;
  margin-bottom: 6px;
}

.copy-from-strategy-radios {
  display: flex;
  gap: 16px;
}

.copy-from-strategy-radios label {
  font-weight: 400;
  font-size: 13px;
  color: #495057;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.copy-from-extra-checkboxes {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e9ecef;
}

.copy-from-extra-checkboxes label {
  font-size: 13px;
  color: #495057;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
}

.copy-from-actions {
  padding: 12px 20px 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid #e9ecef;
}

/* ========== COMPARE VERSIONS TAB ========== */

.compare-select {
  padding: 8px 12px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  font-size: 13px;
  color: #2c3e50;
  background: white;
  min-width: 180px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.compare-select:focus {
  outline: none;
  border-color: #061c2f;
}

.compare-result-area {
  margin-top: 20px;
}

.compare-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 24px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.compare-empty-icon {
  font-size: 48px;
  color: #bdc3c7;
  margin-bottom: 16px;
  line-height: 1;
}

.compare-empty-title {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
  margin: 0 0 6px 0;
}

.compare-empty-sub {
  font-size: 13px;
  color: #7f8c8d;
  margin: 0;
}

/* Shimmer skeleton while diff is loading */
.compare-shimmer {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  padding: 20px;
}

.compare-shimmer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e9ecef;
}

.compare-shimmer-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.shimmer-block {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 6px;
}

.shimmer-block-sm  { height: 20px; }
.shimmer-block-md  { height: 72px; }
.shimmer-block-lg  { height: 52px; }
.shimmer-block-xl  { height: 420px; }

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.compare-info-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.compare-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compare-card-title {
  font-size: 15px;
  font-weight: 600;
  color: #2c3e50;
  margin: 0;
}

.compare-card-body {
  padding: 20px;
}

.compare-view-modes {
  display: flex;
  gap: 6px;
  align-items: center;
}

.compare-view-btn {
  padding: 5px 12px;
  font-size: 12px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  background: white;
  color: #2c3e50;
  cursor: pointer;
  transition: all 0.15s;
}

.compare-view-btn:hover {
  border-color: #061c2f;
  color: #061c2f;
}

.compare-view-btn.active {
  background: #061c2f;
  border-color: #061c2f;
  color: white;
}

.compare-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.compare-stat-card {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 14px 16px;
  border-left: 3px solid #bdc3c7;
}

.compare-stat-card.total  { border-left-color: #3b82f6; }
.compare-stat-card.added  { border-left-color: #22c55e; }
.compare-stat-card.modified { border-left-color: #f59e0b; }
.compare-stat-card.deleted { border-left-color: #ef4444; }

.compare-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6c757d;
  margin-bottom: 4px;
}

.compare-stat-value {
  font-size: 26px;
  font-weight: 700;
  color: #2c3e50;
  line-height: 1;
}

.compare-stat-card.total   .compare-stat-value { color: #3b82f6; }
.compare-stat-card.added   .compare-stat-value { color: #22c55e; }
.compare-stat-card.modified .compare-stat-value { color: #f59e0b; }
.compare-stat-card.deleted .compare-stat-value { color: #ef4444; }

.compare-summary-box {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

.compare-summary-box h4 {
  margin: 0 0 8px 0;
  font-size: 13px;
  font-weight: 600;
  color: #1e40af;
}

.compare-summary-box ul {
  margin: 0;
  padding-left: 18px;
}

.compare-summary-box li {
  font-size: 13px;
  color: #1e3a8a;
  margin-bottom: 4px;
}

.compare-diff-scroll {
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  background: #f8f9fa;
  padding: 12px;
}

/* Unified diff items */
.compare-diff-item {
  border-radius: 5px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-left: 3px solid #bdc3c7;
  background: #f8f9fa;
}

.compare-diff-item.added    { background: #f0fdf4; border-left-color: #22c55e; }
.compare-diff-item.modified { background: #fffbeb; border-left-color: #f59e0b; }
.compare-diff-item.deleted  { background: #fef2f2; border-left-color: #ef4444; }

.compare-diff-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.compare-diff-badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.compare-diff-badge.added    { background: #22c55e; color: white; }
.compare-diff-badge.modified { background: #f59e0b; color: white; }
.compare-diff-badge.deleted  { background: #ef4444; color: white; }
.compare-diff-badge.asset    { background: #8b5cf6; color: white; }

.compare-diff-path {
  font-size: 13px;
  font-weight: 600;
  color: #2c3e50;
}

.compare-diff-raw-path {
  font-size: 10px;
  color: #9ca3af;
  font-family: monospace;
}

.compare-diff-old,
.compare-diff-new {
  font-family: monospace;
  font-size: 11px;
  padding: 6px 10px;
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-all;
}

.compare-diff-old {
  background: #fee2e2;
  color: #991b1b;
  margin-bottom: 4px;
}

.compare-diff-new {
  background: #dcfce7;
  color: #166534;
}

.compare-diff-old::before { content: "−  "; font-weight: 700; }
.compare-diff-new::before { content: "+  "; font-weight: 700; }

/* Side-by-side */
.compare-sbs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.compare-sbs-header {
  padding: 10px 14px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.compare-sbs-header.old { background: #fee2e2; color: #991b1b; }
.compare-sbs-header.new { background: #dcfce7; color: #166534; }

.compare-sbs-item {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 4px;
  border-left: 3px solid #bdc3c7;
  background: #f8f9fa;
}

.compare-sbs-item.deleted  { background: #fef2f2; border-left-color: #ef4444; }
.compare-sbs-item.modified { background: #fffbeb; border-left-color: #f59e0b; }
.compare-sbs-item.added    { background: #f0fdf4; border-left-color: #22c55e; }

.compare-sbs-label {
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
}

.compare-sbs-raw {
  font-size: 9px;
  color: #9ca3af;
  font-family: monospace;
}

.compare-sbs-value {
  font-family: monospace;
  font-size: 11px;
  color: #4b5563;
  word-break: break-all;
}

/* Tree diff */
.compare-tree {
  font-family: monospace;
  font-size: 13px;
  line-height: 1.6;
}

.compare-tree-node {
  margin-bottom: 4px;
}

.compare-tree-toggle {
  color: #3b82f6;
  cursor: pointer;
  user-select: none;
}

.compare-tree-toggle:hover {
  color: #1d4ed8;
}

.compare-tree-change {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #374151;
  padding: 2px 0;
}

.compare-tree-badge {
  padding: 0 5px;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.compare-tree-badge.A { background: #22c55e; }
.compare-tree-badge.M { background: #f59e0b; }
.compare-tree-badge.D { background: #ef4444; }

/* ========== DIAGNOSTICS TAB ========== */

.diag-summary {
  display: flex;
  gap: 12px;
  padding: 16px 0;
  flex-wrap: wrap;
}

.diag-card {
  flex: 1 1 120px;
  min-width: 110px;
  padding: 16px 14px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid #e9ecef;
  background: #fff;
}

.diag-card-number {
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.diag-card-label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  opacity: 0.8;
}

.diag-card-ok {
  border-color: #c3e6cb;
  background: #f0faf3;
}
.diag-card-ok .diag-card-number { color: #1e7e34; }
.diag-card-ok .diag-card-label { color: #28a745; }

.diag-card-mismatch {
  border-color: #f5c6cb;
  background: #fdf0f1;
}
.diag-card-mismatch .diag-card-number { color: #bd2130; }
.diag-card-mismatch .diag-card-label { color: #dc3545; }

.diag-card-warn {
  border-color: #ffeeba;
  background: #fffcf0;
}
.diag-card-warn .diag-card-number { color: #856404; }
.diag-card-warn .diag-card-label { color: #a67c00; }

.diag-card-info {
  border-color: #bee5eb;
  background: #f0f9fb;
}
.diag-card-info .diag-card-number { color: #0c5460; }
.diag-card-info .diag-card-label { color: #17a2b8; }

.diag-card-orphan {
  border-color: #e2d0f0;
  background: #f8f4fd;
}
.diag-card-orphan .diag-card-number { color: #6f42c1; }
.diag-card-orphan .diag-card-label { color: #7952b3; }

.diag-card-total {
  border-color: #d6d8db;
  background: #f8f9fa;
}
.diag-card-total .diag-card-number { color: #495057; }
.diag-card-total .diag-card-label { color: #6c757d; }

.diag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 4px;
}

.diag-table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #6c757d;
  border-bottom: 2px solid #dee2e6;
  background: #f8f9fa;
  position: sticky;
  top: 0;
  z-index: 1;
}

.diag-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}

.diag-row:hover {
  background: #f8f9ff;
}

.diag-row-mismatch {
  background: #fff8f8;
}
.diag-row-mismatch:hover {
  background: #fff0f0;
}
.diag-row-no_config_test {
  background: #fffdf5;
}
.diag-row-no_formula {
  background: #f5fbff;
}
.diag-row-orphan_dep {
  background: #faf5ff;
}
.diag-row-orphan_dep:hover {
  background: #f3ecfc;
}

.diag-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.diag-badge-ok {
  background: #d4edda;
  color: #155724;
}

.diag-badge-mismatch {
  background: #f8d7da;
  color: #721c24;
}

.diag-badge-warn {
  background: #fff3cd;
  color: #856404;
}

.diag-badge-info {
  background: #d1ecf1;
  color: #0c5460;
}

.diag-badge-orphan {
  background: #e2d0f0;
  color: #5a2d82;
}

.diag-results {
  max-height: calc(100vh - 340px);
  overflow-y: auto;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  background: #fff;
}

.diag-results code {
  background: #f1f3f5;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: #d63384;
}

.diag-sync-btn {
  padding: 4px 10px;
  font-size: 11px;
  background: rgba(6, 28, 47, 0.85);
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.diag-sync-btn:hover {
  background: rgba(6, 28, 47, 1);
}

.diag-sync-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
