/* Estils base del programa. Sense framework: variables, disposició i components mínims. */

:root {
  /* Amplada única de totes les pantalles, centrada (en un monitor gran no queda enganxada a l'esquerra). */
  --page-width: 100rem;
  --page-gutter: 2rem;
  /* Paleta «El Curs»: paper càlid, aigua per a l'acció, colors semàntics de sempre. */
  --bg: #f4f1ea;
  --surface: #ffffff;
  --soft: #ece7db;          /* fons suau de xips, comptadors i blocs */
  --border: #ddd6c7;
  --text: #1b292d;
  --muted: #56656a; /* prou contrast sobre blanc i sobre el fons (WCAG AA) */
  --primary: #0b6b7a;       /* «aigua»: l'acció principal */
  --primary-soft: #d3e9ec;
  --primary-text: #ffffff;
  --blue: #2a5db0;
  --todo: #66757a;
  --doing: #0b6b7a;
  --done: #256f45;
  --danger: #b42318;
  /* Paleta semàntica comuna (també la fa servir whiteboard.css). */
  --positive: #256f45;      /* marges positius, fet */
  --negative: #b42318;      /* marges negatius, vençut, comptador */
  --warning-text: #7a4700;  /* esperant, avisos */
  --warning-soft: #f8e9c8;
  --danger-soft: #fbe5e1;
  --success-soft: #dcefe2;
  --hover: #e8f2f3;         /* fons en passar per sobre o triat */
  --timer: #0b6b7a;         /* cronòmetre en marxa */
  --row-hover: #faf8f3;      /* files de llistes en passar-hi */
  --placeholder: #a9a294;
  --primary-line: #a9d0d6;  /* vores de blocs «aigua» */
  --primary-strong: #085460;
  --note-bg: #fffbeb;       /* observacions i avisos de controls */
  --note-line: #fde68a;
  --success-line: #b5dcc4;
  --danger-text: #7f1d1d;
  --danger-line: #f1b5ae;
  --folder-bg: #fdf8e8;     /* carpetes de la pissarra */
  --folder-line: #d9c07a;
  --folder-soft-line: #e4d39a;
  --folder-text: #8a6d1d;
  --folder-hover: #f3e6b5;
  --folder-file-hover: #f6edcc;
  color-scheme: light;
  --radius: 12px;
  --radius-card: 16px;
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* Tema fosc: mateixos noms, colors de nit. L'interruptor de la barra (theme.js) posa data-theme a <html>. */
:root[data-theme="dark"] {
  --bg: #121719;
  --surface: #1b2225;
  --soft: #263034;
  --border: #33403f;
  --text: #e6ecec;
  --muted: #9aa9ad;
  --primary: #4fb3c1;
  --primary-soft: #173b41;
  --primary-text: #0d1b1e;
  --blue: #86aef2;
  --todo: #93a3a8;
  --doing: #4fb3c1;
  --done: #5fc48e;
  --danger: #f28479;
  --positive: #5fc48e;
  --negative: #f28479;
  --warning-text: #f0bb5f;
  --warning-soft: #3a2f18;
  --danger-soft: #3c2421;
  --success-soft: #1c3427;
  --hover: #1d3438;
  --timer: #4fb3c1;
  --row-hover: #20292c;
  --placeholder: #6d7b7f;
  --primary-line: #2c5a61;
  --primary-strong: #7ccbd6;
  --note-bg: #30281a;
  --note-line: #6a5321;
  --success-line: #2e5a41;
  --danger-text: #f6aaa1;
  --danger-line: #6b302a;
  --folder-bg: #2f2a1c;
  --folder-line: #7d6a35;
  --folder-soft-line: #5f522c;
  --folder-text: #e2c77c;
  --folder-hover: #3d3622;
  --folder-file-hover: #3a3321;
  color-scheme: dark;
}
:root[data-theme="dark"] img:not([src$=".svg"]) { filter: brightness(.92); }

/* Manrope (OFL), de @fontsource-variable/manrope 5.3.0: només llatí i llatí ampliat. */
@font-face { font-family: Manrope; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("../fonts/manrope-latin-wght-normal.938c6e8019b6.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: Manrope; font-style: normal; font-display: swap; font-weight: 200 800;
  src: url("../fonts/manrope-latin-ext-wght-normal.6d36d5bdedfa.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
/* Focus visible a tot arreu quan es navega amb el teclat. */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
/* Només per a lectors de pantalla. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--primary); vertical-align: middle; }
/* Reserva sempre el lloc de la barra de desplaçament: canviar a una pàgina llarga no mou res. */
html { scrollbar-gutter: stable; }
body { margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }

/* Barra superior */
/* Marca, seccions en una píndola i, a la dreta, cerca, cronòmetre, «Nou» i el menú de la persona. */
/* La barra fa capa pròpia (view transition): sense z-index, el contingut de la pàgina li tapava els menús. */
.topbar { position: relative; z-index: 50; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .75rem; padding: .85rem max(var(--page-gutter), calc((100% - var(--page-width)) / 2)); }
.brand { font-weight: 800; font-size: 1.3rem; letter-spacing: -.01em; color: var(--text); display: flex; align-items: center; min-height: 44px; }
.brand:hover { text-decoration: none; }
.main-nav { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 4px; margin-left: .75rem; }
.main-nav a { display: flex; align-items: center; gap: .4rem; min-height: 40px; padding: 0 1rem; border-radius: 999px;
  color: var(--muted); font-weight: 600; white-space: nowrap; position: relative; isolation: isolate;
  transition: color .15s ease, background-color .15s ease, transform .1s ease; }
/* Fons de hover translúcid: sobre la píndola fosca que hi arriba no es veu. */
@media (hover: hover) {
  .main-nav a:not([aria-current="page"]):hover { color: var(--text); background: color-mix(in srgb, var(--text) 7%, transparent); text-decoration: none; }
}
.main-nav a:not([aria-current="page"]):active { transform: scale(.97); }
.main-nav a[aria-current="page"] { color: var(--surface); background: none; }
/* Mentre arriba la pàgina triada al menú (frontend/src/menus.js): la d'ara s'apaga i una barra avança a dalt. */
.nav-loading main { opacity: .55; transition: opacity .2s ease; }
.nav-loading .topbar::after { content: ""; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--primary);
  transform-origin: left; animation: nav-loading 8s cubic-bezier(.1, .7, .2, 1) forwards; }
@keyframes nav-loading { from { transform: scaleX(0); } to { transform: scaleX(.92); } }
/* La píndola de la secció activa: entre pàgines llisca amb una view transition (al final del fitxer). */
.nav-pill { position: absolute; inset: 0; z-index: -1; border-radius: inherit; background: var(--text); pointer-events: none; }
.main-nav .icon { flex: none; width: 18px; height: 18px; }
@media (prefers-reduced-motion: reduce) { .main-nav a { transition: none; } }
.topbar-gap { flex: 1; }
svg.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; background: none; border-radius: 50%; color: var(--muted); flex: none; }
.icon-button:hover { background: var(--soft); color: var(--text); }
/* Menús desplegables (Nou, persona). */
.menu { position: relative; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu ul { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; list-style: none; margin: 0; padding: 6px; min-width: 14rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 10px 30px rgb(0 0 0 / .16); }
.menu li > a, .menu li > button, .menu li form button { display: flex; justify-content: space-between; align-items: center; gap: .75rem; width: 100%;
  min-height: 44px; padding: 0 .75rem; border: 0; border-radius: 9px; background: none; color: var(--text); font-weight: 600; text-align: left; }
.menu li > a:hover, .menu li > button:hover, .menu li form button:hover { background: var(--soft); text-decoration: none; }
.menu .menu-label { padding: .5rem .75rem; font-size: .85rem; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.new-menu summary { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; font-weight: 700; }
.user-menu .avatar { width: 40px; height: 40px; margin: 0; border-radius: 50%; display: grid; place-items: center; background: var(--text); color: var(--surface);
  font-size: .85rem; font-weight: 700; }

/* Pàgina */
/* Totes les pàgines tenen la mateixa amplada i van centrades: res no salta en canviar de secció. */
.page { width: 100%; max-width: calc(var(--page-width) + 2 * var(--page-gutter)); margin-inline: auto; padding: 1.5rem var(--page-gutter); }
/* Els formularis omplen l'amplada amb els camps en columnes. */
form.card.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr)); gap: 0 1.25rem; }
form.card.form > :not(.field), form.card.form > .field:has(textarea) { grid-column: 1 / -1; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 1.25rem; margin-bottom: 1rem; }
.muted { color: var(--muted); }
/* Ordre únic dels botons: primer l'acció principal, després «Cancel·lar» com a enllaç. */
.actions { display: flex; gap: .75rem; align-items: center; }
/* Camp amb error en els formularis comuns. */
.has-error label { color: var(--negative); }
.has-error :is(input, select, textarea) { border-color: var(--negative); background: var(--danger-soft); }
/* Llista buida: un missatge amable, no una cel·la trista. */
.empty-state { padding: 1.5rem 1rem; text-align: center; color: var(--muted); background: var(--surface);
  border: 1px dashed var(--border); border-radius: var(--radius); margin: 0; }

/* Botons i formularis */
.button, button { font: inherit; cursor: pointer; padding: .5rem .9rem; border-radius: var(--radius); font-weight: 600;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); display: inline-block; }
.button:hover { text-decoration: none; border-color: var(--primary); }
.button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
button.link { border: 0; background: none; color: var(--primary); padding: 0; }
/* Accions secundàries (Cancel·lar, Ja assentat): grises, perquè el verd és de l'acció principal. */
.actions > .button.primary ~ a:not(.button), .acc-movement-skip button.link { color: var(--muted); }
.actions > .button.primary ~ a:not(.button):hover, .acc-movement-skip button.link:hover { color: var(--text); }
input, select, textarea { font: inherit; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 10px; max-width: 100%; background: var(--surface); color: var(--text); }
.form .field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .9rem; }
.form .field ul { list-style: none; padding: 0; margin: 0; }
.inline-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.inline-form .field { display: flex; flex-direction: column; gap: .25rem; }
.errorlist { color: var(--danger); margin: 0; padding: 0; list-style: none; font-size: .9rem; }

/* Taules */
.table { width: 100%; border-collapse: collapse; background: var(--surface); margin: 1rem 0; }
.table th, .table td { text-align: left; padding: .55rem .7rem; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; color: var(--muted); font-size: .9rem; }
.table .num { text-align: right; white-space: nowrap; }
.table input, .table select { width: 100%; }

/* Etiquetes d'estat */
.badge { display: inline-block; font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; background: var(--soft); }
.badge-todo, .badge-draft { background: var(--soft); }
.badge-doing { background: var(--warning-soft); }
.badge-done, .badge-issued { background: var(--success-soft); }
.badge-cancelled { background: var(--danger-soft); }
/* Estats de projecte: el color el tria l'usuari a l'admin. */
.status-badge { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; white-space: nowrap; }
.status-badge::before { content: ""; width: .9rem; height: .6rem; border-radius: 2px; background: var(--status-color); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .5rem 1.5rem; margin: 0 0 1rem; }
.facts dt { font-size: .78rem; color: var(--muted); }
.facts dd { margin: 0; }

/* Missatges */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.message { padding: .7rem 1rem; border-radius: var(--radius); background: var(--primary-soft); margin-bottom: .5rem; }
.message-error { background: var(--danger-soft); }
.message-warning { background: var(--warning-soft); color: var(--warning-text); }
.message-success { background: var(--success-soft); }

/* Login */
.login { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: min(380px, 92vw); text-align: center; }

/* Contenidor de la pissarra (l'interior el pinta React Flow) */
.whiteboard.expanded { position: fixed; inset: .75rem; z-index: 60; height: auto; min-height: 0;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); }
body.whiteboard-expanded { overflow: hidden; }
body.whiteboard-expanded::after { content: ""; position: fixed; inset: 0; z-index: 59; background: rgba(20, 28, 40, .35); }
.whiteboard { height: var(--whiteboard-height, 65vh); min-height: 420px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 1rem; position: relative; overflow: hidden; }

/* Explorador de projectes */
.filters { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; }
.filters input[type=search] { flex: 1 1 20rem; }
.explorer td.truncate { max-width: 22rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.explorer tfoot td { font-weight: 600; border-bottom: 0; }
.bulk-actions { display: flex; gap: .5rem; align-items: center; }

/* Fitxa de projecte */
.observations { background: var(--note-bg); border-left: 3px solid #f59e0b; padding: .5rem .8rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: 1rem 0; }
.tabs a { padding: .5rem .9rem; border-bottom: 2px solid transparent; color: inherit; }
.tabs a[aria-current="page"] { border-bottom-color: var(--primary); font-weight: 600; }
.explorer td.positive { color: var(--positive); }
.explorer td.negative { color: var(--negative); }

/* Fitxa editable: els camps semblen text fins que hi passes el ratolí o hi entres. */
.sheet-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.sheet-title { display: flex; align-items: center; gap: .75rem; flex: 1; }
.project-number { font-size: 1.6rem; font-weight: 700; color: var(--muted); }
.sheet-title .sheet-field { flex: 1; }
.sheet-title label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sheet-title textarea { font-size: 1.5rem; font-weight: 650; width: 100%; resize: none; field-sizing: content; min-height: 0; line-height: 1.3; overflow: hidden; }
.sheet-title .sheet-status { flex: none; }
.sheet-status .status-select { font-size: .9rem; font-weight: 600; padding: .3rem .8rem .3rem 1.7rem; margin: 0; border-radius: 999px;
  border: 1px solid var(--border); background-color: var(--surface);
  background-image: linear-gradient(var(--status-color), var(--status-color)) !important; background-position: .6rem center; background-size: .7rem .7rem; background-repeat: no-repeat; }

/* Blocs de la fitxa: etiqueta a l'esquerra, valor a la dreta, com una llista de propietats. */
.sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(max(21rem, calc((100% - 3rem) / 4)), 1fr)); gap: 1rem;
  margin-bottom: 1rem; }
.sheet-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem .8rem; min-width: 0; }
.sheet-card h3 { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0 0 .4rem; }
.sheet-card .sheet-field form, .sheet-row { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); align-items: center; gap: .1rem .5rem;
  min-height: 2.1rem; border-top: 1px solid var(--soft); }
.sheet-card h3 + .sheet-field form { border-top: 0; }
.sheet-row > span:first-child, .sheet-card .sheet-field label { font-size: .82rem; color: var(--muted); }
.sheet-row > span:last-child { padding: 0 .35rem; overflow-wrap: anywhere; }
.sheet-card .sheet-field .error { grid-column: 2; }
.sheet-notes { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 2fr) minmax(16rem, 1fr); gap: 0 1.5rem; }
.sheet-notes h3 { grid-column: 1 / -1; }
.sheet-notes .sheet-description form { display: block; border-top: 0; }
.sheet-notes .sheet-description label { display: none; }
.sheet-notes .sheet-description textarea { min-height: 4.5rem; }
.sheet-notes > div .sheet-field:first-child form { border-top: 0; }
.sheet-field form { display: flex; flex-direction: column; padding: .1rem 0; }
.sheet-field ::placeholder { color: var(--placeholder); }
.sheet-field label { font-size: .75rem; color: var(--muted); }
.sheet-field :is(input, select, textarea) { border-color: transparent; background: transparent; padding: .25rem .35rem; margin-left: -.35rem;
  border-radius: 6px; width: 100%; min-width: 0; transition: background .15s, border-color .15s; }
.sheet-card .sheet-field :is(input, select, textarea) { margin-left: 0; }
.sheet-field :is(input, select, textarea):hover { background: var(--soft); }
.sheet-field :is(input, select, textarea):focus { background: var(--surface); border-color: var(--primary); outline: none; }
.sheet-field.saved :is(input, select, textarea) { background: var(--success-soft); }
.sheet-field.invalid :is(input, select, textarea) { border-color: var(--danger); background: var(--danger-soft); }
.sheet-field .error { color: var(--danger); font-size: .8rem; }
.farm-info { display: contents; }
.people-chips { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; padding: .25rem 0; }
.person-chip { display: inline-flex; align-items: center; gap: .2rem; padding: .1rem .2rem .1rem .6rem; border-radius: 999px;
  background: var(--hover); border: 1px solid var(--primary-line); font-size: .85rem; }
.person-chip button { border: 0; background: none; padding: 0 .35rem; line-height: 1.2; color: var(--muted); border-radius: 999px; }
.person-chip button:hover { color: var(--danger); background: var(--danger-soft); }
.sheet-field .people-chips .add-person { width: auto; color: var(--primary); font-size: .85rem; padding: .15rem .3rem; }
.add-link { justify-self: start; margin-top: .45rem; font-size: .85rem; }
.farm-info .add-link { display: block; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .25rem .9rem; }
.form-grid > div { display: flex; flex-direction: column; min-width: 0; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid input { width: 100%; }

/* Fila ràpida: la primera fila de la taula és on s'escriu la nova entrada. */
.quick-table .quick-row td { background: var(--hover); padding: .35rem .4rem; }
.quick-table .quick-row :is(input, select) { width: 100%; padding: .3rem .4rem; }
.quick-table .quick-row input[type=number] { text-align: right; min-width: 5rem; }
.quick-table .quick-row.invalid td { background: var(--danger-soft); }
.quick-errors td { color: var(--danger); font-size: .85rem; }
.quick-errors span + span::before { content: " · "; }

/* Diàleg comú i alta ràpida */
#app-dialog { border: 0; border-radius: 12px; padding: 0; width: min(40rem, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
#app-dialog::backdrop { background: rgba(20, 28, 40, .35); }
.quick-create { display: flex; flex-direction: column; gap: .35rem; padding: 1.25rem 1.5rem; }
.quick-create label { font-size: .8rem; color: var(--muted); margin-top: .5rem; }
.quick-create textarea, .quick-create input[type=search], .quick-create select { width: 100%; }
.quick-create .actions { margin-top: 1rem; justify-content: space-between; }
.quick-create .error { color: var(--danger); margin: 0; }
/* Visites (diàleg de l'agenda i pàgina): sis columnes, els camps n'ocupen 2, 3, 4 o 6. */
.visit-dialog { padding: 1rem 1.25rem; }
.visit-dialog h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
/* .compact-form: els formularis dels expedients fan servir la mateixa graella i els mateixos camps petits. */
:is(.visit-dialog, .compact-form) .field { margin-bottom: .45rem; gap: .15rem; }
:is(.visit-dialog, .compact-form) .field label { font-size: .78rem; color: var(--muted); }
:is(.visit-dialog, .compact-form) .field :is(input, select, textarea) { width: 100%; min-width: 0; }
.visit-dialog :is(input, select, textarea) { width: 100%; min-width: 0; }
.compact-form .actions { margin-top: .35rem; }
.case-form.compact-form { max-width: 52rem; }
:is(.visit-dialog, .compact-form) .quick-dates { display: flex; gap: .25rem; margin-top: .2rem; }
:is(.visit-dialog, .compact-form) .quick-dates .button { padding: .1rem .4rem; font-size: .72rem; }
.visit-dialog .actions { margin-top: .35rem; justify-content: space-between; }
.visit-dialog details { margin-top: .5rem; }
.visit-dialog .small { font-size: .8rem; margin: .1rem 0 .3rem; }
.visit-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0 .7rem; }
.visit-grid .c2 { grid-column: span 2; }
.visit-grid .c3 { grid-column: span 3; }
.visit-grid .c4 { grid-column: span 4; }
.visit-grid .c6 { grid-column: span 6; }
.visit-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.visit-head p { margin: 0 0 .3rem; font-size: .88rem; }
.visit-notes { font-style: italic; }
.visit-actions { margin-top: .4rem; display: flex; flex-direction: column; }
.visit-modes { align-self: flex-end; margin: 0 0 .6rem; }
.visit-modes span { min-height: 30px; padding: 0 .7rem; font-size: .85rem; }
.visit-pane { display: none; }
.visit-actions:has([value=completar]:checked) [data-pane=completar],
.visit-actions:has([value=posposar]:checked) [data-pane=posposar],
.visit-actions:has([value=anullar]:checked) [data-pane=anullar],
.visit-actions:has([value=afegir]:checked) [data-pane=afegir],
.visit-actions:has([value=nou]:checked) [data-pane=nou],
.visit-actions:has([value=descartar]:checked) [data-pane=descartar] { display: block; }
.visit-pane .actions { justify-content: flex-end; }
.visit-close-kind { margin: 0 0 .5rem; }
#app-dialog:has(.visit-dialog) { width: min(44rem, 94vw); }
/* Safata d'entrada */
.inbox-group h2 { display: flex; align-items: center; gap: .5rem; }
.inbox-group.is-clear h2 .count { background: var(--primary-soft); color: var(--primary-strong); }
.inbox-table td { vertical-align: top; }
.inbox-when { width: 6.5rem; white-space: nowrap; }
.inbox-proposal { margin-top: .25rem; font-size: .88rem; }
.inbox-proposal.is-ai .icon, .inbox-proposal-box.is-ai b { color: var(--primary-strong); }
.inbox-proposal .icon { width: .9em; height: .9em; margin-right: .3rem; vertical-align: -.1em; }
.inbox-buttons { width: 1%; white-space: nowrap; text-align: right; }
.inbox-buttons form { display: inline; }
.inbox-more summary h2 { display: inline-flex; gap: .5rem; margin: 0; }
.inbox-more .inline-form { display: inline; margin-left: .4rem; }
.inbox-text { white-space: pre-wrap; max-height: 16rem; overflow-y: auto; padding: .6rem .75rem; margin: .3rem 0 .6rem;
  border: 1px solid var(--border); border-radius: 8px; font-size: .9rem; }
.inbox-text mark { background: var(--primary-soft); color: inherit; border-radius: 3px; padding: 0 .1em; }
.inbox-files { display: flex; flex-wrap: wrap; gap: .35rem; }
.inbox-proposal-box { margin: .2rem 0 .5rem; }
.inbox-proposal-box p { margin: .2rem 0; }
.inbox-reply { border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; margin: .3rem 0 .6rem; }
.inbox-reply p { margin: .1rem 0 .3rem; }
.inbox-reply textarea { width: 100%; }
.inbox-reply .actions { margin-top: .3rem; }
.inbox-resort { float: right; margin: 0 0 .3rem .5rem; }
.inbox-updates { border: 0; padding: 0; margin: .3rem 0; }
.inbox-settings .check { display: flex; gap: .5rem; align-items: center; margin: .3rem 0; }
#app-dialog:has(.inbox-entry) { width: min(48rem, 94vw); }
.visit-dialog :is(input[type=checkbox], input[type=radio]) { width: auto; }
.inbox-entry .check { display: flex; flex-direction: row; align-items: center; gap: .45rem; margin: .1rem 0 .35rem; font-size: .88rem; }
@media (max-width: 560px) { .visit-grid > * { grid-column: 1 / -1 !important; } }
.picker-results { display: flex; flex-direction: column; max-height: 18rem; overflow-y: auto; }
.picker-option { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: .1rem; width: 100%;
  border: 0; border-bottom: 1px solid var(--border); border-radius: 0; background: var(--surface); padding: .45rem .6rem; }
.picker-option span { font-size: .82rem; color: var(--muted); }
.picker-option:hover, .picker-option:focus { background: var(--hover); outline: none; }
.picker-option:first-child { background: var(--hover); }
.picker-new strong { color: var(--primary); }
.picker-choice { display: flex; justify-content: space-between; align-items: center; background: var(--hover);
  border: 1px solid var(--primary-line); border-radius: 6px; padding: .45rem .6rem; font-weight: 600; }
kbd { font: inherit; font-size: .72rem; padding: .05rem .3rem; border: 1px solid currentColor; border-radius: 4px; opacity: .75; }

/* Cercador global */
.global-search { padding: .75rem; }
.global-search-bar { display: flex; gap: .5rem; align-items: center; }
.global-search input { width: 100%; font-size: 1.05rem; padding: .6rem .75rem; }
.dialog-x { flex: none; width: 2.2rem; height: 2.2rem; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.dialog-x:hover { background: var(--soft); color: var(--text); }
.search-results { display: flex; flex-direction: column; margin-top: .5rem; max-height: 60vh; overflow-y: auto; }
.search-results .muted { padding: .5rem .25rem; margin: 0; font-size: .85rem; }
.search-result { display: flex; flex-direction: column; padding: .5rem .6rem; border-radius: 6px; color: var(--text); }
.search-result:hover, .search-result:focus { background: var(--hover); text-decoration: none; outline: none; }
.search-result:first-child { background: var(--hover); }
.search-result span { font-size: .82rem; color: var(--muted); }
.search-result .status-badge { margin-right: .4rem; }
.status-select { border: 0; background: transparent; padding: .2rem 1.2rem .2rem 1.4rem; font-size: .85rem; cursor: pointer;
  background-image: linear-gradient(var(--status-color), var(--status-color)); background-size: .9rem .6rem;
  background-position: .2rem center; background-repeat: no-repeat; width: auto !important; }
.status-select:hover { background-color: var(--soft); }

/* Xips (opcions clicables) i fitxa de la granja triada al diàleg de nou projecte */
.chips { border: 0; padding: 0; margin: .5rem 0 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chips legend { font-size: .8rem; color: var(--muted); padding: 0; margin-bottom: .35rem; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; gap: .4rem; padding: .35rem .75rem; border: 1px solid var(--border);
  border-radius: 999px; background: var(--surface); font-size: .9rem; }
.chip:hover span { border-color: var(--primary); }
.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.chip input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.chip-status span::before { content: ""; width: .7rem; height: .7rem; border-radius: 50%; background: var(--status-color); }
.chip-status input:checked + span { background: color-mix(in srgb, var(--status-color) 18%, var(--surface)); color: var(--text);
  border-color: var(--status-color); }
.picker-card { border: 1px solid var(--primary-line); border-top: 0; border-radius: 0 0 6px 6px; padding: .5rem .6rem; font-size: .88rem; }
.picker-card-facts { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; }
.picker-card-facts span { display: flex; flex-direction: column; }
.picker-card-facts small { font-size: .72rem; color: var(--muted); }
.picker-card-recent { list-style: none; margin: .5rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
.picker-card .muted { margin: .4rem 0 0; }
.picker:has(.picker-card) .picker-choice { border-radius: 6px 6px 0 0; }

/* Esquelet mentre es carrega una pestanya */
.tab-skeleton { display: flex; flex-direction: column; gap: .6rem; padding: .5rem 0; }
.tab-skeleton span { height: 2.2rem; border-radius: 6px;
  background: linear-gradient(90deg, var(--soft) 25%, var(--bg) 50%, var(--soft) 75%); background-size: 200% 100%;
  animation: skeleton 1s linear infinite; }
.tab-skeleton span:first-child { height: 2.6rem; }
@keyframes skeleton { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Explorador: files clicables i vista de targetes */
.row-link { cursor: pointer; }
.row-link:hover td { background: var(--hover); }
.explorer td.truncate a { color: inherit; }
.margin-expected { font-style: italic; }
.margin-expected small, .table tfoot small { font-size: .75em; font-weight: 400; color: var(--muted); }
  border: 1px solid var(--border); border-top: 4px solid var(--status-color); border-radius: var(--radius);
  transition: box-shadow .15s, transform .15s; }
.people { display: flex; }
.avatar { width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: .75rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--surface); }
.avatar + .avatar { margin-left: -.4rem; }

/* Fitxa plegable: plegada, una franja amb el resum; oberta, els blocs editables. */
.sheet-panel { margin-bottom: 1rem; }
.sheet-panel > summary { display: flex; align-items: center; gap: .75rem; list-style: none; cursor: pointer; padding: .55rem .9rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); user-select: none; }
.sheet-panel > summary::-webkit-details-marker { display: none; }
.sheet-panel > summary:hover { border-color: var(--border); background: var(--row-hover); }
.sheet-panel[open] > summary { margin-bottom: .75rem; }
.sheet-panel-toggle::before { content: "›"; display: inline-block; width: 1rem; font-size: 1.2rem; line-height: 1; color: var(--muted); transition: transform .15s; }
.sheet-panel[open] .sheet-panel-toggle::before { transform: rotate(90deg); }
.sheet-panel-title { flex: none; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* Comptadors del menú */
.nav-count { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; margin-left: .15rem; border-radius: 999px; background: var(--negative);
  color: #fff; font-size: .72rem; font-weight: 700; text-align: center; line-height: 1.3rem; }
.task-check { flex: none; width: 1.45rem; height: 1.45rem; padding: 0; border: 2px solid var(--placeholder); border-radius: 999px; background: var(--surface); cursor: pointer; }
.task-check:hover { border-color: var(--positive); background: var(--success-soft); }

/* Pressupost vs cost: barra de consum */
.budget-bar { display: inline-block; position: relative; width: 6rem; height: .45rem; border-radius: 999px; background: var(--soft); overflow: hidden; vertical-align: middle; }
.budget-bar i { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: #22a05a; }
.budget-bar.level-warning i { background: #e0a100; }
.budget-bar.level-over i { background: #c62828; }
.budget-pct { font-size: .8rem; margin-left: .35rem; color: var(--positive); }
.budget-pct.level-warning { color: var(--warning-text); }
.budget-pct.level-over { color: var(--negative); }

/* Cronòmetre: xip a la barra superior, botons ▶/■ a «Les meves tasques» i a la pissarra. */
.timer-chip { display: inline-flex; align-items: center; gap: .5rem; padding: .25rem .35rem .25rem .7rem; border-radius: 999px; background: var(--primary-soft); border: 1px solid var(--primary-line); font-size: .85rem; white-space: nowrap; }
.timer-chip a { display: inline-flex; align-items: center; gap: .4rem; color: var(--text); text-decoration: none; min-width: 0; }
.timer-task { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
.timer-chip time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--primary); }
.timer-chip button { border: 0; border-radius: 999px; background: var(--timer); color: var(--primary-text); padding: .2rem .6rem; font: inherit; font-size: .8rem; cursor: pointer; }
.timer-chip button:hover { background: var(--primary-strong); }
.timer-chip.saved { background: var(--success-soft); border-color: var(--success-line); color: var(--positive); padding-right: .7rem; }
.timer-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--timer); animation: timer-pulse 1.4s ease-in-out infinite; flex: none; }
@keyframes timer-pulse { 50% { opacity: .3; } }
.timer-button { border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); padding: .2rem .65rem; font: inherit; font-size: .8rem; cursor: pointer; white-space: nowrap; }
.timer-button:hover { border-color: var(--timer); color: var(--timer); }
.timer-button.running { background: var(--timer); border-color: var(--timer); color: var(--primary-text); }
.timer-button:disabled { opacity: .6; cursor: wait; }
@media (max-width: 1200px) {
  .main-nav a { padding: 0 .75rem; }
  .timer-task { display: none; } /* el nom de la tasca queda al títol de l'enllaç */
}

/* Cercador: tasques. Ajuda de dreceres (tecla ?). */
.search-task.done strong { color: var(--muted); text-decoration: line-through; }
.shortcuts-help { padding: 1rem 1.25rem 1.25rem; width: min(40rem, 90vw); }
.shortcuts-help header { display: flex; justify-content: space-between; align-items: center; }
.shortcuts-help h2 { margin: 0; font-size: 1.15rem; }
.shortcuts-help h3 { margin: 1rem 0 .4rem; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.shortcuts-help dl { display: grid; grid-template-columns: 14rem 1fr; gap: .35rem 1.25rem; margin: 0; }
.shortcuts-help dt { white-space: nowrap; }
.shortcuts-help dd { margin: 0; color: var(--text); }

/* Pissarra: en arrossegar no s'ha de seleccionar text (sí als camps del panell). */
.whiteboard { user-select: none; -webkit-user-select: none; }
.whiteboard input, .whiteboard textarea, .whiteboard [contenteditable], .whiteboard .viewer-text { user-select: text; -webkit-user-select: text; }

/* Controls que es repeteixen: avís per crear el proper control amb un clic. */
.nav-count-soft { background: var(--warning-soft); color: var(--warning-text); }
.nav-count[hidden] { display: none; }
.controls-notice { margin-bottom: 1.25rem; border-left: 4px solid #d97706; }
.controls-notice h2 { font-size: 1rem; margin: 0 0 .5rem; }
.controls-notice ul { list-style: none; margin: 0; padding: 0; }
.controls-notice li { display: flex; align-items: center; gap: .8rem; padding: .4rem 0; border-top: 1px solid var(--border); }
.controls-notice li:first-child { border-top: 0; }
.controls-notice li > a { font-weight: 600; }
.controls-notice li .muted { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.controls-notice-date { font-variant-numeric: tabular-nums; color: var(--warning-text); font-weight: 600; }
.controls-notice-date.overdue { color: var(--negative); }
.notice-control { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem .9rem; margin-bottom: .75rem;
  background: var(--note-bg); border: 1px solid var(--note-line); border-radius: var(--radius); }
.next-control .button { padding: .3rem .8rem; font-size: .85rem; white-space: nowrap; }
.next-control-done { color: var(--positive); font-weight: 600; white-space: nowrap; }
.notice-template { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem .9rem; margin-bottom: .75rem;
  background: var(--hover); border: 1px solid var(--primary-line); border-radius: var(--radius); }
.chip-hint { display: block; font-size: .72rem; color: var(--muted); font-weight: 400; }
.chip input:checked + span .chip-hint { color: inherit; opacity: .9; }

/* Tipus de projecte (plantilles): targetes que es desen soles i llegenda de marcadors. */
.types-layout { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1.5rem; align-items: start; }
@media (max-width: 1000px) { .types-layout { grid-template-columns: 1fr; } }
.type-create { display: flex; gap: .5rem; align-items: center; margin-bottom: 1rem; }
.type-create input { flex: 1; max-width: 32rem; }
.type-cards { display: flex; flex-direction: column; gap: 1rem; }
.type-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem .7rem; }
.type-card.inactive { opacity: .6; }
.type-card label { display: flex; flex-direction: column; gap: .2rem; font-size: .75rem; color: var(--muted); }
.type-card label input, .type-card label textarea { font-size: .95rem; color: var(--text); }
.type-card-head { display: flex; gap: .75rem; align-items: end; }
.type-code input { width: 6rem; }
.type-name { flex: 1; }
.type-name input { font-weight: 650; font-size: 1.05rem; }
.type-card label.type-active { flex-direction: row; align-items: center; gap: .35rem; font-size: .85rem; padding-bottom: .5rem; white-space: nowrap; }
.type-status { font-size: .8rem; color: var(--positive); min-width: 4.5rem; padding-bottom: .55rem; }
.type-status.error { color: var(--danger); }
.type-card-row { display: flex; gap: .75rem; margin-top: .6rem; }
.type-card-row input { width: 11rem; }
.type-text { margin-top: .6rem; }
.type-text input, .type-text textarea { width: 100%; }
.type-preview { margin: .3rem 0 0; font-size: .85rem; }
.type-card-board { display: flex; justify-content: space-between; gap: 1rem; align-items: center; margin-top: .8rem; padding-top: .6rem;
  border-top: 1px solid var(--border); font-size: .85rem; }
.type-card-actions { display: flex; gap: .9rem; align-items: center; white-space: nowrap; }
button.link.danger { color: var(--danger); }
.markers-legend { position: sticky; top: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.markers-legend h2 { font-size: 1rem; margin: 0 0 .3rem; }
.markers-legend p { font-size: .8rem; }
.markers-legend ul { list-style: none; margin: .5rem 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.marker { width: 100%; text-align: left; display: grid; grid-template-columns: auto 1fr; gap: 0 .5rem; padding: .4rem .55rem;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg); cursor: pointer; font: inherit; }
.marker:hover { border-color: var(--primary); background: var(--hover); }
.marker code { grid-row: span 2; align-self: center; font-size: .78rem; color: var(--primary); font-weight: 600; }
.marker span { font-size: .85rem; }
.marker small { font-size: .75rem; color: var(--muted); }
.type-card ::placeholder { color: var(--placeholder); font-weight: 400; }

/* Avís d'error comú (notice.js): cap acció falla sense que es vegi. */
.app-notice { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); z-index: 1000; display: flex; align-items: center; gap: .75rem;
  max-width: min(36rem, calc(100vw - 2rem)); padding: .7rem .9rem .7rem 1.1rem; background: var(--danger-soft); color: var(--danger-text);
  border: 1px solid var(--danger-line); border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.12); font-size: .92rem; }
.app-notice[hidden] { display: none; }
.app-notice button { font-size: 1.3rem; line-height: 1; color: inherit; padding: 0 .2rem; }
.tab-error { padding: 1.5rem; color: var(--danger); }

/* Pantalles tàctils: no hi ha ratolí per passar per sobre ni teclat per a les dreceres. */
@media (hover: none) {
  kbd, .keyboard-hint { display: none; }
}

/* Mòbil i pantalles estretes. */
@media (max-width: 768px) {
  .page { padding: 1rem .75rem; }
  /* Les seccions baixen a una barra fixa a sota, a tota l'amplada, amb espai reservat. */
  body:has(.main-nav) { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .topbar { padding: .5rem .75rem; }
  .main-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; margin: 0; border-radius: 0; border-width: 1px 0 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .main-nav a { flex: 1 1 0; flex-direction: column; justify-content: center; gap: 2px; min-height: 56px; padding: 4px 2px; font-size: .72rem; border-radius: 12px; }
  .main-nav a[aria-current="page"] { color: var(--primary); }
  .main-nav .nav-pill { background: var(--primary-soft); }
  .main-nav .icon { width: 22px; height: 22px; }
  .main-nav .nav-count { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; }
  .timer-task { display: none; }
  .page-header { flex-wrap: wrap; }
  /* Les taules amples es desplacen de costat dins seu en lloc d'eixamplar la pàgina. */
  .table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table th, .table td { white-space: nowrap; }
  .table td.truncate { white-space: normal; min-width: 12rem; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs a { white-space: nowrap; padding: .5rem .6rem; }
  .sheet-top { flex-wrap: wrap; align-items: flex-start; }
  .sheet-title { flex-basis: 100%; flex-wrap: wrap; }
  .sheet-title textarea { font-size: 1.2rem; }
  .sheet-panel > summary { flex-wrap: wrap; }
  .sheet { grid-template-columns: 1fr; }
  .figures > div { min-width: 0; flex: 1 1 8rem; }
  .figures .budget-figure { min-width: 0; flex-basis: 100%; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  input, select, textarea { font-size: 16px; } /* iOS no fa zoom en entrar-hi */
}


/* Previsió de controls: rangs de dates d'un clic. */
.quick-ranges { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip-link { padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font-size: .85rem; }
.chip-link:hover { border-color: var(--primary); text-decoration: none; }
.chip-link.active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }

/* Dits en lloc de ratolí: objectius més grans. */
@media (pointer: coarse) {
  .task-check { width: 1.9rem; height: 1.9rem; }
  input[type=checkbox] { width: 1.4rem; height: 1.4rem; }
  .timer-button { padding: .45rem .8rem; }
  .button, .tabs a { min-height: 2.5rem; }
}

/* Pestanyes de la fitxa: número de files al costat del nom. */
.tab-count { display: inline-block; min-width: 1.3rem; padding: 0 .35rem; margin-left: .2rem; border-radius: 999px; background: var(--soft);
  color: var(--muted); font-size: .75rem; font-weight: 600; text-align: center; }
.tabs a[aria-current="page"] .tab-count { background: var(--primary-soft); color: var(--primary); }
.quick-upload { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: 1rem 0 .5rem; }
.quick-upload label { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); }
.quick-upload .error { color: var(--danger); font-size: .85rem; }
.filters-active { margin: .75rem 0 0; font-size: .85rem; color: var(--muted); }

/* ===== El Curs: comú a les pantalles (banda de flux, píndoles, comptadors) ===== */
.count { display: inline-block; font-size: .75rem; font-weight: 700; background: var(--soft); color: var(--muted); border-radius: 9px; padding: 1px 7px; vertical-align: middle; }
.count.warn { background: var(--warning-soft); color: var(--warning-text); }
.late-text { color: var(--negative); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .8rem; font-weight: 600; border-radius: 999px; padding: 3px 10px;
  background: var(--soft); color: var(--muted); white-space: nowrap; }
.pill .icon { width: 13px; height: 13px; }
.pill.unblock { background: var(--primary-soft); color: var(--primary); }
.pill.run { background: var(--primary); color: var(--primary-text); }
.pill.late { background: var(--danger-soft); color: var(--negative); }
.button.ghost { background: transparent; }
.button .icon, button .icon { vertical-align: -3px; }
.button:has(.icon) { display: inline-flex; align-items: center; gap: .4rem; }
/* La banda: trams d'amplada proporcional, de «a punt» a «fet». La resclosa (aturades) va ratllada. */
.flow { display: flex; gap: 3px; border-radius: 30px; overflow: hidden; margin: 0 0 1.25rem; }
.flow-seg { flex: var(--n, 1) 1 0; min-width: 104px; min-height: 66px; padding: 8px 16px; border: 0; border-radius: 0; background: var(--primary-soft); color: var(--text);
  display: flex; flex-direction: column; justify-content: center; text-align: left; line-height: 1.2; transition: flex-grow .3s; }
/* Els trams dels extrems segueixen la corba de la banda: així el marc del tram triat no queda retallat. */
.flow > .flow-seg:first-child { border-start-start-radius: inherit; border-end-start-radius: inherit; }
.flow > .flow-seg:last-child { border-start-end-radius: inherit; border-end-end-radius: inherit; }
.flow-seg b { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.flow-seg span { font-size: .8rem; font-weight: 600; }
.flow-seg.run { background: var(--primary); color: var(--primary-text); }
.flow-seg.dam { background: repeating-linear-gradient(135deg, var(--warning-soft) 0 9px, color-mix(in srgb, var(--warning-soft) 55%, var(--surface)) 9px 18px); color: var(--warning-text); }
.flow-seg.sea { background: var(--success-soft); color: var(--positive); }
.flow-seg.src { background: var(--soft); color: var(--muted); }
.flow-seg.sent { background: color-mix(in srgb, var(--blue) 16%, var(--surface)); color: var(--blue); }
button.flow-seg { cursor: pointer; font: inherit; }
button.flow-seg[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--text); }

/* ===== Inici ===== */
.course-header { margin-bottom: .9rem; }
.course-header h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.015em; margin: 0; }
.course-header p { margin: .15rem 0 0; }
.course-cols { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1.25rem; align-items: start; }
.now { background: var(--primary); color: var(--primary-text); border-radius: var(--radius-card); padding: 16px 18px; margin-bottom: 1rem;
  display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; }
.now-what { flex: 1 1 260px; display: flex; flex-direction: column; }
.now-label { font-size: .8rem; font-weight: 700; opacity: .85; }
.now-title { font-size: 1.2rem; font-weight: 800; line-height: 1.25; color: inherit; }
.now .course-project { color: inherit; background: transparent; border-color: color-mix(in srgb, currentColor 45%, transparent); }
.now .course-project:hover { background: color-mix(in srgb, currentColor 12%, transparent); color: inherit; }
.now .course-project:hover b { color: inherit; }
.now .course-project b { color: inherit; }
.now-clock { font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.now-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.now .button { min-height: 44px; border-color: transparent; background: var(--primary-text); color: var(--primary); font-weight: 700; }
.now .button.ghost { background: transparent; color: var(--primary-text); border-color: color-mix(in srgb, var(--primary-text) 55%, transparent); }
.now.idle { background: var(--surface); color: var(--text); border: 1px dashed var(--muted); }
.course-group { padding: 6px 0 8px; }
.course-group-head { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; justify-content: space-between; padding: 10px 16px 6px; }
.course-group-head h2, details.course-group summary h2 { display: flex; align-items: center; gap: 8px; font-size: 1rem; font-weight: 700; margin: 0; }
.course-group-head p { flex-basis: 100%; margin: 0; font-size: .85rem; }
details.course-group summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; padding: 0 16px; }
.sort-bar { display: flex; align-items: center; gap: 2px; font-size: .85rem; color: var(--muted); flex-wrap: wrap; }
.sort-bar button { min-height: 40px; padding: 0 10px; border: 0; background: none; border-radius: 9px; color: var(--muted); }
.sort-bar button[aria-pressed="true"] { color: var(--text); background: var(--soft); }
.course-list { list-style: none; margin: 0; padding: 0; }
.course-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto auto 44px; grid-template-areas: "chk tx tags hrs play"; align-items: center;
  gap: 0 6px; padding: 4px 10px; min-height: 58px; border-top: 1px solid var(--border); }
.course-row:hover { background: var(--row-hover); }
.course-row.timing { background: var(--hover); }
.course-check { grid-area: chk; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; background: none; border-radius: 50%; }
.course-check .box { width: 22px; height: 22px; border: 2px solid var(--muted); border-radius: 50%; display: grid; place-items: center; }
.course-check .icon { width: 13px; height: 13px; stroke-width: 3; opacity: 0; }
.course-check:hover .box { border-color: var(--positive); background: var(--success-soft); }
.course-check[aria-checked="true"] .box { background: var(--positive); border-color: var(--positive); color: var(--surface); }
.course-check[aria-checked="true"] .icon { opacity: 1; }
.course-text { grid-area: tx; padding: 6px 0; display: flex; flex-direction: column; align-items: flex-start; }
.course-title { font-weight: 700; line-height: 1.3; color: var(--text); }
.course-row.done .course-title { text-decoration: line-through; color: var(--muted); }
/* El projecte de la tasca: un botó prou gran per encertar-lo a la primera. */
.course-project { display: inline-flex; align-items: center; gap: .4rem; max-width: 100%; min-height: 34px; margin: 4px 0 2px; padding: .3rem .8rem .3rem .6rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--soft); color: var(--muted); font-size: .88rem; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course-project .icon { flex: none; width: 16px; height: 16px; }
.course-project b { color: var(--text); }
.course-project:hover { border-color: var(--primary); color: var(--primary); background: var(--surface); }
.course-project:hover b { color: var(--primary); }
.course-wait { font-size: .85rem; font-weight: 600; color: var(--warning-text); }
.course-tags { grid-area: tags; display: flex; flex-wrap: wrap; gap: 4px 6px; justify-content: flex-end; }
.course-play { grid-area: play; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--muted); }
.course-play:hover { background: var(--soft); color: var(--primary); }
.course-play[aria-pressed="true"] { background: var(--primary); color: var(--primary-text); }
/* «+h»: entrar hores fetes sense cronòmetre. */
.course-hours { grid-area: hrs; height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .25rem; padding: 0 .7rem;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--muted); font-weight: 700; font-size: .85rem; }
.course-hours .icon { width: 18px; height: 18px; }
.course-hours:hover { border-color: var(--primary); color: var(--primary); }
.task-hours-project { margin: -.25rem 0 .75rem; }
.app-notice.ok { background: var(--success-soft); color: var(--positive); border-color: var(--success-line); }
.course-empty { padding: 1rem 16px; color: var(--muted); border-top: 1px solid var(--border); }
.course-side .card { padding: 14px 16px; }
.course-side h2 { font-size: 1rem; font-weight: 700; margin: 0 0 .5rem; display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.course-side ul { list-style: none; margin: 0; padding: 0; }
.side-list li { padding: 8px 0; border-top: 1px solid var(--border); font-size: .88rem; display: flex; flex-direction: column; }
.side-list a { color: var(--text); }
.side-controls { background: var(--warning-soft); border-color: transparent; }
.side-controls p { font-size: .88rem; margin: 0 0 .5rem; }
.side-controls li { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: 6px 0; border-top: 1px solid color-mix(in srgb, var(--warning-text) 20%, transparent); font-size: .88rem; }
.side-controls li > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.side-controls a { color: var(--text); }
.big-number { font-size: 1.6rem; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.week-bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; align-items: end; height: 74px; margin: 10px 0 2px; }
.week-bars i { display: block; min-height: 3px; background: var(--primary-soft); border-radius: 5px 5px 2px 2px; }
.week-bars i.today { background: var(--primary); }
.week-labels { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; text-align: center; font-size: .72rem; color: var(--muted); }
.week-labels b { display: block; color: var(--text); font-size: .75rem; font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .course-cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 600px) {
  .flow { flex-wrap: wrap; border-radius: 16px; }
  .flow-seg { flex: 1 1 40%; min-height: 58px; }
  .course-row { grid-template-columns: 44px minmax(0, 1fr) 44px; grid-template-areas: "chk tx play" ". tags hrs"; padding: 4px; }
  .course-hours { padding: 0; width: 44px; }
  .course-hours span { display: none; }
  .course-tags { justify-content: flex-start; padding-bottom: 8px; }
  .course-tags:empty { display: none; }
  .course-group-head { padding-inline: 12px; }
  .now-clock { font-size: 1.6rem; }
}

/* Esperant client: botons-enllaç dins la línia i «Espera el client», que només surt en passar-hi. */
.link-button { border: 0; background: none; padding: 0 2px; min-height: 28px; color: inherit; font-weight: 600; text-decoration: underline; }
.course-sub { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .6rem; align-self: stretch; }
.wait-action { min-height: 0; font-size: .8rem; color: var(--warning-text); opacity: 0; transition: opacity .15s; }
.course-row:hover .wait-action, .wait-action:focus-visible { opacity: 1; }
@media (hover: none) { .wait-action { opacity: 1; } }


/* ===== Projectes ===== */
.projects-header p { margin: .15rem 0 0; }
#project-filters { margin-bottom: 1rem; }
.project-flow { border: 0; padding: 0; margin: 0 0 .4rem; }
.project-flow .flow-seg { position: relative; cursor: pointer; min-width: 96px;
  background: color-mix(in srgb, var(--status-color) 22%, var(--surface)); color: color-mix(in srgb, var(--status-color) 45%, var(--text)); }
.project-flow .flow-seg:hover { filter: brightness(.97); }
.project-flow input { position: absolute; opacity: 0; pointer-events: none; }
.project-flow .flow-seg:has(input:checked) { box-shadow: inset 0 0 0 3px var(--text); }
.project-flow .flow-seg:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: -6px; }
.filters { margin-top: .6rem; gap: .5rem .6rem; }
.filters select { min-height: 44px; border-radius: var(--radius); font-weight: 600; }
.search-field { flex: 1 1 18rem; display: flex; align-items: center; gap: .5rem; min-height: 44px; padding: 0 .75rem; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.search-field:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }
.search-field input { flex: 1; border: 0; padding: 0; min-height: 42px; outline: 0; background: none; }
.select-label { display: flex; align-items: center; gap: .4rem; font-size: .88rem; color: var(--muted); }
.segmented { display: flex; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 3px; margin: 0; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; align-items: center; min-height: 36px; padding: 0 .75rem; border-radius: 9px; font-weight: 600; color: var(--muted); }
.segmented input:checked + span { background: var(--text); color: var(--surface); }
.segmented input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.view-switch { margin-left: auto; }
.project-group { padding: 0; border-left: 5px solid var(--status-color, var(--border)); }
.project-group-head { display: flex; align-items: center; gap: .6rem; padding: 12px 16px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; border-radius: 999px; padding: 3px 10px;
  background: color-mix(in srgb, var(--status-color) 18%, transparent); color: color-mix(in srgb, var(--status-color) 50%, var(--text)); }
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--status-color); }
.project-rows { list-style: none; margin: 0; padding: 0; }
/* Tota la fila obre el projecte: l'enllaç del nom s'estén per sobre de la fila; la resta d'enllaços i l'equip queden per sobre. */
.project-row { position: relative; cursor: pointer; transition: background-color .12s; }
.project-row:hover { background: var(--row-hover); }
.project-row .project-name::after { content: ""; position: absolute; inset: 0; }
.project-row .work-now, .project-row .crew { position: relative; z-index: 1; }
.project-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.2fr) minmax(0, 15rem); gap: 6px 22px; padding: 12px 16px;
  border-top: 1px solid var(--border); align-items: start; }
.project-who, .project-work, .project-money { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.project-name { font-weight: 700; font-size: 1rem; line-height: 1.3; color: var(--text); }
.project-name b { color: var(--primary); margin-right: .35rem; font-weight: 800; }
.project-who small, .project-money small { font-size: .82rem; }
.people { display: flex; margin-top: 6px; }
.people .avatar { width: 28px; height: 28px; font-size: .7rem; border: 2px solid var(--surface); background: var(--soft); color: var(--muted); }
.people .avatar + .avatar { margin-left: -8px; }
/* Qui hi treballa: el responsable destacat (ple i amb nom) i una targeta en passar-hi. */
.crew { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: .5rem; margin-top: 6px; }
.crew .people { margin: 0; }
.people .avatar.lead { background: var(--primary); color: var(--primary-text); }
.avatar.timing { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--positive); }
.crew .avatar { position: relative; cursor: default; }
.crew .avatar:hover, .crew .avatar:focus-visible { z-index: 2; outline: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary); }
.crew-lead { font-size: .82rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crew-lead small { display: block; font-size: .68rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; line-height: 1.1; }
.crew-lead.none small { text-transform: none; letter-spacing: 0; font-size: .78rem; }
/* Una línia per persona: apareix sobre la seva inicial. */
.crew-tip { position: absolute; left: -4px; bottom: calc(100% + 8px); z-index: 30; width: max-content; max-width: 26rem; padding: .35rem .65rem;
  border-radius: 8px; background: var(--text); color: var(--surface); font-size: .8rem; font-weight: 500; line-height: 1.3; letter-spacing: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 6px 18px rgba(0,0,0,.18); pointer-events: none;
  opacity: 0; visibility: hidden; transform: translateY(3px); transition: opacity .12s ease, transform .12s ease, visibility 0s linear .12s; }
.crew-tip b { font-weight: 700; }
.crew-tip .crew-now { color: var(--success-soft); }
.crew .avatar:hover .crew-tip, .crew .avatar:focus-visible .crew-tip { opacity: 1; visibility: visible; transform: none; transition-delay: .08s, .08s, 0s; }
@media (prefers-reduced-motion: reduce) { .crew-tip { transition: none; } }
.work-now { font-weight: 600; font-size: .9rem; line-height: 1.35; color: var(--text); }
.work-now.waiting { color: var(--warning-text); }
.work-bar { display: flex; gap: 3px; width: 100%; max-width: 15rem; margin: 7px 0 4px; }
.work-bar i { flex: var(--n) 1 0; height: 6px; border-radius: 3px; background: var(--border); }
.work-bar i.done { background: var(--positive); }
.work-bar i.doing { background: var(--primary); }
.work-bar i.stopped { background: #c98a1a; }
.work-meta { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: .8rem; color: var(--muted); }
.meter { width: 100%; height: 8px; border-radius: 4px; background: var(--border); overflow: hidden; margin: 4px 0 6px; }
.meter i { display: block; height: 100%; background: var(--todo); border-radius: 4px; }
.meter.over i { background: var(--negative); }
.margin-line { width: 100%; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: .85rem; }
.margin-line b { font-size: 1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.margin-line.negative b { color: var(--negative); }
.tag { font-size: .72rem; font-weight: 700; border-radius: 6px; padding: 1px 7px; background: var(--soft); color: var(--muted); white-space: nowrap; }
.tag.real { background: var(--success-soft); color: var(--positive); }
.money-rule { font-size: .82rem; margin: .25rem .25rem 0; }
@media (max-width: 900px) {
  .project-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .project-money { grid-column: 1 / -1; max-width: 26rem; }
}
@media (max-width: 600px) {
  .project-flow { flex-wrap: wrap; border-radius: 16px; }
  .project-flow .flow-seg { flex: 1 1 40%; min-height: 58px; }
  .project-row { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .view-switch { margin-left: 0; }
}
#project-filters:has([name=vista][value=taula]:checked) .sort-select { display: none; } /* l'ordre és de la vista «Curs» */
@media (max-width: 600px) {
  .projects-header > .button { display: none; } /* «Nou» ja és a la barra */
  .filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .filters .search-field { grid-column: 1 / -1; }
  .filters select, .select-label { width: 100%; min-width: 0; }
  .select-label { font-size: 0; gap: 0; } /* sense «Ordena»: el desplegable ja ho diu */
  .select-label select { font-size: 1rem; }
  .segmented span { justify-content: center; white-space: nowrap; padding: 0 .5rem; }
  .segmented label { flex: 1; }
}


/* El Curs (4): fitxa del projecte */
.back-link { display: inline-flex; align-items: center; gap: .3rem; margin: 0 0 .6rem; font-size: .88rem; font-weight: 600; color: var(--muted); text-decoration: none; }
.back-link:hover { color: var(--primary); }
.project-head { padding: 1.1rem 1.3rem; margin-bottom: 1rem; }
.project-head-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem 1.5rem; }
.project-head-main { flex: 1 1 18rem; min-width: 0; }
.project-head .sheet-title { margin-bottom: .35rem; }
.project-meta .meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem 1.1rem; font-size: .92rem; color: var(--muted); }
.project-meta .meta b { color: var(--text); font-weight: 650; }
.project-meta .meta-small { font-size: .82rem; margin-top: .25rem; }
.project-meta .link-button { padding: 0; min-height: 0; font-size: inherit; }
.project-meta .meta-path { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-rail { display: flex; flex-wrap: wrap; gap: 4px; margin-top: .9rem; }
/* Botons i, a sota, el carril d'estats: tot a la dreta de la capçalera. */
.project-side { flex: 0 1 auto; display: flex; flex-direction: column; align-items: flex-end; gap: .6rem; }
.project-side .status-rail { margin: 0; justify-content: flex-end; }
.crew-row { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem; }
.add-technician summary { font-size: .82rem; color: var(--primary); text-decoration: none; padding: .2rem .5rem; border-radius: 999px; }
.add-technician summary:hover { background: var(--soft); }
.add-technician ul { left: 0; right: auto; max-height: 18rem; overflow-y: auto; }
.add-technician form { margin: 0; }
.add-technician li form button { display: flex; justify-content: flex-start; min-height: 36px; align-items: center; gap: .5rem; width: 100%; padding: .35rem .5rem; border: 0; border-radius: 8px; background: none; font: inherit; font-size: .88rem; text-align: left; cursor: pointer; }
.add-technician li form button:hover { background: var(--soft); }
.add-technician .avatar { width: 26px; height: 26px; font-size: .68rem; border: 0; }
/* Cada estat amb el seu color (el de l'admin, el mateix de la banda de Projectes): un punt a cada pastilla
   i, l'actual, plena d'un to del seu color i amb vora. */
.status-rail button { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: .3rem .85rem .3rem .65rem; font: inherit; font-size: .82rem; font-weight: 650; cursor: pointer; }
.status-rail button::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--status-color); }
.status-rail button:hover { border-color: var(--status-color); color: color-mix(in srgb, var(--status-color) 50%, var(--text)); }
.status-rail button[aria-current="step"] { background: color-mix(in srgb, var(--status-color) 24%, var(--surface)); border: 1px solid var(--status-color);
  color: color-mix(in srgb, var(--status-color) 40%, var(--text)); box-shadow: inset 0 0 0 1px var(--status-color); cursor: default; }
.status-rail button.closed:not([aria-current]) { border-style: dashed; }
.project-actions { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .5rem; }
.project-actions form { margin: 0; }
.sheet-panel-hint { font-size: .8rem; color: var(--muted); }
/* Plec plegat: les dades de debò en una ratlla, separades per «|». Obert, ja es veuen a sota. */
.sheet-strip { display: flex; align-items: center; min-width: 0; overflow: hidden; white-space: nowrap; font-size: .8rem; color: var(--text); }
.sheet-strip > span { display: inline-flex; align-items: center; gap: .3rem; flex: none; }
.sheet-strip > span + span::before { content: "|"; margin: 0 .65rem; color: var(--border); }
.sheet-strip .icon { width: .95rem; height: .95rem; color: var(--muted); flex: none; }
.sheet-strip > .sheet-strip-note { flex: 0 1 auto; min-width: 0; }
.sheet-strip-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.sheet-panel[open] .sheet-strip { display: none; }

/* Primera fila: la capçalera del projecte i, al costat, com va la feina. */
.project-top { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(19rem, 1fr); gap: 1rem; margin-bottom: 1rem; }
.project-top .project-head { margin-bottom: 0; }
.project-head-top { flex-wrap: wrap; }
/* Dins del plec de dades: observacions i, al costat, els diners. */
.sheet-bottom { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(18rem, 1fr); gap: 1rem; }
.sheet-bottom > .sheet-notes { grid-column: auto; }
.money-figure h3 { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.money-figure h3 small { font-size: .78rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--muted); }
.figure { padding: .85rem 1.1rem; margin: 0; min-width: 0; }
.figure h2 { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; font-size: 1rem; margin: 0 0 .6rem; }
.figure h2 small { font-size: .8rem; font-weight: 600; color: var(--muted); }
.figure p { margin: .5rem 0 0; font-size: .88rem; }
.stack { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--soft); gap: 2px; }
.stack span, .legend i { background: var(--muted); }
.stack .s-expenses, .legend i.s-expenses { background: color-mix(in srgb, var(--muted) 45%, var(--surface)); }
.stack .s-free, .legend i.s-free { background: var(--success-soft); }
.stack .s-free { flex: 1; border-radius: 0 7px 7px 0; outline: 1px dashed color-mix(in srgb, var(--positive) 45%, transparent); outline-offset: -1px; }
.legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: .55rem 0 0; font-size: .84rem; color: var(--muted); }
.legend b { color: var(--text); font-variant-numeric: tabular-nums; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: .35rem; vertical-align: baseline; }
.small-flow { margin: 0 0 .6rem; border-radius: 12px; }
.small-flow .flow-seg { min-width: 0; min-height: 44px; padding: 4px 8px; }
.small-flow .flow-seg b { font-size: 1rem; }
.small-flow .flow-seg span { font-size: .7rem; }
.money-admin { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem 1.25rem; margin-top: .6rem; padding-top: .55rem; border-top: 1px solid var(--border); font-size: .86rem; color: var(--muted); }
.money-admin b { color: var(--text); font-variant-numeric: tabular-nums; margin-left: .2rem; }
.week-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-top: .55rem; }
.week-strip span { display: flex; flex-direction: column; }
.week-strip em { display: flex; align-items: flex-end; height: 26px; }
.week-strip i { display: block; width: 100%; min-height: 3px; background: var(--primary-soft); border-radius: 4px 4px 2px 2px; }
.week-strip i.today { background: var(--primary); }
.week-strip small { font-size: .68rem; color: var(--muted); text-align: center; margin-top: 2px; }
@media (max-width: 1000px) {
  .project-top, .sheet-bottom { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .figures { grid-template-columns: 1fr; }
  .project-head { padding: .9rem; }
  .project-head-top { flex-direction: column; align-items: stretch; }
  .project-actions { justify-content: flex-start; }
  .project-side { align-items: stretch; }
  .project-side .status-rail { justify-content: flex-start; }
}

/* Resposta immediata: el que ja ha canviat a la pantalla mentre el servidor ho desa. */
.leaving { opacity: .35; pointer-events: none; transition: opacity .15s; }
button.htmx-request, .htmx-request > button[type=submit] { cursor: progress; }

/* Canvi de pàgina sense parpelleig: la barra superior es queda quieta i el contingut es fon. */
/* Canvi de pàgina (Chrome/Edge): capes explícites perquè la píndola llisqui per sota de les etiquetes, mai per sobre. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .topbar { view-transition-name: topbar; }
  .main-nav { view-transition-name: main-nav; }
  .nav-pill { view-transition-name: nav-pill; }
  .main-nav a { view-transition-class: nav-item; }
  .main-nav a[aria-current="page"] { view-transition-class: nav-item nav-active; }
  .main-nav a:nth-child(1) { view-transition-name: nav-1; }
  .main-nav a:nth-child(2) { view-transition-name: nav-2; }
  .main-nav a:nth-child(3) { view-transition-name: nav-3; }
  .main-nav a:nth-child(4) { view-transition-name: nav-4; }
  .main-nav a:nth-child(5) { view-transition-name: nav-5; }
  /* Des de mig d'una pàgina llarga, la capçalera no ha de caure des de dalt. */
  .vt-scrolled .topbar { view-transition-name: none; }
  @media (min-width: 769px) {
    .vt-scrolled .main-nav, .vt-scrolled .main-nav a, .vt-scrolled .nav-pill { view-transition-name: none; }
  }
  ::view-transition-group(topbar) { z-index: 1; animation-duration: .14s; }
  ::view-transition-group(main-nav) { z-index: 2; animation-duration: .14s; }
  ::view-transition-group(nav-pill) { z-index: 3; border-radius: 999px; overflow: clip; animation-duration: .22s; animation-timing-function: cubic-bezier(.22, 1, .36, 1); }
  ::view-transition-old(nav-pill), ::view-transition-new(nav-pill) { height: 100%; animation-duration: .22s; }
  ::view-transition-group(.nav-item) { z-index: 4; animation-duration: .18s; }
  /* Les etiquetes no fan fos encreuat (el blanc sobre blanc no es llegiria): surten ja amb el color nou,
     i la de la secció nova passa de fosc al seu color a mesura que la píndola hi arriba. */
  ::view-transition-old(.nav-item) { animation: none; opacity: 0; }
  ::view-transition-new(.nav-item) { animation: none; }
  ::view-transition-new(.nav-active) { animation: nav-ink .22s cubic-bezier(.22, 1, .36, 1); }
  @keyframes nav-ink { from { filter: brightness(0); } }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .14s; }
  @media (max-width: 768px) { ::view-transition-group(nav-pill) { border-radius: 12px; } }
}
.markers-hint { margin: .4rem 0; padding: .45rem .6rem; border-radius: 8px; background: var(--warning-soft); color: var(--warning-text); font-size: .8rem; }

/* Clients: cerca àmplia, etiqueta d'inactiu i fitxa amb granges i projectes. */
.client-search { max-width: 34rem; margin-bottom: 1rem; }
.inactive-row { opacity: .55; }
.client-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 1rem; align-items: start; }
.client-layout form.client-form { grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); }
.client-side { display: flex; flex-direction: column; gap: 1rem; }
.client-side .card { margin: 0; }
.client-side h2 { font-size: 1rem; margin: 0 0 .6rem; display: flex; gap: .5rem; align-items: baseline; }
.farm-head, .farm-row { display: grid; grid-template-columns: minmax(8rem, 2fr) minmax(4rem, 1fr) minmax(4rem, 1fr) minmax(6rem, 1.4fr) auto 5.5rem; gap: .4rem; align-items: center; }
.farm-head { font-size: .72rem; color: var(--muted); padding: 0 .2rem .2rem; }
.farm-row { padding: .2rem 0; }
.farm-row input[type=text] { width: 100%; min-width: 0; padding: .35rem .5rem; font-size: .88rem; }
.farm-active { display: flex; align-items: center; gap: .3rem; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.farm-projects { font-size: .78rem; white-space: nowrap; }
.farm-new { margin-top: .4rem; padding-top: .5rem; border-top: 1px dashed var(--border); }
.farm-new .button { grid-column: span 2; }
.client-project-list { list-style: none; margin: 0; padding: 0; }
.client-project-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .75rem; align-items: center; padding: .45rem 0; border-top: 1px solid var(--border); font-size: .9rem; }
.client-project-list li:first-child { border-top: 0; }
.client-project-list b { color: var(--muted); margin-right: .3rem; }
@media (max-width: 1100px) { .client-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) {
  .farm-head { display: none; }
  .farm-row { grid-template-columns: 1fr 1fr; }
  .farm-row input[name$="-name"] { grid-column: 1 / -1; }
}

/* Configuració: targetes en dues columnes */
.settings-intro { margin-top: -.5rem; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 30rem), 1fr)); gap: 1rem; align-items: start; }
.settings-card { margin: 0; display: flex; flex-direction: column; gap: .9rem; }
.settings-card h2 { margin: 0; font-size: 1.1rem; }
.settings-card form { margin: 0; }
.settings-form { display: flex; flex-direction: column; gap: .75rem; }
.company-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .9rem 1.2rem; }
.company-form .actions { grid-column: 1 / -1; }
.settings-field { display: flex; flex-direction: column; gap: .2rem; }
.settings-field label { font-weight: 650; }
.settings-field input { max-width: 14rem; }
.settings-field small { font-size: .8rem; }
.status-table { width: 100%; border-collapse: collapse; }
.status-table th { text-align: left; font-size: .75rem; color: var(--muted); font-weight: 600; padding: 0 .4rem .3rem; }
.status-table td { padding: .25rem .4rem; border-top: 1px solid var(--border); vertical-align: middle; }
.status-table input[type=color] { width: 2.4rem; height: 2rem; padding: 2px; border-radius: 8px; }
.status-table input[type=number] { width: 4.5rem; }
.status-table td:nth-child(2) input { width: 100%; }
.status-table .new-status input[type=text] { border-style: dashed; }
.settings-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.settings-links a { font-weight: 650; }
/* Targeta de la IA */
.ai-providers { border: 0; padding: 0; margin: 0 0 1rem; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.ai-providers legend { font-weight: 650; margin-bottom: .4rem; }
.ai-providers label { display: inline-flex; align-items: center; gap: .4rem; }
.ai-key { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.ai-key label { font-weight: 650; }
.ai-key input { width: 100%; font-family: ui-monospace, monospace; }
.ai-key-saved { margin: 0; }
.ai-tools { display: flex; align-items: center; gap: 1rem; padding-top: .75rem; border-top: 1px solid var(--border); }
.ai-updated { margin: 0; font-size: .82rem; }

/* Interruptor de tema: una bola que llisca d'un sol a una lluna. */
.theme-switch { flex: none; padding: 4px; border: 0; background: none; cursor: pointer; border-radius: 999px; }
.theme-switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.theme-switch-track { position: relative; display: block; width: 52px; height: 28px; border-radius: 999px; background: var(--soft);
  border: 1px solid var(--border); transition: background-color .35s ease; }
.theme-switch-thumb { position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface);
  box-shadow: 0 1px 3px rgb(0 0 0 / .25); display: grid; place-items: center; color: #d08a00;
  transition: transform .45s cubic-bezier(.5, 1.6, .4, 1), background-color .35s ease, color .35s ease; }
.theme-switch-thumb svg { grid-area: 1 / 1; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round;
  transition: transform .45s ease, opacity .3s ease; }
.theme-switch-thumb .theme-sun circle { fill: currentColor; }
.theme-switch-thumb .theme-moon { fill: currentColor; stroke: none; opacity: 0; transform: rotate(-90deg) scale(.4); }
.theme-switch[aria-checked="true"] .theme-switch-track { background: #2a3a55; }
.theme-switch[aria-checked="true"] .theme-switch-thumb { transform: translateX(24px); background: #e9eef7; color: #4b5d84; }
.theme-switch[aria-checked="true"] .theme-sun { opacity: 0; transform: rotate(90deg) scale(.4); }
.theme-switch[aria-checked="true"] .theme-moon { opacity: 1; transform: none; }
.theme-switch:hover .theme-switch-thumb { box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent), 0 1px 3px rgb(0 0 0 / .25); }
/* Durant el canvi de tema, la pàgina no fa altres transicions (només el cercle). */
.theme-changing::view-transition-old(root), .theme-changing::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
.theme-changing .topbar { view-transition-name: none; }
.theme-changing .main-nav, .theme-changing .main-nav a, .theme-changing .nav-pill { view-transition-name: none; }
@media (prefers-reduced-motion: reduce) { .theme-switch-thumb, .theme-switch-thumb svg, .theme-switch-track { transition: none; } }
@media (max-width: 768px) { .theme-switch-track { width: 46px; height: 26px; } .theme-switch-thumb { width: 20px; height: 20px; }
  .theme-switch[aria-checked="true"] .theme-switch-thumb { transform: translateX(20px); } }

/* «?» d'ajuda: explicació curta en passar-hi per sobre o en enfocar-lo amb el teclat. */
.help-tip { position: relative; display: inline-grid; place-items: center; width: 1rem; height: 1rem; margin-left: .3rem;
  border-radius: 50%; background: var(--soft); color: var(--muted); font-size: .68rem; font-weight: 700; line-height: 1;
  cursor: help; vertical-align: .1em; text-transform: none; letter-spacing: 0; }
.help-tip:hover, .help-tip:focus-visible { background: var(--primary-soft); color: var(--primary); outline: none; }
.help-tip-text { position: absolute; bottom: calc(100% + .45rem); left: 50%; z-index: 40; width: max-content; max-width: 17rem;
  padding: .45rem .6rem; border-radius: 8px; background: var(--text); color: var(--bg); box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
  font-size: .76rem; font-weight: 500; line-height: 1.35; text-align: left; white-space: normal;
  opacity: 0; pointer-events: none; transform: translate(-50%, 3px); transition: opacity .12s, transform .12s; }
.help-tip:hover .help-tip-text, .help-tip:focus-visible .help-tip-text { opacity: 1; transform: translate(-50%, 0); }
.num .help-tip-text { left: auto; right: -.4rem; transform: translateY(3px); }
.num .help-tip:hover .help-tip-text, .num .help-tip:focus-visible .help-tip-text { transform: none; }

/* Assistent del projecte: panell a la dreta de la pissarra. */
.board-area { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 1rem; }
.board-area.assistant-open { grid-template-columns: minmax(0, 1fr) minmax(320px, 400px); }
.assistant-panel { margin-bottom: 1rem; min-height: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column;
  contain: size; /* la conversa no fa créixer la fila: el panell fa l'alçada de la pissarra */ }
.assistant-panel[hidden] { display: none; }
.assistant-body { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.ai-head { display: flex; gap: .5rem; align-items: flex-start; justify-content: space-between; padding: .75rem .9rem .65rem;
  border-bottom: 1px solid var(--border); }
.ai-head h2 { margin: 0; font-size: 1rem; }
.ai-head p { margin: .15rem 0 0; font-size: .78rem; color: var(--muted); }
.ai-head .icon-button { width: 32px; height: 32px; font-size: 1.3rem; }
.ai-spark { color: var(--primary); }
.ai-chat { flex: 1; min-height: 0; overflow-y: auto; padding: .8rem .9rem; display: flex; flex-direction: column; gap: .75rem;
  font-size: .88rem; line-height: 1.45; overscroll-behavior: contain; }
.ai-msg { max-width: 94%; overflow-wrap: anywhere; }
.ai-msg.me { align-self: flex-end; background: var(--primary-soft); padding: .45rem .7rem; border-radius: 12px 12px 4px 12px; }
.ai-who { font-size: .7rem; font-weight: 700; color: var(--muted); margin-bottom: .15rem; }
.ai-msg.error .ai-text { color: var(--danger-text); }
.ai-activity { display: inline-flex; align-items: center; gap: .45rem; color: var(--muted); font-size: .84rem; }
.ai-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); animation: ai-pulse 1.1s ease-in-out infinite; }
@keyframes ai-pulse { 50% { opacity: .25; transform: scale(.8); } }
.ai-chip { font: inherit; font-size: .8rem; font-weight: 600; padding: 0 .45rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--soft); color: var(--text); cursor: pointer; }
.ai-chip:hover { border-color: var(--primary); color: var(--primary); }
.ai-proposal { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; margin-top: .45rem; padding: .5rem .6rem;
  border: 1px solid var(--primary-line); border-radius: 10px; background: var(--bg); font-size: .82rem; }
.ai-proposal > span { flex: 1 1 12rem; }
.ai-proposal form { display: flex; gap: .35rem; }
.ai-proposal.applied, .ai-proposal.dismissed, .ai-proposal.gone { border-color: var(--border); opacity: .75; }
.ai-done { color: var(--positive); font-weight: 700; }
.button.small { padding: .2rem .65rem; font-size: .8rem; border-radius: 8px; }
.ai-empty { color: var(--muted); display: grid; gap: .4rem; }
.ai-empty p { margin: 0 0 .2rem; }
.ai-suggestion { width: 100%; text-align: left; font-weight: 500; background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.ai-suggestion:hover { border-color: var(--primary); }
.ai-input { border-top: 1px solid var(--border); padding: .65rem .9rem; display: grid; grid-template-columns: 1fr auto; gap: .4rem .5rem; align-items: end; }
.ai-input textarea { resize: none; font: inherit; font-size: .88rem; min-height: 2.6rem; max-height: 10rem; }
.ai-input small { grid-column: 1 / -1; font-size: .7rem; }
@media (max-width: 1100px) {
  .board-area.assistant-open { grid-template-columns: minmax(0, 1fr); }
  .assistant-panel { height: 70vh; }
}
/* Fils de treball de l'assistent */
.ai-threads { padding: .55rem .9rem; border-bottom: 1px solid var(--border); display: grid; gap: .35rem; max-height: 38%; overflow-y: auto; }
.ai-threads:empty { display: none; }
.ai-threads h3 { margin: 0; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.ai-thread { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .5rem; align-items: center; width: 100%;
  text-align: left; padding: .4rem .55rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
  font-weight: 400; font-size: .82rem; color: var(--text); }
.ai-thread:hover { border-color: var(--primary); }
.ai-thread-text { min-width: 0; }
.ai-thread-text b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-thread-text small { display: block; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .74rem; }
.ai-thread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.ai-thread-state { font-size: .7rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.ai-thread.state-working .ai-thread-dot { background: var(--primary); animation: ai-pulse 1.1s ease-in-out infinite; }
.ai-thread.state-working .ai-thread-state { color: var(--primary); }
.ai-thread.state-waiting .ai-thread-dot { background: var(--warning-text); }
.ai-thread.state-waiting .ai-thread-state { color: var(--warning-text); }
.ai-thread.state-done .ai-thread-dot { background: var(--positive); }
.ai-thread.state-error .ai-thread-dot { background: var(--danger); }
.ai-thread-badge { font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--soft); color: var(--muted); vertical-align: middle; }
.ai-thread-badge.state-working { background: var(--primary-soft); color: var(--primary); }
.ai-thread-badge.state-waiting { background: var(--warning-soft); color: var(--warning-text); }
.ai-thread-badge.state-done { background: var(--success-soft); color: var(--positive); }
.ai-thread-badge.state-error { background: var(--danger-soft); color: var(--danger-text); }
.ai-back { padding: 0; border: 0; background: none; color: var(--primary); font-size: .8rem; font-weight: 700; margin-bottom: .2rem; }
.ai-scope { margin: 0; font-size: .76rem; color: var(--muted); background: var(--soft); border-radius: 8px; padding: .4rem .6rem; }
.ai-msg.ai-goal { background: var(--soft); padding: .45rem .7rem; border-radius: 10px; }
.ai-caps { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; border: 0; padding: 0; margin: 1rem 0 0; }
.ai-caps legend { font-weight: 600; margin-bottom: .4rem; }
.ai-caps label { display: inline-flex; align-items: center; gap: .4rem; }
.ai-caps input { width: 6rem; }
.ai-usage { flex-basis: 100%; margin: .2rem 0 0; font-size: .88rem; }

/* --- Portals: Projectes | Comptes ---
   El commutador ocupa el lloc del logotip (només administradors). A Comptes només canvia l'accent: verd fosc. */
.portal-comptes { --primary: #1f4d3a; --primary-soft: #d7e8de; --primary-line: #a9cab7; --primary-strong: #163a2b; --primary-text: #ffffff; }
:root[data-theme="dark"] .portal-comptes { --primary: #6cc196; --primary-soft: #183528; --primary-line: #2e5a45; --primary-strong: #8fd4ae; --primary-text: #0c1a13; }
.portal-switch { flex: none; display: inline-flex; gap: 2px; padding: 3px; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.portal-switch a { display: flex; align-items: center; min-height: 38px; padding: 0 .95rem; border-radius: 999px; font-weight: 700; color: var(--muted); }
.portal-switch a:hover { color: var(--text); text-decoration: none; }
.portal-switch a[aria-current] { background: var(--text); color: var(--surface); }
.portal-comptes .portal-switch a[aria-current] { background: var(--primary); color: var(--primary-text); }
.main-nav .nav-more { display: none; }
@media (min-width: 769px) {
  .portal-comptes .main-nav .nav-pill { background: var(--primary); }
  .portal-comptes .main-nav a[aria-current="page"] { color: var(--primary-text); }
}
@media (max-width: 1600px) { .portal-comptes .main-nav a { padding: 0 .6rem; gap: .3rem; } }
@media (max-width: 1519px) { .portal-comptes .main-nav .icon { display: none; } }
@media (max-width: 768px) {
  .portal-comptes .main-nav .icon { display: block; }
  .main-nav .nav-extra { display: none; }
  .main-nav .nav-more { display: flex; }
  .portal-switch a { min-height: 34px; padding: 0 .55rem; font-size: .82rem; }
  /* Amb el commutador, la barra de dalt va justa: «Nou» queda només amb la icona. */
  .topbar:has(.portal-switch) { gap: .5rem .4rem; }
  .topbar:has(.portal-switch) > .theme-switch { display: none; }
  .menu li.menu-theme { display: flex; }
  .topbar:has(.portal-switch) .new-menu summary { padding: 0; width: 44px; justify-content: center; }
  .topbar:has(.portal-switch) .new-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}
.menu li.menu-theme > .theme-switch { width: auto; flex: none; padding: 4px; background: none; }
.menu .menu-theme { display: none; justify-content: space-between; align-items: center; gap: .75rem; padding: .25rem .5rem .25rem .75rem; }
.menu li > a.menu-icon-link { justify-content: flex-start; gap: .5rem; }
.menu-icon-link .icon { width: 18px; height: 18px; }
.acc-soon { max-width: 46rem; }
.acc-soon-lead { font-size: 1.15rem; font-weight: 600; margin-top: 0; }
.acc-soon-list { margin: .5rem 0 0; padding-left: 1.2rem; }
.acc-soon-list li { margin-bottom: .35rem; }
.acc-more { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); gap: .75rem; }
.acc-more a { display: flex; gap: .75rem; align-items: flex-start; padding: 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); color: var(--text); }
.acc-more a:hover { text-decoration: none; border-color: var(--primary); }
.acc-more .icon { flex: none; width: 22px; height: 22px; color: var(--primary); }
.acc-more b { display: block; }
.acc-more small { display: block; color: var(--muted); }

/* --- Comptes: llibres i tancament --- */
.acc-year { display: flex; align-items: center; gap: .5rem; }
.acc-year label { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-weight: 600; }
.acc-year select { width: auto; }
.acc-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; margin: 0 0 1rem; }
form.acc-bar { justify-content: flex-start; }
.acc-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.acc-chips a { padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .88rem; font-weight: 600; }
.acc-chips a:hover { text-decoration: none; color: var(--text); }
.acc-chips a[aria-current] { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.acc-filter { margin-bottom: 1rem; }
.acc-collect { margin: 0 0 .75rem; }
.acc-collection { white-space: nowrap; }
.acc-collect .is-late { color: var(--danger-text); font-weight: 600; }
.acc-collection.is-paid, .acc-collection.is-refunded { background: var(--success-soft); }
.acc-collection.is-pending, .acc-collection.is-refund { background: var(--warning-soft); }
.acc-collection.is-late { background: var(--danger-soft); color: var(--danger-text); }
.acc-entry { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: .8rem 1rem; margin-bottom: .6rem; }
.acc-entry.is-reversed { opacity: .6; }
.acc-entry header { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .75rem; }
.acc-entry-number { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--primary); }
.acc-entry-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.acc-entry-title { font-weight: 600; color: var(--text); flex: 1; }
.acc-source { font-size: .8rem; color: var(--muted); }
.acc-entry .table { margin: .5rem 0 0; background: none; }
.acc-lines th:nth-child(1), .acc-lines td:nth-child(1) { width: 7rem; }
.acc-lines td.num, .acc-lines th.num { width: 9rem; font-variant-numeric: tabular-nums; }
.acc-plain { list-style: none; margin: .5rem 0 0; padding: 0; }
.acc-plain li { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem .6rem; padding: .3rem 0; border-top: 1px dashed var(--border); }
.acc-plain-what { min-width: 9rem; font-size: .85rem; font-weight: 700; color: var(--muted); }
.acc-plain li.is-debit .acc-plain-what { color: var(--primary); }
.acc-plain-amount { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.acc-entry-card h2 { margin-top: .2rem; }
.acc-entry-card h3 { margin: 1.25rem 0 0; font-size: 1rem; color: var(--muted); }
.acc-entry-form .acc-entry-head { display: grid; grid-template-columns: 12rem minmax(0, 1fr); gap: 0 1rem; }
/* Amplades: el compte o la descripció s'emporten l'espai; els imports, el just per a 9.999.999,99. */
.acc-form-lines { table-layout: fixed; width: 100%; }
.acc-form-lines .col-money { width: 9.5rem; }
.acc-form-lines .col-qty { width: 7rem; }
.acc-form-lines .col-rate { width: 6rem; }
.acc-form-lines .col-remove { width: 4.5rem; }
.acc-form-lines .col-note { width: 24%; }
.acc-form-lines td input:not([type="checkbox"]), .acc-form-lines td select, .acc-form-lines .combo { width: 100%; min-width: 0; box-sizing: border-box; }
.acc-form-lines input[name$="-quantity"], .acc-form-lines input[name$="-unit_price"], .acc-form-lines input[name$="-vat_rate"] { text-align: right; }
.acc-form-lines td { vertical-align: top; }
.acc-form-lines input[name$="-debit"], .acc-form-lines input[name$="-credit"] { text-align: right; }
.acc-form-lines tfoot th { color: var(--text); font-variant-numeric: tabular-nums; }
.acc-form-lines [data-balance] { color: var(--negative); font-weight: 600; }
.acc-form-lines [data-balance].is-ok { color: var(--positive); }
.acc-chart { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1.25rem; align-items: start; }
.acc-chart .acc-parent td { font-weight: 700; }
.acc-subaccount { position: sticky; top: 1rem; }
.acc-intro { max-width: 60ch; }
.acc-months { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: .4rem; max-width: 46rem; }
.acc-months li { display: grid; grid-template-columns: 9rem 10rem minmax(0, 1fr); align-items: center; gap: .75rem; padding: .55rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); min-height: 52px; }
.acc-months li > :last-child { justify-self: end; }
.acc-months li.is-closed { background: var(--primary-soft); border-color: var(--primary-line); }
.acc-months li.is-future { opacity: .55; }
.acc-month-name { font-weight: 700; }
.acc-month-state { display: inline-flex; align-items: center; gap: .35rem; color: var(--primary-strong); font-weight: 600; }
.acc-month-state .icon { width: 16px; height: 16px; }
@media (max-width: 900px) {
  .acc-chart { grid-template-columns: minmax(0, 1fr); }
  .acc-entry-form .acc-entry-head { grid-template-columns: minmax(0, 1fr); }
  .acc-months li { grid-template-columns: minmax(0, 1fr) auto; }
  .acc-months li > .muted:nth-child(2) { display: none; }
}
.acc-entry-form .field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .9rem; }
.acc-entry-form .field label { font-weight: 600; }

/* --- Comptes: factures i configuració --- */
.acc-invoice { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1rem; align-items: start; }
.acc-invoice-parties { display: flex; flex-wrap: wrap; gap: 1rem 2.5rem; }
.acc-invoice-parties p { margin: .2rem 0 0; }
.acc-totals { display: grid; grid-template-columns: auto 9rem; gap: .25rem 0; justify-content: end; margin: .5rem 0 0; font-variant-numeric: tabular-nums; }
.acc-totals dt { color: var(--muted); text-align: right; }
.acc-totals dd { margin: 0; text-align: right; padding-left: 1.5rem; }
.acc-totals .acc-total { font-size: 1.2rem; font-weight: 800; color: var(--text); border-top: 1px solid var(--border); padding-top: .35rem; }
.acc-verifactu h2, .acc-invoice aside h2 { font-size: 1.05rem; margin-top: 0; }
.acc-qr svg { width: 120px; height: 120px; display: block; background: #fff; padding: 6px; border-radius: 6px; }
.acc-hash { font-size: .72rem; word-break: break-all; }
.acc-rectify summary { cursor: pointer; font-weight: 600; }
.acc-rectify input { width: 100%; margin: .25rem 0 .5rem; }
.acc-invoice-form .acc-invoice-head { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: 0 1rem; }
.acc-invoice-form .acc-invoice-head .field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .9rem; }
.acc-invoice-form .acc-invoice-head .field:has(textarea) { grid-column: 1 / -1; }
.acc-settings { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.acc-settings > section > h2 { margin-top: 0; }
.acc-connector header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.acc-connector h3 { margin: 0; }
.acc-connector.is-on { border-color: var(--primary-line); }
.acc-connector.is-on .badge { background: var(--primary-soft); color: var(--primary-strong); }
.acc-connector details summary { cursor: pointer; font-weight: 600; color: var(--primary); margin: .5rem 0; }
.acc-connector form.form { display: grid; gap: 0; }
.acc-connector-details { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .2rem 1rem; margin: .5rem 0; }
.acc-connector-details dt { color: var(--muted); }
.acc-connector-details dd { margin: 0; }
@media (max-width: 1000px) { .acc-invoice, .acc-settings { grid-template-columns: minmax(0, 1fr); } }

/* Selector amb cercador (frontend/src/combobox.js): la millor opció surt a dalt i Enter la tria. */
.combo { position: relative; min-width: 12rem; }
.combo-input { width: 100%; }
.combo-list { position: absolute; z-index: 60; left: 0; top: calc(100% + 4px); min-width: 100%; width: max-content; max-width: min(34rem, 90vw);
  max-height: 18rem; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 28px rgb(0 0 0 / .14); }
.combo-option { padding: .4rem .6rem; border-radius: 7px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-option b { font-variant-numeric: tabular-nums; margin-right: .25rem; }
.combo-option:hover { background: var(--soft); }
.combo-option[aria-selected="true"] { background: var(--primary-soft); color: var(--primary-strong); }
.combo-empty { padding: .4rem .6rem; color: var(--muted); }
.acc-account-pick { font-weight: 600; color: var(--muted); }
form.acc-bar .combo { min-width: 26rem; }

/* Línies de factura: s'afegeixen i es treuen a l'instant; imports en viu. */
.acc-invoice-lines .col-remove { width: 2.5rem; }
.acc-invoice-lines td { padding-top: .3rem; padding-bottom: .3rem; }
.acc-invoice-lines .acc-amount { padding-top: .75rem; font-variant-numeric: tabular-nums; color: var(--text); white-space: nowrap; }
.acc-invoice-lines input[name$="-description"] { font-weight: 500; }
.acc-invoice-lines tfoot td { border: 0; padding-top: .6rem; }
.acc-keys { margin-left: 1rem; font-size: .82rem; }
.acc-remove { width: 2rem; height: 2rem; margin-top: .15rem; border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer; opacity: .35; transition: opacity .12s, background-color .12s, color .12s; }
.acc-invoice-lines tr:hover .acc-remove, .acc-invoice-lines tr:focus-within .acc-remove { opacity: 1; }
.acc-remove:hover, .acc-remove:focus-visible { background: var(--soft); color: var(--negative); }
.acc-invoice-sum { display: grid; grid-template-columns: auto 9.5rem; gap: .3rem 0; justify-content: end; margin: .5rem 0 1.25rem; font-variant-numeric: tabular-nums; }
.acc-invoice-sum dt { color: var(--muted); text-align: right; }
.acc-invoice-sum dd { margin: 0; text-align: right; padding-right: 2.5rem; padding-left: 1.5rem; }
.acc-invoice-sum .is-total { font-size: 1.15rem; font-weight: 700; color: var(--text); border-top: 1px solid var(--border); padding-top: .4rem; }

/* Resclosa: deixar documents, el que s'ha aturat i el que ha fet la màquina. */
.acc-drop { margin: 0 0 1.25rem; }
.acc-drop-zone { display: flex; align-items: center; gap: .9rem; padding: 1rem 1.25rem; border: 1.5px dashed var(--border); border-radius: var(--radius-card); background: var(--surface); color: var(--muted); cursor: pointer; transition: border-color .12s, background-color .12s; }
.acc-drop-zone .icon { width: 1.6rem; height: 1.6rem; flex: none; color: var(--primary); }
.acc-drop-zone b { color: var(--text); }
.acc-drop-zone:hover, .acc-drop.is-over .acc-drop-zone { border-color: var(--primary); background: var(--primary-soft); }
.acc-resclosa { display: grid; grid-template-columns: minmax(0, 1fr) 21rem; gap: 1.5rem; align-items: start; }
.acc-resclosa h2 { font-size: 1.05rem; margin: 0 0 .6rem; display: flex; align-items: center; gap: .5rem; }
.acc-sub { font-size: .95rem; color: var(--muted); margin: 1.25rem 0 .4rem; }
.acc-queue { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.acc-queue a { display: grid; gap: .15rem; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); }
.acc-queue a:hover, .acc-queue a:focus-visible { text-decoration: none; border-color: var(--primary); }
.acc-queue-who { display: flex; justify-content: space-between; gap: 1rem; }
.acc-queue-who .num { font-variant-numeric: tabular-nums; font-weight: 600; }
.acc-queue-why { color: var(--muted); font-size: .9rem; }
.acc-reading { list-style: none; margin: 0; padding: 0; color: var(--muted); }
.acc-reading li { display: flex; align-items: center; gap: .5rem; padding: .2rem 0; }
.acc-spinner { width: .9rem; height: .9rem; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: acc-spin .8s linear infinite; }
@keyframes acc-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .acc-spinner { animation: none; } }
.acc-side { display: grid; gap: 1rem; }
.acc-side section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: .9rem 1rem; }
.acc-funnel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .5rem; margin: 0; }
.acc-funnel div { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: .1rem; }
.acc-funnel dt { font-size: .75rem; color: var(--muted); line-height: 1.2; }
.acc-funnel dd { margin: 0; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.acc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; font-size: .92rem; }
.acc-list li { display: flex; justify-content: space-between; gap: .75rem; }
.acc-list .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.badge-review { background: var(--warning-soft); }
.badge-booked { background: var(--success-soft); }
.badge-reading { background: var(--primary-soft); }

/* Revisar una factura rebuda: el document a l'esquerra, el que se n'ha llegit a la dreta. */
.acc-review { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.3fr); gap: 1.25rem; align-items: start; }
.acc-review-doc { position: sticky; top: 1rem; display: grid; gap: .4rem; }
.acc-review-doc iframe, .acc-review-doc img { width: 100%; height: calc(100vh - 9rem); border: 1px solid var(--border); border-radius: var(--radius-card); background: #fff; object-fit: contain; }
.acc-review-form .acc-invoice-head { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: 0 1rem; }
.acc-review-form .acc-invoice-head .field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; }
.acc-reason { margin-top: 0; }
.acc-checks { margin: 0 0 1rem; }
.acc-checks summary { cursor: pointer; font-weight: 600; }
.acc-checks ul { list-style: none; margin: .5rem 0; padding: 0; display: grid; gap: .2rem; font-size: .92rem; }
.acc-checks .is-ok { color: var(--muted); }
.acc-checks .is-ok span[aria-hidden] { color: var(--positive); }
.acc-checks .is-bad { color: var(--text); font-weight: 600; }
.acc-checks .is-bad span[aria-hidden] { color: var(--negative); }
.acc-checks-bad { list-style: none; padding: 0; display: grid; gap: .2rem; font-size: .92rem; margin: 0 0 .5rem; }
.acc-invoice-sum .acc-fixes { grid-column: 1 / -1; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .4rem; padding: .3rem 2.5rem 0 0; }
.acc-invoice-sum .is-off { color: var(--negative); font-weight: 600; }
.acc-review-more { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; }
.acc-review-more form { margin: 0; }
.link.danger { color: var(--negative); }
.acc-facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0 0 1rem; }
.acc-facts dt { color: var(--muted); }
.acc-facts dd { margin: 0; }
.acc-rules td { vertical-align: middle; }
.acc-rules .combo { min-width: 18rem; }
.acc-rules input[name$="tax_id"] { width: 9.5rem; font-variant-numeric: tabular-nums; }
.acc-rules th:nth-child(2) { width: 10rem; }
.acc-rules td:first-child input { width: 100%; }
@media (max-width: 1000px) { .acc-resclosa, .acc-review { grid-template-columns: minmax(0, 1fr); } .acc-review-doc { position: static; } .acc-review-doc iframe, .acc-review-doc img, .acc-doc-view { height: 60vh; } }
/* El document ocupa tota l'amplada del panell; si és més llarg, es desplaça dins el marc. */
.acc-doc-view { height: calc(100vh - 9rem); overflow: auto; display: grid; gap: .5rem; align-content: start; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--soft); }
.acc-review-doc .acc-doc-view img { height: auto; border: 0; border-radius: 0; object-fit: initial; }
.acc-doc-view canvas, .acc-doc-view img { display: block; width: 100%; height: auto; background: #fff; }
.acc-doc-view iframe { height: 100%; border: 0; }
.acc-doc-view > p { padding: 1rem; margin: 0; }
.acc-ai-note { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .75rem; align-items: start; margin: 0 0 1rem;
  padding: .85rem 1rem; border: 1px solid var(--primary-line); border-left: 4px solid var(--primary); border-radius: 10px;
  background: var(--primary-soft); color: var(--text); }
.acc-ai-note .icon { width: 20px; height: 20px; color: var(--primary-strong); margin-top: .1rem; }
.acc-ai-note p { margin: .2rem 0 0; }
.acc-review-form .acc-form-lines .col-money { width: 7.5rem; }
.acc-review-form .acc-form-lines .col-rate { width: 6.25rem; }
.acc-review-form .acc-form-lines .col-note { width: 30%; }

/* Banc: comptes, importar l'extracte i conciliar. */
.acc-bank-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; margin-bottom: 1.5rem; align-items: start; }
.acc-bank-accounts { display: grid; gap: .6rem; }
.acc-bank-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: .8rem 1rem; }
.acc-bank-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin: .5rem 0 0; }
.acc-bank-card dt { font-size: .78rem; color: var(--muted); }
.acc-bank-card dd { margin: 0; font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.acc-bank-card dd small { display: block; font-size: .75rem; font-weight: 400; color: var(--muted); }
.acc-asset-add summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.acc-asset-add[open] summary { margin-bottom: .6rem; }
.acc-bank-add summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.acc-bank-add form { margin-top: .6rem; }
.acc-bank-add label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; }
.acc-bank-import form.is-over .acc-drop-zone { border-color: var(--primary); background: var(--primary-soft); }
.acc-bank-note { font-size: .88rem; margin: .5rem 0 0; }
.acc-bank-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.acc-bank-head h2 { font-size: 1.05rem; margin: 0; display: flex; align-items: center; gap: .5rem; }
.acc-movements { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .4rem; }
.acc-movement { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .4rem 1rem; align-items: center; padding: .6rem .9rem; border: 1px solid var(--border); border-left-width: 4px; border-radius: 12px; background: var(--surface); }
.acc-movement.is-safe { border-left-color: var(--positive); }
.acc-movement.is-doubt { border-left-color: var(--warning, #c99a2e); }
.acc-movement:focus-within { border-color: var(--primary); }
.acc-movement-what { grid-column: 1 / -1; display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) auto; gap: .75rem; align-items: baseline; }
.acc-movement-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.acc-movement-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-movement-amount { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc-movement-amount.is-in { color: var(--positive); }
.acc-movement-form { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: 0; padding-left: 3.95rem; }
.acc-movement-form .combo { flex: 1 1 24rem; min-width: 16rem; }
.acc-confidence { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); width: 6.5rem; }
.is-safe .acc-confidence { color: var(--positive); }
.acc-learn { display: flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--muted); }
.acc-learn input[name="rule"] { padding: .2rem .4rem; font-size: .85rem; }
.acc-movement-skip { margin: 0; }
.acc-bank-bottom { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.5rem; margin-top: 2rem; align-items: start; }
.acc-bank-bottom h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.acc-list form { margin: 0; display: inline; }
@media (max-width: 1000px) { .acc-bank-top, .acc-bank-bottom { grid-template-columns: minmax(0, 1fr); } .acc-movement-form { padding-left: 0; } }
.acc-bank-gap { font-size: .85rem; margin: .5rem 0 0; }

/* Nòmines: imports a la vista; el cadenat opcional els difumina. */
.acc-locked .acc-secret, .acc-locked .acc-secret-frame iframe, .acc-locked .acc-secret-frame img { filter: blur(7px); user-select: none; }
.acc-locked .acc-secret input { color: transparent; text-shadow: 0 0 8px var(--text); }
.acc-lock[aria-pressed="true"] { background: var(--primary-soft); }
.acc-lock .icon { margin-right: .35rem; }
.acc-month { max-width: 14rem; display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; }
.acc-slips { overflow-x: auto; }
.acc-slip-lines { min-width: 52rem; }
.acc-slip-lines td input { text-align: right; }
.acc-slip-lines td:first-child input, .acc-slip-lines td:nth-child(2) input { text-align: left; }
.acc-paid { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .25rem; color: var(--muted); }
.acc-paid .is-ok { color: var(--positive); }
.acc-review.is-single { grid-template-columns: minmax(0, 1fr); }

/* Impostos: calendari, models amb caselles traçables i revisió. */
.acc-crumb { margin: 0 0 .2rem; font-size: .88rem; }
.acc-tax-sub { margin: .2rem 0 0; }
.acc-tax-nav { flex-wrap: wrap; }
.acc-tax-nav .button { min-width: 2.75rem; justify-content: center; }
.acc-tax-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.acc-tax-card { display: grid; gap: .15rem; padding: .9rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); color: var(--text); }
.acc-tax-card:hover { text-decoration: none; border-color: var(--primary); }
.acc-tax-card-model { font-weight: 800; color: var(--primary); }
.acc-tax-card-name { font-size: .9rem; color: var(--muted); }
.acc-tax-card-amount { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.acc-tax-card-amount.is-negative { color: var(--positive); }
.acc-tax-calendar td { vertical-align: middle; }
.acc-tax-calendar .acc-tax-due { font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc-tax-calendar tr.is-skip, .acc-tax-calendar tr.is-future { color: var(--muted); }
.acc-tax-calendar tr.is-skip a { color: var(--muted); }
.acc-tax-calendar tr.is-late td:first-child { color: var(--negative); font-weight: 700; }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }
.acc-tax { display: grid; grid-template-columns: minmax(0, 1fr) 20rem; gap: 1.25rem; align-items: start; }
.acc-tax-side { position: sticky; top: 1rem; display: grid; gap: 0; }
.acc-tax-side h2 { font-size: 1.05rem; margin-top: 0; }
.acc-tax-result { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem 1rem; padding: .9rem 1.1rem; margin-bottom: 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--radius-card); }
.acc-tax-result span { font-weight: 600; color: var(--muted); }
.acc-tax-result b { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.acc-tax-result.is-pay { border-left-color: var(--warning-text); }
.acc-tax-result.is-back { border-left-color: var(--positive); }
.acc-boxes { margin-bottom: 1.25rem; }
.acc-boxes h2 { font-size: 1rem; color: var(--muted); margin: 0 0 .35rem; }
.acc-box > summary, div.acc-box { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr) 9rem; gap: .75rem; align-items: baseline; padding: .4rem .6rem; border-top: 1px solid var(--border); }
.acc-box > summary { cursor: pointer; list-style: none; }
.acc-box > summary::-webkit-details-marker { display: none; }
.acc-box > summary:hover { background: var(--soft); }
.acc-box > summary .acc-box-label::after { content: " ▾"; color: var(--muted); font-size: .8em; }
.acc-box[open] > summary .acc-box-label::after { content: " ▴"; }
.acc-box-code { font-weight: 800; color: var(--primary); font-variant-numeric: tabular-nums; }
.acc-box-value { text-align: right; font-variant-numeric: tabular-nums; }
.acc-box.is-strong > summary, div.acc-box.is-strong { font-weight: 700; background: var(--soft); }
div.acc-box.is-zero:not(.is-strong) { color: var(--muted); }
div.acc-box.is-zero .acc-box-code { color: var(--muted); }
.acc-box-sources { list-style: none; margin: 0 0 .5rem 3.95rem; padding: .25rem .6rem; display: grid; gap: .2rem; font-size: .9rem; border-left: 2px solid var(--primary-line); }
.acc-box-sources li { display: flex; justify-content: space-between; gap: 1rem; }
.acc-box-sources .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc-tax-rows details summary { cursor: pointer; color: var(--primary); }
.acc-tax-rows .acc-box-sources { margin: .3rem 0 0; min-width: 18rem; }
.acc-tax-notes { color: var(--muted); font-size: .92rem; padding-left: 1.1rem; }
.acc-findings ul { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .45rem; font-size: .92rem; }
.acc-findings li { display: grid; grid-template-columns: 1rem minmax(0, 1fr); gap: .4rem; }
.acc-findings li > span { font-weight: 800; }
.acc-findings .is-ok { color: var(--muted); }
.acc-findings .is-ok > span { color: var(--positive); }
.acc-findings .is-bad > span { color: var(--negative); }
.acc-findings .is-warn > span { color: var(--warning-text); }
.acc-findings h3 { font-size: .95rem; margin: 0 0 .4rem; }
.acc-tax-side .field-check label { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.acc-rates { table-layout: fixed; width: 100%; min-width: 74rem; }
.acc-rates td { padding-left: .3rem; padding-right: .3rem; }
.acc-rates .col-year { width: 5.5rem; }
.acc-rates .col-rate { width: 6.5rem; }
.acc-rates .col-money { width: 8.5rem; }
.acc-rates .col-note { width: auto; }
.acc-rates input { min-width: 0; width: 100%; box-sizing: border-box; }
.acc-rates td:not(:last-child) input { text-align: right; }
.table-wrap { overflow-x: auto; }
.acc-rates small.error { color: var(--danger); display: block; font-size: .8rem; }
.acc-resclosa .is-late a { color: var(--negative); font-weight: 600; }
@media (max-width: 960px) {
  .acc-tax { grid-template-columns: minmax(0, 1fr); }
  .acc-tax-side { position: static; }
  .acc-box > summary, div.acc-box { grid-template-columns: 2.6rem minmax(0, 1fr) 7rem; }
}

/* --- Comptes: tancament --- */
.acc-steps { list-style: none; padding: 0; margin: 1rem 0 1.25rem; display: grid; gap: .4rem; max-width: 52rem; }
.acc-steps li { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr); gap: .6rem; align-items: start; padding: .6rem .9rem;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.acc-steps li small { display: block; text-transform: uppercase; letter-spacing: .04em; font-size: .72rem; }
.acc-step-mark { width: 1.5rem; height: 1.5rem; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.acc-steps .is-done { background: var(--success-soft); border-color: var(--success-line); }
.acc-steps .is-done .acc-step-mark { background: var(--positive); color: #fff; }
.acc-steps .is-todo { background: var(--warning-soft); border-color: var(--note-line); }
.acc-steps .is-todo .acc-step-mark { background: var(--warning-text); color: var(--surface); }
.acc-steps .is-todo a { color: var(--warning-text); text-decoration: underline; text-underline-offset: 2px; }
.acc-steps .is-info .acc-step-mark { background: var(--soft); color: var(--muted); }
.acc-close-form { display: grid; gap: .6rem; justify-items: start; max-width: 52rem; }
.acc-closed-note { display: flex; gap: .5rem; align-items: center; padding: .8rem 1rem; border-radius: 10px; background: var(--primary-soft); max-width: 52rem; }
.acc-closed-note .icon { width: 18px; height: 18px; }
.acc-depreciations { max-width: 52rem; margin-bottom: 1rem; }
.acc-depreciations summary { cursor: pointer; font-weight: 600; margin-bottom: .5rem; }
.acc-year-steps { max-width: 60ch; display: grid; gap: .4rem; margin: 1rem 0 1.25rem; }
.acc-deadlines { max-width: 52rem; }
.acc-assets td:first-child { min-width: 16rem; }
.acc-asset-form { max-width: 52rem; margin-top: 1.5rem; }
.acc-form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 14rem), 1fr)); gap: .75rem 1rem; margin-bottom: 1rem; }
.acc-form-grid .field { display: grid; gap: .25rem; align-content: start; }
.acc-form-grid .is-wide { grid-column: 1 / -1; }
.acc-form-grid .error { color: var(--danger); }
.acc-annual { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 30rem), 1fr)); gap: 1rem; align-items: start; }
.acc-annual h3 { margin: 1rem 0 .25rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
div.acc-statement-line, .acc-statement-line > summary { display: flex; justify-content: space-between; gap: 1rem; }
.acc-statement-line { border-bottom: 1px solid var(--border); padding: .3rem 0; }
.acc-statement-line > summary { cursor: pointer; list-style: none; }
.acc-statement-line > summary::-webkit-details-marker { display: none; }
.acc-statement-line > summary span::after { content: " ▸"; color: var(--muted); font-size: .8em; }
.acc-statement-line[open] > summary span::after { content: " ▾"; }
.acc-statement-line ul { list-style: none; margin: .25rem 0 .4rem 1rem; padding: 0; font-size: .9rem; }
.acc-statement-line li { display: flex; justify-content: space-between; color: var(--muted); }
.acc-statement-line b { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc-statement-line.is-strong b, .acc-statement-line.is-strong > summary b, .acc-statement-line.is-strong span { font-weight: 700; }
.acc-statement-line.is-zero { color: var(--muted); }
.acc-statement-line.is-total { border-bottom: 2px solid var(--text); margin-top: .25rem; }
.acc-warning { margin-top: .75rem; padding: .6rem .8rem; border-radius: 8px; background: var(--warning-soft); color: var(--warning-text); }
@media print {
  .page-header .actions, .site-header, .main-nav { display: none !important; }
  .acc-statement-line[open] > summary span::after, .acc-statement-line > summary span::after { content: ""; }
}

/* --- Comptes: com va --- */
.acc-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: .75rem; margin-bottom: 1rem; }
.acc-figure { display: grid; gap: .2rem; align-content: start; padding: 1rem 1.1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-card); color: var(--text); }
.acc-figure:hover { text-decoration: none; border-color: var(--primary); }
.acc-figure-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.acc-figure-amount { font-size: 1.75rem; font-variant-numeric: tabular-nums; }
.acc-figure.is-good .acc-figure-amount { color: var(--positive); }
.acc-figure.is-bad .acc-figure-amount { color: var(--negative); }
.acc-figure-sentence { font-size: .92rem; line-height: 1.45; }
.acc-summary { max-width: 70ch; }
.acc-summary-action { padding: .5rem .75rem; border-radius: 8px; background: var(--primary-soft); }
.acc-summary .htmx-indicator { display: none; margin-left: .5rem; }
.acc-summary .htmx-request .htmx-indicator, .acc-summary .htmx-request.htmx-indicator { display: inline; }
.acc-warning-text { color: var(--negative); }
.acc-forecast-chart { margin: .5rem 0 .75rem; }
.acc-forecast-chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.acc-chart-grid { stroke: var(--border); stroke-width: 1; }
.acc-chart-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.acc-chart-cushion { stroke: var(--warning-text); stroke-width: 1.5; stroke-dasharray: 5 4; }
.acc-chart-area { fill: var(--primary); opacity: .08; }
.acc-chart-line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.acc-chart-point circle:last-child { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.acc-chart-point.is-low circle:last-child { fill: var(--negative); }
.acc-chart-hit { fill: transparent; cursor: default; }
.acc-chart-point:hover circle:last-child { r: 6; }
.acc-forecast-table { max-width: 60rem; margin-bottom: 1.5rem; }
.acc-forecast-table > summary { cursor: pointer; font-weight: 600; margin-bottom: .5rem; }
.acc-forecast-table tr.is-low td { background: var(--danger-soft); }
.acc-overview-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; align-items: stretch; margin-bottom: 1rem; }
.acc-overview-cols .card { margin: 0; }
.acc-overview-side { display: grid; gap: 1rem; }
.acc-forecast h2, .acc-overview-side h2 { margin-top: 0; }
@media (max-width: 1200px) { .acc-overview-cols { grid-template-columns: minmax(0, 1fr); } }
.acc-free td:last-child, .acc-free th:last-child { text-align: right; }
.acc-projects td:first-child { min-width: 14rem; }
.acc-projects .is-negative { color: var(--negative); }
.button.danger { color: var(--danger); border-color: var(--danger-line); }
.button.danger:hover { background: var(--danger-soft); }
.acc-purge { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin: 0 0 1rem; }

/* Confirmacions pròpies (confirm.js), en lloc de les del navegador. */
.confirm-dialog { border: 0; border-radius: 14px; padding: 0; width: min(28rem, 92vw); background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .28); }
.confirm-dialog::backdrop { background: rgba(20, 28, 40, .4); }
.confirm-dialog[open] { animation: confirm-in .14s ease-out; }
@keyframes confirm-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .confirm-dialog[open] { animation: none; } }
.confirm-dialog form { display: grid; gap: .75rem; padding: 1.35rem 1.5rem 1.25rem; }
.confirm-dialog h2 { margin: 0; font-size: 1.15rem; line-height: 1.3; }
.confirm-dialog p { margin: 0; color: var(--muted); line-height: 1.5; }
.confirm-dialog-field { display: grid; gap: .3rem; font-size: .85rem; color: var(--muted); }
.confirm-dialog-field input { width: 100%; font-size: 1rem; }
.confirm-dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }
.confirm-dialog .button.is-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.confirm-dialog .button.is-danger:hover { filter: brightness(1.08); }
.confirm-dialog .button:focus-visible { outline: 3px solid var(--primary-line); outline-offset: 2px; }

/* Correu: enviar factures i recordatoris i seguir-los. */
.acc-mail h2 { margin-top: 0; }
.acc-mail-log { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: .45rem; }
.acc-mail-log li { display: grid; gap: .3rem; padding: .6rem .85rem; border: 1px solid var(--border); border-left: 4px solid var(--success); border-radius: 10px; background: var(--surface); }
.acc-mail-log li.is-bounced { border-left-color: var(--danger); }
.acc-mail-log li.is-failed { border-left-color: var(--warning); }
.acc-mail-states { display: flex; flex-wrap: wrap; gap: .35rem; }
.acc-mail-compose summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.acc-mail-form { margin-top: .75rem; max-width: 46rem; }
.acc-mail-form textarea { min-height: 11rem; }
.acc-mail-form .field-check label { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
.acc-public-invoice dl { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .4rem 1rem; margin: 1rem 0 1.5rem; }
.acc-public-invoice dt { color: var(--muted); }
.acc-public-invoice dd { margin: 0; }
.acc-entra-error { margin: .5rem 0; padding: .5rem .75rem; border-radius: 8px; background: var(--danger-soft); color: var(--danger-text); }
.acc-entra-steps { margin: .5rem 0 .75rem; padding-left: 1.25rem; display: grid; gap: .25rem; }
.acc-demo { grid-column: 1 / -1; border-left: 4px solid var(--warning, #d9a400); }
.acc-demo .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.demo-strip { margin: 0 0 1rem; padding: .45rem .8rem; border-radius: 8px; background: var(--warning-soft); font-size: .88rem; }
.table td.num + td:not(.num), .table th.num + th:not(.num) { padding-left: 1.5rem; }
.acc-filter-on { margin: -.4rem 0 .8rem; font-size: .92rem; }
.acc-due-head { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: .6rem 0 .3rem; }
.acc-due-head.is-late { color: var(--negative); margin-top: 0; }
.acc-due .num.is-in { color: var(--positive); }
.chip-count { display: inline-block; min-width: 1.3em; padding: 0 .35em; margin-left: .25rem; border-radius: 999px; background: var(--soft); color: var(--text); font-size: .78rem; text-align: center; }
.acc-chips a[aria-current] .chip-count { background: rgba(255,255,255,.25); color: inherit; }
.acc-origin { margin: -.2rem 0 .8rem; }
.acc-prevnext { display: flex; justify-content: space-between; margin-bottom: .5rem; font-size: .92rem; }
.acc-bank-diff { margin: .5rem 0 0; font-size: .88rem; color: var(--positive); }
.acc-bank-diff.is-off { color: var(--warning-text, var(--muted)); }
.acc-bank-card a { color: inherit; }
.acc-h-link { font-size: .85rem; font-weight: 500; margin-left: auto; }
.acc-reason { flex-basis: 100%; margin: 0; font-size: .85rem; color: var(--muted); }
.acc-learn input[name="rule"] { min-width: 12rem; }
.acc-unmatch { margin: 0; }
.acc-unmatch button.link { color: var(--muted); font-size: .85rem; }
.acc-unmatch button.link:hover { color: var(--negative); }
@media (min-width: 1200px) {
  .acc-movement { grid-template-columns: minmax(16rem, 1fr) minmax(0, 1.5fr) auto; }
  .acc-movement-what { grid-column: auto; }
  .acc-movement-form { padding-left: 0; flex-wrap: wrap; }
  .acc-movement-form .combo { flex: 1 1 16rem; min-width: 12rem; }
}
.acc-bank-bottom h2 { display: flex; align-items: baseline; gap: .5rem; }
.acc-bank-top:has(> .acc-bank-import[hidden]) { grid-template-columns: minmax(0, 1fr); }
.acc-bank-top:has(> .acc-bank-import[hidden]) .acc-bank-accounts { grid-template-columns: repeat(auto-fill, minmax(24rem, 1fr)); }
.hide-zero .acc-box.is-zero { display: none; }
.hide-zero .acc-boxes:not(:has(.acc-box:not(.is-zero))) { display: none; }
.acc-boxes-tools { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; font-size: .85rem; margin: 0 0 .5rem; }
.acc-box-value { cursor: copy; border-radius: 6px; transition: background-color .15s; }
.acc-box-value:hover { background: var(--primary-soft); }
.acc-box-value.is-copied { background: var(--positive-soft, var(--primary-soft)); }
.acc-box-value.is-copied::after { content: " ✓ copiat"; font-size: .75rem; font-weight: 500; color: var(--positive); }
.acc-tax-due-now { display: grid; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); gap: 1rem; margin: 0 0 1.5rem; }
.acc-tax-due-block { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: .8rem 1rem; }
.acc-tax-due-block h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 .4rem; }
.acc-tax-due-block.is-late { border-left: 4px solid var(--negative); }
.acc-tax-due-block.is-late h2 { color: var(--negative); }
.hide-zero .acc-box.is-zero + .acc-box.is-pct { display: none; }
.acc-list-tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; margin: 0 0 .75rem; }
.acc-list-tools input[type="search"] { flex: 0 1 22rem; }
.acc-list-tools select { width: auto; }
.acc-list-table thead th { position: sticky; top: 0; z-index: 1; background: var(--bg); }
th.is-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.is-sortable:hover { color: var(--text); }
th[aria-sort="ascending"]::after { content: " ↑"; }
th[aria-sort="descending"]::after { content: " ↓"; }
tr[data-href] { cursor: pointer; }
tr[data-href]:hover td { background: var(--surface-2, var(--primary-soft)); }
tr.is-selected td { background: var(--primary-soft); }
tr.is-selected { outline: 2px solid var(--primary); outline-offset: -2px; }
tr.is-reversed td { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent); }
.acc-closing { display: grid; gap: 1.25rem; align-items: start; }
.acc-closing-now h2 { font-size: 1rem; margin: 0 0 .6rem; }
.acc-closing-now .acc-steps { margin: 0 0 .9rem; }
@media (min-width: 1100px) {
  .acc-closing { grid-template-columns: minmax(0, 1.6fr) minmax(20rem, 1fr); }
  .acc-closing .acc-months { grid-template-columns: repeat(4, minmax(0, 1fr)); max-width: none; margin: 0; gap: .6rem; }
  .acc-closing .acc-months li { grid-template-columns: minmax(0, 1fr); align-content: start; gap: .3rem; min-height: 7.2rem; padding: .8rem .9rem; }
  .acc-closing .acc-months li > :last-child { justify-self: start; }
  .acc-closing .acc-months li > .muted:nth-child(2) { display: block; }
  .acc-closing-now { position: sticky; top: 1rem; }
}
tr.is-out { display: none; }
.acc-chips button.link { padding: .3rem .7rem; border-radius: 999px; color: var(--muted); text-decoration: none; }
.acc-chips button.link[aria-pressed="true"] { background: var(--primary-soft); color: var(--text); font-weight: 600; }
.acc-chart-new { margin-left: auto; }
details.acc-subaccount { position: static; margin: 0 0 1rem; }
details.acc-subaccount:not([open]) { display: none; }
.acc-subaccount-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: .5rem 1rem; max-width: 40rem; }
.acc-chart-add { font-size: .85rem; color: var(--muted); visibility: hidden; }
tr:hover .acc-chart-add, tr.is-selected .acc-chart-add, .acc-chart-add:focus { visibility: visible; }
.acc-settings-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr)); gap: 1rem 1.5rem; }
.acc-settings-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.acc-settings-group legend { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: .4rem; }
.acc-invoice-main { display: grid; gap: 1rem; align-content: start; min-width: 0; }
.acc-invoice-books h2 { font-size: 1rem; margin: 0 0 .4rem; }
.acc-invoice-books p { margin: 0; }
.acc-year-cols { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 1100px) { .acc-year-cols { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); } .acc-year-after h2 { margin-top: 0; } }
.is-foldable { margin-bottom: .2rem; }
.is-folded { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.acc-help-toggle { font-size: .85rem; color: var(--muted); margin: 0 0 1rem; }
.acc-help-toggle:hover { color: var(--text); }
.acc-ledger-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.acc-ledger-balance { margin: 0; font-size: 1.05rem; }
.acc-ledger-balance b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.acc-ok { color: var(--positive); }
.acc-form-lines col.col-x { width: 2.2rem; }
.acc-line-x { color: var(--muted); font-size: 1.1rem; padding: 0 .3rem; }
.acc-line-x:hover { color: var(--negative); }
.acc-field-link { font-size: .82rem; font-weight: 500; margin-left: .4rem; }
.acc-more { margin: .75rem 0; }
.acc-more summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.acc-more[open] summary { margin-bottom: .5rem; }
.acc-saved { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.acc-saved.is-ok { color: var(--positive); }
.acc-saved.is-off { color: var(--negative); }
.acc-payroll-missing td { color: var(--muted); font-style: italic; }
.acc-payroll-missing td:first-child { font-style: normal; font-weight: 600; }
.acc-annual-tools { display: flex; justify-content: flex-end; margin: 0 0 .5rem; }
.acc-estimate span { font-style: italic; }
@media print { .acc-annual-tools { display: none; } }
.acc-month-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .5rem; margin: 1rem 0; max-width: 46rem; }
.acc-month-summary div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: .6rem .8rem; }
.acc-month-summary dt { font-size: .78rem; color: var(--muted); }
.acc-month-summary dd { margin: 0; font-weight: 700; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.acc-month-summary dd.is-negative { color: var(--negative); }
.acc-tax-calendar tr.is-skip td { opacity: .55; }
.acc-invoice-notes { display: grid; gap: .3rem; margin-top: 1rem; }
.acc-invoice-notes textarea { width: 100%; }
.acc-invoice-notes small { color: var(--muted); }
/* Banc: cada compte en una sola fila */
.acc-bank-top:has(> .acc-bank-import[hidden]) .acc-bank-accounts { grid-template-columns: minmax(0, 1fr); }
.acc-bank-card { display: grid; grid-template-columns: minmax(14rem, 1.2fr) minmax(0, 2fr) minmax(12rem, 1.4fr); align-items: center; gap: .5rem 1.5rem; padding: .6rem 1rem; }
.acc-bank-card header { display: flex; flex-direction: column; gap: .1rem; }
.acc-bank-card dl { margin: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.acc-bank-card dd small { display: inline; margin-left: .4rem; }
.acc-bank-card .acc-bank-diff { margin: 0; text-align: right; }
.acc-bank-card .acc-bank-gap { grid-column: 1 / -1; margin: 0; }
.acc-bank-top:not(:has(> .acc-bank-import[hidden])) .acc-bank-card { grid-template-columns: minmax(0, 1fr); }
.acc-bank-top:not(:has(> .acc-bank-import[hidden])) .acc-bank-card .acc-bank-diff { text-align: left; }
.acc-settings-bank-list { list-style: none; padding: 0; margin: 0 0 .75rem; display: grid; gap: .25rem; }
.acc-settings-banks .acc-bar label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; }
.acc-summary-strip { max-width: none; margin-bottom: 1rem; display: flex; gap: .5rem 1.25rem; align-items: baseline; flex-wrap: wrap; }
.acc-summary-strip h2 { margin: 0; font-size: 1.05rem; }
.acc-summary-strip #acc-summary { flex: 1 1 30rem; max-width: 90ch; }
.acc-summary-strip #acc-summary form { margin: 0; }
.acc-projects-card { margin-bottom: 1rem; }
.acc-projects-card h2 { margin-top: 0; }
.acc-pending-work { font-size: .85rem; line-height: 1.35; }
.acc-projects-card .button.small { padding: .25rem .6rem; font-size: .82rem; white-space: nowrap; }
.acc-projects-card form { margin: 0; }
/* Ajuda de cada pàgina: panell a la dreta */
.help-button { font-weight: 700; font-size: 1rem; }
.help-panel { margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(34rem, 100vw); max-width: 100vw; padding: 1.25rem 1.5rem 2rem;
  border: 0; border-left: 1px solid var(--border); background: var(--surface); color: var(--text); overflow-y: auto; }
.help-panel::backdrop { background: rgb(0 0 0 / .35); }
.help-panel header { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.help-panel h2 { margin: 0; font-size: 1.2rem; }
.help-panel h3 { margin: 1.25rem 0 .4rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.help-purpose { font-size: 1.02rem; line-height: 1.5; margin: .75rem 0 0; }
.help-panel ol { margin: 0; padding-left: 1.2rem; display: grid; gap: .35rem; line-height: 1.45; }
.help-panel dl { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: .45rem 1rem; margin: 0; line-height: 1.4; }
.help-panel dt { font-weight: 600; }
.help-panel dd { margin: 0; color: var(--muted-strong, var(--text)); }
.help-keys dt { font-weight: 400; white-space: nowrap; }
@media (max-width: 600px) { .help-panel dl { grid-template-columns: 1fr; } .help-panel dd { margin-bottom: .4rem; } }

/* --- Seguiment (expedients) --- */
.case-today { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 24rem), 1fr)); gap: 1rem; align-items: start; }
.case-today .card { margin: 0; }
.case-today h2 { font-size: 1rem; margin: 0 0 .6rem; }
.case-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.case-row { display: flex; flex-direction: column; gap: .1rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line, var(--soft)); }
.case-row:last-child { border-bottom: 0; }
.case-pending { font-size: .85rem; border-radius: 6px; padding: 1px 7px; background: var(--soft); }
.case-pending.is-late { background: var(--danger-soft); color: var(--danger-text); }
.case-pending.is-today, .case-pending.is-review { background: var(--warning-soft); color: var(--warning-text); }
.case-timeline { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .6rem; }
.case-timeline li { border-left: 3px solid var(--soft); padding-left: .6rem; }
.case-timeline li.is-system { opacity: .75; }
.case-timeline li.is-corrected p { text-decoration: line-through; }
.case-timeline p { margin: .15rem 0 0; }
.case-inline { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.case-inline input[type=text] { flex: 1 1 14rem; }
.case-correct form { display: flex; flex-direction: column; gap: .4rem; margin-top: .3rem; }
.case-correct textarea { width: 100%; min-height: 4.5rem; resize: vertical; }
.case-correct input[name=amount] { width: 10rem; }
.case-correct .actions { display: flex; align-items: center; gap: .75rem; margin: 0; }
.case-quote { margin-bottom: 1.2rem; }
.case-quote h3 { font-size: .95rem; margin: 0 0 .4rem; }
.case-quote .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.case-undo { margin-top: .6rem; }
.case-undo summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.record-bar { position: relative; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin: 0 0 1rem; }
.record-search { flex: 1 1 22rem; }
.record-search input { width: 100%; }
.record-new { display: flex; gap: .5rem; flex-wrap: wrap; }
.record-results:empty { display: none; }
.record-results { position: absolute; top: calc(100% + .25rem); left: 0; z-index: 30; width: min(40rem, 100%);
  max-height: 70vh; overflow: auto; background: var(--surface); border: 1px solid var(--soft); border-radius: 10px;
  box-shadow: 0 12px 32px rgb(0 0 0 / .25); padding: .4rem; display: flex; flex-direction: column; gap: .1rem; }
.record-results .muted { margin: .4rem .6rem; }
.record-hit { display: flex; gap: .3rem; align-items: stretch; }
.record-hit > .search-result:first-child { flex: 1; }
.record-hit-new { align-self: center; white-space: nowrap; font-size: .85rem; }
.record-create { border-top: 1px solid var(--soft); margin-top: .3rem; padding-top: .3rem; }
.record-results .search-result:first-child { background: transparent; }
.record-results > :first-child > .search-result:first-child, .record-results > a.search-result:first-child,
.record-results .search-result:hover, .record-results .search-result:focus { background: var(--hover); }

/* --- Agenda --- */
.agenda-tools { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.agenda-move { display: flex; gap: .3rem; }
.visit-chip { display: block; font-size: .82rem; line-height: 1.25; padding: .25rem .45rem; border-radius: 6px; margin-bottom: .25rem;
  background: var(--primary-soft); color: var(--text); border-left: 3px solid var(--primary); text-decoration: none; overflow: hidden; }
.visit-chip:hover { text-decoration: none; filter: brightness(1.1); }
.visit-chip span { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.visit-chip.kind-delivery { background: var(--success-soft); border-left-color: var(--positive); }
.visit-chip.kind-repair, .visit-chip.kind-review { background: var(--warning-soft); border-left-color: var(--warning-text); }
.visit-chip.is-done { opacity: .55; }
.visit-chip.is-no_show, .visit-chip.is-cancelled { opacity: .5; text-decoration: line-through; }
.agenda-week-wrap, .agenda-day-wrap { overflow-x: auto; }
.agenda-week { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 52rem; }
.agenda-week th, .agenda-week td { border: 1px solid var(--soft); padding: .35rem; vertical-align: top; }
.agenda-week thead th { font-size: .85rem; text-align: left; }
.agenda-week tbody th { width: 9rem; font-size: .85rem; text-align: left; }
.agenda-week thead th:first-child { width: 9rem; }
.agenda-week td { height: 4.5rem; position: relative; }
.agenda-week .is-today { background: var(--hover); }
.agenda-add { display: block; text-align: center; color: var(--muted); opacity: 0; font-size: 1.1rem; text-decoration: none; }
.agenda-week td:hover .agenda-add, .agenda-add:focus { opacity: 1; }
.agenda-day { display: grid; grid-template-columns: 3.5rem repeat(var(--lanes), minmax(11rem, 1fr));
  grid-template-rows: 2rem repeat(var(--rows), 1.15rem); min-width: calc(3.5rem + var(--lanes) * 11rem); }
.agenda-corner { grid-row: 1; grid-column: 1; }
.agenda-lane-head { grid-row: 1; font-size: .85rem; font-weight: 600; padding: .3rem; border-bottom: 1px solid var(--soft); }
.agenda-hour { grid-column: 1; font-size: .75rem; color: var(--muted); border-top: 1px solid var(--soft); padding-right: .3rem; text-align: right; }
.agenda-slot { border-top: 1px solid var(--soft); border-left: 1px solid var(--soft); }
.agenda-slot:hover { background: var(--hover); }
.agenda-block { z-index: 1; padding: 1px 2px; overflow: hidden; }
.agenda-block .visit-chip { height: 100%; margin: 0; }
/* Arrossegar i estirar (frontend/src/agendadrag.js). */
.agenda-block[data-move-url] { position: relative; cursor: grab; touch-action: none; }
.agenda-block[data-move-url] .visit-chip { cursor: inherit; }
.agenda-resize { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; cursor: ns-resize; }
.agenda-resize::after { content: ""; position: absolute; left: 40%; right: 40%; bottom: 2px; height: 2px; border-radius: 2px; background: currentColor; opacity: 0; }
.agenda-block:hover .agenda-resize::after { opacity: .5; }
.agenda-block.is-dragging { z-index: 5; opacity: .85; cursor: grabbing; width: 100%; margin-left: 0; box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.agenda-block.is-saving { opacity: .6; pointer-events: none; }
.agenda-drag-time { position: absolute; right: 4px; top: 2px; font-size: .72rem; font-weight: 600; background: var(--surface); padding: 0 .25rem; border-radius: 4px; }
.agenda-mine { margin-bottom: .8rem; }
.agenda-mine h2 { font-size: 1rem; margin: 0 0 .5rem; }
.agenda-teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); gap: 1rem; align-items: start; }
.agenda-teams h2 { font-size: 1rem; margin: 0; }
.agenda-teams .check { display: flex; gap: .4rem; align-items: center; }
.case-visits { list-style: none; padding: 0; margin: .5rem 0 0; }
.agenda-block .visit-chip { padding: .1rem .4rem; }
.agenda-block .visit-chip span { display: inline; }
.agenda-block .visit-chip span::before { content: " · "; }

/* --- Vendes --- */
.sales-open { max-width: 28rem; }
.till { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.till-scan .search-field { width: 100%; }
.till-scan input[type=search] { width: 100%; font-size: 1.1rem; }
.till-lookup { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.till-lookup:empty { display: none; }
.till-hit { display: flex; gap: .4rem; align-items: baseline; padding: .4rem .6rem; border-radius: 8px; border: 1px solid var(--soft);
  background: var(--surface); color: var(--text); cursor: pointer; text-align: left; }
.till-hit:hover, .till-hit:focus { background: var(--hover); }
.till-hit-price { font-weight: 700; }
.till-free { margin-top: .6rem; } .till-free summary { cursor: pointer; color: var(--muted); font-size: .9rem; }
.till-free-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: .5rem; align-items: end; }
.till-cart { display: grid; grid-template-columns: minmax(0, 1fr) 22rem; gap: 1rem; align-items: start; }
.till-table td { vertical-align: middle; }
.till-qty { display: inline-flex; gap: .2rem; align-items: center; }
.till-qty input { width: 3.5rem; text-align: center; }
.till-num { width: 5.5rem; text-align: right; }
.till-empty { text-align: center; padding: 2rem; }
.till-pay { margin: 0; display: flex; flex-direction: column; gap: .6rem; position: sticky; top: 4.5rem; }
.till-who { display: grid; gap: .4rem; } .till-who label { display: grid; gap: .2rem; font-size: .85rem; }
.till-total { font-size: 2.2rem; font-weight: 800; text-align: right; margin: .2rem 0; }
.till-quick { display: flex; gap: .4rem; flex-wrap: wrap; }
.till-split { display: grid; grid-template-columns: 1fr 1fr; gap: .4rem; }
.till-split label { display: grid; gap: .15rem; font-size: .85rem; }
.till-status { margin: 0; font-weight: 600; color: var(--warning-text); }
.till-status.is-ok { color: var(--positive); }
.till-charge { font-size: 1.1rem; padding: .7rem; }
.till-charge kbd { font-size: .7rem; opacity: .7; }
@media (max-width: 1000px) { .till-cart { grid-template-columns: minmax(0, 1fr); } .till-pay { position: static; } }
.ticket-frame { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }
.sales-variant { border-bottom: 1px solid var(--soft); padding: .5rem 0; }
.sales-variant-form { display: flex; gap: .4rem; flex-wrap: wrap; align-items: end; }
.sales-variant-form label { display: grid; gap: .15rem; font-size: .8rem; }
.sales-variant-form input[type=text], .sales-variant-form input[type=number] { width: 8rem; }
.sales-sums { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; margin: 0; }
.sales-sums dd { margin: 0; text-align: right; }
.sales-settings { margin-top: 1.5rem; max-width: 32rem; }
.is-muted { opacity: .55; }
.agenda-block { width: calc(100% / var(--subs, 1)); margin-left: calc(100% * var(--sub, 0) / var(--subs, 1)); }
.quick-dates { display: inline-flex; gap: .3rem; margin-left: .4rem; flex-wrap: wrap; vertical-align: middle; }
.case-postpone { display: inline-flex; gap: .3rem; align-items: center; margin-left: .4rem; }
.record-hit-case { margin-left: 1.2rem; border-left: 2px solid var(--soft); }

/* Expedients: el bloc «Pendents sense data» a la llista (Joel, 6-12). */
.rows-heading th { text-align: left; padding-top: .9rem; font-weight: 600; }
.rows-heading small { font-weight: 400; margin-left: .4rem; }

/* Caixa: el panell de cobrament (22rem) en una columna neta, sense desbordar (Joel, 6-12). */
.till-pay-form { display: grid; gap: .5rem; }
.till-quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .3rem; }
.till-quick .button { justify-content: center; padding: .45rem .3rem; font-size: .85rem; white-space: nowrap; }
.till-split input { width: 100%; min-width: 0; }
.till-pay-form .check { display: flex; gap: .4rem; align-items: flex-start; font-size: .85rem; line-height: 1.3; margin: 0; }
.till-pay-form .check input { flex: none; margin-top: .1rem; }
.till-charge { width: 100%; justify-content: center; }
.till-free-form .field { margin-bottom: 0; }  /* el botó Afegir, a ran dels camps de la línia lliure */
.till-hit[aria-selected="true"] { background: var(--hover); border-color: var(--primary); outline: 1px solid var(--primary); }  /* marcat amb les fletxes */
/* Llista d'Expedients: Obert/Tancat com a commutador, tot centrat a la mateixa línia (Joel, 6-12). */
.case-tools .segmented { align-self: center; }
.case-tools .search-field { margin-bottom: 0; }
.case-tools .check { display: inline-flex; align-items: center; gap: .4rem; margin: 0; }
.case-tools .check input { margin: 0; }
/* El comptador dins d'un botó principal (p. ex. «Des d'expedients»): invertit, perquè es llegeixi en tots dos temes (Joel, 6-12). */
.button.primary .badge { background: var(--primary-text); color: var(--primary); font-weight: 600; }
/* Agenda de la setmana: arrossegar visites a un altre dia o persona, a la mateixa hora (Joel, 6-12). */
.agenda-week-item[data-move-url] { cursor: grab; touch-action: none; }
.agenda-week-item[data-move-url] .visit-chip { cursor: inherit; }
.agenda-week-item.is-dragging { opacity: .35; }
.agenda-week-item.is-saving { opacity: .6; pointer-events: none; }
.agenda-week-ghost { position: fixed; z-index: 1000; pointer-events: none; opacity: .9; box-shadow: 0 6px 18px rgba(0,0,0,.25); border-radius: 6px; }
.agenda-week-ghost .visit-chip { margin: 0; }
.agenda-week td.is-drop-target { background: var(--primary-soft); outline: 2px dashed var(--primary); outline-offset: -2px; }
/* Telèfons i correus del client: una fila per a cadascun (Joel, 6-12). */
.contact-editor { grid-column: 1 / -1; border: 0; padding: 0; margin: 0 0 .9rem; min-width: 0; }
.contact-editor legend { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; padding: 0; }
.contact-row { display: grid; grid-template-columns: minmax(10rem, 1.4fr) minmax(8rem, 1fr) auto auto; gap: .4rem; align-items: center; margin-bottom: .35rem; }
.contact-row input[type=tel], .contact-row input[type=email], .contact-row input[type=text] { width: 100%; min-width: 0; }
.contact-main { display: inline-flex; align-items: center; gap: .3rem; font-size: .85rem; color: var(--muted); white-space: nowrap; margin: 0; }
.contact-main input { margin: 0; }
@media (max-width: 600px) { .contact-row { grid-template-columns: 1fr auto; } .contact-row input[name$="_label"] { grid-column: 1; } }

/* Configuració: pàgina pròpia, fora dels portals, amb una pestanya per mòdul a dalt (Joel, 6-12). */
.settings-topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.settings-title { display: inline-flex; align-items: center; gap: .45rem; font-weight: 700; font-size: 1.05rem; }
.settings-tabs { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 4px; margin-left: .5rem; overflow-x: auto; max-width: 100%; }
.settings-tabs a { display: flex; align-items: center; min-height: 36px; padding: 0 1rem; border-radius: 999px; color: var(--text); text-decoration: none; font-weight: 600; white-space: nowrap; }
.settings-tabs a:hover { background: var(--surface); }
.settings-tabs a[aria-current="page"] { background: var(--primary); color: var(--primary-text); }
.users-card { padding-bottom: 1rem; }
.users-table { margin: 0 0 1rem; background: none; }
.users-table .users-check { text-align: center; width: 1%; white-space: nowrap; }
.users-table input[type="checkbox"] { width: 1.1rem; height: 1.1rem; }
.users-table .users-mail { display: block; }
.users-table tr.is-admin td:not(:first-child):not(:nth-child(2)):not(:last-child) { opacity: .45; }
.users-table tr.is-inactive td:first-child { opacity: .55; }
.users-new { margin-top: 1.25rem; max-width: 52rem; }
.users-new-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: .25rem 1rem; }
.users-new-modules { border: 1px solid var(--border); border-radius: var(--radius, 8px); padding: .6rem .9rem; display: flex; flex-wrap: wrap; gap: .4rem 1.25rem; align-items: center; margin: .5rem 0 0; }
.users-new-modules legend { font-weight: 650; padding: 0 .3rem; }
.users-new-modules .check { display: inline-flex; gap: .4rem; align-items: center; }
.users-new-modules:disabled { opacity: .5; }
@media (max-width: 700px) { .settings-tabs { margin-left: 0; order: 5; flex-basis: 100%; } }
