/* MMCM Tables – eredita colori e font dal tema; accenti via variabili. */
.mmcm-t {
  --mmcm-line: rgba(128, 128, 128, .28);
  --mmcm-zebra: rgba(128, 128, 128, .07);
  --mmcm-hover: rgba(128, 128, 128, .14);
  --mmcm-accent: #c0143c;
  --mmcm-radius: 6px;
  --mmcm-pop-bg: #fff;   /* menu a tendina multi-selezione: sovrascrivere nel tema se scuro */
  --mmcm-pop-fg: #111;
  font: inherit;
  color: inherit;
  margin: 1.5em 0;
}
@supports (color: color-mix(in srgb, red, blue)) {
  .mmcm-t {
    --mmcm-line: color-mix(in srgb, currentColor 22%, transparent);
    --mmcm-zebra: color-mix(in srgb, currentColor 5%, transparent);
    --mmcm-hover: color-mix(in srgb, currentColor 11%, transparent);
  }
}
.mmcm-t *, .mmcm-t *::before, .mmcm-t *::after { box-sizing: border-box; }

.mmcm-t__bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .75rem; }
.mmcm-t__search { flex: 1 1 14rem; min-width: 0; }
.mmcm-t input, .mmcm-t select, .mmcm-t summary, .mmcm-t__btn {
  font: inherit; color: inherit; background: transparent;
  border: 1px solid var(--mmcm-line); border-radius: var(--mmcm-radius);
  padding: .4rem .6rem; min-height: 2.25rem;
}
.mmcm-t select option { color: #111; background: #fff; }
.mmcm-t input:focus-visible, .mmcm-t select:focus-visible, .mmcm-t summary:focus-visible,
.mmcm-t button:focus-visible, .mmcm-t__scroll:focus-visible { outline: 2px solid var(--mmcm-accent); outline-offset: 2px; }
.mmcm-t__btn { cursor: pointer; }
.mmcm-t__btn:hover { background: var(--mmcm-hover); }
.mmcm-t__btn[hidden] { display: none; }

/* filtri */
.mmcm-t__filters {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr));
  gap: .5rem .75rem; margin-bottom: 1rem;
}
.mmcm-t__field { display: flex; flex-direction: column; gap: .2rem; min-width: 0; position: relative; }
.mmcm-t__field > label { font-size: .78em; opacity: .75; }
.mmcm-t__field > input, .mmcm-t__field > select { width: 100%; }

.mmcm-ms { position: relative; }
.mmcm-ms > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.mmcm-ms__txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mmcm-ms > summary::-webkit-details-marker { display: none; }
.mmcm-ms > summary::after { content: '▾'; opacity: .6; flex: none; }
.mmcm-ms__list {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 2px);
  max-height: 16rem; overflow: auto; padding: .35rem;
  background: var(--mmcm-pop-bg); color: var(--mmcm-pop-fg);
  border: 1px solid var(--mmcm-line); border-radius: var(--mmcm-radius);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.mmcm-ms__opt { display: flex; gap: .5rem; align-items: center; padding: .3rem .35rem; border-radius: 4px; cursor: pointer; }
.mmcm-ms__opt:hover { background: var(--mmcm-hover); }
.mmcm-ms__opt input { min-height: 0; width: auto; padding: 0; }

/* tabella */
.mmcm-t__scroll { overflow-x: auto; border: 1px solid var(--mmcm-line); border-radius: var(--mmcm-radius); -webkit-overflow-scrolling: touch; }
.mmcm-t__table { width: 100%; border-collapse: collapse; font-size: .94em; }
.mmcm-t__table th, .mmcm-t__table td { padding: .5rem .7rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--mmcm-line); }
.mmcm-t__table tbody tr:nth-child(even) { background: var(--mmcm-zebra); }
.mmcm-t__table tbody tr:hover { background: var(--mmcm-hover); }
.mmcm-t__table tbody tr:last-child td { border-bottom: 0; }
.mmcm-t__table td.is-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.mmcm-t__table thead th { background: var(--mmcm-hover); white-space: nowrap; }
.mmcm-t__sort {
  all: unset; display: inline-flex; gap: .35rem; align-items: center; cursor: pointer; font-weight: 600;
}
.mmcm-t__sort:focus-visible { outline: 2px solid var(--mmcm-accent); outline-offset: 2px; }
.mmcm-t__arrow { font-size: .75em; min-width: 1em; color: var(--mmcm-accent); }
.mmcm-t__empty { text-align: center; padding: 2rem 1rem !important; opacity: .7; }
.mmcm-t__flag { color: var(--mmcm-accent); }
.mmcm-t__img { max-height: 2.5rem; width: auto; display: block; }
.mmcm-t--loading .mmcm-t__scroll { opacity: .55; transition: opacity .15s; }

/* piede */
.mmcm-t__status:empty { display: none; }
.mmcm-t__status { padding: .5rem 0; }
.mmcm-t__foot { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: center; margin-top: .75rem; font-size: .9em; }
.mmcm-t__info { opacity: .8; }
.mmcm-t__pager { display: flex; flex-wrap: wrap; gap: .25rem; }
.mmcm-t__pg {
  font: inherit; color: inherit; background: transparent; cursor: pointer; min-width: 2.25rem; min-height: 2.25rem;
  border: 1px solid var(--mmcm-line); border-radius: var(--mmcm-radius); padding: 0 .5rem;
}
.mmcm-t__pg:hover:not(:disabled) { background: var(--mmcm-hover); }
.mmcm-t__pg:disabled { opacity: .35; cursor: default; }
.mmcm-t__pg.is-current { background: var(--mmcm-accent); border-color: var(--mmcm-accent); color: #fff; }

@media (max-width: 600px) {
  .mmcm-t__filters { grid-template-columns: 1fr 1fr; }
  .mmcm-t__table { font-size: .88em; }
  .mmcm-t__table th, .mmcm-t__table td { padding: .4rem .5rem; }
}
@media (prefers-reduced-motion: reduce) { .mmcm-t--loading .mmcm-t__scroll { transition: none; } }

/* titolo, stato, azioni */
.mmcm-t__title { margin: 0 0 .6rem; }
.mmcm-t__status.is-error { color: #c0143c; }
.mmcm-t__actions { white-space: nowrap; }
.mmcm-t__actions .mmcm-t__btn { min-height: 0; padding: .2rem .55rem; margin-right: .3rem; font-size: .9em; }
.mmcm-t__table a { color: var(--mmcm-accent); }
.mmcm-t__table td[style*="background"] a { color: inherit; text-decoration: underline; }
.mmcm-t__btn--primary { background: var(--mmcm-accent); border-color: var(--mmcm-accent); color: #fff; }
.mmcm-t__btn--primary:hover { background: var(--mmcm-accent); filter: brightness(1.1); }
.mmcm-t__btn--danger { color: #c0143c; }
.mmcm-t__btn:disabled { opacity: .5; cursor: default; }

/* finestra di modifica (appesa al body, fuori da .mmcm-t) */
dialog.mmcm-e {
  --mmcm-line: rgba(128, 128, 128, .4); --mmcm-accent: #c0143c; --mmcm-hover: rgba(128, 128, 128, .15);
  background: #fff; color: #111; border: 1px solid var(--mmcm-line); border-radius: 10px;
  padding: 1.25rem; width: min(34rem, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow: auto;
}
dialog.mmcm-e::backdrop { background: rgba(0, 0, 0, .5); }
dialog.mmcm-e * { box-sizing: border-box; }
.mmcm-e__title { margin: 0 0 1rem; font-size: 1.15rem; }
.mmcm-e__row { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .8rem; }
.mmcm-e__row > label { font-size: .85em; opacity: .8; }
.mmcm-e__row input, .mmcm-e__row select, .mmcm-e__row textarea {
  font: inherit; color: inherit; background: #fff; width: 100%; padding: .45rem .6rem; border: 1px solid var(--mmcm-line); border-radius: 6px;
}
.mmcm-e__row input:focus-visible, .mmcm-e__row select:focus-visible, .mmcm-e__row textarea:focus-visible,
.mmcm-e button:focus-visible { outline: 2px solid var(--mmcm-accent); outline-offset: 2px; }
.mmcm-e__err, .mmcm-e__msg { color: #b00020; font-size: .85em; }
.mmcm-e__err:empty, .mmcm-e__msg:empty { display: none; }
.mmcm-e__foot { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }
.mmcm-e .mmcm-t__btn { font: inherit; cursor: pointer; padding: .4rem .9rem; border: 1px solid var(--mmcm-line); border-radius: 6px; background: transparent; color: inherit; }
.mmcm-e .mmcm-t__btn--primary { background: var(--mmcm-accent); border-color: var(--mmcm-accent); color: #fff; }

/* grafici */
.mmcm-c { margin: 1.5em 0; font: inherit; color: inherit; }
.mmcm-c__data { margin-top: .75rem; font-size: .9em; }
.mmcm-c__data summary { cursor: pointer; opacity: .75; }
.mmcm-c__data table { width: 100%; border-collapse: collapse; margin-top: .5rem; }
.mmcm-c__data th, .mmcm-c__data td { padding: .3rem .6rem; text-align: left; border-bottom: 1px solid rgba(128,128,128,.28); }

/* impaginazione come in wpDataTables: senza "word wrap" ogni cella resta su una riga (si scorre in orizzontale) */
.mmcm-t--nowrap .mmcm-t__table td, .mmcm-t--nowrap .mmcm-t__table th { white-space: nowrap; }
.mmcm-t--fixed .mmcm-t__table { table-layout: fixed; }
.mmcm-t--fixed .mmcm-t__table td, .mmcm-t--fixed .mmcm-t__table th { overflow: hidden; text-overflow: ellipsis; }
.mmcm-t__table .mmcm-a-r { text-align: right; }
.mmcm-t__table .mmcm-a-c { text-align: center; }
.mmcm-t__table th.mmcm-a-r .mmcm-t__sort { flex-direction: row-reverse; }
.mmcm-t__table th.mmcm-a-c .mmcm-t__sort { justify-content: center; }
.mmcm-t__table thead th { vertical-align: middle; }
.mmcm-t__table thead .mmcm-t__sort { vertical-align: middle; line-height: 1.3; }
