/* Panel del bot moderador — tema claro con tonos pastel.
   Los colores de texto cumplen contraste AA (4,5:1 o más) sobre sus fondos. */

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --sidebar: #eef1f9;
  --sidebar-hover: #e2e7f5;
  --text: #2b3140;
  --muted: #5d6677;
  --border: #e0e5ef;
  --border-strong: #c9d1e1;

  --primary: #4b68bf;
  --primary-hover: #405bab;
  --primary-soft: #e7edfb;
  --primary-ink: #2f4892;

  --green-soft: #e1f3e7;  --green-ink: #22653e;
  --amber-soft: #fcf0d4;  --amber-ink: #765000;
  --red-soft: #fbe6e6;    --red-ink: #9c3131;  --red-line: #efc6c6;
  --lilac-soft: #eee8fa;  --lilac-ink: #573d93;
  --sky-soft: #e3f2f8;    --sky-ink: #1f5e78;
  --grey-soft: #eceff4;   --grey-ink: #4c5566;

  --focus: #8aa4ec;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(43, 49, 64, .04), 0 2px 8px rgba(43, 49, 64, .05);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { font-size: 16px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-ink); text-underline-offset: 3px; }
a:hover { color: var(--primary); }

h1, h2, h3 { line-height: 1.3; color: var(--text); }
h1 { font-size: 1.75rem; margin: 0; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1.05rem; margin: 1.5rem 0 .6rem; }
p { margin: 0 0 .75rem; }

code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .9em; }
code { background: var(--grey-soft); color: var(--grey-ink); padding: .1em .4em; border-radius: 5px; white-space: nowrap; }

.muted { color: var(--muted); }
.lead { margin-top: .75rem; }
.narrow-card { max-width: 560px; width: 100%; }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Foco visible para quien usa teclado */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 10;
  background: var(--primary); color: #fff; padding: .5rem 1rem; border-radius: var(--radius-sm);
}
.skip-link:focus { top: 1rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Estructura ---------- */

.layout { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 1.4rem 1rem;
  display: flex; flex-direction: column; gap: 1.6rem;
}

.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; padding: 0 .6rem; }
.brand-logo { width: 2.1rem; height: 2.1rem; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); font-size: 1.1rem; }

.nav-title { font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 .6rem; margin: 0 0 .4rem; }
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.nav a {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem .6rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--sidebar-hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 650; color: var(--primary-ink); }
.nav .icon { width: 1.4rem; text-align: center; }
.nav .group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: .6rem; height: .6rem; border-radius: 50%; flex: none; background: var(--border-strong); }
.dot-sim { background: #e9c46a; }
.dot-on { background: #6cc28c; }

.sidebar-footer { margin-top: auto; border-top: 1px solid var(--border); padding: 1rem .6rem 0; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

.content { padding: 2rem clamp(1rem, 3vw, 2.75rem) 4rem; min-width: 0; }

.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-head p { margin: .35rem 0 0; }
.crumbs { font-size: .9rem; color: var(--muted); margin: 0 0 .4rem; }
.crumbs a { color: var(--muted); }

.section-title { font-size: 1.25rem; margin: 2.25rem 0 1rem; }

/* ---------- Pestañas del grupo ---------- */

.tabs { display: flex; flex-wrap: wrap; gap: .35rem; border-bottom: 1px solid var(--border); margin: 0 0 1.75rem; }
.tabs a {
  white-space: nowrap; padding: .55rem .8rem; border-radius: var(--radius-sm) var(--radius-sm) 0 0; font-size: .95rem;
  color: var(--muted); text-decoration: none; font-weight: 550; border-bottom: 3px solid transparent;
  display: flex; align-items: center; gap: .45rem;
}
.tabs a:hover { color: var(--text); background: var(--surface); }
.tabs a[aria-current="page"] { color: var(--primary-ink); border-bottom-color: var(--primary); background: var(--surface); }
.tab-state { width: .5rem; height: .5rem; border-radius: 50%; background: #6cc28c; }

/* ---------- Rejillas ---------- */

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); }

/* Formulario a la izquierda, ayuda a la derecha */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 360px); gap: 1.5rem; align-items: start; }
.split > aside { position: sticky; top: 1.5rem; }

/* ---------- Tarjetas ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem;
  min-width: 0;
}
.card + .card { margin-top: 1.25rem; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.card-head h2 { margin: 0; }
.card > :last-child { margin-bottom: 0; }

.help { background: var(--primary-soft); border-color: #d6e0f8; box-shadow: none; }
.help h2 { font-size: 1rem; color: var(--primary-ink); }
.help ul { margin: 0; padding-left: 1.1rem; display: grid; gap: .45rem; }
.help li { color: var(--text); }

/* Cifras */
.stat { display: flex; align-items: center; gap: 1rem; }
.stat-icon { width: 3rem; height: 3rem; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex: none; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .92rem; }
.tone-blue { background: var(--primary-soft); }
.tone-green { background: var(--green-soft); }
.tone-amber { background: var(--amber-soft); }
.tone-lilac { background: var(--lilac-soft); }
.tone-sky { background: var(--sky-soft); }

/* Tarjetas de grupo en el inicio */
.group-card { display: flex; flex-direction: column; gap: .8rem; text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.group-card:hover { border-color: var(--border-strong); color: inherit; transform: translateY(-1px); }
.group-card h3 { margin: 0; font-size: 1.1rem; color: var(--primary-ink); }
.group-card .meta { display: flex; flex-wrap: wrap; gap: .4rem; }
.group-card .foot { display: flex; justify-content: space-between; color: var(--muted); font-size: .9rem; border-top: 1px solid var(--border); padding-top: .7rem; margin-top: auto; }

/* ---------- Etiquetas ---------- */

.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .7rem; border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap; background: var(--grey-soft); color: var(--grey-ink); }
.badge-ok { background: var(--green-soft); color: var(--green-ink); }
.badge-sim { background: var(--amber-soft); color: var(--amber-ink); }
.badge-error { background: var(--red-soft); color: var(--red-ink); }
.badge-info { background: var(--primary-soft); color: var(--primary-ink); }
.badge-lilac { background: var(--lilac-soft); color: var(--lilac-ink); }

/* ---------- Avisos de la página ---------- */

.flash { display: flex; gap: .6rem; align-items: flex-start; border-radius: var(--radius-sm); padding: .85rem 1.1rem; margin: 0 0 1.25rem; background: var(--green-soft); color: var(--green-ink); border: 1px solid #c8e8d3; }
.flash-warn { background: var(--amber-soft); color: var(--amber-ink); border-color: #f2dda6; }
.flash-error { background: var(--red-soft); color: var(--red-ink); border-color: var(--red-line); }
.flash code { white-space: normal; }

/* ---------- Tablas ---------- */

.table-wrap { overflow-x: auto; margin: 0 -1.5rem; padding: 0 1.5rem; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .7rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 650; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; background: #fafbfd; }
tbody tr:hover { background: #fafbfe; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.excerpt { max-width: 420px; color: var(--muted); overflow-wrap: anywhere; }
tr.dim td { color: var(--muted); }

/* Multimedia: una fila por tipo, con un desplegable por rango y el límite de envíos */
.media-table td, .media-table tbody th { vertical-align: middle; }
.media-table tbody th { color: var(--text); font-size: .95rem; font-weight: 600; text-transform: none; letter-spacing: 0; background: none; }
.media-table select { min-width: 12rem; }
.limit-cell { display: inline-flex; align-items: center; gap: .4rem; white-space: nowrap; color: var(--muted); }
.limit-cell input[type="number"] { width: 4.75rem; }

.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); background: #fbfcfe; margin: 0; }

/* ---------- Formularios ---------- */

form.inline { display: inline; margin: 0; }
.stack { display: grid; gap: 1.2rem; }
.row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.grow { flex: 1 1 260px; }

label, .label { display: grid; gap: .4rem; font-weight: 600; font-size: .95rem; }
.label-note { font-weight: 400; color: var(--muted); }
label[for] { display: block; }
label[for] + textarea { margin-top: -.75rem; }

input[type="text"], input[type="password"], input[type="number"], input:not([type]), select, textarea {
  font: inherit; font-size: 1rem;
  width: 100%;
  padding: .65rem .8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; min-height: 7rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--primary); }
input[type="number"] { max-width: 11rem; }

.hint { color: var(--muted); font-size: .9rem; font-weight: 400; margin: 0; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem 1.1rem 1.1rem; margin: 0; display: grid; gap: 1rem; min-width: 0; }
legend { font-weight: 650; padding: 0 .4rem; }
fieldset.soft { background: #fafbfe; }
fieldset.new { border-style: dashed; border-color: var(--border-strong); }

/* Interruptor accesible (es un checkbox de verdad) */
.switch { display: flex; align-items: flex-start; gap: .85rem; cursor: pointer; font-weight: 600; position: relative; }
.switch input { position: absolute; opacity: 0; width: 2.75rem; height: 1.6rem; margin: 0; cursor: pointer; }
.switch-track { flex: none; width: 2.75rem; height: 1.6rem; border-radius: 999px; background: #d3d9e6; position: relative; transition: background .15s; margin-top: .05rem; }
.switch-track::after { content: ""; position: absolute; top: .2rem; left: .2rem; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .switch-track { background: #7d9be0; }
.switch input:checked + .switch-track::after { transform: translateX(1.15rem); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch-text { display: grid; gap: .15rem; }
.switch-text .hint { font-weight: 400; }

/* Casillas normales */
.check { display: flex; align-items: center; gap: .6rem; font-weight: 500; cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; margin: 0; accent-color: var(--primary); flex: none; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .6rem 1.25rem; }

.form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; padding-top: .3rem; }

/* ---------- Botones ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; font-size: .95rem;
  padding: .6rem 1.15rem; min-height: 2.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff; color: var(--text);
  cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f4f6fb; color: var(--text); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-danger { background: var(--red-soft); border-color: var(--red-line); color: var(--red-ink); }
.btn-danger:hover { background: #f8d9d9; color: var(--red-ink); }
.btn-small { padding: .35rem .8rem; min-height: 2.1rem; font-size: .88rem; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--muted); font-weight: 500; }
.btn-link:hover { background: none; color: var(--text); text-decoration: underline; }

.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }

/* ---------- Login ---------- */

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: linear-gradient(160deg, #eef1fb 0%, #f6f0fb 50%, #eef7f3 100%); }
.login-card { width: 100%; max-width: 410px; }
.login-card .brand { padding: 0; margin-bottom: 1.25rem; }

/* ---------- Pantallas estrechas ---------- */

@media (max-width: 1100px) {
  .split { grid-template-columns: 1fr; }
  .split > aside { position: static; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 1rem; gap: 1rem; border-right: 0; border-bottom: 1px solid var(--border); }
  .nav-groups { display: none; }
  .nav.main { display: flex; flex-wrap: wrap; }
  .sidebar-footer { margin-top: 0; padding-top: .75rem; }
  .content { padding-top: 1.25rem; }
  h1 { font-size: 1.45rem; }
  .card { padding: 1.15rem; }
  .table-wrap { margin: 0 -1.15rem; padding: 0 1.15rem; }
}

.section-gap { margin-top: 1.25rem; }
.meta { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
