/* ===========================================================================
   Theme.

   Two deliberately different jobs:

   LIGHT is Django admin's own palette, with one exception: the top bar,
   which is a navy-to-teal sweep ending on django's own header colour, so
   the breadcrumb strip under it still matches. Everything from the
   breadcrumb down - page, sidebar, cards, buttons, tables - is left on
   django's own shades, so nothing further down the page has to be
   re-matched to a new palette. The rest of what this file does in light
   mode is shape: cards, pill buttons, rounded inputs, spacing, the
   changelist/filter split. Clean and plain, which is what a clinical tool
   should be in daylight.

   DARK is a proper dark theme rather than Django's grey-on-charcoal,
   modelled on csfloat.com: a near-black page (#15171c), a slightly
   lifted bar (#1a1c23), cards a shade above that (#1b1d24), hairline
   borders, muted blue-grey text, and one bright blue accent (#237bff)
   used sparingly.

   Only a handful of --md-* tokens are shared by both; every component rule
   below reads those or Django's own variables, so neither theme has a
   colour hardcoded into a component.

   Loaded from admin/base_site.html so it reaches every page including the
   login screen, and after django's base.css/dark_mode.css so it wins.
   =========================================================================== */

:root {
  --md-radius: 10px;
  --md-radius-lg: 14px;
  --md-pill: 999px;

  /* How wide the navigation down the left is. Django ships a flat 275px,
     which is a sensible number on a big monitor and a quarter of the page
     on a laptop: a 1366x768 screen at the 125% scaling windows recommends
     reports 1093px, so the navigation was taking 25% of it and the work
     was being done in the rest.

     clamp, not a breakpoint: this is a question about how much room there
     is, and the answer should move with the room rather than jumping at
     one width. 19vw lands at 210px on that laptop and 243px at 1280,
     reaching django's own 275px at about 1450px and stopping there - so
     nothing changes on a large screen. The floor is what "Dati studio
     dentistico" and an "Aggiungi" link still fit in without the label
     turning into one word per line.

     Everything that has to agree with this number reads it from here:
     the panel itself, the offset it slides in and out by, and the width
     the content beside it is allowed. Django hardcodes 275, 276 and 299
     in three different rules, and changing one without the others is how
     the sidebar ends up half on the page. See the sidebar section below. */
  --bm-sidebar-width: clamp(210px, 19vw, 275px);

  /* How far the menu's pills stand in from the panel's sides (2.13.0):
     10px, down to 6px on the narrowest panel (210px, a laptop at 125%),
     where every pixel of the names' column counts - there the names have
     what they had when the rows ran edge to edge. A measurement, so no
     business type restates it. */
  --pill-inset: clamp(6px, calc(var(--bm-sidebar-width) / 16 - 7px), 10px);

  /* The inner margin of every card's contents - a form's rows and its
     sections' titles, a table's first and last column, a list's search
     and actions bar (2.12.0; the section "Card gutters" at the foot of
     this file). A measurement, not a colour: no business type restates
     it. 16px on a phone (below). */
  --bm-gutter: 20px;

  /* The three theme-switch icons, as mask shapes. Kept here rather than
     inline in the rules that use them because a data URI is unreadable
     in the middle of a declaration block, and because all three have to
     be drawn on the same 24px grid to sit at the same weight beside each
     other. Colour is never set in them: they are masks, so the shape is
     all that is used and the colour comes from the element. See "The
     theme switch's three icons" below. */
  --icon-theme-auto: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><circle cx='12' cy='12' r='8.7' fill='none' stroke='black' stroke-width='1.8'/><path d='M12 6.2a5.8 5.8 0 0 1 0 11.6Z' fill='black'/></svg>");
  /* No sun here since 2.15.0: it is drawn in the page itself
     (admin/color_theme_toggle.html), so its rays can move on their own
     without being a mask that is resized. See "Light", below. */
  /* The white tick in a ticked tick box ("Tick boxes", below). */
  --icon-tick: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path d='M3.4 8.4l3 3 6.2-6.6' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  --icon-theme-dark: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'><path d='M20.2 14.7A8.2 8.2 0 0 1 9.3 3.8 8.6 8.6 0 1 0 20.2 14.7Z'/></svg>");
}

/* --- Light: Django's own colours, plus the few tokens components need --- */

:root,
html[data-theme="light"] {
  /* Light mode takes django's own breadcrumb and page colours as they
     ship. The top bar is the one exception (below); everything else here
     is the --md-* tokens components of ours need and django has no
     equivalent for. */
  --md-surface: #ffffff;
  --md-surface-sunken: #f8f8f8;

  /* --- The top bar -----------------------------------------------------
     A sweep from a deep navy at the left to django's own header teal,
     rather than one flat band of it. The bar is the full width of the
     screen and the only large field of colour on the page, and flat at
     that size reads as unfinished; a sweep gives the name at the left
     something to sit on and settles into the ordinary colour by the time
     it reaches the account links at the right.

     Same hue throughout (about 205 degrees) - only lightness moves - so
     it reads as one colour lit from the side rather than as two colours
     meeting. The end of the sweep is django's own --header-bg, untouched,
     which is why the right-hand side and the breadcrumb below it still
     agree with each other.

     It is an IMAGE over --header-bg rather than a replacement for it, so
     anything that cannot paint it still gets the flat colour, and dark
     mode turns it off by setting this to none. */
  --header-image: linear-gradient(to right, #12344f 0%, #2a5871 38%, #417690 72%);

  /* The breadcrumb strip repeats the sweep, every stop darkened by the
     same amount django's own --breadcrumbs-bg (#264b5d) is darker than
     its --header-bg (#417690). Without it the bar above went darkest
     exactly where the strip below stayed put, so the top-left corner of
     the page got darker going up and lighter going down and the two bars
     stopped looking like one piece of chrome. Right-hand end unchanged,
     which is why everything below still matches. */
  --breadcrumbs-image: linear-gradient(to right, #0b2133 0%, #193849 38%, #264b5d 72%);

  /* White, not django's gold. On the navy end of the sweep the gold read
     as a warning colour, and the practice's own name is not a warning.
     White is also what dark mode already uses, so the name looks the same
     in both. */
  --header-color: #ffffff;
  --header-branding-color: #ffffff;

  /* Django's own link blue, reused wherever a component needs an accent. */
  --md-accent: #417893;
  --md-accent-strong: #205067;
  --md-accent-soft: rgba(65, 120, 147, 0.12);
  --md-focus-ring: rgba(65, 120, 147, 0.28);

  /* The "Aggiungi ..." button at the top right of every list. Django's
     light theme paints it #747474 - a grey button for the one action on
     the page that creates something, sitting next to a Salva in the
     practice's own colour. Dark mode already had this pair; light mode
     was still on the default. */
  --object-tools-fg: #ffffff;
  --object-tools-bg: #417893;
  --object-tools-hover-bg: #205067;

  /* Pale tints and solid shades of the same hue that a few components
     need and django has no variable for. Named here rather than written
     into the components so that a business type with a palette of its
     own (Vertical.theme_stylesheet - solar's is solar/theme.css) can
     restate them alongside django's variables; every value is the one
     that component was written with, so this changes nothing on its own.
     Light mode only: the components' dark-mode rules set their own. */
  --bm-tint-hover: #DCEAF4;       /* the sidebar's show/hide strip, hovered */
  --bm-toggle-bg: #EEF4F9;        /* ... and at rest: a shade off the page */
  --bm-today-bg: #F6F9FC;         /* the Dashboard's "Oggi" panel */
  --bm-recent-bg: #FFFDF7;        /* the Dashboard's recent clients */
  --bm-today-column: rgba(65, 120, 147, 0.055); /* today in the calendar */
  --bm-calendar-head-bg: #F7CB5A; /* the date picker's top bar: honey (2.13.0; django's is lemon) */
  --bm-calendar-head-fg: #3B2B07;
  --bm-header-glow: rgba(255, 255, 255, 0.13);     /* the light under the mouse on the top bar (2.13.0) */
  --bm-header-glow-edge: rgba(176, 222, 255, 0.85); /* ... and on its lower edge */
  --bm-crumbs-glow: rgba(255, 255, 255, 0.10);      /* the same, softer, on the breadcrumb bar */
  --bm-crumbs-glow-edge: rgba(176, 222, 255, 0.60);
  --bm-pick-bg: var(--md-accent-soft); /* the suggestion under the mouse (2.13.0: a pale tint, was a solid blue bar) */
  --bm-history-bg: #2C5282;       /* Storia, at the foot of a form */
  --bm-history-hover-bg: #1F3F63;
  --bm-chart-incasso: #3b82c4;    /* "Incassato" in the Dati studio chart */
  --bm-chart-spese: #d64545;      /* "Spese", where a business type keeps them (2.9.0) */

  /* Since 2.6.0, so a business type can restate them (solar does). Each is
     what the component looked like before, written as a token. */
  --bm-sidebar-link-fg: var(--link-fg);   /* the model names in the menu */
  --bm-panel-head-bg: var(--secondary);   /* a client-page panel's title bar */
  --bm-panel-head-fg: var(--header-link-color, #ffffff);
  --bm-panel-head-border: transparent;    /* drawn inside the bar, no size */
  --bm-panel-bg: var(--darkened-bg);      /* ... and the panel under it */
  --bm-followups-bg: #ffffff;             /* the CRM's "Da fare oggi" panel */
  /* ...and a grainy mesh over that colour (2.13.0; solar): soft patches
     that drift slowly and brighten and fade, for ever, under a fine grain
     (crm.css, "Da fare oggi"). --bm-followups-layer: block draws it;
     -mesh is a list of radial gradients (the patches), -mesh-size their
     sizes, -mesh-pos-0 to -pos-2 three resting places, -motion the
     animation (crm-mesh-drift between the resting places, crm-mesh-glow
     fading the patches and back), -motion-calm what runs instead on a
     computer that asks for less motion, -grain an image laid over them
     with its -grain-opacity and -grain-blend. "initial": none of it. */
  --bm-followups-layer: initial;
  --bm-followups-mesh: initial;
  --bm-followups-mesh-size: initial;
  --bm-followups-mesh-pos-0: initial;
  --bm-followups-mesh-pos-1: initial;
  --bm-followups-mesh-pos-2: initial;
  --bm-followups-motion: initial;
  --bm-followups-motion-calm: initial;
  --bm-followups-grain: initial;
  --bm-followups-grain-opacity: initial;
  --bm-followups-grain-blend: initial;
  --bm-stat-bg: #f8f8f8;                  /* the figures above the CRM's Pipeline board */
  --bm-addlink-fg: var(--link-fg);        /* "Aggiungi" in the menu and home */
  --bm-foot-link-fg: var(--link-fg);      /* "Apri l'agenda" etc. on the Dashboard */
  --bm-dash-btn-fg: #2F855A;              /* "Appuntamento" on the Dashboard */
  --bm-dash-btn-border: #2F855A;
  --bm-dash-btn-hover-bg: #2F855A;
  --bm-dash-btn-hover-fg: #ffffff;
  /* "+ Nuovo" in a Dashboard panel's heading: a plain link unless a
     business type makes it a pill ("initial": the link's own colours). */
  --bm-head-add-fg: initial;
  --bm-head-add-bg: initial;
  --bm-head-add-border: initial;
  --bm-head-add-hover-bg: initial;
  --bm-head-add-hover-fg: initial;
  --bm-head-add-hover-line: initial;
  /* ...and while it is pressed (default: as under the pointer). */
  --bm-head-add-active-bg: initial;
  --bm-head-add-active-fg: initial;
  /* How far the pill reaches past the heading's end. Unset: by its own
     padding, so a plain link's words stay exactly where they were; a
     business type that draws the pill sets 0px, so the pill itself
     stops where the panel's content does instead of at its border. */
  --bm-head-add-pull: initial;

  /* The colours the BUTTONS are drawn with where they borrow the page's
     own (2.13.0): the plain ones' words, edge and wash under the pointer
     (Filtra, Giorno/Settimana/Mese, Mostra importi, Elimina on a phone's
     row sheet), and the link blue and accent of the outlined and tinted
     ones (Vista elenco and Vista calendario, Converti in cliente, Solo i
     miei, Crea fattura, "+ Nuovo" on a Dashboard panel, Aggiungi
     prestazione, Aggiungi un'altra, Scarica il backup, Filtra while a
     filter is on). Each is the variable it stands for, so nothing changes
     on its own; a business type with a palette of its own restates them
     with the colours its buttons had, so moving the page's colours does
     not move its buttons (solar and generic since 2.13.0, the owner's
     call). Light mode only: dark mode reads the dark palette through
     these defaults, as before. */
  --bm-btn-fg: var(--body-fg);
  --bm-btn-border: var(--border-color);
  --bm-btn-hover-bg: var(--darkened-bg);
  --bm-btn-link: var(--link-fg);
  --bm-btn-link-hover: var(--link-hover-color);
  --bm-btn-accent: var(--md-accent);
  --bm-btn-accent-strong: var(--md-accent-strong);
  --bm-btn-accent-soft: var(--md-accent-soft);

  /* The menu's pages as pills (2.13.0; see "The menu's pages, as pills").
     At rest the colours the rows always had - django's grey and its
     hairline; under the pointer a tint of the accent on the card's white
     (-hover-bg), an edge and a soft shadow in it, and the name in the
     links' hover colour; pressed, the shadow drawn inside; the page being
     viewed in its own fill, edged like the others unless a palette says
     otherwise. Mixed from the accent, so dark mode gets its own from the
     dark one. */
  --bm-pill-bg: var(--darkened-bg);
  --bm-pill-border: var(--hairline-color);
  --bm-pill-hover-bg: color-mix(in srgb, var(--md-accent) 8%, var(--md-surface));
  --bm-pill-hover-fg: var(--link-hover-color);
  --bm-pill-hover-border: color-mix(in srgb, var(--md-accent) 38%, transparent);
  --bm-pill-hover-shadow: 0 3px 10px -4px color-mix(in srgb, var(--md-accent) 45%, transparent);
  --bm-pill-press-shadow: inset 0 1px 3px color-mix(in srgb, var(--md-accent) 30%, transparent);
  --bm-pill-current-border: var(--hairline-color);

  /* The add buttons - "Aggiungi ... +" at the top right of a list, and
     the same pill elsewhere (Nuova trattativa on the board, Nuovo
     appuntamento on the agenda, Modifica dati and the round + on a
     client), and the Dashboard's Azioni rapide. They are not all the same
     colour in the core - django gives them three different variables, the
     tiles are white cards - so here each token is "initial", which makes
     var(--bm-action-bg, <its own colour>) fall back to the colour that
     button always had. A business type that restates them moves them all
     together (solar, 2.8.1: hollow, an orange outline and orange words,
     a pale orange wash and glow under the pointer, stronger pressed). */
  --bm-action-bg: initial;
  --bm-action-fg: initial;
  --bm-action-border: initial;
  --bm-action-hover-bg: initial;
  --bm-action-hover-fg: initial;
  --bm-action-hover-border: initial;  /* default: the hover fill's colour */
  --bm-action-active-bg: initial;     /* pressed - default: as hovered */
  --bm-action-active-fg: initial;
  --bm-action-active-border: initial; /* pressed - default: the pressed fill */
  /* The shadow round a pill under the pointer and pressed (default: the
     lifted shadow under the pointer, the small one pressed). An outlined
     pill can glow in its own colour instead (solar, 2.8.1). */
  --bm-action-hover-glow: initial;
  --bm-action-active-glow: initial;
  /* The Dashboard's Azioni rapide (2.14.0): their own set, so a business
     type can tell them apart from the add buttons. "initial": the
     --bm-action-* above (solar: the same shades in green). */
  --bm-quick-bg: initial;
  --bm-quick-fg: initial;
  --bm-quick-border: initial;
  --bm-quick-hover-bg: initial;
  --bm-quick-hover-fg: initial;
  --bm-quick-hover-border: initial;
  --bm-quick-active-bg: initial;
  --bm-quick-active-fg: initial;
  --bm-quick-active-border: initial;
  --bm-quick-hover-glow: initial;
  --bm-quick-active-glow: initial;
  /* The secondary buttons beside those pills (2.13.0): a different way to
     look at the same records, or a step on the side - Vista elenco, Vista
     calendario, Vista pipeline, Solo le mie / Solo i miei, Scheda
     cliente, Fissa appuntamento... "initial": each keeps the colours it
     has always had; a business type can give them all one look (solar:
     blue, against the orange of the pills that create something). The
     ring is the board's outline width (crm.css, .crm-ghost). */
  --bm-secondary-fg: initial;
  --bm-secondary-bg: initial;
  --bm-secondary-border: initial;
  --bm-secondary-ring: initial;
  --bm-secondary-hover-fg: initial;
  --bm-secondary-hover-bg: initial;
  --bm-secondary-hover-border: initial;
  /* How heavy the words are: the pills that create something and the
     secondary buttons (2.13.0). "initial": both semibold, as before; solar
     makes the pill bolder and the secondary ones lighter. */
  --bm-action-weight: initial;
  --bm-secondary-weight: initial;
  /* The round + on each of the client page's panels (2.12.0), the same
     eleven as the add buttons above and, "initial", the same colours; a
     business type can give it its own (solar: hollow grey). */
  --bm-client-add-bg: initial;
  --bm-client-add-fg: initial;
  --bm-client-add-border: initial;
  --bm-client-add-hover-bg: initial;
  --bm-client-add-hover-fg: initial;
  --bm-client-add-hover-border: initial;
  --bm-client-add-active-bg: initial;
  --bm-client-add-active-fg: initial;
  --bm-client-add-active-border: initial;
  --bm-client-add-hover-glow: initial;
  --bm-client-add-active-glow: initial;
  /* The agenda's arrows and "Oggi", in every business type (2.9.1, the
     owner's call; filled before): hollow - a green edge and green words
     on a light green, a deeper green wash under the pointer and a
     stronger one pressed. Dark values in the dark blocks below. */
  --bm-nav-bg: #EAF6EE;
  --bm-nav-fg: #276749;
  --bm-nav-border: #2F855A;
  --bm-nav-hover-bg: #D3EFDC;
  --bm-nav-hover-fg: #22543D;
  --bm-nav-hover-border: #276749;
  --bm-nav-active-bg: #BCE3C9;
  --bm-nav-active-fg: #1C4532;
  --bm-nav-active-border: #22543D;
  /* The menu: the page being viewed (default: django's --selected-row)
     and a wash while an entry or the show/hide strip is pressed (default:
     none). */
  --bm-sidebar-current-bg: initial;
  --bm-sidebar-press: initial;
  /* The menu's section titles (default: django's header colours). */
  --bm-sidebar-caption-bg: initial;
  --bm-sidebar-caption-fg: initial;
  /* The switches on Impostazioni (2.8.1): the track when off, and the
     shadow under the round knob. On is the theme's accent. */
  --bm-switch-off: #C5CBD3;
  /* Done (2.9.0): the tick beside a preventivo's "Crea fattura" once its
     fattura is saved. A state, not palette: the green of a paid fattura,
     the same in every business type, lighter in dark mode. */
  --bm-done-fg: #2F855A;
  --bm-done-bg: rgba(47, 133, 90, 0.12);
  --bm-switch-knob-shadow: rgba(16, 24, 40, 0.28);
  /* A list's Cerca (very light blue) and its actions' Vai (very light
     green), 2.9.0: two plain buttons told apart at a glance. Dark values
     in the dark blocks below. */
  --bm-search-btn-bg: #E8F2FC;
  --bm-search-btn-border: #BBD5EF;
  --bm-search-btn-fg: #1D4E7A;
  --bm-search-btn-hover-bg: #D6E8F9;
  --bm-go-btn-bg: #E7F6EC;
  --bm-go-btn-border: #B3DEC1;
  --bm-go-btn-fg: #1E6B3A;
  --bm-go-btn-hover-bg: #D3EFDC;
  /* Section colours (2.10.1, clinic/sections.py): each titled section of
     an edit page - and each table with a title - by what it holds. The
     title bar ("-head") fades into the section ("-bg"), which fades to
     the card's own white towards the bottom. Dark values (title bar only,
     section untouched) in the dark blocks below. */
  --bm-section-place-head: #D3E5F8;
  --bm-section-place-bg: #EAF2FC;
  --bm-section-tech-head: #CBEAE2;
  --bm-section-tech-bg: #E6F5F1;
  --bm-section-money-head: #F4E1B8;
  --bm-section-money-bg: #FAF1DD;
  --bm-section-time-head: #DDD5F4;
  --bm-section-time-bg: #EFEBFA;
  --bm-section-people-head: #F3D3DE;
  --bm-section-people-bg: #FAEAF0;
  --bm-section-sales-head: #F7D5C4;
  --bm-section-sales-bg: #FCEBE2;
  --bm-section-docs-head: #E5DFD2;
  --bm-section-docs-bg: #F3F0E9;
  --bm-section-other-head: #DAE1E9;
  --bm-section-other-bg: #EDF1F5;

  /* The top bar's moving patches (2.13.0, the Metodell palettes): a
     business type can draw soft spots of colour in the bar's own image
     (--header-image: the spots first, the bar's colour last) and move
     them. -mesh-size gives each layer of that image its size, -mesh-pos-0
     to -pos-2 three resting places, -motion the animation (bm-header-drift,
     with the header's rules). "initial": one image, still, as on dental. */
  --bm-header-mesh-size: initial;
  --bm-header-mesh-pos-0: initial;
  --bm-header-mesh-pos-1: initial;
  --bm-header-mesh-pos-2: initial;
  --bm-header-motion: initial;
  /* The same layers' sizes in the login page's band (2.14.0), many times
     taller than the bar: "initial" takes -mesh-size. */
  --bm-login-mesh-size: initial;

  /* The page's greys as they were before a palette moved them, for the
     places that keep them (2.13.0, the owner's call): every table and
     list - a list's whole card, with its search bar - the client page's
     panels, the Pipeline's figures and the date picker ("Regions that
     keep the classic colours", further down). Each is the variable it
     stands for, so nothing changes on its own; a palette that moves the
     page's greys restates them with the old ones. */
  /* La mappa dell'attività (2.14.0, the Dashboard): one colour per
     section, in the family of Metodell's mark - violets, blues, cyans -
     with the warmer ones for solar's own sections. Mid tones, so they
     read on the light card and on the dark one alike. */
  --bm-net-1: #6D4AFF;   /* clients */
  --bm-net-2: #2F7BF6;   /* Agenda */
  --bm-net-3: #9B5CF6;   /* Preventivi */
  --bm-net-4: #0EA5E9;   /* Fatture */
  --bm-net-5: #14B8A6;   /* Acconti */
  --bm-net-6: #5B5FEF;   /* Prestazioni */
  --bm-net-7: #C04AF0;   /* Trattative */
  --bm-net-8: #E25FB8;   /* Attività */
  --bm-net-9: #F2A33A;   /* Impianti */
  --bm-net-10: #22B07D;  /* Pratiche */
  --bm-net-11: #06B6D4;  /* Manutenzioni */
  --bm-net-12: #8A94A6;  /* Spese */

  /* The filter panel's two icons (2.13.0): the eye light blue, the
     funnel dark yellow. Lighter in the dark blocks below. */
  --bm-filter-counts-icon: #3B9AE1;
  --bm-filter-clear-icon: #B7791F;

  --bm-classic-bg: var(--darkened-bg);
  --bm-classic-sunken: var(--md-surface-sunken);
  --bm-classic-hairline: var(--hairline-color);
  --bm-classic-border: var(--border-color);
  --bm-classic-selected-bg: var(--selected-bg);
  --bm-classic-selected-row: var(--selected-row);
  --bm-classic-quiet: var(--body-quiet-color);

  --md-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --md-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.16);
}

/* --- Light, on a phone --------------------------------------------------
   No sweep - one flat colour, and it is the navy the desktop sweep
   starts from rather than the teal it ends on.

   A gradient needs room to be a gradient. Across a desktop bar it is a
   slow change nobody has to notice; squeezed into 390px it becomes a
   visible diagonal behind the menu button and the name, and the bar
   stops reading as one colour. So the phone takes a single colour, and
   the one worth taking is the deep end: it is the half of the sweep that
   reads as the app's own, the teal is django's default showing through,
   and a phone bar sitting on the same navy as the left of the desktop
   one makes the two obviously the same product.

   The name is white here too, for the same reason it is white on the
   desktop: against navy the old gold read as a warning colour. White on
   this navy is 12.4:1, which is comfortable at any size - the yellow it
   replaces was 4.0:1 against the teal.

   Only the flat colours change; --header-image stays off. The breadcrumb
   strip is not drawn on a phone at all (mobile-nav.css replaces the
   trail with the drawer), but its colour is set alongside so the pair
   cannot drift if it is ever brought back.

   767px, not 600: that is where mobile-nav.css replaces the whole header
   with the phone one - menu button, name, theme switch - so the two
   always change together.

   Placed between the light and dark blocks on purpose. After light, so it
   wins on a phone; before dark, so dark still wins over it at every
   width. Moving it below them turns a dark phone's bar navy. */

@media (max-width: 767px) {
  :root,
  html[data-theme="light"] {
    --header-image: none;
    --breadcrumbs-image: none;
    /* The first stop of --header-image and of --breadcrumbs-image. */
    --header-bg: #12344f;
    --breadcrumbs-bg: #0b2133;
    --header-branding-color: #ffffff;
  }
}

/* --- Dark ---------------------------------------------------------------
   Repeated verbatim under the media query and under [data-theme="dark"],
   mirroring how django ships dark_mode.css, so the in-app toggle and the
   OS setting both land here. */

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #237bff;
    /* Lifted off the page colour so the sidebar's section bar reads. */
    --secondary: #23252e;
    /* Stays light: django paints #333 text on --accent in the date picker. */
    --accent: #f5dd5d;
    --primary-fg: #ffffff;

    --body-fg: #e4e7ec;
    --body-bg: #15171c;
    --body-quiet-color: #9ea7b1;
    --body-medium-color: #c3c9d1;
    --body-loud-color: #ffffff;

    --header-color: #ffffff;
    --header-branding-color: #ffffff;
    --header-bg: #1a1c23;
    --header-link-color: #ffffff;
    /* No sweep in dark mode: the bar is already a lift off a near-black
       page, and a gradient across it would read as a smudge. */
    --header-image: none;
    --breadcrumbs-image: none;

    --breadcrumbs-fg: #9ea7b1;
    --breadcrumbs-link-fg: #6ba5ff;
    --breadcrumbs-bg: #101216;

    --link-fg: #4f93ff;
    --link-hover-color: #85b6ff;
    --link-selected-fg: #85b6ff;

    --hairline-color: #23252e;
    --border-color: #2c2f39;

    /* The outline round a fieldset on a change form. --hairline-color is
       the page colour here, so the rules that frame each section in light
       mode disappeared completely in dark.

       A plain grey, not green. Green is what the app's controls are -
       Oggi, Storia, the add links - and a green rule round a section
       title said the title bar was one of them. Grey says "this is where
       the section starts" and nothing else.

       Mid-grey rather than near-white: the line only has to be findable,
       and a white one drew more attention than the title it was framing.
       It still clears --hairline-color (#23252e), which is the page
       colour here and is why these lines vanished in dark mode at all. */
    --fieldset-rule: #6b7280;

    --error-fg: #ff7a8a;

    --message-success-bg: #12291f;
    --message-warning-bg: #2b2415;
    --message-error-bg: #2e1720;

    --darkened-bg: #1b1d24;
    --selected-bg: #23252e;
    --selected-row: #1d212b;

    --button-fg: #ffffff;
    --button-bg: #2b2f3a;
    --button-hover-bg: #363b48;
    --default-button-bg: #237bff;
    --default-button-hover-bg: #3d8cff;
    --close-button-bg: #2b2f3a;
    --close-button-hover-bg: #363b48;
    --delete-button-bg: #c0392f;
    --delete-button-hover-bg: #d9483c;

    --object-tools-fg: #ffffff;
    --object-tools-bg: #237bff;
    --object-tools-hover-bg: #3d8cff;

    --md-surface: #1b1d24;
    --md-surface-sunken: #16181e;
    --md-accent: #237bff;
    --md-accent-strong: #3d8cff;
    --md-accent-soft: rgba(35, 123, 255, 0.16);
    --md-focus-ring: rgba(35, 123, 255, 0.4);
    --md-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --md-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);

    --bm-done-fg: #58C68B;
    --bm-done-bg: rgba(88, 198, 139, 0.16);
    --bm-filter-counts-icon: #7CC0F5;
    --bm-filter-clear-icon: #E3B341;
    --bm-search-btn-bg: rgba(35, 123, 255, 0.14);
    --bm-search-btn-border: rgba(35, 123, 255, 0.38);
    --bm-search-btn-fg: #a9c9ff;
    --bm-search-btn-hover-bg: rgba(35, 123, 255, 0.24);
    --bm-go-btn-bg: rgba(56, 161, 105, 0.16);
    --bm-go-btn-border: rgba(72, 187, 120, 0.40);
    --bm-go-btn-fg: #9ae6b4;
    --bm-go-btn-hover-bg: rgba(56, 161, 105, 0.26);
    --bm-calendar-head-bg: rgba(246, 196, 69, 0.20);
    --bm-calendar-head-fg: #F6D27E;
    --bm-header-glow: rgba(120, 170, 255, 0.10);
    --bm-header-glow-edge: rgba(61, 140, 255, 0.80);
    --bm-crumbs-glow: rgba(120, 170, 255, 0.08);
    --bm-crumbs-glow-edge: rgba(61, 140, 255, 0.55);
    --bm-nav-bg: rgba(56, 161, 105, 0.16);
    --bm-nav-fg: #9AE6B4;
    --bm-nav-border: rgba(104, 211, 145, 0.70);
    --bm-nav-hover-bg: rgba(56, 161, 105, 0.28);
    --bm-nav-hover-fg: #C6F6D5;
    --bm-nav-hover-border: #68D391;
    --bm-nav-active-bg: rgba(56, 161, 105, 0.40);
    --bm-nav-active-fg: #F0FFF4;
    --bm-nav-active-border: #9AE6B4;
    --bm-section-place-head: rgba(66, 153, 225, 0.34);
    --bm-section-place-bg: transparent;
    --bm-section-tech-head: rgba(56, 178, 172, 0.32);
    --bm-section-tech-bg: transparent;
    --bm-section-money-head: rgba(214, 158, 46, 0.32);
    --bm-section-money-bg: transparent;
    --bm-section-time-head: rgba(128, 90, 213, 0.36);
    --bm-section-time-bg: transparent;
    --bm-section-people-head: rgba(213, 63, 140, 0.30);
    --bm-section-people-bg: transparent;
    --bm-section-sales-head: rgba(237, 137, 54, 0.32);
    --bm-section-sales-bg: transparent;
    --bm-section-docs-head: rgba(160, 174, 192, 0.26);
    --bm-section-docs-bg: transparent;
    --bm-section-other-head: rgba(113, 128, 150, 0.30);
    --bm-section-other-bg: transparent;
  }
}

html[data-theme="dark"] {
  --primary: #237bff;
  /* Lifted off the page colour so the sidebar's section bar reads. */
  --secondary: #23252e;
  /* Stays light: django paints #333 text on --accent in the date picker. */
  --accent: #f5dd5d;
  --primary-fg: #ffffff;

  --body-fg: #e4e7ec;
  --body-bg: #15171c;
  --body-quiet-color: #9ea7b1;
  --body-medium-color: #c3c9d1;
  --body-loud-color: #ffffff;

  --header-color: #ffffff;
  --header-branding-color: #ffffff;
  --header-bg: #1a1c23;
  --header-link-color: #ffffff;
  --header-image: none;
  --breadcrumbs-image: none;

  --breadcrumbs-fg: #9ea7b1;
  --breadcrumbs-link-fg: #6ba5ff;
  --breadcrumbs-bg: #101216;

  --link-fg: #4f93ff;
  --link-hover-color: #85b6ff;
  --link-selected-fg: #85b6ff;

  --hairline-color: #23252e;
  --border-color: #2c2f39;

  /* See the note on the same token under the media query above. */
  --fieldset-rule: #6b7280;

  --error-fg: #ff7a8a;

  --message-success-bg: #12291f;
  --message-warning-bg: #2b2415;
  --message-error-bg: #2e1720;

  --darkened-bg: #1b1d24;
  --selected-bg: #23252e;
  --selected-row: #1d212b;

  --button-fg: #ffffff;
  --button-bg: #2b2f3a;
  --button-hover-bg: #363b48;
  --default-button-bg: #237bff;
  --default-button-hover-bg: #3d8cff;
  --close-button-bg: #2b2f3a;
  --close-button-hover-bg: #363b48;
  --delete-button-bg: #c0392f;
  --delete-button-hover-bg: #d9483c;

  --object-tools-fg: #ffffff;
  --object-tools-bg: #237bff;
  --object-tools-hover-bg: #3d8cff;

  --md-surface: #1b1d24;
  --md-surface-sunken: #16181e;
  --md-accent: #237bff;
  --md-accent-strong: #3d8cff;
  --md-accent-soft: rgba(35, 123, 255, 0.16);
  --md-focus-ring: rgba(35, 123, 255, 0.4);
  --md-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --md-shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);

  --bm-done-fg: #58C68B;
  --bm-done-bg: rgba(88, 198, 139, 0.16);
  --bm-filter-counts-icon: #7CC0F5;
  --bm-filter-clear-icon: #E3B341;
  --bm-search-btn-bg: rgba(35, 123, 255, 0.14);
  --bm-search-btn-border: rgba(35, 123, 255, 0.38);
  --bm-search-btn-fg: #a9c9ff;
  --bm-search-btn-hover-bg: rgba(35, 123, 255, 0.24);
  --bm-go-btn-bg: rgba(56, 161, 105, 0.16);
  --bm-go-btn-border: rgba(72, 187, 120, 0.40);
  --bm-go-btn-fg: #9ae6b4;
  --bm-go-btn-hover-bg: rgba(56, 161, 105, 0.26);
  --bm-calendar-head-bg: rgba(246, 196, 69, 0.20);
  --bm-calendar-head-fg: #F6D27E;
  --bm-header-glow: rgba(120, 170, 255, 0.10);
  --bm-header-glow-edge: rgba(61, 140, 255, 0.80);
  --bm-crumbs-glow: rgba(120, 170, 255, 0.08);
  --bm-crumbs-glow-edge: rgba(61, 140, 255, 0.55);
  --bm-nav-bg: rgba(56, 161, 105, 0.16);
  --bm-nav-fg: #9AE6B4;
  --bm-nav-border: rgba(104, 211, 145, 0.70);
  --bm-nav-hover-bg: rgba(56, 161, 105, 0.28);
  --bm-nav-hover-fg: #C6F6D5;
  --bm-nav-hover-border: #68D391;
  --bm-nav-active-bg: rgba(56, 161, 105, 0.40);
  --bm-nav-active-fg: #F0FFF4;
  --bm-nav-active-border: #9AE6B4;
  --bm-section-place-head: rgba(66, 153, 225, 0.34);
  --bm-section-place-bg: transparent;
  --bm-section-tech-head: rgba(56, 178, 172, 0.32);
  --bm-section-tech-bg: transparent;
  --bm-section-money-head: rgba(214, 158, 46, 0.32);
  --bm-section-money-bg: transparent;
  --bm-section-time-head: rgba(128, 90, 213, 0.36);
  --bm-section-time-bg: transparent;
  --bm-section-people-head: rgba(213, 63, 140, 0.30);
  --bm-section-people-bg: transparent;
  --bm-section-sales-head: rgba(237, 137, 54, 0.32);
  --bm-section-sales-bg: transparent;
  --bm-section-docs-head: rgba(160, 174, 192, 0.26);
  --bm-section-docs-bg: transparent;
  --bm-section-other-head: rgba(113, 128, 150, 0.30);
  --bm-section-other-bg: transparent;
}

/* ===========================================================================
   Components - shape and spacing only; every colour comes from a variable
   =========================================================================== */

/* --- Header ------------------------------------------------------------- */

#header {
  padding: 14px 40px;
  border-bottom: none;
  /* The sweep, in light mode; "none" in dark, which leaves django's own
     --header-bg showing through underneath. Set as the image rather than
     the whole background so the flat colour stays as the floor. */
  background-image: var(--header-image, none);
  /* A palette's moving patches (2.13.0; the tokens at the top): each
     layer of the image at its own size and place, moved between three
     resting places. One image at its own size, still, without them. */
  background-size: var(--bm-header-mesh-size, auto);
  background-position: var(--bm-header-mesh-pos-0, 0 0);
  background-repeat: no-repeat;
  animation: var(--bm-header-motion, none);
}

@keyframes bm-header-drift {
  0% { background-position: var(--bm-header-mesh-pos-0, 0 0); }
  50% { background-position: var(--bm-header-mesh-pos-1, 0 0); }
  100% { background-position: var(--bm-header-mesh-pos-2, 0 0); }
}

/* A computer that asks for less motion keeps the patches where they first
   are. */
@media (prefers-reduced-motion: reduce) {
  #header {
    animation: none;
  }
}

#site-name a:link,
#site-name a:visited {
  color: var(--header-branding-color);
}

/* The business's name a touch bolder than django's thin 300 (2.10.1, the
   owner's call). */
#site-name {
  font-weight: 400;
}

/* Page titles in capitals and bold on every page (2.10.1). The rule is
   also in admin_overrides.css, which the home page never loads: its
   "Pannello di amministrazione" was django's thin line. */
#content h1 {
  text-transform: uppercase;
  font-weight: 700;
}

#user-tools {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

/* --- Breadcrumbs -------------------------------------------------------- */

div.breadcrumbs {
  font-size: 0.78rem;
  padding: 10px 40px;
  /* The darkened half of the header's sweep; "none" in dark mode. See the
     token in the light block at the top of this file. */
  background-image: var(--breadcrumbs-image, none);
}

/* --- The light under the mouse (2.13.0, the owner's call) ---------------
   Over the top bar a soft light follows the mouse, and the bar's lower
   edge lights up under it; over the breadcrumb bar the same, smaller and
   softer. header-glow.js tells each bar where the mouse is (--glow-x,
   --glow-y) and that it is over it (is-glowing); a screen that is touched
   rather than pointed at never gets it. Drawn on two layers between each
   bar's own background and its words (isolation, z-index -1), so neither
   the colours of the bar nor its text move. The colours are tokens
   (--bm-header-glow*, --bm-crumbs-glow*): a business type tints them to
   its own bar. */
#header,
div.breadcrumbs {
  position: relative;
  isolation: isolate;
}

#header {
  --glow-color: var(--bm-header-glow);
  --glow-edge-color: var(--bm-header-glow-edge);
  --glow-size: 300px;
  --glow-edge-size: 220px;
  --glow-edge-height: 2px;
}

div.breadcrumbs {
  --glow-color: var(--bm-crumbs-glow);
  --glow-edge-color: var(--bm-crumbs-glow-edge);
  --glow-size: 200px;
  --glow-edge-size: 160px;
  --glow-edge-height: 1px;
}

#header::before,
div.breadcrumbs::before,
#header::after,
div.breadcrumbs::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#header::before,
div.breadcrumbs::before {
  inset: 0;
  background: radial-gradient(circle var(--glow-size) at var(--glow-x, 50%) var(--glow-y, 50%),
                              var(--glow-color), transparent 70%);
}

#header::after,
div.breadcrumbs::after {
  right: 0;
  bottom: 0;
  left: 0;
  height: var(--glow-edge-height);
  background: radial-gradient(var(--glow-edge-size) 100% at var(--glow-x, 50%) 50%,
                              var(--glow-edge-color), transparent 70%);
}

#header.is-glowing::before,
div.breadcrumbs.is-glowing::before,
#header.is-glowing::after,
div.breadcrumbs.is-glowing::after {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  #header::before,
  div.breadcrumbs::before,
  #header::after,
  div.breadcrumbs::after { transition: none; }
}

/* --- Collapsible sections ("Numerazione manuale") ------------------------
   The bar you click to open a section that is folded away by default.

   Django paints it in --header-bg, the app's strongest colour, for the
   one section on the page nobody opens; until 2.12.0 it was a pale tint
   of the theme instead. Since 2.13.0 (the owner's call) it is the page's
   own background, in light and dark alike: a plain outlined bar with the
   words in the text's colour - still something to press (the triangle,
   the pointer), no longer a coloured band.

   Body class in the selector so this outranks django's own, which is
   in forms.css and loads in a block that can land either side of this
   file depending on the page. */
.change-form :not(.inline-related) .collapse summary {
  background: transparent;
  border-color: var(--border-color);
  color: var(--body-fg);
}

.change-form :not(.inline-related) .collapse summary:hover {
  background: var(--darkened-bg);
}

/* The section itself, closed or open: no card colour and no section
   tint ("bm-section-money"...), the page showing through. */
.change-form :not(.inline-related) > fieldset.module.collapse {
  background-color: transparent;
  background-image: none;
  box-shadow: none;
}

.change-form :not(.inline-related) > fieldset.module.collapse > details > summary > h2 {
  background: transparent;
  color: inherit;
}

/* --- Cards / modules ---------------------------------------------------- */

.module,
.dashboard-col,
.inline-related fieldset.module {
  background: var(--md-surface);
  border: 1px solid var(--hairline-color);
  border-radius: var(--md-radius);
  box-shadow: var(--md-shadow-sm);
}

.module,
.inline-related fieldset.module {
  overflow: hidden;
}

/* ...except sideways, for a table of lines. overflow:hidden is there to
   keep the contents inside the rounded corners, but on a table wider than
   its card it simply cut the last columns off: at 1280px a fattura's
   Prestazioni lost Denti and Cancella altogether, with nothing to say they
   were there. Now the card scrolls sideways instead. On a screen with
   room for the whole row nothing scrolls and nothing changes; on a phone
   the rows are cards (inline-sheet.css) and the table is parked out of
   sight, so there is nothing here to scroll. */
.inline-group .tabular fieldset.module {
  overflow-x: auto;
  overflow-y: hidden;
}

/* The section's title bar is in the card that scrolls, so it slid off to
   the left with the columns and its right-hand end came along into the
   middle of the table (2.12.0, an impianto's Pratiche). Held at the
   card's left edge instead: it stays the width of the card while the
   rows move under it. */
.inline-group .tabular fieldset.module > h2 {
  position: sticky;
  left: 0;
}

/* Three lines round each section title on a change form - over the top of
   the heading bar and down its two ends - and nothing else. Nine lines on
   a fattura: Prestazioni, Pagamenti, Note e marca da bollo.

   Dark mode only. In light mode --hairline-color already draws these and
   they read well, so there is deliberately no rule here that light mode
   can reach: the selectors below are all under a dark-mode root, and the
   previous attempt - one shared rule with a var() fallback - is gone. In
   dark mode --hairline-color is the page colour itself, so the same lines
   were simply invisible.

   The colour is a near-white, not the green these started as: see the
   note on --fieldset-rule.

   Not the heading's bottom edge and not the rest of the card: outlining
   the whole card put green round everything, which is a different thing
   from making the titles stand out.

   The card's overflow:hidden and border-radius clip the ends of the top
   line, which is what keeps it from meeting the corners. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .change-form #content-main .module > h2,
  html:not([data-theme="light"]) .change-form .inline-related h3 {
    border-top: 1px solid var(--fieldset-rule);
    border-left: 1px solid var(--fieldset-rule);
    border-right: 1px solid var(--fieldset-rule);
  }
}

html[data-theme="dark"] .change-form #content-main .module > h2,
html[data-theme="dark"] .change-form .inline-related h3 {
  border-top: 1px solid var(--fieldset-rule);
  border-left: 1px solid var(--fieldset-rule);
  border-right: 1px solid var(--fieldset-rule);
}

/* Only the three tables at the foot of a patient's page scroll. Scoped
   deliberately: "overflow-x: auto" alone also turns overflow-y into auto
   (the spec won't let one axis be visible while the other is not), which
   on the odontogramma panel meant the hover card counted as overflow and
   the panel grew a scrollbar of its own. */
.dashboard-grid .dashboard-col {
  overflow-x: auto;
}

/* The odontogramma's hover card has to be free to spill out of its panel
   and over whatever is next to it. */
.chart-agenda-grid .dashboard-col {
  overflow: visible;
}

/* Five columns in a third-width panel: tightening the cells lets the last
   one ("Modifica") fit outright at normal window widths, so the scrollbar
   above stays a fallback for narrow screens rather than the usual case. */
.dashboard-col table.dash-table th,
.dashboard-col table.dash-table td {
  padding: 6px 5px;
  font-size: 0.82em;
}

.dashboard-col table.dash-table th:first-child,
.dashboard-col table.dash-table td:first-child {
  padding-left: 2px;
}

/* The app-list caption is a link, and django colours caption links white
   with a more specific selector than the caption itself - which would
   leave white text on the quiet caption bar below. */
#content-main .module caption a,
#content-main .module caption a:link,
#content-main .module caption a:visited,
.module caption a {
  color: var(--body-loud-color);
}

.module > h2,
#content-main .module caption,
.inline-related h3 {
  background: var(--md-surface-sunken);
  color: var(--body-loud-color);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--hairline-color);
}

/* --- Section colours (2.10.1, the owner's call) ---------------------------

   Each titled section of an edit page, and each table with a title, in
   the colour of what it holds (clinic/sections.py picks the family from
   the title: an address is blue, money amber, dates violet...). In light
   mode the title bar fades from a deeper shade into the section's own,
   and the section fades from it to the card's white towards the bottom;
   the boxes and the rows of a table stay white on top. In dark mode the
   -bg tokens are transparent, so only the title bar takes a fade of its
   colour and the section is untouched. The first, untitled part of a form
   has no class and keeps the plain card. */
fieldset.module.bm-section-place {
  --section-head: var(--bm-section-place-head);
  --section-bg: var(--bm-section-place-bg);
}

fieldset.module.bm-section-tech {
  --section-head: var(--bm-section-tech-head);
  --section-bg: var(--bm-section-tech-bg);
}

fieldset.module.bm-section-money {
  --section-head: var(--bm-section-money-head);
  --section-bg: var(--bm-section-money-bg);
}

fieldset.module.bm-section-time {
  --section-head: var(--bm-section-time-head);
  --section-bg: var(--bm-section-time-bg);
}

fieldset.module.bm-section-people {
  --section-head: var(--bm-section-people-head);
  --section-bg: var(--bm-section-people-bg);
}

fieldset.module.bm-section-sales {
  --section-head: var(--bm-section-sales-head);
  --section-bg: var(--bm-section-sales-bg);
}

fieldset.module.bm-section-docs {
  --section-head: var(--bm-section-docs-head);
  --section-bg: var(--bm-section-docs-bg);
}

fieldset.module.bm-section-other {
  --section-head: var(--bm-section-other-head);
  --section-bg: var(--bm-section-other-bg);
}

fieldset.module.bm-section {
  background-image: linear-gradient(180deg, var(--section-bg) 0%, transparent 100%);
}

fieldset.module.bm-section > h2,
fieldset.module.bm-section > details > summary > h2 {
  background-color: var(--md-surface-sunken);
  background-image: linear-gradient(90deg, var(--section-head) 0%, var(--section-bg) 100%);
}

/* A table's frame - its column headings and its "+ Aggiungi" row - lets
   the section's colour through instead of its own grey; its rows stay
   white. (In dark mode the frame was already the card's colour.) */
.inline-group fieldset.module.bm-section thead th,
.inline-group .tabular fieldset.module.bm-section tr.add-row,
.inline-group .tabular fieldset.module.bm-section tr.add-row td {
  background: transparent;
}

/* --- Right-hand column (Azioni recenti) ---------------------------------

   #content-related is only a column wrapper, but django fills it with
   --darkened-bg. That was invisible when the module inside it was a flat
   panel of the same colour; now the module is a white card, the wrapper's
   own fill showed as a stray grey band hanging below it. */

#content-related {
  background: none;
}

/* --- Changelist: results card and filter panel --------------------------

   Django wraps both the results and the filter sidebar in one element,
   #changelist, which also carries .module - so the card styling above put
   a single rounded box around the pair. Because the two are flex siblings,
   the box grew to whichever was taller: on a short list with a long filter
   (or the reverse) it left a large empty stretch of card with nothing in
   it, and the filter's own panel inherited a stray rounded corner where it
   met the card's edge.

   So #changelist is not a card. The results column is, and the filter is
   its own square-edged panel beside it - each ending where its own content
   ends. */

#changelist.module {
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

#changelist .changelist-form-container {
  background: var(--md-surface);
  border: 1px solid var(--hairline-color);
  border-radius: var(--md-radius);
  box-shadow: var(--md-shadow-sm);
  overflow: hidden;
  min-width: 0;
}

/* Narrower than django's 240px, and closer in: the width it takes comes
   straight out of the results table, which on a list with several columns
   was enough to push the last one out of sight. */
#changelist #changelist-filter {
  flex: 0 0 200px;
  margin-left: 18px;
  background: var(--md-surface);
  border: 1px solid var(--hairline-color);
  border-radius: 0;
  box-shadow: var(--md-shadow-sm);
  overflow: hidden;
  align-self: flex-start;
}

#changelist #changelist-filter h2,
#changelist #changelist-filter h3 {
  border-radius: 0;
}

/* --- Tables ------------------------------------------------------------- */

/* A list wider than the screen scrolls sideways inside its own box
   (django's .results). Positioned, so that the box also holds whatever a
   cell places absolutely - django's visually-hidden words, such as the
   ones behind Utenti's Privilegi icons. Those were placed against the
   page instead, and stretched it: on a phone the whole page slid
   sideways past the list (2.9.1). */
#changelist .results {
  position: relative;
}

#changelist table thead th,
.results thead th {
  background: var(--md-surface-sunken);
  border-bottom: 1px solid var(--border-color);
}

/* Uppercase with generous tracking is what makes a header read as a
   header - but it also makes the header the widest thing in its column,
   so the tracking is kept modest and the size small. */
#changelist table thead th a,
.results thead th a {
  color: var(--body-quiet-color);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Django holds thead th to one line, so a two-word heading like
   "Prestazione prevista" props its whole column open - and an uppercased
   heading is wider still. Letting it wrap drops the column's minimum to
   its longest single word. (Django also sets padding: 0 on thead th and
   puts the padding on the link inside; don't override that or every
   column gets wider.) */
#changelist table thead th {
  white-space: normal;
}

#changelist tbody tr:hover > * {
  background: var(--selected-row);
}

/* Sort controls.

   Django floats them beside a block heading with 9px of top padding, so a
   sorted column's header grew taller than its neighbours and the heading
   itself could drop below the float. Sorting a column should not move the
   header row at all - so the controls come out of flow entirely, pinned to
   the right of the cell and vertically centred. Out of flow means they
   cost no height, and the small gutter reserved below is the only width
   they take from the column. */
#changelist table thead th {
  position: relative;
  vertical-align: middle;
}

#changelist table thead th .text {
  display: block;
}

#changelist table thead th.sortable .text,
#changelist table thead th.sorted .text {
  padding-right: 20px;
}

#changelist table thead th .sortoptions {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  float: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  margin: 0;
}

/* The column the list is sorted by shows both of its controls all the
   time (2.6.1): the arrow saying which way it is sorted, and before it
   the barred arrows that take the sort off. Django showed the second
   only under the pointer, so nobody knew it was there, and drew it over
   the end of the heading's own highlighted box. Here the heading leaves
   room for both (6px from the cell's edge, 14px each, 4px between, 6px
   before the heading's box ends), and the icons are django's own -
   same shapes, same colours. */
#changelist table thead th.sorted .text {
  padding-right: 44px;
}

#changelist table thead th.sorted a.sortremove {
  visibility: visible;
}

/* The float's clearing div has nothing left to clear, and it added a stray
   line box to every header. */
#changelist table thead th .clear {
  display: none;
}

/* --- Page numbers under a list (2.9.0) ----------------------------------

   The page you are on is the one that stands out: filled with the theme's
   accent, white number. The others are plain numbers in a light outline,
   to click. Django did the opposite - every OTHER page a filled button
   (in solar's orange) and the current one bare text - so the eye landed
   on the pages you were not on. */
.paginator a:link,
.paginator a:visited,
.paginator .this-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-decoration: none;
  vertical-align: middle;
}

.paginator a:link,
.paginator a:visited {
  background: transparent;
  color: var(--body-fg);
  box-shadow: inset 0 0 0 1px var(--border-color);
  font-weight: 600;
}

.paginator a:hover,
.paginator a:focus-visible {
  background: var(--md-accent-soft);
  color: var(--md-accent-strong);
  box-shadow: inset 0 0 0 1px var(--md-accent);
}

.paginator .this-page {
  background: var(--md-accent);
  color: var(--primary-fg);
  font-weight: 700;
}

/* The same room before "59 Agenda" whichever number comes last: django
   spaces only the last page's link, not the last page when it is the one
   you are on. */
.paginator a.end,
.paginator .this-page:not(:has(~ a:not(.showall))) {
  margin-right: 8px;
}

/* "Mostra tutti" stays a link, not a page. */
.paginator a.showall,
.paginator a.showall:hover,
.paginator a.showall:focus-visible {
  min-width: 0;
  padding: 0;
  background: none;
  box-shadow: none;
  color: var(--link-fg);
}

/* --- Date hierarchy ("‹ Tutte le date | Luglio 2026 | ...") ------------- */

/* Django gives #toolbar a 15px bottom margin, which made sense when the
   search box was its own free-standing block. Inside the results card it
   is just a gap between the search row and the date links, on top of this
   nav's own padding. */
#changelist #toolbar {
  margin-bottom: 0;
}

/* The magnifier before the search box (2.6.0). Django sets it inline on
   the text's baseline, which left it a pixel or two low of the box beside
   it, and with 10px of toolbar before it and the label's own margin and a
   space after it, off-centre in the strip between the card's edge and the
   box. One flex line instead: everything on the box's middle, and the
   same 6px either side of the glyph, so it sits in the middle of its gap
   and the box starts a little further left. Below 1024px responsive.css
   already lays this row out the same way (with its own gaps). Its side
   padding is the cards' gutter (see "Card gutters" at the foot). */

#changelist #toolbar #changelist-search > div {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 10px;
}

#changelist #toolbar #changelist-search label[for="searchbar"] {
  display: flex;
  flex: 0 0 auto;
}

#changelist #toolbar #changelist-search label[for="searchbar"] img {
  display: block;
  margin: 0;
}

/* Cerca and Vai (2.9.0): very light blue and very light green, so the
   list's two plain buttons are told apart at a glance - one searches, one
   runs the action on the ticked rows. Same selectors as django's own
   (changelists.css), which this file loads after. */
#changelist #toolbar form input[type="submit"] {
  background: var(--bm-search-btn-bg);
  border: 1px solid var(--bm-search-btn-border);
  color: var(--bm-search-btn-fg);
  box-shadow: none;
}

#changelist #toolbar form input[type="submit"]:hover,
#changelist #toolbar form input[type="submit"]:focus-visible {
  background: var(--bm-search-btn-hover-bg);
}

#changelist .actions .button {
  background: var(--bm-go-btn-bg);
  border: 1px solid var(--bm-go-btn-border);
  color: var(--bm-go-btn-fg);
  box-shadow: none;
}

#changelist .actions .button:hover,
#changelist .actions .button:focus-visible {
  background: var(--bm-go-btn-hover-bg);
  border-color: var(--bm-go-btn-border);
}

/* "Azione" (2.13.0): django gives this menu no room on the right, so a
   chosen "Cancella impianti selezionati" ran under the arrow and was cut
   off; and when clicked, a dark grey border of django's own. Room for
   the arrow as on every other menu (the menu grows to fit its longest
   choice), and the app's focus: the theme's colour with its soft ring. */
#changelist .actions select {
  padding: 0 34px 0 8px;
  border-radius: 6px;
}

#changelist .actions select:focus {
  border-color: var(--md-accent);
}

#changelist .toplinks {
  padding: 11px 16px;
  gap: 6px 18px;
  align-items: center;
}

/* The guillemet is part of the link text, so without this it sits flush
   against the card edge with a single thin space after it. */
#changelist .toplinks .date-back {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 600;
}

/* --- Filter panel ------------------------------------------------------- */

/* "Mostra i conteggi" and "Cancella tutti i filtri" at the top of the
   panel (2.13.0, templates/admin/change_list.html): each an icon in a
   box of the same width, then its words - so the two texts start on one
   line - the icon centred on the words' line. Line drawings in the link's
   own colour, which follow the theme and the palette. */
#changelist-filter #changelist-filter-extra-actions h3 {
  margin: 0;
}

#changelist-filter .filter-extra {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 2px 0;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
}

#changelist-filter .filter-extra-icon {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Each icon in a colour of its own (2.13.0, the owner's call): the eye of
   "Mostra/Nascondi i conteggi" light blue, the funnel of "Cancella tutti i
   filtri" dark yellow; the words stay the link's. */
#changelist-filter .filter-extra-counts .filter-extra-icon {
  stroke: var(--bm-filter-counts-icon);
}

#changelist-filter .filter-extra-clear .filter-extra-icon {
  stroke: var(--bm-filter-clear-icon);
}

#changelist-filter .filter-extra:hover span,
#changelist-filter .filter-extra:focus-visible span {
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- The drawn "+" ------------------------------------------------------
   See templates/admin/clinic/_plus.html for why it is drawn rather than
   typed. Here, in brand.css, because every page in the app loads this one
   file and add controls are on most of them.

   1em square by default and sized down where it sits inside a round
   button - the rules for those are with the buttons themselves, in
   admin_overrides.css and on the client page. */
.icon-plus {
  display: inline-block;
  width: 1em;
  height: 1em;
  /* Never squashed by a flex parent, whatever else is in the button. */
  flex: 0 0 auto;
  vertical-align: -0.125em;
}

/* --- The theme switch's three icons --------------------------------------
   Auto, light and dark, drawn here instead of django's.

   Django's are a half-filled disc, a sun whose rays are eight separate
   rectangles pinned round a ring, and a moon cut from a square - all
   drawn at 24px and all reading as slightly wrong at the 1.5rem they are
   shown at: the sun's rays touch its body, the moon's crescent is
   thicker on one horn than the other.

   Replaced through the mask property rather than by overriding django's
   <symbol> definitions: those live at the foot of base.html, referenced
   by id, and the first element with an id wins - so a second copy cannot
   take their place without copying the whole template. Masking the <svg>
   box and hiding the <use> inside it needs no template at all.

   background-color: currentColor, so all three take the header's own
   colour and follow the theme - which is the thing a background-image
   could not do.

   Since 2.15.0 that is auto and dark. The sun is drawn in the page
   itself - the switch's own template is copied after all, a dozen
   lines - because it is the one of the three whose parts move apart,
   and a mask's parts cannot (see "Light", below). */

.theme-toggle svg use {
  display: none;
}

/* The switch itself (2.13.1, the owner's call: more polished): a round
   34px target with the icon drawn at 20px in the middle, line drawings of
   one weight (1.8 on a 24 grid) - a disc half filled inside its rim for
   automatico, a sun with eight short rays clear of its body, a crescent -
   and a soft wash of the bar's own text colour under the pointer, a ring
   on the keyboard. */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  /* As tall as django's 24px icon was on the bar's line, so the bar keeps
     its height. */
  margin-top: -5px;
  margin-bottom: -5px;
  transition: background-color 0.15s ease;
}

.theme-toggle:hover {
  background-color: color-mix(in srgb, var(--header-link-color, #ffffff) 14%, transparent);
}

.theme-toggle:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--header-link-color, #ffffff) 75%, transparent);
  outline-offset: 1px;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Alive under the pointer (2.14.0, the owner's call, as the gear after
   it): automatico's half disc turns over, the crescent rocks back, and
   the sun does not turn - it shines: its rays reach out from the disc,
   which draws in a little, as if giving off light (the rays move out
   from the middle, the disc shrinks) - and each settles when the
   pointer leaves. Only where there is a pointer to hover with; still
   where less motion is asked for. */
@media (hover: hover) {
  .theme-toggle:hover svg.theme-icon-when-auto {
    transform: rotate(180deg);
  }

  .theme-toggle:hover .theme-sun-rays {
    transform: scale(1.14);
  }

  .theme-toggle:hover .theme-sun-core {
    transform: scale(0.88);
  }

  .theme-toggle:hover svg.theme-icon-when-dark {
    transform: rotate(-22deg) scale(1.1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle svg {
    transition: none;
  }

  .theme-toggle .theme-sun-rays,
  .theme-toggle .theme-sun-core {
    transition: none;
  }

  .theme-toggle:hover svg.theme-icon-when-auto,
  .theme-toggle:hover svg.theme-icon-when-dark,
  .theme-toggle:hover .theme-sun-rays,
  .theme-toggle:hover .theme-sun-core {
    transform: none;
  }
}

/* NOT currentColor, which is what the first attempt at this used and why
   the switch went blank: django sets `color: var(--header-bg)` on these
   three, because its own symbols carry a backing shape that has to match
   the bar. currentColor there is the bar's own colour, so the icon was
   painted in the colour behind it.

   --header-link-color is the colour django means the icon to be, and it
   is already right in both themes and on a phone.

   Django's own three-selector rule sets fill and color on exactly these
   three classes; matching it selector for selector keeps the weights
   even, and this file loads after dark_mode.css. Django's display
   rules - one icon shown, two hidden, by [data-theme] - are untouched. */
.theme-toggle svg.theme-icon-when-auto,
.theme-toggle svg.theme-icon-when-dark {
  background-color: var(--header-link-color, #ffffff);
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
}

/* Auto: a ring with one half of the disc inside it filled - django's own
   idea, the half set in from the rim so it does not read as a bite. */
.theme-toggle svg.theme-icon-when-auto {
  -webkit-mask-image: var(--icon-theme-auto);
  mask-image: var(--icon-theme-auto);
}

/* Light: a ring with eight short rounded rays, set clear of it - drawn in
   the page (admin/color_theme_toggle.html), not masked like the other two
   (2.15.0, the owner's report: under the pointer it "animated weirdly").

   It was two mask layers, and shining was done by resizing them: the
   rays' layer to 118% of a 20px box, the disc's to 90%. A mask cannot
   paint outside its element, so the four upright rays grew into the edge
   of the box and were cut off flat while the four slanted ones kept
   their round ends; every line got 18% thicker as it grew, the disc's
   10% thinner; and a mask redrawn at a new size on every frame shimmers.

   Now the disc and the rays are shapes of their own. Under the pointer
   the rays move out from the middle and the disc draws in, as before -
   the sun still does not turn - but by transform, which is smooth, and
   with lines that keep their weight (non-scaling-stroke: 1.5px, the
   other two icons' 1.8 on a 24 grid at 20px). The box lets the rays'
   round ends pass its edge. A little spring in the timing: the rays go a
   touch too far and settle.

   The colour is the one the other two take, written as a stroke; django
   also sets "fill" on all three, which here would fill the disc. */
.theme-toggle svg.theme-icon-when-light {
  overflow: visible;
  fill: none;
  stroke: var(--header-link-color, #ffffff);
  stroke-width: 1.5px;
  stroke-linecap: round;
}

.theme-toggle .theme-sun-rays,
.theme-toggle .theme-sun-core {
  vector-effect: non-scaling-stroke;
  transform-origin: 12px 12px;
  transition: transform 0.38s cubic-bezier(0.3, 1.45, 0.5, 1);
}

/* Dark: the outline of one crescent, both horns coming to a point. */
.theme-toggle svg.theme-icon-when-dark {
  -webkit-mask-image: var(--icon-theme-dark);
  mask-image: var(--icon-theme-dark);
}

/* Impostazioni, after the theme switch (2.14.0, the owner's call; until
   then a pill at the foot of the menu): the same round 34px target and
   the same line weight as the switch's icons, the gear in the bar's own
   colour. No circle at rest, as the phone's gear; under the pointer the
   switch's soft wash, and the gear turns a little. On a phone it is not
   in the bar - the menu's corner has it (mobile-nav.css). */
#user-tools a.topbar-gear,
#user-tools a.topbar-gear:link,
#user-tools a.topbar-gear:visited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin: -5px 0 -5px 4px;
  border: none;
  border-radius: 50%;
  vertical-align: middle;
  color: var(--header-link-color, #ffffff);
  text-decoration: none;
  transition: background-color 0.15s ease;
}

#user-tools a.topbar-gear:hover,
#user-tools a.topbar-gear:focus-visible {
  background-color: color-mix(in srgb, var(--header-link-color, #ffffff) 14%, transparent);
  color: var(--header-link-color, #ffffff);
  border: none;
  text-decoration: none;
}

#user-tools a.topbar-gear:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--header-link-color, #ffffff) 75%, transparent);
  outline-offset: 1px;
}

#user-tools a.topbar-gear:hover:active {
  background-color: color-mix(in srgb, var(--header-link-color, #ffffff) 22%, transparent);
}

.topbar-gear .icon-gear {
  width: 20px;
  height: 20px;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.topbar-gear:hover .icon-gear,
.topbar-gear:focus-visible .icon-gear {
  transform: rotate(60deg);
}

@media (prefers-reduced-motion: reduce) {
  .topbar-gear .icon-gear {
    transition: none;
  }

  .topbar-gear:hover .icon-gear,
  .topbar-gear:focus-visible .icon-gear {
    transform: none;
  }
}

/* --- Segmented switch ---------------------------------------------------
   Two mutually exclusive views of the same thing, shown as one control
   rather than as two separate buttons: the teeth picker's Permanenti /
   Decidui, the odontogramma's.

   The shape is .agenda-switch's (agenda.css), which is this same control
   built out of links because its options are real URLs. These options are
   not - they change what is on screen without leaving the page - so they
   are real radio inputs. Radios rather than javascript-toggled buttons
   because the behaviour this control is supposed to have is a radio
   group's: arrow keys move between the options and the whole group is one
   tab stop, both for free.

   The input is moved out of sight rather than hidden, because
   display:none would take it out of the tab order with it.

   Every size and spacing below is written out rather than inherited.
   These labels sit inside admin forms, where ".aligned label" gives every
   label a fixed 160px column - which is right for a field's name and
   wrong for a segment of a switch. Hence the selectors carrying the
   element name: they have to outrank that rule wherever this control is
   used. */
.seg-switch {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background: var(--md-surface);
}

.seg-switch label.seg-switch-option {
  position: relative;
  display: flex;
  float: none;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-weight: 600;
}

.seg-switch label.seg-switch-option + label.seg-switch-option {
  border-left: 1px solid var(--border-color);
}

.seg-switch label.seg-switch-option > input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
}

.seg-switch label.seg-switch-option > span {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  font-size: 0.8rem;
  line-height: 1.2;
  white-space: nowrap;
  color: var(--body-fg);
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.seg-switch label.seg-switch-option > span:hover {
  background: var(--darkened-bg);
}

.seg-switch label.seg-switch-option > input:checked + span {
  background: var(--button-bg);
  color: var(--button-fg);
}

.seg-switch label.seg-switch-option > input:focus-visible + span {
  outline: 2px solid var(--md-accent);
  outline-offset: -2px;
}

@media (prefers-reduced-motion: reduce) {
  .seg-switch label.seg-switch-option > span { transition: none; }
}

/* --- Pills to pick several (2.12.0, clinic.widgets.PillCheckboxSelectMultiple)
   "Interessato a" on a trattativa: each option a pill, the same shape as
   the stages and reasons of "Chiudi con esito", lit in the theme's colour
   while picked. The checkbox is still there for the keyboard and screen
   readers, out of sight. Labels inside are written with the .form-row
   to outweigh django's ".aligned label" (a 160px column). */
.bm-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 2px 0;
}

.form-row .bm-pills label.bm-pill,
.bm-pills label.bm-pill {
  position: relative;
  display: inline-flex;
  float: none;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  font-weight: 400;
}

.bm-pill > input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  clip-path: inset(50%);
  overflow: hidden;
}

.bm-pill > span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  box-sizing: border-box;
  padding: 7px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--md-pill, 999px);
  background: var(--md-surface);
  color: var(--body-fg);
  font-size: 0.86rem;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s ease, background-color 0.12s ease, color 0.12s ease;
}

.bm-pill > span:hover {
  border-color: var(--md-accent);
}

.bm-pill > input:checked + span {
  border-color: var(--md-accent);
  background: var(--md-accent-soft);
  color: var(--md-accent-strong);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--md-accent);
}

.bm-pill > input:focus-visible + span {
  outline: 2px solid var(--md-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .bm-pill > span { transition: none; }
}

/* --- Rows you type into -------------------------------------------------

   The tables of an edit page where rows are added and filled in - the
   prestazioni and pagamenti of a fattura, the lines of a preventivo, an
   installation's pratiche - are forms, not lists to read across: every
   row is on the same plain surface. Django stripes them like a table of
   data, which made one line of the form look different from the next for
   no reason. The frame around them stays grey - the section's title, the
   column headings and the "+ Aggiungi" row - so the start and the end of
   the section are still plain to see.

   Only these tables. The lists (Fatture, Agenda...) keep their stripes:
   there they help the eye follow a row across a wide page. */
.inline-group .tabular tbody tr.form-row,
.inline-group .tabular tbody tr.row-form-errors {
  background: var(--body-bg);
}

.inline-group .tabular tbody tr.add-row {
  background: var(--darkened-bg);
}

/* --- Buttons ------------------------------------------------------------ */

.button,
a.button,
input[type="submit"],
input[type="button"],
button,
.submit-row input,
.submit-row a,
.object-tools a {
  /* Before anything else: stop the browser drawing its own button.

     iOS gives every <button> a native bezel - a pale rounded rectangle -
     and paints it UNDER whatever css puts on top, so the green Salva
     arrived with a white plate around it that stayed until the first
     repaint. It only showed there because that is the app's first real
     <button>; everything else is an <a> or an <input type=submit>, which
     ios leaves alone. */
  appearance: none;
  -webkit-appearance: none;
  border: none;
  border-radius: var(--md-pill);
  padding: 9px 20px;
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease,
    transform 0.06s ease, filter 0.15s ease;
}

.button:active,
input[type="submit"]:active,
button:active,
.object-tools a:active {
  transform: translateY(1px);
}

/* The one primary action on a page gets a little more presence - the
   colour is django's own default-button variable, not a colour of ours. */
.submit-row input[type="submit"].default,
.submit-row input[name="_save"],
#login-form .submit-row input[type="submit"] {
  padding: 11px 30px;
  box-shadow: var(--md-shadow-sm);
}

/* Written against :link/:visited on purpose. Django styles these buttons
   with ".object-tools a:link, .object-tools a:visited", which outranks a
   plain ".object-tools a" - so the sizing below was being ignored
   entirely and the buttons kept django's cramped 3px/12px box. */
.object-tools a:link,
.object-tools a:visited {
  /* Sized to sit in the same family as Salva and the other real buttons -
     django's own box here is 3px/12px at 11px type, which next to a 9px/
     20px submit button reads as a link someone made rectangular. Still a
     step below the submit row, since this one lives up in the heading. */
  display: inline-flex;
  align-items: center;
  float: none;
  padding: 8px 18px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: none;
  border-radius: var(--md-pill);
  box-shadow: var(--md-shadow-sm);
}

.object-tools a:link:hover,
.object-tools a:visited:hover {
  box-shadow: var(--md-shadow-lg);
}

/* --- Buttons that are links: pressed only while the pointer is on them

   Two things kept a button looking pressed or hovered after the pointer
   had left it (2.8.1):

   - :focus. A click focuses a link, and the hover look was also given to
     :focus, so the button stayed lit until something else was clicked.
     Those rules now use :focus-visible, which only a keyboard sets.
   - :active, which holds while the mouse button is down wherever the
     pointer has gone. The pressed look is now :hover:active - pressed AND
     under the pointer - so sliding off a button while holding it lets it
     go back to rest, the way a real button does, and releasing there does
     nothing.

   And a link can be dragged: pressing one and moving starts dragging its
   address, and while that ghost is dragged the button stays lit. These
   are buttons, not links to carry somewhere. */
.object-tools a,
a.agenda-add,
a.agenda-arrow,
a.agenda-today,
.crm-toolbar-actions a.crm-add,
.patient-title-row a.patient-edit-btn,
.col-header-bar a.add-btn,
a.dash-head-add,
a.dash-action,
a.convert-pill,
a.convert-done,
a.section-add-btn {
  -webkit-user-drag: none;
  user-select: none;
}

/* django gives each item a fixed 1rem height, sized for its own 19px
   button; anything taller hangs out of the bottom of the li and the row
   stops lining up with the heading beside it. */
.object-tools li {
  height: auto;
  display: flex;
  align-items: center;
}

/* Django lifts this row by -48px, measured against its own 19px button.
   Ours is 31px, so the number has to be re-derived rather than nudged:
   the value below is the one that puts the middle of the buttons on the
   middle of the <h1> beside them. Kept in px, not rem, because the
   heading's own box grows with the root size at a different rate than
   the button's does - a rem value lands right at 16px and drifts by 4px
   on a 4K desktop, where a fixed one stays inside a pixel or two. */
.object-tools {
  margin-top: -50px;
}

/* ...and no margin under it on a form (2.12.0). Django's lists keep the
   0.8em every list has; on a form the row floats at the right of the
   title, and the first card under it is a box that steps aside from a
   float's margin as well as from the float. Impostazioni has no second
   title line, so from 1920px wide - where that 0.8em grows with the type -
   the margin reached its first card, which came out narrower than the
   cards below it. */
.change-form .object-tools {
  margin-bottom: 0;
}

/* And should the row ever reach down that far again (a bigger type, a
   second line of buttons), the form starts under it rather than letting
   its first card step aside. */
.change-form #content-main > form {
  clear: right;
}

/* A list's title and its buttons (2.10.0, admin/change_list.html): one
   row that wraps, instead of django's float pulled up beside the title -
   which drew the buttons over any title too long to share the line with
   them ("Movimenti di magazzino", the Agenda's four buttons). The title
   is measured by its longest word when the line decides what fits, then
   takes the room the buttons leave it, wrapping if it must; buttons that
   still do not fit go to the line under it, on the right. */
.cl-titlebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  margin-bottom: 20px;
}

#content .cl-titlebar h1 {
  flex: 1 1 0;
  margin: 0;
}

.cl-titlebar .object-tools {
  float: none;
  flex: 0 1 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px 10px;
  margin: 0 0 0 auto;
  padding: 0;
  overflow: visible;
}

.cl-titlebar .object-tools li,
.cl-titlebar .object-tools li + li {
  float: none;
  margin: 0;
}

/* An empty bar (no button for this account) takes no room. */
.cl-titlebar .object-tools:not(:has(li)) {
  display: none;
}

/* On a phone (2.13.0, the owner's layout): the secondary buttons - Vista
   calendario, Vista pipeline, Solo i miei - right after the title, and the
   buttons that create something at the right of the line, or at the right
   of the line under it when they do not fit beside the title. The bar's
   box steps aside so that each button is a piece of the title's row. */
@media (max-width: 767px) {
  .cl-titlebar {
    gap: 10px 8px;
    margin-bottom: 16px;
  }

  #content .cl-titlebar h1 {
    flex: 0 1 auto;
    margin-right: 4px;
  }

  .cl-titlebar .object-tools {
    display: contents;
  }

  .cl-titlebar .object-tools > li:has(> .objtool-secondary) {
    margin-left: 0;
  }

  .cl-titlebar .object-tools > li:has(> a:not(.objtool-secondary)) {
    margin-left: auto;
  }

  .cl-titlebar .object-tools > li:has(> a:not(.objtool-secondary)) ~ li:has(> a:not(.objtool-secondary)) {
    margin-left: 0;
  }
}

/* The add / view-site glyphs are background images pinned to the right
   edge, so the right padding has to clear them by hand. 18 to the edge
   matches the padding on the left, 13 is the glyph, 8 is the gap after
   the label - so the label and the glyph read as one group centred in the
   pill, rather than text shoved left of a floating symbol. */
.object-tools a.viewsitelink:link,
.object-tools a.viewsitelink:visited {
  padding-right: 39px;
  background-position: right 18px center;
  background-size: 13px 13px;
}

/* The filled action pills' colours, through the --bm-action-* tokens
   (see their note at the top of this file): django's own colours unless a
   business type restates them. The outline is an inset shadow, so a pill
   with one is exactly the size of a pill without; under the pointer it
   takes the fill colour and disappears into it. Not the outlined
   secondary tools beside them (.objtool-secondary), which keep theirs,
   nor Storia. The fallbacks are the default-button pair, which is what
   admin_overrides.css has always given these pills (see the note there). */
.object-tools a:not(.objtool-secondary):not(.historylink):link,
.object-tools a:not(.objtool-secondary):not(.historylink):visited {
  background-color: var(--bm-action-bg, var(--default-button-bg));
  color: var(--bm-action-fg, var(--button-fg));
  box-shadow: inset 0 0 0 1px var(--bm-action-border, transparent), var(--md-shadow-sm);
  font-weight: var(--bm-action-weight, 600);
}

.object-tools a:not(.objtool-secondary):not(.historylink):hover,
.object-tools a:not(.objtool-secondary):not(.historylink):focus-visible {
  background-color: var(--bm-action-hover-bg, var(--default-button-hover-bg));
  color: var(--bm-action-hover-fg, var(--button-fg));
  box-shadow: inset 0 0 0 1px var(--bm-action-hover-border, var(--bm-action-hover-bg, transparent)), var(--bm-action-hover-glow, var(--md-shadow-lg));
}

.object-tools a:not(.objtool-secondary):not(.historylink):hover:active,
.object-tools a:not(.objtool-secondary):not(.historylink):link:hover:active,
.object-tools a:not(.objtool-secondary):not(.historylink):visited:hover:active {
  background-color: var(--bm-action-active-bg, var(--bm-action-hover-bg, var(--default-button-hover-bg)));
  color: var(--bm-action-active-fg, var(--bm-action-hover-fg, var(--button-fg)));
  box-shadow: inset 0 0 0 1px var(--bm-action-active-border, var(--bm-action-active-bg, var(--bm-action-hover-border, var(--bm-action-hover-bg, transparent)))), var(--bm-action-active-glow, var(--md-shadow-sm));
}

/* The "Aggiungi ..." pill's + is drawn the way the other Aggiungi links'
   is (see "The + Aggiungi links" below): its own small box after the
   words, on their x-height middle, rather than a background centred on
   the pill - which is centred on the line box, and in Segoe UI the
   letters do not sit in the middle of their line box, so the + rode off
   the words. Same size and the same 8px gap and 18px end padding as
   before, so the pill is exactly as wide as it was.

   The pill stays a flex line (so a template's stray spaces around the
   label never widen the gap), lined up on the text's baseline: the
   glyph's box then stands on that baseline, and the transform lifts its
   middle to half an x-height above it - what vertical-align: middle does
   on an ordinary line - plus the same small nudge towards the capitals.
   A transform moves nothing else, so the pill's height is the text's. */
.object-tools a.addlink:link,
.object-tools a.addlink:visited {
  align-items: baseline;
  padding-right: 18px;
  background-image: none;
}

.object-tools a.addlink::after {
  content: "";
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  /* The negative top margin keeps the glyph, standing on the baseline,
     from making the line taller than the words: a 13px box reaches
     higher above the baseline than these letters do. */
  margin: -6px 0 0 8px;
  transform: translateY(calc(6.5px - 0.5ex - 0.06em));
  /* Painted in the text's own colour through django's glyph as a mask,
     so it follows the pill: white on a filled one, grey on an outlined
     one, white again under the pointer. Since 2.14.0 it turns a quarter
     under the pointer ("The buttons that add something", below). */
  background-color: currentColor;
  -webkit-mask: url("../admin/img/tooltag-add.e59d620a9742.svg") center / contain no-repeat;
  mask: url("../admin/img/tooltag-add.e59d620a9742.svg") center / contain no-repeat;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* A secondary tool: a different way to look at the same records, as
   opposed to the filled pill next to it that creates a new one. Outlined
   and squarer, matching "Vista elenco" on the calendar's toolbar - the two
   directions of the same switch, so they read as the same control.
   Written against :link/:visited because django's own rule for these is,
   and that outranks a plain class. */
.object-tools a.objtool-secondary:link,
.object-tools a.objtool-secondary:visited {
  background: var(--bm-secondary-bg, transparent);
  background-image: none;
  color: var(--bm-secondary-fg, var(--bm-btn-link));
  border: 1px solid var(--bm-secondary-border, var(--bm-btn-border));
  border-radius: 8px;
  /* The outline close round the words (2.14.0, the owner's call): a
     smaller button than the one beside it that adds something, as it is
     the less important of the two. Same line, centred on it. */
  padding: 5px 12px;
  box-shadow: none;
  font-weight: var(--bm-secondary-weight, 600);
}

.object-tools a.objtool-secondary:link:hover,
.object-tools a.objtool-secondary:visited:hover {
  box-shadow: none;
  border-color: var(--bm-secondary-hover-border, var(--bm-btn-accent));
}

.object-tools a.objtool-secondary:focus-visible,
.object-tools a.objtool-secondary:hover {
  background: var(--bm-secondary-hover-bg, var(--bm-btn-hover-bg));
  color: var(--bm-secondary-hover-fg, var(--bm-btn-link));
}

/* A secondary tool that is a switch - the Agenda's "Solo i miei" (2.10.0)
   - while it is on: underlined and edged in the accent, as on the
   calendar (agenda.css, a.agenda-mine). */
.object-tools a.objtool-toggle.is-on:link,
.object-tools a.objtool-toggle.is-on:visited {
  border-color: var(--bm-secondary-hover-border, var(--bm-btn-accent));
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.object-tools a:focus-visible,
.button:focus-visible,
input[type="submit"]:focus-visible,
button:focus-visible {
  outline: 3px solid var(--md-focus-ring);
  outline-offset: 2px;
}

/* --- The buttons that add something (2.14.0, the owner's call) ----------
   "Aggiungi ..." at the top of a list, Evento and Appuntamento on the
   Agenda, Nuova trattativa on the Pipeline: one way of moving,
   everywhere. Still the pill, and still the plain + after the words (a
   rounded rectangle and a + in a disc for a moment: the owner's call, the
   pill and the plain +). Under the pointer the button rises a pixel, its
   shadow deepens and the + turns a quarter; pressed, it settles back
   down. The colours stay the --bm-action-* tokens (solar: pale orange, a
   softer orange edge, a soft orange shadow). */
.object-tools a:not(.objtool-secondary):not(.historylink),
a.agenda-add,
.crm-toolbar-actions .button.crm-add {
  transition: background-color 0.16s ease, color 0.16s ease, box-shadow 0.2s ease,
    transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.object-tools a:not(.objtool-secondary):not(.historylink):hover,
a.agenda-add:hover,
.crm-toolbar-actions .button.crm-add:hover {
  transform: translateY(-1px);
}

.object-tools a:not(.objtool-secondary):not(.historylink):hover:active,
a.agenda-add:hover:active,
.crm-toolbar-actions .button.crm-add:hover:active {
  transform: translateY(0);
}

.object-tools a.addlink:hover::after,
.object-tools a.addlink:focus-visible::after {
  transform: translateY(calc(6.5px - 0.5ex - 0.06em)) rotate(90deg);
}

/* The + in the Agenda's and the Pipeline's buttons is the drawn one
   (_plus.html): the same quarter turn. */
a.agenda-add .icon-plus,
.crm-toolbar-actions .button.crm-add .icon-plus {
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

a.agenda-add:hover .icon-plus,
a.agenda-add:focus-visible .icon-plus,
.crm-toolbar-actions .button.crm-add:hover .icon-plus,
.crm-toolbar-actions .button.crm-add:focus-visible .icon-plus {
  transform: rotate(90deg);
}

@media (prefers-reduced-motion: reduce) {
  .object-tools a:not(.objtool-secondary):not(.historylink),
  a.agenda-add,
  .crm-toolbar-actions .button.crm-add,
  .object-tools a.addlink::after,
  a.agenda-add .icon-plus,
  .crm-toolbar-actions .button.crm-add .icon-plus {
    transition: none;
  }

  .object-tools a:not(.objtool-secondary):not(.historylink):hover,
  a.agenda-add:hover,
  .crm-toolbar-actions .button.crm-add:hover {
    transform: none;
  }
}

/* --- "Crea fattura" in the Preventivi list's Converti column (2.9.0) -----

   A small pill per row: an outline in the link colour, filled with the
   accent's wash under the pointer - or a business type's add-button
   colours, which it is one of (solar: hollow orange, --bm-action-*). */
a.convert-pill,
a.convert-pill:link,
a.convert-pill:visited {
  display: inline-flex;
  align-items: center;
  /* The padding given back above and below, so the word sits on the row's
     line like the text in the cells beside it, and the row is no taller. */
  margin: -4px 0;
  padding: 4px 12px;
  border-radius: var(--md-pill);
  background: var(--bm-action-bg, transparent);
  color: var(--bm-action-fg, var(--bm-btn-link));
  box-shadow: inset 0 0 0 1px var(--bm-action-border, var(--bm-btn-link));
  font-size: 0.74rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.12s ease, box-shadow 0.12s ease;
}

a.convert-pill:hover,
a.convert-pill:focus-visible {
  background: var(--bm-action-hover-bg, var(--bm-btn-accent-soft));
  color: var(--bm-action-hover-fg, var(--bm-btn-link));
  box-shadow: inset 0 0 0 1px var(--bm-action-hover-border, var(--bm-btn-link)), var(--bm-action-hover-glow, 0 0 0 transparent);
  text-decoration: none;
}

a.convert-pill:hover:active {
  background: var(--bm-action-active-bg, var(--bm-btn-accent-soft));
  color: var(--bm-action-active-fg, var(--bm-btn-link));
  box-shadow: inset 0 0 0 1px var(--bm-action-active-border, var(--bm-btn-link)), var(--bm-action-active-glow, 0 0 0 transparent);
}

/* Once a fattura has been made from the preventivo: a green tick after the
   pill, opening that fattura. */
.convert-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

a.convert-done,
a.convert-done:link,
a.convert-done:visited {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: -4px 0;
  border-radius: 50%;
  background: var(--bm-done-bg);
  color: var(--bm-done-fg);
  text-decoration: none;
}

a.convert-done:hover,
a.convert-done:focus-visible {
  box-shadow: inset 0 0 0 1.5px var(--bm-done-fg);
}

.convert-done-icon {
  width: 15px;
  height: 15px;
}

/* --- Required fields (2.9.0) -------------------------------------------

   What has to be filled in before a document can be saved says so before
   anyone presses Salva: its name in red, ending with an asterisk. Django
   already marks these - label.required on a form, th.required over a
   column of a table of lines - so every form in the app follows, the
   business types' and the modules' included, with nothing to keep in
   step. Only for what the form itself requires: a box that may be left
   empty stays as it was. */
.form-row label.required,
fieldset label.required,
.inline-group thead th.required {
  color: var(--error-fg);
}

.form-row label.required::after,
fieldset label.required::after,
.inline-group thead th.required::after {
  content: "*";
  display: inline;
  max-height: none;
  margin-left: 0.2em;
  vertical-align: baseline;
}

/* Over a column the asterisk takes no room of its own - it hangs into the
   cell's padding - so a heading that fitted on one line before still does,
   instead of dropping its help icon and the asterisk onto a second line
   (and a heading kept on one line by force widened the table). */
.inline-group thead th.required::after {
  margin-right: -0.75em;
}

/* --- Form fields -------------------------------------------------------- */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="tel"],
input[type="date"],
input[type="time"],
textarea,
.vTextField {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 11px;
  background: var(--md-surface);
  color: var(--body-fg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Selects get the same box as the inputs beside them - but only inside a
   form. Django pins every select to a fixed 1.875rem (30px) height, and
   with this file's field padding that left about 12px of content box for
   13px text, slicing the label off top and bottom; so here the height has
   to give rather than the padding.

   Scoped to forms deliberately. The changelist's own "Azione" select is
   already sized by django's changelist CSS (24px, its own padding), so it
   never had the clipping problem - and releasing its height made that
   whole actions bar 11px taller for nothing. */
.form-row select,
.aligned select {
  height: auto;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--md-surface);
  color: var(--body-fg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* Every other select keeps django's compact sizing; only the corner is
   rounded to match the rest of the controls. */
select {
  border-radius: 6px;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
textarea:focus,
select:focus,
.vTextField:focus {
  border-color: var(--md-accent);
  box-shadow: 0 0 0 3px var(--md-focus-ring);
  outline: none;
}

/* --- A section's note (2.14.0, the owner's call) ------------------------
   The words under a section's title that say what it is for - "Le parti
   del gestionale che questa persona usa..." over an account's Sezioni,
   "Solo per un cliente che è un'azienda..." over a client's Dati di
   fatturazione. Django sets them 12px from the card's edge and lets them
   run the card's whole width: on a big screen one line of 200
   characters. A reading width instead (about 70 letters a line), the
   card's gutter from its edge like the fields under it, air above and
   below, and lines spaced for reading. */
fieldset.module > div.description {
  box-sizing: content-box;
  max-width: 64ch;
  margin: 0;
  padding: 14px var(--bm-gutter) 6px;
  line-height: 1.6;
  text-wrap: pretty;
}

/* --- Notes boxes -------------------------------------------------------
   A "Note" box is as wide as the boxes above it, so the column of fields
   ends on one straight edge. Django sizes a textarea by its 40 columns
   (319px), which ran past the 284px text boxes on the client form and
   stopped short of the 416px record pickers on the installation and the
   activity.

   The widest box on the form sets the width:
   - a form of text boxes: 20em, the width django gives .vTextField. The
     textarea shares the text boxes' font, padding and border (the rule at
     the top of this section, and django's own under 1024px), so the same
     20em is the same outer edge at every size;
   - a form with a record picker (Cliente, Preventivo...): 26rem, the
     picker's own width (fk-search.css). Before fk-search.js has run the
     picker is still django's select.admin-autocomplete, so that counts too.

   Two lines tall by default (rows=2 on every notes widget). It can still
   be dragged taller, but not wider: the straight edge is the point.

   Only a stacked form's own rows - not a table of lines, not a box in a
   row of several. Nothing to add for a phone: django enlarges the font
   there and 20em grows with the text boxes it matches, while max-width
   keeps a picker-wide box inside a narrow card. */
.aligned .form-row > div > .flex-container:not(.fieldBox) > textarea {
  width: 20em;
  max-width: 100%;
  resize: vertical;
}

form:has(.aligned .form-row .fk-search, .aligned .form-row select.admin-autocomplete)
  .aligned .form-row > div > .flex-container:not(.fieldBox) > textarea {
  box-sizing: border-box;
  width: 26rem;
}

/* --- Messages ----------------------------------------------------------- */

ul.messagelist li {
  border-radius: var(--md-radius);
  border: 1px solid var(--hairline-color);
  font-size: 0.82rem;
  padding: 12px 16px 12px 42px;
}

/* The tick (or the warning sign) in the room the padding above leaves for
   it. Django draws it 40px in, for its own 65px of padding - so here it
   sat on the first letter of every message ("Esito salvato" read
   "Ésito"). Each kind restates its background, so each is named. */
ul.messagelist li,
ul.messagelist li.success,
ul.messagelist li.info,
ul.messagelist li.warning,
ul.messagelist li.error {
  background-position: 16px 50%;
}

/* --- Login --------------------------------------------------------------

   One white card on the top bar's own colours (2.14.0, the owner's call:
   a more professional page; 2.13.1 had the colours across the card's
   head). The colours fill the whole page, top to bottom (a band across
   its top for a moment, then the whole page, the owner's call: no white
   under it), so on a phone they are also what shows behind the status
   bar.

   In the card (templates/admin/login.html): "Login" in the page's own ink
   with the theme switch at its right and a line under it; the two boxes,
   their labels without django's colon and asterisk; Accedi in the green
   every Salva is (#2F855A - fixed in both themes, as Salva's is), a
   rounded rectangle with a soft shadow of its own green; and across the
   card's foot a strip with "Powered by Viscaling", as much room under
   the words as over them. */

/* flow-root: the card's top margin stays inside the page instead of
   pushing the whole page, band and all, down from the top. */
body.login {
  position: relative;
  display: flow-root;
  min-height: 100vh;
  min-height: 100dvh;
}

/* The page: the bar's colour and its patches, still, from the top of the
   page to its foot - "bottom: 0" on a page at least as tall as the
   window. */
body.login {
  background-color: var(--header-bg);
}

body.login::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: var(--header-bg);
  background-image: var(--header-image, none);
  background-size: var(--bm-login-mesh-size, var(--bm-header-mesh-size, auto));
  background-position: var(--bm-header-mesh-pos-0, 0 0);
  background-repeat: no-repeat;
  pointer-events: none;
}

.login #container {
  position: relative;
  /* The card's own colour and its own height - django's login.css gives
     it these on the login page; the page after signing out
     (registration/logged_out.html, the same card since 2.14.0) does not
     load that file, and django's #container is as tall as the page. */
  background: var(--body-bg);
  height: auto;
  border: 1px solid var(--hairline-color);
  border-radius: var(--md-radius-lg);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 24px 48px -16px rgba(16, 24, 40, 0.28);
  overflow: hidden;
  width: 25rem;
  min-width: 0;
  max-width: calc(100vw - 32px);
  /* A little above the middle of the window, where the eye goes first. */
  margin: clamp(48px, calc(50vh - 240px), 160px) auto 40px;
}

@media (max-width: 767px) {
  .login #container {
    margin-top: 48px;
  }
}

/* The card's head: no colours of its own, no light under the mouse.
   "#container" in this one and the content's: django's small-screen rules
   (responsive.css, linked after this file) set both paddings on a phone. */
.login #container #header {
  display: flex;
  flex-direction: row;
  padding: 28px 28px 0 32px;
  border-radius: 0;
  text-align: left;
  background: transparent;
  background-image: none;
  animation: none;
  color: var(--body-fg);
}

.login #header::before,
.login #header::after {
  display: none;
}

.login #branding {
  display: flex;
  flex: 1 1 auto;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.login #site-name {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--body-fg);
}

.login #header .theme-toggle {
  flex: 0 0 auto;
  margin: -4px 0;
}

.login .theme-toggle:hover {
  background-color: color-mix(in srgb, var(--body-fg) 8%, transparent);
}

.login .theme-toggle:focus-visible {
  outline: 2px solid var(--body-quiet-color);
  outline-offset: 1px;
}

.login .theme-toggle svg.theme-icon-when-auto,
.login .theme-toggle svg.theme-icon-when-dark {
  background-color: var(--body-quiet-color);
}

/* The sun is drawn, not masked: the same colour, as its line. */
.login .theme-toggle svg.theme-icon-when-light {
  stroke: var(--body-quiet-color);
}

.login #container #content {
  padding: 6px 32px 28px;
}

/* Not floated, as django has it on a phone, and no empty line of django's
   under it: the card ends where Accedi does, plus the padding. */
.login #content-main {
  float: none;
}

.login #content br.clear {
  display: none;
}

.login .login-lead {
  margin: 0 0 22px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--hairline-color);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--body-quiet-color);
}

@media (max-width: 767px) {
  .login #container #header {
    padding: 24px 18px 0 22px;
  }

  .login #container #content {
    padding: 6px 22px 24px;
  }
}

.login .form-row {
  padding: 0;
  margin-bottom: 16px;
}

.login .form-row label {
  display: block;
  margin-bottom: 6px;
  line-height: 1.3;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--body-fg);
}

/* Both boxes are needed and nothing else is asked: the asterisk of a
   required field would only be noise here. */
.login .form-row label.required::after {
  content: none;
}

.login .form-row input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: 10px;
}

.login .submit-row {
  padding: 8px 0 0;
  margin: 0;
  text-align: center;
}

/* Django's login submit carries no .default class; it is the only
   action on the page, so it gets the app's green outright. The page after
   signing out has the same button, a link: "Accedi di nuovo" (2.14.0). */
.login a.bm-login-again,
.login a.bm-login-again:link,
.login a.bm-login-again:visited {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  text-decoration: none;
}

.login .submit-row input[type="submit"],
.login a.bm-login-again,
.login a.bm-login-again:link,
.login a.bm-login-again:visited {
  width: 100%;
  min-height: 46px;
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #33905F 0%, #2F855A 100%);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: none;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 8px 18px -10px rgba(47, 133, 90, 0.75);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.06s ease;
}

.login .submit-row input[type="submit"]:hover,
.login a.bm-login-again:hover {
  color: #ffffff;
  text-decoration: none;
  background: linear-gradient(180deg, #2C8556 0%, #276749 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14), 0 10px 22px -10px rgba(39, 103, 73, 0.85);
}

.login .submit-row input[type="submit"]:active,
.login a.bm-login-again:hover:active {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
}

.login .submit-row input[type="submit"]:focus-visible,
.login a.bm-login-again:focus-visible {
  outline: 3px solid rgba(47, 133, 90, 0.40);
  outline-offset: 2px;
}

/* The card's foot: django's footer, a strip of the page's grey across the
   card, the words in its middle - the same 14px over them and under. */
.login #footer {
  margin: 0;
  padding: 14px 24px;
  border-top: 1px solid var(--hairline-color);
  background: var(--darkened-bg);
}

.login .login-foot {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--body-quiet-color);
}

/* --- Regions that keep the classic colours (2.13.0) ---------------------

   The owner's call, with the Metodell palettes: the tables and lists keep
   their old greys - a list's whole card with its search bar and actions,
   its rows, stripes, lines and the quiet words in it, every table on a
   page (the lines of a fattura, the client page's, the home page's) and
   the Agenda's grid of days - and so do the client page's panels, the
   Pipeline's figures and the date picker. Inside each, the page's grey variables are put back to the
   --bm-classic-* tokens, which are those same variables in the core (so
   nothing moves on dental) and the old greys in a palette that changed
   them. Text and links keep the page's colours.

   The date picker also keeps its old accent and words: the buttons' own
   (--bm-btn-*), as it was drawn in the page's accent before. Its top bar
   is --bm-calendar-head-bg/-fg. */
#changelist,
#content table,
.agenda-grid,
.dashboard-col,
.crm-stats,
.calendarbox,
.clockbox {
  --darkened-bg: var(--bm-classic-bg);
  --md-surface-sunken: var(--bm-classic-sunken);
  --hairline-color: var(--bm-classic-hairline);
  --border-color: var(--bm-classic-border);
  --selected-bg: var(--bm-classic-selected-bg);
  --selected-row: var(--bm-classic-selected-row);
  --body-quiet-color: var(--bm-classic-quiet);
}

.calendarbox,
.clockbox {
  --body-fg: var(--bm-btn-fg);
  --link-fg: var(--bm-btn-link);
  --link-hover-color: var(--bm-btn-link-hover);
  --md-accent: var(--bm-btn-accent);
  --md-accent-strong: var(--bm-btn-accent-strong);
  --md-accent-soft: var(--bm-btn-accent-soft);
}

/* --- Sidebar ------------------------------------------------------------

   The sidebar is navigation, not content, so it is not a card. Giving it
   the card's border, radius and clipped overflow put a rounded corner on
   the section bar (which should read as full-bleed) and left a hairline
   of border showing to either side of it - the stray little lines around
   the section heading. */

#nav-sidebar .module {
  background: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
}

/* --- The menu's pages, as pills (2.13.0, the owner's call) ---------------

   Each page of the menu is a button of its own: a pill, inset from the
   panel's sides with a little air between one and the next, instead of a
   full-width row ruled off from its neighbours. Every one on the same
   colour - django stripes the rows like a table of data, but it is a
   menu, not rows to read across. The page being viewed is a filled pill
   (django's .current-model, which outranks this).

   The whole pill opens its page, not only the name: the name's link is
   stretched over the pill (its ::after, below), and "+ Aggiungi" is laid
   above that so it still opens the add form.

   Under the pointer it lifts: a tint of the accent, an edge and a soft
   shadow in it, and a nudge of 2px towards the page; pressed, it sinks -
   a touch smaller, the shadow drawn inside instead, and a business type's
   own press wash over it (--bm-sidebar-press, below). The colours are
   tokens (--bm-pill-*, at the top of this file), so a palette can restate
   them; dark mode reads the dark accent through their defaults. */
#nav-sidebar table tbody tr,
#nav-sidebar table > tr {
  position: relative;
  margin: 4px var(--pill-inset);
  border: 1px solid var(--bm-pill-border);
  border-radius: var(--md-pill);
  background-color: var(--bm-pill-bg);
  transition: background-color 0.18s ease, border-color 0.18s ease,
    box-shadow 0.18s ease, transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

#nav-sidebar table tbody tr:first-child,
#nav-sidebar table > tr:first-child {
  margin-top: 10px;
}

#nav-sidebar table tbody tr:last-child,
#nav-sidebar table > tr:last-child {
  margin-bottom: 12px;
}

#nav-sidebar table tbody tr:hover,
#nav-sidebar table > tr:hover {
  box-shadow: var(--bm-pill-hover-shadow);
  transform: translateX(2px);
}

/* The tint and the edge only on the pages not being viewed: the page
   being viewed keeps its own fill under the pointer, and only lifts. */
#nav-sidebar table tbody tr:not(.current-model):hover,
#nav-sidebar table > tr:not(.current-model):hover {
  background-color: var(--bm-pill-hover-bg);
  border-color: var(--bm-pill-hover-border);
}

#nav-sidebar table tbody tr:hover:active,
#nav-sidebar table > tr:hover:active {
  box-shadow: var(--bm-pill-press-shadow);
  transform: translateX(2px) scale(0.98);
  transition-duration: 0.06s;
}

/* A keyboard on the name: the ring round the whole pill, the way the
   pointer sees it, rather than round the word. */
#nav-sidebar table tr:has(th a:focus-visible) {
  box-shadow: 0 0 0 3px var(--md-focus-ring);
}

#nav-sidebar table th a:focus-visible {
  outline: none;
}

/* No underline on the name, pointed at, pressed or focused: the pill
   itself answers (django underlines a link under the pointer). */
#nav-sidebar table th a:hover,
#nav-sidebar table th a:focus,
#nav-sidebar table th a:active {
  text-decoration: none;
}

/* The name's link stretched over the whole pill... */
#nav-sidebar table th a::after {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: var(--md-pill);
}

/* ...and "+ Aggiungi" above it - only the link itself: the rest of its
   cell lets a click through to the pill, so no corner of it is dead. */
#nav-sidebar table td {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

#nav-sidebar table td a {
  pointer-events: auto;
}

/* The name takes the pointer's colour wherever on the pill the pointer
   is, not only over the word. */
#nav-sidebar table tr:hover th a:link,
#nav-sidebar table tr:hover th a:visited {
  color: var(--bm-pill-hover-fg);
}

@media (prefers-reduced-motion: reduce) {
  #nav-sidebar table tbody tr,
  #nav-sidebar table > tr {
    transition: none;
  }

  #nav-sidebar table tbody tr:hover,
  #nav-sidebar table > tr:hover,
  #nav-sidebar table tbody tr:hover:active,
  #nav-sidebar table > tr:hover:active {
    transform: none;
  }
}

/* The page being viewed: django's own --selected-row unless a business
   type sets a menu colour of its own (solar: a light grey, where django's
   is a cream that read as amber on an amber theme; a pale blue since
   2.13.0), edged like the others unless a palette edges it (--bm-pill-current-border:
   a step stronger in the Metodell palettes). The dark roots below
   outrank it. */
#nav-sidebar .current-model {
  background: var(--bm-sidebar-current-bg, var(--selected-row));
  border-color: var(--bm-pill-current-border);
}

/* In dark mode the page being viewed was told apart from its neighbours
   by a shade (#1d212b) only a step off the grey the rows now all share,
   which left it all but invisible. The dark theme's own accent wash
   instead - the same one its selected controls use - unless a palette
   gives the menu a dark colour of its own (--bm-sidebar-current-bg in its
   dark blocks: the Metodell palettes' orange, 2.13.1). Light mode keeps
   django's yellow. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) #nav-sidebar .current-model {
    background: var(--bm-sidebar-current-bg, var(--md-accent-soft));
  }
}

html[data-theme="dark"] #nav-sidebar .current-model {
  background: var(--bm-sidebar-current-bg, var(--md-accent-soft));
}

/* The handle that folds the navigation away.

   In LIGHT mode django gives it the same grey wash it gives a row of a
   table, so the one control whose whole job is to change the shape of
   the page answered no more loudly than a list row does. A pale blue
   instead - a tint rather than a fill, so it lights up without turning
   into a solid bar down the side of the page, and the chevron keeps its
   own link colour rather than being reversed out to white.

   In DARK mode django's own wash is already right: the page is nearly
   black and --darkened-bg is a visible lift off it. Any blue at all
   there reads as a second accent competing with the one blue the dark
   theme uses, so the two dark roots put it straight back.

   It fades rather than switching: this is a 23px target running the
   height of the page, and a hard change at that size reads as a flicker
   every time the pointer crosses it on the way somewhere else.

   Focus gets the same fill, so a keyboard gets the same answer as a
   mouse - on top of the focus ring, not instead of it.

   At rest it is tinted too (2.6.0): django left it the page's own white,
   so the strip was invisible until the pointer happened to cross it. A
   shade darker than what is round it - light blue on dental, a pale
   blue-grey in the Metodell palettes (--bm-toggle-bg) - says it is there; the hover colour above
   it is still the darker answer to the pointer. Light only, like the
   hover: the dark roots put django's own background back. */
.toggle-nav-sidebar {
  background-color: var(--bm-toggle-bg);
  transition: background-color 0.15s ease;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .toggle-nav-sidebar {
    background-color: var(--body-bg);
  }
}

html[data-theme="dark"] .toggle-nav-sidebar {
  background-color: var(--body-bg);
}

.toggle-nav-sidebar:hover,
.toggle-nav-sidebar:focus-visible {
  background-color: var(--bm-tint-hover);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .toggle-nav-sidebar:hover,
  html:not([data-theme="light"]) .toggle-nav-sidebar:focus-visible {
    background-color: var(--darkened-bg);
  }
}

html[data-theme="dark"] .toggle-nav-sidebar:hover,
html[data-theme="dark"] .toggle-nav-sidebar:focus-visible {
  background-color: var(--darkened-bg);
}

/* Pressed - the strip, or an entry of the menu: a wash of its own while
   the button is down (the Metodell palettes: a blue wash, deeper than
   the tint under the pointer; light amber on solar until 2.13.0). Laid over the background rather than replacing it
   (an inset shadow on the strip, an image on the row), so where it is
   unset - transparent - nothing changes at all, whatever each row's own
   background is. On the row rather than its cells, which are not all as
   tall as it. :active holds on a row while one of its links is pressed;
   :hover with it, so the wash goes when the pointer leaves (2.8.1).
   Light mode only: the token is set only there. */
.toggle-nav-sidebar:hover:active {
  box-shadow: inset 0 0 0 100vmax var(--bm-sidebar-press, transparent);
}

#nav-sidebar table tr:hover:active {
  background-image: linear-gradient(var(--bm-sidebar-press, transparent), var(--bm-sidebar-press, transparent));
}

@media (prefers-reduced-motion: reduce) {
  .toggle-nav-sidebar { transition: none; }
}

/* The width, and the two numbers that have to agree with it.

   Django writes 275px, -276px and -276px into this one rule and 299px
   into another (275 + the 23px collapse handle + 1px of border), all of
   them literal. The panel is only in the right place when all four
   agree, so all four are derived from --bm-sidebar-width - see the note
   on that token for why it is not a fixed number any more.

   The 1px is the sidebar's own right-hand border: it slides fully off
   the page rather than leaving a hairline down the left edge when it is
   collapsed.

   Also: django gives this `overflow: auto`, which means both axes, so a
   row a few pixels too wide put a scrollbar across the bottom of the
   navigation. The rows are made to fit (see the note on the label column
   below), so there should be nothing to scroll to sideways - this is the
   guarantee that a longer label added later cannot bring the bar back.
   It wraps instead. Vertical scrolling is untouched: a long list of
   models still scrolls, which is what the `auto` was there for. */
#nav-sidebar {
  flex: 0 0 var(--bm-sidebar-width);
  left: calc((var(--bm-sidebar-width) + 1px) * -1);
  margin-left: calc((var(--bm-sidebar-width) + 1px) * -1);
  overflow-x: hidden;
  overflow-y: auto;
  /* Scrolled to either end, the menu stops there instead of handing the
     wheel on to the page (2.9.0, with sidebar-scroll.js). */
  overscroll-behavior: contain;
  /* Its scrollbar on the left, the page's side away from the work (2.13.0,
     the owner's call): over on the right it sat on the pills' round ends
     and their "Aggiungi". A right-to-left box puts it there; everything
     in it is set back to left-to-right just below. */
  direction: rtl;
  /* No line down its right edge (2.14.0, the owner's call: a cleaner
     page) - the menu's pills and the page's cards are edge enough. The
     border itself stays, transparent, because the four numbers above
     count its 1px. */
  border-right-color: transparent;
}

#nav-sidebar > * {
  direction: ltr;
}

[dir="rtl"] #nav-sidebar {
  left: 0;
  margin-left: 0;
  right: calc((var(--bm-sidebar-width) + 1px) * -1);
  margin-right: calc((var(--bm-sidebar-width) + 1px) * -1);
}

/* What the page beside it gets. Django's 299px was 275 + its 23px «
   strip + 1px of border. The strip is gone (2.8.x: the menu icon in the
   header folds the sidebar instead), so the content gets everything but
   the sidebar and its 1px border - and, with the sidebar folded away,
   django's "100% - 23px" becomes the whole width. Get this wrong and the
   content either overlaps the navigation or leaves a band of empty page
   down its side. */
.main.shifted > #nav-sidebar + .content {
  max-width: calc(100% - var(--bm-sidebar-width) - 1px);
}

.main > #nav-sidebar + .content {
  max-width: 100%;
}

/* The strip itself: kept in the page, because django's script is bound
   to it and the menu icon passes its clicks on to it (mobile-nav.js), but
   never shown. Its colour rules above are kept for a business type that
   still refers to its tokens. */
#toggle-nav-sidebar {
  display: none;
}

/* ...except on a phone, where there is no sidebar to leave room for.

   Django hides it below 767px and hands the width back with a rule of
   its own - the same selector as the one above, with max-width: 100%.
   That rule is in nav_sidebar.css, which base.html links in <head>
   BEFORE brand.css: same selector, same weight, and this file is the
   one that loads last, so the rule above was quietly beating it at
   every width.

   The result on a phone was a page holding 100% - 234px: the content
   squeezed into half the screen with a band of empty page beside it,
   while the top bar - which is not inside .content - still ran the full
   width. It looked like the layout had collapsed rather than like a
   width being subtracted, which is why it read as "completely broken".

   Django's own two lines, restated here so the last word is the right
   one. They have to stay a copy of django's, not a variation on it. */
@media (max-width: 767px) {
  .main > #nav-sidebar + .content,
  .main.shifted > #nav-sidebar + .content {
    max-width: 100%;
  }
}

/* --- Switches (2.8.1) ---------------------------------------------------

   Impostazioni's yes/no settings (clinic.widgets.SwitchInput): a real
   checkbox, drawn as a track with a round knob that slides across when it
   is switched on. Off is a quiet grey; on is the theme's accent (teal on
   dental, orange on solar, blue in dark mode). The words stay where
   django puts a checkbox's, to its right, and clicking them switches it
   too. */
input[type="checkbox"].bm-switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  box-sizing: border-box;
  width: 44px;
  height: 24px;
  margin: 0 10px 0 0;
  padding: 0;
  border: none;
  border-radius: var(--md-pill);
  background: var(--bm-switch-off);
  vertical-align: middle;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

input[type="checkbox"].bm-switch::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--md-surface);
  box-shadow: 0 1px 3px var(--bm-switch-knob-shadow);
  transition: transform 0.2s ease;
}

input[type="checkbox"].bm-switch:checked {
  background: var(--md-accent);
}

input[type="checkbox"].bm-switch:checked::before {
  transform: translateX(20px);
}

input[type="checkbox"].bm-switch:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--md-focus-ring);
}

/* Its words on the switch's middle, not on its top edge, and the gap
   between them the switch's own margin rather than django's label
   padding on top of it - 12px on every screen (2.13.0): django's own
   phone rule took the margin off, and "Tutti" touched its switch. */
.checkbox-row:has(> input.bm-switch) {
  align-items: center;
}

.checkbox-row > input[type="checkbox"].bm-switch {
  margin: 0 12px 0 0;
}

.checkbox-row > input.bm-switch + label.vCheckboxLabel {
  padding: 0;
  cursor: pointer;
}

/* Dark: a lifted grey track, a white knob. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) input[type="checkbox"].bm-switch:not(:checked) {
    background: var(--button-hover-bg);
  }

  html:not([data-theme="light"]) input[type="checkbox"].bm-switch::before {
    background: var(--body-loud-color);
  }
}

html[data-theme="dark"] input[type="checkbox"].bm-switch:not(:checked) {
  background: var(--button-hover-bg);
}

html[data-theme="dark"] input[type="checkbox"].bm-switch::before {
  background: var(--body-loud-color);
}

@media (prefers-reduced-motion: reduce) {
  input[type="checkbox"].bm-switch,
  input[type="checkbox"].bm-switch::before {
    transition: none;
  }
}

/* --- Tick boxes (2.14.0, the owner's call) ------------------------------
   Every square tick box the browser used to draw - a yes/no field on a
   form (an account's Attivo and Amministratore, a prestazione's Attiva, a
   trattativa's interests, the anamnesi's questions), and the box that
   picks a row of a list for an action, with the one over the column that
   picks them all. Drawn by the app instead: 18px, rounded, a fine grey
   edge on the page's surface; under the pointer the edge takes the
   switches' colour (--button-bg: the orange on solar, as Settimana |
   Giorno and the Sezioni) with a soft ring of it; ticked, filled with it
   and a white tick that pops in. A keyboard gets the focus ring. Not the
   round ticks that record a fact (Stampata, Fatta: admin_overrides.css),
   nor the switches. The ones in a table of lines (Cancella) are drawn
   the same way in admin_overrides.css, which places them there. */
.checkbox-row > input[type="checkbox"]:not(.bm-switch):not(.round-tick),
#result_list td.action-checkbox > input[type="checkbox"],
#result_list th.action-checkbox-column input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  box-sizing: border-box;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 1.5px solid color-mix(in srgb, var(--body-quiet-color) 75%, transparent);
  border-radius: 5px;
  background: var(--md-surface) no-repeat center / 12px 12px;
  box-shadow: 0 1px 1px rgba(16, 24, 40, 0.05);
  vertical-align: middle;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.checkbox-row > input[type="checkbox"]:not(.bm-switch):not(.round-tick):hover:not(:disabled),
#result_list td.action-checkbox > input[type="checkbox"]:hover:not(:disabled),
#result_list th.action-checkbox-column input[type="checkbox"]:hover:not(:disabled) {
  border-color: var(--button-bg);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--button-bg) 16%, transparent);
}

.checkbox-row > input[type="checkbox"]:not(.bm-switch):not(.round-tick):checked,
#result_list td.action-checkbox > input[type="checkbox"]:checked,
#result_list th.action-checkbox-column input[type="checkbox"]:checked {
  border-color: var(--button-bg);
  background-color: var(--button-bg);
  background-image: var(--icon-tick);
  animation: bm-tick-in 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.checkbox-row > input[type="checkbox"]:not(.bm-switch):not(.round-tick):checked:hover:not(:disabled),
#result_list td.action-checkbox > input[type="checkbox"]:checked:hover:not(:disabled),
#result_list th.action-checkbox-column input[type="checkbox"]:checked:hover:not(:disabled) {
  background-color: color-mix(in srgb, var(--button-bg) 86%, #000000);
}

.checkbox-row > input[type="checkbox"]:not(.bm-switch):not(.round-tick):focus-visible,
#result_list td.action-checkbox > input[type="checkbox"]:focus-visible,
#result_list th.action-checkbox-column input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--md-accent);
  outline-offset: 2px;
}

.checkbox-row > input[type="checkbox"]:not(.bm-switch):not(.round-tick):disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@keyframes bm-tick-in {
  0% { transform: scale(0.82); }
  100% { transform: scale(1); }
}

/* The words beside a tick box on a form: on its middle, 10px after it,
   in the page's ink and bolder (the owner's call) - a yes/no setting's
   name, read before the box. Django's 1px / 5px nudges are taken off; the
   gap does the spacing. A question of the anamnesi, or a trattativa's
   interest, a touch lighter: there are many of them in a row. */
.checkbox-row:has(> input[type="checkbox"]:not(.bm-switch):not(.round-tick)) {
  align-items: center;
  gap: 10px;
}

.checkbox-row > input[type="checkbox"]:not(.bm-switch):not(.round-tick) + label.vCheckboxLabel {
  padding: 0;
  color: var(--body-fg);
  font-weight: 600;
  line-height: 1.35;
  cursor: pointer;
}

.fieldBox.checkbox-row > input[type="checkbox"]:not(.bm-switch):not(.round-tick) + label {
  font-weight: 500;
}

/* Its help under its words, not under the box: 18px of box and 10px of
   gap in. */
.aligned .checkbox-row:has(> input[type="checkbox"]:not(.bm-switch):not(.round-tick)) + div.help,
.aligned .checkbox-row:has(> input[type="checkbox"]:not(.bm-switch):not(.round-tick)) + p.help {
  padding-left: 28px;
}

@media (prefers-reduced-motion: reduce) {
  .checkbox-row > input[type="checkbox"]:not(.bm-switch):not(.round-tick),
  #result_list td.action-checkbox > input[type="checkbox"],
  #result_list th.action-checkbox-column input[type="checkbox"] {
    transition: none;
    animation: none;
  }
}

#nav-sidebar .module caption,
#nav-sidebar .current-app .section {
  border-radius: 0;
}

/* The section titles: django's header colours unless a business type
   gives the menu its own (solar, 2.8.1: grey bars, white names; 2.13.0:
   fading almost to white towards the right, after the longest name, so
   the white words stay on the colour; 2.14.0: fading all the way into the
   page, to transparent, in light and dark mode alike). The token may be a
   colour or a gradient. The title is a link, which django colours separately,
   so both are set. */
#nav-sidebar .module caption {
  background: var(--bm-sidebar-caption-bg, var(--header-bg));
  color: var(--bm-sidebar-caption-fg, var(--header-link-color));
}

#nav-sidebar .module caption a.section:link,
#nav-sidebar .module caption a.section:visited {
  color: var(--bm-sidebar-caption-fg, var(--header-link-color));
  /* Every section's name bold, not only the one of the page being viewed
     (2.13.0): django makes the "current app" bold, and a section that
     gathers pages of several apps (solar's Impianti fotovoltaici) was bold
     on some of its pages and not on others. */
  font-weight: 700;
}

/* Django gives the filter box width:100%, so it ran edge to edge against
   the sidebar's sides and sat right up under the breadcrumb bar. Inset on
   all four sides so it reads as a control inside the panel. */
#nav-sidebar #nav-filter {
  width: calc(100% - 24px);
  margin: 16px 12px 12px;
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 8px;
}

#nav-filter:focus {
  border-color: var(--md-accent);
  box-shadow: 0 0 0 3px var(--md-focus-ring);
}

/* The "Aggiungi" links down the sidebar. Two things were off:

   - django draws the + as a background image pinned to "0 1px", which
     aligns it to the top of the line box rather than to the text on it,
     so on a 16px line the glyph sat a couple of pixels high of the word
     next to it. inline-flex with a vertically centred background lines
     the two up whatever the row height, including the rows whose model
     name wraps onto two lines.
   - the links started at the cell's 8px padding, which left them adrift
     in the middle of the sidebar rather than lining up with anything.
     Ranged right against a proper gutter, they form a single edge. */
/* The rows themselves.

   Django forces both the sidebar table and the label cell to width:100%,
   which fights ordinary table-cell sizing, so the row is laid out as a
   flex line instead: the label gets a fixed width rather than shrinking to
   its content, which is what makes "+ Aggiungi" land at the same x on
   every row however long the label beside it is. 178px fits "Dati studio
   dentistico", the longest label, on one line with room left for the
   button - widen it here if a longer one is ever added.

   All of this belongs in THIS file, and only here. It used to live in
   admin_overrides.css, which is attached by ModelAdmin.Media and by two
   templates; where that file lands in <head> depends on which page you
   are on (django puts {{ media }} in extrastyle on a changelist, which is
   before this file, and in extrahead on a change form or the agenda
   calendar, which is after it). With a "#nav-sidebar table td" rule in
   both files - same selector, same specificity - the winner changed from
   page to page, and the "+ Aggiungi" buttons visibly jumped sideways when
   you opened the calendar. Keep every sidebar declaration here: brand.css
   is linked once, from base_site.html, on every page. */
#nav-sidebar table tbody tr,
#nav-sidebar table > tr {
  display: flex;
  align-items: center;
  /* The panel less the pill's margins (2.13.0; 100% when the rows ran
     edge to edge): auto fills what the margins leave. */
  width: auto;
}

/* 178px is what the label column WANTS, not what it insists on.

   It used to be `flex: 0 0 178px` - fixed - and django's sidebar is a
   fixed 275px with `overflow: auto` on it. 178 for the label, plus an
   "Aggiungi" link that is told never to wrap, plus the gutter, comes to
   within a few pixels of those 275; whether it fits at all came down to
   how wide the browser happened to draw that one word, which changes with
   the screen, the zoom and the windows scaling setting. When it did not
   fit, the sidebar grew a horizontal scrollbar across the bottom of the
   navigation - on some machines and not others.

   `0 1 178px` keeps the column at 178px whenever there is room, so the
   add links still form one edge down the panel, and lets it give way when
   there is not: the label wraps (it already has overflow-wrap) instead of
   pushing the row wider than the panel. min-width: 0 is what actually
   permits the shrink - a flex item will not go below its content's
   minimum width without it. */
#nav-sidebar table th {
  display: block;
  flex: 0 1 178px;
  min-width: 0;
  width: auto !important;
  /* 9px above and below since the rows became pills (2.13.0; 14px when
     they were full-width rows): a pill reads as one button at about the
     height of the app's other pills, a 46px one as a slab. */
  padding: 9px 6px 9px 13px;
  overflow-wrap: break-word;
  /* A word too long for the column is split where Italian splits it,
     with a hyphen, rather than at whichever letter reaches the edge. */
  hyphens: auto;
  box-sizing: border-box;
  /* Match the app-name header above these rows - django's own CSS already
     uppercases that .module caption, and these model-name rows did not get
     the same treatment. */
  text-transform: uppercase;
}

/* The cell shrinks to its content, so without the auto margin it sat
   immediately after the fixed-width label column, adrift in the middle of
   the panel rather than lined up with anything. margin-left:auto is what
   ranges it right in a flex row; text-align would do nothing here. 10px
   inside the pill's edge (2.13.0; 14px from the panel's when the rows were
   full width), so the words keep clear of the pill's round end. */
#nav-sidebar table td {
  display: block;
  flex: 0 0 auto;
  white-space: nowrap;
  margin-left: auto;
  padding-right: 10px;
  box-sizing: border-box;
}

#nav-sidebar table th a {
  display: block;
}

/* A page with no "+ Aggiungi" (Dashboard, Dati studio dentistico...)
   gives its name the whole pill, so it stays on one line now that the
   pills sit inside the panel's edges (2.13.0). */
#nav-sidebar table tbody tr:has(> td:empty) > th {
  flex-grow: 1;
}

/* ...and is exactly as tall as a page that has one (2.14.0, the owner's
   call: with Segoe UI on Windows the "+ Aggiungi" pills came out a few
   pixels taller than the others). What made them taller is the + itself:
   a small box set on the words' middle (vertical-align: middle, "The
   + Aggiungi links" below), which in that font reaches past the line the
   words alone would take. The empty cell gets the same box and a word of
   no width in the same font (a zero-width space), nothing to see, so its
   line - and the pill - comes out the same height in any font, as tall as
   the ones with "+ Aggiungi". */
#nav-sidebar table td:empty::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0.95em;
  vertical-align: middle;
  visibility: hidden;
}

#nav-sidebar table td:empty::after {
  content: "\200B";
  visibility: hidden;
}

/* Django's generic "td, th { border-bottom }" for data tables leaks onto
   these cells now that they are display:block, and rendered as short
   jagged part-width lines inside the pill. Cancelled: each pill draws its
   own edge (2.13.0; a rule under each row before). */
#nav-sidebar table th,
#nav-sidebar table td {
  border-bottom: none !important;
}

/* The model names. Django colours them as links; a business type can
   give them a colour of its own (--bm-sidebar-link-fg - solar's are dark
   orange since 2.8.1, under grey section titles; with the Metodell
   colours, solar's and generic's are orange in dark mode too). The section titles
   above them are captions, coloured by --bm-sidebar-caption-*. */
#nav-sidebar table th a,
#nav-sidebar table th a:link,
#nav-sidebar table th a:visited {
  color: var(--bm-sidebar-link-fg);
}

#nav-sidebar table th a:hover,
#nav-sidebar table th a:focus-visible {
  color: var(--bm-pill-hover-fg);
}

/* The same names on the home page ("Pannello di amministrazione") and on
   an app's index page, which list the menu again: the same colour as the
   menu. (.dashboard is django's class for those two pages.) */
.dashboard #content-main .module th[scope="row"] a:link,
.dashboard #content-main .module th[scope="row"] a:visited {
  color: var(--bm-sidebar-link-fg);
}

/* Under the pointer, the menu's own hover colour (the links' hover colour
   in the core; a darker orange where the names are orange). */
.dashboard #content-main .module th[scope="row"] a:hover,
.dashboard #content-main .module th[scope="row"] a:focus-visible {
  color: var(--bm-pill-hover-fg);
}

/* Their "Aggiungi" words, beside the green +, through --bm-addlink-fg:
   the link colour in the core, green on solar so word and sign match. */
#nav-sidebar a.addlink:link,
#nav-sidebar a.addlink:visited,
.dashboard #content-main .module a.addlink:link,
.dashboard #content-main .module a.addlink:visited {
  color: var(--bm-addlink-fg);
}

/* --- The "+ Aggiungi" links ---------------------------------------------

   Django draws the + as a background image pinned 1px from the top of the
   link, so where it lands against the word depends on the font: with this
   app's fonts it was close, with Segoe UI on Windows it rode visibly off
   the word's middle - in the menu, on the home page, and under every table
   of lines ("+ Aggiungi prestazione"). The menu's links had been centred on
   their line box instead, which is no better: a line box's middle is not
   where the letters are either.

   So the + is its own small box before the text, set with
   vertical-align: middle - which puts its centre half an x-height above
   the baseline, the middle of the lowercase letters, in whatever font the
   browser picked. Same green glyph, django's own file.

   The "Aggiungi ..." pill at the top right of a list carries its + after
   the words instead; its own rule, further up, draws it the same way. */
#nav-sidebar a.addlink,
#content-main .module a.addlink,
.inline-group .add-row a.addlink {
  padding-left: 0;
  background: none;
  white-space: nowrap;
}

/* "Aggiungi prestazione" under a table of lines keeps the colours it had
   in every palette (2.13.0): the buttons' own link colour, and their own
   hover colour under the pointer - django's link colours, which it took
   until then. The menu's and the home page's "Aggiungi" are
   --bm-addlink-fg (below). */
.inline-group .add-row a.addlink:link,
.inline-group .add-row a.addlink:visited {
  color: var(--bm-btn-link);
}

.inline-group .add-row a.addlink:hover,
.inline-group .add-row a.addlink:focus-visible {
  color: var(--bm-btn-link-hover);
}

#nav-sidebar a.addlink::before,
#content-main .module a.addlink::before,
.inline-group .add-row a.addlink::before {
  content: "";
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  margin-right: 0.4em;
  vertical-align: middle;
  /* vertical-align: middle centres on the x-height; a + belongs a hair
     higher, on the line through the middle of the capitals beside it. */
  position: relative;
  top: -0.06em;
  background: url("../admin/img/icon-addlink.073aeb1feda7.svg") center / contain no-repeat;
}

/* "+ Aggiungi" in the menu, and on the home page's list of the same
   pages, as a small button of its own (2.15.0, the owner's call: "more
   professional and polished", the same colours and the same room). The
   + is a disc in a pale tint of django's green with the sign drawn in
   it at the weight of the app's other icons - not django's file, whose
   sign is a solid block - and the word beside it in its own colour, as
   before. Under the pointer the chip takes a faint tint of the word's
   colour and the disc fills with the green, the sign turning white; the
   pill it sits on answers as it always did. The chip's padding is taken
   back out of the cell's, so the word ends where it ended. */
#nav-sidebar table td:has(> a.addlink) {
  padding-right: 4px;
}

#nav-sidebar a.addlink,
.dashboard #content-main .module a.addlink {
  --addlink-plus: #5FAF2A;
  display: inline-flex;
  align-items: center;
  gap: 0.42em;
  padding: 3px 7px 3px 3px;
  border-radius: var(--md-pill);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

#nav-sidebar a.addlink::before,
.dashboard #content-main .module a.addlink::before {
  width: 18px;
  height: 18px;
  margin: 0;
  top: 0;
  flex: none;
  border-radius: 50%;
  background: color-mix(in srgb, var(--addlink-plus) 16%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--addlink-plus) 30%, transparent);
  transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

#nav-sidebar a.addlink::after,
.dashboard #content-main .module a.addlink::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 50%;
  margin-top: -9px;
  background-color: var(--addlink-plus);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M9 5.2v7.6M5.2 9h7.6' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'/%3E%3C/svg%3E") center / 18px 18px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18'%3E%3Cpath d='M9 5.2v7.6M5.2 9h7.6' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'/%3E%3C/svg%3E") center / 18px 18px no-repeat;
  transition: background-color 0.16s ease;
  pointer-events: none;
}

#nav-sidebar a.addlink,
.dashboard #content-main .module a.addlink {
  position: relative;
}

#nav-sidebar a.addlink:hover,
#nav-sidebar a.addlink:focus-visible,
.dashboard #content-main .module a.addlink:hover,
.dashboard #content-main .module a.addlink:focus-visible {
  background-color: color-mix(in srgb, var(--bm-addlink-fg) 11%, transparent);
  text-decoration: none;
}

#nav-sidebar a.addlink:hover::before,
#nav-sidebar a.addlink:focus-visible::before,
.dashboard #content-main .module a.addlink:hover::before,
.dashboard #content-main .module a.addlink:focus-visible::before {
  background-color: var(--addlink-plus);
  box-shadow: 0 2px 6px -2px color-mix(in srgb, var(--addlink-plus) 70%, transparent);
}

#nav-sidebar a.addlink:hover::after,
#nav-sidebar a.addlink:focus-visible::after,
.dashboard #content-main .module a.addlink:hover::after,
.dashboard #content-main .module a.addlink:focus-visible::after {
  background-color: #FFFFFF;
}

#nav-sidebar a.addlink:active,
.dashboard #content-main .module a.addlink:active {
  background-color: color-mix(in srgb, var(--bm-addlink-fg) 18%, transparent);
}

#nav-sidebar a.addlink:focus-visible,
.dashboard #content-main .module a.addlink:focus-visible {
  outline: 2px solid var(--bm-addlink-fg);
  outline-offset: 1px;
}

@media (prefers-reduced-motion: reduce) {
  #nav-sidebar a.addlink,
  #nav-sidebar a.addlink::before,
  #nav-sidebar a.addlink::after,
  .dashboard #content-main .module a.addlink,
  .dashboard #content-main .module a.addlink::before,
  .dashboard #content-main .module a.addlink::after {
    transition: none;
  }
}

/* The client column on the lists (Agenda, Fatture, Acconti, Preventivi).
   It is a column the code adds, so it can carry the business type's word
   for a client ("Paziente") - and so Django no longer gives it the
   "nowrap" class it puts on a plain foreign-key column. Same effect here,
   so a name keeps to one line as it always did. */
.field-client {
  white-space: nowrap;
}

/* Salva follows the page down (save-float.js; 2.8.0, sticky since
   2.9.1). The script moves the button into this box, at the head of the
   page's content, and places it over its own spot on the title line
   (--save-dock-x and --save-dock-y, measurements, so no --bm- prefix and
   no value here). The box rides the top of the window by itself as the
   page scrolls - position: sticky, worked out by the browser in the same
   step as the scroll - and comes back to rest exactly where it started.
   It has no height, so it takes no room and no clicks; only the button
   in it does. Above the cards and their sticky table headings, below
   django's calendar and the pickers' lists, which open over it. Here
   rather than beside the button's own look in admin_overrides.css: this
   file is on every page, that one only on the forms whose admin lists
   it. */
.cf-savedock {
  position: sticky;
  top: var(--save-dock-top, 14px);
  z-index: 60;
  height: 0;
}

.cf-savedock button.objtool-save {
  position: absolute;
  top: var(--save-dock-y, 0px);
  left: var(--save-dock-x, 0px);
  margin: 0;
  white-space: nowrap;
}

/* A deeper shadow while it rides over the page, so it reads as above it. */
body.bm-save-floating .cf-savedock button.objtool-save {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22), 0 1px 3px rgba(0, 0, 0, 0.12);
}

/* --- Card gutters (2.12.0, the owner's call) ----------------------------
   Django puts a form's labels and boxes 10px from the left edge of their
   card, a section's title 8px, a table's first column and a list's search
   and actions bar about the same. On a wide screen, with most of the card
   empty on the right, that read as everything pressed against the left
   edge. One margin instead, --bm-gutter (20px, 16px on a phone), on both
   sides of everything that sits on a card's edge: the rows and titles of
   a form, the first and last column of its tables and their "+ Aggiungi"
   row, a list's search bar, actions bar, columns and count, and the home
   page's lists of sections. The
   Dashboard's and the client page's panels already had about as much and
   are left as they are.

   Django's phone layout takes a form row's side padding away entirely
   ("15px 0", in its responsive.css, which loads after this file): these
   selectors outweigh its plain .form-row, so the rows keep the gutter
   there too. */
@media (max-width: 767px) {
  :root {
    --bm-gutter: 16px;
  }
}

fieldset.module .form-row,
#content-main fieldset.module > h2,
#content-main .inline-group h2.inline-heading,
.change-form :not(.inline-related) fieldset.module.collapse summary,
#content-main .module > h2,
.practice-columns .module > h2 {
  padding-left: var(--bm-gutter);
  padding-right: var(--bm-gutter);
}

/* The home page's and an app's list of sections: each card's heading and
   the first and last link on each line. */
#content-main .module > table > caption {
  padding-left: var(--bm-gutter);
  padding-right: var(--bm-gutter);
}

#content-main .module > table > tbody > tr > :first-child {
  padding-left: var(--bm-gutter);
}

#content-main .module > table > tbody > tr > :last-child {
  padding-right: var(--bm-gutter);
}

/* A table of lines (Prestazioni, Pagamenti, Pratiche...). Its first cell
   is django's hidden "original" column, so the first one you see is the
   one after it. */
.inline-group .tabular th.original + th,
.inline-group .tabular td.original + td,
.inline-group .tabular tr.add-row td {
  padding-left: var(--bm-gutter);
}

/* ...and that hidden column itself has no width (2.15.0). The rule for a
   card's first cell, above, reached it too - it IS the row's first cell -
   so a table of lines started two gutters in from its card's edge, 20px
   further than its own section's title, and was 20px wider than it
   needed to be on a screen where every pixel of a fattura's line counts
   (admin_overrides.css, "The line fits the screen it is on"). */
#content-main .inline-group .tabular tr td.original,
#content-main .inline-group .tabular th.original {
  padding-left: 0;
}

/* The line's own summary over its boxes ("Otturazione (denti 16, 17) -
   €180.00", kept up to date by procedure_price_autofill.js): django sets
   it at 9px, 9px from the card's edge. Here it starts where the boxes
   under it start and can be read without leaning in. */
.inline-group .tabular td.original p {
  padding: 2px var(--bm-gutter);
  height: 1.35em;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.inline-group .tabular thead th:last-child,
.inline-group .tabular tbody td:last-child {
  padding-right: var(--bm-gutter);
}

/* A list: its search bar, its actions bar, its first and last column and
   the count at its foot start and end at the same margin. */
#changelist #toolbar,
#changelist .actions,
#changelist .paginator {
  padding-left: var(--bm-gutter);
  padding-right: var(--bm-gutter);
}

#changelist .results tbody td:first-child,
#changelist .results tbody th:first-child {
  padding-left: var(--bm-gutter);
}

#changelist .results tbody td:last-child,
#changelist .results tbody th:last-child {
  padding-right: var(--bm-gutter);
}

/* A heading cell has no padding of its own: django puts it on the link
   (or the span) inside, so the gutter goes there too. */
#changelist .results thead th:first-child .text > a,
#changelist .results thead th:first-child .text > span {
  padding-left: var(--bm-gutter);
}

#changelist .results thead th:last-child .text > a,
#changelist .results thead th:last-child .text > span {
  padding-right: var(--bm-gutter);
}

/* The tick column starts at the margin like the search icon above it,
   instead of centred in its narrow column a few pixels further in. */
#changelist .results thead th.action-checkbox-column,
#changelist .results tbody td.action-checkbox {
  text-align: left;
}

/* --- The arrow of a menu (2.12.0, the owner's call) ----------------------
   The browser draws a menu's arrow hard against its right edge, with less
   room than the words get on the left - on every menu in the app. Drawn
   here instead: the same small chevron, 12px in from the edge, and the
   words kept clear of it. A mid grey that reads on the light and the dark
   card alike. Lists with several rows (multiple, size) keep their own
   look. Two attribute tests in the selector so this outweighs the rules
   that set a menu's padding or background (".form-row select"...). */
select:not([multiple]):not([size]) {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238A8F98' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px 6px;
}

/* --- A menu, opened (2.13.0, the owner's call) ---------------------------
   Closed, a menu is the box above. Opened, the browser used to draw its
   own list - Windows' square, plain one with a bright blue bar across the
   choice under the mouse, nothing like the rest of the app. Where the
   browser lets a page draw that list (Chrome and Edge since 2025,
   "appearance: base-select") it is drawn here instead: a card like the
   app's own, a little apart from the box, rounded, with a soft shadow;
   the choices in the app's text, the one under the mouse in the theme's
   pale tint, the chosen one in the theme's colour with a tick at the
   end. The closed box is not meant to change: its border, background,
   padding and arrow all come from the rules above (the browser's own
   arrow, ::picker-icon, is hidden in favour of that one). Browsers that
   cannot (Safari, on the iPhone too) keep their own list, as before.
   Only a menu select-picker.js has measured and marked (bm-picker): see
   that file for why. */
@supports (appearance: base-select) {
  /* ":not([multiple])" only to outweigh the arrow's rule above, which
     sets "appearance: none". */
  select.bm-picker:not([multiple]),
  select.bm-picker:not([multiple])::picker(select) {
    appearance: base-select;
  }

  /* As wide as its longest choice, as the browser's own menu was
     (select-picker.js measures it) - not resizing to whichever choice is
     shown, base-select's own way. Capped by the window, not by "100%":
     inside a box that is itself as wide as its content a percentage
     counts as nothing, and the menu shrank back. */
  select.bm-picker:not([multiple]) {
    min-width: min(var(--select-w, 0px), 100vw - 48px);
    /* The words in the middle of the box, as the browser's own menu has
       them: drawn this way they sat a pixel high. */
    align-items: center;
  }

  select.bm-picker:not([multiple])::picker-icon {
    display: none;
  }

  select.bm-picker:not([multiple])::picker(select) {
    box-sizing: border-box;
    min-width: anchor-size(width);
    max-height: min(22rem, 70vh);
    margin: 4px 0;
    padding: 5px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--md-surface);
    color: var(--body-fg);
    box-shadow: var(--md-shadow-lg);
    font-family: var(--font-family-primary);
    font-size: 0.8125rem;
  }

  select.bm-picker:not([multiple]) option {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 0;
    padding: 8px 12px;
    border-radius: 6px;
    background: transparent;
    color: var(--body-fg);
    font-weight: 400;
    line-height: 1.35;
    white-space: nowrap;
    cursor: pointer;
  }

  /* "---------", django's "nothing chosen": quieter than a real choice. */
  select.bm-picker:not([multiple]) option[value=""] {
    color: var(--body-quiet-color);
  }

  select.bm-picker:not([multiple]) option:hover,
  select.bm-picker:not([multiple]) option:focus-visible {
    background: var(--md-accent-soft);
    color: var(--body-fg);
    outline: none;
  }

  select.bm-picker:not([multiple]) option:checked {
    color: var(--md-accent-strong);
    font-weight: 600;
  }

  select.bm-picker:not([multiple]) option:disabled {
    color: var(--body-quiet-color);
    opacity: 0.6;
    cursor: default;
  }

  /* The tick: after the words, at the right, in the theme's colour. */
  select.bm-picker:not([multiple]) option::checkmark {
    order: 1;
    margin-left: auto;
    padding-left: 12px;
    color: var(--md-accent);
    font-weight: 700;
  }

  select.bm-picker:not([multiple]) optgroup {
    padding: 4px 0;
    color: var(--body-quiet-color);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }

  select.bm-picker:not([multiple]) optgroup option {
    color: var(--body-fg);
    font-size: 0.8125rem;
    font-weight: 400;
    letter-spacing: 0;
    text-transform: none;
  }
}

/* --- A field's name, a touch bolder (2.12.0, the owner's call) -----------
   "Valore stimato", "Assegnata a", "Chiusura prevista"... and the column
   headings of a table of lines: semibold instead of regular. 600 because
   the app's font on Windows (Segoe UI) has no 500 - a 500 is drawn as a
   plain 400. Required ones stay bold and red; the words beside a tick
   stay regular (they are a question, not a heading). */
.form-row .flex-container:not(.checkbox-row) > label:not(.required),
.inline-group thead th:not(.required) {
  font-weight: 600;
}

/* --- The date picker (2.13.0, the owner's call) --------------------------
   Django's calendar under "Oggi | calendar", and the clock under "Adesso |
   clock", redrawn as one of the app's cards: a little bigger, rounded,
   a honey top bar (--bm-calendar-head-*, django's is a lemon yellow), the
   arrows as two round buttons with a drawn chevron, the days as round
   buttons on a plain card - the chosen one filled with the theme's colour,
   today ringed in it, the empty days before and after the month left
   blank rather than grey. Ieri / Oggi / Domani as three small pills,
   "Annulla" a quiet bar at the foot.

   The month and year at the top can be pressed (calendar-plus.js): they
   show the year's months, then twelve years, laid out as the same round
   buttons three to a row. A small chevron after them says so.

   ".calendarbox" in front of django's own selectors so these outweigh
   widgets.css, which some pages link after this file. On a phone django
   centres the card over a dark veil (its responsive.css); that is kept,
   a little lighter. */
.calendarbox,
.clockbox {
  width: 20.5rem;
  max-width: calc(100vw - 24px);
  box-sizing: border-box;
  margin: 6px auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--md-surface);
  color: var(--body-fg);
  box-shadow: var(--md-shadow-lg);
  font-size: 0.8125rem;
}

.clockbox {
  width: 13rem;
}

/* The top bar: the arrows sit in it, over the caption. */
.calendarbox .calendar caption,
.calendarbox .calendar-grid caption,
.clockbox h2 {
  box-sizing: border-box;
  height: 48px;
  margin: 0;
  padding: 0 52px;
  border: 0;
  background: var(--bm-calendar-head-bg);
  color: var(--bm-calendar-head-fg);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 48px;
  text-align: center;
  text-transform: uppercase;
}

.clockbox h2 {
  padding: 0 16px;
}

/* Pressable: a chevron after the words, and a pointer. */
.calendarbox .calendar caption {
  cursor: pointer;
  user-select: none;
}

.calendarbox .calendar caption::after {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  vertical-align: 3px;
  transform: rotate(45deg);
  opacity: 0.7;
}

/* Twelve years: nothing above them. */
.calendarbox .calendar-years caption {
  cursor: default;
}

.calendarbox .calendar-years caption::after {
  display: none;
}

.calendarbox .calendarnav-previous,
.calendarbox .calendarnav-next {
  position: absolute;
  top: 9px;
  z-index: 3;
  display: block;
  width: 30px;
  height: 30px;
  padding: 0;
  overflow: hidden;
  border-radius: 50%;
  background: transparent;
  color: var(--bm-calendar-head-fg);
  text-indent: -9999px;
  transition: background-color 0.12s ease;
}

.calendarbox .calendarnav-previous {
  left: 10px;
}

.calendarbox .calendarnav-next {
  right: 10px;
}

.calendarbox .calendarnav-previous::before,
.calendarbox .calendarnav-next::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translate(-30%, -50%) rotate(45deg);
}

.calendarbox .calendarnav-next::before {
  transform: translate(-70%, -50%) rotate(-135deg);
}

.calendarbox .calendarnav-previous:hover,
.calendarbox .calendarnav-next:hover,
.calendarbox .calendarnav-previous:focus-visible,
.calendarbox .calendarnav-next:focus-visible {
  /* A shade of the bar's own words, so it suits the light bar and the
     dark one alike. */
  background: color-mix(in srgb, currentColor 14%, transparent);
  outline: none;
}

.calendarbox .calendar table,
.calendarbox .calendar-grid {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 2px;
  background: transparent;
}

/* No stripes: django shades every other row of every table. */
.calendarbox .calendar tr,
.calendarbox .calendar tr:nth-child(odd),
.calendarbox .calendar tr:nth-child(even) {
  background: transparent;
}

/* The days of the week: small, quiet, no band of their own. */
.calendarbox .calendar th {
  padding: 10px 0 4px;
  border: 0;
  background: transparent;
  color: var(--body-quiet-color);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.calendarbox .calendar td {
  padding: 0;
  border: 0;
  background: transparent;
  text-align: center;
}

.calendarbox .calendar td.nonday {
  background: transparent;
}

.calendarbox .calendar td a {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 38px;
  height: 38px;
  margin: 0 auto;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--body-fg);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.calendarbox .calendar td a:hover,
.calendarbox .calendar td a:focus-visible {
  background: var(--md-accent-soft);
  color: var(--body-fg);
  outline: none;
}

.calendarbox .calendar td.today a {
  box-shadow: inset 0 0 0 1.5px var(--md-accent);
  color: var(--md-accent-strong);
  font-weight: 700;
}

.calendarbox .calendar td.selected a,
.calendarbox .calendar td.selected a:hover {
  background: var(--md-accent);
  box-shadow: none;
  color: var(--primary-fg);
  font-weight: 700;
}

.calendarbox .calendar td a:active {
  background: var(--md-accent);
  color: var(--primary-fg);
}

/* Months and years: wider buttons, three to a row. */
.calendarbox .calendar-grid {
  border-spacing: 8px;
  padding: 4px 2px;
}

.calendarbox .calendar-grid td a {
  width: auto;
  height: 44px;
  border-radius: 22px;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: capitalize;
}

/* The month or year on the days' page, beside today's and the chosen one. */
.calendarbox .calendar-grid td.shown:not(.selected) a {
  background: var(--md-accent-soft);
}

/* Ieri | Oggi | Domani: three pills; the " | " between them hidden. */
.calendarbox .calendar-shortcuts {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--hairline-color);
  background: transparent;
  font-size: 0;
  line-height: 1;
}

.calendarbox .calendar-shortcuts a {
  margin: 0;
  padding: 6px 14px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  color: var(--body-fg);
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.calendarbox .calendar-shortcuts a:hover,
.calendarbox .calendar-shortcuts a:focus-visible {
  border-color: var(--md-accent);
  background: var(--md-accent-soft);
  color: var(--md-accent-strong);
  outline: none;
}

/* The clock's times: one per line, the one under the mouse tinted. */
.clockbox .timelist {
  padding: 6px;
}

.clockbox .timelist a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  background: transparent;
  color: var(--body-fg);
  font-size: 0.8125rem;
  text-decoration: none;
}

.clockbox .timelist a:hover,
.clockbox .timelist a:focus-visible {
  background: var(--md-accent-soft);
  color: var(--body-fg);
  outline: none;
}

.calendarbox .calendar-cancel,
.clockbox .calendar-cancel {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--hairline-color);
  background: transparent;
}

.calendarbox .calendar-cancel a,
.clockbox .calendar-cancel a {
  display: block;
  padding: 11px 0;
  color: var(--body-quiet-color);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
}

.calendarbox .calendar-cancel:hover,
.clockbox .calendar-cancel:hover,
.calendarbox .calendar-cancel a:focus-visible,
.clockbox .calendar-cancel a:focus-visible {
  background: var(--darkened-bg);
  outline: none;
}

.calendarbox .calendar-cancel:hover a,
.clockbox .calendar-cancel:hover a {
  color: var(--body-fg);
}

@media (max-width: 767px) {
  /* Django centres the card over its veil here, and the veil is part of
     the card (its ::before), so the card cannot clip what is inside it:
     the top bar and the foot are rounded instead. A touch bigger for a
     thumb. */
  .calendarbox,
  .clockbox {
    border: 0;
    border-radius: 16px;
  }

  /* "div." to outweigh django's 4px corners, in its responsive.css,
     which is linked after this file. */
  div.calendarbox .calendar,
  div.clockbox h2 {
    border-radius: 16px 16px 0 0;
    overflow: hidden;
  }

  div.calendarbox .calendar-cancel,
  div.clockbox .calendar-cancel {
    border-radius: 0 0 16px 16px;
    overflow: hidden;
  }

  /* Each part over the veil paints its own card colour: the card's own
     background lies under its veil. */
  .calendarbox .calendar,
  .calendarbox .calendar-shortcuts,
  .calendarbox .calendar-cancel,
  .clockbox .timelist,
  .clockbox .calendar-cancel {
    background-color: var(--md-surface);
  }

  .calendarbox .calendar td a {
    width: 40px;
    height: 40px;
  }

  .calendarbox .calendar-grid td a {
    width: auto;
    height: 46px;
    border-radius: 23px;
  }

  .calendarbox .calendar-shortcuts {
    padding: 12px;
  }

  .calendarbox .calendar-cancel a,
  .clockbox .calendar-cancel a {
    padding: 14px 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .calendarbox .calendar td a,
  .calendarbox .calendarnav-previous,
  .calendarbox .calendarnav-next { transition: none; }
}

/* ===========================================================================
   ONE SHAPE FOR THE SAME THING (2.15.0)
   ===========================================================================
   The review of the whole app measured every card, button and box on
   every page: the cards came in eight corner radii and the buttons in
   twenty-two shapes. Most of that is meant - a pill adds or saves, a
   rounded rectangle switches the view, a line in a table is compact - and
   is left exactly as it is, colours above all. What follows is only what
   was left over from django or from an earlier look, brought to the shape
   the rest of the page already has:

     a card            --md-radius (10px), a hairline, --md-shadow-sm
     a box you type in 34px tall, 8px corners
     a small button    as tall as the box beside it, 8px corners
     a pill            Salva, Storia, the buttons that add

   Nothing here names a colour: every one is the variable the component
   already used, so each business type keeps its own palette.
   =========================================================================== */

/* What a script marks hidden is not drawn. The browser's own rule for the
   word is the weakest there is: any "display" of the app's own outranks
   it, and the element is then only out of sight, still in the way and
   still reached by Tab (the phone's row sheet was: inline-sheet.css). */
[hidden] {
  display: none !important;
}

/* A form on its way to the server (submit-once.js): its button says so,
   and a second press does nothing. */
.is-sending,
.is-sending:hover {
  cursor: progress;
  opacity: 0.72;
}

/* The foot of a form - Storia and Cancella - is a card like the form's
   own sections above it (it had django's 4px corners under their 10). */
#content .submit-row {
  border-radius: var(--md-radius);
}

/* Cancella stays django's own block, with its 4px corners (the owner's
   call, the day this was written: it was made a pill like Storia beside
   it, and he had it put back). */

/* A list's search box, Cerca, the Azione menu and Vai: as tall as every
   other box in the app and with its corners. They were django's own -
   25px, 26px and 24px tall, 4px corners - under a Filtra of 34. Their
   colours are the ones 2.9.0 gave them. No width is asked here: on a
   small screen django's own minimum heights and responsive.css (both
   loaded after this file) still size them for a thumb. */
#changelist #toolbar form #searchbar {
  box-sizing: border-box;
  height: 34px;
  padding: 0 12px;
  border-radius: 8px;
}

#changelist #toolbar form input[type="submit"],
#changelist .actions .button {
  box-sizing: border-box;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.8rem;
}

#changelist .actions select {
  box-sizing: border-box;
  height: 34px;
  border-radius: 8px;
}

/* "Azione:", its menu, Vai and the count on one middle line: beside a
   taller menu the words sat on the text's baseline, a little high. */
#changelist .actions label,
#changelist .actions select,
#changelist .actions .button,
#changelist .actions span.action-counter,
#changelist .actions span.all,
#changelist .actions span.question,
#changelist .actions span.clear {
  vertical-align: middle;
}

/* The home page's "Azioni recenti": its title as every other card's on
   that page (it was django's, half as big again and spaced out). */
#content-related .module h2 {
  padding: 12px var(--bm-gutter) 10px;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

#content-related .module h3,
#content-related .module p,
#content-related .module .actionlist {
  padding-left: var(--bm-gutter);
  padding-right: var(--bm-gutter);
}

/* The page that asks before deleting: what will go with the record, on a
   card, and its two answers as the app's buttons - "Sì, sono sicuro" in
   the red Cancella has, "No, torna indietro" quiet beside it. */
.delete-confirmation #content > p,
.delete-confirmation #content > h2,
.delete-confirmation #content > ul {
  max-width: 60rem;
}

.delete-confirmation #content > ul {
  margin: 0 0 18px;
  padding: 14px var(--bm-gutter) 14px calc(var(--bm-gutter) + 18px);
  border: 1px solid var(--hairline-color);
  border-radius: var(--md-radius);
  background: var(--md-surface);
  box-shadow: var(--md-shadow-sm);
}

.delete-confirmation form input[type="submit"] {
  background: var(--delete-button-bg);
  color: var(--button-fg);
  padding: 10px 22px 9px;
}

.delete-confirmation form input[type="submit"]:hover,
.delete-confirmation form input[type="submit"]:focus-visible {
  background: var(--delete-button-hover-bg);
}

.delete-confirmation form .cancel-link,
.delete-confirmation form .cancel-link:link,
.delete-confirmation form .cancel-link:visited {
  display: inline-flex;
  align-items: center;
  height: auto;
  margin-left: 10px;
  padding: 10px 22px 9px;
  border-radius: var(--md-pill);
  background: transparent;
  color: var(--bm-btn-fg);
  box-shadow: inset 0 0 0 1px var(--bm-btn-border);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
}

.delete-confirmation form .cancel-link:hover,
.delete-confirmation form .cancel-link:focus-visible {
  background: var(--bm-btn-hover-bg);
  color: var(--bm-btn-fg);
}

