/* Meta Backup Portal · estilos (tokens de Pithy Academy) */
:root {
  --ink: #0F2B33;
  --ink-soft: #1B3C46;
  --paper: #F3F6F7;
  --surface: #FFFFFF;
  --line: #DCE4E7;
  --line-2: #C6D3D8;
  --text: #14262C;
  --text-2: #3E555D;
  --muted: #64787F;
  --brand: #00B4C8;
  --brand-deep: #00788A;
  --brand-wash: #E3F6F8;
  --ok: #1E9E6A;
  --ok-wash: #E4F5EC;
  --mid: #C27F12;
  --mid-wash: #FCF1DC;
  --bad: #CF3F55;
  --bad-wash: #FCE8EB;
  --r-s: 8px;
  --r: 14px;
  --r-l: 22px;
  --shadow: 0 1px 2px rgba(15, 43, 51, .06), 0 8px 24px -12px rgba(15, 43, 51, .18);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --side: 232px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--text); font: 15px/1.55 var(--body); -webkit-font-smoothing: antialiased; overflow-x: clip; }
img, svg { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-deep); }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(24px, 3vw, 32px); font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 19px; }
h3 { font-size: 16px; }
p { margin: 0 0 .8em; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.ic { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- botones, campos, chips ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 999px; border: 1.5px solid transparent; font-weight: 700; font-size: 14px; text-decoration: none; white-space: nowrap; background: none; transition: background .15s, border-color .15s, transform .15s var(--ease); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-soft); }
.btn-ghost { border-color: var(--line-2); color: var(--text); background: var(--surface); }
.btn-ghost:hover { border-color: var(--text-2); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .45; pointer-events: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand-deep); font-weight: 700; display: inline-flex; gap: 6px; align-items: center; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.input, select.input { padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--line-2); background: var(--surface); outline: none; min-height: 40px; }
.input:focus { border-color: var(--brand-deep); box-shadow: 0 0 0 4px var(--brand-wash); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--paper); color: var(--text-2); border: 1px solid var(--line); white-space: nowrap; }
.chip-ok { background: var(--ok-wash); color: var(--ok); border-color: transparent; }
.chip-mid { background: var(--mid-wash); color: var(--mid); border-color: transparent; }
.chip-bad { background: var(--bad-wash); color: var(--bad); border-color: transparent; }
.chip-brand { background: var(--brand-wash); color: var(--brand-deep); border-color: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); display: inline-block; flex: none; }
.dot-ok { background: var(--ok); }
.dot-mid { background: var(--mid); }

/* ---------- carga ---------- */
.loading { min-height: 60vh; display: grid; place-items: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- acceso ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); background: var(--ink); color: #fff; }
.login-copy { padding: clamp(28px, 6vw, 72px); display: flex; flex-direction: column; justify-content: space-between; gap: 40px; background: radial-gradient(120% 90% at 0% 100%, rgba(0, 180, 200, .28), transparent 60%), var(--ink); }
.login-copy img { height: 28px; width: auto; align-self: flex-start; object-fit: contain; }
.login-copy h1 { font-size: clamp(34px, 4.8vw, 58px); line-height: 1.02; max-width: 13ch; }
.login-copy p { color: rgba(255, 255, 255, .78); font-size: 17px; max-width: 44ch; margin: 18px 0 0; }
.login-panel { display: grid; place-items: center; padding: 40px 20px; background: var(--paper); color: var(--text); position: relative; }
.login-lang { position: absolute; top: 18px; right: 20px; }
/* Selector de idioma: dos opciones con bandera, la activa resaltada (mismo lenguaje visual que el selector de período). */
.lang { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.lang button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; border-radius: 999px; padding: 4px 10px 4px 7px; font: 700 12px/1 var(--body); color: var(--text-2); letter-spacing: .02em; cursor: pointer; }
.lang button svg { width: 18px; height: 12px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(15, 43, 51, .12); flex: none; }
.lang button.on { background: var(--ink); color: #fff; cursor: default; }
.lang button:hover:not(.on) { background: var(--paper); }
.lang button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 26px; margin-bottom: 6px; }
.login-card .lead { color: var(--muted); margin-bottom: 22px; }
.login-card label { display: block; font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.login-card .input { width: 100%; margin-bottom: 8px; }
.login-card .btn { width: 100%; margin-top: 8px; padding: 12px; }
.form-err { color: var(--bad); font-size: 14px; min-height: 22px; font-weight: 600; margin: 0; }
@media (max-width: 820px) { .login { grid-template-columns: 1fr; } .login-copy { min-height: 38vh; } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--ink); color: #fff; padding: 22px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px; }
.side-logo { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.side-logo img { height: 22px; width: auto; }
.side-logo span { font-family: var(--display); font-weight: 700; font-size: 15px; opacity: .9; }
.client-pick { background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .14); border-radius: 12px; padding: 10px 12px; }
.client-pick small { display: block; color: rgba(255, 255, 255, .6); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.client-pick strong { display: block; font-size: 14px; line-height: 1.3; margin-top: 2px; }
.client-pick span { font-size: 12px; color: rgba(255, 255, 255, .6); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: rgba(255, 255, 255, .78); text-decoration: none; font-weight: 600; font-size: 14px; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav a.on { background: var(--brand); color: var(--ink); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; font-size: 12px; color: rgba(255, 255, 255, .55); padding: 0 8px; }
.side-foot .link-btn { color: rgba(255, 255, 255, .8); font-size: 13px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(243, 246, 247, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding: 10px clamp(16px, 3vw, 32px); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.preview-tag { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--mid); background: var(--mid-wash); border-radius: 999px; padding: 4px 10px; }
.topbar .grow { flex: 1; }
.period { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.period .input { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.page { padding: 22px clamp(16px, 3vw, 32px) 60px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.menu-btn { display: none; }
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .25s var(--ease); }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(15, 43, 51, .45); }
  .menu-btn { display: inline-flex; }
}

/* ---------- tarjetas y KPIs ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.kpi small { display: block; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.kpi strong { display: block; font-family: var(--display); font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
.callout { border-radius: var(--r); padding: 14px 16px; background: var(--mid-wash); color: #6B4708; font-size: 14px; }
.callout strong { display: block; margin-bottom: 4px; }
.callout ul { margin: 6px 0 0; padding-left: 18px; }
.callout-brand { background: var(--brand-wash); color: var(--ink); border: 1px solid rgba(0, 120, 138, .25); }
.callout-brand .ic { color: var(--brand-deep); }
.callout-dark { background: var(--ink); color: rgba(255, 255, 255, .85); }
.callout-dark strong { color: #fff; }
.evidence { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.evidence div { background: rgba(255, 255, 255, .08); border-radius: 10px; padding: 10px 12px; }
.evidence b { display: block; font-family: var(--display); font-size: 22px; color: #fff; }

/* ---------- gráfico diario ---------- */
.chart { width: 100%; height: auto; max-width: 100%; }
.seg { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.seg button.on { background: var(--ink); color: #fff; }
.seg button:hover:not(.on) { background: var(--surface); }
.delta-up { color: var(--bad); font-weight: 700; }
.delta-down { color: var(--ok); font-weight: 700; }
.chart .bar { fill: var(--brand); }
.chart .bar:hover { fill: var(--brand-deep); }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 2; }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: var(--body); }
.chart .grid { stroke: var(--line); }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend { flex-wrap: wrap; }
/* Fin de los datos: día del borrado (el portal es histórico, no hay datos después). */
.legend i.del-key { width: 0; height: 12px; border-radius: 0; border-left: 2px dashed var(--bad, #C2410C); margin-right: 8px; vertical-align: -2px; }
.chart .del-mark line { stroke: var(--bad, #C2410C); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .del-mark text { fill: var(--bad, #C2410C); font-size: 11px; font-weight: 700; font-family: var(--body); }
/* Etiqueta junto al selector de período: todo se cuenta hasta el borrado. */
.period-cap { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; cursor: help; }
.period-cap svg { width: 15px; height: 15px; color: var(--bad, #C2410C); }
.period-cap b { color: var(--ink); }

/* ---------- tablas ---------- */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.tbl-scroll { overflow: auto; max-height: calc(100vh - 230px); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.tbl th { position: sticky; top: 0; z-index: 2; background: #F8FAFB; text-align: left; font-weight: 700; color: var(--text-2); font-size: 12.5px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none; }
.tbl th.sortable { cursor: pointer; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th .arrow { color: var(--brand-deep); margin-left: 4px; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: #FAFCFC; }
.tbl tr.sel td { background: var(--brand-wash); }
.tbl .r { text-align: right; white-space: nowrap; }
.tbl tr.total td { background: #F8FAFB; font-weight: 700; position: sticky; top: 39px; z-index: 1; }
.tbl .name { min-width: 240px; max-width: 420px; }
.tbl .name .link-btn { font-weight: 700; color: var(--text); }
.tbl .name .link-btn:hover { color: var(--brand-deep); }
.tbl .sub { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; align-items: center; }
.tbl .chk { width: 36px; }
.tbl input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--brand-deep); }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--paper); border: 1px solid var(--line); }
.thumb-empty { width: 44px; height: 44px; border-radius: 8px; background: var(--paper); border: 1px dashed var(--line-2); display: grid; place-items: center; color: var(--muted); font-size: 10px; }
.more { padding: 14px; text-align: center; border-top: 1px solid var(--line); }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* ---------- explorador ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 6px; background: var(--surface); }
.tab { border: 0; background: none; padding: 13px 14px 11px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; display: inline-flex; align-items: center; gap: 8px; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--ink); border-bottom-color: var(--brand); }
.tab .chip { font-size: 11px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 12px; border-bottom: 1px solid var(--line); }
.toolbar .search { flex: 1 1 220px; min-width: 180px; }
.toolbar label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--text-2); padding: 0 6px; }
.selbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 12px; background: var(--brand-wash); font-size: 13.5px; color: var(--brand-deep); font-weight: 600; }

/* ---------- galería ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.gcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; text-align: left; padding: 0; box-shadow: var(--shadow); transition: transform .18s var(--ease), box-shadow .18s; }
.gcard:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -14px rgba(15, 43, 51, .35); }
.gcard .cover { position: relative; aspect-ratio: 4 / 5; background: var(--ink); }
.gcard .cover img { width: 100%; height: 100%; object-fit: cover; }
.gcard .rank { position: absolute; top: 10px; left: 10px; background: rgba(15, 43, 51, .85); color: #fff; font-weight: 800; font-size: 12px; border-radius: 999px; padding: 3px 9px; }
.gcard .badge { position: absolute; top: 10px; right: 10px; }
.gcard .gbody { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.gcard .gtitle { font-weight: 700; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gstats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.gstats div { background: var(--paper); border-radius: 8px; padding: 6px 8px; }
.gstats small { display: block; font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.gstats b { font-size: 14px; }

/* ---------- ficha (panel lateral) ---------- */
.drawer-bg { position: fixed; inset: 0; background: rgba(15, 43, 51, .45); z-index: 80; animation: fade .2s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--paper); z-index: 90; overflow-y: auto; box-shadow: -20px 0 50px -20px rgba(15, 43, 51, .5); animation: slide .28s var(--ease); }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); padding: 14px 20px; display: flex; gap: 12px; align-items: flex-start; }
.drawer-head .grow { flex: 1; min-width: 0; }
.crumbs { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.crumbs .link-btn { font-size: 12.5px; }
.drawer-head h2 { margin-top: 4px; font-size: 20px; overflow-wrap: anywhere; }
.drawer-head .sub { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.close { border: 0; background: var(--paper); border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; flex: none; }
.drawer-body { padding: 18px 20px 40px; display: flex; flex-direction: column; gap: 14px; }
.ad-top { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 640px) { .ad-top { grid-template-columns: 1fr; } }
.ad-cover { border-radius: var(--r); overflow: hidden; background: var(--ink); aspect-ratio: 9 / 16; max-height: 430px; }
.ad-cover img { width: 100%; height: 100%; object-fit: cover; }
.ad-cover .none { color: rgba(255, 255, 255, .7); display: grid; place-items: center; height: 100%; padding: 20px; text-align: center; font-size: 13px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.mgrid div { background: var(--paper); border-radius: 10px; padding: 8px 10px; }
.mgrid small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.mgrid b { font-size: 16px; font-family: var(--display); }
.variants { display: flex; flex-direction: column; gap: 8px; }
.variant { background: var(--paper); border-radius: 10px; padding: 10px 12px; white-space: pre-wrap; font-size: 14px; position: relative; }
.variant .n { font-size: 11px; font-weight: 800; color: var(--brand-deep); display: block; margin-bottom: 2px; text-transform: uppercase; letter-spacing: .05em; }
.copy { position: absolute; top: 8px; right: 8px; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.bars { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.bars .row { display: grid; grid-template-columns: 110px minmax(0, 1fr) 140px; gap: 10px; align-items: center; }
.bars .track { height: 10px; background: var(--paper); border-radius: 99px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--brand); border-radius: 99px; }
.bars .val { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.vlist { display: flex; flex-direction: column; gap: 8px; }
.vitem { display: flex; gap: 10px; align-items: center; background: var(--paper); border-radius: 10px; padding: 8px; font-size: 13.5px; }
.funnel { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; font-size: 12px; }
.funnel div { background: var(--paper); border-radius: 8px; padding: 8px 4px; }
.funnel b { display: block; font-size: 15px; }
.mini-list { display: flex; flex-direction: column; }
.mini-list button { display: flex; justify-content: space-between; gap: 10px; border: 0; background: none; border-bottom: 1px solid var(--line); padding: 9px 2px; text-align: left; font-size: 13.5px; }
.mini-list button:hover { color: var(--brand-deep); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 100; }
.btn-light { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .3); }
.btn-light:hover { background: rgba(255, 255, 255, .24); }
.chip-orange { background: #FFE8D6; color: #B4470B; border-color: transparent; font-weight: 700; }
.tbl th .sorter { color: var(--muted); margin-left: 4px; font-size: 11px; }

