:root {
  /* Brand Colors */
  --deep-space: #0A0E1A;
  --surface: #111827;
  --surface-alt: #1A1F2E;
  --card-bg: #1E2336;
  --border: #2D3748;
  --border-light: #374151;

  /* Accent */
  --accent: #3B82F6;
  --accent-hover: #2563EB;
  --accent-light: rgba(59, 130, 246, 0.15);

  /* Status */
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #06B6D4;

  /* Status tints (15% opacity for hover backgrounds) */
  --success-light: rgba(16, 185, 129, 0.15);
  --warning-light: rgba(245, 158, 11, 0.15);
  --danger-light: rgba(239, 68, 68, 0.15);

  /* Flag colors */
  --flag-green: #16A34A;
  --flag-yellow: #EAB308;
  --flag-red: #DC2626;
  --flag-white: #F3F4F6;
  --flag-finish: #9CA3AF;

  /* Text */
  --text: #F3F4F6;
  --text-muted: #9CA3AF;
  --text-dim: #6B7280;

  /* Spacing */
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;

  /* Transitions */
  --transition: 150ms ease;
}

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

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--deep-space);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

input, textarea, select, button {
  font-family: inherit;
  font-size: inherit;
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* Utility classes */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-xs { gap: 4px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 16px; }
.gap-lg { gap: 24px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.font-bold { font-weight: 600; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn:hover { background: var(--border); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.15); }

.btn-success {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-icon { padding: 8px; min-width: 36px; }

/* Inputs */
.input, .select {
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition);
}

.input:focus, .select:focus {
  border-color: var(--accent);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* Toggle switch */
.toggle-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.toggle {
  position: relative;
  width: 48px;
  height: 26px;
  appearance: none;
  background: var(--border);
  border-radius: 13px;
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  outline: none;
}

.toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform var(--transition);
}

.toggle:checked {
  background: var(--success);
}

.toggle:checked::after {
  transform: translateX(22px);
}

/* Kinetica mini toggle (compact, for dense property panels) */
.kn-toggle {
  appearance: none;
  -webkit-appearance: none;
  width: 28px;
  height: 16px;
  border-radius: 8px;
  background: var(--border);
  border: none;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
  flex-shrink: 0;
  outline: none;
}
.kn-toggle::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all var(--transition);
}
.kn-toggle:checked { background: var(--accent); }
.kn-toggle:checked::after { left: 14px; background: white; }
.kn-toggle:hover { background: var(--border-light); }
.kn-toggle:checked:hover { background: var(--accent-hover); }

/* Kinetica styled checkbox (compact, for multi-select lists) */
.kn-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border-light);
  border-radius: 3px;
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
  outline: none;
  position: relative;
}
.kn-checkbox:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.kn-checkbox:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.kn-checkbox:hover { border-color: var(--accent); }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: rgba(6, 182, 212, 0.15); color: var(--info); }

/* Status dot */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--danger); }
.status-dot.warning { background: var(--warning); animation: pulse 2s infinite; }

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

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: white;
  animation: slideIn 300ms ease;
  max-width: 400px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); color: #000; }
.toast-info { background: var(--info); }

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

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms;
}

.modal-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  min-width: 400px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  font-size: 1.125rem;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}
