* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: #f4f4f5;
  color: #1a1a1a;
}

.hidden { display: none !important; }

/* ---------- Pantalla de selecció d'idioma ---------- */
.lang-screen {
  position: fixed;
  inset: 0;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.lang-box { text-align: center; color: white; padding: 24px; }
.lang-box h1 { font-size: 2.4rem; margin: 0 0 24px; }
.lang-box h1::first-letter { color: #ff6a00; }
.lang-title { font-size: 1.1rem; line-height: 1.8; color: #ccc; margin-bottom: 28px; }
.lang-title .sep { color: #ff6a00; }
.lang-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.lang-btn {
  background: transparent;
  border: 2px solid #ff6a00;
  color: white;
  padding: 12px 28px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}
.lang-btn:hover { background: #ff6a00; }

/* ---------- Capçalera ---------- */
header {
  background: #1a1a1a;
  color: white;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
header h1 { margin: 0; font-size: 1.3rem; }
.header-right { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }

.lang-switcher {
  background: #333;
  color: white;
  border: 1px solid #555;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.85rem;
}

.logout-btn {
  background: none;
  border: 1px solid #666;
  color: #ccc;
  border-radius: 6px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 0.85rem;
}
.logout-btn:hover { border-color: #ff6a00; color: #ff6a00; }

main { max-width: 640px; margin: 0 auto; padding: 24px 16px; }

/* ---------- Pestanyes ---------- */
/* La pestanya ACTIVA es veu taronja i plena; la inactiva, plana i grisa.
   Abans l'activa era blanca i es confonia amb el fons del panell, cosa que
   feia semblar que la seleccionada era l'altra. */
.tab {
  padding: 9px 18px;
  border: 1px solid transparent;
  background: transparent;
  color: #888;
  cursor: pointer;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: all 0.15s;
}
.tab:hover { color: #444; background: #f0f0f0; }
.tab.active {
  background: #ff6a00;
  color: white;
  font-weight: 600;
}

.auth-tabs, .reserves-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: #f0f0f0;
  padding: 4px;
  border-radius: 10px;
}
.auth-tabs { margin-bottom: 0; border-radius: 10px 10px 0 0; }

.auth-form, .panel {
  background: white;
  padding: 20px;
  border-radius: 0 0 10px 10px;
  margin-bottom: 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.panel { border-radius: 10px; }
.panel h2 { margin-top: 0; font-size: 1.15rem; }

/* ---------- Formularis ---------- */
form label { display: block; margin-bottom: 14px; font-size: 0.9rem; color: #444; }

.auth-form input,
form input[type="date"],
form input[type="time"],
form input[type="number"],
form select {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;
  width: 100%;
  margin-top: 5px;
  background: white;
}
.auth-form input { margin-bottom: 12px; margin-top: 0; }

.row { display: flex; gap: 12px; }
.row label { flex: 1; }

/* Casella "ús exclusiu" ben alineada */
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 16px;
  padding: 12px;
  background: #fafafa;
  border-radius: 8px;
}
.checkbox-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex-shrink: 0;
  accent-color: #ff6a00;
}
.checkbox-label { margin: 0 !important; cursor: pointer; }
.checkbox-label strong { display: block; font-size: 0.95rem; color: #1a1a1a; }
.checkbox-label small { display: block; color: #777; font-size: 0.82rem; margin-top: 2px; }

button[type="submit"] {
  background: #ff6a00;
  color: white;
  border: none;
  padding: 11px 24px;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 500;
}
button[type="submit"]:hover { background: #e55f00; }

.error { color: #c0392b; margin: 10px 0 0; font-size: 0.9rem; }
.success { color: #1e8449; margin: 10px 0 0; font-size: 0.9rem; }
.empty { color: #888; font-size: 0.9rem; }

/* ---------- Targetes de boxes ---------- */
.cards { display: grid; gap: 10px; }
.box-card {
  border: 1px solid #eaeaea;
  border-radius: 10px;
  padding: 14px;
}
.box-card .tipo-tag {
  display: inline-block;
  background: #f0f0f0;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.75rem;
  margin-left: 8px;
  color: #555;
}
.box-meta { color: #666; font-size: 0.88rem; margin-top: 4px; }

/* ---------- Llista de reserves ---------- */
.list .booking-item {
  border-bottom: 1px solid #eee;
  padding: 12px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.list .booking-item:last-child { border-bottom: none; }
.booking-meta { color: #444; font-size: 0.9rem; margin-top: 3px; }
.booking-status { color: #888; font-size: 0.8rem; margin-top: 2px; }

.cancel-btn {
  background: none;
  border: 1px solid #c0392b;
  color: #c0392b;
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.cancel-btn:hover { background: #c0392b; color: white; }

@media (max-width: 480px) {
  .row { flex-direction: column; gap: 0; }
}

/* Error d'arrencada: si el servidor no dona la configuració no es pinta l'app,
   perquè les franges horàries sortirien inventades sense que es notés. */
.config-error {
  max-width: 520px;
  margin: 60px auto;
  padding: 20px 24px;
  border: 1px solid #e0b4b4;
  border-radius: 10px;
  background: #fdf2f2;
  color: #8a2020;
  text-align: center;
  line-height: 1.5;
}

/* Seu a la targeta del box. Discret: amb una sola seu és redundant, però quan
   n'hi hagi més d'una cal saber on és cada sala. */
.box-sede {
  font-size: 0.85em;
  color: #777;
  margin-top: 2px;
}

/* ============================================================
   Panell d'administració
   Pensat de 375px cap amunt (iPhone 11). Res d'amplades fixes:
   els controls s'apilen quan no hi caben i mai forcen scroll lateral.
   ============================================================ */

.app-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  background: #f0f0f0;
  padding: 4px;
  border-radius: 10px;
}

.nav-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: #888;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.15s;
}
.nav-btn:hover { color: #444; background: #e6e6e6; }
.nav-btn.active { background: #ff6a00; color: white; font-weight: 600; }

.panel-intro {
  margin: -6px 0 18px;
  color: #666;
  font-size: 0.9rem;
  line-height: 1.5;
}

.setting-row {
  padding: 16px 0;
  border-bottom: 1px solid #eee;
}
.setting-row:last-child { border-bottom: none; }

.setting-label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
}

/* L'explicació en paraules planes. Qui fa servir això és el gestor del
   gimnàs, no un programador: el nom de la clau no li diu res. */
.setting-help {
  margin: 0 0 10px;
  color: #666;
  font-size: 0.85rem;
  line-height: 1.45;
}

.setting-control {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Especificitat pujada a posta: el full ja té una regla `form input[type=...]`
   amb width:100% i margin-top que guanyaria per especificitat i desquadraria
   la fila. */
#settings-form .setting-control input,
#settings-form .setting-control select {
  flex: 1 1 120px;
  min-width: 0;              /* sense això un input flex desborda el contenidor */
  width: auto;
  margin-top: 0;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;           /* 16px: per sota, iOS fa zoom en enfocar */
  font-family: inherit;
}

.setting-unit {
  color: #888;
  font-weight: 400;
}

.setting-save {
  flex: 0 0 auto;
  border: none;
  background: #ff6a00;
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
}
.setting-save:disabled { background: #ddd; color: #999; cursor: default; }

.setting-msg {
  margin: 8px 0 0;
  font-size: 0.85rem;
  min-height: 1.1em;         /* reserva l'espai perquè la fila no salti */
}
.setting-msg.error { color: #c0392b; }
.setting-msg.success { color: #1e8449; }
.setting-msg.warning { color: #8a5300; }
.setting-msg.warning ul { margin: 6px 0 0; padding-left: 18px; }

@media (max-width: 420px) {
  /* A 375px el botó al costat deixa l'input massa estret per llegir-hi res.
     El baixem a una línia sencera. */
  .setting-control { gap: 10px; }
  #settings-form .setting-control input,
  #settings-form .setting-control select { flex: 1 1 100%; }
  .setting-save { width: 100%; padding: 12px; }
}

/* ============================================================
   Filtres del llistat de boxes
   No estaven estilats: els selects sortien amb la mida per defecte del
   navegador i al mòbil eren incòmodes de prémer. 44px d'alçada mínima és
   el que recomana Apple per a una diana tàctil.
   ============================================================ */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 160px;
  min-width: 0;
  font-size: 0.9rem;
  color: #444;
}

.filters select {
  min-height: 44px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 1rem;      /* 16px: per sota, iOS fa zoom en enfocar */
  font-family: inherit;
  background: white;
}

@media (max-width: 420px) {
  /* A 375px dos filtres de costat deixen cadascun uns 170px. Millor un per
     línia, a amplada sencera. */
  .filters label { flex: 1 1 100%; }
}

/* ============================================================
   Panell d'administració: espais
   ============================================================ */

.sub-nav { background: #f7f7f7; margin-bottom: 14px; }
.sub-nav .nav-btn { padding: 8px 10px; font-size: 0.9rem; }

.primary-btn {
  border: none;
  background: #ff6a00;
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-family: inherit;
  font-weight: 600;
  margin-bottom: 16px;
}

.secondary-btn {
  border: 1px solid #ccc;
  background: white;
  color: #444;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}
.secondary-btn:hover { background: #f0f0f0; }

#box-form {
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
  background: #fafafa;
}
#box-form h3 { margin: 0 0 14px; font-size: 1rem; }

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.form-actions button { flex: 1 1 120px; min-height: 44px; }

.box-admin-item {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid #eee;
}
.box-admin-item:last-child { border-bottom: none; }
.box-admin-item.inactiu { opacity: 0.6; }

.box-admin-info { flex: 1 1 200px; min-width: 0; }
.inactiu-tag { background: #999; }

.box-pending {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: #b06000;
  background: #fff4e5;
  padding: 2px 8px;
  border-radius: 10px;
}

.box-admin-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}
.box-admin-actions button { min-height: 44px; }

@media (max-width: 420px) {
  /* A 375px els dos botons al costat de la informació deixen tot massa
     estret. Passen a una línia sencera sota de l'espai. */
  .box-admin-info { flex: 1 1 100%; }
  .box-admin-actions { flex: 1 1 100%; }
  .box-admin-actions button { flex: 1; }
}

/* ============================================================
   Saldo d'hores
   A dalt de tot de la vista de reserves: ha de ser el primer que es veu,
   no una cosa amagada dins d'un desplegable.
   ============================================================ */

.saldo-panel {
  background: #1a1a1a;
  color: white;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 18px;
}

.saldo-etiqueta {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #999;
}

.saldo-xifra {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.2;
  margin: 2px 0;
}

.saldo-detall { font-size: 0.85rem; color: #bbb; }
.saldo-buit { font-size: 0.95rem; color: #ddd; margin-top: 4px; }

/* Avisos dins del panell de saldo: poques hores o caducitat propera. */
.saldo-panel.amb-avis {
  border: 1px solid #b06000;
  background: #241a0e;
}

.saldo-avis {
  margin-top: 10px;
  padding: 8px 10px;
  background: #3a2a12;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #ffc879;
}

/* Demanar hores i estat de la sol·licitud */
.saldo-btn {
  margin-top: 14px;
  width: 100%;
  min-height: 44px;
  border: 1px solid #555;
  background: transparent;
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
}
.saldo-btn:hover:not(:disabled) { background: #2a2a2a; }
.saldo-btn:disabled { border-color: #333; color: #666; cursor: default; }

.solicitud-banner {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  line-height: 1.45;
  background: #eef4fb;
  border: 1px solid #c3d8ef;
  color: #2c4a68;
}
.solicitud-banner.rebutjada {
  background: #fdf2f2;
  border-color: #e0b4b4;
  color: #8a2020;
}

/* Enllaços amb aspecte de text dins dels formularis d'autenticació */
.link-btn {
  background: none;
  border: none;
  color: #ff6a00;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  padding: 10px 0;
  text-decoration: underline;
  min-height: 44px;
}
.link-btn:hover { color: #cc5500; }

.form-help {
  color: #666;
  font-size: 0.9rem;
  line-height: 1.45;
  margin: 0 0 12px;
}

/* Aclariment sota un camp del formulari */
.camp-ajuda {
  display: block;
  margin-top: 4px;
  color: #777;
  font-size: 0.82rem;
  line-height: 1.4;
}

/* ============================================================
   Què hi ha lliure
   Llista vertical d'hores. A 375px es llegeix de dalt a baix sense
   scroll lateral, que és el que un mòbil fa bé. Una graella d'espais
   per hores demanaria moure's de costat i no s'entendria.
   ============================================================ */

.dispo-list { margin-top: 4px; }

.dispo-franja {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #f0f0f0;
}
.dispo-franja:last-child { border-bottom: none; }

.dispo-hora {
  flex: 0 0 58px;
  line-height: 1.2;
}
.dispo-hora strong { font-size: 1rem; color: #1a1a1a; }
.dispo-hora small { display: block; color: #999; font-size: 0.78rem; }

.dispo-boxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

/* 44px d'alçada: es prem amb el dit. */
.dispo-chip {
  min-height: 44px;
  padding: 6px 12px;
  border: 1px solid #ffd0ab;
  background: #fff6f0;
  color: #b04a00;
  border-radius: 8px;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.dispo-chip:hover { background: #ff6a00; border-color: #ff6a00; color: white; }

/* Quan s'omple el formulari des d'un forat, que es vegi on has anat a parar. */
.destacat {
  animation: parpelleig 1.2s ease-out;
}
@keyframes parpelleig {
  0% { background: #fff2e6; }
  100% { background: transparent; }
}

/* Càrrecs pendents */
.cargos-totals { margin-bottom: 18px; }
.cargo-total {
  padding: 10px 12px;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 8px;
  margin-bottom: 8px;
}
.decisio-tag { background: #b06000; }

.saldo-deute {
  margin-top: 10px;
  padding: 8px 10px;
  background: #2a2118;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #ffc879;
}

/* ============================================================
   Agenda de l'administrador
   Dues vistes de les mateixes dades. El CSS tria quina es veu.
   ============================================================ */

.agenda-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.agenda-controls button { min-height: 44px; min-width: 44px; }
.agenda-rang { flex: 1 1 auto; font-weight: 600; font-size: 0.95rem; }

/* --- Ordinador: la setmana com a mapa de densitat --- */

.agenda-setmana { display: block; }

.ag-graella {
  display: grid;
  grid-template-columns: 52px repeat(7, 1fr);
  gap: 2px;
}

.ag-cel {
  font-size: 0.75rem;
  padding: 4px 2px;
  text-align: center;
  border-radius: 3px;
  line-height: 1.2;
}

.ag-cap { background: #f4f4f4; padding: 6px 2px; }
.ag-cap strong { display: block; font-size: 0.8rem; }
.ag-cap small { color: #888; }
.ag-cap.avui { background: #ffe8d6; }

.ag-hora { color: #999; text-align: right; padding-right: 6px; }

/* El color diu com de ple està, no quin espai és. Amb vuit espais, vuit colors
   no els recorda ningú i a més no passen contrast. */
.ag-ocupacio { color: #444; min-height: 22px; }
.ag-ocupacio.n0 { background: #fafafa; }
.ag-ocupacio.n1 { background: #ffe8d6; }
.ag-ocupacio.n2 { background: #ffc79b; }
.ag-ocupacio.n3 { background: #ff9d52; color: #3d1c00; }
.ag-ocupacio.n4 { background: #e35a00; color: white; font-weight: 600; }

/* --- Mòbil: tira de dies i el dia sencer --- */



.agenda-tira {
  display: flex;
  gap: 5px;
  margin-bottom: 16px;
}

.ag-pastilla {
  flex: 1 1 0;
  min-width: 0;
  min-height: 66px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 2px;
  border: 1px solid #e0e0e0;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.ag-pastilla.triat { border-color: #ff6a00; background: #fff6f0; }
.ag-pastilla-dia { font-size: 0.7rem; color: #888; text-transform: uppercase; }
.ag-pastilla-num { font-size: 1rem; font-weight: 600; color: #1a1a1a; }

.ag-barra {
  display: block;
  width: 100%;
  height: 22px;
  background: #f0f0f0;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}
.ag-barra i {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: #ff6a00;
  display: block;
}

.ag-fila-dia {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f2f2f2;
}
.ag-fila-dia:last-child { border-bottom: none; }
.ag-fila-hora { flex: 0 0 46px; color: #999; font-size: 0.85rem; padding-top: 3px; }
.ag-fila-blocs { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 5px; }

.ag-bloc {
  padding: 7px 10px;
  background: #fff6f0;
  border-left: 3px solid #ff6a00;
  border-radius: 0 6px 6px 0;
  line-height: 1.3;
}
.ag-bloc strong { font-size: 0.88rem; display: block; }
.ag-bloc small { color: #777; font-size: 0.78rem; }

/* A partir d'aquí hi cap una setmana sencera i val la pena veure-la. Per sota,
   set columnes de dia serien blocs de vuit píxels amb el text tallat, que és
   exactament el problema que volem no repetir. */


/* Avís sota un camp: informa, no bloqueja. */
.camp-avis {
  display: block;
  margin-top: 5px;
  padding: 6px 9px;
  background: #fff4e5;
  border-radius: 6px;
  color: #b06000;
  font-size: 0.8rem;
  line-height: 1.4;
}

.booking-etiqueta {
  margin-top: 4px;
  font-size: 0.82rem;
  color: #777;
  font-style: italic;
}

/* ============================================================
   Agenda: la graella del dia
   Espais en columnes, files de la granularitat. Amb els espais en columnes,
   dues reserves que es trepitgen en el temps van a columnes diferents i no
   s'encavalquen mai. El problema d'encabir blocs dins d'una columna de dia,
   que és el que trenca la graella de l'eina que substituïm, no existeix.
   ============================================================ */

.agenda-modes {
  display: flex;
  gap: 6px;
  background: #f0f0f0;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 14px;
}
.agenda-modes .nav-btn { padding: 8px 12px; font-size: 0.88rem; }

/* Les vuit columnes hi caben a 375px si la graella s'escapa del coixí del
   panell. Sense això queden 34px per columna en comptes de 38. */
.agenda-graella-embolcall { margin: 0 -16px; padding: 0 4px; }

.agenda-graella {
  --ag-fila: 15px;
  display: grid;
  gap: 1px;
  background: #ececec;
  border: 1px solid #ececec;
  border-radius: 6px;
  overflow: hidden;
}

.agg-cel {
  background: white;
  font-size: 0.62rem;
  overflow: hidden;
  min-width: 0;
}

.agg-cap {
  background: #f7f7f7;
  font-weight: 600;
  padding: 5px 2px;
  text-align: center;
  line-height: 1.15;
  font-size: 0.6rem;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.agg-hora {
  background: #fafafa;
  color: #999;
  text-align: right;
  padding-right: 4px;
  font-size: 0.62rem;
  line-height: var(--ag-fila);
}

.agg-lliure { background: white; cursor: pointer; }
.agg-lliure:hover { background: #fff3e8; }

/* Fora de l'horari actual. Les files només hi són perquè hi ha reserves fetes
   abans de reduir l'horari: es veuen apagades i no es poden reservar. */
.agg-tancat { background: #f1f1f1; }

/* Un espai desactivat que surt perquè té reserves aquella setmana. */
.agg-cap.inactiu { background: #ececec; color: #888; font-style: italic; }
.agg-hora.fora-horari { background: #eeeeee; color: #b5b5b5; }

/* Una reserva fora de l'horari s'ha de veure, i s'ha de veure diferent: ratlles
   i vora discontínua, que no depenen només del color. */
.agg-bloc.fora-horari {
  background: repeating-linear-gradient(135deg, #b34700 0 4px, #d85c00 4px 8px);
  outline: 2px dashed #5c2400;
  outline-offset: -2px;
}
.ag-cel.fora-horari { background-image: repeating-linear-gradient(135deg, rgba(0,0,0,0.06) 0 4px, transparent 4px 8px); }
.ag-hora.fora-horari { color: #c4c4c4; }
.ag-fora-horari { color: #8a5300; }

.agenda-avis-horari {
  margin: 8px 0;
  padding: 8px 10px;
  border-left: 3px solid #b34700;
  background: #fff4e5;
  color: #6b3a00;
  font-size: 0.85rem;
}

.agg-bloc {
  background: #ff6a00;
  color: white;
  cursor: pointer;
  padding: 2px 3px;
  line-height: 1.1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
}
.agg-bloc span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agg-bloc em { font-style: normal; opacity: 0.85; font-size: 0.55rem; }

/* El detall: aquí sí que hi cap un botó de 44px. */
.agenda-detall {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #ffd0ab;
  background: #fff9f5;
  border-radius: 10px;
}
.ag-detall-cap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.ag-detall-linia { font-size: 0.9rem; line-height: 1.5; color: #444; }
.ag-detall-nota { font-size: 0.85rem; color: #777; margin: 0 0 12px; }

/* Amb més espai, files i lletra més grans i el panell recupera el coixí. */
@media (min-width: 560px) {
  .agenda-graella-embolcall { margin: 0; padding: 0; }
  .agenda-graella { --ag-fila: 20px; }
  .agg-cap { font-size: 0.75rem; padding: 7px 4px; }
  .agg-hora, .agg-cel { font-size: 0.72rem; }
  .agg-bloc em { font-size: 0.65rem; }
}

/* En horitzontal al mòbil, o a l'ordinador, la graella respira. */
@media (min-width: 760px) {
  .agenda-graella { --ag-fila: 24px; }
  .agg-cap { font-size: 0.82rem; }
}

/* A l'ordinador la graella se surt del contenidor de 640px: és la vista que el
   gestor mira cada dia i li convé tota l'amplada que hi hagi. */
@media (min-width: 1000px) {
  .agenda-graella-embolcall {
    width: min(1080px, calc(100vw - 40px));
    margin-left: 50%;
    transform: translateX(-50%);
    padding: 0;
  }
  .agenda-graella { --ag-fila: 26px; }
}
