/* OctoBooks · identidad Octopus UI (Octopus Energy España).
   Tokens de la skill octopus-ui; maqueta basada en la web de Alexandria (plantilla-index-v16). */
/* Montserrat servida desde la propia app (sin Google Fonts). Licencia SIL OFL 1.1. */
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('fonts/montserrat-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Montserrat'; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url('fonts/montserrat-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  /* Superficies */
  --surface-base: #0D0030;    /* Siphon */
  --surface-raised: #18004A;  /* Hemocyanin */
  --surface-card: #2D1A83;    /* Blueberry */
  --glass-subtle: rgba(13, 0, 48, .6);
  --border-glass: rgba(164, 159, 198, .25);
  --border-strong: rgba(164, 159, 198, .45);

  /* Texto */
  --text-primary: #FCFFFF;    /* Ice */
  --text-secondary: #DCDDFF;  /* Dusty Sky */
  --text-muted: #A49FC6;      /* Purple Haze */
  --text-link: #06F0FB;       /* Voltage: contraste AA sobre todas las superficies */

  /* Acentos */
  --ink: #5840FF;
  --ink-hover: #6675F6;       /* Blue Tang: solo bordes, no fondo con texto */
  --soho-lights: #F05DFB;
  --akoya: #FA89FF;
  --voltage: #06F0FB;
  --plum: #600E68;
  --on-bright: #0D0030;

  --voltage-soft: rgba(6, 240, 251, .1);
  --magenta-soft: rgba(240, 93, 251, .12);
  --ink-soft: rgba(88, 64, 255, .22);
  --muted-soft: rgba(164, 159, 198, .12);

  --grad-accent: linear-gradient(90deg, #5840FF 0%, #F05DFB 100%);
  --radius-card: 12px;
  --radius-md: 16px;
  --gap-base: 16px;
  --gap-section: 32px;
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background: var(--surface-raised);
  color: var(--text-primary);
  font-family: var(--font); font-size: 16px; line-height: 1.6;
}
a { color: var(--text-link); text-underline-offset: 2px; }
a:hover { color: var(--text-primary); }
:where(a, button, input, select, textarea, summary):focus-visible { outline: 2px solid var(--voltage); outline-offset: 2px; }
.icon { width: 20px; height: 20px; flex-shrink: 0; vertical-align: -4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--ink); color: var(--text-primary); padding: 10px 16px; border-radius: 8px; font-weight: 600; text-decoration: none; }
.skip:focus { top: 8px; }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: clamp(24px, 3.2vw, 30px); font-weight: 600; margin: 0 0 12px; }
h2 { font-size: 20px; font-weight: 500; margin: var(--gap-section) 0 12px; }
h3 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }

/* ---------- Estructura: menú lateral + lienzo ---------- */
.layout { display: grid; grid-template-columns: 288px 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface-base); border-radius: 0 16px 16px 0;
  padding: 16px 12px; display: flex; flex-direction: column; gap: 10px;
}
.brand { display: inline-block; padding: 4px 10px; border-radius: 8px; }
.brand img { display: block; height: 31px; width: auto; }
.apptitle { margin: 0; padding: 0 10px 6px; font-size: 12px; font-weight: 500; line-height: 1.6; color: var(--text-muted); }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a, .nav-off {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 9px 12px; border-radius: 12px;
  color: var(--text-primary); text-decoration: none; font-size: 14px; font-weight: 500; line-height: 1.4;
}
.side nav a .icon, .nav-off .icon { color: var(--text-secondary); }
.side nav a:hover { background: var(--surface-card); }
.side nav a.newq { background: var(--ink); margin-bottom: 6px; }
.side nav a.newq .icon { color: var(--text-primary); }
.side nav a.newq:hover { background: var(--surface-card); box-shadow: inset 0 0 0 2px var(--ink); color: var(--text-primary); }
.side nav a:focus-visible { outline-offset: -2px; }
.offlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-off { color: var(--text-secondary); cursor: default; gap: 8px; padding-right: 6px; }
.nav-off .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-off .lbl { flex: 1; min-width: 0; }
.soon {
  flex-shrink: 0; font-size: 11px; font-weight: 600; line-height: 1.4;
  padding: 1px 7px; border-radius: 999px; border: 1px dashed var(--border-strong); color: var(--text-muted);
}
.side .foot { margin-top: auto; border-top: 2px solid var(--border-glass); padding: 12px 10px 0; display: flex; flex-direction: column; gap: 10px; font-size: 12px; line-height: 1.6; color: var(--text-muted); }
.foot p { margin: 0; }
.session { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.session .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.lang { display: inline-flex; align-items: center; gap: 8px; }
.lang .on { background: var(--ink); color: var(--text-primary); border-radius: 999px; padding: 2px 10px; font-weight: 700; }
.linkbtn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 8px;
  background: transparent; border: 0; border-radius: 8px; color: var(--text-secondary);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.linkbtn:hover { color: var(--text-primary); background: var(--surface-card); }
.linkbtn .icon { width: 16px; height: 16px; }

.content {
  min-width: 0; display: flex; flex-direction: column;
  background: radial-gradient(ellipse 70% 55% at 55% 78%, rgba(88, 64, 255, .28), transparent 70%), var(--surface-raised);
}
main { width: 100%; max-width: 880px; margin: 0 auto; padding: 40px 32px 24px; flex: 1; }
main:focus { outline: none; }
.pie { display: none; }

/* Aviso legal fijo */
.aviso {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 24px; padding: 10px 14px; border-radius: var(--radius-card);
  background: var(--magenta-soft); border: 1px solid rgba(240, 93, 251, .35);
  font-size: 13px; line-height: 1.5; color: var(--text-secondary);
}
.aviso .icon { width: 18px; height: 18px; color: var(--akoya); margin-top: 1px; }
.aviso strong { color: var(--text-primary); font-weight: 600; }

/* ---------- Inicio ---------- */
.hero { min-height: calc(100vh - 200px); display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; padding-bottom: 6vh; }
.greet { font-size: clamp(28px, 4.2vw, 44px); line-height: 1.2; font-weight: 600; margin: 0 0 28px; }
.greet .hi { display: block; color: var(--text-muted); font-size: .55em; font-weight: 400; margin-bottom: 6px; }
.hero .composer { width: 100%; max-width: 760px; text-align: left; }
.sugg { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; max-width: 760px; margin: 20px 0 0; padding: 0; list-style: none; }
.sugg a {
  display: flex; gap: 10px; align-items: flex-start; height: 100%; min-height: 76px;
  padding: 12px 14px; border-radius: var(--radius-md); border: 2px solid var(--border-glass);
  background: rgba(13, 0, 48, .45); color: var(--text-secondary); text-decoration: none; text-align: left;
  font-size: 14px; line-height: 1.6;
}
.sugg a:hover { border-color: var(--ink); background: var(--surface-card); color: var(--text-primary); }
.sugg a .icon { width: 18px; height: 18px; color: var(--voltage); margin-top: 3px; }

/* Caja de consulta */
.composer {
  background: rgba(13, 0, 48, .75); border: 2px solid var(--border-glass); border-radius: var(--radius-md);
  padding: 14px 14px 10px 18px; box-shadow: 0 4px 2px 0 rgba(164, 159, 198, .2);
}
.composer:focus-within { border-color: var(--ink); }
.composer input[type="search"] {
  width: 100%; background: transparent; border: 0; color: var(--text-primary);
  font: inherit; font-size: 18px; line-height: 1.6; padding: 2px 0; outline: none;
}
.composer input[type="search"]::placeholder { color: var(--text-muted); opacity: 1; }
.composer:has(input:focus-visible) { outline: 2px solid var(--voltage); outline-offset: 2px; }
.crow { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin-top: 8px; }
.crow .sp { flex: 1; }
.filtros { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px;
  border: 2px dashed var(--border-glass); color: var(--text-muted); font-size: 13px; line-height: 1.5; cursor: default;
}
.chint { margin: 8px 0 0; font-size: 12px; line-height: 1.5; color: var(--text-muted); }
.send {
  width: 44px; height: 44px; border-radius: 50%; border: 0; flex-shrink: 0;
  background: var(--soho-lights); color: var(--on-bright);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.send:hover { background: var(--akoya); }
.hero .meta { margin-top: 24px; font-size: 12px; line-height: 1.6; color: var(--text-muted); }

/* ---------- Resultados ---------- */
.ask { margin-bottom: 28px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--voltage); margin: 0 0 6px; }
.sec-h { display: flex; align-items: baseline; gap: 10px; }
.sec-h .n { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.card {
  background: var(--surface-card); border: 2px solid var(--border-glass);
  border-radius: var(--radius-card); padding: 14px 18px;
}
.card h3 a { color: var(--text-primary); text-decoration: none; }
.card h3 a:hover { text-decoration: underline; color: var(--voltage); }
.card p { margin: 6px 0 0; color: var(--text-secondary); font-size: 14px; line-height: 1.55; }
.card .kind { font-size: 12px; font-weight: 600; letter-spacing: .04em; color: var(--text-muted); margin: 0 0 4px; }
.card .rmeta, .dmeta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.card .pdf { display: inline-flex; gap: 6px; align-items: center; margin-top: 10px; font-size: 13px; font-weight: 600; }
.card .pdf .icon { width: 16px; height: 16px; }
.empty { color: var(--text-muted); padding: 12px 0; margin: 0; }

/* Insignias: color + símbolo + texto (nunca solo color) */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; border: 1px solid;
}
.badge .sym { font-weight: 700; }
.b-ok { background: var(--voltage-soft); color: var(--voltage); border-color: rgba(6, 240, 251, .45); }
.b-parcial { background: var(--ink-soft); color: var(--text-secondary); border-color: var(--ink-hover); border-style: dashed; }
.b-alerta { background: var(--magenta-soft); color: var(--akoya); border-color: rgba(240, 93, 251, .45); }
.b-neutral { background: var(--muted-soft); color: var(--text-secondary); border-color: var(--border-strong); }

/* ---------- Detalle (respuesta y ficha) ---------- */
.back { display: inline-flex; gap: 6px; align-items: center; min-height: 44px; color: var(--text-muted); text-decoration: none; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.back:hover { color: var(--text-primary); }
.back .icon { width: 16px; height: 16px; }
.dmeta { font-size: 13px; color: var(--text-secondary); margin: 0 0 18px; }
.short {
  background: var(--surface-card); border-left: 4px solid var(--voltage); border-radius: var(--radius-card);
  padding: 14px 18px; margin: 0 0 20px; color: var(--text-primary);
}
.short .lbl { display: block; font-size: 12px; font-weight: 600; color: var(--voltage); margin-bottom: 4px; }
.short p { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 20px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 9px 16px;
  border-radius: var(--radius-card); border: 2px solid var(--ink); background: var(--ink);
  color: var(--text-primary); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-card); border-color: var(--ink); color: var(--text-primary); }
.btn .icon { width: 16px; height: 16px; }
.small { font-size: 12px; color: var(--text-muted); }
.md { color: var(--text-secondary); overflow-wrap: anywhere; }
.md h1, .md h2 { font-size: 20px; font-weight: 500; color: var(--text-primary); border-bottom: 1px solid var(--border-glass); padding-bottom: 6px; margin: 28px 0 10px; }
.md h3, .md h4 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin: 22px 0 8px; }
.md strong { color: var(--text-primary); }
.md blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--soho-lights); background: var(--magenta-soft); border-radius: 0 8px 8px 0; }
.md code { background: var(--glass-subtle); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.md pre { overflow-x: auto; }
.md table { display: block; overflow-x: auto; border-collapse: collapse; margin: 12px 0; font-size: 14px; border: 1px solid var(--ink); }
.md th, .md td { min-width: 9em; overflow-wrap: normal; word-break: normal; hyphens: auto; }
.md th { background: var(--surface-card); color: var(--text-primary); text-align: left; font-weight: 600; padding: 8px 10px; }
.md td { padding: 8px 10px; border-top: 1px solid var(--surface-card); vertical-align: top; }
.md hr { border: 0; height: 2px; background: var(--grad-accent); }
.prose p, .prose li { color: var(--text-secondary); }

/* ---------- Entrar ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(135deg, #18004A 0%, #0D0030 100%); }
.login-card { width: 100%; max-width: 440px; text-align: center; background: var(--surface-base); border: 2px solid var(--border-glass); border-radius: var(--radius-md); padding: 32px 24px; }
.login-card img { height: 36px; width: auto; margin: 0 auto 20px; display: block; }
.login-card .line { width: 60px; height: 2px; background: var(--voltage); margin: 0 auto 16px; border: 0; }
.login-card p { color: var(--text-secondary); margin: 0 0 24px; }
.login-card .btn { width: 100%; justify-content: center; }
.login-card .small { margin: 20px 0 0; }

/* ---------- Móvil ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side {
    position: sticky; z-index: 20; height: auto; overflow: visible; border-radius: 0;
    flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 16px;
  }
  .brand { padding: 4px 0; margin-right: auto; }
  .brand img { height: 24px; }
  .apptitle, .offlist, .side .foot .lang, .side .foot p { display: none; }
  .side nav { flex-direction: row; }
  .side nav a.newq { margin: 0; padding: 0 12px; }
  .side .foot { margin: 0; border: 0; padding: 0; }
  .session .who { display: none; }
  main { padding: 24px 16px; }
  .pie { display: block; padding: 16px; border-top: 2px solid var(--border-glass); font-size: 12px; line-height: 1.6; color: var(--text-muted); }
  .pie p { margin: 0; }
  .hero { min-height: 0; padding: 16px 0 0; }
  .greet { font-size: 28px; }
  .composer input[type="search"] { font-size: 16px; }
  .sugg { grid-template-columns: 1fr; gap: 8px; }
  .sugg a { min-height: 0; padding: 10px 12px; font-size: 13px; }
}
@media (max-width: 420px) {
  .side nav a.newq .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print {
  body, .content { background: #fff !important; color: #111 !important; }
  .side, .composer, .pie, .back, .skip { display: none !important; }
  .layout { display: block; }
  .md, .md strong, .md h2, .card p, .short { color: #111 !important; }
}

/* ---------- Formularios de cuenta ---------- */
.form { text-align: left; display: grid; gap: 8px; margin: 0 0 8px; }
.form label { font-weight: 600; font-size: 14px; margin-top: 8px; }
.form input[type="email"], .form input[type="password"], .form input[type="text"] {
  width: 100%; padding: 12px 14px; min-height: 44px; border-radius: 12px; font: inherit; font-size: 16px;
  color: var(--text-primary); background: var(--surface-raised); border: 2px solid var(--border-strong);
}
.form .btn { margin-top: 12px; justify-content: center; }
.errorlist { list-style: none; margin: 0; padding: 0; color: #FFB4C8; font-size: 14px; }
.error { color: #FFB4C8; text-align: left; }
.helptext { color: var(--text-muted); font-size: 13px; }

/* ---------- Segundo factor ---------- */
.qr { background: #fff; border-radius: 12px; padding: 8px; display: inline-block; margin: 0 auto 12px; }
.qr img { display: block; width: 200px; height: 200px; }
.login-card code { overflow-wrap: anywhere; }
.codigos { list-style: none; padding: 0; margin: 0 0 20px; columns: 2; text-align: left; }
.codigos li { margin: 4px 0; font-size: 18px; letter-spacing: .5px; }
.login-card .linkbtn { margin-top: 12px; }

/* ---------- Pendiente de revisión (fichas y respuestas con aviso) ---------- */
.b-pendiente { background: var(--soho-lights); color: var(--on-bright); border-color: var(--soho-lights); }
.card-pendiente { border-color: var(--soho-lights); border-width: 2px; }
.aviso-revision { margin: 0 0 20px; padding: 14px 16px; border-width: 2px; border-color: var(--soho-lights); background: var(--magenta-soft); font-size: 15px; }
.aviso-revision h2 { margin: 0 0 6px; font-size: 16px; font-weight: 700; color: var(--text-primary); }
.aviso-revision p { margin: 0 0 6px; color: var(--text-secondary); }
.aviso-revision p:last-child { margin-bottom: 0; }

/* ---------- Filtros de la búsqueda ---------- */
.pill-select { border-style: solid; border-color: var(--border-strong); color: var(--text-secondary); cursor: pointer; }
.pill-select select {
  background: transparent; color: var(--text-primary); border: 0; font: inherit; font-size: 13px; font-weight: 600;
  max-width: 250px; cursor: pointer; padding: 2px 0;
}
.pill-select select option { color: #0D0030; background: #FCFFFF; }
.pill-select:focus-within { outline: 2px solid var(--voltage); outline-offset: 2px; }
.pill-off { opacity: .7; }
.filtros-activos { color: var(--text-secondary); font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 12px; }
