/* Backoffice Adium. Sin dependencias: tipografía del sistema e íconos SVG en línea.
   Criterio visual: superficie neutra y plana, jerarquía por peso y espacio (no por color ni sombra),
   y el rojo de marca reservado para la navegación activa y el foco. */
:root {
    --brand: #d0021b;
    --brand-dark: #a80116;
    --brand-soft: #fbeaec;
    --ink: #18212f;
    --ink-soft: #5d6776;
    --ink-faint: #8a93a1;
    --line: #dfe3e9;
    --line-soft: #ebeef2;
    --bg: #f3f4f6;
    --card: #ffffff;
    --head: #f7f8fa;
    --action: #1d2a3c;
    --action-dark: #0f1826;
    --link: #1d4e92;
    --side: #101722;
    --side-line: #1d2735;
    --side-ink: #b9c2cf;
    --ok: #146c4f;
    --ok-soft: #e6f3ed;
    --warn: #8a5300;
    --warn-soft: #fbf0d9;
    --info: #1d4e92;
    --info-soft: #e7eef9;
    --bad: #a5271c;
    --bad-soft: #fbeae8;
    --radius: 6px;
    --shadow: none;
    --side-w: 244px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--ink);
    font: 14px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-feature-settings: "tnum" 1, "cv11" 1;
    -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; }
code { background: #eceff3; padding: 1px 5px; border-radius: 3px; font-size: 12.5px; }
small, .muted { color: var(--ink-soft); }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------------------------------------------------------------- estructura */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side); color: var(--side-ink);
    display: flex; flex-direction: column; z-index: 30; transition: transform .2s ease;
}
.sidebar .brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; color: #fff; border-bottom: 1px solid var(--side-line); }
.sidebar .brand:hover { text-decoration: none; }
.sidebar .brand img { width: 40px; height: auto; }
.sidebar .brand b { display: block; font-size: 14.5px; font-weight: 600; }
.sidebar .brand span { font-size: 12px; color: #7f8a9a; }
.nav { list-style: none; margin: 0; padding: 10px 10px 14px; flex: 1; overflow-y: auto; }
.nav .group { margin: 20px 12px 6px; font-size: 12px; font-weight: 600; color: #6e7a8b; }
.nav a {
    position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 12px; border-radius: 5px; color: var(--side-ink); font-weight: 500;
}
.nav a:hover { background: var(--side-line); color: #fff; text-decoration: none; }
.nav a.active { background: #1a2433; color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.me { border-top: 1px solid var(--side-line); padding: 14px 16px; display: flex; align-items: center; gap: 11px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%; background: #2a3647; color: #e8ecf2; display: grid; place-items: center;
    font-weight: 600; font-size: 12.5px; flex: none; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.me .who { min-width: 0; flex: 1; }
.me .who b { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me .who a { font-size: 12px; color: #8a94a3; }
.me .who a:hover { color: #fff; }
.me button { background: none; border: 0; color: #8a94a3; cursor: pointer; padding: 6px; border-radius: 5px; }
.me button:hover { color: #fff; background: var(--side-line); }

.main { margin-left: var(--side-w); flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; align-items: center; gap: 12px; padding: 11px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar button { background: none; border: 0; padding: 6px; cursor: pointer; color: var(--ink); }
.topbar img { height: 24px; }
.content { padding: 30px 36px 44px; max-width: 1240px; width: 100%; }
.footer { margin-top: auto; padding: 16px 36px; color: var(--ink-faint); font-size: 12.5px; border-top: 1px solid var(--line); background: var(--card); }
.footer a { color: var(--ink-soft); }
.scrim { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.page-head h1 { font-size: 22px; letter-spacing: -.1px; }
.page-head p { margin: 5px 0 0; color: var(--ink-soft); max-width: 72ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------------------------------------------------------------- tarjetas y formularios */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.card h2 { font-size: 15px; margin-bottom: 4px; }
.card h3 { font-size: 14px; margin-bottom: 8px; }
.card .lead { margin: 0 0 16px; color: var(--ink-soft); max-width: 70ch; }
.card > .grid + .grid { margin-top: 0; }

/* Secciones dentro de un mismo formulario: la estructura es el título y la línea que las separa. */
.form-section { padding: 0 0 22px; margin: 0 0 22px; border-bottom: 1px solid var(--line-soft); }
.form-section:last-of-type { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.form-section > h2 { font-size: 15px; margin-bottom: 2px; }
.form-section > .lead { margin: 0 0 16px; }
.form-foot { display: flex; gap: 8px; align-items: center; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

.grid { display: grid; gap: 16px 18px; grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: end; }
.col-12 { grid-column: span 12; } .col-8 { grid-column: span 8; } .col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
.field label, label.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.field label .opt { font-weight: 400; color: var(--ink-faint); }
.field .hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=search], input[type=file], select, textarea, input:not([type]) {
    width: 100%; padding: 8px 11px; border: 1px solid #c6ccd5; border-radius: 5px; background: #fff; color: var(--ink); font: inherit;
}
input:hover, select:hover, textarea:hover { border-color: #aab2bf; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(208, 2, 27, .22); outline-offset: 0; border-color: var(--brand); }
input.invalid, select.invalid { border-color: var(--bad); }
.error-text { color: var(--bad); font-size: 12.5px; margin-top: 4px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--action); }
.pw { position: relative; }
.pw input { padding-right: 40px; }
.pw button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0; padding: 6px; color: var(--ink-soft); cursor: pointer; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 8px 14px; border-radius: 5px; font: inherit; font-weight: 600;
    border: 1px solid #c6ccd5; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; line-height: 1.25;
}
.btn:hover { background: #f1f3f6; border-color: #aab2bf; text-decoration: none; color: var(--ink); }
.btn-primary { background: var(--action); border-color: var(--action); color: #fff; }
.btn-primary:hover { background: var(--action-dark); border-color: var(--action-dark); color: #fff; }
.btn-danger { color: var(--bad); border-color: #e6bdb8; }
.btn-danger:hover { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn-block { width: 100%; padding: 10px 14px; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------------------------------------------------------------- tablas, etiquetas, avisos */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); background: var(--head); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #f9fafb; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .empty { text-align: center; color: var(--ink-soft); padding: 32px; }
.table td small { color: var(--ink-faint); }
.kv { width: 100%; max-width: 520px; }
.kv td:first-child { color: var(--ink-soft); text-transform: capitalize; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; background: #eceff3; color: #3b4452; vertical-align: middle; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }

.alert { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; border-left-width: 4px; display: flex; gap: 10px; align-items: flex-start; }
.alert .icon { margin-top: 2px; }
.alert-ok { background: var(--ok-soft); border-color: #b9dccd; color: #0d513b; }
.alert-warn { background: var(--warn-soft); border-color: #ecd49b; color: #6c4200; }
.alert-bad { background: var(--bad-soft); border-color: #eec0ba; color: #7f1c13; }
.alert ul { margin: 0; padding-left: 18px; }

/* Cifras: una sola franja con divisores en lugar de tarjetas sueltas. */
.stats { display: flex; flex-wrap: wrap; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; }
.stat { flex: 1 1 170px; padding: 16px 20px; border-right: 1px solid var(--line-soft); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -.3px; line-height: 1.2; }
.stat span { color: var(--ink-soft); font-size: 13px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.tile { display: flex; gap: 14px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; color: var(--ink); }
.tile:hover { border-color: #aab2bf; background: #fcfcfd; text-decoration: none; color: var(--ink); }
.tile .ico { width: 36px; height: 36px; border-radius: 5px; border: 1px solid var(--line); background: var(--head); color: var(--ink); display: grid; place-items: center; flex: none; }
.tile b { display: block; margin-bottom: 2px; font-weight: 600; }
.tile span { color: var(--ink-soft); font-size: 13.5px; }

.pagination { display: flex; gap: 4px; list-style: none; padding: 0; margin: 16px 0 0; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span { display: inline-block; min-width: 32px; padding: 5px 10px; text-align: center; border: 1px solid var(--line); border-radius: 5px; background: #fff; color: var(--ink); }
.pagination .active span { background: var(--action); border-color: var(--action); color: #fff; }
.pagination .disabled span { color: #aab1bc; background: #f6f7f9; }
.pagination a:hover { background: #f1f3f6; text-decoration: none; }

/* ---------------------------------------------------------------- acceso (invitados) */
.guest { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.guest-side { background: var(--side); color: #fff; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 56px; gap: 20px; }
.guest-side img { width: 88px; }
.guest-side h1 { font-size: 28px; letter-spacing: -.3px; }
.guest-side p { color: #a3adbb; max-width: 38ch; margin: 0; }
.guest-main { display: grid; place-items: center; padding: 32px 20px; }
.guest-card { width: 100%; max-width: 400px; }
.guest-card h2 { font-size: 21px; margin-bottom: 6px; }
.guest-card .lead { color: var(--ink-soft); margin: 0 0 22px; }
.guest-card .field { margin-bottom: 16px; }
.guest-links { margin-top: 16px; text-align: center; font-size: 13.5px; }

/* ---------------------------------------------------------------- vistas específicas */
.filters { margin-bottom: 16px; }
.team-line { display: flex; gap: 0; flex-wrap: wrap; padding: 0; }
.team-line div { flex: 1 1 200px; padding: 16px 22px; border-right: 1px solid var(--line-soft); font-weight: 600; }
.team-line div:last-child { border-right: 0; }
.team-line small { display: block; font-size: 12.5px; font-weight: 500; margin-bottom: 2px; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.split .card { margin-bottom: 0; }
.section-title { font-size: 15px; margin: 8px 0 10px; }
.profile-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.profile-head .avatar { width: 60px; height: 60px; font-size: 21px; }
.plaza-actual { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--line); border-radius: 5px; background: var(--head); }
.plaza-actual b { display: block; }
.plaza-actual small { display: block; }

/* Selector de modo de plaza en el alta de usuario. */
.modes { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.mode { border-bottom: 1px solid var(--line-soft); }
.mode:last-child { border-bottom: 0; }
.mode.is-open { background: var(--head); }
.mode-head { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; cursor: pointer; }
.mode-head input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--action); flex: none; }
.mode-head b { display: block; font-weight: 600; }
.mode-head small { display: block; }
.mode-body { padding: 2px 16px 18px 44px; }
.mode-body .check { margin-top: 12px; }
.mode-body .hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; }

/* Tablero de envíos (Inicio). Colores de serie: paleta categórica fija por formato (SubmissionStats::PALETTE). */
:root { --viz-1: #257de0; }
.dash-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 16px; }
.dash-filters .field { min-width: 220px; }
.dash-filters .check { min-height: 38px; }   /* misma altura que los selects, alineado a su base */
.stat b.ellipsis { font-size: 18px; line-height: 1.55; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(260px, 1fr); gap: 18px; margin-bottom: 26px; align-items: start; }
.dash-grid .card { margin-bottom: 0; }
.viz-head p, .os > p.muted { margin: 0 0 12px; font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 0 0 10px; padding: 0; font-size: 12.5px; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.chart { display: block; width: 100%; height: auto; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .grid-line.base { stroke: var(--line); }
.chart .axis { fill: var(--ink-faint); font-size: 11px; }
.chart .value { fill: var(--ink-soft); font-size: 11px; font-weight: 600; }
.chart .hit { fill: transparent; }
.chart .bar { outline: none; cursor: default; }
.chart .bar.is-hover .hit, .chart .bar:focus-visible .hit { fill: rgba(24, 33, 47, .05); }
.viz-tip { position: absolute; z-index: 50; pointer-events: none; white-space: pre-line; background: var(--side); color: #fff; font-size: 12.5px; line-height: 1.45;
    padding: 7px 10px; border-radius: 5px; max-width: 280px; }
.viz-tip[hidden] { display: none; }
.viz-table { margin-top: 14px; }
.viz-table summary { cursor: pointer; color: var(--link); font-size: 13px; }
.viz-table .table-wrap { margin-top: 10px; }
.empty-viz { color: var(--ink-soft); padding: 40px 0; text-align: center; margin: 0; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.hbar-label { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; margin-bottom: 4px; }
.hbar-track { height: 8px; background: var(--line-soft); border-radius: 4px; overflow: hidden; }
.hbar-track span { display: block; height: 100%; background: var(--viz-1); border-radius: 0 4px 4px 0; }
.hbars .unknown { color: var(--ink-soft); border-top: 1px dashed var(--line); padding-top: 10px; }
.os .hint { font-size: 12.5px; color: var(--ink-soft); margin: 14px 0 0; }

@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); }
    body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
    .main { margin-left: 0; }
    .topbar { display: flex; }
    .content { padding: 20px 16px 32px; }
    .footer { padding: 16px; }
    .guest { grid-template-columns: 1fr; }
    .guest-side { display: none; }
    .col-8, .col-6, .col-4, .col-3, .col-2 { grid-column: span 12; }
    .dash-grid { grid-template-columns: 1fr; }
    .stat, .team-line div { border-right: 0; border-bottom: 1px solid var(--line-soft); }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }
@media print { .sidebar, .topbar, .footer, .actions { display: none !important; } .main { margin: 0; } }
