/* Certs — hoja de estilos principal */
:root {
  --navy: #1f3a57;
  --navy-deep: #122d4a;
  --navy-soft: #2c4d72;
  --primary: #1f3a57;
  --primary-hover: #2c4d72;
  --primary-text: #ffffff;
  --link: #2a5d93;
  --accent: #3b7cc4;
  --live: #d43f3f;
  --live-soft: #fdecec;
  --ok: #1e8a55;
  --ok-soft: #e5f5ec;
  --warn: #a8660b;
  --warn-soft: #fdf3e2;
  --info-soft: #e8f0fa;

  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --hover: #eef2f7;
  --border: #e1e6ed;
  --border-strong: #cbd3de;
  --text: #1c2632;
  --muted: #5d6a7a;
  --faint: #8a95a3;
  --shadow: 0 1px 2px rgba(18, 45, 74, .06), 0 2px 8px rgba(18, 45, 74, .05);
  --shadow-lg: 0 10px 40px rgba(18, 45, 74, .16);

  --t-cert: #2563a8; --t-cert-bg: #e6eff9;
  --t-dipl: #7247b0; --t-dipl-bg: #f0eafa;
  --t-tall: #b25e08; --t-tall-bg: #fcf0e1;
  --t-curs: #11806f; --t-curs-bg: #e1f4f0;

  --radius: 10px;
  --radius-lg: 14px;
  --rail: 84px;
  --top: 52px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #4f86c2; --primary-hover: #6597cd; --primary-text: #ffffff;
    --link: #8bb8e8; --accent: #6ea6e0;
    --live: #f06262; --live-soft: #3a1d22;
    --ok: #4cc08a; --ok-soft: #173327;
    --warn: #e6a64a; --warn-soft: #3a2c16;
    --info-soft: #1a2c42;
    --bg: #0e1620; --surface: #16212e; --surface-2: #1a2735; --hover: #1f2e3e;
    --border: #253446; --border-strong: #34475d;
    --text: #e5ebf2; --muted: #9eabbb; --faint: #6f7d8e;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
    --t-cert: #7fb0e6; --t-cert-bg: #1a2c42;
    --t-dipl: #b79be6; --t-dipl-bg: #2a2140;
    --t-tall: #eba45a; --t-tall-bg: #36260f;
    --t-curs: #5fcdb8; --t-curs-bg: #12302b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --primary: #4f86c2; --primary-hover: #6597cd; --primary-text: #ffffff;
  --link: #8bb8e8; --accent: #6ea6e0;
  --live: #f06262; --live-soft: #3a1d22;
  --ok: #4cc08a; --ok-soft: #173327;
  --warn: #e6a64a; --warn-soft: #3a2c16;
  --info-soft: #1a2c42;
  --bg: #0e1620; --surface: #16212e; --surface-2: #1a2735; --hover: #1f2e3e;
  --border: #253446; --border-strong: #34475d;
  --text: #e5ebf2; --muted: #9eabbb; --faint: #6f7d8e;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 40px rgba(0,0,0,.5);
  --t-cert: #7fb0e6; --t-cert-bg: #1a2c42;
  --t-dipl: #b79be6; --t-dipl-bg: #2a2140;
  --t-tall: #eba45a; --t-tall-bg: #36260f;
  --t-curs: #5fcdb8; --t-curs-bg: #12302b;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font: 14px/1.5 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
p { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
.ic.sm { width: 16px; height: 16px; }
.ic.lg { width: 24px; height: 24px; }
.ic.fill { fill: currentColor; stroke: none; }

/* ───────── Botones y formularios ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent;
  font: 600 14px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important;
  background: var(--primary); color: var(--primary-text); transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: var(--primary-hover); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--hover); }
.btn.ghost { background: transparent; color: var(--text); }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { background: var(--live); color: #fff; }
.btn.danger:hover { filter: brightness(1.08); }
.btn.danger-ghost { background: transparent; color: var(--live); }
.btn.danger-ghost:hover { background: var(--live-soft); }
.btn.live { background: var(--live); color: #fff; }
.btn.sm { height: 30px; padding: 0 11px; font-size: 13px; gap: 6px; }
.btn.lg { height: 44px; padding: 0 22px; font-size: 15px; }
.btn.block { width: 100%; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span, .label { font-size: 13px; font-weight: 600; color: var(--text); }
.field small { color: var(--muted); font-size: 12px; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 14px var(--font);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 9px; font-size: 14px; margin-bottom: 14px; border: 1px solid transparent; }
.alert .ic { margin-top: 1px; }
.alert.error { background: var(--live-soft); color: var(--live); border-color: color-mix(in srgb, var(--live) 25%, transparent); }
.alert.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert.info { background: var(--info-soft); color: var(--link); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }

/* ───────── Insignias y avatares ───────── */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--hover); color: var(--muted); white-space: nowrap; }
.badge.Certificado { background: var(--t-cert-bg); color: var(--t-cert); }
.badge.Diplomado { background: var(--t-dipl-bg); color: var(--t-dipl); }
.badge.Taller { background: var(--t-tall-bg); color: var(--t-tall); }
.badge.Curso { background: var(--t-curs-bg); color: var(--t-curs); }
.badge.live { background: var(--live); color: #fff; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.off { background: var(--hover); color: var(--faint); }
.badge.admin { background: var(--navy); color: #fff; }
.dot-live { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }

.avatar {
  --h: 210; width: 36px; height: 36px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; letter-spacing: .02em; position: relative;
  background: hsl(var(--h) 45% 88%); color: hsl(var(--h) 50% 28%);
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; }
.avatar.lg { width: 48px; height: 48px; font-size: 17px; }
.avatar .presence { position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--surface); background: var(--faint); }
.avatar .presence.on { background: var(--ok); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h) 30% 26%); color: hsl(var(--h) 60% 85%); } }
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 30% 26%); color: hsl(var(--h) 60% 85%); }

.type-tile { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; flex: none; }
.type-tile.Certificado { background: var(--t-cert-bg); color: var(--t-cert); }
.type-tile.Diplomado { background: var(--t-dipl-bg); color: var(--t-dipl); }
.type-tile.Taller { background: var(--t-tall-bg); color: var(--t-tall); }
.type-tile.Curso { background: var(--t-curs-bg); color: var(--t-curs); }
.type-tile.lg { width: 56px; height: 56px; border-radius: 12px; }
.type-tile.lg .ic { width: 28px; height: 28px; }

/* ───────── Estructura de la aplicación ───────── */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; grid-template-rows: var(--top) 1fr; height: 100vh; height: 100dvh; }
.topbar {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 0 16px 0 0;
  background: var(--navy); color: #fff; padding-top: env(safe-area-inset-top, 0px);
}
.topbar .brand { width: var(--rail); display: grid; place-items: center; flex: none; }
.topbar .brand img { height: 26px; }
.topbar .app-name { font-weight: 600; font-size: 15px; letter-spacing: .01em; }
.topbar .spacer { flex: 1; }
.topbar .who { display: flex; align-items: center; gap: 10px; color: #fff; background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 8px; font: inherit; }
.topbar .who:hover { background: rgba(255,255,255,.1); }
.topbar .who .meta { text-align: right; line-height: 1.2; }
.topbar .who .meta b { display: block; font-size: 13px; font-weight: 600; }
.topbar .who .meta small { font-size: 11.5px; opacity: .75; }
.topbar .avatar { box-shadow: 0 0 0 2px rgba(255,255,255,.25); }
.topbar .theme-btn { color: #fff; background: none; border: 0; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.topbar .theme-btn:hover { background: rgba(255,255,255,.1); }

.rail { background: var(--surface-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 2px; }
.rail a {
  position: relative; width: 74px; padding: 8px 0 6px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 10.5px; font-weight: 600; text-decoration: none; letter-spacing: -.01em;
}
.rail a .ic { width: 22px; height: 22px; }
.rail a:hover { background: var(--hover); color: var(--text); }
.rail a.active { color: var(--primary); background: var(--hover); }
.rail a.active::before { content: ""; position: absolute; left: -6px; top: 12px; bottom: 12px; width: 3px; border-radius: 2px; background: var(--primary); }
.rail .count { position: absolute; top: 4px; right: 16px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--live); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; }
.rail .count.livecall { background: var(--live); width: 10px; min-width: 10px; height: 10px; padding: 0; top: 6px; right: 22px; animation: pulse 1.4s infinite; }
.rail .grow { flex: 1; }

.main { overflow: auto; min-width: 0; position: relative; }
.page { max-width: 1180px; margin: 0 auto; padding: 24px 28px 48px; }
.page.narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; }
.page-head p { color: var(--muted); margin-top: 3px; }
.section-title { font-size: 15px; font-weight: 600; margin: 28px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title .ic { color: var(--muted); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: var(--top) 1fr auto; }
  .rail { grid-row: 3; flex-direction: row; justify-content: space-around; border-right: 0; border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); }
  .rail a { width: auto; flex: 1; }
  .rail a.active::before { left: 25%; right: 25%; top: -5px; bottom: auto; width: auto; height: 3px; }
  .rail .grow { display: none; }
  .topbar .who .meta { display: none; }
  .page { padding: 18px 16px 32px; }
}

/* ───────── Tarjetas ───────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 15px; }

.groups-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.group-card { display: flex; flex-direction: column; gap: 14px; padding: 18px; text-decoration: none !important; color: inherit; transition: border-color .15s, transform .15s, box-shadow .15s; position: relative; }
.group-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.group-card .top { display: flex; gap: 12px; align-items: flex-start; }
.group-card h3 { font-size: 15.5px; margin-bottom: 4px; }
.group-card .people { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.group-card .live-strip { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; background: var(--live-soft); color: var(--live); font-weight: 600; font-size: 12.5px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; color: var(--faint); margin-bottom: 10px; stroke-width: 1.4; }
.empty h3 { color: var(--text); font-size: 16px; margin-bottom: 4px; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 1000px) { .two-col { grid-template-columns: 1fr; } }

/* ───────── Listas ───────── */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 11px 20px; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .sub { color: var(--muted); font-size: 12.5px; }
a.list-link { color: inherit; text-decoration: none !important; }
.list > li:has(> a.list-link):hover, .list > li.clickable:hover { background: var(--surface-2); }

/* ───────── Grupo ───────── */
.group-hero { background: var(--surface); border-bottom: 1px solid var(--border); }
.group-hero .inner { max-width: 1180px; margin: 0 auto; padding: 20px 28px 0; }
.group-hero .head { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.group-hero .head .t { flex: 1; min-width: 200px; }
.group-hero h1 { font-size: 21px; }
.group-hero .meta { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 4px; margin-top: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px 12px; color: var(--muted); font-weight: 600; text-decoration: none !important; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.live-banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-radius: var(--radius-lg); background: linear-gradient(100deg, var(--navy) 0%, var(--navy-soft) 100%); color: #fff; margin-bottom: 20px; flex-wrap: wrap; }
.live-banner .t { flex: 1; min-width: 180px; }
.live-banner b { display: block; font-size: 15px; }
.live-banner small { opacity: .8; }
.live-banner .pill { display: inline-flex; align-items: center; gap: 6px; background: var(--live); padding: 4px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; letter-spacing: .03em; }
.live-banner .btn { background: #fff; color: var(--navy); }
@media (max-width: 760px) { .group-hero .inner { padding: 16px 16px 0; } }

.aviso { padding: 18px 20px; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.aviso + .aviso { border-top: 1px solid var(--border); }
.aviso .avatar { grid-row: span 3; }
.aviso .who { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.aviso .who b { font-size: 13.5px; }
.aviso .who time { color: var(--faint); font-size: 12px; }
.aviso h3 { font-size: 16px; margin-top: 2px; }
.aviso .body { white-space: pre-wrap; word-wrap: break-word; color: var(--text); line-height: 1.6; margin-top: 4px; }
.aviso .actions { grid-column: 2; display: flex; justify-content: flex-end; }
.compose summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 20px; color: var(--muted); }
.compose summary::-webkit-details-marker { display: none; }
.compose summary .fake { flex: 1; border: 1px solid var(--border-strong); border-radius: 99px; padding: 8px 16px; }
.compose[open] summary { border-bottom: 1px solid var(--border); }
.compose form { padding: 16px 20px; }

.day-group { margin-bottom: 26px; }
.day-label { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.day-label::first-letter { text-transform: uppercase; }
.day-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.rec-card { overflow: hidden; text-decoration: none !important; color: inherit; display: flex; flex-direction: column; }
.rec-card:hover { box-shadow: var(--shadow-lg); }
.rec-thumb { aspect-ratio: 16/9; background: linear-gradient(135deg, var(--navy-deep), var(--navy-soft)); display: grid; place-items: center; position: relative; color: rgba(255,255,255,.9); }
.rec-thumb .ic { width: 38px; height: 38px; padding: 9px; border-radius: 50%; background: rgba(255,255,255,.16); box-sizing: content-box; }
.rec-thumb .dur { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 5px; }
.rec-thumb .state { position: absolute; left: 8px; top: 8px; }
.rec-card .info { padding: 11px 13px 13px; }
.rec-card .info b { display: block; font-size: 14px; line-height: 1.35; margin-bottom: 4px; }
.rec-card .info small { color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.player-wrap { background: #000; border-radius: var(--radius-lg); overflow: hidden; aspect-ratio: 16/9; }
.player-wrap video { width: 100%; height: 100%; display: block; background: #000; }

.member-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.member { display: flex; gap: 12px; align-items: center; padding: 12px 14px; }
.member .grow { min-width: 0; flex: 1; }
.member b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────── Chat ───────── */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; height: 100%; min-height: 0; }
.chat-side { border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.chat-side .head { padding: 16px 16px 10px; }
.chat-side .head h1 { font-size: 19px; margin-bottom: 10px; }
.chat-side .scroll { overflow: auto; flex: 1; padding: 0 8px 12px; }
.chat-side .group-label { font-size: 11.5px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 12px 10px 6px; }
.conv { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 10px; cursor: pointer; border: 0; background: none; width: 100%; text-align: left; font: inherit; color: inherit; }
.conv:hover { background: var(--hover); }
.conv.active { background: var(--info-soft); }
.conv .grow { flex: 1; min-width: 0; }
.conv b { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .unread { min-width: 20px; height: 20px; border-radius: 10px; background: var(--live); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; }
.conv.has-unread b { font-weight: 700; }
.conv .when { font-size: 11px; color: var(--faint); white-space: nowrap; align-self: flex-start; margin-top: 2px; }
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.chat-main .head { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); min-height: 62px; }
.chat-main .head b { font-size: 15px; }
.chat-main .back { display: none; }
.messages { flex: 1; overflow: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; }
.msg { display: flex; gap: 10px; max-width: 78%; margin-top: 10px; }
.msg.cont { margin-top: 0; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg .bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 4px 12px 12px 12px; padding: 7px 12px 8px; min-width: 0; }
.msg .meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; display: flex; gap: 8px; }
.msg .meta b { color: var(--text); }
.msg .text { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.mine .avatar { display: none; }
.msg.mine .bubble { background: var(--info-soft); border-color: color-mix(in srgb, var(--accent) 22%, transparent); border-radius: 12px 4px 12px 12px; }
.msg .role-tag { font-size: 10.5px; font-weight: 700; color: var(--t-cert); text-transform: uppercase; letter-spacing: .04em; }
.day-sep { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 3px 12px; border-radius: 99px; margin: 16px 0 6px; }
.day-sep::first-letter { text-transform: uppercase; }
.composer { display: flex; gap: 10px; padding: 12px 20px 16px; background: var(--bg); align-items: flex-end; }
.composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 160px; border-radius: 12px; padding: 11px 14px; }
.composer .btn { height: 44px; width: 44px; padding: 0; border-radius: 12px; }
.chat-empty { flex: 1; display: grid; place-items: center; }
@media (max-width: 760px) {
  .chat-layout { grid-template-columns: 1fr; }
  .chat-layout.open .chat-side { display: none; }
  .chat-layout:not(.open) .chat-main { display: none; }
  .chat-main .back { display: inline-flex; }
  .msg { max-width: 92%; }
  .messages, .composer { padding-left: 12px; padding-right: 12px; }
}
.group-chat { height: calc(100vh - 230px); min-height: 420px; display: flex; flex-direction: column; overflow: hidden; }
.group-chat .chat-main { flex: 1; }
.group-chat .messages { background: var(--bg); }

/* ───────── Tablas (admin) ───────── */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--surface-2); }
.table .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; }
.table .actions { display: flex; gap: 4px; justify-content: flex-end; }
.who-cell { display: flex; gap: 10px; align-items: center; min-width: 200px; }
.who-cell b { display: block; }
.who-cell small { color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 8px; }
.stat { padding: 16px 18px; }
.stat .k { color: var(--muted); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: -.01em; }
.stat .s { color: var(--muted); font-size: 12px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filters .input, .filters .select { height: 36px; width: auto; }
.filters .input { flex: 1; min-width: 180px; }
.segmented { display: inline-flex; background: var(--hover); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented a { padding: 5px 12px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: 13px; text-decoration: none !important; }
.segmented a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu .pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 220px; z-index: 30; }
.menu .pop form { margin: 0; }
.menu .pop button, .menu .pop a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 7px; color: var(--text); font: 13.5px var(--font); cursor: pointer; text-align: left; text-decoration: none !important; }
.menu .pop button:hover, .menu .pop a:hover { background: var(--hover); }
.menu .pop .danger { color: var(--live); }
.menu .pop hr { border: 0; border-top: 1px solid var(--border); margin: 5px 0; }
.menu .pop .head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.menu .pop .head b { display: block; }
.menu .pop .head small { color: var(--muted); }
.topbar .menu .pop { color: var(--text); }

dialog.modal { border: 0; padding: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); }
dialog.modal::backdrop { background: rgba(10, 20, 32, .5); }
dialog.modal .m-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
dialog.modal .m-head h2 { font-size: 16px; }
dialog.modal .m-body { padding: 18px 20px 6px; }
dialog.modal .m-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px 18px; }

.toast-zone { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast-zone .alert { box-shadow: var(--shadow-lg); margin: 0; }
@media (max-width: 760px) { .toast-zone { bottom: 80px; } }

/* ───────── Pantallas de acceso ───────── */
.auth { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-art { background: radial-gradient(120% 90% at 10% 0%, var(--navy-soft) 0%, var(--navy) 45%, var(--navy-deep) 100%); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art::after { content: ""; position: absolute; right: -140px; bottom: -160px; width: 520px; height: 520px; border-radius: 50%; border: 70px solid rgba(255,255,255,.04); }
.auth-art .logo { height: 46px; }
.auth-art h1 { font-size: 34px; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; max-width: 460px; }
.auth-art p.lead { margin-top: 14px; font-size: 16px; opacity: .82; max-width: 440px; line-height: 1.55; }
.auth-art .feats { display: grid; gap: 12px; margin-top: 30px; max-width: 420px; position: relative; z-index: 1; }
.auth-art .feat { display: flex; gap: 12px; align-items: center; font-size: 14.5px; }
.auth-art .feat .ic { width: 36px; height: 36px; padding: 8px; border-radius: 10px; background: rgba(255,255,255,.1); box-sizing: border-box; }
.auth-art footer { font-size: 12.5px; opacity: .6; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-box { width: 100%; max-width: 400px; }
.auth-box .mobile-logo { display: none; height: 40px; margin-bottom: 24px; }
.auth-box h2 { font-size: 24px; margin-bottom: 6px; }
.auth-box .sub { color: var(--muted); margin-bottom: 24px; }
.auth-box .links { margin-top: 18px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13.5px; }
.auth-box .divider { text-align: center; color: var(--faint); font-size: 12.5px; margin: 22px 0 14px; display: flex; gap: 12px; align-items: center; }
.auth-box .divider::before, .auth-box .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.steps { display: flex; gap: 6px; margin-bottom: 22px; }
.steps span { flex: 1; height: 4px; border-radius: 2px; background: var(--border); }
.steps span.on { background: var(--primary); }
.big-icon { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; background: var(--info-soft); color: var(--primary); margin-bottom: 18px; }
.big-icon .ic { width: 32px; height: 32px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 32px; height: 32px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; font-size: 12px; font-weight: 600; }
.pw-meter { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; margin-top: 2px; }
.pw-meter i { display: block; height: 100%; width: 0; background: var(--live); transition: width .2s, background .2s; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-box .mobile-logo { display: block; }
}

/* ───────── Asistencia ───────── */
.meter { display: inline-block; vertical-align: middle; width: 70px; height: 6px; border-radius: 3px; background: var(--hover); overflow: hidden; margin-right: 8px; }
.meter i { display: block; height: 100%; border-radius: 3px; background: var(--ok); }
.meter.mid i { background: var(--warn); }
.meter.low i { background: var(--live); }
.att-cols { grid-template-columns: minmax(0, 1fr) 360px; }
.att-cols .list > li { gap: 8px; }
.att-cols .list > li > .ic { color: var(--faint); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
small.mono { display: block; color: var(--muted); }
.table td .who-cell span b { display: block; }
.stat .meter { height: 6px; }
@media (max-width: 1000px) { .att-cols { grid-template-columns: 1fr; } }
