/* Asset Aziendali · aspetto grafico v1.8
   Strato di stile caricato dopo styles.css: ridefinisce token, tipografia e componenti senza toccare
   la struttura. Barra laterale scura, superfici chiare a filo sottile, accento indaco/ciano.
   Per tornare all'aspetto precedente basta togliere il <link> a questo file in index.html. */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #5b5bf6;
  --primary-dark: #4338ca;
  --primary-soft: #eef0ff;
  --accent: #06b6d4;
  --border: #e6e9f2;
  --border-strong: #d5dae6;
  --ink: #0b1022;
  --ink-2: #131a33;
  --ink-text: #c7cde0;
  --ink-muted: #7d87a6;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px -12px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, 0.35);
  --ring: 0 0 0 4px rgba(91, 91, 246, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

h1, h2, h3, h4,
.brand-name,
.kpi-value,
.card-title {
  font-family: "Inter", "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
  letter-spacing: -0.02em;
}

::selection {
  background: rgba(91, 91, 246, 0.18);
}

/* ---------- barra laterale scura */

#main-view {
  grid-template-columns: 264px 1fr;
}

#sidebar {
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(91, 91, 246, 0.22), transparent 60%),
    radial-gradient(100% 50% at 100% 100%, rgba(6, 182, 212, 0.12), transparent 60%),
    linear-gradient(180deg, var(--ink-2), var(--ink));
  border-right: none;
  color: var(--ink-text);
  padding: 22px 16px 18px;
  gap: 22px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.brand {
  padding: 2px 6px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand-logo,
.login-logo {
  background: linear-gradient(135deg, #7c7cff 0%, var(--primary) 45%, var(--accent) 100%);
  box-shadow: 0 8px 24px -6px rgba(91, 91, 246, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 17px;
}

.brand-name {
  color: #fff;
  font-size: 15px;
}

.brand-name .app-version {
  color: var(--ink-muted);
  font-weight: 600;
  margin-left: 2px;
}

.brand-sub {
  color: var(--ink-muted);
}

.tabs {
  gap: 2px;
}

.tab-btn {
  position: relative;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-text);
  font-weight: 600;
  font-size: 13.5px;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.tab-btn .icon {
  color: var(--ink-muted);
  width: 17px;
  height: 17px;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.tab-btn:hover .icon {
  color: #fff;
}

.tab-btn:focus-visible {
  outline: 2px solid rgba(124, 124, 255, 0.8);
  outline-offset: 1px;
}

.tab-btn.active {
  background: linear-gradient(90deg, rgba(91, 91, 246, 0.32), rgba(91, 91, 246, 0.08));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(124, 124, 255, 0.28);
}

.tab-btn.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #8b8bff, var(--accent));
  box-shadow: 0 0 12px rgba(124, 124, 255, 0.8);
}

.tab-btn.active .icon {
  color: #a5b4fc;
}

.tab-btn-external {
  margin-top: 12px;
  border: 1px solid rgba(124, 124, 255, 0.35);
  background: rgba(91, 91, 246, 0.1);
  color: #c7d2fe;
}

.tab-btn.tab-btn-external .icon {
  color: #a5b4fc;
}

.sidebar-footer {
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.user-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
}

.user-chip .badge {
  background: rgba(124, 124, 255, 0.18);
  border-color: transparent;
  color: #c7d2fe;
}

#sidebar .btn-ghost {
  color: var(--ink-text);
  border-color: rgba(255, 255, 255, 0.1);
  background: transparent;
}

#sidebar .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

/* ---------- barra superiore e intestazioni */

.topbar {
  padding: 16px 32px;
  background: rgba(244, 246, 251, 0.8);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.topbar h1 {
  font-size: 19px;
  font-weight: 750;
}

.topbar-date {
  margin-top: 2px;
  font-size: 12.5px;
}

#tenant-badge {
  padding: 6px 12px;
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

#tenant-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 8px;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

#content {
  padding: 28px 32px 48px;
  max-width: 1600px;
}

.page {
  gap: 22px;
  animation: fade-in 0.35s var(--ease);
}

.page-header h2 {
  font-size: 26px;
  font-weight: 780;
  line-height: 1.2;
}

.page-header p {
  font-size: 14px;
  max-width: 72ch;
}

/* ---------- superfici */

.card,
.kpi-card {
  border-color: var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.card-title {
  font-size: 15px;
  font-weight: 750;
  color: var(--text);
}

/* ---------- campi */

input,
select,
textarea {
  padding: 10px 12px;
  border-color: var(--border-strong);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease), background-color 0.15s var(--ease);
}

input:hover,
select:hover,
textarea:hover {
  border-color: #b9c0d4;
}

input:focus,
select:focus,
textarea:focus,
.table-filter:focus {
  border-color: var(--primary);
  box-shadow: var(--ring);
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  box-shadow: none;
  accent-color: var(--primary);
}

input[type="file"] {
  padding: 7px;
  font-size: 13px;
}

input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700;
  cursor: pointer;
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

select[multiple] {
  background-image: none;
  padding-right: 12px;
}

.form-grid label,
.select-card label {
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
}

/* ---------- pulsanti */

.btn {
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  font-weight: 650;
  font-size: 13.5px;
  line-height: 1.2;
  transition: background 0.15s var(--ease), box-shadow 0.15s var(--ease), transform 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(180deg, #6d6dff, var(--primary));
  box-shadow: 0 1px 2px rgba(67, 56, 202, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 6px 16px -6px rgba(91, 91, 246, 0.6);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  background: linear-gradient(180deg, #7676ff, #5050f0);
  box-shadow: 0 1px 2px rgba(67, 56, 202, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 10px 22px -8px rgba(91, 91, 246, 0.7);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: #b9c0d4;
  color: var(--text);
}

.btn-danger {
  background: #fff1f1;
  color: #c81e1e;
  border-color: #fbd5d5;
}

.btn-danger:hover:not(:disabled) {
  background: #ffe2e2;
  border-color: #f8b4b4;
}

.btn-ghost {
  border-color: var(--border-strong);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12.5px;
  border-radius: 8px;
}

/* ---------- tabelle */

th,
td {
  padding: 12px 16px;
  border-bottom-color: #eef1f6;
}

th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.table-card-scroll table thead tr:first-child th {
  background: var(--surface-2);
}

th.sortable:hover {
  color: var(--primary);
}

.filter-row th {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.table-filter {
  border-color: var(--border);
  background: var(--surface-2);
  border-radius: 7px;
  box-shadow: none;
}

td {
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

tbody tr {
  transition: background 0.12s var(--ease);
}

tbody tr:hover {
  background: #f6f7ff;
}

.table-search {
  padding: 10px 14px;
  border-color: var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.table-search:focus-within {
  border-color: var(--primary);
  box-shadow: var(--ring);
}

.table-search input,
.table-search input:focus,
.table-search input:hover {
  box-shadow: none;
  background: transparent;
}

.pagination-bar {
  background: var(--surface-2);
}

code {
  font-family: "Cascadia Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;
  background: #f1f3f9;
  border: 1px solid var(--border);
  color: var(--text-2);
}

/* ---------- badge con pallino di stato */

.badge {
  gap: 6px;
  padding: 3px 9px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.5;
  border: 1px solid transparent;
}

.badge-success { background: #ecfdf3; color: #067647; border-color: #abefc6; }
.badge-warning { background: #fffaeb; color: #b54708; border-color: #fedf89; }
.badge-danger  { background: #fef3f2; color: #b42318; border-color: #fecdca; }
.badge-info    { background: #eff8ff; color: #175cd3; border-color: #b2ddff; }
.badge-muted   { background: #f2f4f7; color: #475467; border-color: #e4e7ec; }
.badge-primary { background: var(--primary-soft); color: var(--primary-dark); border-color: #d6d9ff; }

.badge-success::before,
.badge-warning::before,
.badge-danger::before,
.badge-info::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ---------- KPI della dashboard */

.kpi-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
  gap: 16px;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.kpi-card::after {
  content: "";
  position: absolute;
  right: -50px;
  bottom: -70px;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91, 91, 246, 0.09), transparent 70%);
  pointer-events: none;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 16px 32px -16px rgba(15, 23, 42, 0.25);
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.kpi-icon .icon {
  width: 20px;
  height: 20px;
}

.kpi-icon-primary { background: linear-gradient(135deg, #eef0ff, #e0e3ff); color: var(--primary); }
.kpi-icon-info    { background: linear-gradient(135deg, #ecfbff, #d6f4fb); color: #0891b2; }
.kpi-icon-warning { background: linear-gradient(135deg, #fff8e6, #ffedc2); color: #d97706; }
.kpi-icon-success { background: linear-gradient(135deg, #ebfdf2, #d1fadf); color: #16a34a; }

.kpi-value {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
}

.empty {
  padding: 32px 24px;
  font-size: 13.5px;
}

/* ---------- calendario e attività */

.day {
  border-color: #eceff5;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.day.today {
  box-shadow: inset 0 0 0 2px var(--primary);
}

.view-switch {
  background: #eceff6;
  border-radius: 10px;
  padding: 3px;
}

.view-switch-btn {
  border-radius: 8px;
}

.view-switch-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.activity-chip {
  border-radius: 9px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

/* ---------- modali e notifiche */

.modal {
  background: rgba(11, 16, 34, 0.55);
  backdrop-filter: blur(6px);
}

.modal-content {
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.28s var(--ease);
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.toast {
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-weight: 600;
}

/* ---------- accesso */

#login-view {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(40% 50% at 15% 20%, rgba(91, 91, 246, 0.45), transparent 70%),
    radial-gradient(35% 45% at 85% 80%, rgba(6, 182, 212, 0.35), transparent 70%),
    radial-gradient(30% 40% at 80% 10%, rgba(168, 85, 247, 0.25), transparent 70%),
    linear-gradient(160deg, #0d1330, var(--ink));
}

#login-view::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
          mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  pointer-events: none;
}

.login-card {
  position: relative;
  max-width: 420px;
  padding: 36px 34px 30px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.55);
  animation: modal-in 0.5s var(--ease);
}

.login-card h1 {
  font-size: 24px;
  font-weight: 800;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
}

.login-card .btn-block {
  padding: 12px 16px;
  font-size: 14.5px;
}

/* ---------- importazione da Excel */

.import-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.import-file {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 520px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-2);
}

.import-card .settings-notes {
  margin: 0;
  color: var(--muted);
}

.import-sample {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.import-sample td {
  font-size: 12.5px;
  padding: 7px 12px;
}

.import-result {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.import-report li {
  font-size: 12.5px;
}

.form-grid .checkbox-line,
.checkbox-line {
  flex-direction: row;
  align-items: center;
  align-self: end;
  min-height: 42px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

/* ---------- barre di scorrimento discrete */

.table-wrap,
.calendar-side-block-scroll,
.calendar-palette-scroll,
.import-sample {
  scrollbar-width: thin;
  scrollbar-color: #cbd2e1 transparent;
}

/* ---------- schermi stretti: barra laterale a nastro scorrevole */

@media (max-width: 900px) {
  #main-view {
    grid-template-columns: minmax(0, 1fr);
  }

  #sidebar {
    min-width: 0;
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    padding: 12px 12px 10px;
    gap: 10px;
    overflow: visible;
  }

  .brand {
    padding: 0;
    border-bottom: none;
    flex: 1;
  }

  .tabs {
    min-width: 0;
    max-width: calc(100% + 24px);
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 4px;
    margin: 0 -12px;
    padding: 2px 12px 4px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent);
            mask-image: linear-gradient(90deg, transparent 0, #000 12px, #000 calc(100% - 24px), transparent);
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 8px 12px;
  }

  .tab-btn.active::before {
    display: none;
  }

  .tab-btn-external {
    margin-top: 0;
  }

  .sidebar-footer {
    order: 2;
    width: auto;
    padding-top: 0;
    border-top: none;
    flex-direction: row;
  }

  .sidebar-footer .user-chip {
    display: none;
  }

  .sidebar-footer .btn-block {
    width: auto;
    min-height: 38px;
  }

  .topbar {
    position: static;
    padding: 14px 16px;
  }

  #content {
    padding: 18px 16px 40px;
  }

  .page-header h2 {
    font-size: 22px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .kpi-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 16px;
  }

  .kpi-value {
    font-size: 22px;
  }
}

/* ---------- pagine elenco (v1.9): intestazione con azioni, ricerca e filtri rapidi, tabella a tutta pagina */

:root {
  --topbar-h: 82px;
  --drawer-w: 460px;
}

.page-header-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px 24px;
}

.page-header-bar p strong,
.pagination-info strong {
  color: var(--text);
  font-weight: 750;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.list-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
}

.list-toolbar .table-search {
  flex: 1 1 300px;
  max-width: 460px;
  margin-bottom: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease);
}

.chip:hover {
  border-color: #b9c0d4;
  background: var(--surface-2);
}

.chip:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.chip.active {
  background: var(--primary-soft);
  border-color: #c3c7ff;
  color: var(--primary-dark);
}

.chip-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.chip.active .chip-count {
  color: var(--primary);
}

.list-page table {
  min-width: 0;
}

.list-page td.cell-main {
  min-width: 180px;
}

.cell-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 650;
  line-height: 1.35;
  color: var(--text);
}

.cell-sub {
  margin-top: 2px;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.35;
  color: var(--muted);
}

.cell-sub:empty {
  display: none;
}

.cell-warn {
  display: inline-flex;
  color: #d97706;
}

.cell-warn .icon {
  width: 15px;
  height: 15px;
}

.cell-none {
  color: #b6bdcc;
}

.count-pill {
  display: inline-flex;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.list-page th.cell-go,
.list-page td.cell-go {
  width: 1%;
  padding-left: 0;
  color: #b6bdcc;
}

td.cell-go .icon {
  display: block;
  width: 16px;
  height: 16px;
  transition: transform 0.15s var(--ease);
}

.list-page td.cell-actions {
  width: 1%;
}

.list-page td.cell-actions .btn {
  margin: 2px 0;
}

/* Seconda riga dentro una cella (un badge in più, un'azione in più): non allarga la colonna. */
.cell-stack-row {
  margin-top: 4px;
}

td.cell-actions .cell-stack-row {
  margin-top: 0;
}

@media (max-width: 1279px) {
  .list-page td.cell-actions {
    width: auto;
    white-space: normal;
  }
}

tr.row-click {
  cursor: pointer;
}

tr.row-click:hover td.cell-go {
  color: var(--primary);
}

tr.row-click:hover td.cell-go .icon {
  transform: translateX(2px);
}

tr.row-click:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

tbody tr.row-selected,
tbody tr.row-selected:hover {
  background: var(--primary-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}

tr.row-off .cell-title {
  color: var(--muted);
}

@media (max-width: 1359px) {
  .list-page .col-md {
    display: none;
  }
}

@media (max-width: 1599px) {
  .list-page .col-xl {
    display: none;
  }
}

/* Da 1280px in su l'elenco scorre con la pagina e l'intestazione della tabella resta sotto la barra superiore. */
@media (min-width: 1280px) {
  .list-page .table-card:not(.table-wide),
  .list-page .table-card:not(.table-wide) .table-wrap {
    overflow: visible;
  }

  .list-page .table-card:not(.table-wide) thead th {
    position: sticky;
    top: var(--topbar-h);
    z-index: 3;
    border-bottom: none;
    box-shadow: inset 0 -1px 0 var(--border);
  }

  .list-page .table-card:not(.table-wide) thead th:first-child {
    border-top-left-radius: var(--radius);
  }

  .list-page .table-card:not(.table-wide) thead th:last-child {
    border-top-right-radius: var(--radius);
  }

  .list-page .table-card:not(.table-wide) .pagination-bar {
    border-radius: 0 0 var(--radius) var(--radius);
  }

  .list-page .table-card:not(.table-wide) .table-wrap:last-child tbody tr:last-child td:first-child {
    border-bottom-left-radius: var(--radius);
  }

  .list-page .table-card:not(.table-wide) .table-wrap:last-child tbody tr:last-child td:last-child {
    border-bottom-right-radius: var(--radius);
  }
}

/* ---------- pannello laterale: scheda e moduli */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(11, 16, 34, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease);
}

body.drawer-open .drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  width: min(var(--drawer-w), 100vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  transform: translateX(104%);
  visibility: hidden;
  transition: transform 0.28s var(--ease), visibility 0s linear 0.28s;
}

.drawer.open {
  transform: none;
  visibility: visible;
  transition: transform 0.28s var(--ease), visibility 0s;
}

.drawer:focus {
  outline: none;
}

.drawer .hidden {
  display: none !important;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 15px 14px 15px 20px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
  line-height: 1.3;
}

.drawer-close {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.drawer-close:hover {
  background: #eef1f6;
  color: var(--text);
}

.drawer-close:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.drawer-view {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.drawer-body {
  flex: 1;
  min-height: 0;
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd2e1 transparent;
}

.drawer-foot {
  display: flex;
  justify-content: flex-end;
  flex-shrink: 0;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.drawer .form-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px 12px;
  align-items: start;
}

.drawer .form-grid > * {
  grid-column: 1 / -1;
  min-width: 0;
}

.drawer .form-grid > .span-3 {
  grid-column: span 3;
}

.drawer .form-grid > .span-2 {
  grid-column: span 2;
}

.drawer .form-grid > .span-1 {
  grid-column: span 1;
}

.drawer .form-grid > .span-1 input {
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
  text-transform: uppercase;
}

.drawer .form-grid > .form-hint {
  margin-top: -6px;
}

.drawer .geo-actions .form-hint {
  flex: 1 1 100%;
}

.form-section {
  min-width: 0;
  margin: 0 0 24px;
  padding: 0;
  border: none;
}

.form-section:last-child {
  margin-bottom: 0;
}

.form-section legend,
.detail-section h4 {
  margin: 0 0 12px;
  padding: 0;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.label-note {
  font-weight: 400;
  color: var(--muted);
}

/* Senza questa regola il browser usa per le aree di testo un carattere a spaziatura fissa (note del prelievo,
   note dell'attività, moduli nel pannello laterale). */
textarea {
  font-family: inherit;
}

.asset-photo-actions .btn {
  white-space: nowrap;
}

/* scheda cliente */

.detail-hero {
  display: flex;
  align-items: center;
  gap: 14px;
}

.detail-avatar {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #eef0ff, #dcdfff);
  color: var(--primary-dark);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.detail-name {
  font-size: 18px;
  font-weight: 780;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
  overflow-wrap: anywhere;
}

.detail-sub {
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--muted);
}

.detail-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.detail-actions .btn {
  flex: 1 1 auto;
}

.detail-actions:empty {
  display: none;
}

.detail-section {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.detail-section h4 {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.detail-count {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

.detail-line {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-2);
  text-decoration: none;
  overflow-wrap: anywhere;
}

a.detail-line:hover {
  color: var(--primary);
}

.detail-line .icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--muted);
}

.detail-muted {
  font-size: 13px;
  color: var(--muted);
}

.detail-hint,
.detail-empty {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--muted);
}

.detail-warn {
  display: flex;
  gap: 10px;
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid #fedf89;
  border-radius: 10px;
  background: #fffaeb;
  color: #93370d;
  font-size: 13px;
  line-height: 1.4;
}

.detail-warn .icon {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  color: #d97706;
}

.detail-link {
  display: inline-flex;
  padding: 0;
  border: none;
  background: none;
  color: var(--primary);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.detail-link:hover {
  text-decoration: underline;
}

.detail-pairs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0 0;
}

.detail-pairs dt {
  font-size: 11.5px;
  color: var(--muted);
}

.detail-pairs dd {
  margin: 1px 0 0;
  font-size: 13.5px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.detail-jobs {
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.detail-jobs li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

.detail-jobs li:last-child {
  border-bottom: none;
}

.detail-jobs li > div {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.detail-jobs strong {
  font-size: 13px;
  color: var(--text);
}

.detail-jobs li > div > span {
  overflow: hidden;
  font-size: 12.5px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-jobs .badge {
  flex-shrink: 0;
}

.detail-notes {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.detail-danger {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}

.detail-danger .btn {
  flex-shrink: 0;
}

/* Schermi larghi: la scheda cliente affianca l'elenco invece di coprirlo. */
@media (min-width: 1440px) {
  body.drawer-split-open .main {
    margin-right: var(--drawer-w);
  }

  body.drawer-split-open .drawer-backdrop {
    display: none;
  }

  body.drawer-split-open .list-page .col-md,
  body.drawer-split-open .list-page .col-xl {
    display: none;
  }

  .drawer.drawer-split {
    box-shadow: -16px 0 40px -28px rgba(15, 23, 42, 0.3);
  }
}

/* Telefono: le righe diventano schede e il pannello occupa tutto lo schermo. */
@media (max-width: 720px) {
  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }

  .list-toolbar .table-search {
    flex-basis: 100%;
    max-width: none;
  }

  .chips {
    flex-wrap: nowrap;
    max-width: calc(100% + 32px);
    margin: 0 -16px;
    padding: 0 16px 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .chips::-webkit-scrollbar {
    display: none;
  }

  .chip {
    flex: 0 0 auto;
  }

  .list-page .table-wrap {
    overflow: visible;
  }

  .list-page table,
  .list-page tbody {
    display: block;
    width: 100%;
  }

  .list-page thead {
    display: none;
  }

  .list-page tbody tr {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #eef1f6;
  }

  .list-page tbody tr:last-child {
    border-bottom: none;
  }

  .list-page tbody td {
    display: block;
    width: auto;
    padding: 0;
    border: none;
    white-space: normal;
  }

  .list-page tbody td.col-md,
  .list-page tbody td.col-xl,
  .list-page tbody td:has(> .cell-none:only-child) {
    display: none;
  }

  .list-page tbody td.cell-main {
    flex: 1 1 100%;
    min-width: 0;
    padding-right: 24px;
  }

  .list-page tbody td.cell-actions {
    display: flex;
    flex: 1 1 100%;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
  }

  .list-page tbody td.cell-go {
    position: absolute;
    top: 14px;
    right: 12px;
    width: auto;
  }

  .list-page tbody td.empty {
    flex: 1 1 100%;
    padding: 20px 0;
  }

  .drawer {
    border-left: none;
  }

  .drawer-foot .btn {
    flex: 1;
  }
}

/* ---------- attività: aree di rimozione durante il trascinamento (v1.9.1) ----------
   Le aree da cui si pescano cliente, operatori e asset (più "Operatori liberi" in basso) accettano anche il
   percorso inverso: ciò che vi si riporta viene tolto dal segnaposto. Mentre si trascina un'etichetta
   assegnata, <body data-drag-kind> accende l'area giusta; .drop-target la marca quando ci si è sopra. */

[data-remove-zone] {
  position: relative;
  transition: background-color 0.15s, box-shadow 0.15s;
}

/* Contorno con outline e non con il bordo: i blocchi laterali non hanno bordo né margine interno, e un bordo
   aggiunto durante il trascinamento sposterebbe gli elementi sotto il puntatore. */
body[data-drag-kind="assigned-customer"] [data-remove-zone="customer"],
body[data-drag-kind="assigned-operator"] [data-remove-zone="operator"],
body[data-drag-kind="assigned-asset"] [data-remove-zone="asset"] {
  background-color: #fff7f7;
  outline: 2px dashed #fca5a5;
  outline-offset: -2px;
}

[data-remove-zone].drop-target {
  background-color: var(--danger-soft);
  outline: 2px dashed var(--danger);
  outline-offset: -2px;
}

body[data-drag-kind="assigned-operator"] .calendar-side-block[data-remove-zone="operator"],
body[data-drag-kind="assigned-asset"] .calendar-side-block[data-remove-zone="asset"] {
  border-radius: 6px;
  outline-offset: 5px;
  box-shadow: 0 0 0 5px #fff7f7;
}

.calendar-side-block[data-remove-zone].drop-target {
  border-radius: 6px;
  outline-offset: 5px;
  box-shadow: 0 0 0 5px var(--danger-soft);
}

body[data-drag-kind="assigned-customer"] [data-remove-zone="customer"]::after,
body[data-drag-kind="assigned-operator"] [data-remove-zone="operator"]::after,
body[data-drag-kind="assigned-asset"] [data-remove-zone="asset"]::after,
[data-remove-zone].drop-target::after {
  content: "Rilascia per togliere";
  position: absolute;
  top: -10px;
  right: 12px;
  z-index: 2;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
}

.free-operators-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 720px) {
  .free-operators-hint {
    margin-left: 0;
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
