/* Paleta = tema "Nocturno" del portal (web/src/index.css) */
:root {
  --surface: #0f172a;
  --card: #1e293b;
  --muted-bg: #334155;
  --sidebar: #1e293b;
  --ink: #f1f5f9;
  --ink-soft: #cbd5e1;
  --muted: #94a3b8;
  --faint: #64748b;
  --line: #334155;
  --brand-400: #2dd4bf;
  --brand-500: #14b8a6;
  --brand-600: #0d9488;
  --brand-700: #0f766e;
  --brand-glow: rgba(20, 184, 166, 0.22);
  --sky: #38bdf8;
  --lime: #a3e635;
  --amber: #fbbf24;
  --rose: #fb7185;
  --radius: 14px;
  --nav-w: 264px;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', Consolas, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface);
  line-height: 1.55;
}

a {
  color: var(--brand-400);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--brand-500);
}

.shell {
  display: grid;
  grid-template-columns: var(--nav-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar igual al Layout del portal */
.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 1.25rem 0.75rem 2rem;
  background: var(--sidebar);
  color: var(--ink-soft);
  border-right: 1px solid rgba(51, 65, 85, 0.6);
}

.nav-brand {
  padding: 0 0.6rem 1.1rem;
  margin-bottom: 0.6rem;
}

.nav-brand strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-500);
}

.nav-brand span {
  display: block;
  font-size: 0.78rem;
  color: var(--muted);
}

.nav-brand small {
  display: block;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--faint);
}

.nav-section {
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0.6rem 0.6rem 0.35rem;
}

.nav a.item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem;
  align-items: start;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  color: var(--ink-soft);
  text-decoration: none;
  margin-bottom: 0.15rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav a.item:hover {
  background: rgba(51, 65, 85, 0.7);
  color: var(--ink);
}

.nav a.item.active {
  background: var(--brand-700);
  color: #fff;
}

.nav .num {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand-400);
  min-width: 1.4rem;
  padding-top: 0.12rem;
}

.nav a.item.active .num {
  color: #ccfbf1;
}

.nav .label {
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.25;
}

.nav .meta {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.nav a.item.active .meta {
  color: #99f6e4;
}

.main {
  padding: 1.5rem clamp(1rem, 3vw, 2.25rem) 3rem;
  min-width: 0;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  color: var(--faint);
  font-size: 0.86rem;
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.breadcrumb strong {
  color: var(--ink);
}

.menu-btn {
  display: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* Portada */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  padding: clamp(1.4rem, 4vw, 2.5rem);
  background:
    radial-gradient(600px 260px at 90% 0%, rgba(20, 184, 166, 0.25), transparent 60%),
    linear-gradient(135deg, #1e293b 0%, #0f172a 70%);
  border: 1px solid var(--line);
  margin-bottom: 1.25rem;
  animation: rise 0.5s ease both;
}

.hero .eyebrow {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-400);
  margin-bottom: 0.6rem;
}

.hero h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(1.6rem, 3.4vw, 2.3rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.hero p {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
  font-size: 1.02rem;
}

.demo-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

.demo-pill {
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.demo-pill .k {
  display: block;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
}

.demo-pill .v {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--ink);
}

.secret {
  font-family: var(--mono);
  letter-spacing: 0.12em;
  color: var(--muted);
}

/* KPI tipo dashboard */
.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.stat {
  position: relative;
  overflow: hidden;
  padding: 1rem 1.1rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
}

.stat::after {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 90px;
  height: 90px;
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.12);
}

.stat .k {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat .v {
  margin-top: 0.3rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-400);
}

/* Índice de módulos */
.grid-mods {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.mod-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 0.9rem;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  animation: rise 0.5s ease both;
}

.mod-card:hover {
  transform: translateY(-3px);
  border-color: var(--brand-600);
  box-shadow: 0 16px 32px var(--brand-glow);
}

.mod-card h2 {
  margin: 0;
  font-size: 1rem;
}

.mod-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  flex: 1;
}

.mod-card .go {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand-400);
}

.mod-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top left;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.mod-thumb.phone {
  object-fit: cover;
  object-position: top center;
}

/* Encabezado de módulo */
.page-head {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  animation: rise 0.45s ease both;
}

.page-head h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2rem);
  letter-spacing: -0.02em;
}

.page-head .lede {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  max-width: 72ch;
}

.channels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.chip.portal {
  background: rgba(20, 184, 166, 0.14);
  border-color: rgba(45, 212, 191, 0.35);
  color: var(--brand-400);
}

.chip.app {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  color: var(--sky);
}

.chip.api {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.35);
  color: var(--amber);
}

.chip.all {
  background: rgba(148, 163, 184, 0.12);
  border-color: var(--line);
  color: var(--ink-soft);
}

/* Prints */
.page-thumb {
  margin: 0 0 1.25rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 20px 40px rgba(2, 6, 23, 0.45);
  animation: rise 0.5s ease both;
}

.page-thumb img {
  display: block;
  width: 100%;
  height: auto;
  background: var(--surface);
}

.page-thumb figcaption {
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.print-stack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.print-stack .page-thumb {
  margin: 0;
}

.print-stack {
  align-items: start;
}

.print-duo {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 260px);
  gap: 1rem;
  align-items: start;
  margin-bottom: 1.25rem;
}

.print-duo .page-thumb {
  margin: 0;
}

@media (max-width: 720px) {
  .print-duo {
    grid-template-columns: 1fr;
  }
}

.phone-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-thumb.phone {
  margin: 0;
  border-radius: 26px;
  padding: 8px;
  background: #020617;
  border: 1px solid #1e293b;
}

.page-thumb.phone img {
  border-radius: 18px;
}

.page-thumb.phone figcaption {
  border-top: 0;
  text-align: center;
  padding: 0.55rem 0.3rem 0.2rem;
}

/* Paneles y tablas */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  margin-bottom: 1rem;
  animation: rise 0.5s ease both;
}

.panel h2 {
  margin: 0 0 0.8rem;
  font-size: 1.08rem;
}

.panel h3 {
  margin: 1.1rem 0 0.5rem;
  font-size: 0.98rem;
  color: var(--ink-soft);
}

.panel p,
.panel li {
  color: var(--ink-soft);
}

.panel ul,
.panel ol {
  margin: 0.4rem 0 0;
  padding-left: 1.15rem;
}

.panel li + li {
  margin-top: 0.35rem;
}

.table-wrap {
  overflow: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: var(--muted-bg);
  color: var(--ink);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

td {
  color: var(--ink-soft);
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: rgba(51, 65, 85, 0.35);
}

.fields td:first-child {
  width: 28%;
  font-weight: 600;
  color: var(--ink);
}

.fields .tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.06rem 0.42rem;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 700;
  vertical-align: middle;
  background: rgba(20, 184, 166, 0.15);
  color: var(--brand-400);
}

.fields .tag.opt {
  background: rgba(148, 163, 184, 0.15);
  color: var(--muted);
}

.fields .tag.req {
  background: rgba(251, 191, 36, 0.14);
  color: var(--amber);
}

code,
.kbd {
  font-family: var(--mono);
  font-size: 0.85em;
  color: var(--brand-400);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.05rem 0.35rem;
}

pre {
  margin: 0.6rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: #020617;
  border: 1px solid var(--line);
  overflow: auto;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* Pasos, flujo y avisos */
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: step;
  display: grid;
  gap: 0.6rem;
}

.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.8rem;
  align-items: start;
  padding: 0.8rem 0.95rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}

.steps li + li {
  margin-top: 0;
}

.steps li::before {
  content: counter(step);
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  background: var(--brand-600);
}

.flow {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.flow-node {
  position: relative;
  padding: 0.85rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: center;
  font-weight: 600;
  font-size: 0.86rem;
}

.flow-node small {
  display: block;
  margin-top: 0.25rem;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.74rem;
}

.flow-node::after {
  content: '→';
  position: absolute;
  right: -0.55rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--brand-400);
  font-weight: 700;
  z-index: 1;
}

.flow-node:last-child::after {
  content: none;
}

.callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  margin: 0.8rem 0 0;
  border: 1px solid transparent;
  font-size: 0.92rem;
}

.callout .icon {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.8rem;
  color: #fff;
}

.callout.tip {
  background: rgba(20, 184, 166, 0.1);
  border-color: rgba(45, 212, 191, 0.35);
  color: #99f6e4;
}

.callout.tip .icon {
  background: var(--brand-600);
}

.callout.warn {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fde68a;
}

.callout.warn .icon {
  background: #d97706;
}

.callout.info {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.35);
  color: #bae6fd;
}

.callout.info .icon {
  background: #0284c7;
}

.callout strong {
  display: block;
  margin-bottom: 0.1rem;
}

.legend-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.6rem 0 0;
}

.legend-dots span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
}

.legend-dots i {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 3px;
  background: var(--brand-500);
}

/* Temas */
.swatch-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.7rem;
  margin-top: 0.75rem;
}

.swatch {
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.85rem;
}

.swatch strong {
  display: block;
  color: var(--ink);
}

.swatch small {
  color: var(--muted);
}

.swatch.active {
  border-color: var(--brand-500);
  box-shadow: inset 0 0 0 1px var(--brand-500);
}

.swatch .dots {
  display: flex;
  gap: 0.3rem;
  margin-bottom: 0.45rem;
}

.swatch .dots span {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

/* Paginación */
.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  margin-top: 1.5rem;
}

.pager a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
}

.pager a:hover {
  border-color: var(--brand-600);
  background: var(--brand-700);
  color: #fff;
}

.overlay {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .nav {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, var(--nav-w));
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
  }

  body.nav-open .nav {
    transform: none;
  }

  .overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 30;
  }

  body.nav-open .overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .menu-btn {
    display: inline-flex;
  }

  .flow-node::after {
    content: none;
  }
}
