:root {
  --brand: #2f6b48;
  --brand-dark: #1c3f2b;
  --accent: #c99a3c;
  --leaf: #7fae66;
  --bg: #f5f7ef;
  --panel: #ffffff;
  --border: #dce6d6;
  --text: #212e20;
  --text-muted: #5f7361;
  --hover-tint: #e8f1e2;
  --sidebar-w: 300px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(ellipse 620px 420px at 6% -8%, rgba(47,107,72,.08), transparent 60%),
    radial-gradient(ellipse 520px 420px at 102% 12%, rgba(201,154,60,.07), transparent 58%),
    radial-gradient(ellipse 520px 520px at 12% 105%, rgba(47,107,72,.06), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  background:
    radial-gradient(circle at 8% 0%, rgba(201,154,60,.16), transparent 55%),
    var(--brand-dark);
  color: #fff;
  padding: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}

.brand {
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
}
.brand span {
  display: block;
  font-weight: 400;
  font-size: 11px;
  opacity: .8;
}
.brand:hover { text-decoration: none; }

.search-wrap { position: relative; flex: 1; max-width: 520px; margin-left: auto; }
#searchBox {
  width: 100%;
  padding: 9px 14px;
  border-radius: 20px;
  border: none;
  font-size: 14px;
  outline: none;
}
.search-results {
  display: none;
  position: absolute;
  top: 42px;
  left: 0;
  right: 0;
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  max-height: 420px;
  overflow-y: auto;
  z-index: 60;
}
.search-results.show { display: block; }
.search-results a {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 13.5px;
}
.search-results a:hover { background: var(--hover-tint); text-decoration: none; }
.search-results .r-code { color: var(--accent); font-weight: 600; margin-right: 6px; }
.search-results .r-cat { display: block; color: var(--text-muted); font-size: 11.5px; }
.search-results .r-empty { padding: 14px; color: var(--text-muted); font-size: 13px; }

.body-wrap { display: flex; flex: 1; }

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 0 60px;
  overflow-y: auto;
  height: calc(100vh - 54px);
  position: sticky;
  top: 54px;
}

.nav-group { margin-bottom: 4px; }
.nav-group-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 18px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--brand-dark);
  cursor: pointer;
  user-select: none;
}
.nav-group-title:hover { background: var(--hover-tint); }
.nav-group-title .chev { transition: transform .15s; font-size: 11px; color: var(--text-muted); }
.nav-group.open .chev { transform: rotate(90deg); }
.nav-items { display: none; flex-direction: column; padding-bottom: 6px; }
.nav-group.open .nav-items { display: flex; }
.nav-items a {
  padding: 6px 18px 6px 30px;
  font-size: 13px;
  color: var(--text);
  border-left: 3px solid transparent;
}
.nav-items a:hover { background: var(--hover-tint); text-decoration: none; }
.nav-items a.active {
  border-left-color: var(--accent);
  background: var(--hover-tint);
  font-weight: 600;
  color: var(--brand-dark);
}
.nav-items .item-code { color: var(--text-muted); font-size: 11px; display: block; }

.sidebar-backdrop { display: none; }

.content {
  flex: 1;
  padding: 28px 40px 80px;
  max-width: 900px;
}

.breadcrumb {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.breadcrumb .current { color: var(--text); font-weight: 600; }

.doc-header h1 {
  margin: 0 0 4px;
  font-size: 26px;
  color: var(--brand-dark);
}
.doc-code {
  display: inline-block;
  font-size: 12px;
  letter-spacing: .04em;
  color: #fff;
  background: var(--accent);
  padding: 3px 10px;
  border-radius: 12px;
  margin-bottom: 18px;
  font-weight: 600;
}

.meta-card {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 26px;
}
.meta-item { display: flex; flex-direction: column; }
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.meta-value { font-size: 14px; font-weight: 600; color: var(--text); }

.sec-heading {
  color: var(--brand-dark);
  border-bottom: 2px solid var(--border);
  padding-bottom: 6px;
  margin-top: 30px;
  font-size: 18px;
}

.content p { line-height: 1.65; font-size: 14.5px; }
.content img { max-width: 100%; border-radius: 8px; border: 1px solid var(--border); margin: 10px 0; display: block; }
.content ul { line-height: 1.65; font-size: 14.5px; padding-left: 22px; }
.content li { margin-bottom: 4px; }

.note-box {
  background: #faf3e0;
  border-left: 4px solid var(--accent);
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 4px;
  margin: -6px 0 14px;
}

.table-wrap { overflow-x: auto; margin: 14px 0; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table th, table td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
table th { background: var(--hover-tint); color: var(--brand-dark); }
table tr:nth-child(even) td { background: #f6faf3; }

.source-note { margin-top: 40px; font-size: 11.5px; color: var(--text-muted); font-style: italic; }

.status-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e4f4e6;
  color: #2c7a3d;
  margin-left: 6px;
}

/* Landing / index page */
.hero {
  background:
    radial-gradient(circle at 12% 15%, rgba(255,255,255,.09), transparent 42%),
    radial-gradient(circle at 88% 30%, rgba(201,154,60,.18), transparent 46%),
    radial-gradient(circle at 75% 90%, rgba(255,255,255,.06), transparent 40%),
    linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
  border-radius: 14px;
  padding: 40px;
  margin-bottom: 30px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.08);
}
.hero h1 { margin: 0 0 10px; font-size: 30px; }
.hero p { margin: 0; opacity: .92; max-width: 640px; line-height: 1.6; }

.index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 10px;
}
.index-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  transition: box-shadow .15s, transform .15s;
}
.index-card:hover { box-shadow: 0 6px 18px rgba(28,63,43,.14); transform: translateY(-2px); }
.index-card h3 { margin: 0 0 10px; font-size: 15px; color: var(--brand-dark); }
.index-card ul { margin: 0; padding-left: 18px; font-size: 12.5px; }
.index-card li { margin-bottom: 3px; }
.index-card .more { font-size: 12px; color: var(--text-muted); }

.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 20px; }

/* Evaluaciones / diplomas */
.quiz-intro {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 22px;
  font-size: 14px;
  color: var(--text-muted);
}

.quiz-form { display: flex; flex-direction: column; gap: 18px; }

.quiz-field { display: flex; flex-direction: column; gap: 6px; max-width: 420px; }
.quiz-field label { font-size: 13px; font-weight: 600; color: var(--brand-dark); }
.quiz-field input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.quiz-field input:focus { outline: 2px solid var(--accent); }

.quiz-questions { display: flex; flex-direction: column; gap: 16px; }

.quiz-q {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px 16px;
  background: var(--panel);
  transition: border-color .15s, background .15s;
}
.quiz-q legend {
  font-weight: 600;
  font-size: 14.5px;
  color: var(--text);
  padding: 0 4px;
}
.quiz-q.missing { border-color: #c0392b; background: #fdf1ef; }

.quiz-opt {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 4px;
  font-size: 13.5px;
  cursor: pointer;
  border-radius: 6px;
}
.quiz-opt:hover { background: var(--hover-tint); }
.quiz-opt input { margin-top: 3px; flex-shrink: 0; }

.quiz-error {
  background: #fdf1ef;
  border-left: 4px solid #c0392b;
  color: #96281b;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 13.5px;
}

.quiz-submit, .btn-primary, .btn-secondary {
  display: inline-block;
  border: none;
  border-radius: 22px;
  padding: 11px 26px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.quiz-submit, .btn-primary { background: var(--brand); color: #fff; }
.quiz-submit:hover, .btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #fff; color: var(--brand-dark); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--hover-tint); }
.quiz-submit { align-self: flex-start; }

.quiz-results {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 26px;
  margin-top: 10px;
}
.quiz-results h2 { margin-top: 0; color: var(--brand-dark); }
.quiz-pass { color: #2c7a3d; font-weight: 700; }
.quiz-fail { color: #c0392b; font-weight: 700; }
.quiz-actions { display: flex; gap: 12px; margin: 18px 0 10px; flex-wrap: wrap; }
.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  text-decoration: underline;
  cursor: pointer;
  font-size: 13px;
  padding: 4px;
  font-family: inherit;
}

.eval-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 10px;
}
.eval-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  transition: box-shadow .15s, transform .15s;
}
.eval-card:hover { box-shadow: 0 6px 18px rgba(28,63,43,.14); transform: translateY(-2px); }
.eval-card h3 { margin: 0 0 8px; font-size: 15px; color: var(--brand-dark); }
.eval-card p { margin: 0 0 12px; font-size: 12.5px; color: var(--text-muted); }
.eval-card a.eval-start {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  padding: 7px 16px;
  border-radius: 16px;
}
.eval-card a.eval-start:hover { background: var(--brand); text-decoration: none; }

.hero-actions { margin-top: 18px; }
.hero-actions a {
  display: inline-block;
  background: #fff;
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 13.5px;
  padding: 10px 22px;
  border-radius: 22px;
}
.hero-actions a:hover { text-decoration: none; opacity: .92; }

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -320px;
    top: 54px;
    height: calc(100vh - 54px);
    transition: left .2s;
    z-index: 40;
    box-shadow: 4px 0 16px rgba(0,0,0,.2);
  }
  .sidebar.open { left: 0; }
  .sidebar-backdrop.show {
    display: block;
    position: fixed;
    inset: 54px 0 0 0;
    background: rgba(0,0,0,.35);
    z-index: 39;
  }
  .menu-toggle { display: block; }
  .brand span { display: none; }
  .content { padding: 20px; }
  .search-wrap { max-width: none; }
}
