:root {
  --bg: #f4f6f9;
  --surface: #fff;
  --text: #1a1a1a;
  --text-muted: #5a6a7a;
  --border: #d4dbe4;
  --primary: #3c6db7;
  --primary-hover: #2d5a9e;
  --accent: #ba5b15;
  --accent-hover: #a04e12;
  --danger: #c42b2b;
  --success: #1a7a3a;
  --warning: #ba5b15;
  --info: #3c6db7;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

#app { min-height: 100vh; }
#loading { display: flex; justify-content: center; align-items: center; height: 100vh; font-size: 1.1rem; color: var(--text-muted); }

/* Nav */
.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { color: var(--text-muted); text-decoration: none; font-size: 0.9rem; font-weight: 500; }
.nav-links a:hover, .nav-links a.active { color: var(--primary); }
.nav-links button { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: 1rem; }
.card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-muted); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.3rem; color: var(--text-muted); }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60,109,183,0.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; padding: 0.6rem 0.8rem; font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); border-bottom: 2px solid var(--border); }
td { padding: 0.6rem 0.8rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: rgba(0,0,0,0.015); }
.clickable-row { cursor: pointer; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-awaiting { background: #fdf0e2; color: #ba5b15; }
.badge-ready { background: #e1eaf6; color: #2d5a9e; }
.badge-generated { background: #ddf1e4; color: #1a7a3a; }
.badge-delivered { background: #d6dfe8; color: #2d4a6e; }

/* Search/filter bar */
.filters {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.filters input, .filters select {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
}
.filters input { flex: 1; min-width: 200px; }

/* Login */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 360px;
  box-shadow: var(--shadow);
  text-align: center;
}
.login-card h1 { font-size: 1.3rem; margin-bottom: 0.3rem; }
.login-card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.5rem; }
.login-card .btn { width: 100%; justify-content: center; }
.login-error { color: var(--danger); font-size: 0.85rem; margin-bottom: 0.75rem; }

/* Diff modal */
.modal-backdrop {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center;
  z-index: 200;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  width: 90%; max-width: 900px; max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h2 { font-size: 1.1rem; }
.modal-body { padding: 1.5rem; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 0.5rem;
}
.diff-container { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.diff-side { font-size: 0.85rem; }
.diff-side h4 { font-size: 0.8rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.5rem; }
.diff-old { background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; padding: 0.75rem; white-space: pre-wrap; }
.diff-new { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 6px; padding: 0.75rem; white-space: pre-wrap; }

/* Content edit field */
.content-field { margin-bottom: 1.25rem; }
.content-field-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.3rem;
}
.content-field-header label { font-weight: 600; font-size: 0.85rem; }
.modified-badge { background: #fdf0e2; color: #ba5b15; font-size: 0.7rem; padding: 0.1rem 0.4rem; border-radius: 4px; font-weight: 600; }
.content-field textarea {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.85rem;
  font-family: inherit;
  resize: vertical;
  min-height: 100px;
}
.content-field textarea.modified { border-color: var(--warning); background: #fdf6ef; }
.content-field-actions { display: flex; gap: 0.5rem; margin-top: 0.3rem; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab {
  padding: 0.6rem 1.2rem;
  border: none; background: none;
  font-size: 0.9rem; font-weight: 500;
  cursor: pointer; color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Grid */
.grid-selector { display: flex; gap: 1rem; margin-bottom: 1.5rem; }
.grid-selector select { padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; }

/* Utility */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.hidden { display: none; }

/* Enneagram badge buttons */
.enneagram-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.enneagram-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: transparent;
  color: var(--primary);
  font-weight: 700; font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.enneagram-btn:hover { background: rgba(60,109,183,0.15); }
.enneagram-btn.selected { background: var(--primary); color: #fff; }

/* Advantage colored badges */
.advantage-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
  color: #fff;
  white-space: nowrap;
}
.advantage-badge .deselect {
  background: none; border: none; color: #fff;
  font-size: 1rem; line-height: 1; cursor: pointer;
  padding: 0; margin-left: 0.15rem; opacity: 0.8;
}
.advantage-badge .deselect:hover { opacity: 1; }

/* Advantage badge buttons (outline / selectable) */
.advantage-btn-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.advantage-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem; font-weight: 600;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border-width: 2px; border-style: solid;
}
.advantage-btn:hover { opacity: 0.85; }

/* Advantage placeholder text */
.advantage-placeholder {
  font-size: 0.85rem; color: var(--text-muted); font-style: italic;
}

/* Archetype autocomplete */
.archetype-autocomplete { position: relative; }
.archetype-autocomplete input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem; font-family: inherit;
}
.archetype-autocomplete input[type="text"]:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60,109,183,0.15);
}
.archetype-dropdown {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 240px; overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 50;
  display: none;
}
.archetype-dropdown.open { display: block; }
.archetype-option {
  padding: 0.5rem 0.75rem;
  cursor: pointer; font-size: 0.85rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.archetype-option:hover { background: var(--bg); }
.advantage-dot {
  display: inline-block; width: 10px; height: 10px;
  border-radius: 50%; flex-shrink: 0;
}
.advantage-dots { display: flex; gap: 3px; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== UX Polish ===== */

/* Better touch targets and active states */
.btn { min-height: 36px; }
.btn:active { transform: scale(0.97); }
.btn-sm { min-height: 30px; }
.clickable-row:active td { background: rgba(60,109,183,0.06); }

/* Disabled inputs stand out as read-only */
.form-group input:disabled {
  background: var(--bg); color: var(--text-muted);
  cursor: default; border-color: transparent;
}

/* Card section header with subtle divider */
.card + .card { margin-top: 0.5rem; }
.card h2 { padding-bottom: 0.6rem; border-bottom: 1px solid var(--border); }

/* Smooth archetype dropdown appearance */
.archetype-dropdown.open { animation: fadeSlideDown 0.12s ease-out; }
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Enneagram/advantage buttons: better touch area */
.enneagram-btn { min-width: 36px; min-height: 36px; }
.advantage-btn { min-height: 32px; padding: 0.3rem 0.85rem; }

/* Save status text */
.ml-2 { margin-left: 0.75rem; }

/* ===== Responsive ===== */

@media (max-width: 768px) {
  /* Nav: shrink padding, smaller text */
  .nav { padding: 0 1rem; height: 48px; }
  .nav-brand { font-size: 1rem; }
  .nav-links { gap: 0.75rem; }
  .nav-links a, .nav-links button { font-size: 0.8rem; }

  /* Layout */
  .container { padding: 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .page-header h1 { font-size: 1.25rem; }

  /* Cards */
  .card { padding: 1rem; }

  /* Forms: single column on mobile */
  .form-row, .form-row-3 { grid-template-columns: 1fr; gap: 0; }

  /* Table: let it scroll, but improve readability */
  table { font-size: 0.8rem; }
  th, td { padding: 0.5rem 0.6rem; }

  /* Filters: full width stack */
  .filters { flex-direction: column; }
  .filters input { min-width: 0; width: 100%; }
  .filters select { width: 100%; }

  /* Login card: don't overflow */
  .login-card { width: calc(100% - 2rem); max-width: 360px; padding: 1.5rem; }

  /* Modal: tighter on mobile */
  .modal { width: 95%; max-height: 90vh; }
  .modal-header, .modal-body, .modal-footer { padding: 0.75rem 1rem; }
  .diff-container { grid-template-columns: 1fr; }

  /* Tabs: scrollable */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab { white-space: nowrap; padding: 0.5rem 0.9rem; font-size: 0.8rem; }

  /* Report action buttons: stack */
  .card .flex.gap-1 { flex-wrap: wrap; }

  /* Enneagram row: tighter gap on small screens */
  .enneagram-row { gap: 0.35rem; }
  .enneagram-btn { width: 34px; height: 34px; font-size: 0.8rem; }

  /* Advantage badges: wrap nicely */
  .advantage-btn-row { gap: 0.35rem; }
  .advantage-btn { font-size: 0.75rem; padding: 0.25rem 0.6rem; }
}

/* ===== Zone Dividers ===== */

.zone-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 32px 0 8px 0;
  padding: 0;
}
.zone-divider h2 {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  white-space: nowrap;
  margin: 0;
  border-bottom: none;
  padding-bottom: 0;
}
.zone-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.zone-description {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 16px 0;
  padding: 0;
}

/* ===== Sections Editor ===== */

.sections-editor { margin-top: 0; }
.sections-editor h3 {
  font-size: 0.95rem; font-weight: 600;
  color: var(--primary); margin-bottom: 0.75rem;
  padding-bottom: 0.4rem; border-bottom: 1px solid var(--border);
}

/* Editable list items (Built For, Growth Edge) */
.section-list-item {
  display: flex; gap: 0.5rem; align-items: flex-start;
  margin-bottom: 0.5rem;
}
.section-list-item textarea {
  flex: 1; min-height: 40px; resize: vertical;
  padding: 0.4rem 0.6rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.85rem; font-family: inherit;
}
.section-list-item textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60,109,183,0.15);
}
.section-list-item .remove-item-btn {
  flex-shrink: 0; width: 30px; height: 30px;
  border: 1px solid var(--border); border-radius: 6px;
  background: transparent; color: var(--danger);
  font-size: 1.1rem; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  margin-top: 4px;
}
.section-list-item .remove-item-btn:hover { background: #fef2f2; }

/* Watch Out editor cards */
.watchout-editor-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 0.75rem;
  background: #fafbfc;
}
.watchout-editor-card .watchout-editor-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.watchout-editor-card .watchout-editor-header span {
  font-weight: 600; font-size: 0.85rem; color: var(--primary);
}
.watchout-editor-card .form-group { margin-bottom: 0.6rem; }
.watchout-editor-card .form-group label {
  display: block; font-size: 0.8rem; font-weight: 500;
  margin-bottom: 0.2rem; color: var(--text-muted);
}
.watchout-editor-card .form-group input,
.watchout-editor-card .form-group textarea {
  width: 100%; padding: 0.4rem 0.6rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.85rem; font-family: inherit;
}
.watchout-editor-card .form-group textarea { resize: vertical; min-height: 60px; }
.watchout-editor-card .form-group input:focus,
.watchout-editor-card .form-group textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60,109,183,0.15);
}

/* Alignment editor cards */
.alignment-editor-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 0.75rem;
  background: #fafbfc;
}
.alignment-editor-card .alignment-editor-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.alignment-editor-card .alignment-editor-header span {
  font-weight: 600; font-size: 0.85rem; color: var(--primary);
}
.alignment-editor-card .form-group { margin-bottom: 0.6rem; }
.alignment-editor-card .form-group label {
  display: block; font-size: 0.8rem; font-weight: 500;
  margin-bottom: 0.2rem; color: var(--text-muted);
}
.alignment-editor-card .form-group input,
.alignment-editor-card .form-group textarea {
  width: 100%; padding: 0.4rem 0.6rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.85rem; font-family: inherit;
}
.alignment-editor-card .form-group textarea { resize: vertical; min-height: 60px; }
.alignment-editor-card .form-group input:focus,
.alignment-editor-card .form-group textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60,109,183,0.15);
}

/* Add item button */
.add-item-btn {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.4rem 0.85rem; border: 1px dashed var(--primary);
  border-radius: 6px; background: transparent;
  color: var(--primary); font-size: 0.8rem; font-weight: 500;
  cursor: pointer; margin-top: 0.25rem;
}
.add-item-btn:hover { background: rgba(60,109,183,0.06); }

/* Closing quote textarea */
.closing-quote-textarea {
  width: 100%; min-height: 80px; resize: vertical;
  padding: 0.6rem; border: 1px solid var(--border);
  border-radius: 6px; font-size: 0.85rem; font-family: inherit;
  font-style: italic;
}
.closing-quote-textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60,109,183,0.15);
}

@media (max-width: 768px) {
  .watchout-editor-card, .alignment-editor-card { padding: 0.75rem; }
  .section-list-item textarea { min-height: 36px; }
}

@media (max-width: 480px) {
  /* Even tighter on very small phones */
  .nav-links { gap: 0.5rem; }
  .container { padding: 0.75rem; }
  .card { padding: 0.75rem; }
  .btn { font-size: 0.8rem; padding: 0.4rem 0.75rem; }
  .page-header h1 { font-size: 1.1rem; }
  .watchout-editor-card, .alignment-editor-card { padding: 0.5rem; }
}

/* ===== Drift Detection ===== */

.drift-banner {
  display: flex; align-items: center; gap: 0.75rem;
  background: #fdf6e8; border: 1px solid #f0d68a;
  border-radius: var(--radius); padding: 0.75rem 1rem;
  margin-bottom: 1rem; font-size: 0.85rem; color: #7a5d12;
}
.drift-banner-icon {
  flex-shrink: 0; width: 20px; height: 20px;
  background: #e8a817; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 0.75rem;
}
.drift-banner-text { flex: 1; }
.drift-banner .btn { flex-shrink: 0; }

.drift-indicator {
  display: inline-flex; align-items: center; justify-content: center;
  width: 8px; height: 8px; border-radius: 50%;
  background: #e8a817; margin-left: 6px; cursor: pointer;
  position: relative; flex-shrink: 0;
}
.drift-indicator:hover { background: #d49a0e; }

.drift-popover {
  position: absolute; top: 100%; left: -100px; z-index: 60;
  width: 320px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 0.75rem; font-size: 0.8rem;
  margin-top: 6px;
}
.drift-popover-label {
  font-weight: 600; font-size: 0.7rem;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); margin-bottom: 0.3rem;
}
.drift-popover-value {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 0.4rem 0.5rem;
  white-space: pre-wrap; max-height: 120px; overflow-y: auto;
  margin-bottom: 0.5rem; font-size: 0.8rem;
}
.drift-popover-value.snapshot { border-left: 3px solid #e8a817; }
.drift-popover-value.current { border-left: 3px solid var(--primary); }

/* ===== Pre-fill Badge ===== */

.prefill-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: #e8f4ea; color: #1a7a3a;
  font-size: 0.7rem; font-weight: 600;
  padding: 0.15rem 0.5rem; border-radius: 4px;
  margin-left: 0.5rem;
}

/* ===== Scope Selection Modal ===== */

.scope-modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); display: flex;
  justify-content: center; align-items: center; z-index: 200;
}
.scope-modal-content {
  background: var(--surface); border-radius: var(--radius);
  width: 90%; max-width: 480px; padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.scope-modal-content h2 {
  font-size: 1.1rem; margin-bottom: 0.5rem;
  padding-bottom: 0; border-bottom: none;
}
.scope-modal-content p {
  font-size: 0.85rem; color: var(--text-muted); margin-bottom: 1rem;
}
.scope-option {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem; margin-bottom: 0.5rem;
  border: 2px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.scope-option:hover { border-color: var(--primary); background: rgba(60,109,183,0.03); }
.scope-option.selected { border-color: var(--primary); background: rgba(60,109,183,0.06); }
.scope-option input[type="radio"] { flex-shrink: 0; accent-color: var(--primary); }
.scope-option-label { font-weight: 600; font-size: 0.9rem; }
.scope-option-desc { font-size: 0.8rem; color: var(--text-muted); }
.scope-modal-actions {
  display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem;
}

/* ===== Defaults Admin ===== */

.defaults-section-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem;
  margin-bottom: 0.75rem;
}
.defaults-section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.75rem;
}
.defaults-section-header h3 {
  font-size: 0.95rem; font-weight: 600; color: var(--text);
  margin: 0; padding: 0; border: none;
}
.scope-type-badge {
  display: inline-block; padding: 0.15rem 0.5rem;
  border-radius: 4px; font-size: 0.7rem; font-weight: 600;
  background: #e1eaf6; color: #2d5a9e;
}
.defaults-table { width: 100%; }
.defaults-table th { font-size: 0.75rem; }
.defaults-table td { font-size: 0.85rem; }
.defaults-table textarea {
  width: 100%; min-height: 50px; resize: vertical;
  padding: 0.3rem 0.5rem; border: 1px solid var(--border);
  border-radius: 4px; font-size: 0.8rem; font-family: inherit;
}
.defaults-table textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60,109,183,0.15);
}
.defaults-section-header h2 {
  font-size: 1.05rem; font-weight: 600; color: var(--text);
  margin: 0; padding: 0; border: none;
}
.default-value-preview {
  cursor: pointer; padding: 0.25rem 0.4rem;
  border-radius: 4px; font-size: 0.85rem;
  white-space: pre-wrap; word-break: break-word;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.default-value-preview:hover {
  background: var(--bg); border-color: var(--border);
}
.default-edit-textarea {
  width: 100%; min-height: 80px; resize: vertical;
  padding: 0.4rem 0.5rem; border: 1px solid var(--primary);
  border-radius: 4px; font-size: 0.85rem; font-family: inherit;
  box-shadow: 0 0 0 3px rgba(60,109,183,0.15);
}
.defaults-table select {
  padding: 0.25rem 0.4rem; border: 1px solid var(--border);
  border-radius: 4px; font-size: 0.8rem; background: var(--surface);
}
.defaults-table select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(60,109,183,0.15);
}
.defaults-table code {
  background: var(--bg); padding: 0.1rem 0.3rem;
  border-radius: 3px; font-size: 0.8rem;
}
.mapping-unconfigured {
  background: #fffbf0;
}
