/* ==========================================================================
   UNAM HPC — design system
   Self-contained, no external CDN dependencies (intranet-friendly).
   ========================================================================== */

:root {
  --bg: #f6f8fa;
  --bg-alt: #ffffff;
  --ink: #0d1520;
  --ink-soft: #4a5568;
  --line: #e2e8f0;
  --brand: #0f6e5c;
  --brand-ink: #ffffff;
  --accent: #0ea5a3;
  --accent-2: #2563eb;
  --navy: #071019;
  --navy-soft: #0e1c2b;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(13,21,32,.04), 0 8px 24px rgba(13,21,32,.06);
  --maxw: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
h1, h2, h3, h4 { line-height: 1.2; font-weight: 700; margin: 0 0 .5em; }
h1 { font-size: clamp(2rem, 4vw, 2.75rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
p { margin: 0 0 1em; color: var(--ink-soft); }
code, .mono { font-family: var(--mono); }
.section { padding: 72px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.eyebrow {
  display: inline-block; font-family: var(--mono); font-size: .75rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent); background: rgba(14,165,163,.1);
  padding: 4px 10px; border-radius: 999px; margin-bottom: 14px;
}
.lede { font-size: 1.1rem; max-width: 60ch; }
.grid { display: grid; gap: 24px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: .95rem;
  padding: 12px 22px; border-radius: 999px; border: 1px solid transparent; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 4px 14px rgba(15,110,92,.3); }
.btn-primary:hover { background: #0c5c4d; }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.35); color: #fff; }
.btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-block { width: 100%; justify-content: center; }

/* ---------- nav ---------- */
.site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(7,16,25,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.site-nav .container { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; letter-spacing: .01em; font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.brand .dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.nav-links { display: flex; gap: 4px; align-items: center; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  color: rgba(255,255,255,.78); font-size: .92rem; font-weight: 500; padding: 8px 14px; border-radius: 8px;
}
.nav-links a:hover, .nav-links a.active { color: #fff; background: rgba(255,255,255,.08); text-decoration: none; }
.nav-links a.cta { background: var(--accent); color: #04231f; font-weight: 700; }
.nav-links a.cta:hover { background: #0bb8b6; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; }
@media (max-width: 860px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: absolute; top: 64px; left: 0; right: 0; background: var(--navy);
    flex-direction: column; align-items: stretch; padding: 8px; gap: 2px;
    display: none; border-bottom: 1px solid rgba(255,255,255,.08);
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: 12px 14px; }
}

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden; background: radial-gradient(ellipse at top, var(--navy-soft), var(--navy) 60%);
  padding: 168px 0 96px; color: #fff;
}
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .55; }
.hero .container { position: relative; z-index: 2; }
.hero-inner { max-width: 760px; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); }
.hero p.lede { color: rgba(255,255,255,.75); font-size: 1.15rem; }
.hero .actions { display: flex; gap: 14px; margin-top: 28px; flex-wrap: wrap; }

.stat-strip {
  position: relative; z-index: 2; margin-top: 56px; display: grid;
  grid-template-columns: repeat(4, 1fr); gap: 1px; background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.1); border-radius: var(--radius); overflow: hidden;
}
.stat-strip .stat { background: rgba(255,255,255,.03); padding: 20px 18px; }
.stat .num { font-family: var(--mono); font-size: 1.7rem; font-weight: 700; color: var(--accent); }
.stat .label { font-size: .78rem; color: rgba(255,255,255,.6); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }
@media (max-width: 760px) { .stat-strip { grid-template-columns: repeat(2, 1fr); } }

/* ---------- cards ---------- */
.card {
  background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; box-shadow: var(--shadow);
}
.card h3 { font-size: 1.15rem; }
.card .icon {
  width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: rgba(14,165,163,.12); color: var(--accent); margin-bottom: 16px; font-size: 1.2rem;
}
.card-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: .9rem; margin-top: 10px; }

/* ---------- spec tables ---------- */
.spec-card { background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.spec-card h3 { font-size: 1.05rem; color: var(--brand); }
.spec-card ul { list-style: none; margin: 0; padding: 0; }
.spec-card li {
  display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line);
  font-size: .92rem;
}
.spec-card li:last-child { border-bottom: 0; }
.spec-card li span:first-child { color: var(--ink-soft); }
.spec-card li span:last-child { font-family: var(--mono); font-weight: 600; text-align: right; }

/* ---------- forms ---------- */
.form-card { background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.field { margin-bottom: 18px; }
.field label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: .8rem; color: var(--ink-soft); margin-top: 4px; }
input, select, textarea {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px; font-size: .95rem;
  font-family: var(--sans); background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(14,165,163,.15); }
textarea { resize: vertical; min-height: 110px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .field-row { grid-template-columns: 1fr; } }

.alert { padding: 14px 18px; border-radius: 10px; font-size: .92rem; margin-bottom: 20px; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-rejected { background: #fee2e2; color: #991b1b; }
.badge-decommissioned { background: #e2e8f0; color: #334155; }

/* ---------- table ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; background: #fff; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data th { background: #f1f5f9; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.table-wrap { overflow-x: auto; background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); }

/* ---------- projects grid ---------- */
.project-card { background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.project-card .thumb { aspect-ratio: 16/10; overflow: hidden; background: #eef2f6; }
.project-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.project-card .body { padding: 18px 20px; }
.project-card .tag { font-family: var(--mono); font-size: .72rem; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- footer ---------- */
footer.site-footer { background: var(--navy); color: rgba(255,255,255,.75); padding: 56px 0 24px; margin-top: 0; }
footer.site-footer h2 { color: #fff; font-size: 1rem; margin-bottom: 6px; }
footer.site-footer h3 { color: rgba(255,255,255,.55); font-size: .78rem; font-weight: 500; margin-bottom: 12px; }
footer.site-footer a { color: rgba(255,255,255,.75); }
footer.site-footer a:hover { color: #fff; }
.footer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
@media (max-width: 760px) { .footer-grid { grid-template-columns: 1fr; } }
.footer-bottom { margin-top: 40px; padding-top: 20px; border-top: 1px solid rgba(255,255,255,.1); font-size: .82rem; color: rgba(255,255,255,.5); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

/* ---------- utility ---------- */
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.small { font-size: .85rem; }
.acknowledgement {
  font-style: italic; background: var(--bg-alt); border-left: 3px solid var(--accent);
  padding: 18px 22px; border-radius: 0 10px 10px 0;
}

/* ---------- admin dashboard ---------- */
table.data tbody tr:hover { background: #fafbfc; }
table.data tbody tr:nth-child(even) { background: #fbfcfd; }
table.data tbody tr:nth-child(even):hover { background: #f5f7f9; }
table.data td.col-purpose { max-width: 260px; }
table.data td.col-actions { min-width: 200px; }

.purpose-toggle {
  cursor: pointer; list-style: none; color: var(--ink); position: relative; padding-right: 16px;
}
.purpose-toggle::-webkit-details-marker { display: none; }
.purpose-toggle::after { content: "… more"; color: var(--accent); font-weight: 600; margin-left: 2px; white-space: nowrap; }
details[open] > .purpose-toggle::after { content: " (show less)"; }
.purpose-toggle:hover::after { text-decoration: underline; }
.purpose-full { margin: 6px 0 0; white-space: pre-wrap; }

.action-stack { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; }
.action-stack form { margin: 0; }

.cmd-toggle > summary {
  font-size: .78rem; font-weight: 600; color: var(--ink-soft); cursor: pointer;
  list-style: none; display: flex; align-items: center; gap: 4px;
}
.cmd-toggle > summary::-webkit-details-marker { display: none; }
.cmd-toggle > summary::before { content: "▸"; font-size: .7rem; }
.cmd-toggle[open] > summary::before { content: "▾"; }
.cmd-toggle > summary:hover { color: var(--accent); }
.cmd-row { display: flex; align-items: flex-start; gap: 6px; margin-top: 6px; }
.cmd-block {
  flex: 1; margin: 0; white-space: pre-wrap; word-break: break-all;
  background: #0d1520; color: #e2f6f4; padding: 10px 12px; border-radius: 8px;
  font-size: .78rem; line-height: 1.5;
}
.cmd-copy {
  flex-shrink: 0; border: 1px solid var(--line); background: #fff; color: var(--ink-soft);
  border-radius: 6px; padding: 4px 8px; font-size: .72rem; cursor: pointer;
}
.cmd-copy:hover { border-color: var(--accent); color: var(--accent); }

.note { font-size: .8rem; white-space: pre-wrap; padding: 8px 10px; border-radius: 8px; margin: 0 0 6px; max-width: 280px; }
.note-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.note-info { background: #f1f5f9; color: var(--ink-soft); border: 1px solid var(--line); }

details.note-toggle { margin: 0 0 6px; max-width: 280px; }
details.note-toggle > summary {
  cursor: pointer; list-style: none; font-size: .8rem; padding: 6px 10px; border-radius: 8px;
  display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
details.note-toggle > summary::-webkit-details-marker { display: none; }
details.note-toggle > summary::before { content: "▸"; font-size: .65rem; flex-shrink: 0; }
details.note-toggle[open] > summary::before { content: "▾"; }
details.note-toggle > summary::after { content: "more"; color: inherit; opacity: .65; font-weight: 600; margin-left: 6px; flex-shrink: 0; }
details.note-toggle[open] > summary::after { content: "less"; }
details.note-toggle.note-error > summary { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
details.note-toggle.note-info > summary { background: #f1f5f9; color: var(--ink-soft); border: 1px solid var(--line); }
details.note-toggle .note-full {
  white-space: pre-wrap; font-size: .78rem; margin: 6px 0 0; padding: 8px 10px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 8px;
  max-height: 260px; overflow-y: auto;
}

.flash-banner { padding: 12px 16px; border-radius: 10px; font-size: .9rem; margin-bottom: 16px; }
.flash-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.test-panel {
  background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin: 20px 0 28px; box-shadow: var(--shadow);
}
.test-panel h2 { font-size: .95rem; margin: 0 0 4px; }
.test-panel p.hint { margin: 0 0 14px; }
.test-panel form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.test-panel .field { margin: 0; min-width: 160px; flex: 1; }
.test-panel .field label { font-size: .78rem; margin-bottom: 4px; }
.test-panel .field select, .test-panel .field input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: .88rem;
}
.test-panel .btn { padding: 9px 18px; font-size: .85rem; }

.admin-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin: 8px 0 20px;
}

/* ---------- docs section ---------- */
.docs-layout { display: grid; grid-template-columns: 230px 1fr; gap: 48px; align-items: start; }
@media (max-width: 900px) { .docs-layout { grid-template-columns: 1fr; } }

.docs-sidebar { position: sticky; top: 88px; }
.docs-sidebar .group { margin-bottom: 22px; }
.docs-sidebar .group h4 {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft);
  margin: 0 0 8px;
}
.docs-sidebar ul { list-style: none; margin: 0; padding: 0; }
.docs-sidebar li { margin-bottom: 2px; }
.docs-sidebar a {
  display: block; padding: 7px 10px; border-radius: 8px; font-size: .9rem; color: var(--ink);
}
.docs-sidebar a:hover { background: var(--bg); text-decoration: none; }
.docs-sidebar a.active { background: rgba(14,165,163,.12); color: var(--brand); font-weight: 600; }
@media (max-width: 900px) {
  .docs-sidebar { position: static; }
  .docs-sidebar .group { display: inline-block; margin-right: 24px; vertical-align: top; }
}

.docs-content h2 { margin-top: 2.2em; }
.docs-content h2:first-child { margin-top: 0; }
.docs-content h3 { margin-top: 1.6em; }
.docs-content > p:first-of-type { font-size: 1.05rem; }

.steps { list-style: none; margin: 24px 0; padding: 0; counter-reset: step; }
.steps > li {
  position: relative; padding: 0 0 26px 44px; border-left: 2px solid var(--line); margin-left: 15px;
}
.steps > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps > li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: -15px; top: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand); color: #fff; font-family: var(--mono); font-weight: 700; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
}
.steps h4 { margin: 0 0 6px; font-size: 1rem; }
.steps p { margin: 0 0 8px; }

.callout {
  border-radius: var(--radius); padding: 16px 20px; margin: 22px 0; font-size: .92rem;
  border: 1px solid var(--line); background: var(--bg-alt);
}
.callout p:last-child { margin-bottom: 0; }
.callout strong.label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.callout-info { background: rgba(37,99,235,.06); border-color: rgba(37,99,235,.25); }
.callout-info strong.label { color: var(--accent-2); }
.callout-warn { background: #fffbeb; border-color: #fde68a; }
.callout-warn strong.label { color: #92400e; }
.callout-legacy { background: #f8fafc; border-color: var(--line); }
.callout-legacy strong.label { color: var(--ink-soft); }

pre.code-block {
  background: #0d1520; color: #e2f6f4; padding: 16px 18px; border-radius: 10px;
  font-size: .85rem; line-height: 1.6; overflow-x: auto; margin: 14px 0;
}
.docs-content table.data { margin: 14px 0; }

.docs-topic-grid .card p.small { min-height: 3em; }
