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

html, body {
  height: 100%;
  font-family: 'Open Sans', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: black;
  background: black;
  -webkit-font-smoothing: antialiased;
}

a { color: black; }
a:hover { color: gray; }

/* ===== AUTH PAGES ===== */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: black;
}

.auth-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.auth-card {
  background: white;
  padding: 40px 36px 32px;
  border-radius: 3px;
}

/* Brand / Logo */
.auth-brand {
  text-align: center;
  margin-bottom: 4px;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.auth-card h1 {
  text-align: center;
  font-size: 1.4rem;
  margin: 0 0 2px 0;
  font-family: 'Libre Baskerville', serif;
  text-transform: none;
  letter-spacing: 0;
  color: black;
}

.auth-card h2 {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: gray;
  margin-bottom: 28px;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-family: 'Open Sans', sans-serif;
}

.auth-description {
  font-size: 0.85rem;
  color: gray;
  text-align: center;
  margin: -12px 0 24px;
  line-height: 1.5;
}

/* Auth page links */
.auth-link {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: gray;
}
.auth-link a { color: black; text-decoration: underline; }
.auth-link a:hover { color: gray; }

.auth-inline-link {
  font-size: 0.8rem;
  color: gray;
  text-decoration: none;
}
.auth-inline-link:hover {
  color: black;
  text-decoration: underline;
}

/* Footer */
.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.7rem;
  color: #666;
  letter-spacing: 0.5px;
}

/* ===== FORM ELEMENTS (auth-specific) ===== */

.auth-card .form-group {
  margin-bottom: 18px;
}

.auth-card label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Input wrapper with icon support */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  color: #aaa;
  pointer-events: none;
  z-index: 1;
  flex-shrink: 0;
}

.input-wrapper input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  font-size: 0.9rem;
  font-family: 'Open Sans', sans-serif;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  background: #fafafa;
  color: black;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.input-wrapper input:focus {
  outline: none;
  border-color: #333;
  background: white;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.input-wrapper input::placeholder {
  color: #bbb;
}

/* Password toggle button */
.password-toggle {
  position: absolute;
  right: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.password-toggle:hover {
  color: #333;
  background: #f0f0f0;
}

/* Field errors */
.field-error {
  display: none;
  font-size: 0.78rem;
  color: #c62828;
  margin-top: 4px;
  padding-left: 2px;
}

/* ===== CHECKBOX (Remember me) ===== */

.form-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 2px;
}

.form-row--between {
  justify-content: space-between;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #555;
}

.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: black;
  cursor: pointer;
}

.checkbox-text {
  user-select: none;
}

/* ===== PASSWORD STRENGTH METER ===== */

.password-strength {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.strength-bars {
  display: flex;
  gap: 3px;
  flex: 1;
  max-width: 120px;
}

.strength-bar {
  height: 3px;
  flex: 1;
  background: #e0e0e0;
  border-radius: 2px;
  transition: background 0.2s;
}

.strength-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.2s;
}

/* ===== BUTTONS (auth-specific) ===== */

.btn-full {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 11px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: 'Open Sans', sans-serif;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary:active {
  background: #111;
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Loading spinner */
.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.spinner {
  animation: spin 0.8s linear infinite;
}

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

/* ===== ALERTS ===== */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 3px;
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

.alert svg {
  margin-top: 1px;
}

.alert-error {
  background: #fff5f5;
  color: #c62828;
  border: 1px solid #ffcdd2;
}

.alert-success {
  background: #f0faf0;
  color: #2e7d32;
  border: 1px solid #c8e6c9;
}

.alert-info {
  background: #f5f5f5;
  color: #555;
  border: 1px solid #e0e0e0;
}

/* ===== ADMIN LAYOUT ===== */
.admin-layout { display: flex; flex-direction: column; min-height: 100vh; background: white; }

/* ─── Header Bar ─── */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: black;
  color: #d3d3d3;
  padding: 0 28px;
  height: 52px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: white;
}

.header-logo { flex-shrink: 0; }

.header-brand-name {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #d3d3d3;
  transition: color 0.15s;
}
.header-user:hover { color: white; }

.header-user-name {
  font-size: 0.85rem;
}

.header-user svg { opacity: 0.5; transition: opacity 0.15s; }
.header-user:hover svg { opacity: 1; }

.header-logout {
  font-size: 0.8rem;
  color: #999;
  text-decoration: none;
  padding: 4px 10px;
  border: 1px solid #444;
  border-radius: 3px;
  transition: all 0.15s;
}
.header-logout:hover {
  color: white;
  border-color: #888;
}

/* ─── Main Content ─── */
.admin-main {
  flex: 1;
  padding: 24px 32px;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  background: white;
  min-height: calc(100vh - 52px);
}

@media (max-width: 768px) {
  .admin-header { padding: 0 16px; }
  .admin-main { padding: 16px; }
  .detail-section--shaded,
  .detail-section--danger {
    margin-left: -16px;
    margin-right: -16px;
    padding: 16px;
  }
}

/* When the folder sidebar is expanded, admin-main goes full-width
   so the sidebar can reach the left edge of the viewport.
   The wrapper takes over height/overflow control. */
.admin-main:has(.dashboard-with-sidebar:not(.sidebar-collapsed)) {
  max-width: none;
  padding: 0;
  overflow: hidden;
}

/* ===== COMPONENTS ===== */

/* Page header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 1.5rem;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: 'Saira Semi Condensed', sans-serif;
  text-align: left;
}

.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Breadcrumb */
.breadcrumb { font-size: 0.85rem; color: gray; margin-bottom: 16px; }
.breadcrumb a { color: black; text-decoration: underline; }
.breadcrumb a:hover { color: gray; }

/* Cards */
.card {
  background: white;
  border-radius: 3px;
  margin-bottom: 16px;
  border: 1px solid #e0e0e0;
}

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

.card-header h3 {
  font-size: 1rem;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: 'Saira Semi Condensed', sans-serif;
}

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

.card-actions {
  padding: 12px 20px;
  border-top: 1px solid #e0e0e0;
  display: flex;
  gap: 8px;
}

.card-danger { border-color: #ff3333; }
.card-danger .card-header { background: #fff0f0; }

/* Stats row */
.stats-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }

.stat-card {
  flex: 1;
  min-width: 120px;
  background: white;
  padding: 16px 20px;
  border-radius: 3px;
  text-align: center;
  border: 1px solid #e0e0e0;
}

.stat-number { display: block; font-size: 1.8rem; font-weight: 700; color: black; line-height: 1.2; }

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: gray;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mini-bar { height: 4px; background: #e0e0e0; border-radius: 2px; margin-top: 8px; }
.mini-bar div { height: 100%; background: gray; border-radius: 2px; transition: width 0.3s; }

/* Study grid */
.study-grid { display: flex; flex-direction: column; gap: 12px; }
.study-card .card-header h3 { font-size: 1.05rem; }
.study-card .card-header h3 a { color: black; text-decoration: none; }
.study-card .card-header h3 a:hover { color: gray; }
.study-stats { display: flex; gap: 16px; font-size: 0.85rem; color: gray; margin-top: 4px; flex-wrap: wrap; }

/* Dashboard toolbar */
.dashboard-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dashboard-search {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  padding: 7px 12px 7px 32px;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  font-size: 0.85rem;
  font-family: 'Open Sans', sans-serif;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") 8px center no-repeat;
}

.dashboard-search:focus {
  outline: none;
  border-color: #999;
}

.dashboard-sort {
  padding: 7px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  font-size: 0.85rem;
  font-family: 'Open Sans', sans-serif;
  background: white;
  cursor: pointer;
  color: #333;
}

.dashboard-sort:hover { border-color: #999; }

/* Status filter tabs */
.status-filters {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.status-filter-btn {
  padding: 5px 14px;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  background: white;
  font-size: 0.8rem;
  font-family: 'Open Sans', sans-serif;
  cursor: pointer;
  color: #666;
  transition: all 0.15s;
}

.status-filter-btn:hover {
  border-color: #999;
  color: #333;
}

.status-filter-btn.active {
  background: #333;
  border-color: #333;
  color: white;
}

.status-filter-count {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-left: 3px;
}

/* Compact study rows */
.study-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.1s;
}

.study-row:last-child { border-bottom: none; }
.study-row:hover { background: #f5f7fa; }

.study-row-main {
  flex: 1;
  min-width: 0;
}

.study-row-name {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.study-row-name a {
  color: black;
  text-decoration: none;
}

.study-row-name a:hover { color: #555; }

.study-row-meta {
  font-size: 0.78rem;
  color: #999;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.study-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

/* Dashboard icon buttons — shared base */
.btn-icon {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  padding: 4px 5px;
  color: #999;
  display: flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
}
.btn-icon:hover {
  color: #333;
  border-color: #ccc;
}
.btn-icon.copied {
  color: #2e7d32;
  border-color: #c8e6c9;
}
.btn-icon.btn-delete-study {
  color: #ccc;
}
.btn-icon.btn-delete-study:hover {
  color: #c62828;
  border-color: #ffcdd2;
}

.study-row-badge {
  flex-shrink: 0;
}

.no-results {
  text-align: center;
  padding: 32px 20px;
  color: #999;
  font-size: 0.9rem;
}

/* Delete modal */
.delete-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.delete-modal {
  background: white;
  border-radius: 4px;
  padding: 28px 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

.delete-modal-title {
  font-family: 'Saira Semi Condensed', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px 0;
  color: #c62828;
}

.delete-modal-message {
  font-size: 0.88rem;
  line-height: 1.6;
  color: #444;
  margin: 0 0 16px 0;
}

.delete-modal-prompt {
  font-size: 0.85rem;
  color: #666;
  margin: 0 0 4px 0;
}

.delete-modal-study-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: black;
  background: #f5f5f5;
  padding: 6px 10px;
  border-radius: 3px;
  margin: 0 0 12px 0;
  word-break: break-word;
}

.delete-modal-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  font-size: 0.88rem;
  font-family: 'Open Sans', sans-serif;
  margin-bottom: 16px;
}
.delete-modal-input:focus {
  outline: none;
  border-color: #c62828;
}

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

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 2px;
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-sm { font-size: 0.7rem; padding: 1px 8px; }
.badge-red { background: #ff3333; }
.badge-orange { background: #c0c0c0; color: black; }
.badge-gray { background: #d3d3d3; color: black; }

/* Buttons — styled to match survey continue button */
.btn {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 5px;
  font-size: 0.85rem;
  font-weight: 400;
  font-family: 'Open Sans', sans-serif;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  line-height: 1.4;
  background: #ddd;
  color: gray;
  text-transform: uppercase;
}

.btn:hover { background: #bbb; color: white; }

.btn-primary { background: gray; color: white; }
.btn-primary:hover { background: black; color: white; }

.btn-outline {
  background: transparent;
  border: 1px solid gray;
  color: gray;
}
.btn-outline:hover { background: #ddd; color: black; border-color: #bbb; }

.btn-danger { background: #ff3333; color: white; }
.btn-danger:hover { background: #cc0000; color: white; }

.btn-sm { padding: 4px 12px; font-size: 0.8rem; }

/* Prominent action buttons (study detail) */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 5px;
  letter-spacing: 0.3px;
}
.btn-action svg {
  flex-shrink: 0;
}
.btn-action.btn-primary {
  background: #333;
}
.btn-action.btn-primary:hover {
  background: black;
}
.btn-action.btn-outline {
  border-width: 1.5px;
}

.btn-active { background: black; color: white; }
.btn-active:hover { background: black; }

/* Status buttons */
.status-buttons { display: flex; gap: 6px; flex-wrap: wrap; }

/* Forms — 5px borders matching survey inputs */
.admin-form .form-group { margin-bottom: 16px; }

.admin-form label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 4px;
  color: black;
}

@media all and (min-width: 710px) {
  .admin-form label { font-weight: 500; }
}

.admin-form input[type="text"],
.admin-form input[type="email"],
.admin-form input[type="password"],
.admin-form input[type="number"],
.admin-form input[type="url"],
.admin-form textarea,
.admin-form select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.9rem;
  font-family: 'Open Sans', sans-serif;
  outline: none;
  background: #fafafa;
  transition: border-color 0.5s, background-color 0.5s;
  color: black;
}

.admin-form input:hover, .admin-form input:focus,
.admin-form textarea:hover, .admin-form textarea:focus,
.admin-form select:hover, .admin-form select:focus {
  border-color: #999;
  background: white;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.04);
  transition: 0s;
}

.admin-form small { display: block; margin-top: 2px; font-size: 0.75rem; color: gray; }
.admin-form textarea { resize: vertical; }
.admin-form select { color: gray; }

.form-row .form-group { flex: 1; min-width: 180px; }
.form-actions { display: flex; gap: 12px; margin-top: 20px; }

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-top: 8px; }

.input-sm {
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 3px;
  font-size: 0.85rem;
  font-family: 'Open Sans', sans-serif;
  background: #fafafa;
  transition: border-color 0.5s, background-color 0.5s;
}

.input-sm:hover, .input-sm:focus {
  border-color: #999;
  background: white;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.04);
  transition: 0s;
  outline: none;
}

/* Admin-specific number input override: full-width inside forms */
.admin-form .number-input-wrap {
  width: 100%;
}

/* Data tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }

.data-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 2px solid #d3d3d3;
  font-weight: 600;
  color: gray;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.data-table td { padding: 8px 12px; border-bottom: 1px solid #e0e0e0; }
.data-table tr:hover { background: #f5f5f5; }

/* Page / Question list items */
.page-list, .question-list { display: flex; flex-direction: column; gap: 4px; }

.page-item, .question-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  background: white;
  transition: border-color 0.15s;
}

.page-item:hover, .question-item:hover { border-color: #d0d0d0; }

.page-item-handle, .question-item-handle { cursor: grab; color: gray; font-size: 1.1rem; }
.page-item-info, .question-item-info { flex: 1; min-width: 0; }
.page-item-actions, .question-item-actions { display: flex; gap: 6px; flex-shrink: 0; }

.question-item-header { display: flex; gap: 8px; align-items: center; }
.question-item-label { margin-top: 2px; font-size: 0.85rem; color: black; }
.question-item-config { font-size: 0.75rem; margin-top: 2px; font-family: monospace; color: gray; }

/* Add question section */
.add-question-section { margin-top: 24px; padding-top: 20px; border-top: 2px solid #d3d3d3; }
.add-question-section h4 { margin-bottom: 12px; text-transform: uppercase; letter-spacing: 1px; font-size: 0.9rem; }

/* Warning alert (amber — distinct from error/success/info) */
.alert-warning {
  background: #fff8e1;
  border: 1px solid #ffe082;
  color: #8d6e00;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: gray; }
.empty-state p { margin-bottom: 16px; }

/* Utilities */
.text-muted { color: gray; }



/* ===== STUDY DETAIL PAGE ===== */

/* Header section */
.detail-header {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e0e0e0;
}

.detail-header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.detail-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.detail-header-title h1 {
  font-size: 1.5rem;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: 'Saira Semi Condensed', sans-serif;
}

.detail-description {
  margin-top: 8px;
  color: gray;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Status pill switcher */
.detail-status-switcher {
  display: flex;
  gap: 2px;
  background: #f0f0f0;
  border-radius: 3px;
  padding: 2px;
}

.status-pill {
  padding: 4px 12px;
  border: none;
  background: transparent;
  font-size: 0.75rem;
  font-family: 'Open Sans', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
  border-radius: 2px;
  color: gray;
  transition: all 0.15s;
  font-weight: 600;
}

.status-pill:hover:not(:disabled) {
  background: #e0e0e0;
  color: black;
}

.status-pill.active {
  background: black;
  color: white;
  cursor: default;
}

/* Action groups */
.detail-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-group-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #b0b0b0;
  margin-right: 4px;
  white-space: nowrap;
}

/* Two-column grid */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}

/* ===== SECTION SHADING ===== */

.detail-section {
  margin-bottom: 0;
}

.detail-section--shaded {
  background: #f7f7f8;
  border-top: 1px solid #e8e8e8;
  border-bottom: 1px solid #e8e8e8;
  margin-left: -32px;
  margin-right: -32px;
  padding: 24px 32px;
}

.detail-section--danger {
  margin-left: -32px;
  margin-right: -32px;
  padding: 24px 32px;
  background: #fefafa;
  border-top: 1px solid #f0e0e0;
}

.detail-section--danger .card {
  margin-bottom: 0;
}

/* Info list (definition list) */
.info-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  gap: 12px;
}

.info-item:last-child { border-bottom: none; }

.info-item dt {
  font-size: 0.8rem;
  font-weight: 600;
  color: gray;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  min-width: 110px;
}

.info-item dd {
  font-size: 0.85rem;
  color: black;
  text-align: right;
  word-break: break-word;
}

.info-item dd code {
  font-size: 0.8rem;
  background: #f5f5f5;
  padding: 1px 5px;
  border-radius: 2px;
}

/* Stats */
.detail-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detail-stat {
  text-align: center;
  padding: 12px 8px;
  background: #fafafa;
  border-radius: 3px;
  border: 1px solid #f0f0f0;
}

.detail-stat-number {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
  color: black;
  line-height: 1.2;
}

.detail-stat-label {
  display: block;
  font-size: 0.7rem;
  color: gray;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Completion progress */
.detail-completion {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}

.detail-completion-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: gray;
  margin-bottom: 6px;
}

.detail-progress-bar {
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
  overflow: hidden;
}

.detail-progress-fill {
  height: 100%;
  background: #1565c0;
  border-radius: 3px;
  transition: width 0.3s ease;
}


/* ===== TABS ===== */

.detail-tabs {
  margin: 24px 0 0 0;
}

.detail-tab-nav {
  display: flex;
  gap: 0;
  border-bottom: none;
  margin-bottom: 0;
  position: relative;
  z-index: 1;
}

.detail-tab-btn {
  padding: 10px 24px;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  font-size: 0.8rem;
  font-family: 'Saira Semi Condensed', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: gray;
  cursor: pointer;
  position: relative;
  transition: color 0.15s, background 0.15s;
  border-radius: 4px 4px 0 0;
  margin-bottom: -1px;
}

.detail-tab-btn:hover {
  color: black;
  background: #f5f5f5;
}

.detail-tab-btn.active {
  color: black;
  background: white;
  border-color: #e0e0e0;
}

.detail-tab-btn.active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: white;
}

.btn-save-changes {
  margin-left: auto;
  align-self: center;
  font-size: 0.78rem;
  padding: 6px 18px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Tab panel — bordered content area connected to active tab */
.detail-tab-panel {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 0 4px 4px 4px;
  padding: 0;
}

.detail-tab-content {
  display: none;
  padding: 24px;
}

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

.tab-description {
  font-size: 0.8rem;
  color: gray;
  margin-bottom: 16px;
  line-height: 1.6;
}

/* Checkbox row inside tabs */
.checkbox-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

/* ===== OPTION CARDS (Navigation tab) ===== */
.option-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (max-width: 600px) {
  .option-cards-grid { grid-template-columns: 1fr; }
}

.option-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border: 1.5px solid #e0e0e0;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  position: relative;
}

.option-card:hover {
  border-color: #bbb;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.option-card.active {
  border-color: black;
  background: #fafafa;
}

.option-card input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.option-card-icon {
  flex-shrink: 0;
  color: #ccc;
  margin-top: 1px;
  transition: color 0.15s;
}

.option-card.active .option-card-icon {
  color: #555;
}

.option-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.option-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #555;
  line-height: 1.3;
  transition: color 0.15s;
}

.option-card.active .option-card-title {
  color: black;
}

.option-card-desc {
  font-size: 0.77rem;
  color: #aaa;
  line-height: 1.55;
  transition: color 0.15s;
}

.option-card.active .option-card-desc {
  color: #666;
}

.option-card-toggle {
  flex-shrink: 0;
  margin-top: 3px;
}

.toggle-track {
  width: 34px;
  height: 19px;
  border-radius: 10px;
  background: #ddd;
  position: relative;
  transition: background 0.2s;
}

.option-card.active .toggle-track {
  background: black;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.2s;
}

.option-card.active .toggle-thumb {
  transform: translateX(15px);
}

/* ===== PAGE LIST — Redesigned items + Drag & Drop ===== */

.page-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
}

.page-item:hover {
  border-color: #d0d0d0;
}

.page-item-handle {
  cursor: grab;
  color: #ccc;
  display: flex;
  align-items: center;
  padding: 4px 2px;
  border-radius: 3px;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.page-item-handle:hover {
  color: #888;
  background: #f0f0f0;
}

.page-item-handle:active {
  cursor: grabbing;
}

.page-item-step {
  font-size: 0.8rem;
  font-weight: 700;
  color: gray;
  min-width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.page-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-item-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: black;
}

.page-item-meta {
  font-size: 0.8rem;
  color: gray;
}

.page-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.page-item:hover .page-item-actions {
  opacity: 1;
}

/* Drag states */
.page-item.dragging {
  opacity: 0.4;
  border-style: dashed;
  border-color: #bbb;
}

.page-item.drag-over-above {
  border-top: 2px solid black;
  margin-top: -1px;
}

.page-item.drag-over-below {
  border-bottom: 2px solid black;
  margin-bottom: -1px;
}

/* Prevent pointer events on children during drag */
.page-list.dragging-active .page-item * {
  pointer-events: none;
}


/* =============================================================
   CSS CHANGES FOR admin.css — Study Detail & Participants Pages
   =============================================================
   
   INSTRUCTIONS:
   1. REMOVE these existing blocks (search for them):
      - .detail-url-bar { ... }
      - .detail-url-label { ... }
      - .detail-url-value { ... }
   
   2. ADD the following new CSS at the end of admin.css
      (before the page-list section)
   ============================================================= */


/* ===== CARD HEADER ENHANCEMENTS ===== */

.card-header-link {
  font-size: 0.75rem;
  font-weight: 600;
  color: gray;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: color 0.15s;
}

.card-header-link:hover {
  color: black;
}

.card-header-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 600;
  color: gray;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 4px 10px;
  border-radius: 3px;
  border: 1px solid #e0e0e0;
  background: white;
  transition: all 0.15s;
  white-space: nowrap;
  cursor: pointer;
}

.card-header-btn:hover {
  color: black;
  border-color: #ccc;
  background: #fafafa;
}

.card-header-btn svg {
  flex-shrink: 0;
}

/* Card header actions (multiple buttons) */
.card-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Danger variant of card-header-btn */
.card-header-btn--danger {
  color: #c62828;
  border-color: #f0c0c0;
  background: white;
}

.card-header-btn--danger:hover {
  color: white;
  border-color: #c62828;
  background: #c62828;
}

/* ===== URL DISPLAY (inside info-list) ===== */

.url-display {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.url-code {
  font-size: 0.85rem;
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
  color: black;
  background: #f5f5f5;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid #e8e8e8;
}

.url-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  background: white;
  color: gray;
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}

.url-copy-btn:hover {
  color: black;
  border-color: #ccc;
  background: #fafafa;
}

.url-copy-btn.copied {
  color: #2e7d32;
  border-color: #2e7d32;
  background: #f0faf0;
}

/* ===== ENHANCED STAT CARDS ===== */

.detail-stat--started {
  border-left: 3px solid #888;
}

.detail-stat--completed {
  border-left: 3px solid #1565c0;
}

.detail-stat--active {
  border-left: 3px solid #2e7d32;
}

.detail-stat--exited {
  border-left: 3px solid #c62828;
}

.detail-stat--started,
.detail-stat--completed,
.detail-stat--active,
.detail-stat--exited {
  text-align: left;
  padding-left: 14px;
}

/* ===== CARD FOOTER LINK ===== */

.card-footer-link {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid #f0f0f0;
  text-align: center;
}

.card-footer-link a {
  font-size: 0.8rem;
  font-weight: 600;
  color: gray;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: color 0.15s;
}

.card-footer-link a:hover {
  color: black;
}

/* ===== FLUSH TABLE (no card-body padding) ===== */

.data-table--flush {
  margin: 0;
}

.data-table--flush thead th:first-child,
.data-table--flush tbody td:first-child {
  padding-left: 20px;
}

.data-table--flush thead th:last-child,
.data-table--flush tbody td:last-child {
  padding-right: 20px;
}

/* ─── Inline Creation ─── */
.inline-create-card {
  margin-bottom: 24px;
  border: 2px dashed #d0d5dd;
  background: #fafbfc;
}
.inline-create-card .card-body {
  padding: 16px 20px;
}
.inline-create-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.inline-create-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.inline-create-input {
  font-size: 15px;
  padding: 10px 14px;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  width: 100%;
  background: #fff;
}
.inline-create-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.inline-create-slug-preview {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #667;
  padding: 2px 0;
}
.slug-preview-url {
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #555;
}
.slug-preview-url span {
  color: var(--accent);
  font-weight: 600;
}
.slug-edit-btn {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 13px;
  padding: 0 4px;
}
.slug-edit-btn:hover {
  color: var(--accent);
}
.inline-create-slug-input {
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  padding: 6px 10px;
  border: 1px solid #d0d5dd;
  border-radius: 4px;
  width: 100%;
  background: #fff;
}
#create-study-form {
  display: flex;
  align-items: flex-start;
  padding-top: 0;
}

/* ─── URL Prefix Setup ─── */
.prefix-setup-card {
  margin-bottom: 24px;
  border: 2px solid var(--accent);
  background: #f0f5ff;
}

.prefix-setup-card .card-body {
  padding: 20px 24px;
}

.prefix-setup-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.prefix-input-group {
  display: flex;
  align-items: center;
  gap: 0;
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  padding: 0 2px;
  flex: 1;
  max-width: 500px;
}

.prefix-input-label {
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: #888;
  padding: 8px 4px;
  white-space: nowrap;
}

.prefix-input {
  border: none;
  outline: none;
  font-size: 14px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-weight: 600;
  color: var(--accent);
  padding: 8px 2px;
  width: 120px;
  min-width: 80px;
  background: transparent;
}

.prefix-input:focus {
  outline: none;
}

/* ── Section divider within a form ── */
.admin-section-divider {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #888;
  border-top: 1px solid #e8e8e8;
  margin: 24px 0 18px;
  padding-top: 18px;
}

/* ── URL Parameters section (Recruitment tab) ── */
.url-params-section {
  margin-top: 28px;
  border-top: 1px solid #e8e8e8;
  padding-top: 20px;
}

.url-params-heading {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #555;
  margin: 0 0 6px;
}

/* ── Column header help tooltips ── */
.th-help {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted #aaa;
}

.th-help::after {
  content: attr(data-tip);
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 10;
  width: 260px;
  padding: 8px 10px;
  background: #333;
  color: #f5f5f5;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  border-radius: 4px;
  white-space: normal;
  text-transform: none;
  letter-spacing: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.th-help:hover::after {
  opacity: 1;
}

.url-params-table td code {
  background: #f3f4f6;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}

.url-params-empty-hint {
  font-size: 13px;
  color: #aaa;
  margin: 8px 0 10px;
}

/* Stabilise table layout so edit inputs don't reflow columns */
.url-params-table {
  width: 100%;
  margin-bottom: 0;
  table-layout: fixed;
}

.url-params-table .col-missing { width: 95px; }
.url-params-table .col-actions { width: 145px; }

/* Consistent cell padding and height for all rows (tbody + tfoot) */
.url-params-table td {
  padding: 6px 8px;
  height: 44px;
  vertical-align: middle;
}

.url-params-table td:last-child {
  text-align: right;
}

/* Add-row appearance */
.url-params-add-row td {
  background: #f9f9f9;
  border-top: 2px solid #e0e0e0;
}

/* Single input/select style for the entire table */
.url-params-table input,
.url-params-table select {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  font-size: 13px;
  padding: 5px 8px;
  height: 32px;
  border: 1px solid #ccc;
  border-radius: 3px;
  background: #fff;
  font-family: 'Open Sans', sans-serif;
  color: #333;
}

.url-params-table input:focus,
.url-params-table select:focus {
  outline: none;
  border-color: var(--accent, #333);
}

/* ── Missing params warning banner ── */
.missing-params-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #fffbeb;
  border: 1px solid #f59e0b;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 20px;
}

.missing-params-banner-icon {
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
  color: #d97706;
  margin-top: 1px;
}

.missing-params-banner-body {
  flex: 1;
  font-size: 13px;
  line-height: 1.5;
}

.missing-params-banner-body strong {
  display: block;
  margin-bottom: 4px;
  color: #92400e;
}

.missing-params-list {
  margin: 6px 0;
  font-size: 12px;
  color: #555;
}

.missing-params-list code {
  background: #fef3c7;
  padding: 1px 4px;
  border-radius: 3px;
}

.missing-params-hint {
  font-size: 12px;
  color: #78716c;
  margin-top: 4px;
}

.missing-params-dismiss {
  flex-shrink: 0;
  background: none;
  border: 1px solid #d97706;
  color: #92400e;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  align-self: center;
}

.missing-params-dismiss:hover {
  background: #fef3c7;
}

/* Missing behaviour badges in URL params table */
.param-behaviour-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e8e8e8;
  color: #666;
}

.param-behaviour-badge.badge-warn {
  background: #fef3c7;
  color: #92400e;
}

.param-behaviour-badge.badge-block {
  background: #fee2e2;
  color: #991b1b;
}

.warning-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  background: #fef3c7;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.warning-badge--error {
  background: #fee2e2;
  color: #991b1b;
}

/* ── URL param row edit mode ── */
.param-row-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}

.param-auto-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  background: #e0f0ff;
  color: #1565c0;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-left: 5px;
  vertical-align: middle;
}

/* ═══════════════════════════════════════════
   FACTORIAL DESIGN — Conditions Tab
   ═══════════════════════════════════════════ */

/* ── Mode Selection Cards ── */
.design-mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 540px) {
  .design-mode-cards { grid-template-columns: 1fr; }
}
.design-mode-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid #e0e0e0;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
}
.design-mode-card:hover { border-color: #bbb; }
.design-mode-card.active { border-color: #333; background: #fafafa; }
.design-mode-card-radio {
  flex-shrink: 0;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #ccc;
  display: flex; align-items: center; justify-content: center;
  margin-top: 1px;
  transition: border-color 0.15s;
}
.design-mode-card.active .design-mode-card-radio { border-color: #333; }
.design-mode-radio-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: transparent; transition: background 0.15s;
}
.design-mode-card.active .design-mode-radio-dot { background: #333; }
.design-mode-card-body { display: flex; flex-direction: column; gap: 3px; }
.design-mode-card-title { font-size: 0.88rem; font-weight: 700; color: #555; transition: color 0.15s; }
.design-mode-card.active .design-mode-card-title { color: #111; }
.design-mode-card-desc { font-size: 0.77rem; color: #aaa; line-height: 1.5; }

/* ── Section Labels ── */
.factorial-section-label {
  font-family: 'Saira Semi Condensed', sans-serif;
  font-size: 0.82rem; font-weight: 600; color: #555;
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 10px;
}

/* ── IV Cards ── */
/* ── IV Cards — compact side-by-side ── */
#iv-cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
}
.iv-card {
  border: 1px solid #e0e0e0; border-radius: 4px;
  padding: 8px 10px 6px; background: #fafafa;
}
.iv-card-header {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.iv-card-label {
  font-size: 0.66rem; font-weight: 600; color: #bbb;
  text-transform: uppercase; letter-spacing: 0.03em; flex-shrink: 0;
}
.iv-name-input {
  flex: 1; min-width: 0; font-size: 0.82rem; font-weight: 600;
  padding: 2px 5px; border: 1px solid #ddd; border-radius: 3px;
  background: white;
}
.iv-name-input:focus { border-color: #333; outline: none; }
.iv-remove-btn {
  background: none; border: none; font-size: 1rem;
  color: #ccc; cursor: pointer; padding: 0 4px; line-height: 1; flex-shrink: 0;
}
.iv-remove-btn:hover { color: #c00; }

/* ── Levels — compact rows ── */
.iv-level-row {
  display: flex; align-items: center; gap: 5px;
  padding: 2px 0;
}
.iv-level-num {
  color: #ccc; font-weight: 600; font-size: 0.72rem;
  width: 14px; text-align: right; flex-shrink: 0;
}
.iv-level-name-input {
  flex: 1; min-width: 0; padding: 2px 5px; border: 1px solid #ddd;
  border-radius: 3px; font-size: 0.8rem;
}
.iv-level-code-input {
  width: 62px; border: 1px solid #ddd;
  border-radius: 3px; font-size: 0.8rem; flex-shrink: 0;
  text-align: right;
}
.iv-level-row .number-input-wrap input[type="number"] {
  padding-left: 5px;
  padding-right: 34px;
  text-align: right;
}
.iv-level-row .number-input-wrap {
  flex: 0 0 62px; width: 62px;
}
.iv-level-name-input:focus, .iv-level-code-input:focus { border-color: #333; outline: none; }
.iv-level-remove-btn {
  background: none; border: none; font-size: 0.9rem;
  color: #ddd; cursor: pointer; padding: 0 2px; line-height: 1; flex-shrink: 0;
}
.iv-level-remove-btn:hover { color: #c00; }

/* ── Add links ── */
.add-level-link, .add-iv-link {
  display: inline-block; font-size: 0.76rem; color: #666;
  cursor: pointer; margin-top: 4px; text-decoration: none;
}
.add-level-link:hover, .add-iv-link:hover { color: #333; text-decoration: underline; }
.add-iv-link { margin-top: 4px; }

/* ── Generate Button ── */
.generate-btn { font-size: 0.82rem; padding: 7px 18px; }
.generate-hint {
  font-size: 0.74rem; color: #999; margin-top: 6px;
  line-height: 1.5;
}

/* ── Conditions Summary ── */
.conditions-summary { font-size: 0.78rem; color: #999; font-weight: 400; }

/* ── Design Grid ── */
.design-grid {
  display: grid; gap: 1px; background: #e0e0e0;
  border: 1px solid #e0e0e0; border-radius: 4px;
  overflow: visible; margin-bottom: 12px;
}
.grid-corner-label {
  background: #f5f5f5; padding: 8px;
  font-size: 0.68rem; font-weight: 600; color: #999;
  text-transform: uppercase; letter-spacing: 0.04em;
  display: flex; align-items: flex-end;
}
.grid-header-cell {
  background: #f5f5f5; padding: 8px; text-align: center;
  font-size: 0.78rem; font-weight: 600; color: #555;
}
.grid-header-iv {
  display: block; font-size: 0.66rem; color: #aaa;
  font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.03em; margin-bottom: 2px;
}
.grid-code { color: #aaa; font-weight: 400; font-size: 0.74rem; }
.grid-row-label {
  background: #f5f5f5; padding: 8px 10px;
  font-size: 0.78rem; font-weight: 600; color: #555;
  display: flex; align-items: center; gap: 4px;
}
.grid-cell { background: white; padding: 6px; overflow: visible; position: relative; }

/* ── Grid Layer (3 IVs) ── */
.design-grid-layer { margin-bottom: 16px; }
.design-grid-layer-label {
  font-size: 0.78rem; font-weight: 600; color: #666;
  margin-bottom: 6px; padding: 4px 0; border-bottom: 1px dashed #ddd;
}

/* ── Flat Cards ── */
.flat-cards-container { display: flex; flex-wrap: wrap; gap: 8px; }

/* ── Condition Cards ── */
.pop-wrapper { position: relative; }
.cond-card {
  border: 1px solid #e0e0e0; border-radius: 3px;
  padding: 8px 10px; cursor: pointer; position: relative;
  min-width: 90px; background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.cond-card:hover { border-color: #aaa; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.cond-card-number {
  display: block; font-size: 0.65rem; font-weight: 600; color: #bbb;
  text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 2px;
}
.cond-card-name {
  display: block; font-size: 13px; font-weight: 700; color: #333;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px;
}
.cond-card-mapping { display: block; font-size: 0.7rem; color: #999; margin-top: 2px; }
.cond-card-limit-pill {
  position: absolute; top: 4px; right: 6px;
  font-size: 0.62rem; font-weight: 600; color: #888;
  background: #f0f0f0; padding: 1px 5px; border-radius: 3px;
  transition: opacity 0.15s;
}
.cond-card:hover .cond-card-limit-pill { opacity: 0; }
.cond-card-edit-hint {
  position: absolute; top: 5px; right: 6px;
  font-size: 0.66rem; font-weight: 600; color: #888;
  opacity: 0; transition: opacity 0.15s;
}
.cond-card:hover .cond-card-edit-hint { opacity: 1; }

/* ── Popover ── */
.pop-box {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 100;
  background: white; border: 1px solid #ddd; border-radius: 5px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 14px 16px; min-width: 240px; max-width: 300px;
}
.pop-box::before {
  content: ''; position: absolute; top: -7px; left: 16px;
  width: 12px; height: 12px; background: white;
  border-left: 1px solid #ddd; border-top: 1px solid #ddd;
  transform: rotate(45deg);
}
.pop-header {
  font-size: 0.66rem; font-weight: 700; color: #aaa;
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px;
}
.pop-field { margin-bottom: 8px; }
.pop-field label { display: block; font-size: 0.72rem; font-weight: 600; color: #888; margin-bottom: 3px; }
.pop-field input[type="text"] {
  width: 100%; padding: 5px 8px; border: 1.5px solid #ddd;
  border-radius: 3px; font-size: 0.84rem;
}
.pop-field input:focus { border-color: #333; outline: none; }
.pop-mapping { font-size: 0.76rem; color: #777; line-height: 1.6; margin-bottom: 8px; padding: 4px 0; }
.pop-divider { border-top: 1px solid #eee; margin: 8px 0; }
.pop-limit-row { display: flex; align-items: center; gap: 10px; }
.pop-limit-row label { font-size: 0.76rem; font-weight: 600; color: #777; white-space: nowrap; }
.pop-limit-row input[type="number"] {
  padding: 4px 6px; border: 1.5px solid #ddd; border-radius: 3px; font-size: 0.82rem;
}
.pop-limit-row input:focus { border-color: #333; outline: none; }
.pop-limit-hint { font-size: 0.68rem; color: #aaa; margin-top: 4px; }

/* ── Extra Conditions ── */
.extra-conditions-section { margin-top: 16px; }
.extra-conditions-divider { border-top: 1px solid #eee; margin-bottom: 14px; }
.extra-cards-container { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.cond-card-extra {
  border: 1.5px dashed #ccc;
  background: #fafafa;
}
.cond-card-extra:hover {
  border-color: #999;
}
.extra-badge {
  display: inline-block; font-size: 0.6rem; font-weight: 700; color: #7c6f2a;
  background: #fef3c7; padding: 2px 6px; border-radius: 3px;
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 3px;
}

.extra-export-hint {
  font-size: 0.74rem; color: #999; line-height: 1.5;
  margin: 6px 0; font-style: italic;
}

/* ── Unsaved Changes Indicator ── */
.btn-save-changes.has-unsaved {
  position: relative;
}
.btn-save-changes.has-unsaved::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e65100;
  border: 2px solid white;
}

/* ── Save Toast ── */
.toast-success {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #2e7d32;
  color: white;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 9999;
  opacity: 1;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.toast-success.fade-out {
  opacity: 0;
}

/* ============================================================
   GETTING STARTED PANEL
   ============================================================ */

.getting-started-card {
  border: 1px solid #e0e7ef;
  border-left: 3px solid #2563eb;
  background: linear-gradient(135deg, #f8faff 0%, #fff 100%);
  margin-bottom: 20px;
}

.getting-started-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.getting-started-header h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 0;
  color: #1a1a1a;
}

.getting-started-header p {
  font-size: 13px;
  color: #666;
  margin: 4px 0 0 0;
}

.getting-started-dismiss {
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
  flex-shrink: 0;
}

.getting-started-dismiss:hover {
  background: #f0f0f0;
  color: #666;
}

.getting-started-steps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.getting-started-step {
  display: flex;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e8ecf1;
  transition: border-color 0.15s;
}

.getting-started-step:hover {
  border-color: #c0c8d4;
}

.getting-started-step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  margin-top: 1px;
}

.getting-started-step-content h4 {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 2px 0;
  color: #1a1a1a;
}

.getting-started-step-content p {
  font-size: 12px;
  color: #777;
  margin: 0;
  line-height: 1.4;
}

.getting-started-footer {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}

.getting-started-footer a {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
}

.getting-started-footer a:hover {
  text-decoration: underline;
}

/* ============================================================
   GUIDE PAGE
   ============================================================ */

.guide-toc {
  margin-bottom: 24px;
}

.guide-toc-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.guide-toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 6px;
}

.guide-toc-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #333;
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s;
}

.guide-toc-link:hover {
  background: #f0f4f8;
}

.guide-toc-link svg {
  color: #888;
  flex-shrink: 0;
}

.guide-topic {
  margin-bottom: 20px;
  scroll-margin-top: 80px;
}

.guide-topic-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}

.guide-topic-header svg {
  color: #2563eb;
  flex-shrink: 0;
}

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

.guide-section {
  margin-bottom: 20px;
}

.guide-section:last-child {
  margin-bottom: 0;
}

.guide-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: #333;
}

.guide-section p {
  font-size: 14px;
  line-height: 1.65;
  color: #444;
  margin: 0 0 10px 0;
}

.guide-section p:last-child {
  margin-bottom: 0;
}

.guide-section ol,
.guide-section ul {
  font-size: 14px;
  line-height: 1.65;
  color: #444;
  padding-left: 24px;
  margin: 8px 0;
}

.guide-section li {
  margin-bottom: 4px;
}

.guide-section strong {
  color: #222;
}

.guide-section code {
  background: #f0f4f8;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 13px;
  color: #d63384;
}

.guide-back-top {
  text-align: center;
  padding: 16px 0 8px 0;
}

.guide-back-top a {
  color: #888;
  text-decoration: none;
  font-size: 13px;
}

.guide-back-top a:hover {
  color: #333;
}

/* ============================================================
   CONTEXTUAL HELP LINK
   ============================================================ */

.help-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #999;
  text-decoration: none;
  transition: color 0.15s;
}

.help-link:hover {
  color: #2563eb;
}

.help-link svg {
  flex-shrink: 0;
}

/* Help link in builder topbar */
.builder-help-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: #999;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  margin-left: 4px;
}

.builder-help-link:hover {
  background: rgba(0,0,0,0.08);
  color: #333;
}

/* ============================================================
   DASHBOARD FOLDER SIDEBAR
   ============================================================ */

/* ─── Layout wrapper ─── */
.dashboard-with-sidebar {
  display: flex;
  height: calc(100vh - 52px);
  overflow: hidden;
}

.dashboard-with-sidebar.sidebar-collapsed {
  display: block;
  height: auto;
  overflow: visible;
}

.dashboard-content {
  flex: 1;
  min-width: 0;
  max-width: 1100px;
  padding: 24px 32px;
  overflow-y: auto;
}

/* When sidebar is collapsed, content inherits normal admin-main centering */
.dashboard-with-sidebar.sidebar-collapsed .dashboard-content {
  max-width: none;
  padding: 0;
  overflow-y: visible;
}

/* ─── Sidebar ─── */
.dashboard-sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid #e0e0e0;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: white;
}

.dashboard-with-sidebar.sidebar-collapsed .dashboard-sidebar,
.dashboard-with-sidebar.sidebar-collapsed .sidebar-backdrop {
  display: none;
}

/* Toggle button in page header */
.page-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-toggle-btn {
  background: none;
  border: 1px solid #d0d0d0;
  border-radius: 3px;
  cursor: pointer;
  padding: 5px 7px;
  color: #666;
  display: flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.sidebar-toggle-btn:hover {
  color: #333;
  border-color: #999;
  background: #f5f5f5;
}

.dashboard-with-sidebar:not(.sidebar-collapsed) .sidebar-toggle-btn {
  background: #333;
  color: white;
  border-color: #333;
}

/* ─── Sidebar header ─── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 10px 0;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #999;
}

.sidebar-actions {
  display: flex;
  gap: 2px;
}

.sidebar-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  padding: 3px 5px;
  color: #999;
  display: flex;
  align-items: center;
  transition: color 0.15s, border-color 0.15s;
}

.sidebar-btn:hover {
  color: #333;
  border-color: #ccc;
}

/* ─── Sidebar body ─── */
.sidebar-body {
  flex: 1;
  overflow-y: auto;
}

/* ─── Sidebar items ─── */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 3px;
  background: none;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.82rem;
  color: #444;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s, color 0.1s;
  position: relative;
}

.sidebar-item:hover {
  background: #f0f0f0;
  color: #111;
}

.sidebar-item.active {
  background: #e8e8e8;
  color: #111;
  font-weight: 600;
}

.sidebar-item-icon {
  flex-shrink: 0;
  opacity: 0.5;
}

.sidebar-item.active .sidebar-item-icon {
  opacity: 0.8;
}

.sidebar-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-item-count {
  font-size: 0.7rem;
  color: #aaa;
  flex-shrink: 0;
}

.sidebar-item.active .sidebar-item-count {
  color: #666;
}

/* ─── Folder context menu button ─── */
.sidebar-folder-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 3px;
  color: #ccc;
  border-radius: 3px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.sidebar-folder:hover .sidebar-folder-menu-btn,
.sidebar-folder:focus-within .sidebar-folder-menu-btn {
  opacity: 1;
}

.sidebar-folder-menu-btn:hover {
  color: #333;
  background: rgba(0,0,0,0.06);
}

/* ─── Sidebar divider ─── */
.sidebar-divider {
  height: 1px;
  background: #e8e8e8;
  margin: 6px 0;
}

/* ─── Sidebar sort ─── */
.sidebar-sort-row {
  padding: 0 0 4px 0;
}

.sidebar-sort {
  width: 100%;
  padding: 3px 6px;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  font-size: 0.72rem;
  font-family: 'Open Sans', sans-serif;
  color: #666;
  background: white;
  cursor: pointer;
}

.sidebar-sort:hover {
  border-color: #bbb;
}

/* ─── Archived section ─── */
.sidebar-archived-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 5px 8px;
  border: none;
  background: none;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.75rem;
  color: #999;
  cursor: pointer;
  text-align: left;
  transition: color 0.15s;
}

.sidebar-archived-toggle:hover {
  color: #555;
}

.sidebar-chevron {
  transition: transform 0.15s;
  flex-shrink: 0;
}

.sidebar-archived-toggle.expanded .sidebar-chevron {
  transform: rotate(90deg);
}

.sidebar-archived-list {
  padding-left: 4px;
}

/* ─── Inline folder creation ─── */
.sidebar-folder-input-row {
  padding: 2px 0;
}

.sidebar-folder-input {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid #1565c0;
  border-radius: 3px;
  font-size: 0.82rem;
  font-family: 'Open Sans', sans-serif;
  outline: none;
  background: #f8fbff;
}

.sidebar-rename-input {
  flex: 1;
  min-width: 0;
  padding: 2px 6px;
  margin: -2px 0;
}

/* ─── Folder context menu ─── */
.folder-ctx-menu {
  position: fixed;
  z-index: 300;
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 4px 0;
  min-width: 140px;
}

.folder-ctx-btn {
  display: block;
  width: 100%;
  padding: 7px 14px;
  border: none;
  background: none;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.82rem;
  color: #333;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.folder-ctx-btn:hover {
  background: #f0f0f0;
}

.folder-ctx-btn--danger {
  color: #c62828;
}

.folder-ctx-btn--danger:hover {
  background: #fef0f0;
}

.folder-ctx-divider {
  height: 1px;
  background: #e8e8e8;
  margin: 4px 0;
}

/* ─── Move-to-folder menu ─── */
.move-folder-menu {
  position: fixed;
  z-index: 300;
  background: white;
  border: 1px solid #d0d0d0;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  padding: 4px 0;
  min-width: 180px;
  max-height: 300px;
  overflow-y: auto;
}

.move-folder-menu-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #999;
  padding: 6px 14px 4px;
}

.move-folder-option {
  display: block;
  width: 100%;
  padding: 6px 14px;
  border: none;
  background: none;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.82rem;
  color: #333;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}

.move-folder-option:hover {
  background: #f0f0f0;
}

.move-folder-option.active {
  font-weight: 600;
  color: #1565c0;
}

/* ─── Move folder button in study rows ─── */
.btn-icon.btn-move-folder {
  color: #bbb;
}

.btn-icon.btn-move-folder:hover {
  color: #333;
  border-color: #ccc;
}

/* ─── Sidebar backdrop (mobile) ─── */
.sidebar-backdrop {
  display: none;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  /* On mobile, sidebar becomes a fixed overlay */
  .dashboard-with-sidebar:not(.sidebar-collapsed) .dashboard-sidebar {
    position: fixed;
    top: 52px;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 200;
    margin-right: 0;
    box-shadow: 4px 0 16px rgba(0,0,0,0.1);
  }

  .dashboard-with-sidebar:not(.sidebar-collapsed) .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    top: 52px;
    z-index: 199;
    background: rgba(0,0,0,0.3);
  }

  /* Wrapper reverts to normal flow on mobile — no fixed height */
  .dashboard-with-sidebar {
    height: auto;
    overflow: visible;
  }

  .dashboard-content {
    overflow-y: visible;
    padding: 16px;
  }

  /* admin-main override not needed on mobile — sidebar is an overlay */
  .admin-main:has(.dashboard-with-sidebar:not(.sidebar-collapsed)) {
    max-width: 1100px;
    padding: 16px;
    overflow: visible;
  }
}
