:root {
  /* —— Protocolo 30cm —— */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;

  --text-xs: 12px;
  --text-sm: 14px;
  --text-body: 16px;
  --text-title: 24px;
  --text-hero: 40px;
  --weight-body: 400;
  --weight-hero: 700;

  /* 5 grises + 1 acento (acción principal) */
  --ink: #1a1f1d;
  --muted: #5e6863;
  --line: #d8dfda;
  --paper: #f4f6f4;
  --page-bg: #e8eee9;
  --panel: #ffffff;
  --accent: #0f6b5c;
  --accent-deep: #0a4a40;
  --brand: var(--accent);
  --brand-deep: var(--accent-deep);

  /* Semánticos de datos (no chrome / no CTA) */
  --cd: #0f6b5c;
  --star: #8a6a12;
  --empty: #8a9690;
  --danger: #8f3a3a;
  --warn: #8a6a2b;
  --debt: #a85a2e;
  --shadow: 0 16px 40px rgba(26, 31, 29, 0.12);
  --radius: 16px;
  --font: "Montserrat", "Segoe UI", sans-serif;
  --display: "Montserrat", "Segoe UI", sans-serif;
  --col-surname: 6.6rem;
  --col-given: 4.5rem;
  --col-exp: 3.25rem;
  --col-notes: 1.85rem;
  --col-sticky: calc(var(--col-surname) + var(--given-col, var(--col-given)) + var(--col-exp));
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  font-size: var(--text-body);
  font-weight: var(--weight-body);
  color: var(--ink);
  background: var(--page-bg);
  padding: var(--space-3) clamp(var(--space-3), 2vw, var(--space-5)) var(--space-5);
}

.site-footer {
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-1) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  line-height: 1.4;
  color: var(--empty);
  letter-spacing: 0.01em;
  min-height: 2rem;
}

.site-footer-copy {
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.site-footer-copy .brand-version {
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  padding: 1px 6px;
  font-size: 0.72rem;
  line-height: 1.2;
}

.site-footer-online {
  position: absolute;
  right: var(--space-1);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.55rem;
  max-width: min(28rem, 100%);
  text-align: left;
}

@media (max-width: 1100px) {
  .site-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: static;
  }
  .site-footer-online {
    position: static;
    transform: none;
    justify-content: center;
    text-align: center;
  }
}

.online-label {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.online-label::before {
  content: "";
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  background: #2f9e6a;
  box-shadow: 0 0 0 2px rgba(47, 158, 106, 0.22);
  vertical-align: 0.05em;
}

.online-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.online-list li {
  margin: 0;
  padding: 0.12rem 0.45rem;
  border: 1px solid #c5d4cb;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  font-weight: 500;
}

.online-list li.is-self {
  border-color: var(--accent, #c45c26);
  background: rgba(196, 92, 38, 0.08);
}

.online-list li.is-empty {
  border-style: dashed;
  color: var(--empty);
  font-weight: 400;
}

.site-footer-online .btn.tiny {
  margin-left: 0.15rem;
}

@media (max-width: 640px) {
  .site-footer {
    flex-direction: column;
  }
  .site-footer-copy {
    text-align: center;
  }
  .site-footer-online {
    justify-content: center;
    max-width: none;
  }
}

.bg-wash {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 8% -10%, #c8e6df 0%, transparent 55%),
    radial-gradient(700px 420px at 100% 0%, #f0dcc8 0%, transparent 50%),
    linear-gradient(180deg, #eef3ef, #e4ebe5 40%, #dfe8e2);
}
body.centre-alegra {
  --page-bg: #f3e8df;
  --accent: #c45c26;
  --accent-deep: #a34a1c;
  --brand: var(--accent);
  --brand-deep: var(--accent-deep);
  --debt: #a85a2e;
}
body.centre-alegra .bg-wash {
  background:
    radial-gradient(900px 500px at 8% -10%, #f3d5bc 0%, transparent 55%),
    radial-gradient(700px 420px at 100% 0%, #f7e4d4 0%, transparent 50%),
    linear-gradient(180deg, #faf0e8, #f3e8df 40%, #eddccf);
}
body.centre-torre-setze {
  --page-bg: #e4ebe5;
}

.top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-4);
  align-items: center;
  margin-bottom: var(--space-2);
  padding-bottom: 0;
  min-height: 0;
}
.brand-title {
  justify-self: start;
  min-width: 0;
  max-width: min(46vw, 34rem);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-right: var(--space-2);
}
.brand-version {
  flex-shrink: 0;
  font-family: var(--font); font-feature-settings: "tnum" 1;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand-deep);
  letter-spacing: 0.02em;
  line-height: 1.15;
  margin: 0;
  padding: 2px 6px;
  border: 1px solid rgba(15, 107, 92, 0.28);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
}
.brand-version:hover {
  background: #fff;
  border-color: var(--brand);
  color: var(--brand);
}
.changelog-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(560px, calc(100vw - 24px));
  max-height: min(78vh, 640px);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #fff;
}
.changelog-dialog::backdrop {
  background: rgba(20, 30, 27, 0.45);
}
.changelog-inner {
  display: flex;
  flex-direction: column;
  max-height: min(78vh, 640px);
}
.changelog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.changelog-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.2rem;
}
.changelog-list {
  margin: 0;
  padding: 10px 16px 18px;
  list-style: none;
  overflow: auto;
  display: grid;
  gap: 12px;
}
.changelog-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7faf8;
}
.changelog-item.is-current {
  border-color: rgba(15, 107, 92, 0.45);
  background: #eef7f3;
}
.changelog-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 10px;
  margin-bottom: 4px;
}
.changelog-ver {
  font-family: var(--font); font-feature-settings: "tnum" 1;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--brand-deep);
}
.changelog-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--ink);
}
.changelog-notes {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}
.brand-title h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(0.95rem, 1.6vw, var(--text-title));
  line-height: 1.1;
  letter-spacing: 0.01em;
  text-transform: none;
  white-space: nowrap;
}
.top-center {
  justify-self: center;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: nowrap;
  white-space: nowrap;
  padding-bottom: var(--space-3);
  margin-left: clamp(1.25rem, 3vw, 2.75rem);
  margin-right: clamp(0.5rem, 2vw, 1.5rem);
}
.top-actions {
  justify-self: end;
  display: flex;
  gap: var(--space-2);
  flex-wrap: nowrap;
  flex-shrink: 0;
  align-items: center;
  min-width: 11.5rem;
  justify-content: flex-end;
}
.reset-slot {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: nowrap;
}
.demo-info-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.demo-info-btn:hover,
.demo-info-btn[aria-expanded="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.demo-info-panel {
  position: fixed;
  z-index: 80;
  top: 88px;
  right: 24px;
  width: min(580px, calc(100vw - 24px));
  max-height: none;
  overflow: visible;
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #ffffff 72%, #f3f0ec 100%);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: var(--text-sm);
  line-height: 1.35;
  transform-origin: var(--origin-x, 50%) 0;
  transform: scale(0.2);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
}
.demo-info-panel[hidden] { display: none !important; }
.demo-info-panel.is-open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}
.demo-info-panel.is-below .demo-info-arrow {
  bottom: auto;
  top: -7px;
  background: #fff;
  border-right: none;
  border-bottom: none;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
}
.demo-info-arrow {
  position: absolute;
  left: var(--arrow-x, 50%);
  bottom: -7px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  background: #f3f0ec;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
  border-radius: 2px;
  pointer-events: none;
}
.demo-info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  cursor: grab;
  user-select: none;
  touch-action: none;
  background: #fff;
  border-radius: 12px 12px 0 0;
}
.demo-info-head:active { cursor: grabbing; }
.demo-info-head h2 {
  margin: 0;
  font-size: var(--text-body);
  font-weight: 700;
  line-height: 1.2;
}
.demo-info-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.demo-info-close:hover {
  background: #eee;
  border-color: var(--muted);
}
.demo-info-hint {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  color: var(--muted);
  font-size: var(--text-xs);
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.demo-info-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: block;
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}
.demo-info-list li {
  margin: 0;
  padding: var(--space-2) var(--space-3);
  border-bottom: none;
  display: grid;
  gap: 2px;
  background: #fff;
}
.demo-info-list li:nth-child(even) {
  background: #f3f5f3;
}
.demo-info-list li:last-child {
  border-bottom: none;
  padding-bottom: var(--space-3);
}
.demo-info-line1 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}
.demo-info-line1 strong {
  font-weight: 700;
}
.demo-info-line2 {
  padding-left: 2px;
  color: var(--ink);
  white-space: normal;
}
.demo-info-nosurt {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 2px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--danger);
  white-space: nowrap;
}
.demo-info-action {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: #7a4e1c;
  white-space: nowrap;
}
.demo-info-action.is-keep {
  color: var(--cd);
}
.demo-info-ban {
  display: inline-block;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 2px solid #c62828;
  background:
    linear-gradient(
      to top left,
      transparent calc(50% - 1px),
      #c62828 calc(50% - 1px),
      #c62828 calc(50% + 1px),
      transparent calc(50% + 1px)
    );
  box-sizing: border-box;
}
.demo-info-tag {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  width: fit-content;
  padding: 2px var(--space-2);
  border-radius: 6px;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.demo-info-tag.is-add { border-color: #c4a882; background: #faf3ea; color: #7a4e1c; }
.demo-info-tag.is-out { border-color: #e2bdbd; background: #fdf2f2; color: var(--danger); }
.demo-info-tag.is-debt { border-color: #e0c4a8; background: #fff6ee; color: var(--debt); }
.demo-info-tag.is-rc { border-color: #9dceb8; background: #eef8f2; color: var(--cd); }
.demo-info-list .mono { font-variant-numeric: tabular-nums; }

.demo-excel-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
  padding: var(--space-2) var(--space-3);
  text-decoration: none;
}
.demo-excel-icon {
  display: inline-flex;
  line-height: 0;
}
.demo-excel-txt {
  font-size: var(--text-sm);
  font-weight: 600;
}
.sub-code {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.15;
  min-width: 7.2rem;
  display: inline-block;
}
.sub-code.is-empty {
  visibility: hidden;
}
.clock {
  font-variant-numeric: tabular-nums;
  font-family: var(--font);
  font-feature-settings: "tnum" 1;
  font-size: 0.95rem;
  color: var(--brand-deep);
  font-weight: 500;
  flex-shrink: 0;
  line-height: 1.15;
}
.brand-title .clock-date {
  font-size: var(--text-title);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.centre-toggle {
  display: inline-flex;
  align-items: stretch;
  gap: 6px;
  flex-shrink: 0;
  position: relative;
}
.centre-btn {
  font: inherit;
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.15;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.34rem 0.85rem;
  cursor: pointer;
  color: #6b756f;
  background: #dfe5e1;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  min-width: 7.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.38rem;
}
.centre-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.95em;
  height: 1.95em;
  min-width: 1.95em;
  padding: 0;
  margin-left: 0.22em;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.centre-btn-label {
  flex-shrink: 0;
}
.centre-btn.centre-alegra .centre-count {
  color: #fff;
  background: #c45c26;
  border: 1px solid #a34a1c;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.centre-btn.centre-torre .centre-count {
  color: #fff;
  background: #0f6b5c;
  border: 1px solid #0a4a40;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.centre-btn.centre-alegra.is-on .centre-count {
  color: #8a4218;
  background: #fff;
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: none;
}
.centre-btn.centre-torre.is-on .centre-count {
  color: #0a4a40;
  background: #fff;
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: none;
}
.centre-btn.centre-alegra:not(.is-on) .centre-count {
  color: #fff;
  background: #c45c26;
  border-color: #a34a1c;
}
.centre-btn.centre-torre:not(.is-on) .centre-count {
  color: #fff;
  background: #0f6b5c;
  border-color: #0a4a40;
}
.centre-btn.centre-alegra {
  min-width: 6.5rem;
  letter-spacing: 0.01em;
}
.centre-caret {
  position: absolute;
  left: 0;
  top: calc(100% + 5px);
  width: 0;
  height: 0;
  margin: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #000;
  transform: translateX(-50%);
  transition: left 0.38s cubic-bezier(0.22, 0.9, 0.28, 1);
  pointer-events: none;
}
.centre-caret.is-instant {
  transition: none;
}
.centre-btn.centre-torre {
  min-width: 9.5rem;
}
.hdr-select {
  display: inline-flex;
  align-items: center;
  margin: 0;
  flex-shrink: 0;
}
.hdr-select select {
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.15;
  border: 1px solid var(--line);
  border-radius: 999px;
  /* Més espai a la dreta per a la fletxa */
  padding: 0.28rem 2.1rem 0.28rem 0.9rem;
  color: var(--ink);
  cursor: pointer;
  max-width: 12.5rem;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235c6b64' d='M1.1 1.2 6 6.1l4.9-4.9 1.1 1.1L6 8.3 0 2.3z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 11px 7px;
}
.hdr-select select::-ms-expand { display: none; }
.centre-btn.centre-alegra.is-on {
  background: #c45c26;
  border-color: #a34a1c;
  color: #fff;
}
.centre-btn.centre-torre.is-on {
  background: #0f6b5c;
  border-color: #0a4a40;
  color: #fff;
}
.centre-btn:not(.is-on):hover {
  background: #d0d8d3;
  color: #3d4742;
}
.top-actions .btn {
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  line-height: 1.15;
}
.top-actions .clock-time {
  /* Héroe Protocolo 30cm (~2.5× cuerpo 16px) */
  font-size: var(--text-hero);
  font-weight: var(--weight-hero);
  line-height: 1;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  color: var(--ink);
}
.top-actions .clock-time .clock-secs {
  opacity: 0.38;
  font-weight: 500;
  font-size: 0.55em;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.brand-mark {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  color: var(--brand-deep);
  flex-shrink: 0;
}
.sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions .clock { margin-left: 2px; }

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: var(--space-2) var(--space-3);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  white-space: nowrap;
}
.btn:hover { border-color: #b7c8bd; background: #eef5f1; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: #eef5f1; border-color: #b7c8bd; }
.btn.danger,
.btn.danger-outline {
  color: var(--danger);
  border-color: #e2bdbd;
  background: #fff;
}
.btn.danger:hover,
.btn.danger-outline:hover {
  background: #fde8e8;
  border-color: var(--danger);
  color: #7a1f1f;
}
.reset-form { display: inline; margin: 0; }
.btn.tiny { padding: 0.15rem 0.5rem; font-size: 0.75rem; transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease; }
.btn.tiny:hover {
  background: #d8f0e8;
  border-color: var(--brand);
  color: var(--brand-deep);
}
.btn.tiny.danger:hover {
  background: #fde8e8;
  border-color: var(--danger);
  color: #7a1f1f;
}
.btn.large { padding: 0.9rem 1.4rem; font-size: 1.05rem; }

.flashes { margin-bottom: var(--space-2); display: grid; gap: var(--space-2); }
.flash {
  padding: var(--space-2) var(--space-3);
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: var(--text-sm);
}
.flash.ok { border-color: #9dceb8; background: #eef8f2; }
.flash.error { border-color: #e2bdbd; background: #fdf2f2; color: var(--danger); }

.stats {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-3);
}
.stat {
  background: var(--panel);
  backdrop-filter: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: var(--space-2) var(--space-3);
  min-width: 0;
  box-shadow: none;
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}
.stat-n {
  display: inline;
  font-family: var(--display);
  font-size: var(--text-title);
  font-weight: var(--weight-hero);
  line-height: 1;
  color: var(--ink);
}
.stat-l { color: var(--muted); font-size: var(--text-sm); font-weight: var(--weight-body); }
.stat.warn .stat-n { color: var(--warn); }
.stat.danger .stat-n { color: var(--danger); }
.stat.rc-change .stat-n { color: var(--cd); }
.stats .legend {
  margin-left: auto;
  padding-left: 14px;
  border-left: 1px solid #9aaba2;
}
.legend {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: none;
  flex-shrink: 0;
}
.legend-txt {
  line-height: 1.2;
}
.legend-sep {
  display: block;
  width: 1px;
  height: 1.1rem;
  margin: 0 11px;
  background: #9aaba2;
  flex: 0 0 1px;
  align-self: center;
}
.legend-sep-strong {
  height: 1.25rem;
  margin: 0 14px;
  background: #7a8a82;
}
.legend-hint {
  color: var(--muted);
  opacity: 0.95;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.bar-legend {
  display: inline-block;
  width: 28px;
  height: 10px;
  border-radius: 99px;
  vertical-align: middle;
  flex-shrink: 0;
}
.bar-legend.star { background: #e4b34a; }
.bar-legend.cd { background: #2f9b7a; }
.bar-legend.star.half {
  background: repeating-linear-gradient(
    to right,
    #e4b34a 0 2px,
    #f8eec8 2px 3px
  );
  border: 1px solid rgba(180, 130, 40, 0.4);
  box-sizing: border-box;
}
.bar-legend.cd.half {
  background: repeating-linear-gradient(
    to right,
    #2f9b7a 0 2px,
    #d5efe6 2px 3px
  );
  border: 1px solid rgba(15, 107, 92, 0.4);
  box-sizing: border-box;
}
.bar-legend.empty {
  background: #fff;
  border: 1px solid #c5d4cc;
  width: 18px;
  height: 10px;
  border-radius: 4px;
}

.rc-badge {
  display: inline-flex;
  min-width: 2.2rem;
  justify-content: center;
  padding: 0.15rem 0.4rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
}
.rc-badge.cd { background: #d8f0e8; color: var(--cd); }
.rc-badge.star { background: #f4ebd0; color: var(--star); }

/* Línia de temps: un segment per mes (amb separació) */
.timeline-cell {
  padding: 0 !important;
  min-width: 0;
  background: transparent;
  overflow: visible;
  vertical-align: middle;
  position: relative;
}
.month-timeline {
  position: absolute;
  top: 5%;
  bottom: 5%;
  left: 0;
  right: 0;
  height: auto !important;
  width: auto;
  user-select: none;
  touch-action: none;
  cursor: default;
}
.month-timeline.is-editing { cursor: pointer; }
.month-timeline.is-dragging { cursor: ew-resize; }
.user-row.is-editing {
  background: #f3faf7;
}
.user-row.is-editing .timeline-cell {
  outline: 1px solid rgba(15, 107, 92, 0.25);
  outline-offset: -1px;
  border-radius: 6px;
}
.tl-months {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0;
  z-index: 1;
}
.tl-seg {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  box-sizing: border-box;
  border: 0;
  padding: 0 0 0 6px;
  margin: 0;
  border-radius: 0;
  background: transparent;
  pointer-events: none;
  position: relative;
  overflow: hidden;
}
.tl-months > .tl-seg + .tl-seg {
  border-left: 1px solid var(--line);
}
.tl-seg-amt {
  opacity: 0;
  font-size: 0.98rem;
  font-weight: 500;
  line-height: 1;
  color: #1c2421;
  text-shadow: none;
  pointer-events: none;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 1px 4px;
  border-radius: 3px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(28, 36, 33, 0.08);
  transition: opacity 0.12s ease;
}
.tl-seg.star .tl-seg-amt,
.tl-seg.cd .tl-seg-amt {
  color: #1c2421;
  background: #fff;
}
.tl-seg.star:hover .tl-seg-amt,
.tl-seg.cd:hover .tl-seg-amt,
.tl-seg.star:focus-visible .tl-seg-amt,
.tl-seg.cd:focus-visible .tl-seg-amt {
  opacity: 1;
}
.tl-seg.star,
.tl-seg.cd {
  pointer-events: auto;
  cursor: default;
}
.month-timeline.is-editing .tl-seg {
  pointer-events: auto;
  cursor: pointer;
}
.tl-seg.star {
  background: linear-gradient(180deg, #f3ce74 0%, #e4b34a 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
}
.tl-seg.cd {
  background: linear-gradient(180deg, #45c4a0 0%, #2f9b7a 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3);
}
/* Mitja jornada (Imp DGPS ~200 €): franges verticals */
.tl-seg.star.is-half {
  background: repeating-linear-gradient(
    to right,
    #e4b34a 0 3px,
    #f8eec8 3px 5px
  );
  box-shadow: inset 0 0 0 1px rgba(180, 130, 40, 0.45);
}
.tl-seg.cd.is-half {
  background: repeating-linear-gradient(
    to right,
    #2f9b7a 0 3px,
    #d5efe6 3px 5px
  );
  box-shadow: inset 0 0 0 1px rgba(15, 107, 92, 0.4);
}
.tl-seg.empty {
  background: transparent;
  box-shadow: none;
}
.tl-seg.is-exit {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 2px 4px 4px;
  background: rgba(155, 44, 44, 0.08);
}
.tl-exit-badge {
  display: block;
  max-width: 100%;
  font-family: var(--font);
  font-size: 0.58rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: left;
  color: #9b2c2c;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}
.month-timeline.is-editing .tl-seg.empty:hover {
  background: rgba(15, 107, 92, 0.08);
}
.month-timeline.is-editing .tl-seg:hover {
  filter: brightness(0.96);
  outline: 2px solid rgba(15, 107, 92, 0.35);
  outline-offset: -1px;
}
.tl-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  height: auto;
  width: 14px;
  margin-left: -7px;
  border-radius: 8px;
  background: #fff;
  border: 2px solid var(--brand-deep);
  box-shadow: 0 2px 10px rgba(28, 36, 33, 0.22);
  cursor: ew-resize;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.tl-handle::before {
  content: "";
  width: 2px;
  height: 55%;
  max-height: 18px;
  background: #9bb5a8;
  border-radius: 2px;
  box-shadow: 3px 0 0 #9bb5a8, -3px 0 0 #9bb5a8;
}
.tl-handle:hover,
.month-timeline.is-dragging .tl-handle {
  border-color: var(--accent);
  transform: scaleX(1.08);
}
.tl-edge {
  position: absolute;
  top: 8%;
  bottom: 8%;
  height: auto;
  width: 10px;
  margin-left: -5px;
  border-radius: 6px;
  background: rgba(255,255,255,0.98);
  border: 1px solid #8aa89a;
  cursor: ew-resize;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.15s, transform 0.12s;
}
.month-timeline.is-editing:hover .tl-edge,
.month-timeline.is-dragging .tl-edge { opacity: 1; }
.tl-edge:hover { transform: scaleY(1.05); border-color: var(--accent); }
.tl-tip {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #1c2421;
  color: #fff;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.12s ease;
  box-shadow: 0 4px 12px rgba(28, 36, 33, 0.2);
}
.month-timeline.is-dragging .tl-tip,
.month-timeline .tl-tip.show { opacity: 1; }
.month-timeline.is-locked .tl-handle,
.month-timeline.is-locked .tl-edge,
.month-timeline.is-readonly .tl-handle,
.month-timeline.is-readonly .tl-edge {
  display: none;
}
.month-timeline.is-readonly,
.month-timeline.is-locked {
  cursor: default;
}
.user-row:hover .timeline-cell { background: transparent; }
.act-btns {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}
.edit-timeline-btn.is-on {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.edit-timeline-btn.is-on:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
  color: #fff;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.8rem;
  padding: 0.05rem 0.35rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.pill.cd { background: #d8f0e8; color: var(--cd); }
.pill.star { background: #f4ebd0; color: var(--star); }
.pill.empty { background: #e8ece9; color: var(--empty); }

.panel {
  background: var(--page-bg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: visible;
}
.users-blocks {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-3);
}
.user-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 22px rgba(26, 31, 29, 0.08);
  overflow: hidden;
}
.user-block-head {
  padding: var(--space-3);
  border-bottom: 1px solid var(--line);
  background: #f7faf7;
}
.user-block-finiquitar .user-block-head {
  background: #fdf2f2;
}
.user-block-resolucio .user-block-head {
  background: #fff8eb;
}
.user-block-title {
  margin: 0;
  font-size: var(--text-body);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.user-block-finiquitar .user-block-title {
  color: #9b2c2c;
}
.user-block-resolucio .user-block-title {
  color: #9a5b10;
}
.user-block-hint {
  margin: var(--space-1) 0 0;
  font-size: var(--text-xs);
  color: var(--muted);
  line-height: 1.35;
}
.user-block:not(.user-block-actius) .users-grid > thead {
  display: none;
}
.tabs {
  display: flex;
  align-items: center;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.92);
  position: relative;
  z-index: 3;
  border-radius: 14px 14px 0 0;
  padding-bottom: 10px;
}
.tab {
  padding: 6px 16px 2px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
  border-bottom: 2px solid transparent;
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab.on { color: var(--brand-deep); border-bottom-color: var(--brand); }
.tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35em;
  height: 1.35em;
  padding: 0 0.28em;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: rgba(15, 107, 92, 0.1);
  border: 1px solid rgba(15, 107, 92, 0.18);
}
.tab.on .tab-count {
  color: var(--brand-deep);
  background: rgba(47, 155, 122, 0.16);
  border-color: rgba(47, 155, 122, 0.35);
}
.tab-caret {
  position: absolute;
  left: 0;
  bottom: 1px;
  top: auto;
  width: 0;
  height: 0;
  margin: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 8px solid #000;
  transform: translateX(-50%);
  transition: left 0.38s cubic-bezier(0.22, 0.9, 0.28, 1);
  pointer-events: none;
  z-index: 5;
}
.tab-caret.is-instant {
  transition: none;
}
.identity-edit-btn {
  margin-left: 8px;
  margin-right: 10px;
  font-size: 0.8rem !important;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.28rem 0.7rem !important;
  height: auto !important;
  border-radius: 8px !important;
  position: relative;
}
.identity-edit-btn::before {
  content: none;
}
.icass-year-btn {
  margin-left: auto;
  margin-right: 0;
  font-size: 0.8rem !important;
  font-weight: 600;
  line-height: 1.2;
  padding: 0.28rem 0.7rem !important;
  height: auto !important;
  border-radius: 8px !important;
}
.identity-edit-btn.is-on {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  position: relative;
  cursor: grab;
}
.table-wrap:active {
  cursor: grabbing;
}
.table-wrap.compact { overflow: visible; }
.open-block-frame {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid #000;
  border-radius: 2px;
  pointer-events: none;
  z-index: 8;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.open-block-frame.is-on {
  opacity: 1;
}

.grid {
  width: 100%;
  min-width: 1700px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
  table-layout: fixed;
}
.grid th, .grid td {
  padding: 2px 6px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: middle;
  line-height: 1.2;
}
.grid th + th,
.grid td + td {
  border-left: 1px solid var(--line);
}
.grid thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f7faf7;
  font-family: var(--font) !important;
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.04em !important;
  color: var(--muted) !important;
  padding: 4px 6px;
  text-align: left;
}
.col-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: inherit !important;
  font-weight: inherit !important;
  letter-spacing: inherit !important;
  text-transform: inherit !important;
  color: inherit !important;
  cursor: pointer;
  line-height: 1.2;
  max-width: 100%;
}
.col-sort:hover,
.col-sort:focus-visible {
  color: var(--ink) !important;
}
.col-sort:focus-visible {
  outline: 2px solid rgba(47, 155, 122, 0.45);
  outline-offset: 2px;
  border-radius: 3px;
}
.col-sort-arrow {
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s ease;
}
.col-sort.is-active .col-sort-arrow {
  opacity: 1;
}
.col-sort.is-down .col-sort-arrow {
  background: currentColor;
  clip-path: polygon(50% 100%, 0 35%, 18% 35%, 50% 72%, 82% 35%, 100% 35%);
}
.col-sort.is-up .col-sort-arrow {
  background: currentColor;
  clip-path: polygon(50% 0, 0 65%, 18% 65%, 50% 28%, 82% 65%, 100% 65%);
}
.grid thead th.m {
  text-align: left;
  min-width: 0;
  padding-left: 6px;
  padding-right: 2px;
  font-variant-numeric: tabular-nums;
  position: relative;
  overflow: hidden;
  vertical-align: bottom;
  background: #fff !important;
}
.grid thead th.m .m-icass-btn {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.grid thead th.m .m-icass-btn:hover .m-label,
.grid thead th.m .m-icass-btn:focus-visible .m-label {
  color: var(--brand-deep);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.grid thead th.m.has-icass .m-label::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--brand);
  vertical-align: middle;
}
.grid thead th.m .m-label {
  position: relative;
  z-index: 1;
  display: block;
}
.grid thead th.m .m-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  top: 0;
  width: 0;
  max-width: 100%;
  pointer-events: none;
  z-index: 0;
  animation: fade-in 0.3s ease forwards;
}

/* Modals */
.modal-dialog {
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  padding: 0;
  max-width: 500px;
  width: 90%;
}
.modal-dialog::backdrop {
  background: rgba(0,0,0,0.5);
}
.modal-content {
  display: flex;
  flex-direction: column;
}
.modal-header {
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border-radius: 12px 12px 0 0;
}
.modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}
.close-modal-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
}
.close-modal-btn:hover {
  color: var(--text);
}
.modal-body {
  padding: 20px;
  background: var(--bg);
  border-radius: 0 0 12px 12px;
}
.form-group {
  margin-bottom: 15px;
}
.form-group label {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 5px;
  font-weight: 500;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
}
.form-group.row {
  display: flex;
  gap: 15px;
}
.form-group.row .col {
  flex: 1;
}
/* Mesos ja passats: verd suau (llegible, sense competir amb la barra CD) */
.grid thead th.m.is-past {
  background: #f3f7f5 !important;
}
.grid thead th.m.is-past .m-progress {
  width: 100%;
  background: rgba(15, 107, 92, 0.08);
}
/* Mes en curs: degradat vermell/taronja fins al dia d'avui */
.grid thead th.m.is-today-month {
  background: #fff !important;
}
.grid thead th.m.is-today-month .m-progress {
  background: linear-gradient(
    90deg,
    rgba(196, 92, 38, 0.32) 0%,
    rgba(196, 92, 38, 0.55) 100%
  );
}
.grid thead th.m.is-today-month .m-label {
  color: var(--brand-deep);
  font-weight: 700;
}
/* Mesos futurs: blanc */
.grid thead th.m.is-future {
  background: #fff !important;
}
.grid thead th.m.is-future .m-progress {
  width: 0 !important;
  background: transparent;
}
.grid thead th.m .m-num,
.grid thead th.notes {
  font: inherit !important;
  color: inherit !important;
  letter-spacing: inherit !important;
  text-transform: inherit !important;
  opacity: 1 !important;
}
.m-num {
  margin-right: 0.25em;
}
.grid .sticky {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}
.grid thead .sticky { z-index: 4; background: #f7faf7; }
.grid .sticky.surname {
  left: 0;
  width: var(--col-surname);
  min-width: var(--col-surname);
  max-width: var(--col-surname);
  padding-right: 2px;
}
.grid .sticky.given {
  left: var(--col-surname);
  width: var(--given-col, var(--col-given));
  min-width: var(--given-col, var(--col-given));
  max-width: var(--given-col, var(--col-given));
  padding-left: 3px;
  padding-right: 3px;
}
.grid tbody .sticky.exp {
  left: calc(var(--col-surname) + var(--given-col, var(--col-given)));
  width: var(--col-exp) !important;
  min-width: var(--col-exp) !important;
  max-width: var(--col-exp) !important;
  padding-left: 3px;
  padding-right: calc(3px + 1ch);
  box-sizing: border-box;
  box-shadow: 6px 0 10px rgba(0,0,0,0.03);
  overflow: hidden;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, Consolas, "Cascadia Mono", monospace;
  font-size: 0.78rem;
  /* keep position:sticky from .grid .sticky — do NOT set relative here */
}
.grid thead .sticky.exp {
  left: calc(var(--col-surname) + var(--given-col, var(--col-given)));
  width: var(--col-exp) !important;
  min-width: var(--col-exp) !important;
  max-width: var(--col-exp) !important;
  padding-left: 3px;
  padding-right: calc(3px + 1ch);
  box-sizing: border-box;
  box-shadow: 6px 0 10px rgba(0,0,0,0.03);
  overflow: hidden;
  white-space: nowrap;
  letter-spacing: 0 !important;
  font-size: 0.68rem !important;
  text-overflow: ellipsis;
}
.grid tbody tr:nth-child(even) td { background: #eef5f1; }
.grid tbody tr:nth-child(even) .sticky { background: #eef5f1; }
.grid tbody tr:nth-child(odd) td { background: #fff; }
.grid tbody tr:nth-child(odd) .sticky { background: #fff; }
.grid tbody tr:hover td { background: #e3f0ea; }
.grid tbody tr:hover .sticky { background: #e3f0ea; }
.grid tbody tr.needs-name td,
.grid tbody tr.needs-name .sticky {
  background: #c5d5cc !important;
}
.grid tbody tr.needs-name:hover td,
.grid tbody tr.needs-name:hover .sticky {
  background: #b7c9bf !important;
}
.grid tbody tr.pending-archive td,
.grid tbody tr.pending-archive .sticky {
  background: #f0c4c4 !important;
}
.grid tbody tr.pending-archive:hover td,
.grid tbody tr.pending-archive:hover .sticky {
  background: #e8a8a8 !important;
}
.pending-resolution-sep td {
  background: transparent !important;
  border: none !important;
  padding: 22px 8px 10px !important;
  vertical-align: middle;
}
.pending-resolution-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 6px;
}
.pending-resolution-rule {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, #9b2c2c 12%, #9b2c2c 88%, transparent);
  opacity: 0.55;
}
.pending-resolution-title {
  flex-shrink: 0;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #9b2c2c;
  text-transform: none;
}
.pending-resolution-hint {
  margin: 0;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}
.pending-debt-flag {
  margin-top: 4px;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 700;
  color: #9b2c2c;
  line-height: 1.2;
}
.pending-debt-flag.is-credit {
  color: #0f6b5c;
}
.pending-debt-flag.is-wait {
  color: #9a5b10;
}
.archive-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.3);
}
.cobrat-btn {
  font-weight: 700 !important;
}
.cobrat-inline {
  margin-top: 6px;
  display: inline-flex;
}
.finiquitar-group .pending-resolution-title {
  color: #9b2c2c;
}
.grid tbody.pending-resolution-group tr.user-row td,
.grid tbody.pending-resolution-group tr.user-row .sticky {
  background: #f0c4c4 !important;
}
.grid tr.changed td { background: #fff8eb; }
.grid tbody tr.needs-name .cell-name::placeholder {
  color: #3d4a44;
  opacity: 0.7;
  font-style: italic;
}
.warn-txt { color: #9b2c2c !important; font-weight: 600; }
.sticky.surname .cell-name,
.sticky.given .cell-name {
  width: 100%;
  min-width: 0;
  cursor: pointer;
  border: none !important;
  background: transparent !important;
  border-radius: 0;
  box-shadow: none !important;
  caret-color: transparent;
}
.sticky.surname .cell-name:focus,
.sticky.given .cell-name:focus {
  border: none !important;
  background: rgba(255, 255, 255, 0.35) !important;
  outline: none;
  box-shadow: none !important;
  caret-color: auto;
}
/* Bloc continu Apellidos + Nom + Expedient quan la fila està oberta */
.user-row.is-open > .sticky.surname,
.user-row.is-open > .sticky.given,
.user-row.is-open > .sticky.exp {
  background: #9fc4b4 !important;
}
.user-row.is-open:hover > .sticky.surname,
.user-row.is-open:hover > .sticky.given,
.user-row.is-open:hover > .sticky.exp {
  background: #8fb8a7 !important;
}
.user-row.is-open > .sticky.given,
.user-row.is-open > .sticky.exp {
  border-left-color: transparent !important;
}
.user-row.is-open.needs-name > .sticky.surname,
.user-row.is-open.needs-name > .sticky.given,
.user-row.is-open.needs-name > .sticky.exp,
.user-row.is-open.pending-archive > .sticky.surname,
.user-row.is-open.pending-archive > .sticky.given,
.user-row.is-open.pending-archive > .sticky.exp {
  background: #9fc4b4 !important;
}

.finance-row.open-gap,
.finance-row.open-gap td,
.finance-row.open-gap .sticky,
.grid tbody tr.finance-row.open-gap:hover td,
.grid tbody tr.finance-row.open-gap:hover .sticky,
.grid tbody tr.finance-row.open-gap:nth-child(even) td,
.grid tbody tr.finance-row.open-gap:nth-child(even) .sticky,
.grid tbody tr.finance-row.open-gap:nth-child(odd) td,
.grid tbody tr.finance-row.open-gap:nth-child(odd) .sticky {
  background: var(--page-bg) !important;
  background-color: var(--page-bg) !important;
}
.finance-row.open-gap td {
  padding: 0 !important;
  border: none !important;
  border-bottom: none !important;
  border-left: none !important;
  line-height: 0;
  font-size: 0;
  vertical-align: top;
}
.open-gap-anim {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.28s ease;
  background: var(--page-bg);
}
.open-gap-anim.is-shown {
  grid-template-rows: 1fr;
}
.open-gap-pad {
  overflow: hidden;
  min-height: 0;
  height: var(--open-gap-h, 2rem);
  background: var(--page-bg);
}

.finance-row.accordion-shell > td.fin-accordion-cell {
  padding: 0 !important;
  border: none !important;
  border-left: none !important;
  background: transparent !important;
  white-space: normal !important;
  vertical-align: top;
}
.grid tbody tr.finance-row.accordion-shell:hover > td.fin-accordion-cell,
.grid tbody tr.finance-row.accordion-shell:nth-child(even) > td.fin-accordion-cell,
.grid tbody tr.finance-row.accordion-shell:nth-child(odd) > td.fin-accordion-cell {
  background: transparent !important;
}
.fin-accordion {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.34s ease;
}
.fin-accordion.is-expanded {
  grid-template-rows: 1fr;
}
.fin-accordion-inner {
  overflow: hidden;
  min-height: 0;
}
.fin-amounts-bar {
  display: grid;
  grid-template-columns:
    var(--fin-sticky-w, var(--col-sticky))
    minmax(0, 1fr)
    var(--fin-notes-w, var(--col-notes));
  align-items: start;
  background: #f3f8f5;
  border-bottom: 1px solid var(--line);
}
.fin-provisional-bar {
  display: grid;
  grid-template-columns:
    var(--fin-sticky-w, var(--col-sticky))
    minmax(0, 1fr)
    var(--fin-notes-w, var(--col-notes));
  align-items: center;
  background: #f7f1e4;
  border-bottom: 1px solid #e5d7b8;
  min-height: 2rem;
}
.fin-provisional-bar .fin-prov-label {
  background: #f7f1e4;
  color: #7a5a12;
  font-weight: 700;
  font-size: 0.82rem;
}
.fin-provisional-bar .fin-prov-amt {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 1px;
  width: 100%;
  box-sizing: border-box;
  padding: 3px 6px;
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--star);
  white-space: normal;
}
.fin-provisional-bar .fin-prov-amt .fin-lab {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 0.68rem;
  text-align: left;
  color: var(--star);
}
.fin-provisional-bar .fin-prov-amt .fin-num {
  flex: 0 0 auto;
  text-align: left;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--star);
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
.fin-prov-empty {
  min-height: 1.35rem;
  padding: 3px 6px;
}
.fin-m.is-blank {
  min-height: 1.35rem;
  background: transparent;
  border: none;
  box-shadow: none;
}
.fin-amounts-label {
  position: sticky;
  left: 0;
  z-index: 1;
  box-sizing: border-box;
  padding: 6px;
  font-weight: 600;
  color: var(--ink);
  background: #f3f8f5;
  box-shadow: 6px 0 10px rgba(0, 0, 0, 0.03);
  text-align: right;
}
.fin-amounts-caret {
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 6px;
  vertical-align: middle;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 7px solid #000;
}
.fin-amounts-bar .fin-hint-cell {
  padding: 6px 8px;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: normal;
}

.finance-row.banner td {
  padding: 8px 12px !important;
  background: #e8f2ee !important;
  border-bottom: 1px solid var(--line);
  white-space: normal !important;
  vertical-align: top;
}
.fin-panel-wrap {
  width: 100%;
}
.fin-panel-wrap.banner-panel {
  padding: 8px 12px;
  background: #e8f2ee;
  border-bottom: 1px solid var(--line);
  box-sizing: border-box;
}
.fin-months-cell {
  padding: 4px 0 !important;
  min-width: 0;
  border-left: 1px solid var(--line);
}
.fin-amounts-bar .fin-hint-cell,
.fin-provisional-bar .fin-hint-cell,
.fin-overflow-bar .fin-overflow-hint {
  border-left: 1px solid var(--line);
}
.fin-months-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 0;
  width: 100%;
  align-items: stretch;
}
.fin-months-grid > * + * {
  border-left: 1px solid var(--line);
}
.fin-overflow-bar {
  display: grid;
  grid-template-columns:
    var(--fin-sticky-w, var(--col-sticky))
    minmax(0, 1fr)
    var(--fin-notes-w, var(--col-notes));
  align-items: start;
  background: #eef4f0;
  border-bottom: 1px solid var(--line);
}
.fin-overflow-label {
  position: sticky;
  left: 0;
  z-index: 1;
  box-sizing: border-box;
  padding: 6px;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--brand-deep);
  background: #eef4f0;
  text-align: right;
}
.fin-overflow-grid {
  /* mateixa graella de 12 que l'any origen */
  max-width: none;
  padding: 0;
}
.fin-overflow-hint {
  padding: 6px 8px;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: normal;
}
.fin-m.overflow {
  border: 1px dashed rgba(15, 107, 92, 0.35);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.55);
}
.fin-m.overflow.in-split {
  border-style: solid;
}
.fin-m .overflow-lab {
  font-weight: 600;
  color: var(--brand-deep);
}
.fin-m {
  text-align: left;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 3px 6px;
  overflow: hidden;
}
.fin-m.fin-rows {
  display: grid;
  grid-template-rows: minmax(2.1rem, auto) minmax(2rem, auto) minmax(2.2rem, auto);
  align-items: start;
  justify-items: stretch;
  gap: 4px;
  min-height: 6.6rem;
}
.fin-m .fin-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  line-height: 1.15;
  min-height: 0;
  text-align: left;
}
.fin-m .fin-ph {
  display: block;
  min-height: 1em;
  visibility: hidden;
}
.fin-m .fin-lab {
  font-weight: inherit;
  font-size: 0.68rem;
  color: inherit;
  flex: 0 0 auto;
  text-align: left;
  line-height: 1.2;
  opacity: 0.9;
}
.fin-m .fin-num {
  flex: 0 0 auto;
  text-align: left;
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  line-height: 1.25;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
.fin-m .fin-amt.main,
.fin-m .fin-amt.debt,
.fin-m .fin-amt.total {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 1px;
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  width: 100%;
  white-space: normal;
}
.fin-m .fin-amt.main { color: var(--cd); }
.fin-m .fin-amt.debt { color: var(--debt); }
.fin-m .fin-amt.debt.is-zero { color: var(--muted); }
.fin-m .fin-amt.total {
  color: var(--ink);
  font-weight: 800;
}
.fin-m .fin-amt.main .fin-lab,
.fin-m .fin-amt.debt .fin-lab {
  font-weight: 400;
}
.fin-m .fin-amt.total .fin-lab {
  font-size: 0.68rem;
  font-weight: 700;
  color: inherit;
}
.fin-m.is-leaving-debt .fin-amt.total {
  animation: debt-pulse 1.4s ease-in-out infinite;
  color: #7a2e10;
}
.fin-m.is-leaving-debt .fin-amt.total .fin-lab {
  color: #a34a1c;
}
.fin-amounts-bar .fin-m {
  padding-top: 4px !important;
  padding-bottom: 4px !important;
}
.fin-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  justify-content: flex-start;
  font-size: 0.86rem;
}
.fin-banner.debt,
.fin-banner.credit {
  justify-content: space-between;
}
.fin-banner.debt { border-left: 4px solid #c45c26; padding-left: 10px; }
.fin-banner.liquidated { opacity: 0.92; }
.fin-banner.credit { border-left: 4px solid #0f6b5c; padding-left: 10px; }
.debt-total-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 6px 0 4px;
  padding: 0.55rem 1.1rem;
  min-width: 7.5rem;
  border: 2px solid #c45c26;
  border-radius: 10px;
  background: #fff4ec;
  color: #8a3414;
  box-shadow: 0 0 0 0 rgba(196, 92, 38, 0.45);
  vertical-align: middle;
}
.debt-total-box .debt-total-lab {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #a34a1c;
  line-height: 1.1;
}
.debt-total-box .debt-total-val {
  font-family: var(--font); font-feature-settings: "tnum" 1;
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: #7a2e10;
}
.fin-banner.credit .debt-total-box {
  border-color: #0f6b5c;
  background: #e8f5f1;
  color: #0a4a40;
  box-shadow: 0 0 0 0 rgba(15, 107, 92, 0.45);
}
.fin-banner.credit .debt-total-box .debt-total-lab { color: #0f6b5c; }
.fin-banner.credit .debt-total-box .debt-total-val { color: #0a4a40; }
.fin-banner.liquidated .debt-total-box {
  border-color: #8a9690;
  background: #f0f2f1;
  animation: none;
  box-shadow: none;
}
.fin-banner.liquidated .debt-total-box .debt-total-lab,
.fin-banner.liquidated .debt-total-box .debt-total-val { color: #5c6b64; }
@keyframes debt-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(196, 92, 38, 0.5);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 10px rgba(196, 92, 38, 0);
  }
}
@keyframes debt-pulse-credit {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(15, 107, 92, 0.5);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 0 10px rgba(15, 107, 92, 0);
  }
}
.debt-total-pulse {
  animation: debt-pulse 1.4s ease-in-out infinite;
}
.fin-banner.credit .debt-total-pulse {
  animation-name: debt-pulse-credit;
}

.debt-block-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(420px, calc(100vw - 24px));
  box-shadow: var(--shadow);
  background: #fff8f3;
}
.debt-block-dialog::backdrop {
  background: rgba(40, 20, 10, 0.5);
}
.debt-block-inner {
  padding: 22px 22px 18px;
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
}
.debt-block-inner h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
  color: #7a2e10;
}
.debt-block-msg {
  margin: 0;
  color: var(--ink);
  line-height: 1.45;
  font-size: 0.95rem;
}
.debt-block-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}
.debt-block-dialog .debt-total-box {
  margin: 4px 0 8px;
  min-width: 10rem;
  padding: 0.75rem 1.4rem;
}
.debt-block-dialog .debt-total-box .debt-total-val {
  font-size: 1.75rem;
}
.debt-block-dialog .dialog-actions {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}
.debt-block-dialog.is-credit {
  background: #f0faf6;
}
.debt-block-dialog.is-credit h2 { color: #0a4a40; }

/* Snack de confirmació ancorat al botó — Protocolo 30cm */
.anchor-snack-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: transparent;
}
.anchor-snack {
  position: fixed;
  z-index: 91;
  max-width: min(320px, calc(100vw - 16px));
  padding: var(--space-3);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #ffffff 62%, #f3f0ec 100%);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: var(--text-sm);
  line-height: 1.35;
  transform-origin: var(--origin-x, 50%) var(--origin-y, 100%);
  transform: scale(0.2);
  opacity: 0;
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;
  pointer-events: none;
}
.anchor-snack.is-open {
  transform: scale(1);
  opacity: 1;
  pointer-events: auto;
}
.anchor-snack.is-closing {
  transform: scale(0.15);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.4, 0, 1, 1), opacity 0.18s ease;
}
.anchor-snack-msg {
  margin: 0 0 var(--space-3);
  color: var(--ink);
  white-space: pre-line;
  font-size: var(--text-body);
  font-weight: var(--weight-body);
}
.anchor-snack-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}
.anchor-snack .btn.ghost {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.85);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.anchor-snack .btn.ghost:hover {
  background: var(--paper);
  border-color: var(--muted);
  color: var(--ink);
}
.anchor-snack .btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  transition: background 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
}
.anchor-snack .btn.primary:hover {
  background: var(--accent-deep);
  border-color: var(--accent-deep);
  filter: brightness(1.05);
}
.anchor-snack-arrow {
  position: absolute;
  left: var(--arrow-x, 50%);
  bottom: -8px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  background: #f3f0ec;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
  border-radius: 2px;
}
.anchor-snack.is-below .anchor-snack-arrow {
  bottom: auto;
  top: -8px;
  background: #fff;
  border-right: none;
  border-bottom: none;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
}

.fin-amt.credit-amt { font-weight: 700; font-size: 0.75rem; color: #0f6b5c; margin-top: 2px; }
.fin-banner.muted-banner {
  color: var(--muted);
  display: block;
}
.fin-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.fin-row-actions { display: inline-flex; flex-wrap: nowrap; gap: 6px; align-items: center; }
.fin-banner .fin-actions { margin-left: auto; }
.fin-panel { display: grid; gap: 8px; }
.fin-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.fin-banner-slot {
  flex: 1;
  min-width: 0;
}
.fin-top .fin-actions {
  flex-shrink: 0;
  margin-left: 0;
  padding-top: 0;
  align-self: center;
}
.fin-row-actions .btn.tiny {
  font-size: 0.92rem;
  font-weight: 700;
  padding: 0 0.95rem;
  height: 1.55rem;
  line-height: 1.55rem;
  box-sizing: border-box;
}
.fin-notes-wrap {
  display: grid;
  gap: 4px;
}
.fin-notes-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.fin-notes {
  width: 100%;
  min-height: 3.2rem;
  resize: vertical;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.35;
  color: var(--ink);
  border: 1px solid #c5d4cc;
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}
.fin-notes:focus {
  outline: none;
  border-color: #9bc7ba;
  box-shadow: 0 0 0 2px rgba(15, 107, 92, 0.12);
}
.fin-debt-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-left: auto;
}
.sticky.exp .pending-debt-flag {
  display: block;
  margin-top: 2px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.65rem;
  line-height: 1.2;
}
.grid td.notes .restore-btn,
.sticky.exp .restore-btn {
  display: inline-block;
  width: 100%;
  white-space: normal;
  line-height: 1.2;
  margin-top: 4px;
  padding: 0.35rem 0.4rem;
  font-size: 0.72rem;
}
.sticky.exp .tiny-txt {
  margin-top: 2px;
  font-size: 0.65rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grid td.notes,
.grid th.notes {
  width: var(--col-notes);
  min-width: var(--col-notes);
  max-width: var(--col-notes);
  padding: 2px 0 !important;
  text-align: center;
  vertical-align: middle;
}
.grid thead th.notes-flag-h {
  font-size: 0.72rem !important;
  letter-spacing: 0 !important;
  text-align: center;
  padding: 4px 0 !important;
}
.notes-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 1.45rem;
  height: 1.45rem;
  margin: 0 auto;
  padding: 0;
  border: 1px solid #c5d4cc;
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  line-height: 1;
}
.notes-flag:hover {
  border-color: var(--brand);
  color: var(--brand-deep);
}
.notes-flag:not(.has-note) {
  visibility: hidden;
  pointer-events: none;
}
.notes-flag-letter {
  font-size: 0.72rem;
  font-weight: 700;
}
.notes-flag-dot {
  display: none;
  position: absolute;
  top: 2px;
  right: 2px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c0392b;
  box-shadow: 0 0 0 1.5px #fff;
}
.notes-flag.has-note .notes-flag-dot {
  display: block;
}
.notes-flag.has-note {
  border-color: rgba(192, 57, 43, 0.45);
  color: #9b2c2c;
}
.cell-exp {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78rem;
  border: none;
  background: transparent;
  padding: 0;
  margin: 0;
  color: inherit;
  caret-color: transparent;
  cursor: default;
}
.grid.is-editing-identity .cell-exp {
  caret-color: auto;
  cursor: text;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 4px;
  padding: 1px 2px;
}
.grid.is-editing-identity .sticky.surname .cell-name,
.grid.is-editing-identity .sticky.given .cell-name {
  caret-color: auto;
  cursor: text;
  background: rgba(255, 255, 255, 0.55) !important;
  border-radius: 4px;
}
.cell-notes.notes-preview {
  cursor: default;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  color: var(--muted);
}
.fin-label { font-weight: 700; font-size: 0.78rem; color: var(--brand-deep); }
.fin-amt.main { font-weight: 400; font-size: 0.92rem; color: var(--ink); line-height: 1.2; }
.fin-amt.debt { font-weight: 400; font-size: 0.92rem; color: var(--debt); margin-top: 0; }
.fin-amt.total { font-weight: 800; font-size: 0.92rem; color: var(--ink); margin-top: 0; }
.fin-sub { font-size: 0.62rem; color: var(--muted); margin-top: 0; text-align: left; width: 100%; }
.fin-ap {
  width: 100%;
  min-width: 0;
  flex: 0 0 auto;
  max-width: 100%;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 400;
  text-align: left;
  border: 1px solid #c5d4cc;
  border-radius: 6px;
  padding: 2px 4px;
  background: #fff;
  margin-top: 0;
  color: var(--muted);
  box-sizing: border-box;
}
.fin-radio-group {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-right: 15px;
  font-size: 0.75rem;
  color: var(--ink);
  background: var(--panel);
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #dce8e1;
}
.fin-radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  font-weight: 500;
}
.fin-radio-group input[type="radio"] {
  margin: 0;
  cursor: pointer;
  accent-color: var(--brand-deep);
}
.fin-check {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-top: 4px;
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}
.fin-check input { margin: 0; cursor: pointer; }
.fin-m.star .fin-amt.main { color: var(--star); }
.fin-m.cd .fin-amt.main { color: var(--cd); }
.fin-m.fin-splitable {
  cursor: pointer;
  transition: box-shadow 0.12s ease, background 0.12s ease;
}
.fin-m.fin-splitable:hover {
  box-shadow: inset 0 0 0 2px rgba(15, 107, 92, 0.35);
  background: #e7f5f0 !important;
}
.fin-m.fin-splitable.in-split {
  box-shadow: inset 0 0 0 2px #c45c26;
  background: #fff4ec !important;
}
.fin-split-hint {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--brand-deep);
}
.fin-hint-cell {
  font-size: 0.7rem !important;
  color: var(--muted) !important;
  white-space: normal !important;
  max-width: 110px;
}
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, Consolas, monospace; font-size: 0.78rem; }
.muted { color: var(--muted); }
.tiny-txt { font-size: 0.68rem; margin-top: 0; }
.empty-row { text-align: center; padding: 24px !important; color: var(--muted); }

.cell-name, .cell-notes, .month-select, .rc-select {
  font: inherit;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 1px 4px;
  width: 100%;
  min-width: 0;
  height: 22px;
  line-height: 20px;
}
.cell-name:focus, .cell-notes:focus {
  outline: none;
  border-color: #9bc7ba;
  background: #f7fbf9;
}
.month-select:focus, .rc-select:focus {
  outline: none;
  border-color: #9bb5a8;
}
.month-select.v-eee:focus {
  border-color: #5c6b64;
  background-color: #fff;
}
.cell-notes { min-width: 0; width: 100%; }
.month-select,
.rc-select {
  text-align: center;
  font-weight: 700;
  min-width: 3.4rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: 1px solid #c5d4cc;
  border-radius: 8px;
  background-color: #f3f7f4;
  color: var(--muted);
  padding: 0 18px 0 4px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%236b7c74' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  box-shadow: none;
}
.month-select:hover,
.rc-select:hover {
  border-color: #9bb5a8;
}
.month-select.v-CD {
  color: var(--cd);
  background-color: #d8f0e8;
  border-color: #a8d4c4;
}
.month-select.v-ss {
  color: var(--star);
  background-color: #f4ebd0;
  border-color: #e0d0a0;
}
.month-select.v-eee {
  color: var(--empty);
  background-color: #fff;
  border-color: #5c6b64;
}
.rc-select {
  min-width: 3.2rem;
  background-color: #f3f7f4;
}

.import-dialog {
  border: none;
  border-radius: 16px;
  padding: 0;
  width: min(560px, calc(100vw - 24px));
  max-height: min(80vh, calc(100vh - var(--import-top, 72px) - 16px));
  overflow: auto;
  box-shadow: var(--shadow);
  background: #fff;
  margin: 0;
  position: fixed;
  top: var(--import-top, 72px);
  left: var(--import-left, 50%);
  transform: translateY(-10px) scaleY(0.04);
  transform-origin: top center;
  opacity: 0;
  transition:
    transform 0.36s cubic-bezier(0.22, 0.9, 0.28, 1),
    opacity 0.28s ease;
}
.import-dialog[open].is-open {
  transform: translateY(0) scaleY(1);
  opacity: 1;
}
.import-dialog[open].is-closing {
  transform: translateY(-10px) scaleY(0.04);
  opacity: 0;
}
.import-dialog::backdrop {
  background: rgba(20, 30, 27, 0.45);
  opacity: 0;
  transition: opacity 0.28s ease;
}
.import-dialog[open].is-open::backdrop {
  opacity: 1;
}
.import-dialog[open].is-closing::backdrop {
  opacity: 0;
}
body.centre-alegra .import-dialog {
  background: #f8ebe1;
}
body.centre-torre-setze .import-dialog {
  background: #e8f3ef;
}
.import-form { padding: 22px 22px 18px; display: grid; gap: 14px; }
.import-form h2 { margin: 0; font-family: var(--display); }
.import-form header p { margin: 8px 0 0; color: var(--muted); line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 600; font-size: 0.92rem; }
.import-form input[type="number"],
.import-form select,
.import-form textarea,
.import-form input[type="file"] {
  font: inherit;
  font-weight: 500;
  border: 1px solid #cfd6d2;
  border-radius: 12px;
  padding: 10px 12px;
  background: #f3f4f3;
}
.import-form .drop {
  border: 1.5px dashed #b8c0bb;
  border-radius: 14px;
  padding: 16px;
  background: #eceeed;
}
.drop-title { font-weight: 700; }
.drop-hint { color: var(--muted); font-weight: 500; font-size: 0.86rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.import-form .btn.ghost {
  background: #eceeed;
  border-color: #c5cdc8;
  color: var(--ink);
}
.import-form .btn.ghost:hover {
  background: #e2e6e3;
  border-color: #b0b8b3;
}
body.centre-alegra .import-form .btn.primary {
  background: #c45c26;
  border-color: #a34a1c;
  color: #fff;
}
body.centre-alegra .import-form .btn.primary:hover {
  background: #a34a1c;
  border-color: #8a3e18;
}
body.centre-torre-setze .import-form .btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
body.centre-torre-setze .import-form .btn.primary:hover {
  background: var(--brand-deep);
  border-color: var(--brand-deep);
}

.preview-panels {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
}
.preview-panels-stack {
  grid-template-columns: 1fr;
}
.card-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.card-block h2 { margin: 0 0 6px; font-family: var(--display); font-size: 1.25rem; }
.card-block p { margin: 0 0 12px; color: var(--muted); }
.card-block ul { margin: 0; padding-left: 18px; display: grid; gap: 8px; }
.card-block .preview-note { margin: 10px 0 0; font-size: 0.85rem; }
.card-block.add { border-top: 4px solid #c45c26; }
.card-block.archive { border-top: 4px solid #9b2c2c; }
.card-block.rc-change { border-top: 4px solid #1f6b54; }
.card-block.keep { border-top: 4px solid var(--brand); }
.card-block .table-wrap.compact {
  margin-top: 4px;
  overflow-x: auto;
}
.card-block .grid.preview-grid {
  width: auto;
  max-width: 100%;
  table-layout: auto;
  border-collapse: collapse;
}
.card-block .grid.preview-grid th,
.card-block .grid.preview-grid td {
  width: auto !important;
  min-width: 0;
  max-width: none;
  padding: 6px 14px 6px 8px;
  white-space: nowrap;
}
.card-block .grid.preview-grid th:last-child,
.card-block .grid.preview-grid td:last-child {
  padding-right: 10px;
}
.card-block .grid tbody tr.pending-archive-row td {
  background: #f8e4e4;
}
.card-block .grid tbody tr.needs-name td {
  background: #efeae4;
}

.apply-bar {
  position: sticky;
  bottom: 16px;
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 18px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.apply-bar p { margin: 0; color: var(--muted); max-width: 52ch; }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  :root {
    --col-surname: 5.8rem;
    --col-exp: 3.2rem;
  }
  .top { flex-wrap: wrap; }
  .brand-title h1 { white-space: normal; }
  .top {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .brand-title, .top-actions { justify-self: center; }
  .stats { flex-wrap: wrap; }
  .legend { margin-left: 0; flex-wrap: wrap; }
}

/* —— Arxiu ICASS —— */
.icass-archive-dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  max-width: min(560px, calc(100vw - 24px));
  width: 100%;
  box-shadow: var(--shadow);
}
.icass-archive-dialog::backdrop {
  background: rgba(20, 40, 34, 0.35);
}
.icass-archive-inner {
  padding: 18px 18px 14px;
}
.icass-archive-inner header h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
}
.icass-archive-body {
  margin: 12px 0 8px;
  max-height: min(50vh, 420px);
  overflow: auto;
}
.icass-empty {
  margin: 8px 0;
  color: var(--muted);
}
.icass-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.icass-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.icass-item-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.icass-item-name {
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icass-item-when {
  font-size: 0.75rem;
}
.icass-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.icass-view-panel {
  margin: 16px auto 32px;
  max-width: min(1400px, 98vw);
  padding: 12px;
}
.icass-sheet-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
  padding: 0 0 8px;
  margin-bottom: 8px;
  scrollbar-width: thin;
}
.icass-sheet-tab {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: #f4f8f6;
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
}
.icass-sheet-tab:hover {
  background: #e8f0ec;
}
.icass-sheet-tab.active {
  background: #fff;
  border-bottom-color: #fff;
  color: var(--accent-deep);
  box-shadow: inset 0 2px 0 var(--accent);
}
body.centre-torre-setze .icass-sheet-tab.active {
  color: #1f6b45;
  box-shadow: inset 0 2px 0 #2d8f5c;
}
.icass-sheet-panel {
  display: none;
}
.icass-sheet-panel.active {
  display: block;
}
.icass-sheet-caption {
  margin: 0 0 6px;
  font-size: 0.75rem;
  color: var(--muted);
}
.import-review-panel {
  max-width: min(1400px, 96vw);
}
.import-review-hint {
  margin: 0 0 12px;
  max-width: 70ch;
}
.import-review-actions {
  margin-top: 16px;
}
.import-review-actions p {
  margin: 0;
  color: var(--muted);
  max-width: 48ch;
}
.icass-table-wrap {
  overflow: auto;
  max-height: calc(100vh - 160px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.icass-sheet {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  font-size: 0.78rem;
}
.icass-sheet th,
.icass-sheet td {
  border: 1px solid #d5e0db;
  padding: 4px 8px;
  white-space: nowrap;
  text-align: left;
}
.icass-sheet th {
  position: sticky;
  top: 0;
  background: #eef5f1;
  z-index: 1;
}
.icass-pdf {
  width: 100%;
  min-height: calc(100vh - 160px);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.icass-text {
  margin: 0;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  white-space: pre-wrap;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85rem;
  max-height: calc(100vh - 160px);
  overflow: auto;
}

/* —— Login —— */
body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  padding: var(--space-3);
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-5) var(--space-4);
}

.login-kicker {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.login-title {
  margin: 0;
  font-family: var(--display);
  font-size: var(--text-hero);
  font-weight: var(--weight-hero);
  line-height: 1.05;
  color: var(--ink);
}

.login-lead {
  margin: var(--space-2) 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--muted);
}

.login-error {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: 10px;
  background: #fdeeee;
  color: var(--danger);
  font-size: var(--text-sm);
}

.login-form {
  display: grid;
  gap: var(--space-3);
}

.login-field {
  display: grid;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--muted);
}

.login-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
}

.login-field input:focus {
  outline: 2px solid rgba(15, 107, 92, 0.25);
  border-color: var(--accent);
}

.login-submit {
  width: 100%;
  margin-top: var(--space-1);
}

.login-foot {
  margin: var(--space-4) 0 0;
  font-size: var(--text-xs);
  color: var(--empty);
  text-align: center;
}

.btn-logout {
  font-size: var(--text-xs);
  padding: 6px 10px;
}




.table-wrap::-webkit-scrollbar {
  height: 24px;
}
.table-wrap::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 12px;
}
.table-wrap::-webkit-scrollbar-thumb {
  background-color: #bbccba;
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 6px,
    rgba(255, 255, 255, 0.8) 6px,
    rgba(255, 255, 255, 0.8) 8px
  );
  border-radius: 12px;
  border: 3px solid #f1f1f1;
}
.table-wrap::-webkit-scrollbar-thumb:hover {
  background-color: #9cb09b;
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 6px,
    rgba(255, 255, 255, 0.9) 6px,
    rgba(255, 255, 255, 0.9) 8px
  );
}


.clock-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-left: 16px;
  justify-content: center;
}
.clock-container .clock-time {
  font-size: 1.7rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}
.clock-container .clock-time .clock-secs {
  opacity: 0.5;
  font-weight: 500;
  font-size: 0.6em;
}
.clock-container .clock-date {
  font-size: 1rem;
  color: var(--muted);
  font-weight: 500;
  margin-top: 4px;
  line-height: 1;
  letter-spacing: 0.05em;
}


/* Make inactive Torre button have a distinct dark gray border */
.centre-btn.centre-torre:not(.is-on) {
  border-color: #a4b3ac;
}

/* Match the shape and size of the center buttons */
.hdr-select select,
#open-import.btn {
  border-radius: 8px;
  font-size: 1.05rem;
  padding: 0.34rem 0.85rem;
  height: auto;
}


/* Add separation and specific border to the year dropdown */
.hdr-select {
  margin-left: 12px !important;
}
.hdr-select select {
  border: 1px solid #a4b3ac !important;
}


/* Fix for the select dropdown arrow overlapping text */
.hdr-select select {
  padding-right: 2.2rem !important;
  background-position: right 0.85rem center !important;
}


.btn-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-family: serif;
  font-style: italic;
  font-weight: bold;
  font-size: 14px;
  border: none;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.15s, transform 0.15s;
}
.btn-help:hover {
  opacity: 1;
  transform: scale(1.1);
}
.help-content {
  max-width: 600px;
}
