/* ==========================================================================
   GestionaPública — Design tokens + componentes base
   Compartido por la app del ciudadano (/app) y el panel de gestión (/panel).

   Tema oscuro por defecto; claro con <html data-theme="light">.
   Paleta corporativa: el amarillo yema de la familia Gestiona (--brand).
   Cambiando el bloque :root se reviste el producto entero, incluidos los
   colores de marca del ente (settings del ayuntamiento).

   Sobre --brand y --accent: son el mismo amarillo, pero con oficios distintos.
   --brand es el color fijo del logotipo, idéntico en los dos temas, porque una
   marca que cambia de color deja de ser una marca. --accent es el amarillo de
   la interfaz y sí se oscurece en tema claro: #FCA905 sobre blanco da 1,9:1 de
   contraste y ningún texto ni icono se leería. Regla práctica: el logo usa
   --brand; todo lo demás, --accent.
   ========================================================================== */

:root {
  /* --- Superficies ---
     Las mismas que GestionaFitness: azul oscuro de base en lugar del negro
     grisáceo anterior. Las tarjetas no son un color propio sino blanco a muy
     baja opacidad sobre ese azul; por eso se ven como el mismo material esté
     la tarjeta donde esté, y por eso NO valen aquí colores sólidos. Todo lo
     que tenga que tapar contenido al desplazarse (cabeceras fijas, cajón,
     modal) usa --bg-elev, que sí es opaco. */
  --bg:            #111827;
  --bg-elev:       #18202e;
  --bg-card:       rgba(255, 255, 255, .055);
  --bg-card-hover: rgba(255, 255, 255, .09);
  --bg-input:      rgba(255, 255, 255, .075);
  --bg-overlay:    rgba(9, 14, 26, .72);

  /* --- Bordes y líneas --- */
  --border:        rgba(255, 255, 255, .11);
  --border-soft:   rgba(255, 255, 255, .04);
  --border-strong: rgba(255, 255, 255, .22);

  /* --- Texto --- */
  --text:          #f1f5f9;
  --text-soft:     #94a3b8;
  /* Un punto más claro que el #64748b de GestionaFitness: aquí lo llevan
     avisos y letra pequeña, y aquel se queda en 3,7:1 sobre el fondo nuevo. */
  --text-muted:    #7c8aa0;

  /* --- Marca / acentos --- */
  --brand:         #FCA905;   /* amarillo yema: color fijo del logotipo */
  --brand-deep:    #F59000;   /* extremo naranja del degradado del símbolo */
  --brand-light:   #FFC233;   /* extremo claro del degradado del símbolo */
  /* El mismo degradado del símbolo, para teñir titulares */
  --brand-grad:    linear-gradient(135deg, #F59000, #FFC233);

  --accent:        #FCA905;
  --accent-hover:  #E09400;
  --accent-soft:   rgba(252, 169, 5, .15);
  --accent-text:   #1c1305;   /* tinta oscura: sobre amarillo el blanco no se lee */

  --info:          #0891b2;
  --info-soft:     rgba(8, 145, 178, .15);
  --ok:            #059669;
  --ok-soft:       rgba(5, 150, 105, .15);
  /* El ámbar de antes (#f59e0b) queda a un paso del amarillo de marca: un aviso
     y un elemento destacado se veían igual. El aviso se corre hacia el naranja. */
  --warn:          #f97316;
  --warn-soft:     rgba(249, 115, 22, .15);
  --danger:        #ef4444;
  --danger-soft:   rgba(239, 68, 68, .14);
  --purple:        #a855f7;
  --purple-soft:   rgba(168, 85, 247, .14);

  /* --- Paleta de series para gráficas --- */
  --c1: #FCA905; --c2: #2563eb; --c3: #0891b2; --c4: #7c3aed;
  --c5: #ef4444; --c6: #059669; --c7: #db2777; --c8: #64748b;

  /* --- Formas --- */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* --- Sombras --- */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.32);
  --shadow:    0 4px 16px rgba(0,0,0,.34);
  --shadow-lg: 0 18px 48px rgba(0,0,0,.48);

  /* --- Tipografía --- */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;

  /* --- Layout --- */
  --topbar-h: 64px;   /* igual que la barra de GestionaFitness */
  --tabbar-h: 64px;
  --maxw: 1440px;
}

/* En claro las superficies vuelven a ser sólidas: el blanco translúcido del
   tema oscuro sobre un fondo claro no se vería. Mismos valores que el tema
   claro de GestionaFitness. */
html[data-theme="light"] {
  --bg:            #f8fafc;
  --bg-elev:       #ffffff;
  --bg-card:       #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input:      #ffffff;
  --bg-overlay:    rgba(15, 23, 42, .45);

  --border:        #cbd5e1;
  --border-soft:   #e2e8f0;
  --border-strong: #94a3b8;

  --text:          #0f172a;
  --text-soft:     #475569;
  --text-muted:    #8593a5;

  /* El amarillo de marca sobre blanco es ilegible (1,9:1). En tema claro el
     acento de interfaz baja a un ámbar tostado —mismo color, más tinta— que
     pasa AA como texto y como fondo de botón. El logotipo no se toca: sigue
     pintándose con --brand. */
  --accent:        #B87200;
  --accent-hover:  #9A5F00;
  --accent-soft:   rgba(184, 114, 0, .12);
  --accent-text:   #ffffff;
  --ok-soft:       rgba(5, 150, 105, .11);

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --info-soft:     rgba(8, 145, 178, .11);
  --shadow:    0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, .16);
}

/* ==========================================================================
   Reset
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { min-height: 100vh; }

h1, h2, h3, h4, h5 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p  { margin: 0 0 .6rem; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ==========================================================================
   Utilidades
   ========================================================================== */

.gp-row     { display: flex; align-items: center; gap: 10px; }
.gp-row-b   { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gp-col     { display: flex; flex-direction: column; gap: 10px; }
.gp-wrap    { flex-wrap: wrap; }
.gp-grow    { flex: 1 1 auto; min-width: 0; }
.gp-center  { text-align: center; }
.gp-right   { text-align: right; }
.gp-mt      { margin-top: 14px; }
.gp-mb      { margin-bottom: 14px; }
.gp-hide    { display: none !important; }
.gp-muted   { color: var(--text-muted); }
.gp-soft    { color: var(--text-soft); }
.gp-small   { font-size: .82rem; }
.gp-xs      { font-size: .74rem; }
.gp-bold    { font-weight: 650; }
.gp-num     { font-variant-numeric: tabular-nums; }
.gp-trunc   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.gp-ok    { color: var(--accent); }
.gp-err   { color: var(--danger); }
.gp-warnc { color: var(--warn); }
.gp-infoc { color: var(--info); }

/* ==========================================================================
   Botones
   ========================================================================== */

.gp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: .9rem; font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .06s, opacity .15s;
  white-space: nowrap;
  user-select: none;
}
.gp-btn:hover  { background: var(--bg-card-hover); border-color: var(--border-strong); text-decoration: none; }
.gp-btn:active { transform: translateY(1px); }
.gp-btn:disabled, .gp-btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; }

.gp-btn.primary   { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.gp-btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.gp-btn.danger    { background: var(--danger); border-color: var(--danger); color: #fff; }
.gp-btn.danger:hover { filter: brightness(1.08); }
.gp-btn.ghost     { background: transparent; border-color: transparent; color: var(--text-soft); }
.gp-btn.ghost:hover { background: var(--bg-card-hover); color: var(--text); }
.gp-btn.outline   { background: transparent; }
.gp-btn.sm        { padding: 6px 11px; font-size: .8rem; }
.gp-btn.lg        { padding: 13px 22px; font-size: 1rem; }
.gp-btn.block     { width: 100%; }
.gp-btn.icon      { padding: 8px; width: 36px; height: 36px; }

/* ==========================================================================
   Formularios
   ========================================================================== */

.gp-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.gp-label { font-size: .78rem; font-weight: 600; color: var(--text-soft); letter-spacing: .01em; }
.gp-label .req { color: var(--danger); }

.gp-input, .gp-select, .gp-textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: .92rem;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
.gp-textarea { min-height: 92px; resize: vertical; line-height: 1.55; }
.gp-select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236f7c8f' stroke-width='2.5' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 32px;
}
.gp-input:focus, .gp-select:focus, .gp-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.gp-input::placeholder, .gp-textarea::placeholder { color: var(--text-muted); }
.gp-input:disabled, .gp-select:disabled, .gp-textarea:disabled { opacity: .55; cursor: not-allowed; }
.gp-input.invalid, .gp-select.invalid, .gp-textarea.invalid { border-color: var(--danger); }

.gp-hint { font-size: .74rem; color: var(--text-muted); }
.gp-err-msg { font-size: .74rem; color: var(--danger); }

.gp-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.gp-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.gp-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
@media (max-width: 780px) {
  .gp-grid-2, .gp-grid-3, .gp-grid-4 { grid-template-columns: 1fr; }
}

/* checkbox / switch */
.gp-check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-size: .86rem; color: var(--text-soft); }
.gp-check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 2px 0 0; flex: 0 0 auto; cursor: pointer; }

.gp-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: 0 0 auto; }
.gp-switch input { opacity: 0; width: 0; height: 0; }
.gp-switch span {
  position: absolute; inset: 0; cursor: pointer;
  background: var(--border-strong); border-radius: 99px; transition: background .18s;
}
.gp-switch span::before {
  content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .18s;
}
.gp-switch input:checked + span { background: var(--accent); }
.gp-switch input:checked + span::before { transform: translateX(18px); }

/* ==========================================================================
   Tarjetas
   ========================================================================== */

.gp-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
}
.gp-card.pad-0 { padding: 0; }
.gp-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.gp-card-title { font-size: .95rem; font-weight: 650; }
.gp-card-sub   { font-size: .78rem; color: var(--text-muted); font-weight: 500; }

/* KPI */
.gp-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 15px 16px;
  display: flex; flex-direction: column; gap: 5px;
  position: relative; overflow: hidden;
}
.gp-kpi .k-top { display: flex; align-items: center; gap: 8px; }
.gp-kpi .k-ico {
  width: 30px; height: 30px; border-radius: var(--r-sm);
  display: grid; place-items: center; font-size: .95rem;
  background: var(--accent-soft); color: var(--accent); flex: 0 0 auto;
}
.gp-kpi .k-label { font-size: .76rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.gp-kpi .k-value { font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.gp-kpi .k-foot  { font-size: .76rem; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.gp-kpi.info   .k-ico { background: var(--info-soft);   color: var(--info); }
.gp-kpi.warn   .k-ico { background: var(--warn-soft);   color: var(--warn); }
.gp-kpi.danger .k-ico { background: var(--danger-soft); color: var(--danger); }
.gp-kpi.purple .k-ico { background: var(--purple-soft); color: var(--purple); }

.gp-delta { font-weight: 650; font-size: .76rem; }
.gp-delta.up   { color: var(--accent); }
.gp-delta.down { color: var(--danger); }
.gp-delta.flat { color: var(--text-muted); }

/* ==========================================================================
   Badges / chips
   ========================================================================== */

.gp-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: .72rem; font-weight: 650; letter-spacing: .01em;
  background: var(--bg-card-hover); color: var(--text-soft);
  border: 1px solid var(--border); white-space: nowrap;
}
.gp-badge.ok     { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.gp-badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.gp-badge.info   { background: var(--info-soft);   color: var(--info);   border-color: transparent; }
.gp-badge.warn   { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.gp-badge.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.gp-badge.purple { background: var(--purple-soft); color: var(--purple); border-color: transparent; }
.gp-badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.gp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--r-pill);
  background: var(--bg-card); border: 1px solid var(--border);
  font-size: .82rem; font-weight: 600; color: var(--text-soft);
  cursor: pointer; white-space: nowrap; transition: all .15s;
}
.gp-chip:hover  { border-color: var(--border-strong); color: var(--text); }
.gp-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.gp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gp-chips .gp-chip { padding: 6px 12px; font-size: .78rem; }

/* Selector segmentado: dos o tres opciones excluyentes que se ven de golpe.
   Un <select> escondería que hay alternativas; aquí la elección es el mensaje. */
.gp-seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.gp-seg.gp-seg-block { display: flex; width: 100%; }
.gp-seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  flex: 1 1 auto; padding: 7px 12px; border: 0; border-radius: calc(var(--r-sm) - 3px);
  background: transparent; color: var(--text-muted);
  font-size: .8rem; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap; transition: all .15s;
}
.gp-seg button:hover  { color: var(--text); }
.gp-seg button.active { background: var(--bg-card); color: var(--accent); box-shadow: var(--shadow-sm); }

/* ==========================================================================
   Tablas
   ========================================================================== */

.gp-table { width: 100%; border-collapse: collapse; font-size: .87rem; }
.gp-table thead th {
  text-align: left; padding: 10px 12px;
  font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  position: sticky; top: 0; z-index: 2;
  white-space: nowrap;
}
.gp-table tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.gp-table tbody tr:hover td { background: var(--bg-card-hover); }
.gp-table tbody tr.clickable { cursor: pointer; }
.gp-table td.num, .gp-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.gp-table .empty td { text-align: center; color: var(--text-muted); padding: 34px 12px; }
.gp-table tfoot td { padding: 11px 12px; font-weight: 650; border-top: 1px solid var(--border); }

/* Cabeceras ordenables ------------------------------------------------- */
.gp-table thead th.sortable { cursor: pointer; user-select: none; }
.gp-table thead th.sortable:hover  { color: var(--text); background: var(--bg-card-hover); }
.gp-table thead th.sortable:focus-visible {
  outline: 2px solid var(--accent); outline-offset: -2px;
}
.gp-table thead th.sorted { color: var(--accent); }
.gp-table thead th .th-in { display: inline-flex; align-items: center; gap: 5px; }
.gp-table thead th.num .th-in { flex-direction: row-reverse; }

/* La flecha ocupa sitio siempre, para que la fila no baile al ordenar */
.gp-table thead th .th-arrow {
  width: 8px; height: 8px; flex: 0 0 auto; position: relative; opacity: 0;
  transition: opacity .12s ease;
}
.gp-table thead th.sortable:hover .th-arrow { opacity: .45; }
.gp-table thead th .th-arrow[data-dir="asc"],
.gp-table thead th .th-arrow[data-dir="desc"] { opacity: 1; }
.gp-table thead th .th-arrow::after {
  content: ''; position: absolute; left: 0; top: 50%;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-bottom: 5px solid currentColor;
  transform: translateY(-50%);
}
.gp-table thead th .th-arrow[data-dir="desc"]::after { transform: translateY(-50%) rotate(180deg); }

.gp-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font-size: .74rem; font-weight: 700; flex: 0 0 auto;
  text-transform: uppercase;
}
.gp-avatar.lg { width: 54px; height: 54px; font-size: 1.15rem; }

/* ==========================================================================
   Modal
   ========================================================================== */

.gp-modal {
  position: fixed; inset: 0; z-index: 900;
  background: var(--bg-overlay);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: gpFade .16s ease;
}
.gp-modal-box {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  animation: gpPop .18s cubic-bezier(.2,.9,.3,1.1);
}
.gp-modal-box.wide  { max-width: 900px; }
.gp-modal-box.slim  { max-width: 420px; }
.gp-modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.gp-modal-body { padding: 18px; overflow-y: auto; flex: 1 1 auto; }
.gp-modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 18px; border-top: 1px solid var(--border); flex: 0 0 auto;
}
.gp-x {
  background: none; border: 0; color: var(--text-muted); cursor: pointer;
  font-size: 1.35rem; line-height: 1; padding: 4px 8px; border-radius: var(--r-sm);
}
.gp-x:hover { background: var(--bg-card-hover); color: var(--text); }

@keyframes gpFade { from { opacity: 0 } to { opacity: 1 } }
@keyframes gpPop  { from { opacity: 0; transform: translateY(10px) scale(.985) } to { opacity: 1; transform: none } }
@keyframes gpSlideUp { from { transform: translateY(100%) } to { transform: none } }

/* Hoja inferior (móvil / PWA) */
@media (max-width: 640px) {
  .gp-modal { padding: 0; align-items: flex-end; }
  .gp-modal-box {
    max-width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0;
    max-height: 92vh; animation: gpSlideUp .22s cubic-bezier(.2,.9,.3,1);
  }
}

/* ==========================================================================
   Toasts
   ========================================================================== */

#gp-toasts {
  position: fixed; z-index: 1000; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 9px; pointer-events: none;
  max-width: min(380px, calc(100vw - 32px));
}
.gp-toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 15px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg);
  font-size: .87rem;
  animation: gpToastIn .2s cubic-bezier(.2,.9,.3,1.1);
  pointer-events: auto;
}
.gp-toast.success { border-left-color: var(--accent); }
.gp-toast.error   { border-left-color: var(--danger); }
.gp-toast.warning { border-left-color: var(--warn); }
.gp-toast.info    { border-left-color: var(--info); }
.gp-toast.out     { animation: gpToastOut .18s ease forwards; }
.gp-toast .t-ico  { flex: 0 0 auto; }
@keyframes gpToastIn  { from { opacity: 0; transform: translateX(24px) } to { opacity: 1; transform: none } }
@keyframes gpToastOut { to { opacity: 0; transform: translateX(24px) } }
@media (max-width: 640px) {
  #gp-toasts { bottom: calc(var(--tabbar-h) + 14px); left: 12px; right: 12px; max-width: none; }
}

/* ==========================================================================
   Barra de progreso / aforo
   ========================================================================== */

.gp-bar { height: 7px; background: var(--border-soft); border-radius: 99px; overflow: hidden; }
.gp-bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .35s ease; }
.gp-bar > i.ok     { background: var(--ok); }
.gp-bar > i.warn   { background: var(--warn); }
.gp-bar > i.danger { background: var(--danger); }
.gp-bar > i.info   { background: var(--info); }

/* ==========================================================================
   Estados vacíos / carga
   ========================================================================== */

.gp-empty { text-align: center; padding: 42px 20px; color: var(--text-muted); }
.gp-empty .e-ico { font-size: 2.4rem; margin-bottom: 10px; opacity: .6; }
.gp-empty .e-title { font-weight: 650; color: var(--text-soft); margin-bottom: 4px; }

.gp-skel {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 37%, var(--bg-card) 63%);
  background-size: 400% 100%;
  animation: gpShimmer 1.2s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes gpShimmer { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }

.gp-spin {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: gpSpin .7s linear infinite; flex: 0 0 auto;
}
@keyframes gpSpin { to { transform: rotate(360deg) } }

#gp-loader {
  position: fixed; inset: 0; z-index: 1100;
  background: var(--bg-overlay); backdrop-filter: blur(2px);
  display: grid; place-items: center;
}
#gp-loader .gp-spin { width: 34px; height: 34px; border-width: 3px; }

/* ==========================================================================
   Tabs
   ========================================================================== */

.gp-tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.gp-tab {
  padding: 10px 15px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-muted); font-size: .87rem; font-weight: 600; cursor: pointer;
  white-space: nowrap; transition: color .15s, border-color .15s;
}
.gp-tab:hover  { color: var(--text-soft); }
.gp-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Banner modo demo */
.gp-demo-flag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--warn-soft); color: var(--warn);
  font-size: .68rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==========================================================================
   COMPONENTES PROPIOS DE GESTIÓN PÚBLICA
   ========================================================================== */

/* --- Régimen de gestión: la etiqueta que aparece en todas partes --------- */
.gp-regimen {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: .72rem; font-weight: 650; white-space: nowrap;
  border: 1px solid transparent;
}
.gp-regimen::before { content: ""; width: 7px; height: 7px; border-radius: 2px; background: currentColor; }
.gp-regimen[data-r="directa"]         { color: #2563eb; background: rgba(37,99,235,.14); }
.gp-regimen[data-r="servicios"]       { color: #0891b2; background: rgba(8,145,178,.14); }
.gp-regimen[data-r="concesion"]       { color: #7c3aed; background: rgba(124,58,237,.14); }
.gp-regimen[data-r="concesion_obra"]  { color: #c026d3; background: rgba(192,38,211,.14); }
.gp-regimen[data-r="cesion_convenio"] { color: #059669; background: rgba(5,150,105,.14); }
.gp-regimen[data-r="mixta"]           { color: #d97706; background: rgba(217,119,6,.14); }
.gp-regimen[data-r="fuera_servicio"]  { color: #64748b; background: rgba(100,116,139,.16); }

/* --- Semáforo de vencimiento -------------------------------------------- */
.gp-expiry { display: inline-flex; align-items: center; gap: 5px; font-size: .76rem; font-weight: 600; }
.gp-expiry::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.gp-expiry.ok::before     { background: var(--ok); }
.gp-expiry.warn::before   { background: var(--warn); }
.gp-expiry.danger::before { background: var(--danger); animation: gpPulse 1.8s ease-in-out infinite; }
.gp-expiry.ok     { color: var(--text-muted); }
.gp-expiry.warn   { color: var(--warn); }
.gp-expiry.danger { color: var(--danger); }
@keyframes gpPulse { 0%,100% { opacity: 1 } 50% { opacity: .35 } }

/* --- Ficha 360º: navegación lateral de la instalación -------------------- */
.gp-facility-head {
  display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap;
  padding-bottom: 16px; border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.gp-facility-head .fh-ico {
  width: 56px; height: 56px; border-radius: var(--r); flex: 0 0 auto;
  display: grid; place-items: center; font-size: 1.6rem;
  background: var(--accent-soft); color: var(--accent);
}
.gp-facility-head .fh-name { font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; }
.gp-facility-head .fh-meta { font-size: .8rem; color: var(--text-muted); margin-top: 3px; }
.gp-facility-head .fh-right { margin-left: auto; text-align: right; }

/* --- Documentos (pliegos, contratos, licencias) -------------------------- */
.gp-doc {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--bg-card); transition: all .14s;
}
.gp-doc + .gp-doc { margin-top: 8px; }
.gp-doc:hover { border-color: var(--border-strong); background: var(--bg-card-hover); }
.gp-doc .d-ico {
  width: 36px; height: 36px; border-radius: 8px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: .95rem;
  background: var(--bg-card-hover); color: var(--text-soft);
}
.gp-doc .d-ico.pdf { background: rgba(239,68,68,.14); color: #ef4444; }
.gp-doc .d-ico.doc { background: rgba(37,99,235,.14); color: #2563eb; }
.gp-doc .d-ico.xls { background: rgba(5,150,105,.14); color: #059669; }
.gp-doc .d-name { font-size: .86rem; font-weight: 600; }
.gp-doc .d-meta { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }
.gp-doc.historico { opacity: .62; }

/* --- Línea temporal (hitos del contrato, histórico de régimen) ----------- */
.gp-timeline { position: relative; padding-left: 26px; }
.gp-timeline::before {
  content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.gp-tl-item { position: relative; padding: 0 0 18px; }
.gp-tl-item::before {
  content: ""; position: absolute; left: -22px; top: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bg-card); border: 2px solid var(--border-strong);
}
.gp-tl-item.done::before    { background: var(--ok);     border-color: var(--ok); }
.gp-tl-item.current::before { background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft); }
.gp-tl-item.alert::before   { background: var(--danger); border-color: var(--danger); }
.gp-tl-item .tl-date  { font-size: .72rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.gp-tl-item .tl-title { font-size: .88rem; font-weight: 620; margin-top: 1px; }
.gp-tl-item .tl-desc  { font-size: .78rem; color: var(--text-soft); margin-top: 3px; line-height: 1.5; }

/* --- Contadores y lecturas ---------------------------------------------- */
.gp-meter {
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-card); padding: 14px;
}
.gp-meter .m-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.gp-meter .m-ico {
  width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 1rem;
}
.gp-meter .m-ico.luz   { background: rgba(245,158,11,.15); color: #f59e0b; }
.gp-meter .m-ico.agua  { background: rgba(8,145,178,.15);  color: #0891b2; }
.gp-meter .m-ico.gas   { background: rgba(217,119,6,.15);  color: #d97706; }
.gp-meter .m-ico.otro  { background: var(--bg-card-hover);  color: var(--text-soft); }
.gp-meter .m-name  { font-size: .88rem; font-weight: 650; }
.gp-meter .m-cups  { font-size: .68rem; color: var(--text-muted); font-family: var(--font-mono); }
.gp-meter .m-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.gp-meter .m-unit  { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.gp-meter.anomalia { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }

/* --- Quién paga qué: titular del suministro ------------------------------ */
.gp-titular {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--r-pill);
  font-size: .68rem; font-weight: 650;
}
.gp-titular.ente    { background: var(--accent-soft); color: var(--accent); }
.gp-titular.empresa { background: var(--purple-soft); color: var(--purple); }

/* --- Estado del expediente de contratación ------------------------------- */
.gp-estado {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: .72rem; font-weight: 650; white-space: nowrap;
  background: var(--bg-card-hover); color: var(--text-soft);
  border: 1px solid var(--border);
}
.gp-estado[data-e="preparacion"]   { background: rgba(100,116,139,.16); color: #94a3b8; border-color: transparent; }
.gp-estado[data-e="licitacion"]    { background: rgba(245,158,11,.15);  color: #f59e0b; border-color: transparent; }
.gp-estado[data-e="adjudicacion"]  { background: rgba(8,145,178,.15);   color: #0891b2; border-color: transparent; }
.gp-estado[data-e="ejecucion"]     { background: rgba(5,150,105,.15);   color: #059669; border-color: transparent; }
.gp-estado[data-e="prorroga"]      { background: rgba(124,58,237,.15);  color: #7c3aed; border-color: transparent; }
.gp-estado[data-e="finalizado"]    { background: rgba(100,116,139,.16); color: #94a3b8; border-color: transparent; }
/* Desierta en rojo: no es un estado más del recorrido, es un expediente que
   se ha parado y que obliga a hacer algo. */
.gp-estado[data-e="desierta"]      { background: rgba(239,68,68,.15);   color: #ef4444; border-color: transparent; }

/* --- Barra de progreso del contrato (tiempo consumido) ------------------- */
.gp-progress {
  position: relative; height: 26px; border-radius: var(--r-sm);
  background: var(--border-soft); overflow: hidden;
}
.gp-progress > i {
  display: block; height: 100%; background: var(--accent);
  transition: width .45s cubic-bezier(.2,.8,.3,1);
}
.gp-progress > i.ok     { background: var(--ok); }
.gp-progress > i.warn   { background: var(--warn); }
.gp-progress > i.danger { background: var(--danger); }
.gp-progress > span {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: .72rem; font-weight: 650; color: var(--text);
  text-shadow: 0 1px 2px var(--bg-card);
}

/* --- Mapa de instalaciones (marcadores sin dependencias externas) -------- */
.gp-map {
  position: relative; border-radius: var(--r); overflow: hidden;
  border: 1px solid var(--border); background: var(--bg-elev);
}
.gp-map-pin {
  position: absolute; transform: translate(-50%, -100%);
  cursor: pointer; transition: transform .14s;
}
.gp-map-pin:hover { transform: translate(-50%, -100%) scale(1.15); z-index: 5; }
.gp-map-pin .pin-dot {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
  display: grid; place-items: center;
}
.gp-map-pin .pin-dot span { transform: rotate(45deg); font-size: .7rem; }

/* --- Aviso institucional (cajón de texto legal / advertencia) ------------ */
.gp-notice {
  display: flex; gap: 12px; padding: 13px 15px;
  border-radius: var(--r); border: 1px solid var(--border);
  background: var(--bg-card); font-size: .82rem; line-height: 1.55;
}
.gp-notice .n-ico { flex: 0 0 auto; font-size: 1.1rem; }
.gp-notice.info   { background: var(--info-soft);   border-color: transparent; }
.gp-notice.warn   { background: var(--warn-soft);   border-color: transparent; }
.gp-notice.danger { background: var(--danger-soft); border-color: transparent; }
.gp-notice.ok     { background: var(--ok-soft);     border-color: transparent; }
.gp-notice b { font-weight: 650; }

/* Asiento del registro de entrada. Se destaca sobre el resto de metadatos
   porque es lo que acredita la fecha de presentación: es el dato al que se
   vuelve cuando hay discusión sobre si algo llegó en plazo. */
.gp-doc .d-registro {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 5px;
  font-size: .7rem; color: var(--ok);
  background: var(--ok-soft); border-radius: var(--r-pill); padding: 2px 9px;
}
.gp-doc .d-registro b { font-variant-numeric: tabular-nums; }

/* Zona de selección de archivo */
.doc-drop {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  border: 1.5px dashed var(--border-strong); border-radius: var(--r-sm);
  padding: 12px 14px;
}
.doc-drop label.gp-btn { cursor: pointer; }
