:root {
  --sidebar-bg: #1e293b;
  --sidebar-text: #e2e8f0;
  --sidebar-hover: #334155;
  --content-bg: #ffffff;
  --content-text: #1e293b;
  --border: #e2e8f0;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --secondary: #64748b;
  --secondary-hover: #475569;
  --success: #16a34a;
  --error: #dc2626;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--content-text);
  background: var(--content-bg);
}

body.admin-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  flex-shrink: 0;
}

.sidebar nav {
  padding: 1rem 0;
}

.sidebar a {
  display: block;
  padding: 0.5rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
}

.sidebar a:hover {
  background: var(--sidebar-hover);
}

.sidebar a.active {
  background: var(--sidebar-hover);
  font-weight: 600;
}

.main {
  flex: 1;
  padding: 1.5rem 2rem;
  overflow-x: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.card {
  background: var(--content-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}

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

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

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

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

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

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

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 12px;
}

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

th, td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  background: #f8fafc;
}

tr:hover td {
  background: #f8fafc;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

input, select, textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--content-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  max-width: 500px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h2 {
  margin: 0 0 1rem 0;
  font-size: 1.25rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  animation: fadeIn 0.2s ease;
}

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

.toast-error {
  background: var(--error);
  color: white;
}

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

.loading {
  opacity: 0.6;
  pointer-events: none;
}

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

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

.filters {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.filters .form-group {
  margin-bottom: 0;
}

.filters .form-group label {
  margin-bottom: 0.25rem;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
}

.badge-instruction { background: #dbeafe; color: #1e40af; }
.badge-timer { background: #dcfce7; color: #166534; }
.badge-condition { background: #fef3c7; color: #92400e; }
.badge-calculation { background: #e0e7ff; color: #3730a3; }
.badge-thermal_profile { background: #fce7f3; color: #9d174d; }
.badge-checkpoint { background: #f3e8ff; color: #6b21a8; }

.actions-row {
  display: flex;
  gap: 0.25rem;
}

.step-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  cursor: pointer;
  background: #f8fafc;
}

.step-header:hover {
  background: #f1f5f9;
}

.step-body {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.step-body.collapsed {
  display: none;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
}

.login-card {
  width: 100%;
  max-width: 360px;
}

@media (max-width: 768px) {
  body.admin-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .sidebar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0;

  }

  .main {
    padding: 1rem;
  }
}
