/* Backoffice (§8.1): paleta y componentes de la demo. Solo desktop (mín. 1280 px). */
:root {
    --teal: #018788; --teal-dark: #015C5D; --teal-deep: #013F40; --teal-light: #12A9AA; --teal-soft: #E3F2F2;
    --ambar: #E9903A; --ambar-soft: #FDEEDF; --coral: #E4574C; --coral-soft: #FCE8E6;
    --verde: #2E9E6B; --verde-soft: #E3F5EC; --violeta: #7A5AC9; --info: #2A6FB8;
    --ink: #15201F; --ink-2: #2C3B3A; --ink-3: #5B6E6D; --ink-4: #7D9291;
    --linea: #DFE9E8; --linea-2: #CFE0DF; --bg: #F1F6F6;
    --focus: 0 0 0 3px rgba(233, 144, 58, .55);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 14px; color: var(--ink); background: var(--bg); min-width: 1280px; }
[hidden] { display: none !important; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
h1, h2, h3, h4 { margin: 0; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: #fff; padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ic.sm { width: 15px; height: 15px; }

/* Estructura */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: linear-gradient(185deg, #026F70 0%, var(--teal-deep) 100%); color: #fff; flex-shrink: 0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand strong { font-size: 18px; letter-spacing: .02em; }
.brand img { display: block; width: 150px; height: auto; }
.brand small { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .15em; color: rgba(255,255,255,.55); margin-top: 4px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 0 10px; }
.nav-sep { font-size: 10px; text-transform: uppercase; letter-spacing: .13em; color: rgba(255,255,255,.45); padding: 14px 20px 4px; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 1px 10px; border-radius: 9px; font-size: 13.5px; font-weight: 500; color: rgba(255,255,255,.75); white-space: nowrap; }
.nav-item:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--ambar); }
.nav-item.active .ic { color: #FFD3A6; }
.nav-item.locked { color: rgba(255,255,255,.45); }
.nav-badge { margin-left: auto; background: var(--ambar); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 800; line-height: 18px; min-width: 18px; text-align: center; }
.side-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 10px; }
.side-foot .av { width: 34px; height: 34px; font-size: 12px; background: linear-gradient(135deg, #E9903A, #C7701D); }
.side-foot button { margin-left: auto; background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.2); border-radius: 8px; padding: 6px 10px; cursor: pointer; display: flex; gap: 6px; align-items: center; font-size: 12px; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { min-height: 64px; background: #fff; border-bottom: 1px solid var(--linea); display: flex; align-items: center; justify-content: space-between; padding: 10px 24px; gap: 16px; position: sticky; top: 0; z-index: 20; }
.topbar h1 { font-size: 19px; font-weight: 800; }
.topbar p { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
.strip { background: linear-gradient(90deg, var(--teal-deep), #026F70 55%, var(--teal-deep)); color: #fff; padding: 6px 24px; font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 8px; border-bottom: 2px solid var(--ambar); }
.strip .sep { color: rgba(255,255,255,.35); }
.strip .right { margin-left: auto; opacity: .75; }
.live { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #4ADE80; animation: pulse 1.6s ease-in-out infinite; flex-shrink: 0; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
main { padding: 20px 24px 40px; }

/* Piezas */
.card { background: #fff; border-radius: 14px; border: 1px solid var(--linea); box-shadow: 0 1px 2px rgba(1,63,64,.04); }
.card.pad { padding: 16px 18px; }
.card-h { padding: 12px 18px; border-bottom: 1px solid var(--linea); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-h h2, .card h2 { font-size: 15px; font-weight: 800; }
.card .sub { font-size: 12px; color: var(--ink-3); margin: 2px 0 12px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.mb { margin-bottom: 16px; }
.mt { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.strong { font-weight: 700; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.stat { background: #fff; border-radius: 14px; border: 1px solid var(--linea); padding: 14px 16px; }
.stat h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-4); font-weight: 700; }
.stat .val { font-size: 23px; font-weight: 800; line-height: 1.2; margin: 4px 0 2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.stat p { font-size: 12px; color: var(--ink-4); }
.notice { background: var(--ambar-soft); color: #7A4610; border: 1px solid #F5D2AC; border-radius: 12px; padding: 10px 14px; font-size: 13px; }
.notice.info { background: #E5EFF9; color: #1B4E85; border-color: #C8DCF1; }
.notice.danger { background: var(--coral-soft); color: #A32F26; border-color: #F3C4BF; }
.flash { border-radius: 12px; padding: 10px 14px; margin-bottom: 14px; font-weight: 600; }
.flash.ok { background: var(--verde-soft); color: #1C6E48; }
.flash.error { background: var(--coral-soft); color: #A32F26; }

/* Encabezado fijo dentro de la tabla (el contenedor scrollea en ambos sentidos). */
.table-wrap { overflow: auto; max-height: calc(100vh - 150px); }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
.tbl thead th { background: #E8F1F1; padding: 9px 10px; text-align: left; font-weight: 700; color: var(--ink-2); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; border-bottom: 2px solid var(--linea-2); position: sticky; top: 0; z-index: 2; white-space: nowrap; }
.tbl tbody td { padding: 9px 10px; border-bottom: 1px solid #EDF3F3; color: var(--ink-2); vertical-align: middle; }
.tbl tbody tr:hover { background: #F7FBFB; }
.tbl .r { text-align: right; }
.tbl td, .num { font-variant-numeric: tabular-nums; }
.tbl .empty { text-align: center; color: var(--ink-4); padding: 28px; }
.tbl-foot { padding: 10px 16px; border-top: 1px solid var(--linea); font-size: 12px; color: var(--ink-4); display: flex; justify-content: space-between; align-items: center; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap; line-height: 1.6; }
.b-teal { background: var(--teal-soft); color: #016465; } .b-verde { background: var(--verde-soft); color: #1C6E48; }
.b-ambar { background: var(--ambar-soft); color: #9A5A15; } .b-coral { background: var(--coral-soft); color: #A32F26; }
.b-info { background: #E5EFF9; color: #1B4E85; } .b-violeta { background: #EEE9FA; color: #4B33A0; }
.b-gris { background: #EDF3F3; color: #4E605F; }

.btn { font: inherit; font-weight: 700; border-radius: 10px; padding: 8px 14px; font-size: 13px; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; line-height: 1.3; }
.btn:hover { text-decoration: none; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn-primary { background: linear-gradient(135deg, #0FA3A4, var(--teal)); color: #fff; box-shadow: 0 2px 8px rgba(1,135,136,.3); }
.btn-ambar { background: linear-gradient(135deg, #F0A653, var(--ambar)); color: #fff; }
.btn-coral { background: linear-gradient(135deg, #EE6E63, var(--coral)); color: #fff; }
.btn-verde { background: linear-gradient(135deg, #3DB27D, var(--verde)); color: #fff; }
.btn-outline { background: #fff; color: var(--ink-2); border: 1.5px solid var(--linea-2); }
.btn-outline:hover { border-color: var(--teal); color: var(--teal); background: #F5FBFB; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.link-btn { background: none; border: none; color: var(--teal); font: inherit; font-weight: 700; cursor: pointer; padding: 0; }

input[type=text], input[type=number], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=search], input[type=file], textarea, select {
    font: inherit; font-size: 13px; border: 1.5px solid var(--linea-2); border-radius: 10px; padding: 8px 11px; background: #fff; width: 100%; color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; min-height: 260px; }
input:disabled, textarea:disabled, select:disabled { background: #F3F7F7; color: var(--ink-4); cursor: not-allowed; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(1,135,136,.18); }
label, .lbl { font-size: 12px; font-weight: 700; color: var(--ink-2); display: block; margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; margin: 0; }
.check input { width: 17px; height: 17px; accent-color: var(--teal); }
.field { margin-bottom: 12px; }
.field .help { font-size: 11.5px; color: var(--ink-4); margin-top: 3px; }
.field .error, .error-text { font-size: 12px; color: #A32F26; margin-top: 3px; font-weight: 600; }
.filters { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filters .f { min-width: 150px; }
.filters .f.wide { min-width: 240px; }
.filters label { font-size: 11px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 13px; background: #fff; border: 1px solid var(--linea-2); border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-3); white-space: nowrap; }
.pill:hover { border-color: var(--teal); color: var(--teal); text-decoration: none; }
.pill.active { background: var(--teal); border-color: var(--teal); color: #fff; }
.pill .count { font-size: 11px; opacity: .8; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--linea); margin-bottom: 16px; }
.tab { padding: 9px 14px; font-weight: 700; color: var(--ink-3); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tab:hover { color: var(--teal); text-decoration: none; }
.tab.active { color: var(--teal); border-bottom-color: var(--teal); }
.pbar { height: 7px; border-radius: 999px; background: #E4EDEC; overflow: hidden; min-width: 60px; }
.pbar > div { height: 100%; background: linear-gradient(90deg, #0FA3A4, var(--teal)); }
.av { border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; background: var(--teal); width: 32px; height: 32px; font-size: 12px; flex-shrink: 0; overflow: hidden; }
.av img { width: 100%; height: 100%; object-fit: cover; }
.person { display: flex; align-items: center; gap: 8px; }
.person small { display: block; color: var(--ink-4); font-size: 11.5px; }
details.fold { border: 1px solid var(--linea); border-radius: 10px; padding: 8px 12px; background: #FAFCFC; }
details.fold summary { cursor: pointer; font-weight: 700; color: var(--ink-2); }
pre.raw { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: #0C2A2A; color: #CFE8E8; padding: 12px; border-radius: 10px; max-height: 420px; overflow: auto; }
.pagination { display: flex; gap: 4px; align-items: center; }
.pagination a, .pagination span { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--linea-2); background: #fff; font-size: 12px; }
.pagination .current { background: var(--teal); color: #fff; border-color: var(--teal); }
.pagination .disabled { opacity: .45; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 6px 0 6px 18px; border-left: 2px solid var(--linea-2); position: relative; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); }
.viewer { width: 100%; height: 520px; border: 1px solid var(--linea); border-radius: 10px; background: #F7FAFA; }
.viewer-img { max-width: 100%; max-height: 520px; border: 1px solid var(--linea); border-radius: 10px; display: block; }
.thread .msg { border: 1px solid var(--linea); border-radius: 12px; padding: 10px 14px; background: #fff; max-width: 80%; }
.thread .msg.admin { margin-left: auto; background: var(--teal-soft); border-color: #C9E7E7; }
.thread .msg + .msg { margin-top: 10px; }
.video-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.video-card video { width: 100%; aspect-ratio: 9 / 16; max-height: 460px; background: #061a1b; border-radius: 12px 12px 0 0; display: block; }
.frames { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.frames img { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 4px; border: 1px solid var(--linea); }
.md-preview { border: 1px dashed var(--linea-2); border-radius: 10px; padding: 12px 16px; background: #fff; min-height: 260px; max-height: 620px; overflow: auto; }
.md-preview h1, .md-preview h2 { margin: 12px 0 6px; }
.md-preview p { margin: 6px 0; }
.chart-box { position: relative; height: 220px; }
.chart-box.sm { height: 160px; }
.stk { display: flex; height: 26px; border-radius: 6px; overflow: hidden; margin: 8px 0 12px; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.attention li { padding: 8px 0; border-bottom: 1px solid #EDF3F3; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.attention ul { list-style: none; margin: 0; padding: 0; }

/* Modales */
.overlay { position: fixed; inset: 0; background: rgba(1,32,33,.62); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; box-shadow: 0 25px 60px rgba(0,0,0,.35); padding: 20px 22px; }
.modal.wide { max-width: 1000px; }
.modal h2 { font-size: 17px; margin-bottom: 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(145deg, var(--teal-deep) 0%, var(--teal) 60%, var(--teal-dark) 100%); }
.login-card { width: 380px; background: #fff; border-radius: 18px; padding: 32px; box-shadow: 0 25px 60px rgba(0,0,0,.3); }
.login-card h1 { font-size: 22px; color: var(--teal-deep); }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; margin-top: 8px; font-size: 15px; }

/* §14.9: tablas compactas (entran sin scroll horizontal a 1366 px), columna ordenada, totales y notas. */
.tbl.compact { font-size: 12.5px; }
.tbl.compact thead th { padding: 8px 6px; white-space: normal; line-height: 1.25; vertical-align: bottom; }
.tbl.compact tbody td { padding: 7px 6px; }
.tbl.compact .wrap { min-width: 70px; max-width: 150px; }
.tbl abbr[title] { text-decoration: none; border-bottom: 1px dotted currentColor; cursor: help; }
.tbl .clip { display: block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl thead th a { color: inherit; }
.tbl th.sorted, .tbl td.sorted { background: #EAF5F5; }
.tbl thead th.sorted a { color: var(--teal-dark); text-decoration: underline; }
.tbl tfoot td { padding: 10px; font-weight: 800; color: var(--ink); background: #F3F8F8; border-top: 2px solid var(--linea-2); position: sticky; bottom: 0; }
.card-note { padding: 10px 18px 14px; font-size: 12px; color: var(--ink-3); border-top: 1px solid var(--linea); line-height: 1.5; }
.pills.flat { margin-bottom: 0; }
.direct { color: #4B33A0; font-weight: 700; }
.mt-s { margin-top: 6px; }
.span-all { grid-column: 1 / -1; }

/* §14.9 Catálogos: ícono y color de cada categoría elegidos de una grilla (los íconos de categoría van rellenos). */
.mi { width: 22px; height: 22px; fill: currentColor; stroke: none; flex-shrink: 0; }
.cat-icon { display: inline-flex; width: 30px; height: 30px; border-radius: 9px; background: #F3F8F8; align-items: center; justify-content: center; }
fieldset.picker { border: 1px solid var(--linea); border-radius: 12px; padding: 8px 12px 12px; margin: 0; min-width: 0; }
fieldset.picker legend { font-size: 12px; font-weight: 700; color: var(--ink-2); padding: 0 4px; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.pick { position: relative; margin: 0; cursor: pointer; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick .tile { display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; padding: 8px 4px 6px; border: 1.5px solid var(--linea-2); border-radius: 10px; background: #fff; text-align: center; }
.pick .tile .mi { color: var(--pick, var(--teal)); width: 26px; height: 26px; }
.pick .tile .cap { font-size: 10.5px; line-height: 1.2; font-weight: 600; color: var(--ink-3); }
.pick .tile .auto { height: 26px; display: flex; align-items: center; font-size: 11px; font-weight: 800; color: var(--ink-3); }
.pick:hover .tile { border-color: var(--teal-light); }
.pick input:checked + .tile { border-color: var(--teal); background: var(--teal-soft); box-shadow: 0 0 0 2px rgba(1,135,136,.25); }
.pick input:checked + .tile .cap { color: var(--ink); font-weight: 700; }
.swatch { display: inline-flex; width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1.5px var(--linea-2); align-items: center; justify-content: center; }
.swatch.auto { background: repeating-linear-gradient(45deg, #fff 0 5px, #E3ECEC 5px 10px); font-size: 9.5px; font-weight: 800; color: var(--ink-2); }
.pick input:checked + .swatch { box-shadow: 0 0 0 3px var(--ink); }
.pick input:focus-visible + .tile, .pick input:focus-visible + .swatch { box-shadow: var(--focus); }
