/* =====================================================================
   Esteria — tema applicativo (sopra Bootstrap 5.3)
   ===================================================================== */

@font-face { font-family: "Plex"; src: url("vendor/fonts/plex-sans-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("vendor/fonts/plex-sans-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url("vendor/fonts/plex-sans-600.woff2") format("woff2"); font-weight: 600 700; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("vendor/fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }

:root {
  --ink: #1b1f24;
  --ink-2: #3d444d;
  --muted: #6b737d;
  --faint: #9aa1a9;
  --line: #e3e5e8;
  --line-2: #eef0f2;
  --canvas: #f6f7f8;
  --surface: #ffffff;
  --accent: #1d4f4a;
  --accent-hover: #163e3a;
  --accent-soft: #e8f0ee;
  --accent-ink: #1d4f4a;
  --ok: #1f7a4d;   --ok-soft: #e7f4ec;
  --warn: #9a5b00; --warn-soft: #fbf1df;
  --bad: #b3261e;  --bad-soft: #fbe9e7;
  --info: #28589c; --info-soft: #e8eff9;
  --radius: 8px;
  --sidebar-w: 236px;

  --bs-body-font-family: "Plex", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-font-monospace: "Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --bs-body-font-size: 0.875rem;
  --bs-body-line-height: 1.5;
  --bs-body-color: var(--ink);
  --bs-body-bg: var(--canvas);
  --bs-secondary-color: var(--muted);
  --bs-border-color: var(--line);
  --bs-border-radius: 6px;
  --bs-border-radius-sm: 5px;
  --bs-border-radius-lg: var(--radius);
  --bs-link-color: var(--accent);
  --bs-link-color-rgb: 29, 79, 74;
  --bs-link-hover-color: var(--accent-hover);
  --bs-primary: var(--accent);
  --bs-primary-rgb: 29, 79, 74;
  --bs-focus-ring-color: rgba(29, 79, 74, .18);
  --bs-heading-color: var(--ink);
}

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { background: var(--canvas); color: var(--ink); letter-spacing: -0.003em; }
h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -0.01em; }
a { text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code { color: var(--ink-2); background: var(--line-2); padding: 1px 5px; border-radius: 4px; font-size: .82em; }
.muted { color: var(--muted); }
.small-note { font-size: .8rem; color: var(--muted); }
.num, .tnum { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- shell */
.shell { min-height: 100vh; }
.sidebar {
  background-color: var(--surface) !important; /* .offcanvas-lg lo rende trasparente su desktop */
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
@media (min-width: 992px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1030; }
  .main { margin-left: var(--sidebar-w); }
}
@media (max-width: 991.98px) {
  .sidebar { --bs-offcanvas-width: 264px; }
}
.sb-brand { display: flex; align-items: center; justify-content: space-between; height: 56px; padding: 0 16px 0 18px; border-bottom: 1px solid var(--line-2); }
.sb-brand a { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; font-size: .95rem; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; color: var(--accent); flex: none; }

.sb-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 1px; }
.sb-label { font-size: .7rem; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: .06em; padding: 18px 10px 6px; }
.sb-link {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 6px;
  color: var(--ink-2); font-weight: 500; font-size: .86rem;
}
.sb-link i { font-size: 1rem; color: var(--faint); width: 18px; text-align: center; }
.sb-link:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.sb-link.active { background: var(--accent-soft); color: var(--accent-ink); }
.sb-link.active i { color: var(--accent); }

.sb-user { border-top: 1px solid var(--line-2); padding: 10px; }
.sb-user-btn {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left;
  background: none; border: 0; border-radius: 6px; padding: 6px 8px; color: var(--ink);
}
.sb-user-btn:hover { background: var(--line-2); }
.sb-user-btn .who { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.sb-user-btn .who strong { font-weight: 500; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-btn .who small { color: var(--muted); font-size: .74rem; }
.sb-user-btn > i { color: var(--faint); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--line-2); color: var(--ink-2); display: grid; place-items: center; font-size: .74rem; font-weight: 600; flex: none; border: 1px solid var(--line); }
.sb-user .dropdown-menu { width: calc(100% - 20px); }

.topbar {
  position: sticky; top: 0; z-index: 1020;
  height: 56px; display: flex; align-items: center; gap: 12px;
  padding: 0 28px; background: rgba(246, 247, 248, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.topbar-context { color: var(--muted); font-size: .82rem; }
.topbar-context i { margin-right: 4px; }
.topbar-context strong { color: var(--ink-2); font-weight: 500; }
.client-picker { display: flex; align-items: center; gap: 8px; }
.topbar-bell { margin-left: auto; position: relative; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; color: var(--ink-2); font-size: 1.1rem; }
.topbar-bell:hover, .topbar-bell.active { background: var(--line-2); color: var(--ink); text-decoration: none; }
.bell-badge { position: absolute; top: 3px; right: 1px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--bad); color: #fff; font-size: .66rem; font-weight: 600; line-height: 17px; text-align: center; font-variant-numeric: tabular-nums; box-shadow: 0 0 0 2px var(--canvas); }
tr.notif-unread td { font-weight: 500; }
tr.notif-unread td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.notif-body { white-space: pre-wrap; color: var(--ink-2); }
.notif-row { cursor: pointer; }
.client-picker label { color: var(--muted); font-size: .8rem; }
.client-picker select { min-width: 260px; max-width: 360px; background-color: var(--surface); }
.btn-icon { border: 1px solid var(--line); background: var(--surface); width: 34px; height: 34px; padding: 0; display: grid; place-items: center; font-size: 1.1rem; }

.content { padding: 28px 28px 56px; max-width: 1480px; }

/* ---------------------------------------------------------------- page header */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 22px; }
.page-head h1 { font-size: 1.35rem; margin: 0; }
.page-head .sub { color: var(--muted); margin: 4px 0 0; max-width: 72ch; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.page-actions .btn { white-space: nowrap; }
.context-bar { display: inline-flex; gap: 6px; align-items: baseline; font-size: .84rem; margin-bottom: 14px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }

/* ---------------------------------------------------------------- panels */
.card-app { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.card-app > h2, .panel-title { font-size: .95rem; font-weight: 600; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.card-app > h2 i { color: var(--faint); font-size: 1rem; }
.card-app.flush { padding: 0; }
.card-app.flush .panel-head { padding: 14px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.card-app.flush .panel-body { padding: 4px 18px 16px; }
.card-app .card-app { border-color: var(--line-2); }

/* KPI: un'unica fascia divisa, non card separate */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.kpi { padding: 16px 20px; border-right: 1px solid var(--line-2); color: inherit; display: block; }
.kpi:last-child { border-right: 0; }
a.kpi:hover { background: #fafbfb; text-decoration: none; }
.kpi .label { color: var(--muted); font-size: .78rem; font-weight: 500; }
.kpi .value { font-size: 1.55rem; font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; letter-spacing: -0.02em; }
.kpi .value.sm { font-size: 1rem; font-weight: 500; margin-top: 8px; }
.kpi .hint { color: var(--muted); font-size: .76rem; margin-top: 2px; }
.kpi.warn .value { color: var(--warn); }
.kpi.ok .value { color: var(--ok); }
@media (max-width: 767.98px) { .kpi { border-right: 0; border-bottom: 1px solid var(--line-2); } }

/* stat compatte (manutenzione) */
.stat { background: var(--surface); border: 1px solid var(--line-2); border-radius: 6px; padding: 12px 14px; height: 100%; }
.stat .label { color: var(--muted); font-size: .76rem; font-weight: 500; }
.stat .value { font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 12px; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 34px; color: var(--ink-2); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line); color: var(--muted); font-size: .72rem; font-weight: 600; display: grid; place-items: center; background: var(--surface); }

.empty { text-align: center; padding: 64px 16px; color: var(--muted); }
.empty i { font-size: 1.8rem; color: var(--faint); }
.empty h2 { font-size: 1rem; margin: 12px 0 4px; color: var(--ink); }
.empty p { margin: 0; }

/* ---------------------------------------------------------------- pill / badge */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 500; line-height: 1; padding: 4px 8px; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.pill.no-dot::before, .pill-neutral::before { display: none; }
.pill-ok { color: var(--ok); background: var(--ok-soft); }
.pill-warn { color: var(--warn); background: var(--warn-soft); }
.pill-bad { color: var(--bad); background: var(--bad-soft); }
.pill-info { color: var(--info); background: var(--info-soft); }
.pill-accent { color: var(--accent); background: var(--accent-soft); }
.pill-neutral { color: var(--ink-2); background: var(--line-2); border-color: var(--line); }
.tag { display: inline-block; font-size: .7rem; font-weight: 500; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; line-height: 1.5; margin-left: 4px; }

.badge { font-weight: 500; }
.score { display: inline-block; min-width: 44px; text-align: center; border-radius: 4px; padding: 2px 6px; font-size: .75rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.score.hi { background: var(--ok-soft); color: var(--ok); }
.score.mid { background: var(--warn-soft); color: var(--warn); }
.score.lo { background: var(--line-2); color: var(--muted); }

/* ---------------------------------------------------------------- bottoni e form */
.btn { font-weight: 500; font-size: .84rem; --bs-btn-padding-y: .4rem; --bs-btn-padding-x: .8rem; border-radius: 6px; }
.btn-sm { font-size: .78rem; --bs-btn-padding-y: .22rem; --bs-btn-padding-x: .55rem; }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent-hover); --bs-btn-hover-border-color: var(--accent-hover); --bs-btn-active-bg: var(--accent-hover); --bs-btn-active-border-color: var(--accent-hover); --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); }
.btn-outline-primary, .btn-outline-secondary, .btn-light {
  --bs-btn-color: var(--ink-2); --bs-btn-bg: var(--surface); --bs-btn-border-color: var(--line);
  --bs-btn-hover-color: var(--ink); --bs-btn-hover-bg: #f3f4f5; --bs-btn-hover-border-color: #d5d8dc;
  --bs-btn-active-color: var(--ink); --bs-btn-active-bg: #eceef0; --bs-btn-active-border-color: #d5d8dc;
  --bs-btn-disabled-color: var(--faint); --bs-btn-disabled-bg: var(--surface); --bs-btn-disabled-border-color: var(--line);
}
.btn-outline-danger { --bs-btn-color: var(--bad); --bs-btn-border-color: var(--line); --bs-btn-bg: var(--surface); --bs-btn-hover-bg: var(--bad-soft); --bs-btn-hover-color: var(--bad); --bs-btn-hover-border-color: #efc4bf; }
.btn-danger { --bs-btn-bg: var(--bad); --bs-btn-border-color: var(--bad); --bs-btn-hover-bg: #962019; --bs-btn-hover-border-color: #962019; }
.form-label { font-weight: 500; font-size: .8rem; color: var(--ink-2); margin-bottom: 5px; }
.form-control, .form-select { border-color: var(--line); font-size: .86rem; padding: .42rem .65rem; background-color: var(--surface); }
.form-control-sm, .form-select-sm { font-size: .8rem; padding-top: .28rem; padding-bottom: .28rem; }
.form-control::placeholder { color: var(--faint); }
.form-control:focus, .form-select:focus { border-color: #8fb0ab; box-shadow: 0 0 0 3px var(--bs-focus-ring-color); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--bs-focus-ring-color); border-color: #8fb0ab; }
.form-check-label { color: var(--ink-2); }
.form-switch .form-check-input { width: 2.1em; }

/* segmented control */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: #eceef0; border-radius: 8px; margin-bottom: 16px; }
.segmented button { border: 0; background: none; border-radius: 6px; padding: 6px 12px; font-size: .84rem; font-weight: 500; color: var(--ink-2); display: inline-flex; align-items: center; gap: 8px; }
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 32, .08), 0 0 0 1px rgba(16, 24, 32, .04); }
.segmented .count { font-size: .72rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); background: rgba(0, 0, 0, .05); border-radius: 999px; padding: 1px 7px; }
.segmented button.active .count { background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- tabelle */
.table { --bs-table-bg: var(--surface); --bs-table-color: var(--ink); --bs-table-hover-bg: #f7f8f9; --bs-table-hover-color: var(--ink); --bs-table-border-color: var(--line-2); margin-bottom: 0; }
.table > thead th { font-size: .74rem; font-weight: 500; color: var(--muted); letter-spacing: .01em; border-bottom: 1px solid var(--line) !important; white-space: nowrap; background: var(--surface) !important; box-shadow: none !important; }
.table > :not(caption) > * > * { padding: .6rem .65rem; }
.table-sm > :not(caption) > * > * { padding: .4rem .5rem; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.nowrap { white-space: nowrap; }
table.dataTable th.dt-type-date, table.dataTable td.dt-type-date { text-align: left; }
table.dataTable th.dt-type-numeric:not(.num), table.dataTable td.dt-type-numeric:not(.num) { text-align: left; }
table.dataTable > tbody > tr > .sorting_1 { box-shadow: none !important; }
.desc-cell { max-width: 340px; }
.sub-line.clip { max-width: 340px; }
.desc-cell .clip { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { white-space: nowrap; text-align: right; }
.actions .btn { padding: .2rem .42rem; line-height: 1; margin-left: 2px; }
.actions .btn i { font-size: .9rem; }
.btn-vis-group { display: inline-flex; vertical-align: middle; margin-left: 2px; }
.btn-vis-group .btn { margin-left: 0; border-radius: 0; }
.btn-vis-group .btn:first-child { border-radius: 6px 0 0 6px; }
.btn-vis-group .btn:last-child { border-radius: 0 6px 6px 0; margin-left: -1px; }
.btn-vis-group .btn.btn-primary { position: relative; z-index: 1; }
.sub-line { display: block; font-size: .75rem; color: var(--muted); margin-top: 1px; }

/* DataTables */
div.dt-container { font-size: .84rem; }
div.dt-container .dt-layout-row { margin: 0 !important; }
div.dt-container .dt-layout-row:first-child { padding-bottom: 12px; }
div.dt-container .dt-layout-row:last-child { padding-top: 14px; }
div.dt-container .dt-search input { border: 1px solid var(--line); border-radius: 6px; font-size: .82rem; padding: .34rem .7rem .34rem 2rem; width: 280px; margin-left: 0 !important;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='%239aa1a9' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10'/%3E%3C/svg%3E") no-repeat 10px center; }
div.dt-container .dt-length select { border: 1px solid var(--line); border-radius: 6px; font-size: .8rem; padding: .25rem 1.9rem .25rem .6rem; background-position: right .5rem center; width: auto; display: inline-block; margin-right: 6px; }
div.dt-container .dt-layout-end { gap: 16px; }
.dt-export { display: flex; gap: 6px; }
.dt-export .btn i { margin-right: 3px; }
div.dt-container .dt-layout-cell.dt-layout-end { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
div.dt-container .dt-layout-table > div, div.dt-container .dt-layout-table { overflow-x: auto; }
div.dt-container .dt-search label, div.dt-container .dt-length label, div.dt-container .dt-info { color: var(--muted); font-size: .8rem; }
div.dt-container .dt-paging .pagination { --bs-pagination-font-size: .8rem; --bs-pagination-padding-x: .6rem; --bs-pagination-padding-y: .25rem; --bs-pagination-color: var(--ink-2); --bs-pagination-border-color: var(--line); --bs-pagination-hover-bg: var(--line-2); --bs-pagination-hover-color: var(--ink); --bs-pagination-active-bg: var(--accent); --bs-pagination-active-border-color: var(--accent); --bs-pagination-focus-box-shadow: 0 0 0 3px var(--bs-focus-ring-color); margin: 0; }
table.dataTable thead > tr > th.dt-orderable-asc span.dt-column-order, table.dataTable thead > tr > th.dt-orderable-desc span.dt-column-order { opacity: .5; }
table.dataTable > tbody > tr.selected > * { box-shadow: inset 0 0 0 9999px var(--accent-soft); color: var(--ink); }
table.dataTable thead tr.filters th { padding: 0 .4rem 8px !important; border-bottom: 1px solid var(--line) !important; cursor: default; }
table.dataTable thead tr:first-child th { border-bottom: 0 !important; padding-bottom: .35rem; }
table.dataTable thead tr.filters th::before, table.dataTable thead tr.filters th::after, table.dataTable thead tr.filters .dt-column-order { display: none !important; }
table.dataTable thead tr.filters input { width: 100%; min-width: 56px; font-size: .76rem; padding: 3px 7px; border: 1px solid var(--line-2); border-radius: 5px; background: #fafbfb; color: var(--ink); font-weight: 400; }
table.dataTable thead tr.filters input::placeholder { color: #b7bcc2; }
table.dataTable thead tr.filters input:hover { border-color: var(--line); }
table.dataTable thead tr.filters input:focus { outline: none; background: var(--surface); border-color: #8fb0ab; box-shadow: 0 0 0 2px var(--bs-focus-ring-color); }
.table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------- componenti vari */
.alert { border-radius: 6px; font-size: .86rem; border-width: 1px; }
.alert-success { --bs-alert-bg: var(--ok-soft); --bs-alert-color: #185f3c; --bs-alert-border-color: #cde8d8; }
.alert-warning { --bs-alert-bg: var(--warn-soft); --bs-alert-color: #7a4800; --bs-alert-border-color: #f1dfb8; }
.alert-danger { --bs-alert-bg: var(--bad-soft); --bs-alert-color: #8f1e18; --bs-alert-border-color: #f3cdc8; }
.alert-info, .alert-light { --bs-alert-bg: #f7f8f9; --bs-alert-color: var(--ink-2); --bs-alert-border-color: var(--line); }

.modal-content { border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 40px rgba(16, 24, 32, .14); }
.modal-header { border-bottom-color: var(--line-2); padding: 14px 20px; }
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 18px 20px; }
.modal-footer { border-top-color: var(--line-2); padding: 12px 20px; }
.modal-backdrop.show { opacity: .35; }
.dropdown-menu { border-color: var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(16, 24, 32, .1); font-size: .85rem; padding: 4px; }
.dropdown-item { border-radius: 5px; padding: 6px 10px; }
.dropdown-item i { color: var(--muted); margin-right: 6px; }
.dropdown-item:active { background: var(--accent-soft); color: var(--ink); }
.toast { border-radius: 8px; font-size: .85rem; }

.summary { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: #fafbfb; margin-bottom: 14px; }
.summary .k { color: var(--muted); font-size: .76rem; display: block; }
.summary .v { font-weight: 500; }
.dl-grid { display: grid; grid-template-columns: 170px 1fr; gap: 6px 16px; margin: 0; }
.dl-grid dt { font-weight: 400; color: var(--muted); }
.dl-grid dd { margin: 0; word-break: break-word; }
@media (max-width: 575.98px) { .dl-grid { grid-template-columns: 1fr; } .dl-grid dd { margin-bottom: 6px; } }
.headers-pre { max-height: 50vh; overflow: auto; background: #f7f8f9; border: 1px solid var(--line); color: var(--ink-2); padding: 12px 14px; border-radius: 6px; font-size: .76rem; white-space: pre-wrap; word-break: break-all; font-family: var(--bs-font-monospace); }

.dropzone { display: block; border: 1px dashed #c5cbd1; border-radius: 8px; padding: 26px 16px; text-align: center; background: #fbfbfc; cursor: pointer; transition: border-color .12s, background .12s; color: var(--ink-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone i { font-size: 1.5rem; color: var(--muted); }
.dropzone strong { font-weight: 500; color: var(--ink); }
.file-list { list-style: none; padding: 0; margin: 12px 0 0; }
.file-list li { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 6px; background: var(--surface); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.file-list li i { color: var(--muted); margin-right: 6px; }
.result-line { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 8px; background: var(--surface); }
.result-line .bi-check-circle { color: var(--ok); }
.result-line .bi-x-circle { color: var(--bad); }

.kv-list { list-style: none; padding: 0; margin: 0; }
.kv-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.kv-list li:last-child { border-bottom: 0; }

/* ---------------------------------------------------------------- confronto fatture / movimenti */
.cmp-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; font-size: .8rem; color: var(--ink-2); margin-bottom: 12px; }
.cmp-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--line); vertical-align: -1px; margin-right: 4px; }
.cmp-legend .sw-ok { background: var(--ok-soft); border-color: #cde8d8; }
.cmp-legend .sw-bad { background: var(--bad-soft); border-color: #f3cdc8; }
.cmp-legend .sw-none { background: var(--surface); }
.cmp-card { padding: 8px 12px 12px; }
.sm-table { min-width: 720px; border-collapse: collapse; }
.sm-table > thead > tr > th, .sm-table > tbody > tr > td { border: 1px solid #cfd4da !important; vertical-align: middle; }
.sm-table > thead > tr > th { background: var(--line-2) !important; color: var(--ink-2); }
.sm-table th.sm-m { text-align: center; white-space: nowrap; }
.sm-table th.sm-m.sm-now { color: var(--accent); }
.sm-table .sm-sup { position: sticky; left: 0; z-index: 1; font-weight: 500; min-width: 200px; max-width: 280px; }
.sm-table td.sm-sup { background: var(--surface); }
.sm-table td.sm-cell { text-align: center; font-size: .82rem; line-height: 1.25; min-width: 110px; }
.sm-table td.sm-cell .sm-inv { display: block; }
.sm-table td.sm-cell .sm-inv + .sm-inv { margin-top: 6px; padding-top: 6px; border-top: 1px dashed #cfd4da; }
.sm-table td.sm-cell .sm-d { display: block; color: var(--muted); font-size: .75rem; }
.sm-table td.sm-cell.sm-has { background: var(--ok-soft); }
.cmp-table { min-width: 980px; table-layout: fixed; }
.cmp-table col.c-date { width: 104px; }
.cmp-table col.c-amt { width: 132px; }
.cmp-table col.c-gap { width: 18px; }
.cmp-table thead tr.cmp-groups th { font-size: .82rem; font-weight: 600; color: var(--ink); border-bottom: 0 !important; padding-bottom: .2rem; }
.cmp-table thead .count { font-size: .72rem; font-weight: 600; color: var(--muted); background: var(--line-2); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.cmp-table td { vertical-align: top; }
.cmp-table .gap { background: var(--canvas) !important; border-bottom-color: transparent !important; padding: 0 !important; }
.cmp-table thead .gap { background: var(--surface) !important; }
.cmp-table tr.grp-start > td:not(.gap) { border-top: 1px solid #cfd4d9; }
.cmp-table .desc-cell { max-width: none; }
.cmp-table .desc-cell .clip, .cmp-table .sub-line.clip { max-width: 100%; }
.cmp-table td.st-ok { background: var(--ok-soft); }
.cmp-table td.st-bad { background: var(--bad-soft); }
.cmp-table td.st-ignored { color: var(--muted); }
.cmp-table td.lit { box-shadow: inset 0 0 0 9999px rgba(31, 122, 77, .12); }

/* ---------------------------------------------------------------- login */
body.login { background: var(--canvas); }
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 1.05rem; margin-bottom: 22px; }
.login-brand .brand-mark { width: 26px; height: 26px; }
.login-card { width: 100%; max-width: 372px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px 28px 26px; }
.login-card h1 { font-size: 1.2rem; margin: 0 0 4px; }
.login-card > p { font-size: .82rem; margin-bottom: 20px; }
.login-foot { color: var(--faint); font-size: .76rem; margin-top: 20px; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 991.98px) {
  .topbar { padding: 0 16px; }
  .content { padding: 20px 16px 40px; }
  .client-picker select { min-width: 0; width: 100%; }
  .client-picker { flex: 1; }
  .client-picker label { display: none; }
  div.dt-container .dt-search input { width: 100%; margin-left: 0 !important; }
}
@media (max-width: 767.98px) {
  .segmented { display: flex; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  .segmented button { white-space: nowrap; }
}

/* ---------------------------------------------------------------- semaforo di completezza */
.segmented .seg-link { border-radius: 6px; padding: 6px 12px; font-size: .84rem; font-weight: 500; color: var(--ink-2); text-decoration: none; }
.segmented .seg-link:hover { color: var(--ink); }
.segmented .seg-link.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 32, .08), 0 0 0 1px rgba(16, 24, 32, .04); }
.completeness { --bs-table-hover-bg: transparent; }
.completeness th, .completeness td { white-space: nowrap; }
.completeness thead th { font-size: .74rem; }
.completeness td { padding: 6px 4px !important; min-width: 112px; }
.completeness .sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 200px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; padding-left: 18px !important; box-shadow: inset -1px 0 0 var(--line-2); }
.completeness tbody th.sticky-col { font-size: .84rem; color: var(--ink); }
.cell { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 100%; max-width: 150px; min-height: 30px; padding: 4px 8px; border-radius: 6px; font-size: .75rem; font-weight: 500; border: 1px solid transparent; background: none; line-height: 1.2; }
.cell .dot, .legend .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
button.cell { cursor: pointer; transition: border-color .12s, filter .12s; }
button.cell:hover { filter: brightness(.97); border-color: currentColor; }
.cell-red { background: var(--bad-soft); color: var(--bad); }
.cell-red .dot, .dot-red { background: var(--bad); }
.cell-yellow { background: var(--warn-soft); color: var(--warn); }
.cell-yellow .dot, .dot-yellow { background: #d08700; }
.cell-green { background: var(--ok-soft); color: var(--ok); }
.cell-green .dot, .dot-green { background: var(--ok); }
.cell-empty { color: var(--faint); }
.dot-empty { background: var(--line); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 12px 18px; border-top: 1px solid var(--line-2); font-size: .76rem; color: var(--muted); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------------- analisi spese (grafici) */
.section-title { font-size: 1.05rem; font-weight: 600; margin: 8px 0 12px; }
.period-switch { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
.period-switch button { white-space: nowrap; padding: 5px 10px; }
.chart-figure { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 6px 0 4px; }
.chart-figure-value { font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; }
.chart-figure-label { color: var(--muted); font-size: .84rem; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; overflow: visible; }
.chart-tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart-label { font-size: 11px; fill: var(--ink-2); }
.chart-value { font-size: 11px; font-weight: 600; fill: var(--ink); font-variant-numeric: tabular-nums; }
.chart-bar .chart-mark { transition: opacity .12s; }
.chart-bar.is-hover .chart-mark { opacity: .78; }
.chart-bar rect:focus { outline: none; }
.chart-bar rect:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chart-tip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 18px rgba(16, 24, 32, .12); padding: 7px 10px; font-size: .78rem; display: flex; flex-direction: column; gap: 1px; max-width: 260px; }
.chart-tip strong { font-size: .9rem; font-weight: 600; color: var(--ink); }
.chart-tip span { color: var(--ink-2); }
.chart-tip small { color: var(--muted); font-size: .72rem; }
.chart-empty { display: grid; place-items: center; height: 200px; color: var(--muted); font-size: .86rem; border: 1px dashed var(--line); border-radius: 8px; }
.chart-data { margin-top: 8px; }
.chart-data summary { font-size: .78rem; color: var(--muted); cursor: pointer; width: max-content; }
.chart-data summary:hover { color: var(--ink-2); }
.chart-data[open] summary { margin-bottom: 8px; }
.spread-box .spread-value { font-size: 2.4rem; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); line-height: 1.1; }
.spread-box .spread-sub { color: var(--ink-2); font-size: .86rem; margin: 6px 0 14px; }

/* ---------------------------------------------------------------- verifica in due passaggi */
.otp-input { font-family: var(--bs-font-monospace); letter-spacing: .12em; font-size: 1rem; }
.tfa-apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.tfa-app { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px 9px 34px; position: relative; cursor: pointer; background: var(--surface); }
.tfa-app input { position: absolute; left: 12px; top: 12px; accent-color: var(--accent); }
.tfa-app span { font-weight: 500; font-size: .86rem; }
.tfa-app small { font-size: .74rem; color: var(--muted); }
.tfa-app:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.tfa-qr-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.tfa-qr { width: 172px; height: 172px; flex: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
.tfa-qr svg { width: 100%; height: 100%; display: block; }
.tfa-qr-row .small-note { flex: 1; min-width: 200px; }
.tfa-key { display: block; margin: 6px 0; font-size: .9rem; letter-spacing: .06em; word-break: break-all; padding: 6px 8px; }
.recovery-box { border: 1px solid #f1dfb8; background: var(--warn-soft); border-radius: 8px; padding: 12px 14px; margin-bottom: 14px; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.recovery-codes code { background: var(--surface); border: 1px solid var(--line); text-align: center; padding: 5px; font-size: .86rem; letter-spacing: .05em; }
.tfa-admin { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fafbfb; }

/* ---------------------------------------------------------------- pagine pubbliche: iscrizione e documenti */
.public-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.public-wrap .login-card { max-width: 420px; }
.public-wrap.public-lg .login-card { max-width: 640px; }
.public-wrap .login-brand { color: var(--ink); text-decoration: none; }
.login-signup { font-size: .84rem; color: var(--muted); margin: 16px 0 0; text-align: center; }
.login-foot a { color: var(--muted); }
.signup-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 575.98px) { .signup-choices { grid-template-columns: 1fr; } }
.signup-choice { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); padding: 16px; color: var(--ink); transition: border-color .12s, background .12s; }
.signup-choice:hover { border-color: var(--accent); background: var(--accent-soft); }
.signup-choice i { font-size: 1.3rem; color: var(--accent); }
.signup-choice strong { font-weight: 600; font-size: .95rem; }
.signup-choice span { color: var(--muted); font-size: .8rem; }
.signup-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.consents { display: flex; flex-direction: column; gap: 10px; margin: 20px 0 18px; padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfb; }
.consents .form-check { display: flex; gap: 10px; padding-left: 0; margin: 0; }
.consents .form-check-input { flex: none; margin: 3px 0 0; float: none; }
.consents .form-check-label { font-size: .82rem; color: var(--ink-2); }
.consents em { color: var(--muted); font-style: normal; font-size: .76rem; }
.hp-field { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.legal-doc h2 { font-size: 1rem; margin: 20px 0 6px; }
.legal-doc p { color: var(--ink-2); font-size: .88rem; }
.form-check-input { border-color: #a9b0b8; }
.consents a, .signup-card .form-check-label a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* ---------------------------------------------------------------- beta */
.beta-badge { display: inline-block; margin-left: 2px; padding: 2px 6px; border-radius: 4px; background: #f6ecd8; color: #8a5f12; font-size: .62rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; line-height: 1.4; vertical-align: 2px; }
.beta-note { width: 100%; max-width: 372px; margin-top: 16px; padding: 12px 14px; border-radius: 8px; background: #f6ecd8; border: 1px solid #ead7ae; color: #5a4310; font-size: .82rem; line-height: 1.5; }
.beta-note strong { color: #3d2d08; }
.beta-note a { color: #3d2d08; text-decoration: underline; }
.login-card .beta-note { max-width: none; margin: 0 0 20px; }

/* fatture ricorrenti */
.recurring-alert { border-color: var(--warn); box-shadow: inset 3px 0 0 var(--warn); }
.recurring-alert > h2 i { color: var(--warn); }
.recurring-alert .kv-list li { flex-wrap: wrap; }
.recurring-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.recurring-box .grow { flex: 1 1 220px; }
.rule-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 18px; }
.rule-box + .summary { border-top: 1px solid var(--line); padding-top: 18px; }
.rule-box form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.rule-box input { flex: 1 1 260px; }

/* pagina Fornitori */
.sup-ctl { display: flex; align-items: center; gap: 8px; }
.sup-ctl .form-switch .form-check-input { width: 2.4em; height: 1.3em; cursor: pointer; }
.sup-table td { vertical-align: top; }
.sb-sep { margin: 8px 10px; border: 0; border-top: 1px solid var(--line); opacity: 1; }

/* Esteria — logo */
.brand-logo { display: block; height: 22px; width: auto; flex: none; }
.login-brand .brand-logo { height: 28px; }
