/* Agenda Social · panel. Sin build: un solo archivo de estilos con tokens en :root. */

:root {
  --bg: oklch(98.4% 0.004 85);
  --surface: oklch(100% 0 0);
  --surface-2: oklch(96.4% 0.006 85);
  --surface-3: oklch(93.5% 0.008 85);
  --line: oklch(90.5% 0.008 85);
  --line-strong: oklch(83% 0.01 85);
  --text: oklch(23% 0.016 262);
  --muted: oklch(47% 0.016 262);
  --faint: oklch(60% 0.012 262);
  --accent: oklch(49% 0.15 262);
  --accent-hover: oklch(43% 0.15 262);
  --accent-soft: oklch(94% 0.03 262);
  --on-accent: oklch(99% 0 0);
  --ok: oklch(50% 0.12 155);
  --ok-soft: oklch(94.5% 0.04 155);
  --bad: oklch(52% 0.17 27);
  --bad-soft: oklch(95% 0.03 27);
  --warn: oklch(55% 0.12 70);
  --warn-soft: oklch(95.5% 0.05 85);
  --busy: oklch(50% 0.14 300);
  --busy-soft: oklch(95% 0.03 300);
  --off: oklch(56% 0.01 262);
  --off-soft: oklch(94.5% 0.004 262);
  --net-instagram: oklch(58% 0.2 355);
  --net-facebook: oklch(52% 0.17 262);
  --net-threads: oklch(28% 0.01 262);
  --net-youtube: oklch(56% 0.21 27);
  --net-gbp: oklch(56% 0.14 150);
  --net-test: oklch(58% 0.1 205);
  --shadow: 0 1px 2px oklch(20% 0.02 262 / 0.06), 0 8px 24px -6px oklch(20% 0.02 262 / 0.12);
  --shadow-lg: 0 2px 6px oklch(20% 0.02 262 / 0.08), 0 24px 56px -12px oklch(20% 0.02 262 / 0.28);
  --radius: 10px;
  --radius-sm: 7px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(17.5% 0.012 262);
    --surface: oklch(21% 0.013 262);
    --surface-2: oklch(24% 0.014 262);
    --surface-3: oklch(28% 0.015 262);
    --line: oklch(30% 0.014 262);
    --line-strong: oklch(38% 0.016 262);
    --text: oklch(94% 0.006 262);
    --muted: oklch(73% 0.014 262);
    --faint: oklch(60% 0.014 262);
    --accent: oklch(70% 0.13 262);
    --accent-hover: oklch(76% 0.12 262);
    --accent-soft: oklch(30% 0.06 262);
    --on-accent: oklch(18% 0.03 262);
    --ok: oklch(74% 0.13 155);
    --ok-soft: oklch(29% 0.05 155);
    --bad: oklch(72% 0.15 27);
    --bad-soft: oklch(30% 0.06 27);
    --warn: oklch(80% 0.12 80);
    --warn-soft: oklch(31% 0.05 80);
    --busy: oklch(74% 0.12 300);
    --busy-soft: oklch(30% 0.06 300);
    --off: oklch(66% 0.01 262);
    --off-soft: oklch(27% 0.008 262);
    --net-threads: oklch(88% 0.01 262);
    --net-facebook: oklch(66% 0.15 262);
    --shadow: 0 1px 2px oklch(0% 0 0 / 0.3), 0 8px 24px -6px oklch(0% 0 0 / 0.4);
    --shadow-lg: 0 2px 6px oklch(0% 0 0 / 0.35), 0 24px 56px -12px oklch(0% 0 0 / 0.6);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); color: var(--text); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 650; }
h2 { font-size: 1.125rem; font-weight: 620; }
h3 { font-size: 0.9375rem; font-weight: 620; }
p { margin: 0; }
code { font: 0.875em ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.8125rem; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Controles ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 38px; padding: 0 0.9rem;
  font: inherit; font-weight: 560; font-size: 0.875rem;
  color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out, transform 120ms ease-out;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.icon { padding: 0; width: 38px; }
.btn.sm { min-height: 32px; padding: 0 0.65rem; font-size: 0.8125rem; }
.btn.icon.sm { width: 32px; }
.btn[aria-busy="true"] { cursor: progress; opacity: 0.7; }

.field { display: grid; gap: 0.35rem; font-size: 0.8125rem; font-weight: 560; color: var(--muted); }
.field > span { display: flex; justify-content: space-between; gap: 0.5rem; }
input[type="text"], input[type="password"], input[type="url"], input[type="date"], input[type="time"], select, textarea {
  width: 100%; min-height: 40px; padding: 0.5rem 0.7rem;
  font: inherit; font-size: 0.9375rem; font-weight: 400; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; padding-right: 2rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; }
.segmented button { font: inherit; font-size: 0.8125rem; font-weight: 560; padding: 0.35rem 0.8rem; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; transition: background-color 150ms ease-out, color 150ms ease-out; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px oklch(20% 0.02 262 / 0.12); }

.switch { position: relative; width: 40px; height: 24px; flex: none; appearance: none; margin: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-strong); cursor: pointer; transition: background-color 180ms ease-out, border-color 180ms ease-out; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); box-shadow: 0 1px 3px oklch(0% 0 0 / 0.25); transition: transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1); }
.switch:checked { background: var(--ok); border-color: var(--ok); }
.switch:checked::after { transform: translateX(16px); }

.check { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.7rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: 0.875rem; transition: border-color 150ms ease-out, background-color 150ms ease-out; }
.check:hover { border-color: var(--line-strong); }
.check:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.check input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.check:has(input:disabled) { opacity: 0.55; cursor: not-allowed; }

/* ---------- Marco ---------- */

.app { min-height: 100dvh; display: grid; grid-template-columns: 232px 1fr; }
.rail {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 1.5rem;
  padding: 1.25rem 0.85rem; background: var(--surface-2); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.6rem; padding: 0 0.5rem; color: var(--text); text-decoration: none; font-weight: 650; letter-spacing: -0.01em; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 0.7rem; padding: 0.55rem 0.65rem; border-radius: var(--radius-sm); color: var(--muted); text-decoration: none; font-weight: 540; transition: background-color 150ms ease-out, color 150ms ease-out; }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px oklch(20% 0.02 262 / 0.08); }
.nav a[aria-current="page"] .ic { color: var(--accent); }
.logout { margin-top: auto; }
.logout .btn { width: 100%; justify-content: flex-start; }

.main { min-width: 0; padding: 1.75rem clamp(1rem, 3vw, 2.5rem) 3rem; outline: none; }
.view { max-width: 1240px; margin: 0 auto; display: grid; gap: 1.25rem; }
.view-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; justify-content: space-between; }
.view-head .tools { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.view-head p { margin-top: 0.25rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--line); }
.panel-body { padding: 1.1rem; }

/* ---------- Estados y redes ---------- */

.status { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; color: var(--st); background: var(--st-soft); }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
[data-status="scheduled"] { --st: var(--accent); --st-soft: var(--accent-soft); }
[data-status="publishing"] { --st: var(--busy); --st-soft: var(--busy-soft); }
[data-status="published"] { --st: var(--ok); --st-soft: var(--ok-soft); }
[data-status="failed"] { --st: var(--bad); --st-soft: var(--bad-soft); }
[data-status="partial"] { --st: var(--warn); --st-soft: var(--warn-soft); }
[data-status="canceled"] { --st: var(--off); --st-soft: var(--off-soft); }

.net { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8125rem; color: var(--muted); }
.net::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--net, var(--faint)); flex: none; }
[data-net="instagram"] { --net: var(--net-instagram); }
[data-net="facebook"] { --net: var(--net-facebook); }
[data-net="threads"] { --net: var(--net-threads); }
[data-net="youtube"] { --net: var(--net-youtube); }
[data-net="gbp"] { --net: var(--net-gbp); }
[data-net="test"] { --net: var(--net-test); }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--net); }

/* ---------- Calendario ---------- */

.cal-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.cal-bar .title { font-size: 1.125rem; font-weight: 620; min-width: 11ch; }
.cal-bar .tools { display: flex; align-items: center; gap: 0.35rem; }
.cal-bar .spacer { flex: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.month { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; }
.month .dow { background: var(--surface-2); padding: 0.45rem 0.6rem; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: capitalize; }
.day { background: var(--surface); min-height: 118px; padding: 0.4rem; display: flex; flex-direction: column; gap: 3px; min-width: 0; text-align: left; border: 0; font: inherit; color: inherit; }
.day.out { background: var(--surface-2); }
.day.out .daynum { color: var(--faint); }
.daynum { font-size: 0.8125rem; font-weight: 600; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.day.today .daynum { background: var(--accent); color: var(--on-accent); }
.day .more { font-size: 0.75rem; color: var(--muted); padding: 0 0.35rem; background: none; border: 0; text-align: left; cursor: pointer; font: inherit; font-size: 0.75rem; }
.day .more:hover { color: var(--text); text-decoration: underline; }
.mobile-dots { display: none; }

.chip {
  display: flex; align-items: center; gap: 0.35rem; width: 100%; min-width: 0;
  padding: 0.2rem 0.4rem; border: 0; border-radius: 5px;
  font: inherit; font-size: 0.75rem; text-align: left; cursor: pointer;
  color: var(--text); background: var(--st-soft);
  transition: filter 150ms ease-out;
}
.chip:hover { filter: brightness(0.96); }
.chip .t { font-weight: 650; color: var(--st); font-variant-numeric: tabular-nums; flex: none; }
.chip .x { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.chip[data-status="canceled"] .x { text-decoration: line-through; color: var(--muted); }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.6rem; }
.wday { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.wday-head { display: flex; align-items: baseline; gap: 0.4rem; padding: 0.25rem 0.2rem 0.4rem; border-bottom: 1px solid var(--line); }
.wday-head b { font-size: 1.25rem; font-weight: 640; font-variant-numeric: tabular-nums; }
.wday-head span { font-size: 0.8125rem; color: var(--muted); text-transform: capitalize; }
.wday.today .wday-head b { color: var(--accent); }
.wday .empty-day { font-size: 0.8125rem; color: var(--faint); padding: 0.25rem 0.2rem; }
.card-post {
  display: grid; gap: 0.35rem; padding: 0.6rem 0.65rem; text-align: left; width: 100%; min-width: 0; overflow: hidden;
  font: inherit; color: var(--text); background: var(--surface); cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
}
.card-post:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.card-post .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.3rem 0.4rem; }
.card-post .time { font-size: 0.8125rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.card-post .x { font-size: 0.8125rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.card-post .thumb { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 5px; background: var(--surface-2); }

.day-list { display: none; }

/* ---------- Hojas (detalle y formulario) ---------- */

dialog.sheet {
  width: min(560px, 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  margin: 0 0 0 auto; padding: 0; border: 0; border-left: 1px solid var(--line);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.sheet.wide { width: min(720px, 100vw); }
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in 240ms cubic-bezier(0.16, 1, 0.3, 1); }
dialog.sheet::backdrop { background: oklch(18% 0.02 262 / 0.38); animation: fade-in 200ms ease-out; }
@keyframes sheet-in { from { transform: translateX(32px); opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); }
.sheet-body { flex: 1; overflow-y: auto; padding: 1.25rem; display: grid; gap: 1.25rem; align-content: start; }
.sheet-foot { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; padding: 0.85rem 1.25rem calc(0.85rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface-2); }
.sheet-foot .left { margin-right: auto; display: flex; gap: 0.5rem; flex-wrap: wrap; }

.post-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9375rem; line-height: 1.55; max-width: 65ch; }
.meta { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; font-size: 0.875rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; }
.targets { display: grid; gap: 0.5rem; }
.target { display: grid; gap: 0.3rem; padding: 0.7rem 0.8rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.target .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; }
.target .name { font-weight: 580; font-size: 0.875rem; }
.target .err { font-size: 0.8125rem; color: var(--bad); white-space: pre-wrap; }
.target .metrics { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.8125rem; color: var(--muted); }
.target .metrics b { color: var(--text); font-weight: 620; font-variant-numeric: tabular-nums; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 0.5rem; }
.media-item { position: relative; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.media-item img, .media-item video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-item .kind { position: absolute; left: 6px; bottom: 6px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: oklch(15% 0.01 262 / 0.65); color: oklch(98% 0 0); }
.media-item .kind .ic { width: 14px; height: 14px; }
.media-item .remove { position: absolute; top: 5px; right: 5px; width: 26px; height: 26px; min-height: 0; padding: 0; border-radius: 50%; background: oklch(15% 0.01 262 / 0.7); border: 0; color: oklch(98% 0 0); }
.media-item .remove:hover { background: oklch(15% 0.01 262 / 0.9); }
.media-item .remove .ic { width: 14px; height: 14px; }
.media-item .progress { position: absolute; inset: auto 0 0 0; height: 4px; background: oklch(15% 0.01 262 / 0.3); }
.media-item .progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width 120ms linear; }
.media-item.uploading img { opacity: 0.5; }
.media-item .filename { position: absolute; inset: 0; display: grid; place-items: center; padding: 0.5rem; font-size: 0.75rem; color: var(--muted); text-align: center; overflow-wrap: anywhere; }

.drop {
  display: grid; place-items: center; gap: 0.3rem; padding: 1.1rem; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius); color: var(--muted); font-size: 0.875rem;
  transition: border-color 150ms ease-out, background-color 150ms ease-out;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.drop .ic { width: 22px; height: 22px; color: var(--accent); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.stack { display: grid; gap: 1rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.accounts-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.5rem; }
.group-title { font-size: 0.8125rem; font-weight: 600; color: var(--muted); margin-bottom: 0.5rem; }
.counter { font-weight: 500; font-variant-numeric: tabular-nums; }
.counter.over { color: var(--bad); }
.net-options { display: grid; gap: 0.75rem; padding: 0.9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.net-options h3 { display: flex; align-items: center; gap: 0.5rem; }
.form-error { white-space: pre-wrap; font-size: 0.875rem; color: var(--bad); background: var(--bad-soft); padding: 0.7rem 0.85rem; border-radius: var(--radius-sm); }
.hint { font-size: 0.8125rem; color: var(--muted); font-weight: 400; }
.when-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: end; }
.when-row .field { flex: 1 1 140px; }

/* ---------- Cuentas ---------- */

.providers { display: grid; gap: 0; }
.provider { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; padding: 0.95rem 1.1rem; border-top: 1px solid var(--line); }
.provider:first-child { border-top: 0; }
.provider .who { flex: 1 1 260px; display: grid; gap: 0.15rem; min-width: 0; }
.provider .who b { font-weight: 600; }
.provider .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pill { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; font-weight: 600; padding: 0.1rem 0.5rem; border-radius: 999px; }
.pill.ok { color: var(--ok); background: var(--ok-soft); }
.pill.warn { color: var(--warn); background: var(--warn-soft); }

.acc-list { display: grid; }
.acc { display: flex; align-items: center; gap: 0.85rem; padding: 0.8rem 1.1rem; border-top: 1px solid var(--line); }
.acc:first-child { border-top: 0; }
.acc .who { flex: 1; min-width: 0; display: grid; gap: 0.1rem; }
.acc .who b { font-weight: 580; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc.disabled .who b { color: var(--muted); }
.avatar { width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 650; font-size: 0.875rem; color: oklch(99% 0 0); background: var(--net, var(--faint)); }
.acc.disabled .avatar { filter: grayscale(1); opacity: 0.6; }

/* ---------- Estadísticas ---------- */

.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; }
.filters .field { min-width: 180px; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.kpi { padding: 1rem 1.15rem; display: grid; gap: 0.2rem; border-left: 1px solid var(--line); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi .label { font-size: 0.8125rem; color: var(--muted); font-weight: 540; }
.kpi .value { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .delta { font-size: 0.8125rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); }
.kpi .delta.up { color: var(--ok); }
.kpi .delta.down { color: var(--bad); }
.kpi .delta span { font-weight: 400; color: var(--muted); }

.stats-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.chart-wrap { position: relative; }
.chart { width: 100%; height: 240px; display: block; overflow: visible; }
.chart .grid line { stroke: var(--line); }
.chart .axis text { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .area { fill: var(--accent); opacity: 0.1; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .bar { fill: var(--accent); opacity: 0.85; }
.chart .bar:hover { opacity: 1; }
.chart .hover-line { stroke: var(--line-strong); stroke-dasharray: 3 3; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.tooltip { position: absolute; pointer-events: none; padding: 0.4rem 0.6rem; font-size: 0.8125rem; background: var(--text); color: var(--bg); border-radius: 6px; white-space: nowrap; transform: translate(-50%, -110%); box-shadow: var(--shadow); }
.tooltip b { font-variant-numeric: tabular-nums; }

.top-list { display: grid; }
.top-item { display: grid; grid-template-columns: 1.6rem 1fr auto; gap: 0.75rem; align-items: start; padding: 0.75rem 1.1rem; border-top: 1px solid var(--line); }
.top-item:first-child { border-top: 0; }
.top-item .rank { font-weight: 650; color: var(--faint); font-variant-numeric: tabular-nums; }
.top-item .cap { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; font-size: 0.875rem; }
.top-item .sub { display: flex; flex-wrap: wrap; gap: 0.2rem 0.8rem; font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }
.top-item .score { text-align: right; font-variant-numeric: tabular-nums; font-weight: 620; font-size: 0.875rem; }
.top-item .score span { display: block; font-size: 0.75rem; font-weight: 400; color: var(--muted); }

.slots { display: grid; gap: 0.45rem; }
.slot { display: grid; grid-template-columns: 8.5rem 1fr 3rem; gap: 0.6rem; align-items: center; font-size: 0.8125rem; }
.slot .when { text-transform: capitalize; font-weight: 560; }
.slot .bar-bg { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.slot .bar-bg i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.slot .s { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ---------- Vacíos, carga y avisos ---------- */

.empty { display: grid; justify-items: start; gap: 0.6rem; padding: 1.5rem 1.25rem; }
.empty h3 { font-size: 1rem; }
.empty p { color: var(--muted); max-width: 60ch; font-size: 0.875rem; }
.empty .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.25rem; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }
.notice { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.75rem 0.9rem; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--text); font-size: 0.875rem; }
.notice.info { background: var(--accent-soft); }

.toasts { position: fixed; z-index: 50; left: 50%; bottom: calc(1rem + env(safe-area-inset-bottom)); transform: translateX(-50%); display: grid; gap: 0.5rem; width: min(440px, calc(100vw - 2rem)); pointer-events: none; }
.toast { pointer-events: auto; padding: 0.7rem 0.95rem; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); font-size: 0.875rem; box-shadow: var(--shadow-lg); white-space: pre-wrap; animation: toast-in 220ms cubic-bezier(0.16, 1, 0.3, 1); }
.toast.bad { background: var(--bad); color: oklch(99% 0 0); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Acceso ---------- */

body.gate { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; }
.gate-card { width: min(380px, 100%); display: grid; gap: 0.75rem; padding: 2rem 1.75rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.gate-card h1 { font-size: 1.375rem; margin-top: 0.5rem; }
.gate-card form { margin-top: 0.75rem; }
.gate-card .btn { width: 100%; min-height: 42px; }

/* ---------- Celular ---------- */

@media (max-width: 1080px) {
  .stats-grid { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: fixed; z-index: 20; inset: auto 0 0 0; top: auto; height: auto;
    flex-direction: row; align-items: center; gap: 0; padding: 0.3rem 0.4rem calc(0.3rem + env(safe-area-inset-bottom));
    border-right: 0; border-top: 1px solid var(--line); background: var(--surface);
  }
  .brand { display: none; }
  .nav { flex: 1; grid-auto-flow: column; grid-auto-columns: 1fr; }
  .nav a, .logout .btn { flex-direction: column; gap: 0.15rem; padding: 0.4rem 0.2rem; font-size: 0.6875rem; justify-content: center; min-height: 52px; }
  .nav a[aria-current="page"] { background: transparent; box-shadow: none; color: var(--accent); }
  .logout { margin: 0; flex: 0 0 64px; }
  .logout .btn { width: 100%; }
  .ic { width: 20px; height: 20px; }
  .main { padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom)); }
  h1 { font-size: 1.3125rem; }

  .day { min-height: 54px; padding: 0.3rem 0.15rem; align-items: center; cursor: pointer; }
  .day .chip, .day .more { display: none; }
  .day .daynum { width: 28px; height: 28px; }
  .day.selected .daynum { outline: 2px solid var(--accent); outline-offset: -2px; }
  .day.today.selected .daynum { outline-color: var(--text); }
  .mobile-dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
  .mobile-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--st); }
  .month .dow { padding: 0.4rem 0; text-align: center; }
  .day-list { display: grid; gap: 0.5rem; }
  .day-list h2 { font-size: 1rem; margin-top: 0.25rem; }

  .week { grid-template-columns: 1fr; gap: 1rem; }
  .wday-head { position: sticky; top: 0; background: var(--bg); z-index: 1; }

  dialog.sheet, dialog.sheet.wide { width: 100vw; border-left: 0; }
  @keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
  .grid-2 { grid-template-columns: 1fr; }
  .kpi .value { font-size: 1.4rem; }
  .slot { grid-template-columns: 7.5rem 1fr 2.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* Ajustes sueltos */
.cal-bar select { width: auto; min-height: 32px; padding-top: 0.25rem; padding-bottom: 0.25rem; font-size: 0.8125rem; }
.sheet-head .spacer { flex: 1; }
fieldset.plain { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.plain legend { padding: 0; }
.sheet-form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.sheet-foot .left p { align-self: center; }
#media-grid:empty { display: none; }
.stack > .segmented { justify-self: start; }
.panel-head .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.top-item > div { min-width: 0; }
.stats-grid > *, .stack > * { min-width: 0; }
.segmented button { white-space: nowrap; }
@media (max-width: 860px) {
  .filters { width: 100%; }
  .filters .field { flex: 1 1 140px; min-width: 0; }
  .filters .btn { flex: 1 1 100%; }
  .view-head .tools { width: 100%; }
  .view-head .tools .btn.primary { flex: 1; }
}
