
:root {
  --imega-primary: #1E3A5F;
  --imega-secondary: #465A6D;
  --imega-text: #1F242B;
  --imega-surface: #E6E9ED;
  --imega-bg: #F5F7F9;
  --imega-accent: #C62828;
  --imega-success: #2E7D32;
  --imega-warning: #E68A00;
  --imega-info: #1E3A5F;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  color: var(--imega-text);
  background: var(--imega-bg);
  margin: 0;
  padding: 0;
}

/* ===== Header ===== */
.site-header {
  background: var(--imega-primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-logo { height: 36px; vertical-align: middle; }
.main-nav { display: flex; gap: 28px; }
.main-nav a {
  color: white;
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: border-color .2s;
}
.main-nav a:hover { border-color: white; }

/* ===== Layout ===== */
.layout {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 28px;
}

/* ===== Sidebar ===== */
.sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  background: white;
  border: 1px solid var(--imega-surface);
  border-radius: 6px;
  padding: 18px;
  font-size: 13px;
}
.sidebar h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--imega-secondary);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--imega-surface);
}
.sidebar-section { margin-bottom: 16px; }
.sidebar-section-title {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--imega-secondary);
  margin-bottom: 6px;
  font-weight: 600;
}
.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar li {
  padding: 4px 0;
  border-bottom: 1px dashed transparent;
}
.sidebar li a {
  color: var(--imega-text);
  text-decoration: none;
  display: block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.4;
}
.sidebar li a:hover { background: var(--imega-surface); }
.sidebar li.active > a {
  background: var(--imega-primary);
  color: white;
  font-weight: 500;
}
.sidebar .code {
  display: inline-block;
  background: var(--imega-surface);
  color: var(--imega-secondary);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: "Menlo", "Consolas", monospace;
  font-size: 11px;
  margin-right: 4px;
}

/* ===== Document ===== */
.document {
  background: white;
  border: 1px solid var(--imega-surface);
  border-radius: 6px;
  padding: 36px 48px;
  min-height: 60vh;
}
.breadcrumb {
  font-size: 13px;
  color: var(--imega-secondary);
  margin-bottom: 12px;
}
.breadcrumb a { color: var(--imega-primary); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.doc-header {
  border-bottom: 3px solid var(--imega-primary);
  margin-bottom: 28px;
  padding-bottom: 14px;
}
.doc-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.doc-header h1 {
  margin: 0 0 8px;
  font-size: 24px;
  color: var(--imega-primary);
  font-weight: 700;
  flex: 1;
}
.download-pdf {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--imega-primary);
  color: white;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .2s;
  flex-shrink: 0;
}
.download-pdf:hover { background: #2E5277; }
.doc-meta {
  font-size: 13px;
  color: var(--imega-secondary);
  display: flex;
  gap: 24px;
}
.doc-meta code {
  background: var(--imega-surface);
  padding: 2px 6px;
  border-radius: 3px;
}

/* Headings */
.document h1 { color: var(--imega-primary); }
.document h2 {
  color: var(--imega-primary);
  border-bottom: 2px solid var(--imega-surface);
  padding-bottom: 6px;
  margin-top: 32px;
  margin-bottom: 14px;
  font-size: 20px;
}
.document h3 {
  color: var(--imega-secondary);
  margin-top: 24px;
  font-size: 17px;
}
.document h4 { color: var(--imega-secondary); font-size: 15px; }

/* Code (códigos del sistema) */
.document code {
  background: var(--imega-surface);
  color: var(--imega-primary);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: "Menlo", "Consolas", monospace;
  font-size: 13px;
}
.code-link {
  text-decoration: none;
  border-bottom: 1px dashed var(--imega-primary);
}
.code-link:hover code { background: var(--imega-primary); color: white; }

/* Tables */
.document table {
  border-collapse: collapse;
  margin: 18px 0;
  width: 100%;
  font-size: 13px;
  background: white;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.document table th {
  background: var(--imega-primary);
  color: white;
  text-align: left;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.document table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--imega-surface);
  vertical-align: top;
}
.document table tr:nth-child(even) td { background: rgba(245, 247, 249, .6); }
.document table tr:hover td { background: rgba(30, 58, 95, .04); }

/* Bullets */
.document ul, .document ol { padding-left: 24px; }
.document li { margin: 4px 0; }

/* Blockquote (callouts) */
.document blockquote {
  background: #FFF8E1;
  border-left: 4px solid var(--imega-warning);
  padding: 14px 18px;
  margin: 18px 0;
  border-radius: 4px;
}
.document blockquote p:first-child strong { color: var(--imega-warning); }

/* Images */
.document img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 20px auto;
  border: 1px solid var(--imega-surface);
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,.06);
}

/* Footer */
.site-footer {
  background: var(--imega-primary);
  color: white;
  margin-top: 40px;
  padding: 18px 0;
  font-size: 12px;
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
  display: flex;
  justify-content: space-between;
  opacity: .9;
}

/* ===== Landing ===== */
.hero {
  background: linear-gradient(135deg, var(--imega-primary) 0%, #2E5277 100%);
  color: white;
  padding: 60px 28px;
  text-align: center;
}
.hero-inner { max-width: 900px; margin: 0 auto; }
.hero h1 {
  font-size: 38px;
  margin: 0 0 12px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.hero .subtitle {
  font-size: 18px;
  opacity: .9;
  margin-bottom: 28px;
}
.hero .actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.hero .btn {
  background: white;
  color: var(--imega-primary);
  padding: 12px 24px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: transform .15s;
}
.hero .btn:hover { transform: translateY(-2px); }
.hero .btn.secondary {
  background: transparent;
  color: white;
  border: 2px solid white;
}

.landing-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 28px;
}
.landing-section h2 {
  color: var(--imega-primary);
  font-size: 24px;
  margin-bottom: 8px;
  border-bottom: 3px solid var(--imega-primary);
  padding-bottom: 8px;
  display: inline-block;
}
.landing-section .section-desc {
  color: var(--imega-secondary);
  margin-bottom: 24px;
  font-size: 14px;
}
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.doc-card {
  background: white;
  border: 1px solid var(--imega-surface);
  border-radius: 6px;
  padding: 16px 18px;
  text-decoration: none;
  color: var(--imega-text);
  display: block;
  transition: all .2s;
}
.doc-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(30, 58, 95, .15);
  border-color: var(--imega-primary);
}
.doc-card .doc-code {
  font-family: "Menlo", "Consolas", monospace;
  font-size: 11px;
  color: var(--imega-secondary);
  margin-bottom: 6px;
}
.doc-card .doc-title {
  font-weight: 600;
  color: var(--imega-primary);
  font-size: 14px;
  line-height: 1.3;
}
.doc-card .doc-rev {
  font-size: 11px;
  color: var(--imega-secondary);
  margin-top: 6px;
}

/* ===== Search ===== */
.search-container {
  max-width: 900px;
  margin: 40px auto;
  padding: 0 28px;
}
.search-container h1 {
  color: var(--imega-primary);
  font-size: 28px;
  margin-bottom: 18px;
}
.search-box {
  width: 100%;
  font-size: 18px;
  padding: 14px 18px;
  border: 2px solid var(--imega-surface);
  border-radius: 6px;
  outline: none;
}
.search-box:focus { border-color: var(--imega-primary); }
.search-results { margin-top: 24px; }
.search-result {
  background: white;
  border: 1px solid var(--imega-surface);
  border-radius: 6px;
  padding: 18px;
  margin-bottom: 12px;
}
.search-result h3 { margin: 0 0 6px; }
.search-result h3 a {
  color: var(--imega-primary);
  text-decoration: none;
}
.search-result .result-code {
  font-family: "Menlo", "Consolas", monospace;
  font-size: 11px;
  color: var(--imega-secondary);
  margin-bottom: 6px;
}
.search-result .result-snippet {
  font-size: 13px;
  color: var(--imega-text);
  line-height: 1.5;
}
.search-result mark {
  background: #FFF59D;
  padding: 0 2px;
  border-radius: 2px;
}
.search-stats {
  font-size: 13px;
  color: var(--imega-secondary);
  margin: 16px 0;
}

/* ===== Registros ===== */
.registros-container {
  max-width: 1300px;
  margin: 30px auto;
  padding: 0 28px;
}
.registros-container h1 {
  color: var(--imega-primary);
  font-size: 28px;
  border-bottom: 3px solid var(--imega-primary);
  padding-bottom: 10px;
}
.registros-container h2 {
  color: var(--imega-primary);
  margin-top: 32px;
}
.registros-container table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  font-size: 13px;
  margin-top: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.registros-container th {
  background: var(--imega-primary);
  color: white;
  padding: 10px;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
}
.registros-container td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--imega-surface);
}
.registros-container tr:target td {
  background: #FFF59D !important;
}
.registros-container tr:nth-child(even) td { background: rgba(245, 247, 249, .6); }
.registros-container .badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.registros-container .badge-mt { background: var(--imega-primary); color: white; }
.registros-container .badge-fo { background: var(--imega-warning); color: white; }
.registros-container .badge-rg { background: var(--imega-success); color: white; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .document { padding: 24px 18px; }
  .header-inner { padding: 12px 16px; }
  .main-nav { gap: 16px; }
  .hero { padding: 28px 18px; }
  .hero h1 { font-size: 24px; }
  .hero .subtitle { font-size: 14px; margin-bottom: 16px; }
  .hero img { height: 38px !important; margin-bottom: 12px !important; }
  .landing-section { padding: 24px 18px; }
}

/* Cuando el sitio está embebido (iframe — Moodle), ocultar el header propio,
   el sidebar y compactar el hero. */
html.in-frame .site-header,
html.in-frame .site-footer { display: none; }
html.in-frame .sidebar { display: none; }
html.in-frame .layout { grid-template-columns: 1fr; padding: 14px 20px; }
html.in-frame .document { padding: 18px 22px; }
html.in-frame .hero { padding: 24px 18px; }
html.in-frame .hero h1 { font-size: 22px; margin: 0 0 6px; }
html.in-frame .hero .subtitle { font-size: 13px; margin-bottom: 14px; }
html.in-frame .hero img { height: 32px !important; margin-bottom: 10px !important; }
html.in-frame .landing-section { padding: 22px 18px; }
html.in-frame .landing-section h2 { font-size: 18px; }
