* {
  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 (System Admin, Telemetry) */
.header:not(:has(.header-top)) {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 12px 30px;
  gap: 15px;
  min-height: 56px;
}

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

.header-top {
  display: flex;
  align-items: center;
  padding: 12px 30px;
  gap: 15px;
  min-height: 56px;
}

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

/* Three-column layout for portal admin header-top */
.header-top:not(.system-admin-header) .header-left {
  flex: 1;
  min-width: 0;
}

.header-top:not(.system-admin-header) .header-config-info {
  flex: 1;
  justify-content: center;
  min-width: 0;
}

.header-top:not(.system-admin-header) .user-info {
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

/* Two-column layout for system admin header-top (no middle section) */
.header-top.system-admin-header {
  justify-content: space-between;
}

.header-top.system-admin-header .header-left {
  flex-shrink: 0;
}

.header-top.system-admin-header .user-info {
  flex-shrink: 0;
}

/* Three-column layout for single-row headers (telemetry, etc) */
.header:not(:has(.header-top)) .header-left {
  flex: 1;
  min-width: 0;
}

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

.header:not(:has(.header-top)) .user-info {
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

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

/* 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;
}

.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: 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: 20px;
}

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

.test-list-panel {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  max-height: 800px;
  overflow-y: auto;
}

.config-structure-panel {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  max-height: 800px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.test-list-header {
  margin-bottom: 15px;
}

.test-list-header h3 {
  margin-bottom: 15px;
  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-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-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-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-children {
  margin-left: 28px;
  border-left: 2px solid #e9ecef;
  padding-left: 10px;
  display: none;
}

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

.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;
}

/* 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;
}

.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;
}

.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-race-section {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 15px;
  overflow: hidden;
}

.normlevels-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background: #f8f9fa;
  border-bottom: 1px solid #e0e0e0;
}

.normlevels-section-title {
  font-weight: 600;
  font-size: 14px;
  color: #2c3e50;
}

.normlevels-section-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.normlevels-format-select {
  padding: 5px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  background: white;
}

.normlevels-section-content {
  padding: 15px;
}

.normlevels-gender-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.normlevels-gender-section {
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 6px;
  padding: 12px;
}

.normlevels-gender-title {
  font-weight: 500;
  font-size: 13px;
  color: #495057;
  margin-bottom: 10px;
  padding-bottom: 5px;
  border-bottom: 1px solid #e9ecef;
}

.normlevels-age-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.normlevels-age-section {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  padding: 10px;
}

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

.normlevels-age-title {
  font-weight: 500;
  font-size: 12px;
  color: #6c757d;
  background: #e9ecef;
  padding: 2px 8px;
  border-radius: 3px;
}

.normlevels-items-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

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

.normlevels-level-item .form-field {
  margin-bottom: 0;
}

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

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

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

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

.normlevels-level-item .normlevels-color {
  width: 90px;
  font-size: 11px;
  font-family: monospace;
}

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

.normlevels-add-race {
  margin-top: 10px;
}

/* ========== 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: 15px 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-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;
}

.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-shrink: 0;
}

.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: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.test-editor-upload-wrap label {
  display: block;
  text-align: center;
  width: 100%;
}

.test-editor-file-input-wrap {
  width: 100%;
  text-align: center;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.test-editor-upload-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #6c757d;
  color: white;
  font-size: 12px;
  font-weight: bold;
  cursor: help;
  flex-shrink: 0;
}

.test-editor-file-input {
  border: none;
  background: none;
  padding: 0;
  color: transparent;
  width: auto;
  display: inline-block;
  font-size: 0;
  vertical-align: middle;
}

.test-editor-file-input::-webkit-file-upload-button {
  font-size: 14px;
}

.test-editor-file-input::-webkit-file-upload-button {
  color: initial;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  background: #f8f9fa;
}

.test-editor-file-input::-webkit-file-upload-button:hover {
  background: #e9ecef;
}

.test-editor-file-input::file-selector-button {
  color: initial;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid #bdc3c7;
  border-radius: 4px;
  background: #f8f9fa;
  font-size: 14px;
}

.test-editor-file-input::file-selector-button:hover {
  background: #e9ecef;
}

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

.test-editor-unit-wrap-left label {
  display: block;
  text-align: center;
}

.test-editor-unit-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.test-editor-unit-input-wrap input {
  flex: 1;
  min-width: 0;
  box-sizing: border-box;
}

.test-editor-unit-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #6c757d;
  color: white;
  font-size: 12px;
  font-weight: bold;
  cursor: help;
  flex-shrink: 0;
}

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

.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;
}

/* 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-fullscreen-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  margin: 0;
  font-size: 12px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.test-editor-fullscreen-btn:hover {
  background: rgba(0, 0, 0, 0.75);
  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: 600px;
  }
}

/* ========== 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;
}
