/* Dossier Manager – one hand-written stylesheet.
   Three colours only: the page light grey; the sections and the tables have no background of their own (their texts
   sit on the grey); black for what needs focus (the data box, the numbers, the bar of the column titles, filled
   buttons; white text on it); white for the fields and for what is under the mouse. Yellow: tocca a te. */

:root {
  /* The only colours: black, white, the light grey of the page and yellow (tocca a te) */
  --black: #000;  /* black: every text, icon and edge */
  --light: #e4e4e4;
  --white: #fff;
  --yellow: #ffd43b;
  --user-row: 2.5rem;  /* the line of the name, top left */
  /* Pills, buttons, the field of the chat and every field: 37 px tall (15 px text × 1.5 + 2 × 0.391rem + 2 × 1 px);
     the buttons with an icon (←, ✕, +, pencil, ○, arrow) too, round: 37 × 37 px (18.4 px icon + 2 × 0.519rem + 2 × 1 px) */
  --gap: 1.5rem;  /* the one space between the boxes (sections, notices, buttons on top), and around the page */
  /* Text sizes, the same in every page: normal text 15px (body, also column titles, histories, form errors), labels 12px */
  --size-label: 12px;  /* only: date and time of an activity, the version, the label of a number (Conti) */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Inter (SIL Open Font License, static/fonts/Inter-LICENSE.txt), served by the app: the same text on every device, no
   request to other servers. Only the two weights used: normal and bold. */
@font-face { font-family: "Inter"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/Inter-Regular.3875f8357497.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/Inter-Bold.66894432e7ff.woff2") format("woff2"); }

* { box-sizing: border-box; }
input, select, textarea { color: var(--black); }  /* every field: the chat, Cerca, the login, the forms */
::placeholder { color: var(--black); opacity: 1; }  /* the words inside an empty field: black too (some browsers fade them) */
*, *::before, *::after, ::file-selector-button { border-radius: 0; }  /* square and precise: no rounded corners nor pills */

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--black);
  background: var(--light);  /* the grey of the page down to the bottom of the window (no white strip under it) */
}

a { color: inherit; }

/* Three clear levels of type (about 1.3× each): the page 28 px, its sections and the numbers 20 px, the data 15 px */
h1 { font-size: 28px; line-height: 1.25; margin: 0 0 1rem; }
h2 { font-size: 20px; line-height: 1.3; margin: 0 0 0.75rem; }

/* Pannello di controllo (every role): the Assistente, as tall as the window. Nothing open on the right: the chat alone,
   in the middle; something open (a dossier, a report): the chat on the left (1/3), it on the right (2/3). The page does
   not scroll: the chat and the right part do. */
.with-assistant {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 2fr;
  gap: var(--gap);
  align-items: start;
}
.with-assistant .assistant-column { display: flex; flex-direction: column; height: calc(100vh - 2 * var(--gap) - var(--user-row)); }
.with-assistant .assistant { flex: 1; }
.with-assistant .side-panel { height: calc(100vh - 2 * var(--gap) - var(--user-row)); }
/* ← and ✕ on the line of the name (top left): the right part starts at the top of the page, next to the name (the
   computer; on the phone one column, under the chat) */
@media (min-width: 701px) {
  .with-assistant > .side-panel:not(:empty) { margin-top: calc(-1 * var(--user-row)); height: calc(100vh - 2 * var(--gap)); }
}
.with-assistant:has(> .side-panel:empty) { grid-template-columns: minmax(0, 1fr); }
.with-assistant:has(> .side-panel:empty) .assistant-column { width: 100%; max-width: 52rem; margin: 0 auto; }
.with-assistant > .side-panel:empty { display: none; }
/* Scadenze (owner): in a row that opens the dossier, the cell with the date to change is not a link */
.table .row-link td.edit-cell { padding: 0.4rem 1.25rem; }
.form .edit-cell input[type="date"] { font: inherit; margin: 0; }


/* Assistente: on the light grey page, no box (only the field to write and the questions of the user are white). Empty:
   only the field (with the solleciti above it), in the middle of the window; after the first answer it goes to the
   bottom, the messages above it. As tall as the Pannello: down to the bottom of the window. */
.assistant {
  display: flex; flex-direction: column; min-height: 0; margin-bottom: 0; padding: 0;
  border-color: transparent; background: transparent;
}
.assistant-body { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.assistant-body:has(> .assistant-turns.is-empty) { justify-content: center; }
/* A page open on the right: the field of the chat goes down at once, on the left, even with no messages yet */
.with-assistant:has(> .side-panel:not(:empty)) .assistant-body { justify-content: flex-end; }
.assistant-turns { flex: 1; min-height: 0; overflow-y: auto; padding-right: 0.25rem; }
/* The messages scroll (wheel, touch, keyboard) without a visible scrollbar */
.assistant-turns { scrollbar-width: none; }
.assistant-turns::-webkit-scrollbar { display: none; }
.assistant-turns.is-empty { display: none; }
.assistant-turns > div { flex-shrink: 0; }  /* the messages keep their height: the box scrolls */
/* The first messages start at the top and go down; once they fill the box it scrolls and stays on the newest one at
   the bottom (column-reverse; the free space goes under the messages) */
.assistant-turns > div { margin-bottom: auto; }
.assistant-turn { margin: 0 0 1rem; line-height: 1.55; overflow-wrap: anywhere; }
.assistant-turn:last-child { margin-bottom: 0; }
.assistant-turn p { margin: 0; }
/* An answer: what the user wants first, clear. A line with a link is a line of its own, with room around it; the
   name of the link cut with «…» like the long texts of the tables (whole on hover: its title). */
.assistant-turn.role-assistant p.with-link { margin: 0.5rem 0; }
/* The scheme of an answer: the items of a list each on its own line, a little apart; an empty line of the text (between
   the first line and the list, between two groups) a clear space */
.assistant-turn.role-assistant p.item { margin-top: 0.3rem; }
.assistant-turn.role-assistant p.gap { margin-top: 0.85rem; }
.assistant-turn.role-assistant a.answer-link {
  display: inline-block; max-width: 16rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  vertical-align: bottom;
}
.assistant-turn.role-user {  /* white, round; on one line as tall as Cerca (same space, line and border) */
  margin-left: 20%; padding: 0.391rem 1rem; border: 1px solid transparent; 
  background: var(--white); line-height: 1.5;
}
.assistant-turn.error { color: var(--black); }
/* In the answers the links (dossiers, reports, documents, clients, technicians, tasks) are written in the text, no room
   around them, always semi-bold (that is how one sees they can be clicked). Under the mouse only underlined. */
/* The same in the Storici: the name of the dossier (or request) and the file of an update. */
.assistant-turn.role-assistant .answer-link,
.activity .activity-dossier,
.activity a.file-link {
  display: inline; margin: 0; padding: 0; background: transparent; color: inherit; font-size: inherit;
  font-weight: 700; text-decoration: none;  /* bold, like the author; underlined only under the mouse */
  white-space: normal;
}
.assistant-turn.role-assistant a.answer-link:hover,
.activity a.activity-dossier:hover,
.activity a.file-link:hover { background: transparent; color: var(--black); text-decoration: underline; }  /* only underlined */

.activity .activity-dossier { font-size: inherit; }
.activity .activity-dossier, .activity a.file-link { font-weight: normal; }  /* in the Storici only the author is bold */
.assistant-prompt { margin-top: 2.5rem; }
.assistant-prompt[inert] { opacity: 0.5; }  /* while Claude answers: in place, faded, off */  /* the pills well apart from the messages */
.assistant-body:has(> .assistant-turns.is-empty) .assistant-prompt { margin-top: 0; }
.assistant-suggestions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
/* The yellow solleciti first, then the pages, on one line when they all fit in the width of the field of the chat;
   otherwise the pages go whole on the line below (each group stays together: flex 0 0 auto) */
.assistant-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.assistant-row > .assistant-suggestions { margin-bottom: 0; flex: 0 0 auto; max-width: 100%; }
/* The pages of the app (Pratiche, Clienti, Tecnici, Documenti): like the name top left (.user-menu-name),
   black bold text on the grey; on hover a white pill */
.assistant-page {
  padding: 0.391rem 1rem; border: 1px solid transparent; background: transparent;
  color: var(--black); font-weight: 700; text-decoration: none; white-space: nowrap;
}
.assistant-page:hover { background: var(--white); }
/* Solleciti (secretary, technician): yellow pills, 15 px; only when there is something to do */
.assistant-reminders { flex-wrap: wrap; overflow: visible; }
.assistant-reminders:empty { display: none; }
.assistant-reminder {
  padding: 0.391rem 1rem; border: 1px solid var(--yellow); background: var(--yellow);  /* like the buttons */
  color: var(--black); font: inherit; font-weight: 700; white-space: nowrap; cursor: pointer;
}
.assistant-reminder:hover { border-color: var(--black); }  /* yellow stays: only the black border */
/* Giallo = tocca a te, also in the pages, only where one acts on a sollecito: the + of the bonifico of a phase to
   collect (secretary: Da incassare), the scadenza of a dossier of the technician due within 7 days (In scadenza) */
.content .icon-button.your-turn { background: var(--yellow); border-color: var(--yellow); color: var(--black); }
.content .icon-button.your-turn:hover { background: var(--yellow); border-color: var(--black); color: var(--black); }
.your-turn:not(.button) { margin-left: -0.6rem; padding: 0.1rem 0.6rem; background: var(--yellow); color: var(--black); font-weight: 700; }  /* the date stays in its column */
.assistant-composer { margin-top: 0.6rem; }
.assistant-composer input {
  width: 100%; padding: 0.391rem 1rem; border: 1px solid transparent; /* round, no border: white on the grey; as tall as the pills, Cerca and the messages */
  background: var(--white); font: inherit;
}
/* Writing in it: a thin black outline, not the blue one of the browser */
/* Writing in the field of the chat, the login or Cerca: no outline, no border; the name inside (placeholder) goes,
   only the blinking cursor stays */
.assistant-composer input:focus,
.login-box input:focus,
.search input[type="search"]:focus { outline: none; }
.assistant-composer input:focus::placeholder,
.login-box input:focus::placeholder,
.search input[type="search"]:focus::placeholder,
.form input:focus::placeholder,
.form textarea:focus::placeholder { color: transparent; }  /* every field: only the cursor (e.g. "Nuova fase…") */
.assistant-note { margin: 0.6rem 0 0; color: var(--black); }
/* "Sto pensando": three dots that come and go (CSS only) */
/* The messages of waiting, the same everywhere: "Sto pensando" (the chat), "Sto leggendo il documento / il bonifico"
   (Nuova pratica, Bonifico, Uscita): a yellow block with normal text (a message, not a button), as wide as its words;
   it keeps its width while only the dots move */
.assistant-thinking {
  display: inline-block; margin: 0.5rem 0 0; padding: 0.391rem 1rem; border: 1px solid var(--yellow);
  background: var(--yellow); color: var(--black); font-weight: 400;
}
.assistant-thinking::after { content: ""; display: inline-block; width: 1.2em; text-align: left; animation: assistant-dots 1.2s steps(4) infinite; }
@keyframes assistant-dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.assistant-thinking.htmx-indicator { display: none; }
.assistant-thinking.htmx-indicator.htmx-request { display: inline-block; }
/* Flussi di cassa (Pannello of the owner): the boxes like Conti, on one line; In arrivo with a black bar for
   the amount; compact tables, so that everything fits in the window. Margine per tipo di pratica takes the space left
   (its table scrolls inside, if there are many kinds). */
/* Report (assistant/report.html): always the same layout; compact tables, the numbers on the right */
.report .table.compact th, .report .table.compact td { padding: 0.35rem 0.5rem; }
.report .table.compact .row-link td { padding: 0; }
.report .table.compact .row-link a { padding: 0.35rem 0.5rem; }  /* compact rows that open a page too */
/* A page opened in the right part of the Pannello: Indietro on top, on the left; Chiudi on the right */
/* Indietro and Chiudi together on the left: the right of the line is for the button of the page (Nuova pratica) */
.panel-bar { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; }  /* from the ✕ to the first title: 16 px, like from the last field to Salva */
/* On the light grey page: black under the mouse, white text */
.content .panel-bar .button:hover { background: var(--white); border-color: transparent; color: var(--black); }
/* Indietro and Chiudi: only a ← and an ✕ (drawn), no border; white under the mouse (like the name, top left) */
.content .panel-bar .panel-back,
.content .panel-bar .panel-close { display: inline-flex; padding: 0.519rem; border-color: transparent; background: transparent; }
.content .panel-bar .panel-back:hover,
.content .panel-bar .panel-close:hover { background: var(--white); border-color: transparent; color: var(--black); }
/* ← and ✕ drawn (SVG), with the same line: the characters of the fonts have different weights */
.content .panel-bar .button svg { display: block; width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: square; stroke-linejoin: miter; }
.content .side-panel .panel-bar .button { margin: 0; }
/* Every page compact on the left: one column as wide as its widest part (a table, the data, a form; at most the room
   there is), every box of the page as wide as that one, like Nuova pratica */
.panel-page { display: grid; grid-template-columns: minmax(0, max-content); align-content: start; }
.panel-page > * { min-width: 0; }  /* never wider than the room there is (a long table: its cells cut with "…") */
.panel-page:has(.document-view) { grid-template-columns: minmax(0, 1fr); }  /* a file (PDF, picture): all the room there is */
/* The right part of the Pannello of the owner (#side-panel): the Flussi di cassa or the card of a dossier (it scrolls inside) */
.side-panel { min-width: 0; min-height: 0; overflow-x: hidden; overflow-y: auto; }
/* Its scrollbar in a strip of its own, never over the boxes: the space is kept (scrollbar-gutter) and, for the scrollbars
   drawn over the page (Firefox, GNOME), a margin on the right where they float */
.with-assistant .side-panel { padding-right: 0.75rem; scrollbar-gutter: stable; }
.side-panel .section:last-child { margin-bottom: 0; }
/* A document next to the chat: the file fills the right part */
.document-view iframe { display: block; width: 100%; height: calc(100vh - 12rem); border: 0; }
.side-panel .tile { flex: 1 1 0; min-width: 0; padding: 0.5rem 0.75rem; }  /* on one line */
.table.compact th, .table.compact td { padding: 0.35rem 0.75rem; }

/* ---------- App layout: the content alone (no sidebar, no title bar: the chat is the frame) ---------- */

.app { min-height: 100vh; }

/* Top left: the name of the user; a click opens below Impostazioni and Esci (a popover of the browser, no JavaScript:
   a click anywhere else or Esc closes it) */
.user-row { display: flex; justify-content: flex-start; height: var(--user-row); }
.user-menu-name {
  padding: 0.391rem 1rem; border: 1px solid transparent; background: transparent;
  color: var(--black); font: inherit; font-weight: 700; cursor: pointer;
}
.user-menu-name:hover, .user-menu-name:has(+ :popover-open) { background: var(--white); }
.user-menu-items {
  position: fixed; inset: auto; top: calc(var(--gap) + var(--user-row) + 0.25rem); left: var(--gap); margin: 0;
  min-width: 12rem; padding: 0.4rem; border: 0; background: var(--white); color: var(--black);
}
.user-menu-items a,
.user-menu-items button {
  display: block; width: 100%; padding: 0.391rem 1rem; border: 1px solid transparent; background: transparent;  /* as tall as the pills (32.5 px) */
  color: var(--black); font: inherit; text-align: left; text-decoration: none; cursor: pointer;
}
.user-menu-items a:hover,
.user-menu-items button:hover { background: var(--light); }
.user-menu-items form { margin: 0; }
/* Impostazioni and Segnala: in the middle of the window, across and from top to bottom (with their ✕); the boxes compact */
.settings-page {
  display: grid; grid-template-columns: minmax(0, max-content); justify-content: center; align-content: center;
  min-height: calc(100vh - 2 * var(--gap) - var(--user-row));
}  /* in the middle of the window, also from top to bottom; its boxes compact, as wide as the widest */
.settings-page > * { min-width: 0; }
.app-version { margin: 1.25rem 0 0.25rem; padding: 0 1rem; color: var(--black); font-size: var(--size-label); }  /* under Esci, apart */

.section-actions form { margin: 0; }

.content { padding: var(--gap); background: var(--light); }

/* ---------- Components ---------- */

/* A button: only its word (or icon), no fill and no edge, the word in bold (the sign that it is pressed); white under
   the mouse */
.button {
  font: inherit;
  font-weight: 700;
  padding: 0.391rem 1rem;
  border: 1px solid transparent;
  background: transparent;
  color: var(--black);
  cursor: pointer;
}

/* Hover, one step of grey: white (or transparent on white) → light grey, light grey → black,
   black → light grey; the border stays */
.button:hover { background: var(--white); color: var(--black); }  /* on the grey of the page: white */

/* Links that look like buttons: no underline */
a.button { display: inline-block; text-decoration: none; }
/* Buttons in the page: transparent with a dark border and text; under the mouse black with white text */
.content .button { background: transparent; color: var(--black); }
.content .button:hover { background: var(--white); color: var(--black); }
/* Salva: just its word, like ← and ✕ (no border, transparent); under the mouse white on the grey of the page, light
   grey in a white box (one grade of grey) */
.content .button.text-button { border-color: transparent; background: transparent; color: var(--black); font-weight: 700; }  /* bold: as thick as the line of ← and ✕ */
.content .button.text-button:hover { border-color: transparent; background: var(--white); color: var(--black); }
.content .card .button.text-button:hover { background: var(--white); }
/* Salva under the boxes (out of them, on the grey of the page): close to the last box, not a whole gap below it */
.form > .button.text-button { margin-top: 1rem; }  /* the button of a form (Salva, Controlla, Importa, Richiedi…): 16 px under its last field, everywhere */
/* the last section of a form ends with its last field (no space of its own nor of the last paragraph): only the 16 px above */
.form section:has(+ .text-button), .form div:has(+ .text-button) > section:last-of-type { margin-bottom: 0; }
.form section:has(+ .text-button) > :last-child, .form section:has(+ .text-button) > :last-child > :last-child,
.form div:has(+ .text-button) > section:last-of-type > :last-child { margin-bottom: 0; }
/* a table of fields at the end of a form (Entrate): no space under its last row, Salva 16 px under the last field */
.form section:has(+ .text-button) tbody tr:last-child td, .form div:has(+ .text-button) > section:last-of-type tbody tr:last-child td { padding-bottom: 0; }

/* A section: no box of its own, its title and content on the grey of the page (in line with it, no space on the
   sides); above and below it the space it had as a box, so between two sections 1 rem + the gap + 1 rem */
.card {
  padding: 0;
  border: 0;  /* no box: no edge either */
  background: transparent;
}

/* Cerca: one minimal field above a list (Pratiche, Documenti, Clienti, Tecnici) */
.search { margin: 0 0 1rem; }
/* Lists (Pratiche, Clienti, Documenti, ...): Cerca above the box, on the left; in the box the button of the box
   (Nuova pratica, Nuovo cliente, Richiedi) on the top right, then the table */
.list-search { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0 0 1rem; }
.list-search .search { flex: 0 1 24rem; margin: 0; }  /* Cerca on the left, the button of the list on the right */
.search input[type="search"] {
  width: 100%;
  max-width: 24rem;
  padding: 0.391rem 1rem;  /* the same height as the buttons (Chiudi, Indietro, Nuova pratica, ...) */
  border: 1px solid var(--light);
 /* round, like the field of the chat */
  background: var(--white);
  font: inherit;
}

.section { margin-bottom: 2rem; }  /* the one space between two sections, in every page (32 px) */

.messages { list-style: none; margin: 0 0 var(--gap); padding: 0; }
.messages li:last-child { margin-bottom: 0; }
/* A notice with its button (Crea cliente): two blocks, the notice and under it a yellow button (bold;
   under the mouse it keeps the yellow and shows a black edge, like every yellow button) *
.notice-row { display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; margin-bottom: var(--gap); }  /* the gap of the pills above the field of the chat */
.notice-row .messages { margin: 0; }
.content .button.your-turn { background: var(--yellow); border-color: var(--yellow); color: var(--black); font-weight: 700; }
.content .button.your-turn:hover { background: var(--yellow); border-color: var(--black); color: var(--black); }

/* Notices after an action of the user (confirmations, warnings, errors such as a wrong login): yellow box */
.messages li {
  padding: 0.6rem 1rem;
  margin-bottom: 0.5rem;
 
  background: var(--yellow);
  color: var(--black);
}


.table { width: 100%; border-collapse: collapse; }
.table th,
.table td {
  text-align: left;
  vertical-align: middle;
  padding: 0.42rem 1.25rem;  /* a row as tall as the bar, the fields and the pills (37 px) */
  border-bottom: 1px solid transparent;  /* no lines between the rows */
  white-space: nowrap;  /* one line: the long texts are cut (td.cut) */
}
.table th { background: transparent; color: var(--black); }  /* the column titles: bold, on the grey */
/* Figures of the same width (Inter's tabular numbers): amounts, dates, codes and counts line up in their column */
.table td, .data-box .details { font-variant-numeric: tabular-nums; }
.table td.nowrap { white-space: nowrap; }  /* short data with spaces (Telefono): on one line */
/* The bar of the column titles: round corners, the curve of the pills and of the boxes */
/* The bar of the column titles as tall as the pills and the field of the chat (37 px);
   titles on one line (in a narrow table they may wrap, below) */
.table thead th { padding-top: 0.476rem; padding-bottom: 0.476rem; line-height: 1.5; white-space: nowrap; border-bottom: none; }
.table td.file-name { min-width: 10rem; overflow-wrap: anywhere; }  /* long file names without spaces wrap */
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:has(+ .add-row) td { border-bottom: none; }  /* no line before the + (it is not a row of data) */
/* Rows that open a page (Pratiche, Clienti, Tecnici): every cell is a link filling the cell, so a click anywhere
   on the row opens it (also "open in new tab"). No underline: the row looks like plain text; the cells after
   the title are tabindex="-1", so Tab stops once per row. */
.table .row-link td { padding: 0; }
.table .row-link td > a { display: block; padding: 0.42rem 1.25rem; text-decoration: none; }
.table .row-link:hover td { background: var(--white); }  /* the row under the mouse: white on the grey */
.table .row-link:hover td, .table tr:has(+ .row-link:hover) td { border-bottom-color: transparent; }  /* no square lines around it */
.table tbody tr:first-child td { border-top: 3px solid transparent; }  /* a little space between the bar and a row under the mouse */
/* The last row that adds one (Uscite, Documenti of the dossier, the lists): a + in the middle, a button as big as the ✕
   that closes the right part (same padding, same icon); under the mouse it goes light grey */
.table .add-row td { padding: 0.25rem 1.25rem 0; text-align: center; }
/* Entrate: Fase raggiunta, in the middle of its column: ✓ (reached) or the round button Raggiunta (icon-button); the
   + of the bonifico is an icon-button too. Their cells are not taller than the others. */
.table th.phase-reached, .table td.phase-reached { text-align: center; white-space: nowrap; }
/* A long text in a table (titles, clients, files, phases, descriptions): one line, cut with "…" (whole when the mouse
   stops on it: title) */
.table td.cut { max-width: 12rem; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
/* Narrower right part (a small screen, the chat on the left): the long texts cut sooner, the cells closer, so the tables fit */
.side-panel { container-type: inline-size; }
@container (max-width: 1000px) {  /* the right part of a laptop: the long texts cut sooner, the lists fit */
  .table td.cut { max-width: 7rem; }
  .table th, .table td, .table .row-link td > a { padding-left: 0.75rem; padding-right: 0.75rem; }
}
@container (max-width: 760px) {  /* phone, half a screen: may wrap or scroll sideways */
  .table td.cut { max-width: 6rem; }
  .table th, .table td, .table thead th { white-space: normal; }
  .table th, .table td, .table .row-link td > a { padding-left: 0.5rem; padding-right: 0.5rem; }
  .table td.nowrap { white-space: normal; }  /* very narrow: better a Telefono on two lines than a table to scroll */
}
.table td.cut > a { overflow: hidden; text-overflow: ellipsis; }
.table th.phase-pay, .table td.phase-pay { text-align: center; }  /* Bonifico in the middle, like Fase raggiunta: the + of the secretary like the ○ of the technician */
.table td.phase-reached .reach-form { display: inline-block; margin: 0; }
.table td .icon-button { margin: -0.519rem 0; vertical-align: middle; }
.reached-mark { display: inline-flex; vertical-align: middle; }
.reached-mark svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: square; stroke-linejoin: miter; }
.table .row-link td.phase-reached > a { display: block; }
.table .add-row a {
  display: inline-flex; padding: 0.519rem; border: 1px solid transparent; color: var(--black);
}
.table .add-row svg { display: block; width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: square; }
.table .add-row a:hover { background: var(--white); color: var(--black); }
.table .add-row a + a { margin-left: 0.5rem; }  /* Importa (arrow up) next to the + */
/* In a list that scrolls, the + stays visible at the bottom of the box (like the column titles at the top) */
.scroll-box .add-row td { position: sticky; bottom: 0; z-index: 1; background: var(--light); }

/* Long lists scroll inside their box, so the page fits in one browser screen.
   below-search: the box has the Cerca field above it (Pratiche, Documenti, Clienti, Tecnici). */
.scroll-box { max-height: calc(100vh - 12rem); overflow-y: auto; }
/* Its scrollbar in a strip of its own, never over the bar of the column titles nor over the rows: the space is kept
   (scrollbar-gutter) and, for the scrollbars drawn over the page (Firefox, GNOME), a margin on the right where they
   float; like the right part */
.scroll-box { padding-right: 0.75rem; scrollbar-gutter: stable; }
/* The tables that do not scroll (yet) keep the same strip on the right, so every table of the page ends at the same
   place from the start (when one starts to scroll nothing moves) */
.card .table { width: calc(100% - 0.75rem); }
.card .scroll-box .table { width: 100%; }
.scroll-box.below-search { max-height: calc(100vh - 15.5rem); }
.scroll-box .table th { position: sticky; top: 0; z-index: 1; }  /* column titles stay visible */
/* Documenti of the dossier page, from the oldest (top) to the newest (bottom): column-reverse makes the box open
   scrolled to the bottom, on the newest one (no JavaScript) */
.starts-at-bottom { display: flex; flex-direction: column-reverse; }
/* It ends at 3/4 of the window height (7.5rem: top bar, page padding and the filters above it) */

.details { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0; }
.details dt { font-weight: 700; }
.details dd { margin: 0; }
/* The data boxes (black: dossier, client, technician, request, preventivo): the names that are links (client,
   technicians, the dossier) look like the white text around them; under the mouse they are underlined. Only the links in the data (.details), not the buttons of the box (the pencil, ...). */
.data-box .details a { color: var(--black); text-decoration: none; }  /* like the plain text of the box */
.data-box .details a:hover { color: var(--black); text-decoration: underline; }
/* The data box, first in the pages of a dossier, client, technician and request: black, white text; its links and
   buttons white, on hover white with dark text (the links: .dossier-data .details a) */
.card.data-box { color: var(--black); }  /* the data of the page: on the grey like the sections, in line with them */
/* The big title of the data box (dossier, client, technician, request, preventivo, report): at most half of the box,
   on one line; longer: cut with "…" (the whole title when the mouse stops on it) */
.data-box h1 { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }  /* all the room up to the pencil */
.content .data-box .button { border-color: transparent; color: var(--black); }
.content .data-box .button:hover { background: var(--white); border-color: transparent; color: var(--black); }
/* Modifica: a pencil as big as the ✕ of the right part, no border, transparent; under the mouse light grey with the
   pencil black (on white and on the black of the data box, where the pencil is white) */
.content .icon-button, .content .data-box .icon-button { display: inline-flex; padding: 0.519rem; border-color: transparent; background: transparent; }
.content .icon-button:hover { background: var(--white); border-color: transparent; color: var(--black); }  /* on the grey: white */
.content .icon-button svg { display: block; width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: square; stroke-linejoin: miter; }

/* Activities: compact (tighter spacing) */
.activities { list-style: none; margin: 0; padding: 0; }
.activity {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.5rem;
  line-height: 1.4;
  border-bottom: 1px solid var(--light);
}
.activity > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }  /* long file names wrap inside the box */
/* The row is not a button: the dossier pill (black on mouse over) and the file name are the links.
   The file name looks like text; on mouse over it becomes a black pill with white text, like the dossier pill. */
a.file-link { color: inherit; text-decoration: none; padding: 0.05rem 0.3rem; }
a.file-link:hover { background: var(--white); color: var(--black); }
/* Storico of a dossier: Nota on top (whoever follows the dossier) */
.note-form { margin-top: 1rem; }  /* under the Storico, after the newest activity */
/* Nota: like the field of the chat (round, no border, the name inside), light grey on the white box; sent with Enter */
.form.note-form input[type="text"] {
  width: 100%; padding: 0.391rem 1rem; border: 1px solid transparent; background: var(--white);
}
.form.note-form input[type="text"]:focus { outline: none; }
.form.note-form input[type="text"]:focus::placeholder { color: transparent; }  /* only the cursor */
.form.note-form input::placeholder { color: var(--black); }
/* File fields: round, like the field of the chat; the button of the browser (Sfoglia…) a black pill */
.content .form input[type="file"] {
  width: 100%; max-width: 26rem; min-width: 0; padding: 0.266rem; border: 0; /* as tall as the other fields */
  background: var(--white); color: var(--black); font: inherit;
}
.form input[type="file"]::file-selector-button {
  margin-right: 0.75rem; padding: 0.125rem 1rem; border: 1px solid transparent;
  background: transparent; color: var(--black); font: inherit; font-weight: 700; cursor: pointer;
}
.form input[type="file"]::file-selector-button:hover { background: var(--white); color: var(--black); }
.activity:last-child { border-bottom: none; }
/* Carica: one button per kind of file, side by side */
/* Dossier page, more than 5 documents: column titles + 5 rows of about 3.1rem, the others scroll */
.scroll-box.table-scroll { max-height: 18.5rem; }  /* a table of a page (Documenti, Uscite, Pratiche of a client or a technician): about 5 rows, then it scrolls */
.scroll-box.activities-scroll { max-height: 22rem; }  /* Storico: about 5 updates, then it scrolls */
/* Two sizes only: the author, "in" and the dossier, the sentence at 15 px like every text; date and time 12 px */
/* Second line: one sentence, what happened and then the file (a link) and/or the text */
.activity-text { margin: 0.2rem 0 0; }  /* "Kind. text" / "Kind: file", one sentence */
.activity-date { margin-top: 0.2rem; font-size: var(--size-label); color: var(--black); }  /* the last line: date and time */

/* Nuova pratica and Modifica (Incassi): the fields inside the table cells */
.form .phases-table input[type="text"] { width: 100%; min-width: 10rem; margin: 0; }
.phases-table input.phase-order { width: 4rem; min-width: 0; margin: 0; }
.form .phases-table select { width: auto; margin: 0; }
.form .phases-table input[type="number"]:not(.phase-order) { width: 9rem; margin: 0; }
/* Amounts in euro: aligned on the right, the digits all the same width */
.table th.amount { text-align: right; }
.table td.amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* Conti (dossier page), reports: a few boxes with the numbers, side by side */
.tiles { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.tile { flex: 1 1 10rem; padding: 0.75rem 1rem 0.75rem 0; border: 1px solid transparent; background: transparent; color: var(--black); }
.tile p { margin: 0; }
.tile-label { color: var(--black); font-size: var(--size-label); }
.tile-value { margin: 0.15rem 0; font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.section-note { margin: 0.75rem 0 0; color: var(--black); }
/* Nuova pratica / Modifica, Cliente: the data of the client chosen, well apart from the field above */
.details.client-summary { margin-top: 1.25rem; }
/* Nuova uscita / Nuovo documento / Nuova entrata: under the title, what to upload */
.upload-what { margin: 0; color: var(--black); }  /* what goes in a section of a form: normal text (15 px) */
/* Conti: the boxes white, each on its own, on the grey of the page (no box around them) */
/* Quando: the day ("Dal giorno") appears next to it only when "Dal giorno" is chosen (CSS :has, no JavaScript) */
/* Modifica (Incassi): ✕ marks a phase to take away (a hidden tick and its label): the row fades, the button becomes
   "Annulla"; it goes away only with Salva */
/* ✕ in the middle of a column of its own (room for "Annulla"), right after Importo: the column Fase takes the space
   left (.table td aligns on the left: hence .table td.remove-cell) */
.table td.remove-cell, .table th.remove-cell { width: 6rem; white-space: nowrap; text-align: center; }
.phases-table td:nth-child(2) { width: 100%; }
.phases-table th { white-space: nowrap; }  /* "Importo senza IVA (€)" on one line */
.remove-toggle { position: absolute; width: 1px; height: 1px; opacity: 0; }  /* invisible, still usable from the keyboard */
/* ✕ like the one of Chiudi (same size, same line, no border); under the mouse light grey, like the other buttons with
   an icon in the pages (+, the pencil). Once pressed: "Annulla", in the same button */
.remove-button, .form .remove-button {
  display: inline-flex; align-items: center; margin: 0; padding: 0.519rem; border: 1px solid transparent;
 background: transparent; color: var(--black); font-size: inherit; line-height: 1.15rem;  /* Annulla: 15 px, like the other buttons */
  cursor: pointer;
}
.remove-button svg { display: block; width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: square; }
.remove-button:hover { background: var(--white); color: var(--black); }
.remove-toggle:focus-visible + .remove-button { outline: 2px solid var(--black); outline-offset: 2px; }
.remove-on,
.remove-toggle:checked + .remove-button .remove-off { display: none; }
.remove-toggle:checked + .remove-button .remove-on { display: inline; }
.remove-off { display: block; }
.phases-table tr:has(.remove-toggle:checked) td:not(.remove-cell) { opacity: 0.35; text-decoration: line-through; }
.table form { margin: 0; }

/* Column titles you can click to sort */
.table th a.sort { color: var(--black); text-decoration: none; }
.table th a.sort:hover { text-decoration: underline; }

/* ---------- Forms ---------- */

.form fieldset { border: none; margin: 0 0 1.25rem; padding: 0; }

.form legend { font-weight: 700; margin-bottom: 0.5rem; }

.form label { display: block; margin: 0.75rem 0 0.25rem; font-size: 0.9rem; }

/* The fields, like the field of the chat, the login and the Nota: round, light grey on the white box, no border,
   also while writing in them (only the cursor) */
.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="number"],
.form input[type="date"],
.form select,
.form textarea {
  font: inherit;
  padding: 0.391rem 1rem;  /* as tall as the field of the chat, the pills and Cerca */
  border: 1px solid transparent;
 
  background: var(--white);  /* white on the grey of the page */
  color: var(--black);
}
.form textarea { resize: vertical; }
.form input[type="date"], .form select { box-sizing: border-box; height: calc(1.5em + 0.781rem + 2px); }  /* the browser draws them taller or shorter: one line + padding + border, like the others */  /* more lines: round corners only */
.form input[type="text"]:focus,
.form input[type="email"]:focus,
.form input[type="password"]:focus,
.form input[type="number"]:focus,
.form input[type="date"]:focus,
.form select:focus,
.form textarea:focus { outline: none; }  /* no border while writing: only the cursor */
/* A box with a short form (Nuovo cliente, Modifica del cliente, the sections of Nuova pratica): compact on the left, not as wide as the page; its
   fields as wide as the box */
.card.compact { max-width: 26rem; }
.card.compact.wide { max-width: 40rem; }  /* the categories in 3 columns, the table of the Entrate */
/* In a page of compact boxes the yellow notices are compact too: as wide as their text, at most as the widest box */
.content:has(.card.compact) .messages li { width: fit-content; max-width: 40rem; }
/* Every field of every form (also Impostazioni and Segnala): one per line, 26 rem wide (all the width on a small
   screen); the fields in a table (Entrate, Prestazioni) keep the width of their column */
.form :is(input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
  input[type="file"], select, textarea) { display: block; }
.form :is(input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
  input[type="file"], select, textarea):not(td *) { width: 26rem; max-width: 100%; }

/* Checkbox groups (Tipo pratica, ...): Django renders them as a fieldset; the boxes side by side */
.form fieldset legend { font-weight: normal; font-size: 0.9rem; margin-top: 0.75rem; }
.form fieldset > div { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.form fieldset label { display: flex; align-items: center; gap: 0.4rem; margin: 0; }
/* Tipo pratica: many types, in 3 columns in the order of the list (2 on small screens, below) */
.form #id_kinds { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.5rem 1.25rem; max-width: 48rem; }
/* The same checkboxes side by side in a box without fieldset (Collaboratori) */
.form .checkbox-list > div { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; margin-bottom: 0.5rem; }
.form .checkbox-list label { display: flex; align-items: center; gap: 0.4rem; margin: 0; }

/* Nuova pratica from a Richiesta: what the technician wrote about the client, under "Cliente" */
.request-client { margin: 0.4rem 0 0; }
/* Required fields: * after the label (forms with required_css_class = "required") */
.form label.required::after, .form legend.required::after { content: " *"; }  /* the label only (Django marks the <p> too) */

.errorlist {
  list-style: none;
  margin: 0.25rem 0;
  padding: 0.4rem 0.75rem;
 
  background: var(--yellow);
  color: var(--black);
}

.form .button { margin-top: 0.5rem; }
/* Salva always on a line of its own, under the last field (e.g. under "Rimuovi la foto attuale" and its tick) */
.form > .button { display: block; margin-top: 1rem; }

/* Title of a section with, at the top right of the box, the buttons that change only that section
   (Modifica, Collaboratori, Scadenza, Carica) */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;  /* title -> content: 12 px everywhere */
}
.section-header h1, .section-header h2 { margin: 0; }
.section-actions .icon-button { margin: -0.519rem 0; }  /* the pencil next to the title does not push the content down */
.section-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }

/* Carica, Carica (Incassi): the browser's own file field, Salva on its right */
.form.file-form .file-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 0.75rem; }
.form.file-form .file-row .button { margin: 0; }  /* Salva on the right of the file field */

.form input[type="checkbox"] { margin-right: 0.4rem; }
/* Boxes and dots (Categoria, Subito, Collaboratori, Visibile a, Tipologia documento, ...): 18 px, like the icons */
input[type="checkbox"], input[type="radio"] { width: 1.15rem; height: 1.15rem; vertical-align: middle; }

/* ---------- Login page (no sidebar) ---------- */

.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
  background: var(--light);
}

/* Login: the box in the middle. It has no white background: it is on the light grey of the page; the fields are like
   the field of the chat */
.login-page { display: flex; flex-direction: column; align-items: center; gap: 1.5rem; width: 100%; max-width: 360px; }
.login-page .login-box { background: transparent; }

.login-box {
  width: 100%;
  max-width: 360px;
  padding: 1.5rem;
 
  background: var(--white);
}

.login-box input {
  width: 100%;
  font: inherit;
  padding: 0.391rem 1rem;
  border: 1px solid transparent;
 /* round, white, no border: like the field of the chat (and as tall) */
  background: var(--white);
}
/* The name of the field, inside it: grey (the light grey of the page would not be read on white) */
.login-box input::placeholder, .assistant-composer input::placeholder,
.search input[type="search"]::placeholder, .form input::placeholder, .form textarea::placeholder { color: var(--black); }

.login-box .button { display: block; margin: 1rem auto 0; }  /* as wide as its word, 16 px under the last field, in the middle of the box */
.login-box form > p:last-of-type { margin-bottom: 0; }

/* ---------- Small screens: one column ---------- */

@media (max-width: 700px) {
  /* Pannello of the owner: one column, the Assistente first (not as tall as the window: the page scrolls) */
  .assistant { height: auto; }
  .assistant-turns { max-height: 60vh; }
  .with-assistant { grid-template-columns: minmax(0, 1fr); }
  .with-assistant .assistant-column,
  .with-assistant .side-panel { height: auto; padding-right: 0; }  /* the page scrolls, not the part */
  .form #id_kinds { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scroll-box,
  .scroll-box.below-search,
  .table { display: block; overflow-x: auto; }  /* too many columns for the screen: only the table scrolls sideways */
  .table th,
  .table td { padding: 0.6rem 0.5rem; }
  .form input[type="text"],
  .form input[type="email"],
  .form input[type="file"],
  .form select,
  .form textarea { width: 100%; min-width: 0; }
}

/* Preventivo: the document laid out as the fac-simile of the studio (titles of the parts small, like the fac-simile) */
/* Preventivo: each part, its name in bold, then its text under it */
.quote-parts { margin: 0; }
.quote-parts dt { font-weight: 700; margin-top: 1rem; }
.quote-parts dt:first-child { margin-top: 0; }
.quote-parts dd { margin: 0.25rem 0 0; }
.quote-parts ul, .quote-parts ol { margin: 0; padding-left: 1.25rem; }
.quote-parts .messages { margin: 0.5rem 0 0; }
