/*
 * Hoja común de index, inici, expedientes, ficha, calendario y gestiones.
 * Diseño móvil primero; las variantes de escritorio e impresión se conservan
 * en su posición de cascada. Los bloques de ajuste posteriores son intencionales.
 * Cargada desde index.php y includes/header.php.
 */

/* ===== Variables de diseño y estilos base ===== */
:root {
  --navy: #14324f;
  --navy-2: #1b4a73;
  --blue: #1d6aa5;
  --blue-soft: #e7f1f8;
  --blue-line: #c5d9e8;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --text: #1a2330;
  --muted: #5b6b7a;
  --line: #e2e7ec;
  --danger: #b42318;
  --warn: #b54708;
  --ok: #067647;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 50, 79, .06), 0 8px 24px rgba(20, 50, 79, .06);
  --header-h: 56px;
  --nav-h: 64px;
  --font: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
}

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

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button, input, textarea, select { font: inherit; }

/* ===== Utilidades y accesibilidad ===== */
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* ===== Estructura común y cabecera ===== */
.app {
  min-height: 100dvh;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}

.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--navy);
  color: #fff;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}

.topbar__brand:hover { text-decoration: none; color: #fff; }

.topbar__mark {
  width: 26px; height: 26px;
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
}

.topbar__title {
  flex: 1;
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.icon-btn:hover { background: rgba(255,255,255,.1); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: #e11d48;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.badge--no-llegida { background: var(--navy); }

.icon-btn { position: relative; }
.icon-btn .badge {
  position: absolute;
  top: 4px; right: 4px;
}

/* ===== Navegación inferior móvil ===== */
.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.bottomnav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-decoration: none;
}

.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a.is-active { color: var(--navy); }
.bottomnav .nav-badge {
  position: relative;
}
.bottomnav .nav-badges {
  position: absolute;
  top: -4px;
  right: calc(50% - 22px);
  display: flex;
  align-items: center;
  gap: 3px;
}
.bottomnav .nav-badge .nav-badges .badge {
  position: static;
}

/* ===== Contenedor y encabezado de página ===== */
.page { padding: 16px; max-width: 980px; margin: 0 auto; }

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

.page-head h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.page-head--accion h1 {
  min-width: 0;
}

.page-head--accion .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.page-head__actions {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.page-head--accion .btn--primary:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

@media (max-width: 380px) {
  .page-head--accion { gap: 8px; flex-wrap: wrap; }
  .page-head--accion h1 { font-size: 22px; }
  .page-head--accion .btn {
    height: 40px;
    padding: 0 10px;
  }
}

/* ===== Buscador y filtros del listado ===== */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  height: 44px;
  margin-bottom: 14px;
}

.search input {
  border: 0;
  outline: 0;
  width: 100%;
  background: transparent;
  font-size: 16px; /* evita zoom iOS */
}

.search svg { color: var(--muted); flex: 0 0 auto; }

.search-block { margin-bottom: 14px; }
.search-block .search { margin-bottom: 8px; }
.search-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 4px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}
.search-opt input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}
.case-card.is-closed { background: #f3f5f7; }
.pill.is-closed { background: #eef1f4; color: #5b6b7a; }

/* ===== Pestañas ===== */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.tabs a, .tabs button {
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font-weight: 650;
  font-size: 14px;
  padding: 10px 12px;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.tabs a.is-active, .tabs button.is-active {
  color: var(--navy);
  border-bottom-color: var(--blue);
}

/* ===== Tarjetas de expedientes y alertas ===== */
.case-list { display: flex; flex-direction: column; gap: 10px; }

.case-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: none;
  color: inherit;
  text-decoration: none;
}

.case-card:hover { text-decoration: none; border-color: var(--blue-line); }

.case-card.is-alert {
  border-color: #ead2a2;
  background: #fff8ea;
  box-shadow: none;
}

.case-card.is-alert:hover { border-color: #d4a017; }

.case-card.is-no-llegida,
.case-card.is-no-llegida.is-alert,
.case-card.is-no-llegida.is-closed {
  border-color: #c5d4e4;
  background: #f4f8fb;
  box-shadow: none;
}
.case-card.is-no-llegida:hover { border-color: var(--navy); }
.case-card__no-llegida {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}
.case-card__no-llegida::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: #fff;
  flex: 0 0 auto;
}

.case-card__alerts {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-top: 10px;
}

.case-card__alert {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  background: #fff4e5;
  color: var(--warn);
}

.case-card__alert.is-judici {
  background: #fde8e6;
  color: var(--danger);
}

.case-card__alert.is-tasca {
  background: var(--blue-soft);
  color: var(--navy-2);
}

.case-card__alert.is-termini {
  background: #fff4e5;
  color: var(--warn);
}

.case-card__alert-type {
  flex: 0 0 auto;
  white-space: nowrap;
}

.case-card__alert-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.case-card__alert-date {
  flex: 0 0 auto;
  font-size: 12px;
  opacity: 0.8;
  font-weight: 650;
  white-space: nowrap;
}

.case-card__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.xinxeta {
  display: inline;
  font-size: 1em;
  line-height: inherit;
  vertical-align: baseline;
  white-space: nowrap;
  color: currentColor;
  background: none;
  box-shadow: none;
  outline: none;
}
.xinxeta svg {
  display: inline-block;
  width: 1em;
  height: 1em;
  overflow: hidden;
  vertical-align: -0.15em;
  box-shadow: none;
  outline: none;
}

.case-card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--navy-2);
  line-height: 1.3;
}

.case-card__client {
  margin: 2px 0 0;
  font-weight: 650;
}

.case-card__meta {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.case-card__date {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.pill {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 650;
  background: var(--blue-soft);
  color: var(--navy-2);
}

.pill.is-soon { background: #fff4e5; color: var(--warn); }
.pill.is-overdue { background: #fde8e6; color: var(--danger); }
.pill.is-done { background: #e8f6ee; color: var(--ok); }

/* ===== Resumen de la ficha ===== */
.case-hero {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}

.case-hero h1 {
  margin: 0;
  font-size: 20px;
  color: var(--navy-2);
}

.case-hero .sub { margin: 4px 0 0; font-weight: 650; }
.case-hero .meta { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

.stat-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.stat {
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}
.stat b { color: var(--text); font-weight: 700; }

/* ===== Gestiones: listado y alta rápida ===== */
.glist {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.glist__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.glist__print {
  appearance: none;
  border: 0;
  background: none;
  color: var(--blue);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
}
.glist__print:hover { text-decoration: underline; }

.glist__head,
.grow {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 74px 42px 52px 46px;
  gap: 8px;
  align-items: center;
  padding: 5px 10px;
}

.glist__head {
  font-size: 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-top: 6px;
  padding-bottom: 6px;
}
.glist__head .num { text-align: right; }

.glist__add {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
}

.glist__plus,
.glist__minus {
  width: 22px;
  height: 22px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  display: grid;
  place-items: center;
}
.glist__plus:hover,
.glist__minus:hover { border-color: var(--blue); color: var(--blue); }

.glist__minus { display: none; }

.glist__add textarea {
  width: 100%;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 10px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  overflow: hidden;
  color: var(--text);
}
.glist__add textarea:focus {
  outline: 2px solid var(--blue-line);
  border-color: var(--blue);
}

.glist__add.is-open {
  grid-template-columns: 32px minmax(0, 1fr) 22px;
  align-items: start;
  padding-top: 8px;
  padding-bottom: 10px;
}
.glist__add.is-open .glist__plus,
.glist__add.is-open .glist__minus { margin-top: 6px; }
.glist__add.is-open .glist__minus { display: grid; }

.glist__add.is-open textarea {
  height: 108px;
  border-radius: 6px;
  padding: 8px 10px;
  overflow: auto;
}

.glist__extra {
  display: none;
  grid-column: 2;
  grid-template-columns: minmax(92px, 0.9fr) 130px minmax(120px, 1.4fr) auto auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.glist__add.is-open .glist__extra {
  display: grid;
}
.glist__field {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.glist__field--inline span {
  flex: 0 0 auto;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.glist__extra select,
.glist__extra input,
.glist__cal select,
.glist__cal input,
.grow__extra select,
.grow__extra input,
.grow__cal select,
.grow__cal input {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 8px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  min-width: 0;
}
.glist__extra input[name="temps"] { width: 88px; }
.glist__extra input[name="import"] { width: 64px; text-align: right; }
.glist__extra select:focus,
.glist__extra input:focus,
.glist__cal select:focus,
.glist__cal input:focus,
.grow__extra select:focus,
.grow__extra input:focus,
.grow__cal select:focus,
.grow__cal input:focus {
  outline: 2px solid var(--blue-line);
  border-color: var(--blue);
}
.glist__cal {
  display: none;
  grid-column: 2;
  min-width: 0;
  padding-top: 4px;
}
.glist__add.is-open .glist__cal.is-on {
  display: block;
}
.glist__cal-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.glist__cal-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}
.glist__cal-fields {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
  min-width: 0;
}
.glist__cal input[name="inici"] { width: 88px; }
.glist__cal select[name="duracio"] { width: auto; min-width: 118px; }
.glist__empty {
  margin: 0;
  padding: 14px 12px;
  color: var(--muted);
  font-size: 13px;
}

.grow {
  border-bottom: 1px solid #eef1f4;
  min-height: 40px;
  color: inherit;
  text-decoration: none;
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.grow:last-child { border-bottom: 0; }
.grow:hover { background: #f7fafc; text-decoration: none; }

/* ===== Iconos y variantes de los tipos de gestión ===== */
.gicon {
  position: relative;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--navy);
  background: #eef1f4;
  display: grid;
  place-items: center;
}
.gicon svg { width: 16px; height: 16px; display: block; }
.gicon--tasca,
.gicon--escrit,
.gicon--nota,
.gicon--fi_termini_completat,
.gicon--burofax,
.gicon--pagament,
.gicon--document,
.gicon--recordatori { background: #e7f1f8; color: var(--navy); }
.gicon--judici,
.gicon--fi_termini,
.gicon--nota_important,
.gicon--tasca_pendent,
.gicon--pagament_pendent { background: #f6e59b; color: #8a6914; }
.gicon--cita,
.gicon--trucada,
.gicon--mail { background: #e7f1f8; color: var(--blue); }
.gicon--judici_suspes { background: #eef1f4; color: #5b6b7a; }
.gicon--diner {
  background: #e7f6ee;
  color: #067647;
}
.gicon__bang {
  position: absolute;
  right: -3px;
  top: -3px;
  width: 12px;
  height: 12px;
  border-radius: 99px;
  background: #e11d48;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: grid;
  place-items: center;
  line-height: 1;
}
.gicon__bang--soft {
  background: #f3d56e;
  color: #7a5a0c;
}
.gicon__arrow {
  position: absolute;
  right: -4px;
  bottom: -3px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: var(--blue);
  background: #fff;
  border-radius: 99px;
}

.grow__title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.grow.is-no-llegida {
  background: #fff8ee;
  box-shadow: inset 3px 0 0 #8a4b08;
}
.grow__llegida-mark {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  min-width: 0;
}
.grow__no-llegida {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 4px;
  margin: 0 0 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fff4e5;
  color: #6b3a06;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}
.grow__no-llegida .grow__llegida-btn {
  width: auto;
  height: auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  line-height: 1;
}
.grow__llegida {
  margin: 0;
}
.grow__llegida-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #e2c9a8;
  border-radius: 8px;
  background: #fff;
  color: #6b3a06;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
}
.grow__llegida-btn:hover { background: #fff4e5; }
.grow__no-llegida .grow__llegida-btn:hover { background: transparent; opacity: 0.65; }
.grow__llegida-btn:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}
.grow__llegida-btn:disabled { opacity: 0.6; cursor: default; }
.grow__exp {
  margin: 1px 0 0;
  font-size: 12px;
  color: var(--muted);
}
.grow__who {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}
.grow__avatar {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #d5dde4;
  color: #3d4d5c;
  font-size: 8px;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.grow__date,
.grow__time,
.grow__imp {
  font-size: 12px;
  color: #3d4d5c;
  text-align: right;
  white-space: nowrap;
}
.grow__date {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.grow__clock {
  font-size: 11px;
  line-height: 1.2;
  font-weight: 400;
  color: var(--muted);
}
.grow__imp.is-set { color: #b54708; font-weight: 650; }
.grow__del { display: contents; }
.grow__acts {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 0;
  flex: 0 0 auto;
}
.grow__acts button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #8b97a3;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.grow__acts button:hover { color: var(--navy); }
.grow__acts button:focus-visible,
.grow__llegida-btn:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}
.grow__acts svg { width: 15px; height: 15px; }

@media (max-width: 640px) {
  .glist__head,
  .grow {
    grid-template-columns: 24px minmax(0, 1fr) auto 40px;
    gap: 6px;
  }
  .col-tmps,
  .col-imp { display: none; }
}

/* ===== Editor de gestiones en la fila ===== */
.grow.is-editing {
  grid-template-columns: 32px minmax(0, 1fr) 100px;
  align-items: start;
  padding-top: 8px;
  padding-bottom: 10px;
}
.grow.is-editing .grow__who-line { display: contents; }
.grow.is-editing .grow__top,
.grow.is-editing .grow__who,
.grow.is-editing .grow__date,
.grow.is-editing .grow__time,
.grow.is-editing .grow__imp,
.grow.is-editing .grow__llegida,
.grow.is-editing .grow__no-llegida {
  display: none;
}
.grow.is-editing .grow__main,
.grow.is-editing .grow__line {
  display: contents;
}
.grow.is-editing > .grow__edit {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}
.grow.is-editing .grow__acts {
  grid-column: 3;
  grid-row: 1;
  align-self: start;
}
.grow.is-editing .gicon,
.grow.is-editing .grow__del { display: contents; }
.grow__acts {
  margin-top: 0;
}
.grow__edit { display: none; min-width: 0; }
.grow.is-editing .grow__edit { display: block; }
.grow__edit textarea {
  width: 100%;
  height: 108px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  resize: vertical;
  overflow: auto;
  color: var(--text);
  box-sizing: border-box;
}
.grow__edit textarea:focus {
  outline: 2px solid var(--blue-line);
  border-color: var(--blue);
}
.grow__extra {
  display: grid;
  grid-template-columns: minmax(92px, 0.85fr) 130px minmax(120px, 1.3fr) auto auto minmax(128px, 0.9fr);
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  min-width: 0;
}
.grow__extra select[name="xinxeta"] { min-width: 0; }
.grow__cal {
  display: none;
  margin-top: 8px;
  min-width: 0;
}
.grow__cal.is-on { display: block; }
.grow__cal input[name="inici"] { width: 88px; }
.grow__cal select[name="duracio"] { width: auto; min-width: 118px; }
.grow__meta {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
.grow__meta p { margin: 0; }
.grow__acts .grow__save-btn,
.grow__acts .grow__cancel-btn { display: none; }
.grow.is-editing .grow__edit-btn { display: none; }
.grow.is-editing .grow__acts .grow__save-btn,
.grow.is-editing .grow__acts .grow__cancel-btn { display: grid; }
@media print {
  .topbar, .sidenav, .bottomnav, .glist__add, .glist__print, .grow__acts, .grow__edit { display: none !important; }
  .grow.is-editing .grow__main,
  .grow.is-editing .grow__date,
  .grow.is-editing .grow__time,
  .grow.is-editing .grow__imp { display: initial !important; }
  .app { padding: 0; }
  .glist { border: 0; }
}

/* ===== Botones compartidos ===== */
.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:hover { background: var(--navy-2); color: #fff; }
.btn--ghost {
  background: transparent;
  color: var(--navy-2);
  border: 1px solid var(--line);
}

/* ===== Calendario: agenda y mes ===== */
.seg {
  display: flex;
  background: #e8edf1;
  border-radius: 10px;
  padding: 3px;
}

.seg button {
  appearance: none;
  border: 0;
  background: transparent;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  font-weight: 650;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.seg button.is-active { background: #fff; color: var(--navy); }

.agenda { display: flex; flex-direction: column; gap: 22px; }
.agenda.is-hidden { display: none; }

.agenda-group { display: flex; flex-direction: column; gap: 8px; }
.agenda-group__items { display: flex; flex-direction: column; gap: 8px; }

.agenda-day {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
}
.agenda-day__badge {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  box-shadow: var(--shadow);
  flex: 0 0 auto;
}
.agenda-day__num {
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  letter-spacing: -0.03em;
}
.agenda-day__mon {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.agenda-day__txt { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.agenda-day__name { font-size: 16px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.agenda-day__meta { font-size: 13px; color: var(--muted); }

.agenda-day.is-today .agenda-day__badge {
  background: var(--navy);
  border-color: var(--navy);
}
.agenda-day.is-today .agenda-day__num { color: #fff; }
.agenda-day.is-today .agenda-day__mon { color: rgba(255,255,255,.72); }
.agenda-day.is-today .agenda-day__name { color: var(--blue); }
.agenda-group.is-future .agenda-day__badge { border-color: var(--blue-line); background: var(--blue-soft); }

.event {
  --event-accent: var(--blue);
  display: grid;
  grid-template-columns: 58px 32px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px 12px 12px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.event::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--event-accent);
}
.event:hover { text-decoration: none; border-color: var(--blue-line); }
.event .gicon { margin-top: 2px; }

.event__time {
  font-weight: 700;
  color: var(--navy);
  font-size: 14px;
  line-height: 1.25;
  padding-top: 4px;
  text-align: right;
}
.event__time.is-allday {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .03em;
  padding-top: 5px;
}
.event__body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.event__title {
  font-weight: 700;
  color: var(--navy-2);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.event__sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.event--cita { --event-accent: var(--navy-2); }
.event--judici,
.event--judici_suspes { --event-accent: var(--danger); }
.event--fi_termini,
.event--fi_termini_completat { --event-accent: var(--warn); }
.event--tasca { --event-accent: var(--blue); }
.event--pagament,
.event--diner { --event-accent: var(--ok); }
.event--trucada { --event-accent: #0e7490; }
.event--escrit { --event-accent: #5b4b8a; }
.event--burofax,
.event--document,
.event--mail,
.event--correu { --event-accent: var(--blue); }
.event--nota,
.event--recordatori { --event-accent: #64748b; }

.month {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.month.is-hidden { display: none; }
.month__nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px 10px;
}
.month__title {
  margin: 0;
  padding: 0;
  flex: 1;
  text-align: center;
  font-size: 20px;
  color: var(--navy);
  text-transform: capitalize;
}
.month__nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--navy);
  text-decoration: none;
  border: 1px solid var(--line);
  background: #fff;
  flex: 0 0 auto;
}
.month__nav-btn:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
  text-decoration: none;
  color: var(--navy);
}
.month__cell.is-other .month__num,
.month__cell.is-other .month__ev-title { opacity: 0.45; }

.month__weekdays,
.month__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.month__weekdays span {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  padding: 10px 0;
}

.month__cell {
  min-width: 0;
  min-height: 112px;
  border-top: 1px solid var(--line);
  padding: 7px;
  font-size: 13px;
  overflow: visible;
}

.month__cell.is-today { background: var(--blue-soft); }
.month__num { font-weight: 700; font-size: 14px; color: var(--muted); margin: 0 2px 2px; }

.month__events {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
  min-width: 0;
}

.month__ev {
  position: relative;
  min-width: 0;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
body.is-month-dragging {
  cursor: grabbing;
  user-select: none;
}
body.is-month-dragging .month__tip {
  display: none !important;
}
.month__ev.is-dragging {
  opacity: 0.45;
  cursor: grabbing;
}
.month__ev.is-dragging .month__tip {
  display: none !important;
}
.month__cell.is-dragover {
  outline: 2px dashed var(--blue);
  outline-offset: -3px;
  background: var(--blue-soft);
}

.month__ev-title {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  overflow: hidden;
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.4;
  padding: 3px 6px;
  border-radius: 5px;
}
.month__ev-title .gicon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex: 0 0 auto;
}
.month__ev-title .gicon svg {
  width: 12px;
  height: 12px;
}
.month__ev-title .gicon__bang {
  width: 9px;
  height: 9px;
  font-size: 7px;
  right: -2px;
  top: -2px;
}
.month__ev-title .gicon__arrow {
  font-size: 8px;
  right: -3px;
  bottom: -2px;
}
.month__ev-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.month__ev-title:hover {
  background: var(--blue-soft);
  color: var(--navy);
  text-decoration: none;
}

.month__tip {
  display: none;
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  width: max-content;
  max-width: 260px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.14);
  color: var(--navy);
  white-space: normal;
  pointer-events: none;
}

.month__ev:hover .month__tip,
.month__ev:focus-within .month__tip {
  display: block;
}

.month__cell:nth-child(7n) .month__tip,
.month__cell:nth-child(7n-1) .month__tip {
  left: auto;
  right: 0;
}

.month__cell:nth-last-child(-n+7) .month__tip {
  top: auto;
  bottom: calc(100% + 6px);
}

.month__tip-exp {
  font-weight: 700;
  font-size: 13px;
  color: var(--navy);
}

.month__tip-titol {
  font-size: 13px;
  margin-top: 3px;
  line-height: 1.35;
}

.month__tip-client {
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.month__tip-meta {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.month__tip-gestio {
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.35;
}

/* ===== Acceso: formulario y fotografía ===== */
body.page-login {
  background: var(--navy);
  min-height: 100dvh;
}

body.page-login.has-photo {
  background-color: #0c1826;
  background-image:
    linear-gradient(180deg, rgba(12, 24, 38, .12) 0%, rgba(12, 24, 38, .28) 100%),
    url("../img/login-bg.jpg?v=2");
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
}

.login-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 28px 22px 24px;
  box-shadow: 0 16px 50px rgba(0,0,0,.35);
}

.login-card h1 {
  margin: 8px 0 4px;
  font-size: 22px;
}

.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }

.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 4px;
}

.field input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  background: #f7f9fb;
}

.field input:focus {
  outline: 2px solid var(--blue-line);
  border-color: var(--blue);
  background: #fff;
}

.login-card .btn { width: 100%; margin-top: 8px; }
.login-foot { margin-top: 14px; text-align: center; font-size: 13px; }

/* ===== Variantes de escritorio y navegación lateral ===== */
@media (min-width: 860px) {
  :root { --header-h: 60px; }

  .bottomnav { display: none; }

  .app {
    padding-bottom: 24px;
    padding-left: 220px;
  }

  .sidenav {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    padding: 16px 10px;
    gap: 4px;
  }

  .sidenav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--text);
    font-weight: 650;
    text-decoration: none;
  }
  .sidenav a:hover { background: var(--bg); text-decoration: none; }
  .sidenav a.is-active { background: var(--blue-soft); color: var(--navy); }
  .sidenav a .nav-badges {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .sidenav a .nav-badges .badge { margin-left: 0; }

  .page { padding: 24px; }
}

@media (max-width: 859px) {
  .sidenav { display: none; }
  #agenda.is-hidden { display: none; }
  #mes.is-hidden,
  #mes.is-desktop-only,
  .month.is-desktop-only { display: none; }
}

/* ===== Formularios de ficha y alta de expediente ===== */
.fitxa {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
}
.fitxa__grid {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 8px 14px;
  align-items: center;
}
.fitxa__grid label {
  color: var(--text);
  font-size: 14px;
}
.fitxa__grid input[type="text"],
.fitxa__grid input[type="date"],
.fitxa__grid input[type="time"],
.fitxa__grid input[type="number"],
.fitxa__grid select,
.fitxa__grid textarea {
  width: 100%;
  min-width: 0;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 8px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}
.fitxa__grid textarea {
  height: 76px;
  resize: vertical;
  align-self: start;
  padding-top: 6px;
}
.fitxa__grid label[for="fitxa-notes"] {
  align-self: start;
  padding-top: 8px;
}
.fitxa__date {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.fitxa__exp {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.fitxa__exp input {
  flex: 1 1 0;
  min-width: 0;
}
.fitxa__exp span {
  flex: 0 0 auto;
  color: var(--muted);
}
.fitxa__lock {
  width: 28px;
  height: 28px;
  border: 0;
  background: transparent;
  color: #8b97a3;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  flex-shrink: 0;
}
.fitxa__lock svg { width: 16px; height: 16px; display: block; }
.fitxa__lock:hover,
.fitxa__lock.is-open { color: var(--navy); }
.fitxa__meta {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 2px 14px;
  font-size: 12px;
  color: var(--muted);
}
.fitxa__actions {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.fitxa__error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fde8e6;
  color: var(--danger);
  font-size: 14px;
  font-weight: 650;
}
.fitxa__ok {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #e7f6ee;
  color: #1a6b3c;
  font-size: 14px;
  font-weight: 650;
}
.fitxa__ok a { color: inherit; text-decoration: underline; }
.fitxa__grid label[for="nova-gestio-titol"] {
  align-self: start;
  padding-top: 8px;
}
@media print {
  .fitxa__lock,
  .fitxa__actions { display: none !important; }
}
/* ===== Edición de gestiones en móvil ===== */
@media (max-width: 640px) {
  .grow.is-editing {
    grid-template-columns: 28px minmax(0, 1fr);
  }
  .grow.is-editing .grow__acts {
    grid-column: 1 / -1;
    justify-content: flex-end;
    margin-top: 8px;
  }
  .grow.is-editing .grow__extra {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .grow.is-editing .grow__extra .glist__field:nth-child(3),
  .grow.is-editing .grow__extra .glist__field:nth-child(6) {
    grid-column: 1 / -1;
  }
  .grow.is-editing .grow__extra input[name="temps"],
  .grow.is-editing .grow__extra input[name="import"],
  .grow.is-editing .grow__extra input[type="date"],
  .grow.is-editing .grow__extra input[type="time"],
  .grow.is-editing .grow__extra select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .grow.is-editing .grow__cal-fields {
    flex-wrap: wrap;
    white-space: normal;
  }
  .grow.is-editing .grow__cal input[name="inici"],
  .grow.is-editing .grow__cal select[name="duracio"] {
    width: auto;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 120px;
  }

  .glist__add.is-open {
    grid-template-columns: 28px minmax(0, 1fr);
  }
  .glist__add.is-open .glist__minus {
    grid-column: 1 / -1;
    justify-self: end;
    margin-top: 8px;
  }
  .glist__add.is-open .glist__extra {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .glist__add.is-open .glist__extra .glist__field:nth-child(3) {
    grid-column: 1 / -1;
  }
  .glist__add.is-open .glist__extra input[name="temps"],
  .glist__add.is-open .glist__extra input[name="import"],
  .glist__add.is-open .glist__extra input[type="date"],
  .glist__add.is-open .glist__extra input[type="time"],
  .glist__add.is-open .glist__extra select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .glist__add.is-open .glist__cal-fields {
    flex-wrap: wrap;
    white-space: normal;
  }
  .glist__add.is-open .glist__cal input[name="inici"],
  .glist__add.is-open .glist__cal select[name="duracio"] {
    width: auto;
    max-width: 100%;
    min-width: 0;
    flex: 1 1 120px;
  }
}
/* ===== Inicio: indicadores y próximas gestiones ===== */
.page-head__sub {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--muted);
  font-weight: 400;
}
.dash-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.dash-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
a.dash-card:hover {
  text-decoration: none;
  border-color: var(--blue-line);
}
.dash-card__label {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.3;
}
.dash-card__value {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.dash-card__hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}
.dash-card.is-warn .dash-card__value { color: var(--warn); }
.dash-card.is-alert .dash-card__value { color: var(--danger); }
.dash-cmp--up { color: var(--ok); font-weight: 650; }
.dash-cmp--down { color: var(--warn); font-weight: 650; }
.dash-cmp--eq { color: var(--muted); }
.dash-section {
  margin-top: 28px;
}
.dash-section h2 {
  margin: 0 0 10px;
  font-size: 16px;
  color: var(--navy);
}
.dash-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dash-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
}
.dash-item:hover {
  text-decoration: none;
  border-color: var(--blue-line);
}

.dash-item.is-overdue { border-color: #f0c2bc; background: #fff8f7; }
.dash-item__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dash-item__title {
  font-weight: 700;
  color: var(--navy-2);
  font-size: 15px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-item__meta {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dash-item__date {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.dash-more { margin: 8px 0 0; }

@media (min-width: 860px) {
  .dash-grid { grid-template-columns: repeat(4, 1fr); }
}
/* ===== Gestiones: ajustes finales de densidad (orden de cascada) ===== */
.glist__meta {
  padding: 10px 16px;
  font-size: 14px;
}
.glist__print { font-size: 14px; }
.glist__head,
.grow {
  grid-template-columns: 36px minmax(0, 1fr) 88px 48px 60px 52px;
  gap: 12px;
  padding: 11px 16px;
}
.glist__head {
  font-size: 13px;
  padding-top: 10px;
  padding-bottom: 10px;
}
.glist__add {
  gap: 10px;
  padding: 10px 16px;
}
.grow {
  border-top: 1px solid var(--line);
}
.grow:hover,
.grow:focus-within { background: #f7fafc; }
.grow:focus { outline: none; }
.grow:focus-visible {
  outline: 2px solid var(--blue-line);
  outline-offset: -2px;
}
.grow.is-editing { background: #fff; }
.grow__title {
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.grow__exp {
  font-size: 13px;
  margin-top: 3px;
}
.grow__who {
  font-size: 12px;
  gap: 6px;
  margin-top: 4px;
}
.grow__date,
.grow__time,
.grow__imp {
  font-size: 13.5px;
}
.glist .gicon {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}
.glist .gicon svg {
  width: 18px;
  height: 18px;
}
.glist__empty {
  padding: 20px 16px;
  font-size: 14px;
}
.grow__meta {
  font-size: 13px;
}
.grow.is-editing {
  padding-top: 12px;
  padding-bottom: 14px;
}
.grow__name {
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (min-width: 641px) {
  .grow:not(.is-editing) {
    column-gap: 12px;
    row-gap: 0;
  }
  .grow:not(.is-editing) > .gicon {
    grid-row: 1 / span 2;
    align-self: center;
  }
  .grow:not(.is-editing) > .grow__main {
    display: contents;
  }
  .grow:not(.is-editing) .grow__top {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .grow:not(.is-editing) .grow__line {
    display: contents;
  }
  .grow:not(.is-editing) .grow__who-line {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin-top: 4px;
  }
  .grow:not(.is-editing) .grow__who-line .grow__who {
    flex: 0 1 auto;
    min-width: 0;
    margin: 0;
  }
  .grow:not(.is-editing) .grow__acts {
    gap: 0;
    margin-right: -6px;
  }
  .grow:not(.is-editing) .grow__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .grow:not(.is-editing) .grow__date {
    grid-column: 3;
    grid-row: 1 / span 2;
    align-self: center;
  }
  .grow:not(.is-editing) .grow__time {
    grid-column: 4;
    grid-row: 1 / span 2;
    align-self: center;
  }
  .grow:not(.is-editing) .grow__imp {
    grid-column: 5;
    grid-row: 1 / span 2;
    align-self: center;
  }
}
@media (min-width: 641px) and (hover: hover) {
  .grow:not(.is-editing) .grow__acts {
    opacity: 0;
    visibility: hidden;
  }
  .grow:not(.is-editing):hover .grow__acts,
  .grow:not(.is-editing):focus-within .grow__acts {
    opacity: 1;
    visibility: visible;
  }
}
@media (max-width: 640px) {
  .glist__head {
    grid-template-columns: 32px minmax(0, 1fr);
  }
  .glist__head .num,
  .glist__head span:last-child { display: none; }
  .grow:not(.is-editing) {
    grid-template-columns: 32px minmax(0, 1fr);
    align-items: start;
    gap: 8px;
    padding: 10px 12px;
  }
  .grow:not(.is-editing) > .gicon {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    margin-top: 2px;
  }
  .grow:not(.is-editing) > .grow__main {
    grid-column: 2;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  .grow:not(.is-editing) .grow__line {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px 8px;
    min-width: 0;
    margin-top: 4px;
  }
  .grow:not(.is-editing) .grow__who-line {
    display: contents;
  }
  .grow:not(.is-editing) .grow__who { order: 1; }
  .grow:not(.is-editing) .grow__llegida { order: 3; }
  .grow:not(.is-editing) .grow__date { order: 4; }
  .grow:not(.is-editing) .grow__acts { order: 5; }
  .grow:not(.is-editing) .grow__who {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
  }
  .grow:not(.is-editing) .grow__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .grow:not(.is-editing) .grow__date,
  .grow:not(.is-editing) .grow__llegida,
  .grow:not(.is-editing) .grow__acts {
    flex: 0 0 auto;
    margin-top: 0;
  }
  .grow:not(.is-editing) .grow__acts {
    justify-content: flex-start;
  }
  .grow.is-editing .grow__acts {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-end;
    margin-top: 8px;
  }
}
/* Escritorio: Data, Temps e Import al ancho del dato; el título ocupa el resto. */
@media (min-width: 641px) {
  .glist {
    display: grid;
    /* 52px = 36px de la columna del icono + 16px de padding que el subgrid solapa. */
    grid-template-columns: 52px minmax(0, 1fr) max-content max-content max-content;
    column-gap: 12px;
    row-gap: 0;
  }
  .glist__head > span:last-child { display: none; }
  .glist > .glist__head,
  .glist > .glist__add,
  .glist > .glist__empty,
  .glist > .grow {
    grid-column: 1 / -1;
  }
  .glist > .glist__head,
  .glist > .grow:not(.is-editing) {
    grid-template-columns: subgrid;
    column-gap: 12px;
  }
  .glist__head .num {
    white-space: nowrap;
  }
}
/* ===== Intervinientes del expediente ===== */
.interv {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.interv__add .fitxa__error {
  margin: 0 0 12px;
}
.interv__empty {
  margin: 0;
  padding: 18px 16px;
  color: var(--muted);
  font-size: 14px;
}
.interv__head,
.interv__row {
  display: grid;
  grid-template-columns: minmax(140px, 0.9fr) minmax(0, 1.3fr) minmax(140px, 0.9fr) minmax(100px, 0.7fr) 78px;
  gap: 12px;
  padding: 12px 16px;
  align-items: start;
}
.interv__head {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f7fafc;
}
.interv__row {
  border-top: 1px solid var(--line);
  font-size: 14.5px;
}
.interv__row:hover {
  background: #f7fafc;
}
.interv__tipus {
  font-weight: 650;
  color: var(--navy);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.interv__nom {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.interv__org {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}
.interv__contact {
  font-size: 13.5px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 2px;
  word-break: break-word;
}
.interv__contact a {
  color: var(--blue);
  text-decoration: none;
}
.interv__contact a:hover {
  text-decoration: underline;
}
.interv__notes {
  font-size: 13.5px;
  color: var(--muted);
  word-break: break-word;
}
.interv__view {
  display: contents;
}
.interv__edit {
  display: none;
  grid-column: 1 / -2;
  min-width: 0;
}
.interv__row.is-editing .interv__view {
  display: none;
}
.interv__row.is-editing .interv__edit {
  display: block;
}
.interv__acts {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 0;
}
.interv__acts button {
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: #8b97a3;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}
.interv__acts button:hover { color: var(--navy); }
.interv__acts svg { width: 14px; height: 14px; }
.interv__del { display: contents; }
.interv__acts .interv__save-btn,
.interv__acts .interv__cancel-btn { display: none; }
.interv__row.is-editing .interv__edit-btn { display: none; }
.interv__row.is-editing .interv__acts .interv__save-btn,
.interv__row.is-editing .interv__acts .interv__cancel-btn { display: grid; }
.interv__client {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--navy-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.interv__add {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px 18px;
}
.interv__add-title {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--navy);
}
.interv__nou {
  margin-top: 10px;
}
.interv__check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}
.interv__check input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}
.interv__actions {
  margin-top: 14px;
}
@media (max-width: 640px) {
  .interv__head {
    display: none;
  }
  .interv__row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px;
    padding: 14px;
  }
  .interv__view {
    display: flex;
    flex-direction: column;
    gap: 6px;
    grid-column: 1;
  }
  .interv__acts {
    grid-column: 2;
    grid-row: 1;
  }
  .interv__edit {
    grid-column: 1 / -1;
  }
  .interv__row.is-editing .interv__view {
    display: none;
  }
}
@media print {
  .interv__acts,
  .interv__edit { display: none !important; }
}
/* ===== Archivos: rutas y botones ===== */
.arxius {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.arxius__line {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-top: 1px solid var(--line);
}
.arxius__line:first-child {
  border-top: none;
}
.arxius__line code {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 14.5px;
  color: var(--navy);
  word-break: break-all;
  user-select: all;
}
.arxius__copy,
.arxius__open {
  appearance: none;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--navy);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.arxius__copy:hover,
.arxius__open:hover {
  background: #eef4f8;
}
.arxius__copy svg {
  width: 20px;
  height: 20px;
}
.arxius__open svg {
  width: 22px;
  height: 22px;
}
.arxius__open:disabled {
  opacity: 0.55;
  cursor: default;
}
.arxius__copy.is-copied {
  color: #2f7d4a;
}