/* Flussi trasporto: the financial statement and actual cash ledger share
   controls, but retain their own units, dates and source semantics. */
.tcf-workspace {
  --tcf-brand: #214e41;
  --tcf-border: #dfe6e1;
  --tcf-control: #809086;
  --tcf-soft: #f5f7f4;
  --tcf-muted: #53655c;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
  max-width: 100%;
  color: #253c32;
  font-size: 14px;
  line-height: 1.5;
}
.tcf-workspace *, .tcf-workspace *::before { box-sizing: border-box; }
.tcf-workspace > *, .tcf-workspace .tcf-panel, .tcf-workspace .tcf-table-scroll { min-width: 0; max-width: 100%; }
.tcf-workspace .tcf-panel { padding: 16px; background: #fff; border: 1px solid var(--tcf-border); border-radius: 12px; }
.tcf-workspace h2, .tcf-workspace h3 { margin: 0; color: var(--tcf-brand); }
.tcf-workspace h2 { font-size: 22px; }
.tcf-workspace h3 { font-size: 18px; font-weight: 650; }
.tcf-workspace p { margin: 6px 0 0; }
.tcf-workspace .tcf-intro { margin: 0; font-weight: 650; font-size: 16px; }
.tcf-workspace small, .tcf-workspace .tcf-help, .tcf-workspace .tcf-heading p { color: var(--tcf-muted); }
.tcf-workspace small { display: block; font-size: 13px; font-weight: 400; line-height: 1.4; }
.tcf-workspace .tcf-help { font-size: 13px; }
.tcf-workspace .tcf-heading { display: flex; justify-content: space-between; align-items: start; gap: 16px; }
.tcf-workspace .tcf-heading > div { min-width: 0; }
.tcf-workspace .tcf-actions, .tcf-workspace .tcf-row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.tcf-workspace .tcf-actions { flex-shrink: 0; }
.tcf-workspace .button, .tcf-workspace input, .tcf-workspace select, .tcf-workspace .tcf-tabs button, .tcf-workspace summary { min-height: 44px; }
.tcf-workspace .button { padding: 9px 12px; border: 1px solid var(--tcf-control); border-radius: 8px; white-space: nowrap; font-size: 14px; }
.tcf-workspace .primary { background: var(--tcf-brand); color: #fff; border-color: var(--tcf-brand); }
.tcf-workspace button:focus-visible, .tcf-workspace a:focus-visible, .tcf-workspace input:focus-visible, .tcf-workspace select:focus-visible, .tcf-workspace textarea:focus-visible, .tcf-workspace summary:focus-visible { outline: 3px solid #a86b20; outline-offset: 3px; }
.tcf-workspace button:disabled { opacity: .55; cursor: not-allowed; }
.tcf-workspace [hidden] { display: none !important; }
.tcf-workspace button, .tcf-workspace a { transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease; }

/* Period and scope are applied together; the month picker only fills dates. */
.tcf-workspace .tcf-tabs { display: flex; gap: 8px; margin: 12px 0; padding-bottom: 12px; border-bottom: 1px solid var(--tcf-border); }
.tcf-workspace .tcf-tabs button { padding: 9px 16px; border: 1px solid var(--tcf-control); border-radius: 8px; background: #fff; color: var(--tcf-brand); font: inherit; cursor: pointer; }
.tcf-workspace .tcf-tabs button[aria-selected=true] { background: var(--tcf-brand); border-color: var(--tcf-brand); color: #fff; font-weight: 650; }
.tcf-workspace .tcf-filters { display: grid; grid-template-columns: minmax(150px, 1.1fr) repeat(2, minmax(130px, .8fr)) minmax(160px, 1.2fr) minmax(150px, 1fr); gap: 12px; align-items: end; }
.tcf-workspace label { display: grid; gap: 6px; min-width: 0; font-size: 14px; font-weight: 600; }
.tcf-workspace input, .tcf-workspace select, .tcf-workspace textarea { width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid var(--tcf-control); border-radius: 8px; background: #fff; color: #253c32; font: inherit; }
.tcf-workspace label small { font-weight: 400; }
.tcf-workspace .tcf-filter-bottom { grid-column: 1 / -1; display: flex; gap: 16px; align-items: center; justify-content: space-between; }
.tcf-workspace .tcf-month { display: grid; grid-template-columns: auto minmax(140px, 170px); align-items: center; gap: 8px; }
.tcf-workspace .tcf-month small { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.tcf-workspace .tcf-period-basis { margin: 0; font-size: 13px; color: var(--tcf-muted); }
.tcf-workspace .tcf-status { min-height: 20px; margin-top: 10px; color: var(--tcf-muted); font-size: 13px; }
.tcf-workspace .tcf-error, .tcf-workspace .tcf-filter-error, .tcf-workspace .tcf-form-error { padding: 12px; border: 1px solid #b96c60; border-radius: 8px; background: #fff1ed; color: #8e3526; }

/* Totals stay bound to the complete API scope, independently of local search. */
.tcf-workspace .tcf-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tcf-workspace .tcf-kpis article { display: grid; gap: 5px; align-content: start; padding: 12px 14px; background: #fff; border: 1px solid var(--tcf-border); border-radius: 12px; }
.tcf-workspace .tcf-kpis article > span:first-child { color: var(--tcf-muted); font-size: 14px; font-weight: 600; }
.tcf-workspace .tcf-kpis article > strong { font-size: 23px; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tcf-workspace .tcf-kpis article > strong small { display: inline; font-size: 14px; }
.tcf-workspace .tcf-kpi-components { display: grid; gap: 3px; }
.tcf-workspace .tcf-kpi-components > span { color: var(--tcf-muted); font-size: 13px; }
.tcf-workspace .tcf-kpi-components strong { color: #253c32; font-size: 14px; }
.tcf-workspace .tcf-cash-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tcf-workspace .tcf-partial { color: #805321; }
.tcf-workspace .tcf-unavailable { color: var(--tcf-muted); }
.tcf-workspace .tcf-positive { color: var(--tcf-brand); }
.tcf-workspace .tcf-negative { color: #963f30; }
.tcf-workspace .tcf-split { display: grid; gap: 8px; }
.tcf-workspace .tcf-split > span { color: var(--tcf-muted); }
.tcf-workspace .tcf-split strong { color: #253c32; }
.tcf-workspace .tcf-unit-control { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.tcf-workspace .tcf-unit-control > span { font-weight: 600; margin-right: 4px; }
.tcf-workspace .tcf-unit-control button[aria-pressed=true] { background: var(--tcf-brand); border-color: var(--tcf-brand); color: #fff; }
.tcf-workspace .tcf-unit-control > small { flex-basis: 100%; text-align: right; }
.tcf-workspace .tcf-search-row { display: flex; align-items: end; gap: 16px; margin-top: 12px; }
.tcf-workspace .tcf-search { width: min(100%, 470px); }
.tcf-workspace .tcf-search-row > span { padding-bottom: 12px; }

/* Six columns mirror a financial statement; document details stay in a drawer. */
.tcf-workspace .tcf-table-scroll { overflow-x: auto; margin-top: 12px; }
.tcf-workspace .tcf-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tcf-workspace .tcf-table th { padding: 11px 10px; background: var(--tcf-soft); color: var(--tcf-brand); text-align: center; font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--tcf-border); }
.tcf-workspace .tcf-table td { padding: 12px 10px; text-align: center; vertical-align: middle; border-bottom: 1px solid var(--tcf-border); }
.tcf-workspace .tcf-table tbody tr:last-child td { border-bottom: 0; }
.tcf-workspace .tcf-table tfoot { background: var(--tcf-soft); }
.tcf-workspace .tcf-table tfoot td, .tcf-workspace .tcf-table tfoot th { border-top: 2px solid #c5d4ca; font-weight: 600; }
.tcf-workspace .tcf-cell-value { display: grid; gap: 4px; min-width: 0; font-variant-numeric: tabular-nums; }
.tcf-workspace .tcf-cell-value > strong { white-space: nowrap; }
.tcf-workspace .tcf-row-identity { min-width: 140px; }
.tcf-workspace .tcf-eer { white-space: nowrap; font-weight: 600; color: var(--tcf-brand); }
.tcf-workspace .tcf-description { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.tcf-workspace .tcf-menu { position: relative; }
.tcf-workspace .tcf-menu summary { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 12px; border: 1px solid var(--tcf-control); border-radius: 8px; background: #fff; cursor: pointer; }
.tcf-workspace .tcf-menu summary::after { content: '▾'; }
.tcf-workspace .tcf-menu summary::-webkit-details-marker { display: none; }
.tcf-workspace .tcf-menu[open] .tcf-row-actions { display: grid; gap: 4px; margin-top: 4px; }
.tcf-workspace .tcf-badge { display: inline-block; justify-self: center; padding: 4px 8px; border: 1px solid #c9d9cf; border-radius: 6px; background: #f2f7f3; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tcf-workspace .tcf-incomplete { color: #805321; border-color: #d4b785; background: #fff3df; }
.tcf-workspace .tcf-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: end; gap: 8px; margin-top: 16px; }
.tcf-workspace .tcf-pager > span { margin-right: auto; color: var(--tcf-muted); font-size: 13px; }
.tcf-workspace .tcf-empty { padding: 24px 16px; text-align: center; background: var(--tcf-soft); border-radius: 8px; color: var(--tcf-muted); }
.tcf-workspace .tcf-empty > strong { color: var(--tcf-brand); font-size: 16px; }
.tcf-workspace .tcf-coverage, .tcf-workspace .tcf-limitations { margin-top: 16px; }
.tcf-workspace .tcf-coverage summary, .tcf-workspace .tcf-limitations summary { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; font-weight: 600; cursor: pointer; }
.tcf-workspace .tcf-coverage-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.tcf-workspace .tcf-coverage-list > span { padding: 8px 10px; border: 1px solid var(--tcf-border); border-radius: 8px; background: var(--tcf-soft); }
.tcf-workspace .tcf-limitations ul { padding-left: 20px; color: var(--tcf-muted); line-height: 1.6; }
.tcf-workspace .tcf-sr { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Native dialogs retain keyboard trapping; the close action restores focus. */
.tcf-workspace .tcf-dialog { width: min(860px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); margin: auto; padding: 0; border: 1px solid var(--tcf-border); border-radius: 12px; background: #fff; color: #253c32; box-shadow: 0 24px 80px #1735283b; }
.tcf-workspace .tcf-dialog::backdrop { background: #102d2373; }
.tcf-workspace .tcf-dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; border-bottom: 1px solid var(--tcf-border); background: #fff; }
.tcf-workspace .tcf-dialog-head h2 { font-size: 20px; }
.tcf-workspace .tcf-dialog-body { padding: 16px; }
.tcf-workspace .tcf-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.tcf-workspace .tcf-full { grid-column: 1 / -1; }
.tcf-workspace .tcf-dialog-footer { position: sticky; bottom: -16px; z-index: 1; display: flex; flex-wrap: wrap; align-items: center; justify-content: end; gap: 8px; margin: 16px -16px -16px; padding: 12px 16px; border-top: 1px solid var(--tcf-border); background: #fff; }
.tcf-workspace .tcf-dialog-footer > span { margin-right: auto; max-width: 360px; font-size: 13px; color: var(--tcf-muted); }
.tcf-workspace .tcf-field-error { color: #943928; }
.tcf-workspace .tcf-document-heading { display: grid; gap: 8px; margin-bottom: 16px; }
.tcf-workspace .tcf-document-heading > strong { font-size: 19px; }
.tcf-workspace .tcf-document-heading .button { justify-self: start; }
.tcf-workspace .tcf-detail { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; }
.tcf-workspace .tcf-detail > div { display: grid; gap: 6px; padding: 12px; border: 1px solid var(--tcf-border); border-radius: 8px; }
.tcf-workspace dt { color: var(--tcf-muted); font-weight: 600; }
.tcf-workspace dd { display: grid; gap: 5px; margin: 0; overflow-wrap: anywhere; }
.tcf-workspace .tcf-detail-reasons { margin-top: 16px; }
.tcf-workspace .tcf-detail-reasons ul { padding-left: 20px; color: #805321; }
.tcf-workspace .tcf-audit { display: grid; gap: 16px; padding-left: 24px; }
.tcf-workspace .tcf-audit li { padding: 0 0 12px 4px; border-bottom: 1px solid var(--tcf-border); }
.tcf-workspace .tcf-audit li > span { display: block; margin: 4px 0; color: var(--tcf-muted); }

@media (max-width: 1100px) {
  .tcf-workspace .tcf-heading { flex-wrap: wrap; }
  .tcf-workspace .tcf-actions { flex-shrink: 1; }
  .tcf-workspace .tcf-filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tcf-workspace .tcf-filters > label:first-child { grid-column: 1 / -1; }
  .tcf-workspace .tcf-filter-bottom { flex-wrap: wrap; }
  .tcf-workspace .tcf-period-basis { margin-left: auto; }
  .tcf-workspace .tcf-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tcf-workspace .tcf-cash-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .tcf-workspace { gap: 12px; }
  .tcf-workspace .tcf-panel { padding: 12px; }
  .tcf-workspace .tcf-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .tcf-workspace .tcf-actions button:first-child { grid-column: 1 / -1; }
  .tcf-workspace .tcf-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tcf-workspace .tcf-tabs button { padding: 8px; }
  .tcf-workspace .tcf-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tcf-workspace .tcf-filters > label:nth-child(4), .tcf-workspace .tcf-filters > label:nth-child(5) { grid-column: 1 / -1; }
  .tcf-workspace .tcf-filter-bottom { display: grid; grid-template-columns: 1fr; gap: 12px; }
  .tcf-workspace .tcf-month { grid-template-columns: 1fr; }
  .tcf-workspace .tcf-period-basis { margin-left: 0; }
  .tcf-workspace .tcf-kpis, .tcf-workspace .tcf-cash-kpis { grid-template-columns: 1fr; }
  .tcf-workspace .tcf-unit-control > small { text-align: left; }
  .tcf-workspace .tcf-search-row { display: grid; gap: 4px; }
  .tcf-workspace .tcf-search { width: 100%; }
  .tcf-workspace .tcf-search-row > span { padding-bottom: 0; }

  /* Card values have one explicit wrapper, so multiline amounts stay beside
     the label instead of slipping into the label column on the next line. */
  .tcf-workspace .tcf-table, .tcf-workspace .tcf-table tbody, .tcf-workspace .tcf-table tfoot, .tcf-workspace .tcf-table tr { display: block; width: 100%; }
  .tcf-workspace .tcf-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  .tcf-workspace .tcf-table tr { padding: 4px 12px; margin-bottom: 12px; border: 1px solid var(--tcf-border); border-radius: 8px; background: #fff; }
  .tcf-workspace .tcf-table tfoot tr { background: var(--tcf-soft); }
  .tcf-workspace .tcf-table td, .tcf-workspace .tcf-table tfoot th { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 12px; width: 100%; padding: 9px 0; border: 0; }
  .tcf-workspace .tcf-table td::before, .tcf-workspace .tcf-table tfoot th::before { content: attr(data-label); color: var(--tcf-muted); font-weight: 600; font-size: 13px; text-align: left; white-space: normal; }
  .tcf-workspace .tcf-cell-value { grid-column: 2; min-width: 0; }
  .tcf-workspace .tcf-cell-value > strong { white-space: normal; overflow-wrap: anywhere; }
  .tcf-workspace .tcf-row-identity { min-width: 0; }
  .tcf-workspace .tcf-description { -webkit-line-clamp: unset; }
  .tcf-workspace .tcf-badge { white-space: normal; }
  .tcf-workspace .tcf-dialog { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; border: 0; border-radius: 0; }
  .tcf-workspace .tcf-dialog-head { padding: 12px; }
  .tcf-workspace .tcf-dialog-head h2 { font-size: 18px; }
  .tcf-workspace .tcf-dialog-body { padding: 12px; }
  .tcf-workspace .tcf-form-grid, .tcf-workspace .tcf-detail { grid-template-columns: 1fr; }
  .tcf-workspace .tcf-dialog-footer { bottom: -12px; margin: 16px -12px -12px; padding: 12px; }
  .tcf-workspace .tcf-dialog-footer > span { width: 100%; max-width: none; }
  .tcf-workspace .tcf-dialog-footer .button { flex: 1; }

  /* The shared table enhancer remains desktop-only; cards use page scrolling. */
  .tcf-workspace .tcf-table { width: 100% !important; min-width: 0 !important; max-width: 100%; zoom: 1 !important; }
  .tcf-workspace .tcf-table colgroup, .tcf-workspace .table-zoom-toolbar { display: none; }
  .tcf-workspace .tcf-table-scroll, .tcf-workspace .table-scroll, .tcf-workspace .table-zoom-frame { width: 100% !important; min-width: 0 !important; max-width: 100%; height: auto !important; max-height: none !important; overflow: visible; scrollbar-gutter: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .tcf-workspace button, .tcf-workspace a { transition: none; }
}
