/* Trama, voce 6: schede delle viste, barra strumenti e pillole dei filtri, costruttore dei filtri, ordinamenti e gruppi,
   Bacheca, Lista e Calendario (replica/design/components.md). Colori e misure solo dai token. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* schede */
.view-tabs { flex-wrap: nowrap; overflow-x: auto; align-items: flex-end; min-width: 0; }
.view-tab { white-space: nowrap; }
.view-tab:hover { color: var(--text); background: var(--bg-hover); }
.view-tab:focus-visible { outline-offset: -2px; }
.view-tab-name { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.view-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-strong); flex: none; }
.view-add { margin: 0 0 5px 4px; }
.view-rename { height: 32px; margin-bottom: 3px; padding: 4px 8px; border: 2px solid var(--accent); border-radius: var(--r-ctl); font-weight: 600; background: var(--bg); }
.view-bar { flex-wrap: wrap; }

/* barra strumenti e pillole */
.tool-btn { color: var(--text-muted); }
.tool-btn.on { color: var(--accent-strong); }
.view-pills { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; padding: 8px 48px; border-bottom: 1px solid var(--border); }
.view-pills.dirty { background: var(--bg-soft); }
.pills-left, .pills-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fpill { display: inline-flex; align-items: center; gap: 2px; border-radius: var(--r-chip); background: var(--accent-soft); color: var(--accent-strong); font-size: 13px; font-weight: 600; padding: 0 4px 0 2px; max-width: 360px; }
.fpill.bad { background: var(--error-bg); color: var(--danger); }
.fpill.mine { padding: 2px 10px; }
.fpill-txt { padding: 3px 6px; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: var(--r-chip); }
.fpill .pill-x { width: 20px; height: 20px; border-radius: 50%; }
.fpill .pill-x:hover { background: var(--bg-hover); }

/* popover larghi: filtro e impostazioni */
.popover:has(.filter-pop) { max-width: min(720px, calc(100vw - 16px)); }
.filter-pop { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: min(520px, calc(100vw - 32px)); }
.fc-group { display: flex; flex-direction: column; gap: 6px; }
.fc-group[data-depth="2"], .fc-group[data-depth="3"] { background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 8px 8px 8px 12px; flex: 1; min-width: 0; }
.fc-group[data-depth="3"] { background: var(--bg-hover); }
.fc-row { display: flex; align-items: center; gap: 6px; min-height: 36px; flex-wrap: wrap; }
.fc-row-group { align-items: flex-start; flex-wrap: nowrap; }
.fc-row.bad { border: 1px solid var(--danger); border-radius: var(--r-ctl); padding: 2px 6px; }
.fc-conj { width: 56px; flex: none; font-size: 13px; color: var(--text-muted); }
select.fc-conj { width: 56px; padding: 3px 4px; color: var(--text); }
.fc-prop { width: 150px; }
.fc-op { width: 130px; }
.fc-val { display: inline-flex; align-items: center; gap: 6px; flex: 1; min-width: 140px; }
.fc-group[data-depth="2"] .fc-prop, .fc-group[data-depth="3"] .fc-prop { width: 120px; }
.fc-group[data-depth="2"] .fc-op, .fc-group[data-depth="3"] .fc-op { width: 110px; }
.fc-group[data-depth="2"] .fc-val, .fc-group[data-depth="3"] .fc-val { min-width: 110px; }
.fc-val .input { min-width: 0; }
.fc-note { font-size: 12px; }
.fc-err { color: var(--danger); font-size: 13px; flex: 1; }
.fc-opts { display: flex; flex-wrap: wrap; gap: 4px 10px; }
.fc-opt { display: inline-flex; align-items: center; gap: 4px; }
.fc-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fc-foot .disabled { opacity: .5; cursor: default; }
.fc-empty { margin: 0; font-size: 14px; }
.sort-pop, .group-pop, .view-settings { padding: 12px; display: flex; flex-direction: column; gap: 8px; width: 360px; max-width: calc(100vw - 16px); }
.sort-row { display: flex; align-items: center; gap: 4px; }
.sort-row select { flex: 1 1 0; min-width: 0; width: auto; }
.hid-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; }
.type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.type-card { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border: 1px solid var(--border-input); border-radius: var(--r-lg); font-size: 12px; font-weight: 600; color: var(--text); }
.type-card:hover:not(:disabled) { background: var(--bg-hover); }
.type-card[aria-checked="true"] { background: var(--sel-bg); border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.type-card:disabled { opacity: .5; cursor: default; }
.vis-list { display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow: auto; }
.vis-list .switch { min-height: 28px; }

/* intestazione di gruppo */
.ghead-group { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 8px; }
.ghead-group.in-grid { grid-column: 1 / -1; position: sticky; left: 0; border-bottom: 1px solid var(--border); background: var(--bg); }
.gh-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 2px 4px; border-radius: var(--r-ctl); }
.gh-toggle .ic { transition: transform var(--t-fast); }
.gh-toggle.open .ic:first-child { transform: rotate(90deg); }
.gh-toggle:hover { background: var(--bg-hover); }
.gh-count { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.gh-spacer { flex: 1; }
.ghead-group .gh-add-row, .ghead-group .gh-more { opacity: 0; }
.ghead-group:hover .gh-add-row, .ghead-group:hover .gh-more, .ghead-group:focus-within .gh-add-row, .ghead-group:focus-within .gh-more { opacity: 1; }
.group-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }

/* bacheca */
.board-wrap { overflow-x: auto; padding: 12px 48px 24px; }
.board { display: flex; gap: 12px; align-items: flex-start; width: max-content; }
.bcol { width: 272px; flex: none; background: var(--bg-soft); border: 1px solid var(--border); border-radius: var(--r-column); padding: 4px 8px 8px; display: flex; flex-direction: column; }
.bcol.drop { box-shadow: inset 0 0 0 2px var(--accent); background: var(--drop-bg); }
.bcol .ghead-group { padding: 0 2px; }
.bcol .gh-count { color: var(--muted-on-soft); }
.bcards { display: flex; flex-direction: column; gap: 8px; min-height: 8px; }
.bcol-empty { margin: 4px 2px; font-size: 13px; color: var(--muted-on-soft); }
.bcard { position: relative; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-card); padding: 10px 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.bcard:hover { border-color: var(--text-muted); }
.bcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.bcard.dragging { opacity: .45; }
.bcard-title { font-size: 14px; font-weight: 600; padding-right: 24px; overflow-wrap: anywhere; }
.bcard-prop { font-size: 12px; display: flex; align-items: center; gap: 4px; min-width: 0; }
.bcard-prop .val { flex-wrap: wrap; white-space: normal; }
.bcard-more { position: absolute; top: 6px; right: 6px; opacity: 0; }
.bcard:hover .bcard-more, .bcard:focus-within .bcard-more, .bcard:focus .bcard-more { opacity: 1; }
.bdrop-line { height: 2px; background: var(--accent); border-radius: 1px; }
.bcol-new { display: flex; align-items: center; gap: 6px; height: 32px; margin-top: 6px; padding: 0 6px; border-radius: var(--r-ctl); color: var(--muted-on-soft); font-size: 13px; }
.bcol-new:hover { background: var(--bg-hover); color: var(--text); }
.bhidden { width: 200px; flex: none; padding: 4px 8px; }
.bhidden-title { margin: 6px 0; font-size: 13px; font-weight: 700; color: var(--text-muted); }

/* lista */
.list-wrap { padding: 4px 48px 24px; display: flex; flex-direction: column; }
.list { display: flex; flex-direction: column; }
.lrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; padding: 8px 12px; border-bottom: 1px solid var(--border); cursor: pointer; }
.lrow:hover { background: var(--bg-hover); }
.lrow.open { background: var(--sel-bg); }
.lrow:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.lrow-main { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.lrow-ic { color: var(--text-muted); display: inline-grid; }
.lrow-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow-props { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); min-width: 0; overflow: hidden; flex-shrink: 1; }
.lgroup { display: flex; flex-direction: column; }

/* calendario */
.cal-wrap { padding: 8px 48px 24px; }
.cal-head { display: flex; align-items: center; gap: 6px; min-height: 40px; flex-wrap: wrap; }
.cal-title { margin: 0 8px 0 0; font-size: var(--fs-title); font-weight: 800; text-transform: capitalize; }
.cal-prop { margin-left: auto; }
.cal-empty { margin: 4px 0 8px; font-size: 14px; }
.cal-grid { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.cal-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dows { background: var(--bg-soft); }
.cal-dow { padding: 6px 8px; font-size: 12px; font-weight: 600; color: var(--muted-on-soft); }
.cal-cell { min-height: 112px; border-top: 1px solid var(--border); border-left: 1px solid var(--border); padding: 4px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-row .cal-cell:first-child { border-left: 0; }
.cal-cell.weekend, .cal-cell.other { background: var(--bg-soft); }
.cal-cell.other .cal-num { color: var(--muted-on-soft); }
.cal-cell.drop { background: var(--drop-bg); box-shadow: inset 0 0 0 2px var(--accent); }
.cal-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-top { display: flex; align-items: center; justify-content: flex-end; gap: 4px; min-height: 24px; }
.cal-num { width: 24px; height: 24px; display: inline-grid; place-items: center; border-radius: 50%; font-size: 12px; font-weight: 600; }
.cal-cell.today .cal-num { background: var(--accent); color: var(--on-accent); }
.cal-add { width: 22px; height: 22px; margin-right: auto; opacity: 0; }
.cal-cell:hover .cal-add, .cal-cell:focus-within .cal-add, .cal-cell:focus .cal-add { opacity: 1; }
.cal-item { display: block; width: 100%; text-align: left; padding: 2px 6px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg); font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item:hover { border-color: var(--text-muted); }
.cal-item.dragging { opacity: .45; }
.cal-more { text-align: left; padding: 0 6px; font-size: 12px; font-weight: 600; color: var(--accent-strong); }
.cal-day-pop { padding: 12px; display: flex; flex-direction: column; gap: 8px; width: 300px; }
.cal-day-list { display: flex; flex-direction: column; gap: 4px; }
.agenda { display: flex; flex-direction: column; gap: 12px; }
.agenda-day { display: flex; flex-direction: column; gap: 4px; }
.agenda-date { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: capitalize; }

@media (max-width: 760px) {
  .view-pills, .board-wrap, .list-wrap, .cal-wrap { padding-left: 16px; padding-right: 16px; }
  .board-wrap { scroll-snap-type: x mandatory; }
  .bcol { width: 85vw; scroll-snap-align: start; }
  .tool-btn > span:last-child { display: none; }
  .view-tools { flex-wrap: wrap; }
  .filter-pop { min-width: 0; }
  .fc-prop, .fc-op { width: auto; flex: 1; }
}
@media (max-width: 1100px) {
  .tool-btn > span:last-child { font-size: 12px; }
}
.view-error { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 12px 48px; padding: 12px 14px; background: var(--error-bg); color: var(--danger); border-radius: var(--r-lg); }
.view-error p { margin: 0; flex: 1; min-width: 200px; color: var(--text); }
.cal-hint { flex-basis: 100%; margin: 0; }
@media (max-width: 760px) { .view-error { margin: 12px 16px; } }
.board-hint { margin: 0 0 8px; }
