:root {
  --bg: #EEF1F8;
  --bg-accent: #E4E9F5;
  --card-bg: #FFFFFF;
  --primary: #1F3864;
  --primary-h: #2E5299;
  --primary-soft: #EAF0FA;
  --success: #1E6B3A;
  --success-bg: #EAF6EE;
  --error: #9C2020;
  --error-bg: #FBECEC;
  --text: #1A1A2E;
  --subtext: #6B7280;
  --border: #DCE3EF;
  --tag-bg: #E8EEF7;
  --radius: 10px;
  --radius-sm: 7px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(23, 43, 77, 0.06);
  --shadow-md: 0 6px 20px rgba(23, 43, 77, 0.08);
  --shadow-lg: 0 12px 32px rgba(23, 43, 77, 0.12);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background:
    radial-gradient(1100px 480px at 50% -120px, var(--bg-accent), transparent),
    var(--bg);
  font-family: 'Segoe UI', system-ui, -apple-system, Tahoma, sans-serif;
  color: var(--text);
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
}
.container {
  width: 100%;
  max-width: 960px;
  margin: 28px 16px;
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.bar {
  background: linear-gradient(135deg, var(--primary), var(--primary-h));
  padding: 26px 24px 22px;
  text-align: center;
}
.bar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.01em;
}
.bar p {
  margin: 5px 0 0;
  font-size: 12px;
  color: #C0D3EC;
  letter-spacing: 0.03em;
}

.body { padding: 26px 24px 30px; }
.section {
  font-size: 11px;
  font-weight: 700;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 22px 0 8px;
}
.section:first-child { margin-top: 0; }

.preview-toggle-bar { display: flex; justify-content: flex-end; margin-bottom: 14px; }
.preview-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--primary);
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, border-color .15s ease, transform .1s ease;
}
.preview-toggle:hover { background: #DCE6F4; border-color: #C3CEE1; }
.preview-toggle:active { transform: translateY(1px); }
.collapsible-arrow {
  display: inline-block;
  font-size: 9px;
  transition: transform .2s ease;
}
#modPreviewColumn.collapsed { display: none; }
.mod-grid.full-width { grid-template-columns: 1fr; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
input[type=text],
input[type=time],
input[type=date],
textarea,
select {
  width: 100%;
  font-size: 13.5px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  font-family: inherit;
  background: #FDFEFF;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type=text]:hover,
input[type=time]:hover,
input[type=date]:hover,
textarea:hover,
select:hover { border-color: #C3CEE1; }
input[type=text]:focus,
input[type=time]:focus,
input[type=date]:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 56, 100, 0.12);
}
input[type=date] { color-scheme: light; }
textarea { resize: vertical; }
.hint { font-size: 10.5px; color: var(--subtext); margin: 5px 0 0; }

.preview {
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--subtext);
  white-space: pre-line;
  padding: 4px 2px;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.field .hint { margin: 5px 0 0; }
.field-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.field-label-row label { margin-bottom: 0; }
.required-badge {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--error);
  background: var(--error-bg);
  border: 1px solid rgba(156, 32, 32, 0.2);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-crear {
  width: 100%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 16px;
  box-shadow: var(--shadow-sm);
  transition: background .15s ease, box-shadow .15s ease, transform .1s ease;
}
.btn-crear:hover { background: var(--primary-h); box-shadow: var(--shadow-md); }
.btn-crear:active { transform: translateY(1px); }
.btn-crear:disabled { opacity: 0.6; cursor: default; box-shadow: none; }

.status {
  font-size: 12.5px;
  color: var(--subtext);
  margin-top: 12px;
  white-space: pre-line;
  line-height: 1.5;
}
.status.success,
.status.error {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.status.success { color: var(--success); background: var(--success-bg); border-color: rgba(30, 107, 58, 0.18); }
.status.error { color: var(--error); background: var(--error-bg); border-color: rgba(156, 32, 32, 0.18); }

.btn-secundario {
  width: 100%;
  background: var(--tag-bg);
  color: var(--primary);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-top: 10px;
  transition: background .15s ease, border-color .15s ease;
}
.btn-secundario:hover { background: #DCE6F4; border-color: #C3CEE1; }
.btn-secundario:disabled { opacity: 0.6; cursor: default; }

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
}
.field label.checkbox-item {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 0;
  transition: opacity .15s ease;
}
.checkbox-item input {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
}
.field label.checkbox-item.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.checkbox-item.is-disabled input { cursor: not-allowed; }

.combobox { position: relative; }
.combobox-list {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--card-bg);
  border: 1px solid var(--border);
  max-height: 190px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 4px;
}
.combobox-list.open { display: block; }
.combobox-item {
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .1s ease;
}
.combobox-item:hover,
.combobox-item.active { background: var(--primary-soft); }

.multicombobox { position: relative; }
.multicombobox input[type=text] { margin: 0; }
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips:not(:empty) { margin-bottom: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--tag-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 6px 4px 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--primary);
}
.chip button {
  background: none;
  border: none;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--subtext);
  cursor: pointer;
}
.chip button:hover { color: var(--error); }
.multicombobox.is-disabled { opacity: 0.5; }
.multicombobox.is-disabled input[type=text] { cursor: not-allowed; }

.field label.switch-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  margin: 0 0 8px;
}
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 21px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  inset: 0;
  background: #C7D0E0;
  border-radius: var(--radius-pill);
  transition: background .15s ease;
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 15px;
  width: 15px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform .15s ease;
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(17px); }

.campos-raw {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 11px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 480px;
  overflow-y: auto;
  margin: 0;
  background: #F7F9FC;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.descripcion-preview {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  max-height: 480px;
  overflow-y: auto;
  background: #F7F9FC;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.descripcion-preview .wiki-p { margin: 0; }
.descripcion-preview .wiki-gap { height: 10px; }
.descripcion-preview .wiki-heading {
  margin: 4px 0 6px;
  font-weight: 700;
  color: var(--primary);
}
.descripcion-preview h1.wiki-heading { font-size: 16px; }
.descripcion-preview h2.wiki-heading { font-size: 14.5px; }
.descripcion-preview h3.wiki-heading { font-size: 13.5px; }
.descripcion-preview a { color: var(--primary); }
.descripcion-preview .wiki-table {
  border-collapse: collapse;
  width: 100%;
  margin: 4px 0 10px;
  font-size: 11.5px;
}
.descripcion-preview .wiki-table th,
.descripcion-preview .wiki-table td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: left;
}
.descripcion-preview .wiki-table th {
  background: var(--tag-bg);
  font-weight: 600;
}

.mod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  align-items: start;
}
