/* ────────────────────────────────────────────────────────────────────────────
   NEREU · shell, plantilles i components (Nereu DS)
   Cada component una sola vegada; l'API en JS és a js/ui/components.js.
   Només tokens (tokens.css): cap hex, cap mida inventada.
   Punts de tall: < 640 mòbil (capçalera + pestanyes a baix) · 640–1023
   tauleta (barra lateral d'icones) · ≥ 1024 escriptori (barra lateral sencera).
   ────────────────────────────────────────────────────────────────────────── */

/* ══ SHELL ══════════════════════════════════════════════════════════════════ */

.salta {
  position: absolute; left: var(--sp-4); top: -80px; z-index: calc(var(--z-toast) + 1);
  padding: var(--sp-3) var(--sp-5); border-radius: var(--r-sm); background: var(--c-brand); color: var(--c-on-brand);
  font-weight: var(--fw-bold); text-decoration: none; transition: top var(--dur-1) var(--ease);
}
.salta:focus { top: var(--sp-3); color: var(--c-on-brand); }
#app:focus { outline: none; }

.brand-wordmark {
  display: inline-block; flex: none; aspect-ratio: 1084 / 252; background-color: currentColor;
  -webkit-mask: url("/icons/nereu-wordmark.svg") center / contain no-repeat;
  mask: url("/icons/nereu-wordmark.svg") center / contain no-repeat;
}
.ico { flex: none; display: inline-block; vertical-align: middle; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ── barra lateral ── */
.sb {
  position: fixed; inset: 0 auto 0 0; z-index: var(--z-nav); width: var(--sidebar-w);
  display: flex; flex-direction: column; gap: var(--sp-2);
  padding: 0 var(--sp-4) var(--sp-4); background: var(--c-sidebar); border-right: 1px solid var(--c-border);
  overflow-y: auto; overscroll-behavior: contain;
}
.sb__brand { display: flex; align-items: center; gap: var(--sp-3); height: var(--header-h); flex: none; padding: 0 var(--sp-3); color: var(--c-brand); text-decoration: none; }
.sb__brand .brand-icon { width: 24px; height: 24px; display: block; }
.sb__brand .brand-wordmark { width: 76px; }
/* el logotip és una rajola petroli: en fosc, en negatiu */
:root[data-theme="dark"] .brand-icon { filter: brightness(0) invert(.92); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-icon { filter: brightness(0) invert(.92); } }

.sb__local {
  display: flex; align-items: center; gap: var(--sp-4); width: 100%; min-height: var(--ctl-h-lg); padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text);
  text-align: left; font-weight: var(--fw-bold); font-size: var(--fs-body); cursor: default;
}
.sb__local--varis { cursor: pointer; }
.sb__local--varis:hover { border-color: var(--c-border-strong); }
.sb__local:disabled { opacity: 1; color: var(--c-text); }
.sb__local .avatar { flex: none; }
.sb__local-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: var(--lh-sm); }
.sb__local-nom { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }
.sb__local-sub { color: var(--c-text-3); font-weight: var(--fw-regular); font-size: var(--fs-xs); }
.sb__local .ico { color: var(--c-text-3); display: none; }
.sb__local--varis .ico { display: inline-block; }

.sb__neso {
  display: flex; align-items: center; gap: var(--sp-3); width: 100%; min-height: var(--ctl-h); margin-top: var(--sp-2); padding: 0 var(--sp-4);
  border: 1px solid var(--c-neso-border); border-radius: var(--r-md); background: var(--c-neso-surface); color: var(--c-text);
  font-weight: var(--fw-bold); text-decoration: none;
}
.sb__neso:hover { color: var(--c-text); border-color: var(--c-accent); }
.sb__neso .ico { color: var(--c-accent); }
.sb__neso.on { border-color: var(--c-accent); box-shadow: inset 0 0 0 1px var(--c-accent); }
.sb__neso kbd { margin-left: auto; font: inherit; font-size: var(--fs-xs); color: var(--c-text-3); border: 1px solid var(--c-border-strong); border-radius: var(--r-xs); padding: 0 var(--sp-2); line-height: 18px; }

.sb__nav { display: flex; flex-direction: column; gap: var(--sp-1); margin-top: var(--sp-5); }
.sb__label { margin: var(--sp-5) var(--sp-3) var(--sp-2); color: var(--c-text-3); font-size: var(--fs-xs); font-weight: var(--fw-bold); }
.sb__link {
  position: relative; display: flex; align-items: center; gap: var(--sp-4); min-height: var(--tap); padding: 0 var(--sp-3);
  border-radius: var(--r-sm); color: var(--c-text-2); text-decoration: none; font-weight: var(--fw-bold); font-size: var(--fs-body);
}
.sb__link .ico { color: var(--c-text-3); }
.sb__link:hover { background: var(--c-surface-sunken); color: var(--c-text); }
.sb__link.on { background: var(--c-surface); color: var(--c-text); box-shadow: inset 0 0 0 1px var(--c-border); }
.sb__link.on .ico { color: var(--c-accent); }
.sb__link.on::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c-accent); }
.sb__count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full); background: var(--c-danger); color: var(--c-text-inverse); font-size: var(--fs-xs); font-weight: var(--fw-bold); display: inline-grid; place-items: center; }
:root[data-theme="dark"] .sb__count { color: var(--c-bg); }
.sb__foot { margin-top: auto; padding-top: var(--sp-4); border-top: 1px solid var(--c-border); display: flex; flex-direction: column; gap: var(--sp-1); }

/* ── capçalera ── */
.tb {
  /* per sobre de la barra lateral: el menú del compte i el del restaurant hi viuen a dins */
  position: sticky; top: 0; z-index: calc(var(--z-nav) + 1); height: var(--header-h); padding-top: env(safe-area-inset-top);
  /* sense backdrop-filter: crearia un bloc contenidor i el menú fix (position: fixed) hi quedaria tancat */
  box-sizing: content-box; background: color-mix(in srgb, var(--c-bg) 97%, transparent);
  border-bottom: 1px solid var(--c-border);
}
.tb__in { display: flex; align-items: center; gap: var(--sp-4); height: 100%; padding: 0 var(--content-pad); max-width: var(--content-max); }
.tb__logo { display: none; align-items: center; color: var(--c-brand); flex: none; min-width: 36px; min-height: 36px; }
.tb__logo .brand-icon { width: 24px; height: 24px; display: block; }
.tb__where { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; flex: 1; }
.tb__title { font-family: var(--font-ui); font-weight: var(--fw-bold); font-size: var(--fs-h3); color: var(--c-text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; display: none; }
.tb__end { display: flex; align-items: center; gap: var(--sp-3); flex: none; }
.tb__fonts { display: flex; gap: var(--sp-3); align-items: center; min-width: 0; }
/* el selector de restaurant, quan app.js el mou a la capçalera (mòbil): un xip */
.sb__local-slot, .tb__local-slot { display: contents; }
.tb .sb__local { position: relative; width: auto; max-width: 40vw; min-height: 32px; gap: var(--sp-2); padding: 0 var(--sp-3); border-color: var(--c-border-strong); border-radius: var(--r-full); font-size: var(--fs-sm); }
.tb .sb__local::after { content: ""; position: absolute; inset: -7px -2px; }
.tb .sb__local .avatar, .tb .sb__local .sb__local-sub { display: none; }

/* «Pregunta a la Neso» per veu (veu.js en dibuixa el contingut) */
.hd__veu {
  display: inline-flex; align-items: center; gap: var(--sp-3); min-height: var(--ctl-h-sm); padding: 0 var(--sp-4);
  border: 1px solid var(--c-neso-border); border-radius: var(--r-sm); background: var(--c-neso-surface); color: var(--c-text);
  font-weight: var(--fw-bold); font-size: var(--fs-sm);
}
.hd__veu svg { width: 16px; height: 16px; }

/* compte */
.account-shell { position: relative; flex: none; }
.account-shell > summary { list-style: none; display: inline-flex !important; align-items: center; justify-content: center; }
.account-shell > summary::-webkit-details-marker { display: none; }
.account-shell > summary::marker { content: ""; }
.hd__compte {
  position: relative; width: 32px; height: 32px; border-radius: var(--r-full); padding: 0; border: 1px solid var(--c-border-strong);
  background: var(--c-brand); color: var(--c-on-brand); font-size: var(--fs-xs); font-weight: var(--fw-bold); letter-spacing: .02em; cursor: pointer;
}
.hd__compte::after { content: ""; position: absolute; inset: -7px; }
.hd__compte:hover { box-shadow: 0 0 0 3px var(--c-brand-subtle); }
.hd__compte #compteText { display: block; line-height: 1; }

.menu {
  position: fixed; z-index: var(--z-dropdown); top: calc(var(--header-h) + env(safe-area-inset-top) + 4px); right: var(--sp-5);
  width: min(320px, calc(100vw - 32px)); max-height: calc(100dvh - 80px); overflow-y: auto; display: none;
  padding: var(--sp-2); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); box-shadow: var(--e-2);
}
.menu--sb { right: auto; left: var(--sp-4); top: calc(var(--header-h) + 56px); }
.account-shell[open] .menu, .menu.on { display: block; animation: ds-in var(--dur-1) var(--ease); }
.menu__cap { padding: var(--sp-4); display: flex; gap: var(--sp-4); align-items: center; }
.menu__nom { font-weight: var(--fw-bold); }
.menu__sub { color: var(--c-text-3); font-size: var(--fs-sm); word-break: break-all; }
.menu__pill { margin-top: var(--sp-2); display: inline-block; line-height: var(--lh-xs); font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--c-text-2); background: var(--c-surface-subtle); border-radius: var(--r-xs); padding: 1px var(--sp-3); }
.menu__grup { padding: var(--sp-2) 0; border-top: 1px solid var(--c-border); }
.menu__et { font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--c-text-3); padding: var(--sp-3) var(--sp-4) var(--sp-2); }
.menu__it {
  display: flex; align-items: center; gap: var(--sp-4); width: 100%; min-height: var(--tap); padding: 0 var(--sp-4);
  border: 0; border-radius: var(--r-sm); background: none; color: var(--c-text); text-align: left; text-decoration: none; font-size: var(--fs-body); cursor: pointer;
}
.menu__it .ico { color: var(--c-text-3); }
.menu__it:hover { background: var(--c-surface-subtle); color: var(--c-text); }
.menu__it.on { font-weight: var(--fw-bold); }
.menu__it.on::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-radius: var(--r-full); background: var(--c-accent); }
.menu__it--fluix { color: var(--c-text-2); }
.menu__info { padding: 0 var(--sp-4) var(--sp-3); font-size: var(--fs-body); color: var(--c-text); }
.menu__tema { padding: var(--sp-2) var(--sp-4) var(--sp-3); }
.menu__tema .segmented { width: 100%; }
.menu__tema .segmented__it { flex: 1; }

/* ── contingut ── */
.main { min-width: 0; }
.page-tabs { padding: var(--sp-5) var(--content-pad) 0; max-width: var(--content-max); }
.page-tabs:empty { display: none; }
.wrap { width: 100%; min-width: 0; max-width: var(--content-max); padding: var(--sp-7) var(--content-pad) var(--sp-11); }
.page-tabs:not(:empty) + .wrap { padding-top: var(--sp-6); }
.view { min-width: 0; animation: ds-fade var(--dur-2) var(--ease); }
@keyframes ds-fade { from { opacity: .4; } to { opacity: 1; } }
@keyframes ds-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ── sense connexió (bàner fix a sota de la capçalera) ── */
.xarxa {
  position: sticky; top: calc(var(--header-h) + env(safe-area-inset-top) + 1px); z-index: calc(var(--z-sticky) - 1);
  display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; padding: var(--sp-3) var(--content-pad);
  background: var(--c-warning-bg); color: var(--c-warning); border-bottom: 1px solid var(--c-warning-border); font-size: var(--fs-sm); line-height: var(--lh-sm);
}
.xarxa[hidden] { display: none; }
.xarxa__punt { width: 8px; height: 8px; border-radius: var(--r-full); background: currentColor; flex: none; }
.xarxa__text { min-width: 0; }
.xarxa__cua { margin-left: auto; padding: 1px var(--sp-3); border-radius: var(--r-xs); background: var(--c-surface); border: 1px solid var(--c-warning-border); font-weight: var(--fw-bold); white-space: nowrap; }

/* ── pestanyes de baix (mòbil) ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-nav); display: none;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar__in { display: flex; max-width: 560px; margin: 0 auto; }
.tabbar__more { flex: 1; min-width: 0; display: flex; }
.tabbar__more > summary { list-style: none; }
.tabbar__more > summary::-webkit-details-marker { display: none; }
.tab {
  flex: 1; min-width: 0; min-height: var(--tabbar-h); position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-1); color: var(--c-text-3); text-decoration: none; font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: var(--lh-xs);
}
.tab .ico { width: 22px; height: 22px; }
.tab:hover { color: var(--c-text); }
.tab.on { color: var(--c-text); }
.tab.on .ico { color: var(--c-accent); }
.tab.on::before { content: ""; position: absolute; top: 0; left: 50%; width: 28px; height: 3px; margin-left: -14px; border-radius: 0 0 3px 3px; background: var(--c-accent); }
.tab__n { position: absolute; top: 6px; left: 50%; margin-left: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full); background: var(--c-danger); color: var(--c-surface); font-size: var(--fs-xs); font-weight: var(--fw-bold); display: grid; place-items: center; }
.tab--more { border: 0; background: transparent; cursor: pointer; font-family: inherit; }
.tab--neso { color: var(--c-text); }
.tab__neso {
  display: grid; place-items: center; width: 48px; height: 48px; margin-top: -20px; border-radius: var(--r-full);
  background: var(--c-brand); color: var(--c-on-brand); box-shadow: var(--e-2), 0 0 0 4px var(--c-surface); transition: transform var(--dur-1) var(--ease);
}
.tab__neso .ico { width: 24px; height: 24px; color: inherit !important; }
.tab--neso.on::before { display: none; }
.tab--neso.on .tab__neso { background: var(--c-accent); }
.tab--neso:active .tab__neso { transform: scale(.95); }

/* ── «Més»: un full a tota l'alçada amb totes les àrees ── */
.mobile-nav { display: none; }
.mobile-nav__head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); padding: var(--sp-2) 0 var(--sp-4); }
.mobile-nav__head b { font-size: var(--fs-h2); }
.mobile-nav__groups { display: flex; flex-direction: column; gap: var(--sp-5); }
.mobile-nav__label { color: var(--c-text-3); font-size: var(--fs-xs); font-weight: var(--fw-bold); margin: 0 var(--sp-3) var(--sp-2); }
.mobile-nav__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-2); }
.mobile-nav__grid a, .mobile-nav__grid button {
  display: flex; align-items: center; gap: var(--sp-4); min-width: 0; min-height: 48px; padding: 0 var(--sp-4);
  border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface); color: var(--c-text);
  text-decoration: none; font-weight: var(--fw-bold); font-size: var(--fs-body); text-align: left;
}
.mobile-nav__grid a .ico, .mobile-nav__grid button .ico { color: var(--c-text-3); }
.mobile-nav__grid a.on { border-color: var(--c-accent); background: var(--c-accent-subtle); }
.mobile-nav__grid a.on .ico { color: var(--c-accent); }
.mobile-nav__grid--1 { grid-template-columns: minmax(0, 1fr); }

/* ══ RESPONSIVE DEL SHELL ═══════════════════════════════════════════════════ */

@media (min-width: 1024px) {
  body:not(.sense-xrome) { padding-left: var(--sidebar-w); }
}
/* tauleta: barra lateral d'icones */
@media (min-width: 640px) and (max-width: 1023px) {
  body:not(.sense-xrome) { padding-left: var(--sidebar-w-collapsed); }
  .sb { width: var(--sidebar-w-collapsed); padding: 0 var(--sp-3) var(--sp-4); align-items: center; }
  .sb__brand { padding: 0; justify-content: center; }
  .sb__brand .brand-wordmark, .sb__local-text, .sb__local .ico, .sb__neso span, .sb__neso kbd, .sb__label, .sb__link span, .sb__count { display: none !important; }
  .sb__local { width: auto; border: 0; background: none; padding: 0; justify-content: center; }
  .sb__neso { width: var(--ctl-h); padding: 0; justify-content: center; }
  .sb__link { width: var(--ctl-h); justify-content: center; padding: 0; }
  .sb__link.on::before { left: -8px; }
  .sb__nav, .sb__foot { align-items: center; width: 100%; }
  .menu--sb { left: calc(var(--sidebar-w-collapsed) + 8px); top: 60px; }
  .tb__title { display: block; }
}
/* mòbil: capçalera amb títol, pestanyes a baix */
@media (max-width: 639px) {
  :root { --content-pad: var(--content-pad-m); }
  body:not(.sense-xrome) { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .sb { display: none; }
  .tabbar { display: block; }
  .tb__in { gap: var(--sp-3); }
  .tb__logo { display: inline-flex; }
  .tb__title { display: block; }
  .tb__where .crumbs { display: none; }
  .tb__fonts, .hd__veu { display: none !important; }
  .menu { right: var(--sp-4); }
  .menu--sb { left: auto; right: var(--sp-4); top: calc(var(--header-h) + env(safe-area-inset-top) + 4px); }
  body.nav-oberta { overflow: hidden; }
  .tabbar__more[open] .mobile-nav {
    display: block; position: fixed; inset: env(safe-area-inset-top) 0 calc(var(--tabbar-h) + env(safe-area-inset-bottom)) 0; z-index: var(--z-sheet);
    overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-5) var(--sp-5) var(--sp-8);
    background: var(--c-bg); border-bottom: 1px solid var(--c-border); animation: ds-sheet-up var(--dur-2) var(--ease);
  }
  .page-tabs { padding-top: var(--sp-3); }
  .wrap { padding-top: var(--sp-5); }
}
@keyframes ds-sheet-up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 1023px) { .tb__where .crumbs { display: none; } }

/* les pantalles d'accés no porten shell */
body.sense-xrome .sb, body.sense-xrome .tb, body.sense-xrome .tabbar, body.sense-xrome .page-tabs { display: none !important; }
body.sense-xrome .wrap { max-width: none; padding: 0; }

/* instal·lació de la PWA */
.install {
  position: fixed; left: var(--sp-5); right: var(--sp-5); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-4)); z-index: var(--z-toast);
  display: flex; gap: var(--sp-4); align-items: center; padding: var(--sp-5); border-radius: var(--r-lg);
  background: var(--c-surface); color: var(--c-text); border: 1px solid var(--c-border); box-shadow: var(--e-3);
}
.install p { flex: 1; font-size: var(--fs-sm); line-height: var(--lh-sm); }
.install button { min-height: var(--ctl-h-sm); padding: 0 var(--sp-4); border-radius: var(--r-sm); border: 1px solid var(--c-border-input); background: var(--c-surface); font-weight: var(--fw-bold); }
.install .si { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); }
@media (min-width: 640px) { .install { left: auto; right: var(--sp-7); bottom: var(--sp-7); width: 380px; } }

/* ══ PLANTILLES DE PÀGINA ═══════════════════════════════════════════════════ */

.stack { display: flex; flex-direction: column; gap: var(--gap, var(--sp-5)); min-width: 0; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--sp-3)); min-width: 0; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--gap, var(--sp-5)); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 768px) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.t-overview, .t-detail { display: grid; gap: var(--sp-7); grid-template-columns: minmax(0, 1fr); }
.t-overview > .page-header, .t-overview > .kpis, .t-detail > .page-header, .t-overview > .banner, .t-detail > .banner { grid-column: 1 / -1; }
@media (min-width: 1024px) {
  .t-overview, .t-detail { grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); align-items: start; }
  .t-side { position: sticky; top: calc(var(--header-h) + var(--sp-5)); }
}
.t-main, .t-side { display: flex; flex-direction: column; gap: var(--sp-5); min-width: 0; }
.t-list { display: flex; flex-direction: column; gap: var(--sp-5); }
.t-planner { display: flex; flex-direction: column; gap: var(--sp-5); }
.planner { overflow-x: auto; border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); }
.planner table { width: 100%; }
.planner th:first-child, .planner td:first-child { position: sticky; left: 0; z-index: 1; background: var(--c-surface); }
.t-form { max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--sp-5); }
.savebar {
  position: sticky; bottom: 0; z-index: var(--z-sticky); display: flex; gap: var(--sp-3); justify-content: flex-end;
  padding: var(--sp-4) 0; background: var(--c-bg);
}
/* El fos és a sobre de la barra: quan salta a dues línies (mòbil), el que hi ha a dins mai no queda damunt del contingut. */
.savebar::before { content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: var(--sp-5); background: linear-gradient(to top, var(--c-bg), transparent); pointer-events: none; }
@media (max-width: 639px) { .savebar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); } .savebar .button { flex: 1; } }
.t-settings { display: grid; gap: var(--sp-7); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .t-settings { grid-template-columns: 200px minmax(0, 1fr); } }
.settings-nav { display: flex; flex-direction: column; gap: var(--sp-1); }
.settings-nav a { display: flex; align-items: center; min-height: var(--tap); padding: 0 var(--sp-4); border-radius: var(--r-sm); color: var(--c-text-2); text-decoration: none; font-weight: var(--fw-bold); }
.settings-nav a:hover { background: var(--c-surface-subtle); color: var(--c-text); }
.settings-nav a[aria-current] { background: var(--c-surface); color: var(--c-text); box-shadow: inset 0 0 0 1px var(--c-border); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.toolbar__grow { flex: 1 1 220px; min-width: 0; }

/* ══ COMPONENTS ═════════════════════════════════════════════════════════════ */

/* ── botons ── */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-3); min-height: var(--ctl-h); max-width: 100%;
  padding: 0 var(--sp-5); border: 1px solid transparent; border-radius: var(--r-sm);
  font-family: var(--font-ui); font-size: var(--fs-body); font-weight: var(--fw-bold); line-height: 1.2; text-align: center; text-decoration: none; white-space: normal;
  cursor: pointer; transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.button .ico { margin-left: -2px; }
.button--sm { min-height: var(--ctl-h-sm); padding: 0 var(--sp-4); font-size: var(--fs-sm); gap: var(--sp-2); }
.button--lg { min-height: var(--ctl-h-lg); padding: 0 var(--sp-7); }
.button--block { width: 100%; }
.button--primary { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); }
.button--primary:hover { background: var(--c-brand-hover); border-color: var(--c-brand-hover); color: var(--c-on-brand); }
.button--secondary { background: var(--c-surface); border-color: var(--c-border-input); color: var(--c-text); }
.button--secondary:hover { background: var(--c-surface-subtle); color: var(--c-text); }
.button--ghost { background: transparent; color: var(--c-text-2); }
.button--ghost:hover { background: var(--c-surface-subtle); color: var(--c-text); }
.button--danger { background: var(--c-danger); border-color: var(--c-danger); color: var(--c-text-inverse); }
.button--danger:hover { filter: brightness(.94); color: var(--c-text-inverse); }
:root[data-theme="dark"] .button--danger { color: var(--c-bg); }
.button--neso { background: var(--c-neso-surface); border-color: var(--c-neso-border); color: var(--c-text); }
.button--neso:hover { border-color: var(--c-accent); color: var(--c-text); }
.button--neso .ico { color: var(--c-accent); }
.button--link { background: none; border: 0; padding: 0; min-height: auto; color: var(--c-accent); text-decoration: underline; text-underline-offset: 2px; }
.button:disabled, .button[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.button.is-loading { cursor: progress; opacity: .85; }

.icon-button {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); flex: none; padding: 0;
  border: 1px solid transparent; border-radius: var(--r-sm); background: transparent; color: var(--c-text-2); cursor: pointer;
}
.icon-button:hover { background: var(--c-surface-subtle); color: var(--c-text); }
.icon-button--secondary { border-color: var(--c-border-input); background: var(--c-surface); }
.icon-button--sm { width: var(--ctl-h-sm); height: var(--ctl-h-sm); }

.actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; margin-top: var(--sp-5); }
.actions--end { justify-content: flex-end; }
@media (max-width: 639px) { .actions > .button { flex: 1 1 auto; } }

.spinner { width: 16px; height: 16px; flex: none; border-radius: var(--r-full); border: 2px solid currentColor; border-right-color: transparent; animation: ds-spin .7s linear infinite; }
@keyframes ds-spin { to { transform: rotate(360deg); } }

/* ── engrunes ── */
.crumbs ol { display: flex; align-items: center; flex-wrap: wrap; gap: var(--sp-2); margin: 0; padding: 0; list-style: none; font-size: var(--fs-sm); line-height: var(--lh-sm); }
.crumbs li { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--c-text-3); min-width: 0; }
.crumbs li + li::before { content: "/"; color: var(--c-border-strong); }
.crumbs a { color: var(--c-text-2); text-decoration: none; font-weight: var(--fw-bold); }
.crumbs a:hover { color: var(--c-text); text-decoration: underline; }
.crumbs [aria-current] { color: var(--c-text); font-weight: var(--fw-bold); }
.tb .crumbs ol { font-size: var(--fs-body); }

/* ── capçalera de pàgina ── */
.page-header { display: flex; flex-direction: column; gap: var(--sp-4); margin-bottom: var(--sp-7); }
.page-header__row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-5); flex-wrap: wrap; }
.page-header__text { min-width: 0; flex: 1 1 320px; }
.page-header__title { font-family: var(--font-display); font-weight: var(--fw-display); font-size: var(--fs-h1); line-height: var(--lh-h1); }
.page-header__subtitle { margin-top: var(--sp-2); color: var(--c-text-2); max-width: var(--reading-max); }
.page-header__meta { margin-top: var(--sp-3); display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; color: var(--c-text-3); font-size: var(--fs-sm); }
.page-header__actions { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.page-header .tabs { margin-top: var(--sp-2); }
@media (max-width: 639px) {
  .page-header__title { font-size: 1.375rem; line-height: 1.75rem; }
  .page-header__actions { width: 100%; }
}

/* ── pestanyes ── */
.tabs { position: relative; border-bottom: 1px solid var(--c-border); }
.tabs__list { display: flex; gap: var(--sp-6); overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent); mask-image: linear-gradient(to right, black calc(100% - 24px), transparent); }
.tabs__list::-webkit-scrollbar { display: none; }
@media (min-width: 640px) { .tabs__list { -webkit-mask-image: none; mask-image: none; } }
.tabs__it {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: var(--sp-3); min-height: 40px; padding: 0 var(--sp-1);
  color: var(--c-text-2); text-decoration: none; font-weight: var(--fw-bold); white-space: nowrap; overflow-wrap: normal;
}
.tabs__it:hover { color: var(--c-text); }
.tabs__it.is-active { color: var(--c-text); }
.tabs__it.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--c-accent); }
.tabs__n { min-width: 20px; height: 20px; padding: 0 var(--sp-2); border-radius: var(--r-full); background: var(--c-surface-sunken); color: var(--c-text-2); font-size: var(--fs-xs); display: inline-grid; place-items: center; }
@media (pointer: coarse) { .tabs__it { min-height: 44px; } }

/* ── control segmentat ── */
.segmented { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r-sm); background: var(--c-surface-sunken); max-width: 100%; overflow-x: auto; }
.segmented__it { position: relative; display: inline-flex; flex: none; }
.segmented__it input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented__it span { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); width: 100%; min-height: 32px; padding: 0 var(--sp-4); border-radius: var(--r-xs); color: var(--c-text-2); font-weight: var(--fw-bold); font-size: var(--fs-sm); white-space: nowrap; overflow-wrap: normal; }
.segmented__it input:checked + span { background: var(--c-surface); color: var(--c-text); box-shadow: var(--e-1), inset 0 0 0 1px var(--c-border); }
.segmented__it input:focus-visible + span { outline: 2px solid var(--c-focus); outline-offset: 1px; }
.segmented--sm .segmented__it span { min-height: 28px; padding: 0 var(--sp-3); }
@media (pointer: coarse) { .segmented__it span, .segmented--sm .segmented__it span { min-height: var(--tap); } }

/* ── targetes ── */
.card { min-width: 0; max-width: 100%; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: var(--sp-6); }
.card + .card { margin-top: var(--sp-5); }
.stack > .card + .card, .grid-2 > .card + .card, .grid-3 > .card + .card, .grid-4 > .card + .card, .t-main > .card + .card, .t-side > .card + .card { margin-top: 0; }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.card__titles { min-width: 0; }
.card__title { font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: var(--fw-bold); }
.card__subtitle { margin-top: var(--sp-1); color: var(--c-text-3); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.card__actions { display: flex; gap: var(--sp-2); flex: none; }
.card__foot { margin-top: var(--sp-5); padding-top: var(--sp-5); border-top: 1px solid var(--c-border); display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.card--flush { padding: 0; overflow: hidden; }
.card--flush > .card__head { padding: var(--sp-5) var(--sp-6) 0; }
.card--flush > .card__foot { margin: 0; padding: var(--sp-4) var(--sp-6); }
.card--neso { background: var(--c-neso-surface); border-color: var(--c-neso-border); }
.card--warning { background: var(--c-warning-bg); border-color: var(--c-warning-border); }
.card--danger { border-color: var(--c-danger-border); }
.card--success { background: var(--c-success-bg); border-color: var(--c-success-border); }
@media (max-width: 639px) { .card { padding: var(--sp-5); } }

/* ── la veu de la Neso ── */
.insight { display: flex; gap: var(--sp-4); padding: var(--sp-5) var(--sp-6); border: 1px solid var(--c-neso-border); border-radius: var(--r-lg); background: var(--c-neso-surface); }
.insight__mark { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-full); background: var(--c-brand); color: var(--c-neso); }
/* En fosc el petroli de la marca és menta (com el traç): la marca de la Neso s'omple de menta amb el traç fosc, com el botó de la Neso de la barra. */
:root[data-theme="dark"] .insight__mark { background: var(--c-neso); color: var(--c-on-brand); }
.insight__body { min-width: 0; flex: 1; }
.insight__eyebrow { color: var(--c-accent); font-size: var(--fs-sm); font-weight: var(--fw-bold); line-height: var(--lh-sm); }
.insight__title { margin-top: var(--sp-1); font-size: var(--fs-h3); line-height: var(--lh-h3); font-weight: var(--fw-bold); color: var(--c-text); }
.insight__text { margin-top: var(--sp-2); color: var(--c-text-2); max-width: var(--reading-max); }
.insight .actions { margin-top: var(--sp-4); }
.insight .perque { margin-top: var(--sp-3); }

/* ── targeta de decisió ── */
.decision-card { padding: var(--sp-5) var(--sp-6); border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); }
.decision-card__meta { display: flex; align-items: center; gap: var(--sp-3); min-height: 28px; }
.decision-card__area { display: inline-flex; align-items: center; gap: var(--sp-2); color: var(--c-text-2); font-size: var(--fs-sm); font-weight: var(--fw-bold); }
.decision-card__area .ico { color: var(--c-accent); }
.decision-card__menu { margin-left: auto; }
.decision-card__title { margin-top: var(--sp-3); font-size: var(--fs-h3); line-height: var(--lh-h3); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.decision-card .kv { margin-top: var(--sp-3); }
.decision-card .actions { margin-top: var(--sp-4); }

/* ── clau / valor ── */
.kv { margin: 0; display: flex; flex-direction: column; }
.kv__row { display: grid; grid-template-columns: minmax(96px, 30%) minmax(0, 1fr); gap: var(--sp-4); padding: var(--sp-3) 0; border-top: 1px solid var(--c-border); }
.kv__row:first-child { border-top: 0; }
.kv dt { color: var(--c-text-3); font-size: var(--fs-sm); line-height: var(--lh-body); }
.kv dd { margin: 0; color: var(--c-text); min-width: 0; }

/* ── KPI ── */
.kpis { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .kpis--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .kpis--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpis--1 { grid-template-columns: minmax(0, 1fr); }
.kpi { display: flex; flex-direction: column; gap: var(--sp-2); min-width: 0; padding: var(--sp-5); border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); color: var(--c-text); text-decoration: none; }
.kpi--link:hover { border-color: var(--c-border-strong); color: var(--c-text); }
.kpi__label { color: var(--c-text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.kpi__value { font-family: var(--font-num); font-weight: var(--fw-display); font-size: var(--fs-kpi); line-height: var(--lh-kpi); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi__unit { margin-left: var(--sp-2); font-size: var(--fs-body); color: var(--c-text-2); font-family: var(--font-ui); font-weight: var(--fw-bold); }
.kpi__sub { color: var(--c-text-3); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.kpi__spark svg { width: 100%; height: 28px; display: block; }
.kpi__spark path { fill: none; stroke: var(--c-s1); stroke-width: 2; vector-effect: non-scaling-stroke; }
@media (max-width: 639px) { .kpi { padding: var(--sp-4); } .kpi__value { font-size: 1.5rem; line-height: 1.75rem; } }

/* ── taules ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-body); }
.table th { position: sticky; top: 0; z-index: 1; height: 40px; padding: 0 var(--sp-5); background: var(--c-surface-subtle); color: var(--c-text-2); font-size: var(--fs-sm); font-weight: var(--fw-bold); text-align: left; white-space: nowrap; border-bottom: 1px solid var(--c-border); width: var(--w, auto); }
.table td { height: 44px; padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--c-border); vertical-align: middle; color: var(--c-text); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr.is-link { cursor: pointer; }
.table tbody tr:hover td { background: var(--c-surface-subtle); }
.table__link { color: inherit; font-weight: var(--fw-bold); text-decoration: none; }
.table__link:hover { color: var(--c-accent); text-decoration: underline; }
.table--dense td { height: 36px; padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.table--dense th { height: 32px; }
@media (pointer: coarse) { .table td { height: 52px; } }
.data-table { border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); overflow: hidden; }
.card > .card__body > .data-table, .card--flush .data-table { border: 0; border-radius: 0; }
.data-table .table-list { display: none; }
@media (max-width: 639px) {
  .data-table .table-wrap { display: none; }
  .data-table .table-list { display: block; }
}

/* ── llistes ── */
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--c-border); }
.list-row { display: flex; align-items: center; gap: var(--sp-4); width: 100%; min-height: 56px; padding: var(--sp-3) var(--sp-5); color: var(--c-text); text-decoration: none; text-align: left; background: none; border: 0; }
a.list-row:hover, button.list-row:hover { background: var(--c-surface-subtle); color: var(--c-text); }
.list-row__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--c-surface-subtle); color: var(--c-text-2); flex: none; }
.list-row__main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.list-row__title { font-weight: var(--fw-bold); min-width: 0; }
.list-row__meta { color: var(--c-text-3); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.list-row__value { flex: none; font-variant-numeric: tabular-nums; font-weight: var(--fw-bold); text-align: right; }
.list-row__chev { color: var(--c-text-3); flex: none; }

/* ── formularis ── */
.field { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); min-width: 0; }
.field__label { font-size: var(--fs-sm); line-height: var(--lh-sm); font-weight: var(--fw-bold); color: var(--c-text); }
.field__opt { color: var(--c-text-3); font-weight: var(--fw-regular); }
.field__help { color: var(--c-text-3); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.field__error { display: flex; align-items: center; gap: var(--sp-2); color: var(--c-danger); font-size: var(--fs-sm); line-height: var(--lh-sm); font-weight: var(--fw-bold); }
.field__control { display: flex; align-items: stretch; min-width: 0; }
.field__control > .input { flex: 1; min-width: 0; }
.field__control > .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.field__control > .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.field__affix { display: inline-flex; align-items: center; padding: 0 var(--sp-4); border: 1px solid var(--c-border-input); background: var(--c-surface-subtle); color: var(--c-text-2); font-size: var(--fs-sm); white-space: nowrap; }
.field__affix:first-child { border-right: 0; border-radius: var(--r-sm) 0 0 var(--r-sm); }
.field__affix:last-child { border-left: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.input, .select, .textarea {
  width: 100%; min-height: var(--ctl-h); padding: 0 var(--sp-4); border: 1px solid var(--c-border-input); border-radius: var(--r-sm);
  background: var(--c-surface); color: var(--c-text); font-size: var(--fs-body); line-height: var(--lh-body);
  transition: border-color var(--dur-1) var(--ease), box-shadow var(--dur-1) var(--ease); -webkit-appearance: none; appearance: none;
}
.textarea { padding: var(--sp-3) var(--sp-4); min-height: 88px; resize: vertical; }
.input--sm { min-height: var(--ctl-h-sm); }
.input--lg { min-height: var(--ctl-h-lg); font-size: var(--fs-h2); }
.input::placeholder, .textarea::placeholder { color: var(--c-text-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--c-text-3); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--c-focus); box-shadow: 0 0 0 3px var(--c-accent-subtle); outline: none; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--c-danger); }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--c-surface-subtle); color: var(--c-text-3); cursor: not-allowed; }
.select { padding-right: var(--sp-9); background-image: linear-gradient(45deg, transparent 50%, var(--c-text-2) 50%), linear-gradient(135deg, var(--c-text-2) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
@media (pointer: coarse) { .input, .select, .textarea { font-size: 16px; } }

.checkbox { display: inline-flex; align-items: flex-start; gap: var(--sp-3); min-height: var(--tap); padding: var(--sp-2) 0; cursor: pointer; }
.checkbox input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.checkbox__box { display: grid; place-items: center; width: 18px; height: 18px; margin-top: 2px; flex: none; border: 1.5px solid var(--c-border-input); border-radius: var(--r-xs); background: var(--c-surface); color: transparent; }
.checkbox input:checked + .checkbox__box { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-surface); }
.checkbox input:focus-visible + .checkbox__box { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.checkbox__text small { display: block; color: var(--c-text-3); }
.radio-card { position: relative; display: flex; gap: var(--sp-4); align-items: flex-start; padding: var(--sp-5); border: 1px solid var(--c-border-strong); border-radius: var(--r-md); background: var(--c-surface); cursor: pointer; }
.radio-card + .radio-card { margin-top: var(--sp-3); }
.radio-card input { margin: 3px 0 0; width: 18px; height: 18px; flex: none; }
.radio-card__icon { color: var(--c-accent); }
.radio-card__text { display: flex; flex-direction: column; gap: var(--sp-1); min-width: 0; flex: 1; }
.radio-card__text span { color: var(--c-text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.radio-card:has(input:checked) { border-color: var(--c-accent); box-shadow: inset 0 0 0 1px var(--c-accent); background: var(--c-accent-subtle); }
.toggle { display: inline-flex; align-items: center; gap: var(--sp-3); min-height: var(--tap); cursor: pointer; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle__track { position: relative; width: 36px; height: 20px; flex: none; border-radius: var(--r-full); background: var(--c-border-input); transition: background var(--dur-1) var(--ease); }
.toggle__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: var(--r-full); background: var(--c-surface); transition: transform var(--dur-1) var(--ease); }
.toggle input:checked + .toggle__track { background: var(--c-accent); }
.toggle input:checked + .toggle__track::after { transform: translateX(16px); }
.toggle input:focus-visible + .toggle__track { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.date-chip { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; }
.date-chip__picker { width: auto; }

/* ── insígnies i xips ── */
.badge { display: inline-flex; align-items: center; gap: var(--sp-2); height: 20px; padding: 0 var(--sp-3); border-radius: var(--r-xs); font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 1; white-space: nowrap; overflow-wrap: normal; border: 1px solid transparent; vertical-align: middle; }
.badge__dot { width: 6px; height: 6px; border-radius: var(--r-full); background: currentColor; }
.badge--neutral { background: var(--c-surface-subtle); color: var(--c-text-2); border-color: var(--c-border); }
.badge--success { background: var(--c-success-bg); color: var(--c-success); border-color: var(--c-success-border); }
.badge--warning { background: var(--c-warning-bg); color: var(--c-warning); border-color: var(--c-warning-border); }
.badge--danger { background: var(--c-danger-bg); color: var(--c-danger); border-color: var(--c-danger-border); }
.badge--info { background: var(--c-info-bg); color: var(--c-info); border-color: var(--c-info-border); }
.badge--brand { background: var(--c-brand-subtle); color: var(--c-brand); }
.chip { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: 32px; padding: 0 var(--sp-4); border: 1px solid var(--c-border-strong); border-radius: var(--r-full); background: var(--c-surface); color: var(--c-text-2); font-size: var(--fs-sm); font-weight: var(--fw-bold); text-decoration: none; white-space: nowrap; cursor: pointer; }
.chip:hover { border-color: var(--c-text-3); color: var(--c-text); }
.chip.is-active { background: var(--c-brand-subtle); border-color: var(--c-brand); color: var(--c-brand); }
.chip__n { color: var(--c-text-3); font-variant-numeric: tabular-nums; }
@media (pointer: coarse) { .chip { min-height: var(--tap); } }

/* font de la dada (viu · cache · simulat · pendent) */
.src { display: inline-flex; align-items: center; gap: var(--sp-2); max-width: 100%; height: 24px; padding: 0 var(--sp-3); border: 1px solid var(--c-border); border-radius: var(--r-xs); background: var(--c-surface); color: var(--c-text-2); font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
.src::before { content: ""; width: 6px; height: 6px; border-radius: var(--r-full); background: var(--c-text-3); flex: none; }
.src--viu { color: var(--c-success); border-color: var(--c-success-border); background: var(--c-success-bg); }
.src--viu::before { background: var(--c-success); }
.src--simulat { border-style: dashed; color: var(--c-info); }
.src--simulat::before { background: var(--c-info); }
.src--pendent { color: var(--c-warning); border-color: var(--c-warning-border); background: var(--c-warning-bg); }
.src--pendent::before { background: var(--c-warning); }

.rating { display: inline-flex; gap: 1px; color: var(--c-border-strong); }
.rating__star.is-on { color: var(--c-warning); }
.rating__star.is-on .ico { fill: currentColor; }

.progress__head, .meter__head { display: flex; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-2); font-size: var(--fs-sm); color: var(--c-text-2); }
.progress__track, .meter__track { position: relative; height: 8px; border-radius: var(--r-full); background: var(--c-surface-sunken); overflow: visible; }
.progress__track i, .meter__track i { display: block; height: 100%; width: var(--p); border-radius: var(--r-full); background: var(--c-brand); }
.progress--accent .progress__track i, .meter--success .meter__track i { background: var(--c-accent); }
.meter--warning .meter__track i { background: var(--c-threshold); }
.meter--danger .meter__track i { background: var(--c-danger); }
.meter__target { position: absolute; top: -3px; bottom: -3px; left: var(--p); width: 2px; margin-left: -1px; background: var(--c-text); border-radius: 1px; }

.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: var(--r-full); background: var(--c-brand); color: var(--c-on-brand); font-size: var(--fs-xs); font-weight: var(--fw-bold); }
.avatar--square { border-radius: var(--r-sm); }
.avatar--sm { width: 24px; height: 24px; }
.avatar--lg { width: 40px; height: 40px; font-size: var(--fs-sm); }

/* ── buits ── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-3); padding: var(--sp-9) var(--sp-5); }
.empty__icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--r-full); background: var(--c-surface-subtle); color: var(--c-text-3); margin-bottom: var(--sp-2); }
.empty--all-clear .empty__icon { background: var(--c-success-bg); color: var(--c-success); }
.empty--error .empty__icon { background: var(--c-danger-bg); color: var(--c-danger); }
.empty__title { font-weight: var(--fw-bold); font-size: var(--fs-h3); }
.empty__body { color: var(--c-text-2); max-width: 44ch; }
.empty__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--sp-3); margin-top: var(--sp-3); }

/* ── esquelets ── */
.skeleton { display: flex; flex-direction: column; gap: var(--sp-5); }
.sk-b, .sk { display: block; height: 12px; border-radius: var(--r-xs); background: linear-gradient(90deg, var(--c-surface-sunken) 25%, var(--c-surface-subtle) 37%, var(--c-surface-sunken) 63%); background-size: 400% 100%; animation: ds-shimmer 1.4s ease infinite; }
@keyframes ds-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.sk-head { display: flex; flex-direction: column; gap: var(--sp-3); }
.sk-card { padding: var(--sp-5); border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); display: flex; flex-direction: column; gap: var(--sp-4); }
.sk-row { display: flex; gap: var(--sp-5); align-items: center; }
.sk-row--head { padding-bottom: var(--sp-3); border-bottom: 1px solid var(--c-border); }
.sk-push { margin-left: auto; }
.sk-kpis { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.sk-cols { display: grid; gap: var(--sp-5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .sk-cols { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }
.sk-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: var(--sp-3); }
.sk-cell { height: 44px; }
.sk-form { max-width: 560px; display: flex; flex-direction: column; gap: var(--sp-3); }
.sk-tall { min-height: 320px; } .sk-mid { min-height: 140px; }
.sk-w10 { width: 10%; } .sk-w20 { width: 20%; } .sk-w30 { width: 30%; } .sk-w40 { width: 40%; } .sk-w50 { width: 50%; }
.sk-w70 { width: 70%; } .sk-w80 { width: 80%; } .sk-w90 { width: 90%; } .sk-w100 { width: 100%; }
.sk-h14 { height: 14px; } .sk-h28 { height: 28px; } .sk-h40 { height: 40px; }

/* ── bàners ── */
.banner { display: flex; align-items: flex-start; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5); border: 1px solid var(--c-border); border-radius: var(--r-md); background: var(--c-surface-subtle); color: var(--c-text); }
.banner__icon { margin-top: 2px; }
.banner__text { flex: 1; min-width: 0; }
.banner__action { flex: none; }
.banner--info { background: var(--c-info-bg); border-color: var(--c-info-border); } .banner--info .banner__icon { color: var(--c-info); }
.banner--warning { background: var(--c-warning-bg); border-color: var(--c-warning-border); } .banner--warning .banner__icon { color: var(--c-warning); }
.banner--danger { background: var(--c-danger-bg); border-color: var(--c-danger-border); } .banner--danger .banner__icon { color: var(--c-danger); }
.banner--success { background: var(--c-success-bg); border-color: var(--c-success-border); } .banner--success .banner__icon { color: var(--c-success); }
@media (max-width: 639px) { .banner { flex-wrap: wrap; } .banner__action { width: 100%; padding-left: 30px; } }

/* ── menús desplegables ── */
.dropdown { position: relative; display: inline-block; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; z-index: var(--z-dropdown); top: calc(100% + 4px); min-width: 220px; margin: 0; padding: var(--sp-2); list-style: none; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-md); box-shadow: var(--e-2); animation: ds-in var(--dur-1) var(--ease); }
.dropdown--end .menu-list { right: 0; }
.dropdown--start .menu-list { left: 0; }
.menu-list__it { display: flex; align-items: center; gap: var(--sp-4); width: 100%; min-height: var(--tap); padding: var(--sp-2) var(--sp-4); border: 0; border-radius: var(--r-sm); background: none; color: var(--c-text); text-align: left; text-decoration: none; font-size: var(--fs-body); cursor: pointer; }
.menu-list__it .ico { color: var(--c-text-3); }
.menu-list__it:hover, .menu-list__it:focus-visible { background: var(--c-surface-subtle); color: var(--c-text); }
.menu-list__it.is-danger, .menu-list__it.is-danger .ico { color: var(--c-danger); }
.menu-list__t { display: flex; flex-direction: column; }
.menu-list__t small { color: var(--c-text-3); }
.menu-list__sep { height: 1px; margin: var(--sp-2) 0; background: var(--c-border); }

/* ── llista de passos ── */
.checklist { padding: var(--sp-5); border: 1px solid var(--c-border); border-radius: var(--r-lg); background: var(--c-surface); }
.checklist__head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.checklist__count { color: var(--c-text-3); font-size: var(--fs-sm); }
.checklist__steps { list-style: none; margin: var(--sp-4) 0 0; padding: 0; }
.checklist__step { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: var(--sp-4); align-items: center; padding: var(--sp-3) 0; border-top: 1px solid var(--c-border); }
.checklist__check { display: grid; place-items: center; width: 20px; height: 20px; border-radius: var(--r-full); border: 1.5px solid var(--c-border-input); color: var(--c-surface); }
.checklist__step.is-done .checklist__check { background: var(--c-success); border-color: var(--c-success); }
.checklist__step.is-done .checklist__text { color: var(--c-text-3); text-decoration: line-through; text-decoration-color: var(--c-border-strong); }
@media (max-width: 639px) { .checklist__step { grid-template-columns: 20px minmax(0, 1fr); } .checklist__step .button { grid-column: 2; justify-self: start; } }

/* ── avís breu ── */
.toast {
  position: fixed; z-index: var(--z-toast); left: 50%; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-4)); transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--sp-4); max-width: calc(100vw - 32px); min-height: 44px; padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-5);
  border-radius: var(--r-md); background: var(--c-tooltip); color: var(--c-on-tooltip); box-shadow: var(--e-2); font-size: var(--fs-body); animation: ds-toast var(--dur-2) var(--ease);
}
.toast > span:only-child, .toast__text:last-child { padding-right: var(--sp-3); }
.toast__icon { flex: none; }
.toast--success .toast__icon { color: var(--c-neso); }
.toast--danger .toast__icon { color: var(--c-danger-border); }
.toast__action, .toast button { flex: none; min-height: 32px; padding: 0 var(--sp-4); border: 0; border-radius: var(--r-sm); background: color-mix(in srgb, var(--c-on-tooltip) 16%, transparent); color: var(--c-on-tooltip); font-weight: var(--fw-bold); cursor: pointer; }
@keyframes ds-toast { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (min-width: 640px) { .toast { left: auto; right: var(--sp-7); bottom: var(--sp-7); transform: none; animation-name: ds-toast-d; } }
@keyframes ds-toast-d { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── fulls, calaixos i diàlegs ── */
html.is-modal, html.is-modal body { overflow: hidden; }
.sheet { position: fixed; inset: 0; margin: 0; padding: 0; width: 100%; max-width: 100%; height: 100%; max-height: 100%; border: 0; background: transparent; color: var(--c-text); overflow: hidden; }
.sheet::backdrop { background: var(--c-overlay); animation: ds-fade-in var(--dur-2) var(--ease); }
@keyframes ds-fade-in { from { opacity: 0; } to { opacity: 1; } }
.sheet__panel { position: absolute; display: flex; flex-direction: column; background: var(--c-surface); box-shadow: var(--e-3); outline: none; }
.sheet__handle { display: none; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-5) var(--sp-6); border-bottom: 1px solid var(--c-border); }
.sheet__title { font-size: var(--fs-h2); line-height: var(--lh-h2); }
.sheet__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--sp-6); }
.sheet__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--sp-3); padding: var(--sp-4) var(--sp-6) calc(var(--sp-4) + env(safe-area-inset-bottom)); border-top: 1px solid var(--c-border); background: var(--c-surface); }
/* escriptori: calaix a la dreta */
@media (min-width: 640px) {
  .sheet .sheet__panel { top: 0; right: 0; bottom: 0; width: 480px; max-width: 100%; animation: ds-drawer var(--dur-3) var(--ease); }
  .sheet--lg .sheet__panel { width: 640px; }
}
@keyframes ds-drawer { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
/* mòbil: full que puja de baix */
@media (max-width: 639px) {
  .sheet .sheet__panel { left: 0; right: 0; bottom: 0; max-height: 90dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; animation: ds-up var(--dur-3) var(--ease); }
  .sheet__handle { display: block; width: 36px; height: 4px; margin: var(--sp-3) auto 0; border-radius: var(--r-full); background: var(--c-border-strong); }
  .sheet__head { padding: var(--sp-3) var(--sp-5) var(--sp-4); }
  .sheet__body { padding: var(--sp-5); }
  .sheet__foot { padding-left: var(--sp-5); padding-right: var(--sp-5); }
  .sheet__foot .button { flex: 1 1 auto; }
}
@keyframes ds-up { from { transform: translateY(32px); opacity: 0; } to { transform: none; opacity: 1; } }
/* confirmació: diàleg centrat a qualsevol amplada */
.sheet.dialog .sheet__panel { inset: auto; top: 50%; left: 50%; right: auto; bottom: auto; width: min(480px, calc(100vw - 32px)); max-height: calc(100dvh - 64px); transform: translate(-50%, -50%); border-radius: var(--r-lg); animation: ds-pop var(--dur-2) var(--ease); }
.sheet.dialog .sheet__handle { display: none; }
.sheet.dialog .sheet__head { border-bottom: 0; padding-bottom: 0; }
.sheet.dialog .sheet__body { padding-top: var(--sp-3); }
.sheet.dialog .sheet__foot { border-top: 0; padding-top: 0; }
.dialog__text { color: var(--c-text-2); }
.dialog__text + .dialog__text { margin-top: var(--sp-3); }
@keyframes ds-pop { from { opacity: 0; transform: translate(-50%, -48%) scale(.98); } to { opacity: 1; transform: translate(-50%, -50%); } }

/* ── autenticació ── */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); background: var(--c-bg); }
.auth__brand { display: none; }
.auth__main { display: flex; align-items: flex-start; justify-content: center; padding: var(--sp-9) var(--sp-5); }
.auth__card { width: 100%; max-width: 420px; }
.auth__logo { display: flex; align-items: center; gap: var(--sp-3); color: var(--c-brand); }
.auth__logo .brand-icon { width: 28px; height: 28px; }
.auth__logo .brand-wordmark { width: 96px; }
.auth__logo--m { margin-bottom: var(--sp-9); }
.auth__title { font-size: var(--fs-h1); line-height: var(--lh-h1); }
.auth__subtitle { margin-top: var(--sp-3); color: var(--c-text-2); }
.auth__body { margin-top: var(--sp-7); }
.auth__foot { margin-top: var(--sp-7); padding-top: var(--sp-5); border-top: 1px solid var(--c-border); color: var(--c-text-2); font-size: var(--fs-sm); }
@media (min-width: 1024px) {
  .auth { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  .auth__brand { display: flex; flex-direction: column; justify-content: space-between; padding: var(--sp-9); background: var(--c-brand); color: var(--c-on-brand); }
  .auth__brand .auth__logo { color: var(--c-on-brand); }
  .auth__brand .brand-icon { filter: brightness(0) invert(1); }
  :root[data-theme="dark"] .auth__brand .brand-icon { filter: brightness(0); }
  @media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .auth__brand .brand-icon { filter: brightness(0); } }
  .auth .porta__marca { display: none; }
  .auth__claim { font-family: var(--font-display); font-weight: var(--fw-display); font-size: var(--fs-display); line-height: var(--lh-display); max-width: 14ch; }
  .auth__main { align-items: center; }
  .auth__logo--m { display: none; }
}

/* ══ GRÀFICS ════════════════════════════════════════════════════════════════ */
.ch { margin: 0; min-width: 0; }
.ch-title { font-weight: var(--fw-bold); margin-bottom: var(--sp-3); }
.ch-plot { position: relative; width: 100%; border-radius: var(--r-sm); }
.ch-plot:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 4px; }
.ch-svg { display: block; max-width: none; overflow: visible; }
.ch-grid { stroke: var(--c-grid); stroke-width: 1; }
.ch-lbl { fill: var(--c-text-3); font-family: var(--font-ui); font-size: 12px; font-variant-numeric: tabular-nums; }
.ch-lbl--strong { fill: var(--c-text); font-weight: var(--fw-bold); }
.ch-lbl--threshold { fill: var(--c-threshold); font-weight: var(--fw-bold); }
.ch-lbl--strong, .ch-lbl--threshold { paint-order: stroke; stroke: var(--c-surface); stroke-width: 4px; stroke-linejoin: round; }
.ch-line { fill: none; stroke: var(--ch-c); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ch-line--dashed { stroke-dasharray: 5 4; }
.ch-line--fade { opacity: .45; stroke-dasharray: 2 4; }
.ch-band { fill: var(--ch-c); opacity: .16; }
.ch-dot { fill: var(--ch-c); stroke: var(--c-surface); stroke-width: 2; }
.ch-dot--note { stroke-width: 3; }
.ch-bar { fill: var(--ch-c); }
.ch-bar--fade { opacity: .5; }
.ch-whisker { stroke: var(--c-text-2); stroke-width: 1.5; fill: none; }
.ch-closed { fill: var(--c-surface-subtle); stroke: var(--c-border); stroke-dasharray: 3 3; }
.ch-threshold { stroke: var(--c-threshold); stroke-width: 1.5; stroke-dasharray: 6 4; }
.ch-marker { stroke: var(--c-text-3); stroke-width: 1; stroke-dasharray: 2 3; }
.ch-cursor { stroke: var(--c-text-3); stroke-width: 1; }
.ch-hits rect { fill: transparent; cursor: crosshair; }
.ch-tip { position: absolute; top: -8px; z-index: 2; transform: translateY(-100%); display: flex; flex-direction: column; gap: 2px; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--c-tooltip); color: var(--c-on-tooltip); font-size: var(--fs-sm); line-height: var(--lh-sm); box-shadow: var(--e-2); pointer-events: none; white-space: nowrap; }
.ch-tip[hidden] { display: none; }
.ch-tip__row { display: flex; align-items: center; gap: var(--sp-2); }
.ch-tip__row i { width: 8px; height: 8px; border-radius: 2px; background: var(--ch-c); }
.ch-legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-5); margin-top: var(--sp-3); color: var(--c-text-2); font-size: var(--fs-sm); }
.ch-key { display: inline-flex; align-items: center; gap: var(--sp-2); }
.ch-key i { width: 14px; height: 3px; border-radius: 2px; background: var(--ch-c); }
.ch-key i.ch-key--band { height: 10px; opacity: .3; }
.ch-key i.ch-key--dashed { background: repeating-linear-gradient(90deg, var(--ch-c) 0 4px, transparent 4px 7px); }
.ch-key i.ch-key--threshold { background: repeating-linear-gradient(90deg, var(--c-threshold) 0 5px, transparent 5px 8px); }
.ch-key i.ch-key--fade { opacity: .45; }
.ch-key i.ch-key--whisker { width: 2px; height: 12px; background: var(--c-text-2); }
.ch-caption { margin-top: var(--sp-3); color: var(--c-text-2); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.ch-data { margin-top: var(--sp-3); }
.ch-data > summary { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--c-accent); font-size: var(--fs-sm); font-weight: var(--fw-bold); cursor: pointer; }
.ch-data .table-wrap { margin-top: var(--sp-3); border: 1px solid var(--c-border); border-radius: var(--r-md); max-height: 320px; }
.hbar { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--sp-3); }
.hbar__row { display: grid; grid-template-columns: minmax(80px, 30%) minmax(0, 1fr) auto; gap: var(--sp-4); align-items: center; }
.hbar__label { color: var(--c-text-2); font-size: var(--fs-sm); min-width: 0; }
.hbar__track { height: 10px; border-radius: var(--r-xs); background: var(--c-surface-subtle); overflow: hidden; }
.hbar__track i { display: block; height: 100%; width: var(--p); background: var(--ch-c); border-radius: var(--r-xs); }
.hbar__value { font-weight: var(--fw-bold); font-size: var(--fs-sm); }
.sparkline { width: 100%; height: 24px; display: block; }
.sparkline path { fill: none; stroke: var(--ch-c); stroke-width: 2; vector-effect: non-scaling-stroke; }

/* ── text dins de pàgina ──────────────────────────────────────────────────────
   Els tres textos que cada llesca de l'onada 2 havia repetit al seu ext-*.css
   (cl-, cfg-, eq-, fx-, xs-), fusionats aquí: el text secundari, el gris
   discret i la nota de peu amb els seus enllaços. */
.cl-text, .cfg-text, .eq-text, .fx-text { color: var(--c-text-2); max-width: var(--reading-max); }
.cl-mut, .eq-mut, .fx-mut { color: var(--c-text-3); }
.cl-peu, .eq-peu, .fx-peu { color: var(--c-text-3); font-size: var(--fs-sm); line-height: var(--lh-sm); max-width: var(--reading-max); }
.eq-peu, .fx-peu { margin-top: var(--sp-4); }
.cl-peu a, .eq-peu a, .fx-peu a, .xs-nota a { color: var(--c-accent); font-weight: var(--fw-bold); }

/* El mateix per al fosc del sistema (sense tema triat): abans només el cobria [data-theme="dark"]. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sb__count { color: var(--c-bg); }
  :root:not([data-theme="light"]) .button--danger { color: var(--c-bg); }
  :root:not([data-theme="light"]) .insight__mark { background: var(--c-neso); color: var(--c-on-brand); }
}

/* ── Dit (punter gruixut): cap objectiu per sota de 44 px ─────────────────────
   Els controls de mida sm ja fan 44 px (tokens.css). El que ha de conservar la
   mida visual (el logotip de la capçalera, els botons-enllaç) amplia l'àrea de
   toc amb un ::after transparent. */
@media (pointer: coarse) {
  .tb__logo { min-width: var(--tap); min-height: var(--tap); justify-content: center; }
  .button--link, .crumbs a { position: relative; }
  .button--link::after, .crumbs a::after { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: 44px; transform: translate(-50%, -50%); }
}
