/* Theme colours (docs/contracts/ui/theme.md): the only place with fixed colours, besides the grid definitions. */
:root {
    --app-bg: #FFFFFF;
    --app-surface: #FFFFFF;
    --app-panel: #F7F9FB;
    --app-border: #E6E8EB;
    --app-input-border: #C9D3CB;
    --app-text: #1B1F1C;
    --app-muted: #59625B;
    --app-account-bg: #F5F6F3;
    --app-error-bg: #F6E1E1;
    --app-error-text: #7A2E2E;
    --app-positive: #2E7D32;
    --app-negative: #EF6C00;
    --app-accent: #D9A441;
    --app-warning: #F9A825;
    --app-warning-text: #8A5A00; /* warning as text: contrast 5.9:1 on white */
    color-scheme: light;
}

[data-theme="dark"] {
    --app-bg: #121417;
    --app-surface: #1B1E22;
    --app-panel: #22262B;
    --app-border: #2C3036;
    --app-input-border: #4A5059;
    --app-text: #E6E8EB;
    --app-muted: #A3AAB3;
    --app-account-bg: #121417;
    --app-error-bg: #3A2224;
    --app-error-text: #F2A7A7;
    --app-positive: #7BC88F;
    --app-negative: #F5A25D;
    --app-accent: #E3B562;
    --app-warning: #F5C451;
    --app-warning-text: #F5C451;
    color-scheme: dark;
}

html, body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--app-bg);
  color: var(--app-text);
}

/* Location bar at the top of the content. */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 16px;
  min-height: 56px;
  padding: 8px 16px;
  margin-bottom: 24px;
  background: var(--brand-tint);
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.page-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}

.page-header-icon.mud-icon-root {
  color: var(--brand-text);
  font-size: 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
}

.page-header-nav {
  min-width: 0;
}

.page-header-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 15px;
  line-height: 1.3;
}

.page-header-crumb {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.page-header-link,
.page-header-text {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  max-width: 28vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--app-muted);
  font-weight: 500;
  text-decoration: none;
}

.page-header-link:hover {
  color: var(--brand-dark);
  text-decoration: underline;
}

.page-header-sep {
  margin: 0 8px;
  color: var(--app-muted);
}

.page-header-h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--brand-dark);
  overflow-wrap: anywhere;
}

/* FocusOnNavigate (Routes.razor) focuses the page title after each navigation for screen readers:
   the title is not interactive, so it keeps the focus without the focus ring. */
h1:focus {
  outline: none;
}

.page-header-subtitle {
  font-size: 13px;
  color: var(--app-muted);
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

@media (min-width: 600px) {
  .page-header-link,
  .page-header-text {
    max-width: 240px;
    min-height: 0;
  }
}

@media (max-width: 599.95px) {
  /* Phone: keep only the section icon and the previous level; the middle levels stay reachable through the menu. */
  .page-header-crumb:not(:nth-last-child(-n+2)) {
    display: none;
  }
}

/* A Class="active" set on MudNavLink may land on its wrapper (.mud-nav-item): same look. */
.mud-nav-link.active:not(.mud-nav-link-disabled),
.mud-nav-item.active > .mud-nav-link:not(.mud-nav-link-disabled) {
  background: var(--brand-tint);
  box-shadow: inset 3px 0 0 var(--brand);
  color: var(--brand-dark);
  font-weight: 600;
}

.mud-nav-link.active:not(.mud-nav-link-disabled) .mud-nav-link-icon,
.mud-nav-item.active > .mud-nav-link:not(.mud-nav-link-disabled) .mud-nav-link-icon {
  color: var(--brand-text);
}

.app-content {
  max-width: 1600px;
  margin: 0 auto;
  padding: 28px 16px;
}

@media (min-width: 600px) {
  .app-content {
    padding: 28px 32px;
  }
}

.nav-section {
  padding: 16px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--app-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.role-select {
  min-width: 170px;
}

.article-thumb {
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.article-thumb--empty {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-tint);
    color: var(--brand-text);
}

/* User avatar (UserAvatar): round photo or initials; the initials colours come from the category palette. */
.user-avatar {
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    object-fit: cover;
    flex: none;
    font-weight: 600;
    line-height: 1;
    user-select: none;
    background: var(--app-panel);
    border: 1px solid var(--app-border);
    box-sizing: border-box;
}

.user-avatar--initials {
    border: none;
}

.article-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    cursor: pointer;
    min-width: 0;
}

.article-card > * {
    flex-shrink: 0;
}

/* The text column takes the free space and shrinks; its chips wrap. */
.article-card > .article-card-body {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.article-card-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.article-notes {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 360px;
}

.article-card-notes {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* Movement author (MovementTable.Author) and user name in the Users grid: avatar next to the name. */
.movement-author,
.user-name-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.movement-card-notes,
.movement-card-author {
    font-size: 0.75rem;
    line-height: 1.5;
}

.movement-card-author {
    margin-top: 2px;
    color: var(--app-muted);
}

.category-tag {
    display: inline-block;
    max-width: 100%;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    line-height: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
}

.color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

@media (max-width: 599px) {
    .color-swatch {
        width: 44px;
        height: 44px;
    }
}

.color-swatch--selected {
    outline: 2px solid var(--app-text);
    outline-offset: 2px;
}

.color-swatch:disabled {
    cursor: default;
    opacity: .6;
}

/* Row action icon buttons: touch area of at least 44px on phones. */
@media (max-width: 599.95px) {
    .mud-table .mud-icon-button,
    .mud-list .mud-icon-button,
    .checklist-row .mud-icon-button {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Panel for adding a new entry above a configuration list. */
.add-panel {
    padding: 16px;
    margin-bottom: 24px;
    background: var(--app-panel);
    border: 1px solid var(--app-border);
}

/* Side menu: white with a thin right border. */
.mud-drawer {
    background: var(--app-surface);
    border-right: 1px solid var(--app-border);
}

/* Tabs block: tinted header bar, active tab in brand color, bordered white card. */
.tabs-card.mud-tabs {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface);
    overflow: hidden;
}

.tabs-card .mud-tabs-tabbar {
    background: var(--brand-tint);
    border-bottom: 1px solid var(--app-border);
}

.tabs-card .mud-tab {
    font-weight: 500;
}

.tabs-card .mud-tab.mud-tab-active {
    color: var(--brand-text);
    font-weight: 600;
}

.tabs-card .mud-tab-slider {
    background-color: var(--brand);
}

.tabs-card .mud-tab-slider.mud-tab-slider-horizontal {
    height: 3px;
}

.tabs-card .mud-tabs-panels {
    background: var(--app-surface);
}

/* Collapsed side menu (icon-only rail). */
.nav-tip {
    display: block;
    width: 100%;
}

.nav-collapsed .mud-nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    position: relative;
}

.nav-collapsed .mud-nav-link .mud-nav-link-icon {
    margin-right: 0;
}

.nav-collapsed .mud-nav-link .mud-nav-link-text {
    display: none;
}

.nav-dot {
    position: absolute;
    top: 8px;
    left: calc(50% + 4px);
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--brand);
    border: 2px solid var(--app-surface);
    box-sizing: content-box;
}

.stock-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.stock-total {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.stock-total--big {
    font-size: 22px;
}

/* Expanded «Prestito» row of the article stock table (ArticleStockSection). */
.stock-loans-detail {
    background: var(--app-panel);
    border-top: 1px solid var(--app-border);
}

/* Nuovo movimento: on phones the main button stays visible at the bottom. */
@media (max-width: 959.95px) {
    .movement-actions {
        position: sticky;
        bottom: var(--bottom-nav-space);
        z-index: 2;
        margin: 0 -16px -16px;
        padding: 12px 16px;
        background: var(--app-surface);
        border-top: 1px solid var(--app-border);
    }

    .movement-actions .mud-button-root {
        min-height: 44px;
    }
}

/* Nuovo movimento: type segments always fully readable (2×2 on phones). */
.movement-types {
    width: 100%;
}

.movement-types .mud-toggle-item {
    min-height: 44px;
    padding: 6px 8px;
    text-transform: none;
}

.movement-types .mud-toggle-item .mud-button-label {
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.2;
    text-align: center;
}

@media (max-width: 599.95px) {
    /* MudToggleGroup sets the columns inline. */
    .movement-types {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .movement-types .mud-toggle-item {
        margin-left: 0 !important;
    }
}

/* Article movements panel (ArticleMovementsDrawer): the width is set on the drawer. */
.movements-drawer {
    display: flex;
    flex-direction: column;
}

/* Grids (docs/contracts/ui/grids.md): colours only from these variables (rule 8, future dark theme);
   fallbacks are allowed only here, in the definitions. */
:root {
    --grid-border: var(--mud-palette-lines-default, #E6E8EB);
    --grid-row-hover: var(--mud-palette-action-default-hover, rgba(0, 0, 0, .04));
    --grid-muted: var(--mud-palette-text-secondary, #59625B);
    --grid-text: var(--mud-palette-text-primary, #1B1F1C);
    --grid-surface: var(--mud-palette-surface, #FFFFFF);
    --grid-accent: var(--mud-palette-primary, #2A6FB0);
    /* Header and footer: a light shade of the association's primary colour (--brand, set in App.razor),
       so they follow the colour chosen in Configurazione. */
    --grid-header-bg: color-mix(in srgb, var(--brand, #2A6FB0) 8%, var(--grid-surface));
    --grid-footer-bg: color-mix(in srgb, var(--brand, #2A6FB0) 5%, var(--grid-surface));
    --grid-header-border: color-mix(in srgb, var(--brand, #2A6FB0) 22%, var(--grid-surface));
}

/* Filter fields under the titles, in the same header cell. */
.grid-header-filter .grid-filter-field,
.grid-header-filter .grid-filter-field .mud-input-control-input-container {
    margin: 0 !important;
}

.grid-header-filter .grid-filter-field .mud-input {
    background: var(--grid-surface);
}

.grid-header-filter .mud-input-control.grid-filter-field {
    min-width: 120px;
}

.grid-date-range {
    display: flex;
    gap: 6px;
    min-width: 260px;
}

.grid-date-range--stacked {
    flex-direction: column;
    gap: 0;
    min-width: 0;
}

.grid-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
}

.grid-pager-count {
    color: var(--grid-muted);
    font-size: 13px;
}

.grid-pager-size {
    max-width: 150px;
}

.grid-pager-pages {
    display: flex;
    align-items: center;
    gap: 2px;
}

.grid-pager-number {
    min-width: 36px !important;
}

.grid-pager-gap {
    padding: 0 6px;
    color: var(--grid-muted);
}

.grid-pager--compact .grid-pager-pages .mud-icon-button {
    min-width: 44px;
    min-height: 44px;
}

.grid-filters-button {
    min-height: 44px;
}

.grid-filters-drawer {
    max-height: 85vh;
    overflow-y: auto;
}

/* Reserved height: the loading indicator does not move the grid. */
.grid-progress {
    min-height: 4px;
    margin-bottom: 4px;
}

/* MudDataGrid on PC (class pro-grid): fixed header, dense rows, footer with the totals. */
.pro-grid {
    color: var(--grid-text);
    border-color: var(--grid-border) !important;
}

/* Scrolls inside the page height so the header (and the footer) stay fixed; shorter lists keep their own height. */
.pro-grid .mud-table-container {
    max-height: calc(100vh - 290px);
    overflow: auto;
}

/* The second selector matches MudBlazor's sticky-header rule, which would otherwise paint the cells with the surface colour. */
.pro-grid .mud-table-head .mud-table-cell,
.pro-grid.mud-table-sticky-header * .mud-table-root .mud-table-head .mud-table-cell {
    background: var(--grid-header-bg);
    color: var(--grid-text);
    font-size: 12.5px;
    font-weight: 600;
    padding: 7px 10px;
    border-bottom: 1px solid var(--grid-header-border);
    vertical-align: top;
}

/* Title and filter field stacked in the header cell (MudDataGrid wraps HeaderTemplate in .column-header). */
.pro-grid .mud-table-head .column-header {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.grid-header {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1 1 auto;
    min-width: 0;
}

.grid-header--right {
    align-items: flex-end;
}

.grid-header-title {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    white-space: nowrap;
}

.grid-header-filter {
    font-weight: 400;
}

.pro-grid .mud-table-body .mud-table-cell {
    padding: 7px 10px;
    border-bottom: 1px solid var(--grid-border);
}

.pro-grid.mud-table-hover .mud-table-body .mud-table-row:hover {
    background: var(--grid-row-hover);
}

.pro-grid .mud-table-foot .mud-table-cell,
.pro-grid.mud-table-sticky-footer * .mud-table-root .mud-table-foot .mud-table-cell {
    background: var(--grid-footer-bg);
    color: var(--grid-text);
    font-weight: 600;
    padding: 7px 10px;
    border-top: 2px solid var(--grid-header-border);
    border-bottom: 0;
}

.pro-grid .grid-number {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.pro-grid .mud-table-cell,
.grid-totals-summary {
    font-variant-numeric: tabular-nums;
}

/* Column resize handle: visible on hover. */
.pro-grid .mud-resizer {
    opacity: 0;
    transition: opacity .15s;
}

.pro-grid .mud-table-head .mud-table-cell:hover .mud-resizer {
    opacity: 1;
    border-right: 2px solid var(--grid-border);
}

/* Sortable title: a button without its own style. */
.grid-sort-header {
    white-space: nowrap;
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
}

.grid-sort-header:focus-visible {
    outline: 2px solid var(--grid-accent);
    outline-offset: 2px;
}

.grid-sort-icon {
    color: var(--grid-muted);
    opacity: .6;
}

.grid-sort-icon--on {
    color: var(--grid-accent);
    opacity: 1;
}

.grid-footer-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* Phone: the footer totals above the cards. */
.grid-totals-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: var(--grid-footer-bg);
    border: 1px solid var(--grid-border);
    border-radius: 8px;
    color: var(--grid-text);
    font-size: 13px;
}

/* Row actions of a grid on one line (icon buttons, small gap). */
.grid-row-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 2px;
    white-space: nowrap;
}

/* The photo picker (MudFileUpload is a block input control) stays inline with the other icons. */
.grid-row-actions .photo-picker,
.grid-row-actions .photo-picker .mud-input-control,
.grid-row-actions .photo-picker .mud-file-upload,
.grid-row-actions .photo-picker .mud-file-upload-custom-content {
    display: inline-flex;
    align-items: center;
    width: auto;
    margin: 0;
}

/* Phone navigation (docs/contracts/ui/phone-navigation.md): below 960px the bottom bar replaces the side menu. */
:root {
    --bottom-nav-height: 56px;
    --bottom-nav-space: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 960px) {
    .phone-only {
        display: none !important;
    }
}

@media (max-width: 959.95px) {
    .desktop-only,
    .app-drawer {
        display: none !important;
    }

    /* MudBlazor shifts the content for the drawer through these layout classes. */
    .mud-layout .mud-main-content {
        margin-left: 0 !important;
    }

    .app-content {
        padding-bottom: calc(var(--bottom-nav-space) + 16px);
    }
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1150; /* below popovers (1200), above content */
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: var(--bottom-nav-space);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--app-surface);
    border-top: 1px solid var(--app-border);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 44px;
    padding: 4px 2px;
    border: 0;
    background: none;
    font: inherit;
    color: var(--app-muted);
    text-decoration: none;
    cursor: pointer;
}

.bottom-nav-item--active {
    color: var(--brand-text);
    font-weight: 600;
}

.bottom-nav-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    line-height: 1.2;
}

.bottom-nav-icon-wrap {
    position: relative;
    display: inline-flex;
}

/* Same icon area for every item, so icons and labels line up. */
.bottom-nav-item > .mud-icon-root,
.bottom-nav-icon-wrap {
    height: 32px;
    align-items: center;
}

.bottom-nav-dot {
    position: absolute;
    top: -2px;
    right: -4px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #C0392B;
    border: 2px solid var(--app-surface);
}

.more-sheet.mud-drawer {
    height: auto !important;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    overflow-y: auto;
}

.more-sheet-menu .mud-nav-link {
    min-height: 48px;
}

/* Bottom sheets with automatic height (filters, «Altro»): MudBlazor hides a closed bottom drawer with
   bottom: -var(--mud-drawer-height), which is invalid for "auto" and leaves the sheet in the page. Slide it instead. */
.mud-drawer.mud-drawer-temporary.mud-drawer-pos-bottom.grid-filters-drawer,
.mud-drawer.mud-drawer-temporary.mud-drawer-pos-bottom.more-sheet {
    bottom: 0;
    transition: transform 225ms cubic-bezier(0, 0, 0.2, 1);
}

.mud-drawer.mud-drawer-temporary.mud-drawer-pos-bottom.mud-drawer--closed.grid-filters-drawer,
.mud-drawer.mud-drawer-temporary.mud-drawer-pos-bottom.mud-drawer--closed.more-sheet {
    transform: translateY(calc(100% + 16px));
    visibility: hidden;
    transition: transform 225ms cubic-bezier(0, 0, 0.2, 1), visibility 0s 225ms;
}

/* User menu (UserMenu): avatar activator, header with name and role, theme items with check. */
.user-menu-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: inherit;
    cursor: pointer;
}

/* Shown when the user has no email (docs/contracts/users/user-profile.md §4): sun accent on the primary-coloured bar. */
.user-menu-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--app-accent);
    border: 2px solid var(--brand);
    box-sizing: content-box;
}

.user-menu-button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    min-width: 220px;
}

.user-menu-header-text {
    min-width: 0;
}

.user-menu-role {
    color: var(--app-muted);
}

.user-menu-section {
    display: block;
    padding: 8px 16px 0;
    color: var(--app-muted);
}

.user-menu-check-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 140px;
}

/* Profile «Email» box: current address with its chip, pending change with its actions. */
.profile-email-current {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.profile-email-address,
.profile-email-pending strong {
    overflow-wrap: anywhere;
}

.profile-email-pending {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-panel);
}

/* Home page by areas (docs/contracts/ui/home.md): greeting and quick actions, area cards, recent activity. */
.home {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.home-hello {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px 24px;
}

.home-greeting {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -.01em;
    color: var(--app-text);
}

.home-date {
    margin: 4px 0 0;
    font-size: 14px;
    color: var(--app-muted);
}

.home-areas {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.home-area {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 10px;
}

.home-area-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 10px;
}

.home-area-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--brand-tint);
    color: var(--brand-text);
}

.home-area-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--app-text);
}

.home-area-note {
    margin-left: auto;
    font-size: 12px;
    text-align: right;
    color: var(--app-muted);
}

.home-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 4px 8px 12px;
}

.home-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    padding: 8px;
    border-radius: 8px;
    color: var(--app-text);
    text-decoration: none;
}

.home-stat:hover {
    background: var(--app-panel);
}

.home-stat:focus-visible,
.home-feed-row:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

.home-stat-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.home-stat-label {
    font-size: 12px;
    color: var(--app-muted);
}

.home-stat .category-tag,
.home-stat .home-stat-chip.mud-chip {
    margin: 2px 0 0;
}

.home-stat .home-stat-chip.mud-chip {
    height: 20px;
    font-size: 11px;
    font-weight: 600;
}

.home-area-links {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-top: auto;
    padding: 10px 16px;
    border-top: 1px solid var(--app-border);
    font-size: 13px;
}

.home-area-links a,
.home-feed-head a {
    font-weight: 600;
    color: var(--brand-text);
    text-decoration: none;
}

.home-area-links a:hover,
.home-feed-head a:hover {
    text-decoration: underline;
}

/* Larghezza al contenuto (non stirati): affiancati quando entrano, altrimenti l'intero pulsante va a capo. */
.home-area-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 14px;
}

.home-area-action.mud-button-root {
    font-weight: 600;
}

.home-area--soon {
    background: var(--app-panel);
    border-style: dashed;
}

.home-area--soon .home-area-icon {
    background: var(--app-border);
    color: var(--app-muted);
}

.home-soon-chip {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--app-border);
    color: var(--app-muted);
    font-size: 11px;
    font-weight: 600;
}

.home-soon-text,
.home-area-error {
    margin: 0;
    padding: 4px 16px 16px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--app-muted);
}

.home-area-error {
    color: var(--app-error-text);
}

.home-feed {
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 10px;
}

.home-feed-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--app-border);
    font-size: 13px;
}

.home-feed-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--app-text);
}

.home-feed-empty {
    margin: 0;
    padding: 16px;
    font-size: 13px;
    color: var(--app-muted);
}

.home-feed-row {
    display: grid;
    grid-template-columns: 92px 120px minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--app-text);
    text-decoration: none;
}

.home-feed-row + .home-feed-row {
    border-top: 1px solid var(--app-border);
}

.home-feed-row:hover {
    background: var(--app-panel);
}

.home-feed-when {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    color: var(--app-muted);
}

.home-feed-type {
    justify-self: start;
    min-width: 0;
}

.home-feed-what {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-feed-what strong {
    color: var(--brand-text);
}

.home-feed-qty {
    white-space: nowrap;
    text-align: right;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.home-feed-who {
    white-space: nowrap;
    color: var(--app-muted);
}

@media (max-width: 1279.95px) {
    .home-areas {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Phone (same threshold as the bottom bar): one column, full-width quick actions, compact activity cards (first 5). */
@media (max-width: 959.95px) {
    .home {
        gap: 16px;
    }

    .home-greeting {
        font-size: 20px;
    }

    .home-areas {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .home-area-action.mud-button-root {
        min-height: 44px;
    }

    .home-area-links a,
    .home-feed-head a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .home-feed-head,
    .home-area-links {
        padding-top: 0;
        padding-bottom: 0;
    }

    .home-feed-head {
        min-height: 48px;
    }

    .home-feed-row {
        grid-template-columns: auto auto minmax(0, 1fr);
        grid-template-areas:
            "what what qty"
            "when type who";
        row-gap: 6px;
        column-gap: 8px;
    }

    .home-feed-what { grid-area: what; white-space: normal; }
    .home-feed-qty { grid-area: qty; }
    .home-feed-when { grid-area: when; font-size: 12px; }
    .home-feed-type { grid-area: type; }
    .home-feed-who { grid-area: who; justify-self: end; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }

    .home-feed-row:nth-child(n + 6) {
        display: none;
    }
}

/* Home card list (e.g. the next events): colour mark, detail, text. */
.home-area-items {
    list-style: none;
    margin: 0;
    padding: 0 8px 10px;
}

.home-area-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    padding: 4px 8px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--app-text);
    text-decoration: none;
}

.home-area-item:hover {
    background: var(--app-panel);
}

.home-area-item:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

.home-area-item-mark {
    flex: none;
    width: 4px;
    height: 18px;
    border-radius: 2px;
}

.home-area-item-detail {
    flex: none;
    color: var(--app-muted);
    font-variant-numeric: tabular-nums;
}

.home-area-item-text {
    min-width: 0;
    overflow: hidden;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

@media (max-width: 959.95px) {
    .home-area-item {
        min-height: 44px;
    }
}

/* Events (docs/contracts/events/events.md §4). */
.event-status-chips {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    vertical-align: middle;
}

.event-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.event-when {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: 12px;
}

.cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 24px;
    margin-bottom: 12px;
}

.cal-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cal-month {
    min-width: 170px;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    color: var(--app-text);
}

.cal-today.mud-button-root {
    margin-left: 8px;
}

.cal-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
}

.cal-filters .grid-filter-field {
    width: 190px;
}

.cal {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--app-surface);
}

.cal-head {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    background: var(--brand-tint);
    border-bottom: 1px solid var(--app-border);
}

.cal-head-cell {
    padding: 6px 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--app-muted);
}

.cal-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: 30px repeat(var(--cal-lanes), 24px) 22px minmax(8px, 1fr);
    row-gap: 2px;
    min-height: 136px;
}

.cal-week + .cal-week {
    border-top: 1px solid var(--app-border);
}

.cal-day {
    grid-row: 1 / -1;
    padding: 4px 6px;
    border-left: 1px solid var(--app-border);
}

.cal-day:first-child {
    border-left: none;
}

.cal-day--out {
    background: var(--app-panel);
}

.cal-day--out .cal-day-number {
    color: var(--app-muted);
    opacity: .7;
}

.cal-day--new {
    cursor: pointer;
}

.cal-day--new:hover {
    background: var(--brand-tint);
}

.cal-day--new:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

.cal-day-number {
    display: inline-grid;
    place-items: center;
    min-width: 24px;
    height: 24px;
    padding: 0 4px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--app-text);
}

.cal-day--today .cal-day-number {
    background: var(--brand);
    color: #FFFFFF;
    font-weight: 700;
}

.cal-bar {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin: 0 4px;
    padding: 0 8px;
    border-radius: 6px;
    font-size: 12px;
    line-height: 24px;
    white-space: nowrap;
    overflow: hidden;
    text-decoration: none;
}

.cal-bar:hover {
    filter: brightness(1.08);
}

.cal-bar:focus-visible {
    outline: 2px solid var(--app-text);
    outline-offset: 1px;
}

.cal-bar--before {
    margin-left: 0;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.cal-bar--after {
    margin-right: 0;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.cal-bar--cancelled {
    opacity: .5;
}

.cal-bar--cancelled .cal-bar-name {
    text-decoration: line-through;
}

.cal-bar-time {
    flex: none;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.cal-bar-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Overdue tasks of the event: the icon keeps the surface behind it to read on any type colour. */
.cal-bar-overdue {
    flex: none;
    margin-left: auto;
    display: inline-flex;
}

.cal-bar-overdue .mud-icon-root {
    border-radius: 50%;
    background: var(--app-surface);
    color: var(--app-error-text);
}

.cal-bar-dot {
    flex: none;
    width: 9px;
    height: 9px;
    margin-left: auto;
    border-radius: 50%;
    background: var(--app-warning);
    box-shadow: 0 0 0 2px var(--app-surface);
}

.cal-more {
    position: relative;
    z-index: 1;
    justify-self: start;
    margin: 0 4px;
    padding: 0 6px;
    border: none;
    border-radius: 6px;
    background: none;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-text);
    cursor: pointer;
}

.cal-more:hover {
    background: var(--brand-tint);
}

.cal-more:focus-visible {
    outline: 2px solid var(--brand);
}

/* Agenda (phone) and event cards (agenda, day list). */
.agenda-empty {
    margin: 24px 0;
    color: var(--app-muted);
    text-align: center;
}

.agenda-day + .agenda-day {
    margin-top: 16px;
}

.agenda-day-head {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--app-muted);
}

.agenda-day-head--today {
    color: var(--brand-text);
}

.event-card {
    display: flex;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    margin-bottom: 8px;
    border: 1px solid var(--app-border);
    border-left: 4px solid var(--event-color);
    border-radius: 8px;
    background: var(--app-surface);
    color: var(--app-text);
    text-decoration: none;
}

.event-card:hover {
    background: var(--app-panel);
}

.event-card:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

.event-card--cancelled {
    opacity: .6;
}

.event-card--cancelled .event-card-name {
    text-decoration: line-through;
}

.event-card-time {
    display: flex;
    flex-direction: column;
    flex: none;
    width: 92px;
    font-size: 13px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.event-card-dayof {
    font-size: 11px;
    font-weight: 500;
    color: var(--app-muted);
}

.event-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.event-card-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.event-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    font-size: 12px;
    color: var(--app-muted);
}

.event-card-overdue {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--app-error-text);
}

.day-events .event-card:last-child {
    margin-bottom: 0;
}

@media (max-width: 959.95px) {
    .cal-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .cal-nav {
        justify-content: space-between;
    }

    .cal-month {
        flex: 1;
        min-width: 0;
    }

    .cal-filters .grid-filter-field {
        width: auto;
        flex: 1 1 140px;
    }

    .cal-switch {
        min-height: 44px;
    }

    .cal-today.mud-button-root {
        min-height: 44px;
    }
}

@media (max-width: 599.95px) {
    .event-when {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }
}

/* Event page tabs and «Attività» tab (docs/contracts/events/event-tasks.md §4). */
.event-tab-panels {
    padding: 24px;
}

.task-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.task-toolbar-switch {
    margin-left: auto;
}

.task-empty {
    padding: 24px 0;
    text-align: center;
}

.task-muted {
    color: var(--app-muted);
}

.task-list {
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.task-row + .task-row {
    border-top: 1px solid var(--app-border);
}

.task-row-main {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto 110px minmax(0, 200px) auto;
    align-items: center;
    gap: 8px;
    padding: 2px 8px;
    cursor: pointer;
}

.task-row-main:hover {
    background: var(--grid-row-hover);
}

.task-name,
.task-card-body {
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    color: var(--app-text);
    text-align: left;
    cursor: pointer;
    min-width: 0;
    overflow-wrap: anywhere;
}

.task-row--done .task-name,
.task-row--done .task-name-text {
    text-decoration: line-through;
    color: var(--app-muted);
}

.task-due {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-size: 14px;
}

.task-assignee {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 14px;
}

.task-assignee > span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.task-details {
    padding: 4px 16px 12px 56px;
    font-size: 14px;
}

/* The clip of a task row: the attachments the viewer may see. */
.task-attachments {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 13px;
    color: var(--app-muted);
}

.task-attachments-panel {
    margin-top: 12px;
}

.task-notes {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.task-assignee-option {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.task-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-card {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface);
}

.task-card-main {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px;
}

.task-card-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 44px;
    justify-content: center;
}

.task-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
}

.task-card .task-details {
    padding: 0 12px 12px 52px;
}

.task-card .mud-checkbox .mud-button-root,
.task-card .mud-icon-button {
    min-width: 44px;
    min-height: 44px;
}

.task-menu-label {
    display: block;
}

.task-menu-reason {
    display: block;
    max-width: 260px;
    font-size: 12px;
    color: var(--app-muted);
    white-space: normal;
}

/* «Importa attività» dialog. */
.import-empty {
    color: var(--app-muted);
}

.import-events {
    display: flex;
    flex-direction: column;
    max-height: 240px;
    overflow-y: auto;
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.import-event {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
    padding: 8px 12px;
    border: 0;
    border-left: 3px solid transparent;
    background: none;
    font: inherit;
    color: var(--app-text);
    text-align: left;
    cursor: pointer;
}

.import-event + .import-event {
    border-top: 1px solid var(--app-border);
}

.import-event:hover {
    background: var(--grid-row-hover);
}

.import-event--selected {
    background: var(--brand-tint);
    border-left-color: var(--brand);
    font-weight: 600;
}

.import-event-date {
    color: var(--app-muted);
    white-space: nowrap;
}

.import-preview {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.import-preview-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    padding: 8px 12px;
    font-size: 14px;
}

.import-preview-item + .import-preview-item {
    border-top: 1px solid var(--app-border);
}

.import-preview-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.import-preview-due {
    color: var(--app-muted);
    white-space: nowrap;
}

.import-preview-item--present {
    opacity: .55;
}

.import-preview-present {
    font-size: 12px;
    font-style: italic;
    color: var(--app-muted);
}

@media (max-width: 959.95px) {
    .event-tab-panels {
        padding: 12px;
    }
}

.task-card-reason {
    padding: 0 12px 8px 52px;
    font-size: 12px;
    color: var(--app-muted);
}

/* «Attività» page (/events/tasks, docs/contracts/events/event-tasks.md §4). */
.tasks-page-name {
    overflow-wrap: anywhere;
}

/* The card body is not a button here (no details to expand). */
.tasks-page-card-body {
    cursor: default;
}

/* A grid total that needs attention (e.g. overdue tasks > 0). */
.grid-total--alert {
    color: var(--app-error-text);
    font-weight: 600;
}

/* «Catalogo attività» and «Checklist» lists (/events/activities, /events/checklists). */
.catalog-row-text {
    flex: 1;
    min-width: 180px;
    overflow-wrap: anywhere;
}

.catalog-row-name {
    font-weight: 500;
    color: var(--app-text);
}

a.catalog-row-link {
    text-decoration: none;
}

a.catalog-row-link:hover {
    color: var(--brand-text);
    text-decoration: underline;
}

.catalog-row-meta {
    font-size: 14px;
    color: var(--app-muted);
}

.catalog-row-notes {
    font-size: 13px;
    color: var(--app-muted);
    white-space: pre-line;
}

.catalog-empty {
    color: var(--app-muted);
}

/* Checklist page: one row per activity; on phones the days and the actions wrap below the activity. */
.checklist-rows {
    margin-bottom: 8px;
}

.checklist-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 0;
    border-bottom: 1px solid var(--app-border);
}

.checklist-row-activity {
    flex: 1 1 280px;
    min-width: 0;
}

.checklist-row-days {
    flex: 0 0 140px;
}

.checklist-row-actions {
    display: flex;
    align-items: center;
}

/* Attachments panel and dialogs (docs/contracts/common/attachments.md §4). */
.attachment-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.attachment-empty {
    padding: 16px 0;
    color: var(--app-muted);
}

.attachment-meta {
    font-size: 13px;
    color: var(--app-muted);
    white-space: nowrap;
}

.attachment-list {
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.attachment-row {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(0, 180px) 80px minmax(0, 220px) auto;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
}

.attachment-row + .attachment-row {
    border-top: 1px solid var(--app-border);
}

.attachment-row:hover {
    background: var(--grid-row-hover);
}

.attachment-thumb {
    width: 48px;
    height: 48px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    object-fit: cover;
    flex: none;
}

.attachment-thumb--empty {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand-tint);
    color: var(--brand-text);
}

.attachment-main {
    min-width: 0;
}

.attachment-title {
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    text-align: left;
    color: var(--app-text);
    text-decoration: none;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.attachment-title:hover {
    color: var(--brand-text);
    text-decoration: underline;
}

.attachment-notes {
    font-size: 13px;
    color: var(--app-muted);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.attachment-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.attachment-uploader {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    font-size: 13px;
}

.attachment-uploader-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-actions {
    justify-self: end;
}

.attachment-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attachment-card {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface);
}

.attachment-card-main {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px;
}

.attachment-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
    margin-top: 4px;
}

.attachment-card .attachment-title {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
}

.attachment-card .mud-icon-button {
    min-width: 44px;
    min-height: 44px;
}

/* Dense: the panel inside the expansion of a task row. */
.attachment-panel--dense .attachment-toolbar {
    margin-bottom: 8px;
}

.attachment-panel--dense .attachment-empty {
    padding: 4px 0;
}

.attachment-panel--dense .attachment-row {
    padding: 4px 8px;
}

.attachment-panel--dense .attachment-thumb {
    width: 32px;
    height: 32px;
}

.attachment-menu-label {
    display: block;
}

.attachment-menu-reason {
    display: block;
    max-width: 260px;
    font-size: 12px;
    color: var(--app-muted);
    white-space: normal;
}

.attachment-menu-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

/* «Nuovo allegato» dialog: drop area, chosen files and the type options. */
.attachment-upload {
    position: relative;
}

.attachment-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px;
    border: 1px dashed var(--app-input-border);
    border-radius: 8px;
    color: var(--app-muted);
    text-align: center;
}

.attachment-drop--over {
    border-color: var(--brand);
    background: var(--brand-tint);
}

.attachment-drop-text {
    font-size: 14px;
}

.attachment-chosen {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--app-border);
    border-radius: 8px;
}

.attachment-chosen-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
}

.attachment-chosen-item + .attachment-chosen-item {
    border-top: 1px solid var(--app-border);
}

.attachment-chosen-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.attachment-chosen-error {
    font-size: 13px;
    color: var(--app-error-text);
}

.attachment-type-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Preview of an image attachment. */
.attachment-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.attachment-preview-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
}

/* Compact panel, inside the expansion of an event task row. */
.attachment-panel--dense .attachment-row {
    padding: 4px 8px;
    gap: 8px;
}

.attachment-panel--dense .attachment-thumb {
    width: 32px;
    height: 32px;
}
