/* AnalistaP · extracted stylesheet (design AD-5)
   Dark token set and component patterns ported from FreshConv
   (frontend/src/index.css). AnalistaP's own page structure, layout, and
   spacing are retained unchanged — only colors, radii, elevation, and
   typography move to FreshConv's system. See openspec/changes/
   freshconv-look-and-feel/design.md for the full component mapping and the
   list of what was deliberately NOT ported. */

:root {
  --bg-dark: #0d1117;
  --bg-panel: #161b22;
  --bg-border: #30363d;
  --bg-border-hover: #3b4249;
  --text-main: #e6edf3;
  --text-muted: #8b949e;

  --primary: #2f81f7;
  --primary-hover: #1f6feb;
  --primary-tint: rgba(47, 129, 247, .1);
  --primary-tint-weak: rgba(47, 129, 247, .05);
  --focus-ring: rgba(47, 129, 247, .2);

  --ok: #3fb950;
  --ok-bg: rgba(63, 185, 80, .1);
  --err: #f85149;
  --err-bg: rgba(248, 81, 73, .1);
  --warn: #e3b341;
  --warn-border: #d29922;
  --warn-bg: rgba(210, 153, 34, .12);

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, 'Cascadia Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.wrap { max-width: 1180px; width: 100%; margin: 0 auto; padding: 0 40px; }
code { font-family: var(--mono); font-size: .86em; }

/* top */
.top { display: flex; align-items: center; justify-content: space-between; padding: 15px 40px; background: var(--bg-panel); border-bottom: 1px solid var(--bg-border); position: sticky; top: 0; z-index: 20; }
.top .brand { display: flex; align-items: center; gap: 14px; }
.top .brand img { height: 30px; width: auto; display: block; }
.top .brand .div { width: 1px; height: 22px; background: var(--bg-border); }
.top .brand .sub { font-weight: 500; color: var(--text-muted); font-size: 13.5px; }
.top-r { display: flex; align-items: center; gap: 14px; }
.env { display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 9px; border: 1px solid var(--bg-border); border-radius: 999px; font-family: var(--mono); font-size: 11px; color: var(--text-muted); }
.env .d { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 185, 80, .16); }
.dash { display: inline-flex; align-items: center; gap: 8px; padding: 9px 17px; border-radius: 999px; background: var(--primary); color: #fff; font-weight: 600; font-size: 13px; text-decoration: none; transition: .15s; }
.dash:hover { background: var(--primary-hover); }
.dash svg { width: 15px; height: 15px; }

/* hero band */
.band-hero { background: var(--bg-panel); border-bottom: 1px solid var(--bg-border); position: relative; overflow: hidden; }
.ring { position: absolute; border-radius: 50%; border: 26px solid; opacity: .4; pointer-events: none; }
.ring.r1 { width: 230px; height: 230px; border-color: rgba(47, 129, 247, .15); top: -70px; right: 8%; opacity: .5; }
.ring.r2 { width: 120px; height: 120px; border-color: rgba(139, 148, 158, .1); top: 90px; right: 3%; }
.ring.r3 { width: 160px; height: 160px; border-color: rgba(47, 129, 247, .12); bottom: -80px; left: -30px; }
.hero { position: relative; z-index: 1; padding: 44px 0 48px; }
.kick { display: inline-block; font-size: 11.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: #fff; background: var(--primary); padding: 5px 13px; border-radius: 999px; margin-bottom: 18px; }
.hero h1 { font-size: 28px; font-weight: 700; line-height: 1.05; letter-spacing: -.02em; margin: 0 0 14px; color: var(--text-main); }
.hero h1 .g { color: var(--primary); }
.hero p { margin: 0 0 22px; color: var(--text-muted); font-size: 15.5px; max-width: 62ch; }
.hero p code { background: var(--bg-dark); border: 1px solid var(--bg-border); border-radius: 6px; padding: 1px 7px; color: var(--primary); }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--bg-border); border-radius: 999px; padding: 6px 13px; font-size: 12.5px; color: var(--text-muted); font-family: var(--mono); }
.chip b { color: var(--primary); font-weight: 600; }

/* sections */
.band { padding: 42px 0; }
.band-blue { background: var(--bg-panel); padding: 42px 0 52px; }
.shead { display: flex; align-items: center; gap: 14px; margin: 0 0 20px; }
.shead .num { width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.shead h2 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; margin: 0; color: var(--text-main); }
.shead .hint { margin-left: auto; font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid.two { grid-template-columns: repeat(2, 1fr); max-width: 780px; }
@media (max-width: 1080px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .grid, .grid.two { grid-template-columns: 1fr; } .wrap { padding: 0 22px; } }
.card { background: var(--bg-panel); border: 1px solid var(--bg-border); border-radius: 8px; padding: 24px; display: flex; flex-direction: column; transition: .2s; }
.card:hover { border-color: var(--bg-border-hover); }
.chead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.ct { display: flex; align-items: center; gap: 11px; }
.ci { width: 38px; height: 38px; border-radius: 11px; background: var(--primary-tint); color: var(--primary); display: grid; place-items: center; }
.ci svg { width: 19px; height: 19px; stroke-width: 1.8; }
.ct h3 { font-size: 16px; font-weight: 600; margin: 0; color: var(--text-main); }
.badge { font-family: var(--mono); font-size: 10px; letter-spacing: .03em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; background: var(--bg-dark); border: 1px solid var(--bg-border); color: var(--text-muted); font-weight: 500; }
.lede { margin: 13px 0 18px; color: var(--text-muted); font-size: 13.5px; }
.lede code { color: var(--primary); }

.drop { border: 2px dashed var(--bg-border); border-radius: 8px; padding: 24px 16px; text-align: center; cursor: pointer; background: var(--bg-dark); transition: .15s; display: block; }
.drop:hover, .drop.dragover { border-color: var(--primary); background: var(--primary-tint-weak); }
.drop .di { width: 42px; height: 42px; margin: 0 auto 11px; border-radius: 12px; background: var(--bg-panel); border: 1px solid var(--bg-border); display: grid; place-items: center; color: var(--primary); }
.drop:hover .di, .drop.dragover .di { background: var(--primary); color: #fff; border-color: var(--primary); }
.drop .di svg { width: 20px; height: 20px; stroke-width: 1.8; }
.drop .c1 { font-size: 13.5px; } .drop .c1 b { color: var(--primary); font-weight: 600; }
.drop .c2 { font-family: var(--mono); font-size: 11px; color: var(--text-muted); margin-top: 5px; }
.drop .fn { display: none; margin-top: 11px; padding: 8px 11px; background: var(--bg-panel); border: 1px solid var(--bg-border); border-radius: 9px; font-family: var(--mono); font-size: 11.5px; text-align: left; word-break: break-all; color: var(--primary); }
.drop.has-file .fn { display: block; } .drop.has-file .c2 { display: none; }
.drop input[type=file] { display: none; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--text-muted); display: flex; justify-content: space-between; }
.field label .sv { color: var(--ok); font-weight: 500; display: none; align-items: center; gap: 5px; font-family: var(--mono); font-size: 10.5px; }
.field label .sv.on { display: inline-flex; }
.field label .sv::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.input { width: 100%; padding: 11px 13px; background: var(--bg-dark); border: 1px solid var(--bg-border); border-radius: 6px; font-family: var(--sans); font-size: 13px; color: var(--text-main); outline: none; transition: .15s; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--focus-ring); }
select.input { cursor: pointer; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 12px 16px; margin-top: auto; border-radius: 6px; border: none; background: var(--primary); color: #fff; font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; transition: .15s; }
.btn:hover { background: var(--primary-hover); }
.btn[disabled], .btn.disabled { opacity: .6; cursor: not-allowed; pointer-events: none; }
.btn.ghost { background: var(--bg-border); color: var(--text-main); }
.btn.ghost:hover { background: var(--bg-border-hover); }
.btn .spinner { width: 13px; height: 13px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; display: none; }
.btn.loading .spinner { display: inline-block; }
.btn.loading .label { opacity: .7; }
.btn.ghost .spinner { border-color: rgba(230, 237, 243, .3); border-top-color: var(--text-main); }
@keyframes spin { to { transform: rotate(360deg); } }
.form-tail { margin-top: auto; display: flex; flex-direction: column; }
.cfoot { margin-top: 14px; display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 10.5px; color: var(--text-muted); }
.cfoot kbd { border: 1px solid var(--bg-border); background: var(--bg-dark); padding: 1px 5px; border-radius: 5px; color: var(--text-muted); }

/* status (message-block pattern) */
.status { margin-top: 14px; padding: 8px 10px; border-radius: 3px; font-family: var(--mono); font-size: 12px; line-height: 1.4; display: none; align-items: flex-start; gap: 9px; border-left: 2px solid var(--bg-border); background: var(--bg-panel); color: var(--text-muted); }
.status.show { display: flex; }
.status::before { content: ""; width: 7px; min-width: 7px; height: 7px; margin-top: 5px; border-radius: 50%; background: var(--text-muted); }
.status.ok { background: var(--ok-bg); border-left-color: var(--ok); color: var(--ok); }
.status.ok::before { background: var(--ok); }
.status.err { background: var(--err-bg); border-left-color: var(--err); color: var(--err); }
.status.err::before { background: var(--err); }
.status.info { background: var(--primary-tint); border-left-color: var(--primary); color: var(--primary); }
.status.info::before { background: var(--primary); }

/* portal menu */
.menu-intro { margin: 0 0 26px; }
.menu-intro h2 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 6px; color: var(--text-main); }
.menu-intro p { margin: 0; color: var(--text-muted); font-size: 14px; }
.portal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 24px; max-width: 1180px; }
@media (max-width: 760px) { .portal-grid { grid-template-columns: 1fr; } }
.portal { position: relative; overflow: hidden; text-align: left; font: inherit; color: inherit; cursor: pointer; background: var(--bg-panel); border: 1px solid var(--bg-border); border-radius: 10px; padding: 30px 28px; display: flex; flex-direction: column; gap: 15px; transition: .2s; }
.portal::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--primary); opacity: 0; transition: .2s; }
.portal:hover { border-color: var(--bg-border-hover); }
.portal:hover::before { opacity: 1; }
.portal:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
.portal .pi { width: 56px; height: 56px; border-radius: 16px; background: var(--primary-tint); color: var(--primary); display: grid; place-items: center; }
.portal .pi svg { width: 28px; height: 28px; stroke-width: 1.7; }
.portal h3 { font-size: 21px; font-weight: 700; letter-spacing: -.01em; margin: 0; color: var(--text-main); }
.portal p { margin: 0; color: var(--text-muted); font-size: 13.5px; line-height: 1.5; flex: 1; }
.portal .go { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; color: var(--primary); }
.portal .go svg { width: 16px; height: 16px; transition: transform .2s; }
.portal:hover .go svg { transform: translateX(4px); }

/* views + back control */
.back-row { padding-top: 24px; }
.back-to-menu { display: inline-flex; align-items: center; gap: 7px; padding: 8px 15px; border-radius: 999px; border: 1px solid var(--bg-border); background: transparent; color: var(--text-muted); font: inherit; font-weight: 600; font-size: 12.5px; cursor: pointer; transition: .15s; }
.back-to-menu:hover { border-color: var(--bg-border-hover); color: var(--text-main); }
.back-to-menu svg { width: 14px; height: 14px; stroke-width: 2.2; }

/* footer */
.foot-strip { background: var(--bg-panel); border-top: 1px solid var(--bg-border); color: var(--text-muted); text-align: center; padding: 11px; font-size: 12px; }
.foot-strip a { color: var(--text-main); text-decoration: underline; text-underline-offset: 2px; }
footer { background: var(--bg-dark); border-top: 1px solid var(--bg-border); }
.fin { display: flex; justify-content: space-between; align-items: center; padding: 22px 0; font-family: var(--mono); font-size: 11.5px; color: var(--text-muted); gap: 16px; flex-wrap: wrap; }
.fin img { height: 26px; }
.fin .lk { display: flex; gap: 20px; }
.fin a { color: var(--text-muted); text-decoration: none; }
.fin a:hover { color: var(--text-main); }

/* Ingest history panel */
.history { grid-column: 1 / -1; margin-top: 24px; background: var(--bg-panel); border: 1px solid var(--bg-border); border-radius: 8px; padding: 18px 20px; }
.history .hhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.history .hhead h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-main); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.htable { width: 100%; border-collapse: collapse; font-size: 13px; }
.htable th, .htable td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--bg-border); }
.htable th { font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: .04em; color: var(--text-muted); }
.htable tr:hover td { background: var(--primary-tint-weak); }
.hbadge { padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--bg-dark); border: 1px solid var(--bg-border); color: var(--text-muted); }
.hbadge.ok { color: var(--ok); background: var(--ok-bg); }
.hbadge.err { color: var(--err); background: var(--err-bg); }
.hbadge.warn { color: var(--warn); background: var(--warn-bg); }
.hbadge.info { color: var(--primary); background: var(--primary-tint); }
.sub-label { margin: 1.5rem 0 .6rem; font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--text-muted); }

/* Cobertura de snapshots: una tira de 31 celdas por mes, no un calendario alineado
   por dia de semana (eso pediria celdas de offset y encabezados L-M-M-J-V-S-D). */
.cob-meses { display: grid; gap: 16px; }
.cob-mes { border: 1px solid var(--bg-border); border-radius: 8px; padding: 12px 14px; background: var(--bg-dark); }
.cob-mes-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cob-mes-head h4 { margin: 0; font-size: 13.5px; font-weight: 600; color: var(--text-main); text-transform: capitalize; }
.cob-mes-head .hbadge { margin-left: auto; }
.cob-dias { display: grid; grid-template-columns: repeat(31, minmax(0, 1fr)); gap: 4px; }
.cob-dia { display: grid; place-items: center; aspect-ratio: 1; min-height: 20px; border: 1px solid var(--bg-border); border-radius: 4px; font-family: var(--mono); font-size: 10px; color: var(--text-muted); }
.cob-dia.ok { color: var(--ok); background: var(--ok-bg); border-color: var(--ok); }
.cob-dia.miss { color: var(--err); background: var(--err-bg); border-color: var(--err); }
.cob-dia.oob { opacity: .3; }
.cob-legend { display: flex; align-items: center; gap: 18px; margin: 0 0 14px; font-size: 12px; color: var(--text-muted); }
.cob-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cob-legend .cob-dia { width: 13px; height: 13px; min-height: 13px; aspect-ratio: auto; }
@media (max-width: 900px) { .cob-dias { grid-template-columns: repeat(16, minmax(0, 1fr)); } }

/* Cobertura · tablist (Prestamos / Marketing). */
.cob-tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid var(--bg-border); }
.cob-tabs button { background: none; border: none; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.cob-tabs button:hover { color: var(--text-main); }
.cob-tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

/* login gate */

/* The gate replaces the app rather than layering under its chrome (FreshConv
   frontend/src/main.jsx:73 renders the logo once, in the card). The header and
   both footer strips live outside #login-gate and #ops-ui, so without this they
   drew over the gate and put a second and third logo above and below the card.
   Keyed off one class on <body>, set by showLoginGate()/showOpsUi(); none of
   these three elements may carry an inline `display`, which would outrank it. */
body.gated .top,
body.gated .foot-strip,
body.gated footer { display: none; }

/* Full viewport, since with the chrome hidden there is no 63px header to
   subtract — that offset is what left the card visibly off-centre. */
.login-gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg-dark); }
.login-box { width: 100%; max-width: 360px; padding: 28px; background: var(--bg-panel); border: 1px solid var(--bg-border); border-radius: 8px; }
.login-box h2 { margin: 0 0 6px; font-size: 19px; font-weight: 700; color: var(--text-main); }
.login-box .sub { margin: 0 0 24px; font-size: 13.5px; color: var(--text-muted); }
#logout-btn { padding: 8px 16px; border-radius: 999px; border: 1px solid var(--bg-border); background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; cursor: pointer; transition: .15s; }
#logout-btn:hover { border-color: var(--bg-border-hover); color: var(--text-main); }

/* Gate family (design AD-2/AD-5, FreshConv index.css:2100-2242): the logo,
   the divider between the Microsoft path and the password fallback, and the
   amber bootstrap/probe-failure notice. Unused until the gate markup is
   reordered (PR3) and diagnosability lands (PR4) — dead CSS, harmless. */
.gate-logo { height: 34px; width: auto; display: block; margin-bottom: 12px; }
.gate-divider { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 12px; margin: 16px 0; }
.gate-divider::before, .gate-divider::after { content: ''; flex: 1; height: 1px; background: var(--bg-border); }
.gate-notice { font-size: 13px; line-height: 1.4; color: var(--warn); background: var(--warn-bg); border-left: 2px solid var(--warn-border); border-radius: 3px; padding: 8px 10px; margin: 0 0 16px; }
.gate-secret-label { color: var(--text-muted); font-size: 12px; margin: 4px 0 8px; }

/* Persistent Microsoft SSO renewal banner (task 1.8): `display:none` stays
   an INLINE style on #msal-session-banner in index.html on purpose —
   showSessionExpiredBanner() clears the inline style, and a class-level
   display:none default here would silently swallow that. Every other
   property migrates here. */
.session-banner { position: sticky; top: 0; z-index: 30; background: var(--bg-panel); border-bottom: 1px solid var(--warn-border); color: var(--warn); padding: 10px 20px; text-align: center; font-size: 13px; }
.session-banner button { width: auto; margin-left: 12px; }
/* Retry-failure text, shown inside the banner because #gate-notice is inside
   the login box and therefore unreachable while this banner is on screen.
   `display: block` so it wraps onto its own line under the button; the `hidden`
   attribute (not a class) controls visibility, and the global reset gives
   [hidden] display:none, so no rule here may set display unconditionally. */
.session-banner-error { display: block; margin-top: 8px; font-family: var(--mono); font-size: 12px; color: var(--err); }
.session-banner-error[hidden] { display: none; }

/* Focus rings on the gate controls (WCAG 2.4.7, FreshConv index.css:2238) */
.login-box .btn:focus-visible,
.login-box .input:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* consultas view */
.consulta-layout { display: grid; grid-template-columns: minmax(320px, 400px) minmax(0, 1fr); gap: 24px; align-items: start; }
.consulta-ask { position: sticky; top: 84px; }
@media (max-width: 900px) { .consulta-layout { grid-template-columns: 1fr; } .consulta-ask { position: static; } }
.consulta-ask .input { resize: vertical; min-height: 96px; line-height: 1.45; }
.chip-btn { background: none; cursor: pointer; font: inherit; font-family: var(--mono); text-align: left; white-space: normal; line-height: 1.35; width: 100%; justify-content: flex-start; transition: .15s; }
.chip-btn:hover { border-color: var(--primary); color: var(--text-main); }
.consulta-out { min-height: 320px; }
.consulta-vacio { color: var(--text-muted); font-size: 13.5px; }
.consulta-vacio p { margin: 0; }
.consulta-respuesta { font-size: 14.5px; line-height: 1.6; color: var(--text-main); }
.consulta-respuesta p { margin: 0 0 12px; }
.consulta-respuesta ul { margin: 0 0 12px; padding-left: 20px; }
.consulta-respuesta .tscroll { margin: 4px 0 16px; }
.tscroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.htable td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.consulta-query { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--bg-border); }
.consulta-query h4 { margin: 0 0 12px; font-size: 13.5px; font-weight: 600; color: var(--text-main); }
.consulta-query details { margin-top: 10px; }
.consulta-query summary { cursor: pointer; font-family: var(--mono); font-size: 12px; color: var(--primary); }
.consulta-query pre { margin: 8px 0 0; padding: 12px 14px; background: var(--bg-dark); border: 1px solid var(--bg-border); border-radius: 6px; font-family: var(--mono); font-size: 12px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--text-main); }
#consulta-footer { margin-bottom: 0; }
