/* Components · Eines internes CityXerpa
   Implementació de referència. Classes .ds-<slot>, variants amb data-variant / data-state.
   Totes les mides i colors surten de tokens.css (variables --ei-*). Mode fosc: classe .dark a <html>.
   Regla de color: blau = interfície · blau cel = identitat d'eina interna · estats = només estats · gris pissarra = dades. */

.ds, .ds * { box-sizing: border-box; }
.ds { font-family: var(--ei-font); font-size: 14px; line-height: 20px; color: var(--ei-foreground); background: var(--ei-background);
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum", "cv11"; -webkit-font-smoothing: antialiased; }
.ds ::selection { background: var(--ei-primary-soft-border); }
.ds :focus-visible { outline: none; box-shadow: 0 0 0 2px var(--ei-card), 0 0 0 4px var(--ei-primary); border-radius: var(--ei-radius-sm); }
.ds svg.ds-ico { width: 18px; height: 18px; flex: none; }
.ds svg.ds-ico[data-size="sm"] { width: 15px; height: 15px; }
.ds-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ds-nowrap { white-space: nowrap; }

/* ── Estructura de pantalla ──────────────────────────────────────────── */
/* minmax(0, 1fr): sense el 0, una taula ampla eixampla la columna i la pàgina desborda en pantalla estreta */
.ds-app { display: grid; grid-template-columns: var(--ei-sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.ds-app[data-menu="plegat"] { grid-template-columns: var(--ei-sidebar-folded-w) minmax(0, 1fr); }
.ds-main { min-width: 0; grid-column: 2; }
.ds-page { padding: 24px 32px 56px; max-width: var(--ei-content-max); }

/* ── Menú lateral ────────────────────────────────────────────────────── */
.ds-sidebar { background: var(--ei-sidebar); border-right: 1px solid var(--ei-border); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow: hidden; }
.ds-sidebar-top { display: flex; align-items: center; gap: 10px; height: var(--ei-topbar); padding: 0 14px 0 18px; border-bottom: 1px solid var(--ei-border); }
.ds-sidebar-logo { height: 22px; }
.ds-sidebar-iso { height: 26px; display: none; }
.ds-tool-tag { font-size: 12px; font-weight: 600; line-height: 16px; color: var(--ei-identity-text); background: var(--ei-identity-soft); padding: 3px 8px; border-radius: var(--ei-radius-pill); white-space: nowrap; }
.ds-sidebar-scroll { flex: 1; overflow-y: auto; padding: 8px 10px; }
.ds-nav-group { margin-bottom: 6px; }
.ds-nav-group-title { display: flex; align-items: center; width: 100%; gap: 6px; height: 30px; padding: 0 8px; border: 0; background: none; cursor: pointer;
  font: 600 12px/16px var(--ei-font); color: var(--ei-subtle-foreground); border-radius: var(--ei-radius-sm); white-space: nowrap; }
.ds-nav-group-title .ds-ico { margin-left: auto; transition: transform .15s ease-out; }
.ds-nav-group[data-state="tancat"] .ds-nav-group-title .ds-ico { transform: rotate(-90deg); }
.ds-nav-group[data-state="tancat"] .ds-nav-list { display: none; }
.ds-nav-list { display: flex; flex-direction: column; gap: 1px; }
.ds-nav-item { position: relative; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--ei-radius-sm);
  color: var(--ei-foreground); text-decoration: none; font-weight: 500; white-space: nowrap; }
.ds-nav-item .ds-ico { color: var(--ei-subtle-foreground); }
.ds-nav-item:hover { background: var(--ei-hover); }
.ds-nav-item[aria-current] { background: var(--ei-primary-soft); color: var(--ei-primary-text); font-weight: 600; }
.ds-nav-item[aria-current] .ds-ico { color: var(--ei-primary); }
.ds-nav-badge { margin-left: auto; font-size: 12px; font-weight: 600; line-height: 16px; color: var(--ei-muted-foreground); background: var(--ei-hover); padding: 1px 7px; border-radius: var(--ei-radius-pill); }
.ds-nav-count { margin-left: auto; min-width: 22px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700;
  color: var(--ei-bad-foreground); background: var(--ei-bad-background); border-radius: var(--ei-radius-pill); }
.ds-sidebar-foot { border-top: 1px solid var(--ei-border); padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.ds-sidebar-note { font-size: 12px; line-height: 17px; color: var(--ei-muted-foreground); background: var(--ei-hover); border-radius: var(--ei-radius-sm); padding: 10px; margin-bottom: 6px; }
.ds-sidebar-fold { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border: 0; background: none; border-radius: var(--ei-radius-sm);
  color: var(--ei-muted-foreground); cursor: pointer; white-space: nowrap; font: 500 14px var(--ei-font); }
.ds-sidebar-fold:hover { background: var(--ei-hover); }
.ds-user { display: flex; align-items: center; gap: 10px; padding: 6px; white-space: nowrap; }
.ds-avatar { width: 30px; height: 30px; flex: none; border-radius: 50%; background: var(--ei-hover); color: var(--ei-foreground); display: grid; place-items: center; font-weight: 700; font-size: 12.5px; }
.ds-user b { display: block; font-size: 13px; line-height: 18px; } .ds-user small { color: var(--ei-subtle-foreground); font-size: 12px; }
/* Plegat: només icones; el nom surt en una bafarada (hover i focus) */
.ds-app[data-menu="plegat"] .ds-sidebar-top { justify-content: center; padding: 0; }
.ds-app[data-menu="plegat"] .ds-sidebar-logo, .ds-app[data-menu="plegat"] .ds-tool-tag,
.ds-app[data-menu="plegat"] .ds-nav-group-title, .ds-app[data-menu="plegat"] .ds-nav-badge,
.ds-app[data-menu="plegat"] .ds-sidebar-note, .ds-app[data-menu="plegat"] .ds-user > div,
.ds-app[data-menu="plegat"] .ds-sidebar-fold > span { display: none; }
/* El nom de l'opció queda dins de l'enllaç per als lectors de pantalla, però no es veu */
.ds-app[data-menu="plegat"] .ds-nav-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ds-app[data-menu="plegat"] .ds-sidebar-iso { display: block; }
.ds-app[data-menu="plegat"] .ds-nav-group[data-state="tancat"] .ds-nav-list { display: flex; }
.ds-app[data-menu="plegat"] .ds-nav-group + .ds-nav-group { border-top: 1px solid var(--ei-border); padding-top: 6px; }
.ds-app[data-menu="plegat"] .ds-nav-item, .ds-app[data-menu="plegat"] .ds-sidebar-fold, .ds-app[data-menu="plegat"] .ds-user { justify-content: center; padding: 0; }
/* Plegat, el comptador és un punt vermell; el número continua dins per als lectors de pantalla */
.ds-app[data-menu="plegat"] .ds-nav-count { position: absolute; top: 6px; right: 10px; min-width: 0; width: 9px; height: 9px; padding: 0; font-size: 0; background: var(--ei-bad-foreground); box-shadow: 0 0 0 2px var(--ei-sidebar); }
.ds-app[data-menu="plegat"] .ds-sidebar-fold .ds-ico { transform: rotate(180deg); }
.ds-tooltip { position: fixed; z-index: 60; font-size: 13px; font-weight: 500; color: var(--ei-card); background: var(--ei-foreground); padding: 5px 10px;
  border-radius: var(--ei-radius-sm); white-space: nowrap; pointer-events: none; transform: translateY(-50%); }

/* ── Barra superior ──────────────────────────────────────────────────── */
.ds-topbar { display: flex; align-items: center; gap: 16px; height: var(--ei-topbar); padding: 0 32px; background: var(--ei-card); border-bottom: 1px solid var(--ei-border); position: sticky; top: 0; z-index: 10; }
.ds-breadcrumb { display: flex; align-items: center; gap: 6px; color: var(--ei-subtle-foreground); font-size: 13px; }
.ds-breadcrumb b { color: var(--ei-foreground); font-weight: 600; }
.ds-topbar-meta { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--ei-muted-foreground); font-size: 13px; }

/* ── Capçalera de pàgina ─────────────────────────────────────────────── */
.ds-page-header { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 24px; margin-bottom: 20px; }
.ds-page-title { margin: 0; font-size: 26px; line-height: 32px; font-weight: 700; letter-spacing: -.01em; }
.ds-page-desc { margin: 4px 0 0; color: var(--ei-muted-foreground); max-width: 75ch; }
.ds-page-actions { margin-left: auto; display: flex; gap: 8px; }

/* ── Pestanyes ───────────────────────────────────────────────────────── */
.ds-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--ei-border); margin-bottom: 24px; overflow-x: auto; }
.ds-tab { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 10px 0 12px; color: var(--ei-muted-foreground); text-decoration: none; font-weight: 500; white-space: nowrap; }
.ds-tab:hover { color: var(--ei-foreground); }
.ds-tab[aria-current], .ds-tab[aria-selected="true"] { color: var(--ei-foreground); font-weight: 600; }
.ds-tab[aria-current]::after, .ds-tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; border-radius: 2px; background: var(--ei-primary); }
.ds-tab-count { font-size: 12px; font-weight: 600; line-height: 18px; padding: 0 7px; border-radius: var(--ei-radius-pill); background: var(--ei-hover); color: var(--ei-muted-foreground); }
.ds-tab[aria-current] .ds-tab-count, .ds-tab[aria-selected="true"] .ds-tab-count { background: var(--ei-primary-soft); color: var(--ei-primary-text); }

/* ── Cal fer ara: l'únic bloc de color de la pantalla ────────────────── */
.ds-now { background: var(--ei-primary-soft); border: 1px solid var(--ei-primary-soft-border); border-radius: var(--ei-radius-lg); padding: 22px 24px;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 24px; margin-bottom: 28px; }
.ds-now-kicker { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ei-primary-text); margin-bottom: 6px; }
.ds-now-title { margin: 0 0 6px; font-size: 24px; line-height: 30px; font-weight: 700; letter-spacing: -.01em; }
.ds-now-title em { font-style: normal; color: var(--ei-bad-foreground); }
.ds-now-text { margin: 0; color: var(--ei-muted-foreground); max-width: 60ch; }
.ds-todo { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ds-todo-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--ei-radius-md); background: var(--ei-card); box-shadow: var(--ei-shadow-sm); }
.ds-todo-item > .ds-ico { width: 20px; height: 20px; }
.ds-todo-item[data-state="bad"] > .ds-ico { color: var(--ei-bad-foreground); }
.ds-todo-item[data-state="warn"] > .ds-ico { color: var(--ei-warn-foreground); }
.ds-todo-item[data-state="wait"] > .ds-ico { color: var(--ei-wait-foreground); }
.ds-todo-item[data-state="ok"] > .ds-ico { color: var(--ei-ok-foreground); }
.ds-todo-item b { display: block; font-weight: 600; }
.ds-todo-item small { color: var(--ei-muted-foreground); font-size: 13px; line-height: 18px; }
.ds-todo-item .ds-button { margin-left: auto; }
.ds-now[data-state="ok"] { background: var(--ei-card); border-color: var(--ei-border); }

/* ── Títol de zona ───────────────────────────────────────────────────── */
.ds-zone-title { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 0 0 12px; }
.ds-zone-title h3 { margin: 0; font-size: 16px; line-height: 24px; font-weight: 700; }
.ds-zone-title span { color: var(--ei-subtle-foreground); font-size: 13px; }
.ds-zone-title .ds-zone-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.ds-zone { margin-bottom: 32px; }

/* ── Xifres clau ─────────────────────────────────────────────────────── */
.ds-kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.ds-kpi { background: var(--ei-card); border: 1px solid var(--ei-border); border-radius: var(--ei-radius-lg); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
a.ds-kpi:hover { border-color: var(--ei-border-strong); }
.ds-kpi[aria-current] { border-color: var(--ei-primary); box-shadow: 0 0 0 1px var(--ei-primary); }
.ds-kpi-label { font-size: 13px; line-height: 18px; color: var(--ei-muted-foreground); font-weight: 500; }
.ds-kpi-value { font-size: 30px; line-height: 36px; font-weight: 700; letter-spacing: -.02em; }
.ds-kpi-value[data-state="bad"] { color: var(--ei-bad-foreground); }
.ds-kpi-value[data-state="ok"] { color: var(--ei-ok-foreground); }
.ds-kpi-unit { font-size: 14px; font-weight: 500; color: var(--ei-muted-foreground); margin-left: 4px; letter-spacing: 0; }
.ds-kpi-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* ── Estat (xip) i etiqueta neutra ───────────────────────────────────── */
.ds-status { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 7px; border-radius: var(--ei-radius-pill);
  font-size: 12.5px; font-weight: 600; line-height: 16px; white-space: nowrap; border: 1px solid; }
.ds-status .ds-ico { width: 15px; height: 15px; }
.ds-status[data-state="ok"]   { color: var(--ei-ok-foreground);   background: var(--ei-ok-background);   border-color: var(--ei-ok-border); }
.ds-status[data-state="warn"] { color: var(--ei-warn-foreground); background: var(--ei-warn-background); border-color: var(--ei-warn-border); }
.ds-status[data-state="bad"]  { color: var(--ei-bad-foreground);  background: var(--ei-bad-background);  border-color: var(--ei-bad-border); }
.ds-status[data-state="wait"] { color: var(--ei-wait-foreground); background: var(--ei-wait-background); border-color: var(--ei-wait-border); }
.ds-status[data-state="none"] { color: var(--ei-none-foreground); background: var(--ei-none-background); border-color: var(--ei-none-border); }
.ds-tag { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; border-radius: var(--ei-radius-pill); background: var(--ei-none-background);
  color: var(--ei-muted-foreground); font-size: 12.5px; font-weight: 600; white-space: nowrap; }

/* ── Avís ────────────────────────────────────────────────────────────── */
.ds-alert { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: var(--ei-radius-md); border: 1px solid; margin-bottom: 20px; }
.ds-alert > .ds-ico { width: 20px; height: 20px; margin-top: 1px; }
.ds-alert b { display: block; font-weight: 600; color: var(--ei-foreground); }
.ds-alert p { margin: 2px 0 0; color: var(--ei-muted-foreground); max-width: 80ch; }
.ds-alert .ds-alert-actions { margin-left: auto; display: flex; gap: 8px; align-self: center; }
.ds-alert[data-state="ok"]   { background: var(--ei-ok-background);   border-color: var(--ei-ok-border); }   .ds-alert[data-state="ok"] > .ds-ico   { color: var(--ei-ok-foreground); }
.ds-alert[data-state="warn"] { background: var(--ei-warn-background); border-color: var(--ei-warn-border); } .ds-alert[data-state="warn"] > .ds-ico { color: var(--ei-warn-foreground); }
.ds-alert[data-state="bad"]  { background: var(--ei-bad-background);  border-color: var(--ei-bad-border); }  .ds-alert[data-state="bad"] > .ds-ico  { color: var(--ei-bad-foreground); }
.ds-alert[data-state="wait"] { background: var(--ei-wait-background); border-color: var(--ei-wait-border); } .ds-alert[data-state="wait"] > .ds-ico { color: var(--ei-wait-foreground); }
.ds-alert[data-state="none"] { background: var(--ei-card); border-color: var(--ei-border); } .ds-alert[data-state="none"] > .ds-ico { color: var(--ei-subtle-foreground); }

/* ── Botons ──────────────────────────────────────────────────────────── */
.ds-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--ei-control); padding: 0 14px; border-radius: var(--ei-radius-sm);
  border: 1px solid var(--ei-border-strong); background: var(--ei-card); color: var(--ei-foreground); font: 600 13.5px/1 var(--ei-font); cursor: pointer; white-space: nowrap; text-decoration: none; }
.ds-button:hover { background: var(--ei-hover); }
.ds-button[data-variant="primary"] { background: var(--ei-primary); border-color: var(--ei-primary); color: var(--ei-primary-foreground); }
.ds-button[data-variant="primary"]:hover { filter: brightness(.94); }
.ds-button[data-variant="ghost"] { border-color: transparent; background: transparent; }
.ds-button[data-variant="danger"] { color: var(--ei-bad-foreground); border-color: var(--ei-bad-border); }
.ds-button[data-size="sm"] { height: var(--ei-control-sm); padding: 0 10px; font-size: 13px; }
.ds-button[data-size="icon"] { width: var(--ei-control-sm); height: var(--ei-control-sm); padding: 0; }
.ds-button:disabled, .ds-button[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* ── Control segmentat ───────────────────────────────────────────────── */
.ds-segmented { display: inline-flex; padding: 3px; background: var(--ei-hover); border-radius: var(--ei-radius-sm); gap: 2px; }
.ds-segmented button { border: 0; background: none; height: 28px; padding: 0 12px; border-radius: 6px; font: 600 13px var(--ei-font); color: var(--ei-muted-foreground); cursor: pointer; }
.ds-segmented button[aria-pressed="true"] { background: var(--ei-card); color: var(--ei-foreground); box-shadow: var(--ei-shadow-sm); }

/* ── Filtres ─────────────────────────────────────────────────────────── */
.ds-filters { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-bottom: 1px solid var(--ei-border); }
.ds-search { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 240px; height: var(--ei-control); padding: 0 10px; border: 1px solid var(--ei-input-border); border-radius: var(--ei-radius-sm); background: var(--ei-card); color: var(--ei-subtle-foreground); }
.ds-search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; color: var(--ei-foreground); }
.ds-search input::placeholder { color: var(--ei-subtle-foreground); }
.ds-filter { display: inline-flex; align-items: center; gap: 6px; height: var(--ei-control); padding: 0 10px; border: 1px solid var(--ei-input-border); border-radius: var(--ei-radius-sm);
  background: var(--ei-card); color: var(--ei-subtle-foreground); font: 400 14px var(--ei-font); cursor: pointer; white-space: nowrap; }
.ds-filter b { color: var(--ei-foreground); font-weight: 500; }
.ds-filter[data-state="actiu"] { border-color: var(--ei-primary); background: var(--ei-primary-soft); color: var(--ei-primary-text); }
.ds-filter[data-state="actiu"] b { color: var(--ei-primary-text); }
.ds-filters-clear { border: 0; background: none; color: var(--ei-primary-text); font: 600 13px var(--ei-font); cursor: pointer; padding: 0 6px; }

/* ── Taula ───────────────────────────────────────────────────────────── */
.ds-table-card { background: var(--ei-card); border: 1px solid var(--ei-border); border-radius: var(--ei-radius-lg); overflow: clip; }
/* Capçalera fixa sota la barra superior; per això la taula no fa scroll propi en escriptori */
.ds-table-scroll { overflow: visible; }
.ds-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.ds-table th { position: sticky; top: var(--ei-topbar); z-index: 1; text-align: left; font-size: 12.5px; font-weight: 600; line-height: 16px; color: var(--ei-muted-foreground);
  background: var(--ei-table-header); padding: 10px 16px; white-space: nowrap; border-bottom: 1px solid var(--ei-border); }
.ds-table th button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.ds-table td { height: var(--ei-row); padding: 10px 16px; border-bottom: 1px solid var(--ei-border); vertical-align: middle; }
.ds-table[data-size="dense"] td { height: var(--ei-row-dense); padding: 6px 12px; }
.ds-table tbody tr:hover td { background: var(--ei-hover); }
.ds-table tbody tr[aria-selected="true"] td { background: var(--ei-primary-soft); }
.ds-table .ds-num { text-align: right; }
.ds-table .ds-num-bad { text-align: right; font-weight: 700; color: var(--ei-bad-foreground); }
.ds-table .ds-cell-strong { font-weight: 600; }
.ds-table .ds-cell-sub { display: block; color: var(--ei-subtle-foreground); font-size: 13px; line-height: 18px; white-space: nowrap; }
.ds-table .ds-cell-text { color: var(--ei-muted-foreground); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 80ch; }
.ds-table tr.ds-row-group td { height: auto; background: var(--ei-table-header); font-size: 12.5px; font-weight: 600; color: var(--ei-muted-foreground); padding: 7px 16px; }
.ds-table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 16px; color: var(--ei-muted-foreground); font-size: 13px; }
.ds-pagination { display: inline-flex; align-items: center; gap: 6px; }

/* ── Barra de cobertura (dada sense judici + franja objectiu) ────────── */
.ds-bar { position: relative; height: 8px; border-radius: var(--ei-radius-pill); background: var(--ei-data-track); min-width: 80px; }
.ds-bar > i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: var(--ei-radius-pill); background: var(--ei-data); }
.ds-bar > u { position: absolute; top: -4px; bottom: -4px; border-radius: 4px; border: 1.5px dashed var(--ei-muted-foreground); }

/* ── Formulari ───────────────────────────────────────────────────────── */
.ds-form { display: grid; gap: 18px; max-width: 640px; }
.ds-field { display: grid; gap: 6px; }
.ds-label { font-size: 13px; font-weight: 600; line-height: 18px; color: var(--ei-foreground); }
.ds-label small { font-size: 12px; font-weight: 400; color: var(--ei-subtle-foreground); }
.ds-input, .ds-textarea, .ds-select { width: 100%; min-height: var(--ei-control); padding: 8px 10px; border: 1px solid var(--ei-input-border); border-radius: var(--ei-radius-sm);
  background: var(--ei-card); color: var(--ei-foreground); font: 400 14px/20px var(--ei-font); }
.ds-textarea { min-height: 96px; resize: vertical; }
.ds-input:focus, .ds-textarea:focus, .ds-select:focus { outline: none; border-color: var(--ei-primary); box-shadow: 0 0 0 3px var(--ei-primary-soft-border); }
.ds-input::placeholder, .ds-textarea::placeholder { color: var(--ei-subtle-foreground); }
.ds-help { font-size: 13px; line-height: 18px; color: var(--ei-subtle-foreground); }
.ds-field[data-state="error"] .ds-input, .ds-field[data-state="error"] .ds-textarea { border-color: var(--ei-bad-foreground); }
.ds-field-error { display: flex; align-items: center; gap: 6px; font-size: 13px; line-height: 18px; color: var(--ei-bad-foreground); font-weight: 500; }
.ds-form-actions { display: flex; gap: 8px; padding-top: 4px; }
.ds-fieldset { border: 1px solid var(--ei-border); border-radius: var(--ei-radius-lg); padding: 18px 20px; background: var(--ei-card); display: grid; gap: 16px; margin: 0; }
.ds-fieldset legend { font-weight: 700; padding: 0 6px; }

/* ── Fitxa de detall ─────────────────────────────────────────────────── */
.ds-detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.ds-panel { background: var(--ei-card); border: 1px solid var(--ei-border); border-radius: var(--ei-radius-lg); }
.ds-panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--ei-border); }
.ds-panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.ds-panel-head .ds-panel-actions { margin-left: auto; display: flex; gap: 6px; }
.ds-panel-body { padding: 16px 18px; }
.ds-dl { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 10px 20px; margin: 0; }
.ds-dl dt { color: var(--ei-muted-foreground); }
.ds-dl dd { margin: 0; font-weight: 500; }
.ds-detail-header { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 20px; }
.ds-id { font-weight: 600; font-size: 13px; padding: 3px 8px; border-radius: var(--ei-radius-sm); background: var(--ei-hover); }

/* ── Estats de càrrega, buit i error ─────────────────────────────────── */
.ds-empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 48px 24px; color: var(--ei-muted-foreground); }
.ds-empty .ds-ico { width: 28px; height: 28px; color: var(--ei-subtle-foreground); }
.ds-empty b { color: var(--ei-foreground); font-size: 15px; }
.ds-empty p { margin: 0; max-width: 52ch; }
.ds-skeleton { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--ei-hover), var(--ei-data-track), var(--ei-hover)); background-size: 200% 100%; animation: ds-sk 1.2s ease-in-out infinite; }
@keyframes ds-sk { from { background-position: 100% 0; } to { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) { .ds-skeleton { animation: none; } .ds-nav-group-title .ds-ico { transition: none; } }
@media (max-width: 1180px) {
  .ds-now { grid-template-columns: minmax(0, 1fr); } .ds-detail { grid-template-columns: minmax(0, 1fr); }
  /* Per sota de 1180 px una taula ampla pot no cabre: fa scroll dins de la targeta i la capçalera deixa de ser fixa */
  .ds-table-scroll { overflow-x: auto; } .ds-table th { position: static; }
}
@media (max-width: 760px) {
  .ds-topbar, .ds-page { padding-left: 16px; padding-right: 16px; }
  .ds-todo-item { flex-wrap: wrap; } .ds-todo-item .ds-button { margin-left: 32px; }
  .ds-search { min-width: 0; flex: 1 1 100%; } .ds-filter { flex: 1 1 auto; }
  .ds-dl { grid-template-columns: 1fr; gap: 2px 0; } .ds-dl dd { margin-bottom: 8px; }
}

/* Pantalla estreta (< 760 px): el menú comença plegat; en desplegar-lo, flota per sobre del contingut */
.ds-app[data-menu="superposat"] { grid-template-columns: var(--ei-sidebar-folded-w) minmax(0, 1fr); }
.ds-app[data-menu="superposat"] .ds-sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: var(--ei-sidebar-w); box-shadow: var(--ei-shadow-md); }
.ds-scrim { position: fixed; inset: 0; z-index: 39; background: rgba(15, 20, 28, .35); }
