/* MATEC HUB - calendari e tabelle: sola coerenza visiva, nessun cambio strutturale. */
html[data-theme] body .ds-app__main :is(table, .attendance-table) { font-family: Roboto, Arial, sans-serif; color: var(--mh-text); }
html[data-theme] body .ds-app__main :is(table, .attendance-table) th { font-size: .75rem !important; font-weight: 700 !important; line-height: 1.25 !important; color: var(--mh-muted) !important; }
html[data-theme] body .ds-app__main :is(table, .attendance-table) td { font-size: .8125rem; line-height: 1.35; }
html[data-theme] body :is(.calendar-weekday, .weekday, .week-day, .calendar-head) { font-family: Roboto, Arial, sans-serif; font-size: .75rem !important; font-weight: 700 !important; }
html[data-theme] body :is(.calendar-day, .day-cell, .month-day) { font-family: Roboto, Arial, sans-serif; }

/* Stessa gerarchia cromatica in tutti i calendari mensili. */
html[data-theme] body :is(.office-timesheets-page, .attendance-page, .truck-page) :is(.calendar-strip .day, .day-column-header, .calendar-day) :is(.day-weekday, .weekday-label, .truck-day-weekday, .day-number, .truck-day-number) {
    color:#243247 !important;
}
html[data-theme="dark"] body :is(.office-timesheets-page, .attendance-page, .truck-page) :is(.calendar-strip .day, .day-column-header, .calendar-day) :is(.day-weekday, .weekday-label, .truck-day-weekday, .day-number, .truck-day-number) {
    color:#e6edf7 !important;
}
html[data-theme] body :is(.office-timesheets-page, .attendance-page, .truck-page) :is(.saturday-day-number, .saturday-header .weekday-label, .saturday-header .day-number) {
    color:#d99a00 !important;
}
html[data-theme] body :is(.office-timesheets-page, .attendance-page, .truck-page) :is(.holiday-day-number, .sunday-header .weekday-label, .sunday-header .day-number, .holiday-header .weekday-label, .holiday-header .day-number) {
    color:#e5484d !important;
}
html[data-theme] body :is(.office-timesheets-page, .attendance-page, .truck-page) :is(.empty-day, .inactive, .inactive-day) :is(.day-weekday, .weekday-label, .truck-day-weekday, .day-number, .truck-day-number) {
    color:#8a97a8 !important;
}
/* Eccezioni legacy individuate dal controllo pagina per pagina. */
html[data-theme] body .office-timesheets-page .calendar-strip .day > .day-weekday {
    font-size: .6875rem !important;
    line-height: 1.15 !important;
}
html[data-theme] body .office-timesheets-page .calendar-strip .day > .day-weekday::after {
    font-size: .6875rem !important;
}
/* Il testo breve sostituisce quello lungo: non devono mai essere visibili insieme. */
@container (max-width:44px) {
    html[data-theme] body .office-timesheets-page .calendar-strip .day > .day-weekday { font-size:0 !important; }
}
@container (max-width:44px) {
    html[data-theme] body .attendance-page .day-column-header .weekday-label-full { display:none !important; }
    html[data-theme] body .attendance-page .day-column-header .weekday-label-narrow { display:block !important; }
    html[data-theme] body .truck-page .calendar-strip .day > .day-weekday { font-size:0 !important; }
}
html[data-theme] body .mobile-menu .menu-calendar small {
    font-size: .5625rem !important;
}
html[data-theme] body .truck-calendar .calendar-day i {
    font-size: .5625rem !important;
}

/* Contratto unico dei calendari mensili.
   Specificità alta intenzionale: neutralizza le vecchie regole locali. */
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .month-bar.month-bar,
html[data-theme] body .attendance-page.attendance-page .month-toolbar.month-toolbar {
    display:flex !important; align-items:center !important; justify-content:center !important;
    gap:20px !important; width:max-content !important; max-width:100% !important;
    margin:0 auto 18px !important; padding:0 !important; border:0 !important;
    background:transparent !important; box-shadow:none !important;
}
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .month-bar.month-bar > button,
html[data-theme] body .attendance-page.attendance-page .month-toolbar.month-toolbar > button {
    display:flex !important; align-items:center !important; justify-content:center !important;
    width:52px !important; min-width:52px !important; height:52px !important; padding:0 !important;
    border:1px solid var(--ds-color-border,var(--mh-border,#cbd8e7)) !important;
    border-radius:16px !important; background:var(--ds-color-surface,var(--mh-surface,#fff)) !important;
    color:var(--ds-color-text,var(--mh-text,#243247)) !important; font-size:22px !important; font-weight:900 !important;
}
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .month-bar.month-bar > strong,
html[data-theme] body .attendance-page.attendance-page .month-toolbar.month-toolbar > strong {
    min-width:270px !important; margin:0 !important; padding:0 !important; border:0 !important;
    background:transparent !important; color:var(--ds-color-text,var(--mh-text,#243247)) !important;
    text-align:center !important; text-transform:capitalize !important; font-size:27px !important; line-height:1.1 !important;
}
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day {
    container:calendar-day-cell / inline-size !important; display:flex !important; flex-direction:column !important;
    align-items:center !important; justify-content:center !important; gap:3px !important;
    min-width:0 !important; height:86px !important; min-height:86px !important; padding:6px 2px !important;
    color:#243247 !important; background:var(--mh-surface,#fff) !important;
    border:1px solid var(--mh-border,#cbd8e7) !important; opacity:1 !important;
}
html[data-theme="dark"] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day { color:#e6edf7 !important; }
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day.empty-day {
    color:#8a97a8 !important; opacity:.45 !important;
}
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day > span.day-weekday {
    position:static !important; display:block !important; flex:0 0 11px !important; width:100% !important;
    max-width:100% !important; margin:0 !important; padding:0 !important; overflow:hidden !important;
    white-space:nowrap !important; text-align:center !important; text-transform:uppercase !important;
    color:inherit !important; font-size:11px !important; line-height:11px !important; font-weight:900 !important;
}
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day > strong.day-number {
    position:static !important; display:flex !important; flex:0 0 auto !important; align-items:center !important;
    justify-content:center !important; min-height:30px !important; margin:0 !important; padding:0 !important;
    white-space:nowrap !important; color:inherit !important; font-size:24px !important;
    line-height:1 !important; font-weight:950 !important;
}
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day > strong.day-number > span {
    position:static !important; display:inline !important; margin:0 !important; padding:0 !important;
    color:inherit !important; font-size:inherit !important; line-height:inherit !important;
}
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day > span.day-status-dots {
    position:static !important; display:flex !important; flex:0 0 auto !important; flex-direction:row !important;
    align-items:center !important; justify-content:center !important; gap:3px !important;
    min-height:9px !important; margin:0 !important; padding:0 !important;
}
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day > :is(span.day-weekday.saturday-day-number,strong.day-number.saturday-day-number) { color:#d99a00 !important; }
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day > :is(span.day-weekday.holiday-day-number,strong.day-number.holiday-day-number) { color:#e5484d !important; }
html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day.selected-day {
    position:relative !important; z-index:4 !important; height:94px !important; min-height:94px !important;
    border:3px solid #2563eb !important; outline:3px solid rgba(37,99,235,.32) !important;
    outline-offset:-7px !important; background:#dbeafe !important;
    box-shadow:inset 0 0 0 3px #fff,0 0 0 4px #2563eb,0 8px 22px rgba(37,99,235,.38) !important;
    transform:translateY(-4px) scale(1.025) !important;
}
html[data-theme="dark"] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
  .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day.selected-day {
    border-color:#22c55e !important; outline-color:rgba(74,222,128,.42) !important;
    background:#16345f !important; box-shadow:0 0 0 4px #22c55e,0 8px 26px rgba(34,197,94,.46) !important;
}

/* La tabella presenze conserva la propria forma, ma usa gli stessi testi e la
   stessa soglia adattiva dei due calendari a pulsanti. */
html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper {
    container:attendance-calendar / inline-size !important;
}
html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
  .attendance-table.attendance-table thead th.day-column-header {
    height:86px !important; min-height:86px !important; padding:6px 2px !important;
    border-color:var(--ds-color-border,var(--mh-border,#cbd8e7)) !important;
    background:var(--ds-color-surface,var(--mh-surface,#fff)) !important;
    color:#243247 !important; text-align:center !important; vertical-align:middle !important;
}
html[data-theme="dark"] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
  .attendance-table.attendance-table thead th.day-column-header {
    background:var(--ds-color-surface,var(--mh-surface,#111c31)) !important; color:#e6edf7 !important;
  }
html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
  .attendance-table.attendance-table thead th.day-column-header .weekday-label {
    width:100% !important; margin:0 !important; padding:0 !important; color:inherit !important;
    text-align:center !important; text-transform:uppercase !important; font-size:11px !important;
    line-height:11px !important; font-weight:900 !important;
}
html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
  .attendance-table.attendance-table thead th.day-column-header strong.day-number {
    display:flex !important; flex-direction:row !important; align-items:center !important; justify-content:center !important;
    min-height:30px !important; color:inherit !important; white-space:nowrap !important;
    font-size:24px !important; line-height:1 !important; font-weight:950 !important;
}
html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
  .attendance-table.attendance-table thead th.day-column-header.saturday-header { color:#d99a00 !important; }
html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
  .attendance-table.attendance-table thead th.day-column-header:is(.sunday-header,.holiday-header) { color:#e5484d !important; }

html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
  .attendance-table.attendance-table thead th.day-column-header .weekday-label-full { display:block !important; }
html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
  .attendance-table.attendance-table thead th.day-column-header .weekday-label-narrow {
    display:none !important;
}
html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
  .attendance-table.attendance-table thead th.day-column-header strong.day-number > span {
    display:inline !important; line-height:inherit !important;
}

@container calendar-day-cell (max-width:44px) {
  html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
    .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day > span.day-weekday {
      flex-basis:10px !important; font-size:0 !important; line-height:10px !important;
  }
  html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
    .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day > span.day-weekday::after {
      content:attr(data-narrow) !important; color:inherit !important; font-size:10px !important; line-height:10px !important;
  }
  html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
    .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day > strong.day-number {
      flex-direction:column !important; gap:0 !important; font-size:18px !important; line-height:.82 !important;
  }
  html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
    .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day > strong.day-number > span {
      display:block !important; line-height:.82 !important;
  }
  html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
    .timesheet-calendar-panel.timesheet-calendar-panel .calendar-strip.calendar-strip button.day.day > span.day-status-dots {
      flex-direction:column !important; gap:1px !important; min-height:24px !important;
  }
}

/* Il cambio avviene in base alla larghezza reale della tabella, non al modello
   di telefono: a spazio sufficiente LUN/10 restano orizzontali, altrimenti
   diventano L/1/0. */
@container attendance-calendar (max-width:1700px) {
  html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
    .attendance-table.attendance-table thead th.day-column-header .weekday-label-full { display:none !important; }
  html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
    .attendance-table.attendance-table thead th.day-column-header .weekday-label-narrow {
      display:block !important; font-size:10px !important; line-height:10px !important;
  }
  html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
    .attendance-table.attendance-table thead th.day-column-header strong.day-number {
      flex-direction:column !important; gap:0 !important; font-size:18px !important; line-height:.82 !important;
  }
  html[data-theme] body .attendance-page.attendance-page .calendar-wrapper.calendar-wrapper
    .attendance-table.attendance-table thead th.day-column-header strong.day-number > span {
      display:block !important; line-height:.82 !important;
  }
}

@media(max-width:700px) {
  html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
    .timesheet-calendar-panel.timesheet-calendar-panel .month-bar.month-bar > strong,
  html[data-theme] body .attendance-page.attendance-page .month-toolbar.month-toolbar > strong {
      min-width:190px !important; font-size:22px !important;
  }
  html[data-theme] body :is(.office-timesheets-page.office-timesheets-page,.truck-page.truck-page)
    .timesheet-calendar-panel.timesheet-calendar-panel .month-bar.month-bar,
  html[data-theme] body .attendance-page.attendance-page .month-toolbar.month-toolbar { gap:10px !important; }
}
