/* Panel de apps · apps.lidiaruedas.com */
@font-face { font-family: "Geist"; src: url("fonts/geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("fonts/geist-mono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #f6f6f4;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --line: #e2e1dc;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6f6e69;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series: #2a78d6;
  --grid: #e7e6e1;
  --good: #0ca30c; --good-ink: #006300; --good-bg: #e9f6e9;
  --warn: #fab219; --warn-ink: #7a5200; --warn-bg: #fdf4de;
  --crit: #d03b3b; --crit-ink: #a42525; --crit-bg: #fbeaea;
  --info-bg: #e8f1fc; --info-ink: #1c5cab;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 "Geist", system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .2rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .8rem; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
p { margin: 0 0 .8rem; }
code, pre { font-family: "Geist Mono", ui-monospace, monospace; font-size: .85em; }
code { background: var(--surface-2); padding: .05em .35em; border-radius: 5px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.icon { width: 1em; height: 1em; flex: none; vertical-align: -.125em; }
[hidden] { display: none !important; }

/* Estructura: barra lateral + contenido */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--surface) 247px, var(--line) 247px 248px, transparent 248px); }
.side { background: var(--surface); padding: 1.1rem .8rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 1.2rem; }
.brand { display: flex; gap: .65rem; align-items: center; color: var(--text); font-weight: 700; padding: 0 .4rem; }
.brand:hover { text-decoration: none; }
.brand small { display: block; font-weight: 400; font-size: .76rem; color: var(--muted); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.brand-mark .icon { width: 18px; height: 18px; }
.side-group { display: grid; gap: 2px; }
.side-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 0 .6rem .3rem; }
.side-group a { display: flex; align-items: center; gap: .6rem; padding: .42rem .6rem; border-radius: 8px; color: var(--text-2); font-size: .9rem; font-weight: 500; }
.side-group a .icon { width: 16px; height: 16px; color: var(--muted); }
.side-group a .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-group a .count { font-size: .76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.side-group a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.side-group a[aria-current] { background: var(--info-bg); color: var(--info-ink); }
.side-group a[aria-current] .icon, .side-group a[aria-current] .count { color: var(--info-ink); }
.side-foot { margin-top: auto; display: grid; gap: .6rem; justify-items: center; }
.side-foot form { width: 100%; margin: 0; }
.main { min-width: 0; }
.section-title { margin: 1.6rem 0 .8rem; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .shell { background: none; }
  .side { position: static; height: auto; border-bottom: 1px solid var(--line); padding: .8rem 16px; gap: .7rem; }
  .side-group { display: flex; gap: .3rem; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .side-group::-webkit-scrollbar { display: none; }
  .side-label { display: none; }
  .side-group a { flex: none; border: 1px solid var(--line); padding: .32rem .7rem; font-size: .85rem; }
  .side-foot { flex-direction: row; display: flex; align-items: center; gap: 1rem; }
  .side-foot form { width: auto; }
}

.wrap { max-width: 1280px; margin: 0 auto; padding: 1.6rem clamp(16px, 3vw, 2.2rem) 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.page-head form { margin: 0; }

/* Barra de escaneo */
.scanbar { background: var(--info-bg); color: var(--info-ink); border-bottom: 1px solid var(--line); }
.scanbar-inner { max-width: 1280px; margin: 0 auto; padding: .55rem 16px; display: flex; align-items: center; gap: .7rem; font-size: .9rem; flex-wrap: wrap; }
.scan-track { flex: 1; min-width: 120px; height: 6px; background: var(--surface); border-radius: 99px; overflow: hidden; }
#scan-fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .4s; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } #scan-fill { transition: none; } }

/* Tarjetas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); min-width: 0; }
.card.empty { text-align: center; padding: 2.5rem 1.5rem; }
.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid > .card { margin-bottom: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }

/* Cifras */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.tile-label { color: var(--text-2); font-size: .85rem; font-weight: 500; }
.tile-value { font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 600; letter-spacing: -.02em; line-height: 1.2; margin: .25rem 0 .2rem; font-variant-numeric: tabular-nums; }
.tile-value.small-value { font-size: 1.3rem; }
.tile-foot { font-size: .82rem; min-height: 1.2em; }
.delta { font-size: .82rem; font-weight: 500; }
.delta.up { color: var(--good-ink); }
.delta.down { color: var(--crit-ink); }

/* Avisos (siempre icono + texto, nunca solo color) */
.alert { display: flex; gap: .6rem; align-items: flex-start; padding: .7rem .9rem; border-radius: 10px; margin-bottom: .7rem; font-size: .92rem; border: 1px solid transparent; }
.alert .icon { margin-top: .2em; }
.alert.good { background: var(--good-bg); color: var(--good-ink); }
.alert.warn { background: var(--warn-bg); color: var(--text); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.alert.warn .icon { color: var(--warn-ink); }
.alert.crit { background: var(--crit-bg); color: var(--crit-ink); }
.alert.info { background: var(--info-bg); color: var(--text); }
.alert.info .icon { color: var(--info-ink); }
.badge { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; font-weight: 500; padding: .05rem .45rem; border-radius: 99px; margin-left: .3rem; vertical-align: 1px; white-space: nowrap; }
.badge.warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge.crit { background: var(--crit-bg); color: var(--crit-ink); }
.badge.info { background: var(--info-bg); color: var(--info-ink); }

/* Filtros */
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: 1.4rem 0 1rem; }
.chip { font: inherit; font-size: .88rem; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); border-radius: 99px; padding: .3rem .8rem; cursor: pointer; }
.chip span { color: var(--muted); margin-left: .2rem; font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip[aria-pressed="true"] span { color: inherit; opacity: .7; }

/* Tablas */
.table-scroll { overflow-x: auto; margin: 0 -1.2rem; padding: 0 1.2rem; }
table.apps { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.apps th { text-align: left; font-weight: 500; color: var(--muted); font-size: .8rem; padding: .4rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.apps th.num { text-align: right; }
table.apps td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.apps tr:last-child td { border-bottom: 0; }
table.apps tr.dim td { opacity: .6; }
.app-cell a { font-weight: 500; color: var(--text); }
.app-cell .sub { font-size: .8rem; color: var(--muted); }
form.inline { margin: 0; }
form.inline select { font: inherit; font-size: .82rem; padding: .2rem .3rem; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text-2); max-width: 160px; }

/* Gráficos */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .val { fill: var(--text); font-size: 12px; font-weight: 600; font-family: inherit; }
.chart .bar { fill: var(--series); }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart rect.hit:hover, .chart rect.hit:focus { fill: var(--text); fill-opacity: .05; }
.chart circle.hit:hover, .chart circle.hit:focus { fill: var(--series); fill-opacity: .25; }
.as-table { margin-top: .4rem; font-size: .82rem; color: var(--muted); }
.as-table summary { cursor: pointer; }
table.mini { border-collapse: collapse; margin-top: .4rem; }
table.mini td { padding: .1rem .8rem .1rem 0; }
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: var(--bg); font-size: .8rem; font-weight: 500; padding: .3rem .55rem; border-radius: 6px; white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); }

/* Formularios */
.stack { display: grid; gap: .8rem; }
label { display: grid; gap: .25rem; font-size: .85rem; color: var(--text-2); font-weight: 500; }
label.check { display: flex; gap: .5rem; align-items: center; color: var(--text); }
input, select, textarea { font: inherit; font-size: .95rem; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); width: 100%; min-width: 0; }
input[type="checkbox"] { width: auto; }
input:focus, select:focus, textarea:focus, .chip:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .8rem 1rem 1rem; margin: 0; display: grid; gap: .7rem; min-width: 0; }
legend { font-weight: 600; padding: 0 .3rem; }
.sources { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 1rem; align-items: start; }
.sources > .btn { justify-self: start; }
.row-form { display: flex; gap: .5rem; margin-top: 1rem; }
.row-form select { flex: 1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .95rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.full { width: 100%; }

dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; font-size: .92rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; }
@media (max-width: 520px) { dl.facts { grid-template-columns: 1fr; } dl.facts dd { margin-bottom: .4rem; } }
pre.code { background: var(--surface-2); padding: .8rem 1rem; border-radius: 8px; white-space: pre-wrap; word-break: break-all; margin: 0; }
ul.plain, ul.stale-list { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
ul.stale-list li { padding: .5rem 0; border-bottom: 1px solid var(--line); }
ul.stale-list li:last-child { border-bottom: 0; }

/* Acceso */
body.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 1.8rem; }
.auth-card h1 { font-size: 1.4rem; }

/* Portada: pestañas, periodo y tarjetas de apps */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.head-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.head-actions form { margin: 0; }
.period select { width: auto; font-weight: 500; padding: .48rem 2rem .48rem .8rem; border-color: var(--accent); box-shadow: 0 0 0 3px var(--info-bg); }
.tile.accent { border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); background: linear-gradient(180deg, var(--info-bg), var(--surface) 70%); }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: 1.6rem 0 .8rem; flex-wrap: wrap; }
.list-head h2 { margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a { padding: .3rem .8rem; font-size: .85rem; color: var(--text-2); }
.seg a + a { border-left: 1px solid var(--line); }
.seg a[aria-current] { background: var(--surface-2); color: var(--text); font-weight: 500; }
.seg a:hover { text-decoration: none; color: var(--text); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 1.1rem; margin-bottom: 1rem; }
.appcard { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .03); transition: border-color .15s, box-shadow .15s, transform .15s; overflow: hidden; }
.appcard:hover, .appcard:focus-visible { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 10px 28px rgba(28, 92, 171, .10); transform: translateY(-2px); outline: none; }
@media (prefers-reduced-motion: reduce) { .appcard { transition: none; } .appcard:hover { transform: none; } }
.appcard-head { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.1rem .9rem; }
.appcard-title { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.appcard-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
.avatar { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-weight: 700; flex: none; font-size: 1rem; }
.cat-ventas { background: #e3eefb; color: #1c5cab; }
.cat-clientes { background: #dff4ec; color: #0e6b4a; }
.cat-internas { background: #ebe8fb; color: #4a3aa7; }
.cat-personales { background: #fbe9f0; color: #a3305c; }
.cat-webs { background: #fdf0d9; color: #8a5a00; }
.cat-revisar, .cat-borrar { background: var(--surface-2); color: var(--text-2); }
.pill { display: inline-flex; align-items: center; gap: .25rem; font-size: .7rem; font-weight: 600; padding: .2rem .5rem; border-radius: 6px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; flex: none; border: 1px solid var(--line); }
.pill.good { background: var(--good-bg); color: var(--good-ink); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.pill.crit { background: var(--crit-bg); color: var(--crit-ink); border-color: transparent; }
dl.stats { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem 1rem; margin: 0; }
dl.stats.sec { padding: .85rem 1.1rem; border-top: 1px solid var(--line); }
dl.stats.three { grid-template-columns: repeat(3, 1fr); }
dl.stats.three dd { font-size: 1rem; }
dl.stats div { min-width: 0; }
dl.stats dt { font-size: .74rem; color: var(--muted); }
dl.stats dd { margin: .1rem 0 0; font-size: 1.25rem; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unsure { color: var(--muted); font-weight: 500; }
.band { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; font-size: .8rem; color: var(--text-2); background: var(--surface-2); padding: .6rem 1.1rem; margin-top: auto; border-top: 1px solid var(--line); }
.band strong { color: var(--text); font-weight: 600; }
.band.warn { background: var(--warn-bg); color: var(--warn-ink); }
.warn-ink { color: var(--warn-ink); }

/* Guía de borrado */
ol.steps { margin: 0; padding-left: 1.3rem; display: grid; gap: .55rem; }
ol.steps em { font-style: normal; font-weight: 600; }
.appcard.static:hover { transform: none; box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 14px rgba(0, 0, 0, .03); border-color: var(--line); }
.appcard .sec { padding: .7rem 1.1rem; border-top: 1px solid var(--line); }
.appcard .why { color: var(--warn-ink); background: var(--warn-bg); }
ul.todo { list-style: none; margin: 0; display: grid; gap: .45rem; font-size: .88rem; }
ul.todo code { font-size: .8rem; }
.btn.small { padding: .25rem .6rem; font-size: .8rem; }

/* Decisión por app */
.appcard-main { display: flex; flex-direction: column; color: inherit; flex: 1; }
.appcard-main:hover { text-decoration: none; }
.appcard:has(.appcard-main:hover) { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 10px 28px rgba(28, 92, 171, .10); }
.appcard:hover { transform: none; }
.note { margin: 0; font-size: .82rem; color: var(--text-2); font-style: italic; }
.decide { display: flex; align-items: center; gap: .5rem; padding: .55rem 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.decide-label { font-size: .76rem; color: var(--muted); }
form.decision { margin: 0; flex: 1; min-width: 150px; }
form.decision select { font-size: .85rem; font-weight: 600; padding: .3rem .5rem; border-radius: 7px; }
select.dec-none { color: var(--muted); font-weight: 500; }
select.dec-mantener { background: var(--good-bg); color: var(--good-ink); border-color: transparent; }
select.dec-mejorar { background: var(--info-bg); color: var(--info-ink); border-color: transparent; }
select.dec-retomar { background: #ebe8fb; color: #4a3aa7; border-color: transparent; }
select.dec-vender { background: #dff4ec; color: #0e6b4a; border-color: transparent; }
select.dec-aparcar { background: var(--surface-2); color: var(--text-2); }
select.dec-borrar { background: var(--crit-bg); color: var(--crit-ink); border-color: transparent; }
select.dec-borrada { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }
table.apps form.decision select { max-width: 170px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin: 0 3px; }
.dot.dec-none { background: transparent; border: 2px solid var(--muted); }
.dot.dec-mantener { background: var(--good); }
.dot.dec-mejorar { background: var(--accent); }
.dot.dec-retomar { background: #6250d6; }
.dot.dec-vender { background: #1baf7a; }
.dot.dec-aparcar { background: #9a998f; }
.dot.dec-borrar { background: var(--crit); }
.dot.dec-borrada { background: var(--line); }

/* Barra lateral compacta: periodo en botones pequeños */
.side { gap: .95rem; padding: 1rem .75rem; }
.side-group a { padding: .34rem .6rem; }
.side-group.periods { display: flex; flex-wrap: wrap; gap: 4px; }
.side-group.periods .side-label { width: 100%; }
.side-group.periods a { padding: .22rem .6rem; border: 1px solid var(--line); border-radius: 99px; font-size: .8rem; }
.side-group.periods a[aria-current] { border-color: transparent; }
@media (max-width: 900px) { .side-group.periods { flex-wrap: nowrap; } }

/* Webs */
.pill.info { background: var(--info-bg); color: var(--info-ink); border-color: transparent; }
.band .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }
.cat-webs_comerciales { background: #fde9df; color: #a2421a; }
.src-list, .top-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; font-size: .9rem; }
.src-list li, .top-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem; align-items: center; }
.src-list .bar-row { grid-column: 1 / -1; height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.src-list .bar-row span { display: block; height: 100%; background: var(--series); border-radius: 99px; }
.top-list code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Guardado sin recargar */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; font-size: .9rem; font-weight: 500; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100vw - 32px); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--crit); color: #fff; }
.leaving { opacity: 0; transform: scale(.97); transition: opacity .3s, transform .3s; }
@media (prefers-reduced-motion: reduce) { .toast, .leaving { transition: none; } }

.row-form.tight { margin: 0 0 .2rem; }
