:root {
  --beige: #dcd7d0;
  --beige-soft: #f4f2ee;
  --surface: #fff;
  --surface-2: #faf9f7;
  --ink: #17171a;
  --muted: #6a655e;
  --red: #e2001a;
  --yellow: #ffe500;
  --line: #d9d4cc;
  --accent: var(--red);
  --accent2: var(--yellow);
  --danger: #b4001a;
  --ok: #1b7a34;
  --radius: 10px;
  --shadow-1: 0 1px 2px rgba(23, 20, 15, .06), 0 1px 1px rgba(23, 20, 15, .04);
  --shadow-2: 0 12px 32px rgba(23, 20, 15, .16);
  --ring: 0 0 0 3px rgba(226, 0, 26, .2);
  --ease: cubic-bezier(.2, .7, .2, 1);
}
* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); background: var(--beige-soft);
  font-family: system-ui, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5; -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
::selection { background: rgba(226, 0, 26, .18); }

/* ---- Barra superior: fija, con pestañas y usuario ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: 10px 24px; background: rgba(255, 255, 255, .92); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brandmark { display: flex; align-items: center; gap: 12px; flex: none; }
.app-name { font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; }
.company-logo { display: block; height: 26px; width: auto; }
.wordmark {
  font-weight: 900; letter-spacing: .12em; font-size: 1.35rem; padding-bottom: 3px; text-transform: uppercase;
  border-bottom: 4px solid; border-image: linear-gradient(90deg, var(--accent) 0 60%, var(--accent2) 60% 100%) 1;
}
.tabs { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px; flex: none;
  border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; font: inherit; font-size: .93rem;
  cursor: pointer; color: var(--muted); transition: color .15s, background .15s;
}
.tab:hover { color: var(--ink); background: rgba(23, 20, 15, .05); }
.tab.active { color: var(--ink); font-weight: 600; }
.tab.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -11px; height: 3px; border-radius: 3px 3px 0 0;
  background: linear-gradient(90deg, var(--red) 0 65%, var(--yellow) 65% 100%);
}
.badge {
  display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 99px; background: var(--red); color: #fff;
  font-size: .72rem; font-weight: 700; line-height: 18px; text-align: center;
}
.athlete-session { display: flex; align-items: center; gap: 10px; flex: none; }
.athlete-session select { height: 32px; padding: 2px 8px; }
#me-name { font-size: .88rem; }

main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; }
.panel { display: flex; flex-direction: column; gap: 18px; animation: rise .22s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; box-shadow: var(--shadow-1); }
h2, h3 { margin: 0 0 12px; letter-spacing: -.01em; }
h2 { font-size: 1.28rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); margin: 0; font-size: .92rem; }
.empty {
  text-align: center; color: var(--muted); padding: 40px 24px; background: var(--surface-2);
  border: 1.5px dashed var(--line); border-radius: 12px;
}
.empty .btn { margin-top: 12px; }
.error { color: #8f0015; background: #fde8eb; border: 1px solid #f3b6be; padding: 10px 12px; border-radius: var(--radius); margin: 0; }
.past-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.past-head h3 { margin: 0; }
label.inline { flex-direction: row; align-items: center; gap: 8px; }

/* ---- Formularios ---- */
label { display: flex; flex-direction: column; gap: 6px; font-size: .86rem; font-weight: 600; }
.hint { font-weight: 400; color: var(--muted); }
input, select, textarea {
  font: inherit; font-weight: 400; padding: 9px 12px; border: 1px solid #cdc7be; border-radius: 8px;
  background: var(--surface); color: var(--ink); min-width: 0; transition: border-color .15s, box-shadow .15s;
}
input:hover, select:hover, textarea:hover { border-color: #aaa398; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: #a39d94; }
input[readonly] { background: var(--surface-2); }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 6px; }
input:not([type=checkbox]):not([type=file]):not([type=color]), select { height: 42px; }
input[type=file] { padding: 7px 10px; background: var(--surface-2); }
input[type=checkbox] { accent-color: var(--red); width: 16px; height: 16px; }
textarea { resize: vertical; line-height: 1.5; }
.form { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.row > label { flex: 1 1 180px; }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filters .grow { flex: 1 1 220px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---- Botones ---- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px;
  font: inherit; font-size: .92rem; font-weight: 600; padding: 0 18px; border-radius: 8px; white-space: nowrap;
  border: 1px solid #b9b2a8; background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .08s;
}
.btn:hover { border-color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fff; box-shadow: var(--shadow-1); }
.btn.primary:hover { background: #000; box-shadow: 0 4px 12px rgba(0, 0, 0, .25); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(23, 20, 15, .06); }
.btn.small { height: 30px; padding: 0 11px; font-size: .82rem; border-radius: 7px; }
.btn.danger { border-color: #d9a4ac; color: var(--danger); }
.btn.danger:hover { background: #fde8eb; border-color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.solid:hover { background: #8f0015; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(23, 20, 15, .25); border-top-color: var(--ink); animation: spin .7s linear infinite;
}
.btn.primary.loading::after, .btn.danger.solid.loading::after { border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; margin-right: 6px;
  border: 2px solid rgba(23, 20, 15, .2); border-top-color: var(--red); animation: spin .7s linear infinite; }

/* ---- Tablas ---- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow-x: auto; box-shadow: var(--shadow-1); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 12px 14px; vertical-align: top; border-bottom: 1px solid #ebe7e1; }
th { background: var(--surface-2); color: var(--muted); font-size: .73rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; white-space: nowrap; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fbfaf8; }
tbody tr:last-child td { border-bottom: 0; }
td.date { white-space: nowrap; }
td.cell-text { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 220px; }
td.row-actions { white-space: nowrap; text-align: right; }
td.row-actions .btn + .btn { margin-left: 4px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 99px; background: #eeeae4; font-size: .78rem; font-weight: 500; white-space: nowrap; }

/* ---- Informes anteriores / barra de herramientas ---- */
.past-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.past-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 6px; border-bottom: 1px solid #ebe7e1; border-radius: 6px; }
.past-list li:hover { background: var(--surface-2); }
.past-list li:last-child { border-bottom: 0; }
.past-list .grow { flex: 1; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- Avisos (toasts) y diálogos de confirmación ---- */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: none; }
.toast-item {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; max-width: min(420px, calc(100vw - 40px));
  padding: 12px 14px 12px 12px; border-radius: 10px; background: var(--ink); color: #fff; box-shadow: var(--shadow-2);
  border-left: 4px solid var(--ok); font-size: .92rem; animation: toast-in .25s var(--ease);
}
.toast-item.error { border-left-color: #ff5a6e; background: #3a0a12; }
.toast-item.warn { border-left-color: var(--yellow); }
.toast-item.out { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast-item button { flex: none; border: 0; background: none; color: inherit; opacity: .6; cursor: pointer; font-size: 1.1rem; line-height: 1; padding: 0 2px; }
.toast-item button:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

dialog.dialog {
  border: 0; border-radius: 14px; padding: 0; width: min(440px, calc(100vw - 32px)); color: var(--ink);
  box-shadow: var(--shadow-2); animation: toast-in .2s var(--ease);
}
dialog.dialog::backdrop { background: rgba(23, 20, 15, .5); backdrop-filter: blur(2px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
dialog.dialog form { display: flex; flex-direction: column; gap: 10px; padding: 22px; }
dialog.dialog h3 { margin: 0; font-size: 1.1rem; }
dialog.dialog p { margin: 0; color: var(--muted); }
dialog.dialog .actions { justify-content: flex-end; margin-top: 8px; }

/* ---- Zona para soltar archivos ---- */
.dropzone { border: 1.5px dashed #bdb6ab; border-radius: 12px; padding: 14px; background: var(--surface-2); transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--red); background: #fff4f5; }
.dropzone .drop-hint { margin: 0; font-size: .86rem; color: var(--muted); }

/* ===================== INFORME (estilo presentación LEKI) ===================== */
#report-view { display: flex; flex-direction: column; gap: 24px; }
.slide {
  position: relative; background: var(--beige); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 48px 56px; min-height: 560px;
}
.slide .corner-logo { position: absolute; top: 28px; right: 40px; font-size: 1.1rem; }
.slide.cover { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 22px; }
.cover h1 { font-size: 3rem; font-weight: 400; margin: 0; letter-spacing: .02em; text-transform: uppercase; }
.cover .who { font-size: 1.15rem; }
.cover .who { display: flex; align-items: center; justify-content: center; gap: 14px; }
.cover .who .company-logo { height: 38px; }
.cover .report-title { color: var(--muted); max-width: 640px; }
.slide h2 { font-size: 1.5rem; font-weight: 400; text-transform: uppercase; margin: 0 0 20px; max-width: 80%; }
.slide p { margin: 0 0 12px; }
.slide .lead { max-width: 900px; }
.slide .note { margin-top: 20px; padding: 10px 14px; background: rgba(255,255,255,.55); border-left: 4px solid var(--accent2); font-size: .92rem; }
.group { margin: 22px 0 0; }
.group h3 { font-size: 1.05rem; margin: 0 0 6px; }
.items { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item { background: rgba(255,255,255,.6); border-radius: 6px; padding: 10px 14px; break-inside: avoid; }
.item .when { font-weight: 700; margin-right: 8px; }
.item .what { white-space: pre-wrap; overflow-wrap: anywhere; }
.item .more { display: block; margin-top: 4px; color: var(--muted); font-size: .92rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.item a, .slide a { color: #0b57a5; }
.highlight { border-left: 4px solid var(--accent); }
.highlight .why { margin-top: 4px; }
.draft-badge { display: inline-block; background: var(--accent2); padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 700; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 3px solid var(--accent); display: flex; flex-direction: column; gap: 8px; }
.timeline li { break-inside: avoid; }
.timeline .when { font-weight: 700; margin-right: 8px; }

/* ---- Histórico compacto ---- */
.history-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
tr.main { cursor: pointer; }
tr.main:hover { background: var(--beige-soft); }
tr.main td { vertical-align: middle; }
td.tog { width: 28px; padding-right: 0; }
.toggle { border: 0; background: none; cursor: pointer; font-size: 1rem; color: var(--muted); transition: transform .15s; }
tr.open .toggle { transform: rotate(90deg); color: var(--ink); }
tr.open { background: var(--beige-soft); }
tr.detail td { background: var(--beige-soft); }
.detail-box { display: grid; gap: 12px; padding: 4px 0 10px; }
.detail-box h4 { margin: 0 0 4px; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---- Adjuntos, sponsors y redes ---- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: .9rem; font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
.row > label.wide { flex: 3 1 320px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.thumb { display: inline-block; line-height: 0; }
.thumb img { height: 96px; max-width: 160px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #fff; }
.thumbs.small .thumb img { height: 48px; max-width: 72px; }
.item-thumbs { margin-top: 8px; }
.item-thumbs .thumb img { height: 120px; max-width: 220px; }
.thumb-wrap { position: relative; display: inline-flex; }
.thumb-wrap .x {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: #a30015; color: #fff; cursor: pointer; line-height: 1; font-size: 15px;
}
.chip.file { background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.error-text { color: #a30015; font-size: .82rem; }
.report-table { width: 100%; border-collapse: collapse; background: rgba(255,255,255,.6); font-size: .92rem; margin-top: 8px; }
.report-table th { background: rgba(255,255,255,.7); font-size: .78rem; }
.report-table td, .report-table th { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.report-table tr { break-inside: avoid; }
.report-table td.wrap { overflow-wrap: anywhere; white-space: pre-wrap; }
.sponsor-card { display: flex; gap: 12px; align-items: flex-start; }
.delta { font-weight: 700; }
.delta.pos { color: #1b7a34; }
.delta.neg { color: #a30015; }

/* ---- Tarjetas de enlaces leídos ---- */
a.shortlink { display: inline-block; padding: 0 8px; border-radius: 99px; background: rgba(255,255,255,.75); border: 1px solid var(--line); font-size: .85rem; text-decoration: none; color: var(--ink); white-space: nowrap; }
.note-box { background: var(--beige-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; font-size: .92rem; }
.note-box ul { margin: 6px 0 0; padding-left: 18px; overflow-wrap: anywhere; }
.linkcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-top: 10px; align-items: stretch; }
.linkcard {
  display: flex; flex-direction: column; overflow: hidden; border-radius: 8px; height: 100%;
  background: rgba(255,255,255,.75); border: 1px solid var(--line); text-decoration: none; color: var(--ink); break-inside: avoid;
}
/* misma proporción de imagen en todas las tarjetas, con o sin foto, para que queden a la misma altura */
.linkcard .thumbbox { position: relative; isolation: isolate; display: flex; align-items: center; justify-content: center; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; background: rgba(0,0,0,.06); }
.linkcard .thumbbox.empty { color: var(--muted); font-size: .9rem; padding: 8px; text-align: center; overflow-wrap: anywhere; }
.linkcard .thumbbox img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
.linkcard .meta { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1; min-width: 0; }
.linkcard strong { font-size: .9rem; line-height: 1.25; min-height: 2.5em; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.linkcard small { color: var(--muted); overflow-wrap: anywhere; }

/* ---- Una página por acción ---- */
.slide.action {
  overflow: hidden;
  display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 36px; align-items: stretch;
  aspect-ratio: 297 / 210; min-height: 0; padding: 40px 44px;
}
.slide.action.flip { grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr); }
.slide.action.flip .a-text { order: 2; }
.slide.action.text, .slide.action.text.flip { grid-template-columns: minmax(0, 1fr) 30%; }
.slide.action.text.flip .a-text { order: 0; }
.a-text { position: relative; display: flex; flex-direction: column; gap: 12px; min-width: 0; padding-bottom: 8px; }
.kicker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kicker .when { color: var(--ink); font-weight: 700; }
.slide h2.a-title { font-size: clamp(1.5rem, 2.6vw, 2.4rem); line-height: 1.15; font-weight: 700; text-transform: none; margin: 4px 0 0; max-width: none; }
.rule { width: 64px; height: 4px; background: linear-gradient(90deg, var(--accent) 0 60%, var(--accent2) 60% 100%); }
.a-body { font-size: 1.1rem; line-height: 1.55; margin: 0; }
.a-files { display: flex; flex-wrap: wrap; gap: 6px; }
.a-text .linkcards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 6px; }
.a-text .linkcard strong { font-size: .8rem; }
.foot-brand { margin-top: auto; padding-top: 12px; font-weight: 900; font-size: .75rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
/* página sin fotos: texto grande y centrado */
.slide.action.text .a-text { justify-content: center; }
.slide.action.text h2.a-title { font-size: clamp(2rem, 4vw, 3.4rem); }
.slide.action.text .a-body { font-size: 1.3rem; max-width: 640px; }
.slide.action.text .foot-brand { position: absolute; left: 0; bottom: 0; }
.a-deco { display: flex; align-items: center; justify-content: center; font-size: clamp(5rem, 14vw, 11rem); font-weight: 900; line-height: 1; color: rgba(0,0,0,.06); }

.a-media { display: flex; align-items: center; justify-content: center; min-height: 0; min-width: 0; overflow: hidden; }
.pack { display: flex; flex-direction: column; gap: 10px; margin: auto; }
.prow { display: flex; gap: 10px; width: 100%; align-self: center; }
/* cada foto ocupa un hueco con su misma proporción: se ve entera, sin recortes ni franjas */
.prow .m { position: relative; display: block; min-width: 0; overflow: hidden; border-radius: 10px; background: #f6f4f0; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.prow .m img { display: block; width: 100%; height: 100%; object-fit: cover; }
/* fotos muy apaisadas: debajo del texto, a todo el ancho */
.slide.action.below { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); gap: 18px; }
.slide.divider { display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 16px; aspect-ratio: 297 / 210; min-height: 0; }
.divider h2 { font-size: clamp(2rem, 4vw, 3.4rem); text-transform: uppercase; max-width: 75%; margin: 0; }
.divider p { max-width: 640px; color: var(--muted); font-size: 1.1rem; margin: 0; }

@media (max-width: 800px) {
  .slide.action, .slide.action.flip, .slide.action.text, .slide.action.text.flip { grid-template-columns: 1fr; aspect-ratio: auto; padding: 28px 22px; }
  .slide.action.flip .a-text { order: 0; }
  .a-media { min-height: 260px; }
  .a-deco { display: none; }
}

/* ---- Marcas ---- */
.brand-logo { height: 34px; width: auto; max-width: 160px; object-fit: contain; }
.cover .cover-logo { height: 90px; width: auto; max-width: 320px; object-fit: contain; }
.foot-brand img { display: block; height: 22px; width: auto; max-width: 120px; object-fit: contain; }
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.brand-card { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.brand-card h3 { margin: 0 0 4px; }
.brand-card .logo-box { display: flex; align-items: center; justify-content: center; height: 90px; border-radius: 6px; background: var(--beige-soft); overflow: hidden; }
.brand-card .logo-box img { max-width: 80%; max-height: 70px; object-fit: contain; }
.brand-card .brand-notes { margin: 0; font-size: .9rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.swatches { display: inline-flex; gap: 4px; margin-right: 8px; vertical-align: middle; }
.swatches span { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line); }
input[type=color] { padding: 2px; min-width: 64px; cursor: pointer; }

/* ---- Impresión: cada bloque del informe es una página apaisada ---- */
@page { size: A4 landscape; margin: 0; }
@media print {
  body { background: #fff; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .no-print, .topbar { display: none !important; }
  main { max-width: none; padding: 0; }
  #report-view { gap: 0; }
  .slide { border: 0; border-radius: 0; min-height: 210mm; padding: 18mm 20mm; break-after: page; }
  .slide.cover { height: 210mm; }
  /* cada acción ocupa exactamente una página A4 apaisada */
  .slide.action, .slide.divider { height: 210mm; aspect-ratio: auto; overflow: hidden; padding: 14mm 16mm; }
}
@media (max-width: 640px) {
  main { padding: 14px; }
  .slide { padding: 28px 22px; }
  .cover h1 { font-size: 2rem; }
}

/* ---- Atletas: estados, portal y memoria ---- */
pre.creds { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; white-space: pre-wrap; user-select: all; margin: 8px 0; }
.auth-card { max-width: 420px; margin: 40px auto; width: 100%; }
.athlete-session { display: flex; align-items: center; gap: 8px; }
.athlete-session select { height: 32px; padding: 2px 8px; }
.chip.status-pending { background: #ffe9a8; }
.chip.status-approved { background: #cfe9d2; }
.chip.link { background: #e3edf8; color: #0b57a5; text-decoration: none; }
.athlete-list { display: flex; flex-direction: column; gap: 12px; }
.athlete-action { display: flex; flex-direction: column; gap: 8px; }
.athlete-action-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.thumb-wrap { position: relative; display: inline-block; }
.thumb-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: #a30015; color: #fff; cursor: pointer; line-height: 1; }
.memoria { display: flex; flex-direction: column; gap: 24px; }
.memoria-logo { height: 54px; width: auto; max-width: 240px; object-fit: contain; }
.memoria-table { width: 100%; border-collapse: collapse; background: rgba(255,255,255,.6); }
.memoria-action { background: rgba(255,255,255,.6); border-radius: 6px; padding: 12px 14px; margin-bottom: 10px; break-inside: avoid; }
.memoria-action-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.memoria-action .when { font-weight: 700; }
.memoria-action .what { white-space: pre-wrap; overflow-wrap: anywhere; }
.memoria-action .more { margin-top: 4px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.memoria-sec h2 { max-width: none; }
@media print {
  .memoria .slide { min-height: 0; break-after: page; }
  .memoria .slide.memoria-cover { height: 210mm; }
}


/* ===================== Pulido de interfaz ===================== */
/* Histórico */
tr.main:hover { background: #fbfaf8; }
tr.open { background: var(--surface-2); }
tr.detail td { background: var(--surface-2); }
tr.detail:hover { background: var(--surface-2); }
.history-bar { align-items: center; }
.detail-box { padding: 6px 0 12px; }
.chip.status-pending { background: #ffeeb5; color: #5c4600; }
.chip.status-approved { background: #d3ecd8; color: #135a27; }
.chip.link { background: #e3edf8; color: #0b57a5; text-decoration: none; }
.chip.link:hover { background: #d3e4f6; }
.note-box { box-shadow: var(--shadow-1); background: var(--surface); }
pre.creds { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; white-space: pre-wrap; user-select: all; margin: 8px 0; font-size: .9rem; }
.thumb img { transition: transform .15s var(--ease), box-shadow .15s; }
.thumb:hover img { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, .18); }
.brand-card { box-shadow: var(--shadow-1); border-radius: 12px; transition: box-shadow .15s, transform .15s var(--ease); }
.brand-card:hover { box-shadow: 0 6px 20px rgba(23, 20, 15, .1); transform: translateY(-2px); }

/* Entrada / portal del atleta */
.auth-card { max-width: 420px; margin: 8vh auto 0; width: 100%; padding: 28px; box-shadow: var(--shadow-2); }
.auth-card h2 { font-size: 1.5rem; }
.login-page { background: radial-gradient(1200px 500px at 50% -10%, #fff 0, var(--beige-soft) 60%), var(--beige-soft); min-height: 100vh; }
.pw { position: relative; display: flex; }
.pw input { flex: 1; padding-right: 64px; }
.pw button {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; cursor: pointer;
  color: var(--muted); font: inherit; font-size: .8rem; font-weight: 600; padding: 4px 8px; border-radius: 6px;
}
.pw button:hover { color: var(--ink); background: rgba(23, 20, 15, .06); }
.athlete-list { display: flex; flex-direction: column; gap: 12px; }
.athlete-action { display: flex; flex-direction: column; gap: 10px; }
.athlete-action-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.thumb-x { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; cursor: pointer; line-height: 1; }

.form > h2 + .muted, .form > h3 + .muted { margin-top: -8px; }
.filters > .btn { margin-left: auto; }
.history-bar .muted { font-weight: 500; }

/* Adaptación a móvil: objetivos táctiles grandes, pestañas desplazables, formularios en una columna */
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; gap: 8px 12px; }
  .tabs { order: 3; flex-basis: 100%; margin: 0 -4px; }
  .tab { padding: 9px 12px; }
  .tab.active::after { bottom: -3px; left: 12px; right: 12px; }
  main { padding: 18px 14px 56px; }
  .card { padding: 16px; }
  .row > label { flex: 1 1 100%; }
  .filters > label { flex: 1 1 calc(50% - 6px); }
  .filters > label.grow, .filters > .btn { flex: 1 1 100%; margin-left: 0; }
  .btn { height: 44px; }
  .btn.small { height: 36px; }
  input:not([type=checkbox]):not([type=file]):not([type=color]), select { height: 46px; font-size: 16px; }
  textarea { font-size: 16px; }
  .actions .btn.primary { flex: 1 1 auto; }
  #toasts { left: 14px; right: 14px; bottom: 14px; align-items: stretch; }
  .toast-item { max-width: none; }
  .auth-card { margin-top: 4vh; padding: 20px; }
  .brandmark { flex: 1 1 0; min-width: 0; }
  .app-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
@media print {
  #toasts, dialog.dialog { display: none !important; }
}

/* ---- Sponsors: resumen, filtros y tarjetas ---- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-1); }
.stat strong { font-size: 1.6rem; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--muted); }
.stat.ok strong { color: var(--ok); }
.stat.warn { border-color: #ecd58a; background: #fffbea; }
.toolbar-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.toolbar-row .grow { flex: 1 1 220px; }
.sponsor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 16px; }
.sp-card {
  display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow-1); cursor: pointer; min-width: 0;
  transition: box-shadow .15s, transform .15s var(--ease), border-color .15s;
}
.sp-card:hover { box-shadow: 0 8px 22px rgba(23, 20, 15, .11); transform: translateY(-2px); border-color: #c4bdb2; }
.sp-card:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.sp-head { display: flex; align-items: flex-start; gap: 12px; }
.sp-title { flex: 1; min-width: 0; }
.sp-title h3 { margin: 0 0 4px; font-size: 1.05rem; overflow-wrap: anywhere; }
.sp-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip.brand { background: var(--ink); color: #fff; }
.avatar {
  flex: none; display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; border-radius: 50%;
  overflow: hidden; color: #fff; font-weight: 700; font-size: 1rem; letter-spacing: .02em; background: var(--muted);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.kebab {
  flex: none; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; cursor: pointer;
  font-size: 1.2rem; line-height: 1; color: var(--muted); transition: background .12s, color .12s;
}
.kebab:hover, .kebab[aria-expanded="true"] { background: rgba(23, 20, 15, .08); color: var(--ink); }
.sp-meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 0; }
.sp-meta div { min-width: 0; }
.sp-meta .wide { grid-column: 1 / -1; }
.sp-meta dt { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.sp-meta dd { margin: 0; font-size: .9rem; overflow-wrap: anywhere; }
.sp-notes { margin: 0; font-size: .86rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.sp-foot { display: flex; flex-direction: column; gap: 8px; margin-top: auto; padding-top: 10px; border-top: 1px solid #ebe7e1; }
.sp-counts { font-size: .84rem; color: var(--muted); }
.sp-counts strong { color: var(--ink); }
.sp-counts .badge { vertical-align: 1px; }
.sp-social { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---- Menú desplegable ---- */
.popmenu {
  position: absolute; z-index: 60; min-width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow-2); animation: toast-in .15s var(--ease);
}
.popmenu button {
  display: block; width: 100%; text-align: left; border: 0; background: none; font: inherit; font-size: .9rem; padding: 8px 12px;
  border-radius: 6px; cursor: pointer; color: var(--ink);
}
.popmenu button:hover, .popmenu button:focus-visible { background: #f1eeea; outline: none; }
.popmenu button.danger { color: var(--danger); }
.popmenu button.danger:hover, .popmenu button.danger:focus-visible { background: #fde8eb; }
.popmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ---- Formulario en ventana ---- */
dialog.dialog.wide { width: min(780px, calc(100vw - 32px)); }
dialog.dialog.wide form { max-height: 88vh; overflow-y: auto; gap: 14px; }
dialog.dialog h2 { margin: 0; font-size: 1.25rem; }
dialog.dialog .muted { margin-top: -6px; }
.form-section { margin-top: 4px; padding-bottom: 4px; border-bottom: 1px solid #ebe7e1; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.actions.end { justify-content: flex-end; }
@media (max-width: 760px) {
  .toolbar-row > label { flex: 1 1 calc(50% - 6px); }
  .toolbar-row > label.grow, .toolbar-row > .btn { flex: 1 1 100%; }
  .stat strong { font-size: 1.3rem; }
  .sponsor-grid { grid-template-columns: 1fr; }
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h2 { margin: 0; }

/* ---- Ficha del sponsor ---- */
#ath-head { display: flex; flex-direction: column; gap: 14px; }
.ath-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.ath-head .avatar { width: 64px; height: 64px; font-size: 1.3rem; }
.ath-id { flex: 1 1 220px; min-width: 0; }
.ath-id h2 { margin: 0 0 6px; }
.ath-stats { display: flex; gap: 10px; }
.ath-stats .stat { min-width: 92px; padding: 10px 14px; box-shadow: none; }
.ath-meta { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); padding-top: 12px; border-top: 1px solid #ebe7e1; }
.sp-notes.full { -webkit-line-clamp: unset; display: block; }

/* ---- Panel de redes sociales (ficha del sponsor y marcas) ---- */
.social-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 14px; }
.social-row { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid #ebe7e1; background: var(--surface); }
.social-row:last-child { border-bottom: 0; }
.social-handle { font-weight: 600; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
.social-handle:hover { text-decoration: underline; }
.social-count { display: flex; flex-direction: column; line-height: 1.25; margin-left: auto; text-align: right; }
.social-count small { color: var(--muted); font-size: .74rem; }
.social-row .error-text { flex-basis: 100%; }
.social-row .row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.social-add { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.social-add input[name=url] { flex: 3 1 280px; }
.social-add input[name=followers] { flex: 1 1 150px; }
.dlg-body { display: flex; flex-direction: column; gap: 12px; padding: 22px; max-height: 88vh; overflow-y: auto; }
@media (max-width: 760px) { .social-count { margin-left: 0; text-align: left; } }

/* ---- Usuarios: tipo y marcas de un representante ---- */
fieldset.brand-pick { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 12px; margin: 0; }
fieldset.brand-pick legend { font-size: .82rem; font-weight: 600; padding: 0 6px; }
.brand-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }

.link-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ---- Ficha maestra y temporadas ---- */
table.master { font-size: .88rem; }
table.master td, table.master th { padding: 9px 10px; white-space: nowrap; }
table.master td.wrap { white-space: normal; min-width: 160px; }
table.master tr.main td { vertical-align: middle; }
.master-detail { display: grid; gap: 16px; padding: 4px 0 10px; }
.season-block { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 12px 14px; }
.season-block h4 { margin: 0 0 8px; font-size: .95rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; text-transform: none; letter-spacing: 0; color: var(--ink); }
.season-block .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.season-block h5 { margin: 0 0 4px; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.season-block ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: .88rem; }
.season-block li { overflow-wrap: anywhere; }
.chip.cycle-invierno { background: #dbe8fb; color: #12407e; }
.chip.cycle-trekking { background: #d6ecd9; color: #135a27; }
.chip.status-final { background: #ece8e1; color: var(--muted); }

tr.group th { background: var(--surface-2); text-transform: none; letter-spacing: 0; font-size: .92rem; color: var(--ink); padding: 10px 14px; }

.master-detail { position: sticky; left: 14px; max-width: min(1100px, calc(100vw - 120px)); white-space: normal; }

/* ---- Móvil y pantallas táctiles ---- */
html { -webkit-text-size-adjust: 100%; }
button, a, select, summary, label.check { touch-action: manipulation; }
.topbar { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(14px, env(safe-area-inset-left)); padding-right: max(14px, env(safe-area-inset-right)); }
main { padding-bottom: max(56px, calc(env(safe-area-inset-bottom) + 24px)); }
@media (max-width: 760px) {
  .tabs { scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; }
  .tab { scroll-snap-align: start; white-space: nowrap; min-height: 44px; }
  .btn.small, .row-actions .btn, .popmenu button { min-height: 40px; }
  .row-actions { display: flex; flex-wrap: wrap; gap: 6px; }
  input[type=checkbox] { width: 22px; height: 22px; }
  label.check { gap: 10px; align-items: flex-start; }
  .dialog, dialog.dialog { width: calc(100vw - 24px); max-width: 520px; max-height: 92dvh; overflow-y: auto; }
  dialog:not(.dialog) { max-width: calc(100vw - 16px); max-height: 94dvh; }
  .dlg-body { padding: 16px; max-height: 90dvh; }
  /* Tablas anchas: se desplazan de lado dentro de su caja y la primera columna se queda fija */
  .table-wrap { -webkit-overflow-scrolling: touch; margin-left: -2px; margin-right: -2px; }
  .table-wrap th:first-child, .table-wrap td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; box-shadow: 1px 0 0 var(--line); }
  .table-wrap tr.group th:first-child { position: static; box-shadow: none; }
  .ath-head { gap: 12px; }
  .ath-stats { width: 100%; }
  .ath-stats .stat { flex: 1 1 0; min-width: 0; }
  .a-media img, .thumb img { max-width: 100%; height: auto; }
}
@media (hover: none) {
  .tab:hover, .btn:hover { background: inherit; border-color: inherit; }
}
