/* RH Lab Panel · layout: barra lateral fija + área principal en tarjetas, estilo herramienta de analítica social */
:root {
  --bg: #f3f5fa; --surface: #ffffff; --ink: #0e1a3a; --mute: #66728f; --faint: #98a2bb; --line: #e3e8f2; --line2: #eef1f8;
  --brand: #3b5bfd; --brand-ink: #2a43c9; --brand-soft: #e9edff;
  --good: #11934d; --good-soft: #e3f6ec; --bad: #d3392b; --bad-soft: #fde9e6; --warn: #b97708; --warn-soft: #fff3d9;
  --yt: #ff2d3d; --ig: #e1306c; --tt: #0f1115;
  --radius: 14px; --shadow: 0 1px 2px rgba(14,26,58,.04), 0 4px 16px rgba(14,26,58,.04);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1022; --surface: #111a33; --ink: #eef2ff; --mute: #9aa6c6; --faint: #6c7898; --line: #1f2b4d; --line2: #182243;
    --brand: #6d86ff; --brand-ink: #9fb0ff; --brand-soft: #1b2850;
    --good: #35c97d; --good-soft: #10301f; --bad: #ff7468; --bad-soft: #3a1612; --warn: #f2b84b; --warn-soft: #382a0c;
    --tt: #e8eaf0; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 36px 32px 30px; box-shadow: var(--shadow); }
.login-card img { width: 44px; height: 44px; border-radius: 11px; display: block; margin-bottom: 22px; }
.login-card h1 { font: 800 24px/1.15 var(--display); letter-spacing: -.02em; margin: 0 0 6px; }
.login-card p { color: var(--mute); margin: 0 0 22px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--mute); }
.field input { height: 44px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 10px; padding: 0 13px; font: inherit; font-size: 15px; }
.field input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.code-in { letter-spacing: .5em; font-size: 22px !important; text-align: center; font-weight: 700; }
.btn { height: 44px; border-radius: 10px; border: 0; background: var(--brand); color: #fff; font-weight: 600; width: 100%; font-size: 15px; }
.btn:hover { background: var(--brand-ink); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.ghost { background: transparent; color: var(--mute); font-weight: 500; height: 36px; margin-top: 6px; }
.btn.ghost:hover { background: var(--line2); color: var(--ink); }
.msg { min-height: 20px; font-size: 13px; color: var(--bad); margin: -4px 0 8px; }
.msg.ok { color: var(--good); }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100%; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; padding: 2px 8px; font: 800 16px var(--display); letter-spacing: -.02em; }
.logo img { width: 30px; height: 30px; border-radius: 8px; }
.logo small { display: block; font: 500 11px var(--font); color: var(--mute); letter-spacing: 0; }
.brand-sw { position: relative; }
.brand-btn { width: 100%; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 9px 11px; text-align: left; }
.brand-btn:hover { border-color: var(--faint); }
.avatar { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); font: 800 13px var(--display); flex: none; }
.brand-btn b { display: block; font-size: 13.5px; line-height: 1.2; }
.brand-btn span { font-size: 11.5px; color: var(--mute); }
.brand-btn svg { margin-left: auto; color: var(--faint); flex: none; }
.brand-menu { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(14,26,58,.14); padding: 6px; }
.brand-menu button { width: 100%; display: flex; gap: 10px; align-items: center; border: 0; background: transparent; padding: 8px; border-radius: 8px; text-align: left; }
.brand-menu button:hover, .brand-menu button[aria-current="true"] { background: var(--brand-soft); }
.nav { display: grid; gap: 2px; }
.nav-h { font-size: 11px; font-weight: 700; color: var(--faint); letter-spacing: .08em; text-transform: uppercase; padding: 10px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: var(--mute); font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--line2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.nav svg { width: 18px; height: 18px; flex: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin: 0 4.5px; }
.nav .st { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.nav .st.off { background: var(--faint); }
.nav .st.err { background: var(--bad); }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 8px 0; font-size: 12px; color: var(--mute); display: grid; gap: 8px; }
.side-foot button { border: 0; background: transparent; color: var(--mute); text-align: left; padding: 0; font-size: 12.5px; }
.side-foot button:hover { color: var(--ink); text-decoration: underline; }

.main { padding: 22px 28px 48px; min-width: 0; max-width: 1280px; width: 100%; }
.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.top h1 { font: 800 24px/1.1 var(--display); letter-spacing: -.025em; margin: 0; }
.top .sub { color: var(--mute); font-size: 13px; margin-top: 3px; }
.top-r { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--mute); }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--mute); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; }
.pill i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.pill.stale i { background: var(--warn); }

.alert { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 11px 14px; margin-bottom: 14px; font-size: 13px; font-weight: 500; }

.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 16px; }
.two { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; }
.card h2 { font: 700 15px var(--display); letter-spacing: -.01em; margin: 0; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h .hint { color: var(--mute); font-size: 12.5px; }
.card-h .push { margin-left: auto; }

.kpi { display: flex; flex-direction: column; gap: 2px; }
.kpi-l { font-size: 12.5px; color: var(--mute); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi-v { font: 800 30px/1.15 var(--display); letter-spacing: -.03em; margin-top: 4px; }
.kpi-v small { font: 600 14px var(--font); color: var(--mute); letter-spacing: 0; margin-left: 3px; }
.kpi-d { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600; margin-top: 2px; }
.kpi-d span { color: var(--mute); font-weight: 400; }
.up { color: var(--good); } .down { color: var(--bad); } .flat { color: var(--mute); }
.chip-d { padding: 2px 7px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.chip-d.up { background: var(--good-soft); } .chip-d.down { background: var(--bad-soft); } .chip-d.flat { background: var(--line2); }
.spark { height: 34px; margin-top: 8px; }
.info { display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--line2); color: var(--faint); font-size: 10px; font-weight: 700; cursor: help; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 6px 11px; border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--mute); }
.tabs button:hover { background: var(--line2); color: var(--ink); }
.tabs button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-ink); }
.chart { position: relative; width: 100%; height: 280px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart text { font: 500 11px var(--font); fill: var(--faint); }
.tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--surface); border-radius: 10px; padding: 8px 11px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.22); z-index: 5; min-width: 130px; transform: translate(-50%, -100%); }
.tip b { display: block; margin-bottom: 4px; font-weight: 600; opacity: .8; }
.tip div { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
.tip div span { display: inline-flex; align-items: center; gap: 6px; }
.tip i { width: 8px; height: 8px; border-radius: 50%; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--mute); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; }
.empty { color: var(--mute); text-align: center; padding: 34px 16px; font-size: 13.5px; }
.empty b { display: block; color: var(--ink); font: 700 15px var(--display); margin-bottom: 4px; }

.nets { display: grid; gap: 10px; }
.net { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; text-decoration: none; color: inherit; }
.net:hover { border-color: var(--faint); text-decoration: none; }
.net-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex: none; }
.net-ic svg { width: 19px; height: 19px; }
.net b { display: block; font-size: 14px; }
.net small { color: var(--mute); font-size: 12px; }
.net .n { margin-left: auto; text-align: right; }
.net .n b { font: 800 18px var(--display); letter-spacing: -.02em; }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--line2); color: var(--mute); }
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.posts { display: grid; gap: 4px; }
.post { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 7px; border-radius: 10px; color: inherit; text-decoration: none; }
.post:hover { background: var(--line2); text-decoration: none; }
.thumb { width: 54px; height: 54px; border-radius: 9px; background: var(--line2) center/cover no-repeat; position: relative; overflow: hidden; flex: none; }
.thumb.sm { width: 44px; height: 44px; border-radius: 8px; }
.thumb i { position: absolute; right: 3px; bottom: 3px; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--surface); }
.post-t { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.post-m { color: var(--mute); font-size: 12px; margin-top: 2px; }
.post-n { text-align: right; font: 800 16px var(--display); letter-spacing: -.02em; }
.post-n small { display: block; font: 500 11px var(--font); color: var(--mute); letter-spacing: 0; }

.tools { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.search { height: 38px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 10px; padding: 0 12px; min-width: 220px; font: inherit; }
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 760px; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--mute); padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.num, td.num { text-align: right; }
th button { background: none; border: 0; padding: 0; font-weight: 600; color: inherit; }
th button:hover { color: var(--ink); }
th[aria-sort] button::after { content: " ↓"; }
th[aria-sort="ascending"] button::after { content: " ↑"; }
td { padding: 9px 12px; border-bottom: 1px solid var(--line2); vertical-align: middle; }
tr:hover td { background: var(--bg); }
td.t { display: flex; gap: 11px; align-items: center; min-width: 280px; max-width: 420px; }
td.t a { color: var(--ink); font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.rchip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; }
.rchip i { width: 8px; height: 8px; border-radius: 50%; }
.top3 { font-size: 10.5px; font-weight: 800; letter-spacing: .04em; color: var(--good); background: var(--good-soft); padding: 2px 6px; border-radius: 5px; margin-left: 6px; vertical-align: middle; }
.sch { font-size: 10.5px; font-weight: 800; letter-spacing: .04em; color: var(--warn); background: var(--warn-soft); padding: 2px 6px; border-radius: 5px; margin-left: 6px; }

.cal-h { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cal-h h2 { font: 800 18px var(--display); letter-spacing: -.02em; text-transform: capitalize; min-width: 170px; }
.icon-b { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; }
.icon-b:hover { border-color: var(--faint); }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cal .dow { padding: 8px 10px; font-size: 11.5px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .05em; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--bg); }
.cal .day { min-height: 104px; padding: 6px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal .day.out { background: var(--bg); }
.cal .day.out .dn { color: var(--faint); }
.cal .dn { font-size: 12px; font-weight: 600; color: var(--mute); padding: 1px 4px; }
.cal .day.today .dn { background: var(--brand); color: #fff; border-radius: 6px; align-self: flex-start; }
.ev { display: flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 500; padding: 3px 6px; border-radius: 6px; background: var(--bg); color: var(--ink); text-decoration: none; overflow: hidden; white-space: nowrap; border-left: 3px solid var(--c); }
.ev:hover { background: var(--line2); text-decoration: none; }
.ev span { overflow: hidden; text-overflow: ellipsis; }
.ev.sch { border-left-style: dashed; background: transparent; border: 1px dashed var(--c); color: var(--ink); padding: 2px 5px; }
.more { font-size: 11px; color: var(--mute); padding: 0 4px; }

.skel { background: linear-gradient(90deg, var(--line2), var(--line), var(--line2)); background-size: 200% 100%; animation: sk 1.3s linear infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .two { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: column; gap: 10px; padding: 12px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { display: flex; overflow-x: auto; gap: 4px; padding-bottom: 2px; }
  .nav a { white-space: nowrap; padding: 8px 12px; }
  .nav-h, .side-foot { display: none; }
  .main { padding: 16px 14px 40px; }
  .cal .day { min-height: 78px; padding: 4px; }
  .ev { font-size: 10.5px; }
}
@media (max-width: 520px) { .kpis { grid-template-columns: minmax(0, 1fr); } .kpi-v { font-size: 26px; } }
