/* Estilos comunes del portal, Socios y Facturación (la Mapoteca tiene los suyos). Cada módulo
   añade después su hoja con lo propio. El color del club lo aplica marca.js sobre --accent. */
:root {
  --paper: #f7f8f5;
  --surface: #ffffff;
  --ink: #1b1e1a;
  --muted: #646b62;
  --line: #e1e5de;
  --line-strong: #c9cfc4;
  --accent: #38761d;          /* verde de la plantilla de facturas */
  --accent-ink: #ffffff;
  --accent-soft: #e5f0df;
  --accent-strong: #2c5e17;
  --red: #c4271f;             /* rojo del logo */
  --red-soft: #fbe7e5;
  --warn: #8a5a00;
  --warn-soft: #fff1d1;
  --info: #1f6fae;
  --info-soft: #e2eef8;
  --shadow: 0 1px 2px rgba(20, 30, 20, .06), 0 6px 20px rgba(20, 30, 20, .05);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #131612;
    --surface: #1b1f1a;
    --ink: #e9ece6;
    --muted: #9ba396;
    --line: #2b3129;
    --line-strong: #3a4237;
    --accent: #7cc25a;
    --accent-ink: #0f1a0a;
    --accent-soft: #22341b;
    --accent-strong: #9bd67e;
    --red: #f07a70;
    --red-soft: #3d1c19;
    --warn: #f0c060;
    --warn-soft: #3a2e12;
    --info: #86bdea;
    --info-soft: #1a2c3c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -.01em; }
p { margin: 0; }
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.nowrap { white-space: nowrap; }
/* ---------- barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--accent);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand img { height: 34px; width: auto; border-radius: 4px; background: #fff; }
.brand strong { font-size: 16px; display: block; }
.brand small { color: var(--muted); font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); min-width: 0; }
#user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; font-size: 12px; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.link { color: var(--ink); font-weight: 500; }
main { padding: clamp(16px, 4vw, 36px); max-width: 1240px; width: 100%; margin: 0 auto; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 24px 16px 32px; }
/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 550; font-size: 14px;
  padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--accent-soft); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 12px 22px; font-size: 16px; }
.icon-btn { border: 0; background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.icon-btn:hover { background: var(--accent-soft); color: var(--ink); }
.btn svg, .tab svg { flex: none; }
/* ---------- formularios ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.form-card { padding: clamp(18px, 3vw, 28px); }
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid > * { grid-column: span 3; min-width: 0; }
.form-grid > .full { grid-column: 1 / -1; }
.form-grid > .third { grid-column: span 2; }
.form-grid > .sixth { grid-column: span 1; }
@media (max-width: 720px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid > *, .form-grid > .third { grid-column: 1 / -1; }
  .form-grid > .sixth { grid-column: span 1; }
}
.field { display: grid; gap: 5px; align-content: start; }
.field > span, .field > legend, .label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field small { color: var(--muted); font-size: 12px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible, .tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input[aria-invalid="true"] { border-color: var(--red); }
textarea { resize: vertical; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; }
.section-title { font-size: 15px; font-weight: 700; margin: 8px 0 -2px; grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.hint { font-size: 13px; color: var(--muted); }
.form-error { color: var(--red); background: var(--red-soft); padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.honeypot { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
/* ---------- página pública ---------- */
.public-wrap { max-width: 760px; margin: 0 auto; display: grid; gap: 20px; }
.public-intro h1 { font-size: clamp(24px, 4vw, 32px); }
.public-intro p { color: var(--muted); margin-top: 8px; }
.done { text-align: center; padding: 40px 24px; display: grid; gap: 14px; justify-items: center; }
.done .ref { font: 600 22px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--accent-soft); color: var(--accent-strong); padding: 8px 16px; border-radius: 10px; }
.done svg { color: var(--accent); }
/* ---------- vistas centradas ---------- */
.center-view { min-height: 60vh; display: grid; place-items: center; }
.hero { max-width: 460px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.hero img { width: 150px; height: auto; background: #fff; border-radius: 12px; padding: 8px; }
.hero h1 { font-size: clamp(22px, 4vw, 30px); }
.hero p { color: var(--muted); }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tab {
  font: inherit; font-weight: 600; font-size: 14px; color: var(--muted);
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent-strong); border-bottom-color: var(--accent); }
.tab .count { background: var(--red); color: #fff; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 0 6px; min-width: 18px; text-align: center; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.view-head h1 { font-size: 24px; }
.view-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar select, .toolbar input[type="search"] { width: auto; }
.toolbar input[type="search"] { flex: 1 1 220px; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 9px; overflow: hidden; background: var(--surface); }
.segmented button { font: inherit; font-size: 13px; font-weight: 600; border: 0; background: transparent; color: var(--muted); padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); }
/* ---------- totales ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 12px 14px; }
.stat .label { font-size: 12px; }
.stat .value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
/* ---------- tablas ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
table.data tr.anulada td { color: var(--muted); }
table.data tr.anulada .tercero { text-decoration: line-through; }
.doc-title { font-weight: 600; }
.doc-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--line); color: var(--ink); white-space: nowrap; }
.badge-ok { background: var(--accent-soft); color: var(--accent-strong); }
.badge-no { background: var(--red-soft); color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
/* ---------- solicitudes ---------- */
.req-list { display: grid; gap: 12px; }
.req { padding: 16px 18px; display: grid; gap: 10px; }
.req-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.req-head h3 { font-size: 16px; }
.req-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 6px 18px; font-size: 14px; }
.req-grid dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.req-grid dd { margin: 0; overflow-wrap: anywhere; }
.req-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.warn-box { background: var(--warn-soft); color: var(--warn); padding: 10px 12px; border-radius: 8px; font-size: 13.5px; grid-column: 1 / -1; }
.info-box { background: var(--info-soft); color: var(--info); padding: 10px 12px; border-radius: 8px; font-size: 13.5px; grid-column: 1 / -1; }
/* ---------- diálogos ---------- */
.dialog {
  border: 0; padding: 0; border-radius: 16px; width: min(760px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.dialog::backdrop { background: rgba(15, 20, 15, .45); }
.dialog-sm { width: min(460px, calc(100vw - 24px)); }
.dialog-pdf { width: min(980px, calc(100vw - 24px)); height: calc(100vh - 32px); height: calc(100dvh - 32px); }
.dialog-pdf[open] { display: flex; flex-direction: column; }
.dialog form { display: contents; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 18px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dialog-body { padding: 18px 20px; overflow: auto; }
.dialog-pdf .dialog-body { flex: 1; padding: 0; display: flex; }
.dialog-pdf iframe { border: 0; width: 100%; flex: 1; background: #525659; }
.pdf-fallback { flex: 1; display: grid; align-content: center; justify-items: center; gap: 16px; padding: 24px; text-align: center; color: var(--muted); }
.pdf-fallback[hidden] { display: none; }
.pdf-fallback-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.dropzone strong { color: var(--ink); }
/* ---------- avisos ---------- */
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 100; width: min(460px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; }
.toast-error { background: var(--red); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* ---------- ajustes finos y móvil ---------- */
.view-head .actions select { width: auto; }
table.data td.c-acc { width: 1%; }
@media (max-width: 720px) {
  #user-email { display: none; }
  .view-head .actions { width: 100%; }
  .toolbar select { flex: 1 1 45%; }
  .segmented { max-width: 100%; overflow-x: auto; }
}
/* ---------- comprobantes ---------- */
.dropzone-sm { padding: 12px; }
.dropzone-sm .dz-text { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; font-size: 14px; }
.dz-files { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 4px; }
.dz-files:empty { display: none; }
.dz-files li { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); font-size: 14px; min-width: 0; }
.dz-files .dz-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
/* ---------- espera: ruedas, barra de actividad y progreso ---------- */
.spin { display: inline-block; width: 1em; height: 1em; flex: none; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; vertical-align: -0.15em; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]:disabled { opacity: .85; }
.dialog.busy { cursor: progress; }
.busy-bar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 300; overflow: hidden; background: color-mix(in srgb, var(--accent) 18%, transparent); pointer-events: none; }
.busy-bar::before { content: ''; position: absolute; top: 0; bottom: 0; left: 0; width: 35%; background: var(--accent); animation: busy 1.1s ease-in-out infinite; }
@keyframes busy { from { transform: translateX(-100%); } to { transform: translateX(290%); } }
.progreso { display: block; width: 100%; height: 6px; border: 0; border-radius: 99px; overflow: hidden; appearance: none; -webkit-appearance: none; background: var(--line); color: var(--accent); }
.progreso::-webkit-progress-bar { background: var(--line); border-radius: 99px; }
.progreso::-webkit-progress-value { background: var(--accent); border-radius: 99px; transition: width .2s; }
.progreso::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
/* Sin valor (no se sabe cuánto falta): una franja que va y viene. */
.progreso:indeterminate { background: linear-gradient(90deg, transparent 0 35%, var(--accent) 35% 65%, transparent 65%) var(--line); background-size: 250% 100%; animation: indet 1.3s ease-in-out infinite; }
.progreso:indeterminate::-webkit-progress-bar { background: transparent; }
.progreso:indeterminate::-moz-progress-bar { background: transparent; }
@keyframes indet { from { background-position: 100% 0; } to { background-position: 0 0; } }
.dlg-status { flex: 1 1 100%; display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
.toasts[popover] { inset: auto auto 16px 50%; margin: 0; padding: 0; border: 0; background: none; overflow: visible; color: inherit; }
.toast-tarea { display: grid; gap: 8px; }
.toast-tarea .linea { display: flex; align-items: center; gap: 8px; }
.toast-tarea .progreso { background: color-mix(in srgb, var(--paper) 25%, transparent); }
.toast-tarea .progreso::-webkit-progress-bar { background: color-mix(in srgb, var(--paper) 25%, transparent); }
.toast-tarea .progreso:indeterminate { background-color: color-mix(in srgb, var(--paper) 25%, transparent); }
.pdf-loading { flex: 1; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; color: var(--muted); }
.pdf-loading .progreso { width: min(320px, 70vw); }
.pdf-loading .form-error { max-width: 480px; }
#dlg-form-body .hint .spin { margin-right: 4px; }
@media (prefers-reduced-motion: reduce) {
  .spin, .spinner, .busy-bar::before, .progreso:indeterminate { animation-duration: 3s; }
}
