/* ═══════════════════════════════════════════════════════════
   GESTIONE MASTER CRM — Design System v2
   Refactoring conservativo: override Bootstrap mirato.
   NON modificare logica applicativa (semafori, stati, filtri).
═══════════════════════════════════════════════════════════ */

/* ── Variabili design system ──────────────────────────── */
:root {
  --bg:                #f0f2f5;
  --sidebar-bg:        #0f1623;
  --sidebar-text:      #8b96a8;
  --sidebar-active:    #ffffff;
  --sidebar-active-bg: #1e2d45;
  --sidebar-hover:     #1a2438;
  --accent:            #2563eb;
  --accent-dark:       #1d4ed8;
  --accent-light:      #eff6ff;
  --surface:           #ffffff;
  --border:            #e4e8ee;
  --text-primary:      #111827;
  --text-secondary:    #6b7280;
  --text-muted:        #9ca3af;
  --radius:            10px;
  --shadow:            0 1px 3px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.05);
  --font-base:         'DM Sans', system-ui, -apple-system, sans-serif;
  --font-mono:         'DM Mono', 'Courier New', monospace;

  /* Status: definiti come variabili CSS, usati solo per presentazione.
     La logica che li assegna resta invariata nel backend. */
  --st-grigio:     #9ca3af; --st-grigio-bg: #f3f4f6;
  --st-giallo:     #d97706; --st-giallo-bg: #fffbeb;
  --st-rosso:      #dc2626; --st-rosso-bg:  #fef2f2;
  --st-verde:      #16a34a; --st-verde-bg:  #f0fdf4;

  /* Badge tipologia commesse — solo estetica */
  --badge-int:     #1d4ed8; --badge-int-bg:  #eff6ff; --badge-int-brd: #bfdbfe;
  --badge-srv:     #15803d; --badge-srv-bg:  #f0fdf4; --badge-srv-brd: #bbf7d0;
}

/* ── Global ───────────────────────────────────────────── */
body {
  font-family: var(--font-base);
  background: var(--bg);
  color: var(--text-primary);
}

/* ── SIDEBAR ──────────────────────────────────────────── */
#sidebar {
  min-width: 230px;
  max-width: 230px;
  min-height: 100vh;
  background: var(--sidebar-bg) !important;
  transition: margin 0.3s;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 15px;
  line-height: 1;
}

.sidebar-logo-text {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-section-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #4b5563;
  padding: 16px 18px 5px;
}

#sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 400;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
  text-decoration: none;
}

#sidebar .nav-link:hover {
  background: var(--sidebar-hover);
  color: #c9d3e0;
}

#sidebar .nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active);
  font-weight: 500;
}

#sidebar .nav-link i {
  width: 18px;
  text-align: center;
  font-size: 15px;
  opacity: 0.7;
  flex-shrink: 0;
  margin-right: 0;
}

#sidebar .nav-link.active i { opacity: 1; }
#sidebar .nav-link:hover i  { opacity: 0.9; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 12px;
  color: rgba(255,255,255,0.45);
  display: block;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer-links { display: flex; align-items: center; gap: 4px; }

.sidebar-footer-links a {
  font-size: 12px;
  color: rgba(255,255,255,0.38);
  text-decoration: none;
  transition: color 0.15s;
}
.sidebar-footer-links a:hover { color: rgba(255,255,255,0.7); }
.sidebar-footer-links .sep { color: rgba(255,255,255,0.2); font-size: 11px; padding: 0 2px; }

/* ── LAYOUT CONTENT ───────────────────────────────────── */
#content {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOPBAR ───────────────────────────────────────────── */
.app-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-left h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1;
}

.topbar-count {
  display: inline-flex;
  align-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  font-family: var(--font-mono);
  line-height: 1.6;
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

/* ── CONTENT AREA ─────────────────────────────────────── */
.content-area {
  flex: 1;
  padding: 24px 28px;
  overflow-y: auto;
}

/* ── PULSANTI CRM ─────────────────────────────────────── */
.btn-crm-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff !important;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--font-base);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn-crm-primary:hover  { background: var(--accent-dark); transform: translateY(-1px); }
.btn-crm-primary:active { transform: translateY(0); }

.btn-sidebar-toggle {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  margin-right: 4px;
  line-height: 1;
}
.btn-sidebar-toggle:hover { background: var(--bg); color: var(--text-primary); }

/* ── FILTER BAR (barra filtri sopra tabelle) ──────────── */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

/* ── TABLE WRAP ───────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ── TABLE (override Bootstrap) ───────────────────────── */
.table {
  font-family: var(--font-base);
  margin-bottom: 0;
}

.table thead th {
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: #f9fafb !important;
  border-bottom: 1px solid var(--border) !important;
  border-top: none;
  white-space: nowrap;
  vertical-align: middle;
}

.table tbody tr {
  transition: background 0.1s;
  cursor: pointer;
}

.table-hover tbody tr:hover {
  background-color: #f8faff !important;
}

.table tbody td {
  padding: 12px 16px;
  font-size: 13.5px;
  vertical-align: middle;
  border-color: var(--border);
  color: var(--text-primary);
}

/* ── CELL TYPES ───────────────────────────────────────── */
.cell-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.cell-cf {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-secondary);
}

.cell-valore {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  text-align: right !important;
  white-space: nowrap;
}

.cell-muted  { color: var(--text-secondary); font-size: 13px; }
.cell-phone  { color: var(--text-secondary); white-space: nowrap; }
.cell-email  { color: var(--accent); font-size: 13px; }
.cell-small  { font-size: 12.5px; color: var(--text-secondary); }

/* ── AVATAR + CLIENTE ─────────────────────────────────── */
.cell-cliente { display: flex; align-items: center; gap: 10px; }
.client-info  { display: flex; flex-direction: column; }
.client-nome  { font-weight: 500; font-size: 13.5px; color: var(--text-primary); }
.client-tipo  { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.client-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-family: var(--font-base);
  line-height: 1;
}
.client-avatar.privato { background: #eff6ff; color: #2563eb; }
.client-avatar.azienda { background: #f0fdf4; color: #16a34a; border-radius: 8px; }

/* ── BADGES COMMESSE ──────────────────────────────────── */
.badges-wrap { display: flex; flex-wrap: wrap; gap: 4px; max-width: 280px; }

.badge-intervento,
.badge-servizio {
  display: inline-flex; align-items: center;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1.5;
}

.badge-intervento {
  background: var(--badge-int-bg);
  color: var(--badge-int);
  border-color: var(--badge-int-brd);
}

.badge-servizio {
  background: var(--badge-srv-bg);
  color: var(--badge-srv);
  border-color: var(--badge-srv-brd);
}

/* ── STATUS BADGE (semaforo — solo contenitore visivo) ── */
/* La logica che assegna il colore resta INVARIATA nel backend */
.badge-stato {
  font-size: 0.75rem;
  padding: 0.35em 0.65em;
  border-radius: 20px;
  font-weight: 500;
}

/* ── KPI CARDS (Dashboard) ────────────────────────────── */
.kpi-card {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.kpi-card:hover { transform: translateY(-2px); }
.kpi-value { font-size: 1.8rem; font-weight: 700; font-family: var(--font-mono); }
.kpi-label { font-size: 0.85rem; color: var(--text-secondary); }

/* ── DATATABLES override ──────────────────────────────── */
.dataTables_wrapper { font-family: var(--font-base); }

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  padding: 10px 16px 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  background: #f9fafb;
}

.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-family: var(--font-base);
  outline: none;
  color: var(--text-primary);
  margin-left: 6px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 13px;
  font-family: var(--font-base);
  margin: 0 4px;
  outline: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 6px !important;
  font-size: 13px;
  padding: 4px 10px !important;
  color: var(--text-secondary) !important;
  border: 1px solid transparent !important;
  transition: all 0.12s;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:not(.current):hover {
  background: var(--accent-light) !important;
  border-color: var(--border) !important;
  color: var(--accent) !important;
}

/* ── FORM ─────────────────────────────────────────────── */
.form-label {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.form-control,
.form-select {
  border-color: var(--border);
  font-size: 0.875rem;
  font-family: var(--font-base);
  color: var(--text-primary);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.08);
}

/* ── DROPBOX PANEL (invariato) ────────────────────────── */
.dropbox-panel {
  position: fixed;
  right: 0; top: 0;
  width: 50%; height: 100vh;
  background: var(--surface);
  z-index: 1050;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  transform: translateX(100%);
  transition: transform 0.3s ease;
}
.dropbox-panel.open { transform: translateX(0); }
.dropbox-panel .panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem; border-bottom: 1px solid var(--border);
}
.dropbox-panel iframe { width: 100%; height: calc(100vh - 60px); border: none; }

/* ── LOGICA APPLICATIVA — PRESERVATA INTATTA ──────────────
   Queste classi sono generate dal backend sulla base di
   regole business validate. Non modificare semantica.
────────────────────────────────────────────────────────── */
tr.inattiva  { opacity: 0.5; background: #f8f9fa; }
.pill-si     { color: #198754; font-weight: 600; }
.pill-no     { color: #adb5bd; }

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    margin-left: -230px;
    position: fixed;
    z-index: 1040;
    height: 100vh;
  }
  #sidebar.show { margin-left: 0; }
  .dropbox-panel { width: 100%; }
  .app-topbar    { padding: 0 14px; }
  .content-area  { padding: 14px 16px; }
}

/* ── BOOTSTRAP CARD — override per coerenza design system ─
   I template non ancora aggiornati usano .card Bootstrap.
   Questi stili li allineano al design system senza toccare
   la struttura HTML esistente.
────────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow) !important;
  background: var(--surface);
}

.card-body {
  font-family: var(--font-base);
}

.card-header {
  background: #f9fafb !important;
  border-bottom: 1px solid var(--border) !important;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── TITOLO PAGINA inline (template non ancora aggiornati) ─
   Le schermate non ancora migrate al blocco page_header
   mostrano il titolo dentro content-area. Stile coerente.
────────────────────────────────────────────────────────── */
.content-area > .d-flex.justify-content-between:first-child h4,
.content-area > .d-flex.justify-content-between:first-child h5 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0;
}

.content-area > .d-flex.justify-content-between:first-child .badge.bg-secondary {
  background: var(--accent) !important;
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ═══════════════════════════════════════════════════════════
   DETAIL PAGE — commessa/dettaglio layout
   Stili aggiuntivi per header-card, summary-row, tab custom,
   section-cards, kv-tables, inline-status.
   Non sovrascrivono logica applicativa esistente.
═══════════════════════════════════════════════════════════ */

/* ── Header card (titolo + summary boxes) ───────────── */
.header-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 22px 24px 18px;
  margin-bottom: 18px;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 18px;
}
.page-kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.page-title {
  font-size: 28px;
  line-height: 1.1;
  margin: 0 0 8px 0;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--text-primary);
}
.page-subtitle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 15px;
}
.head-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.btn-head {
  min-height: 40px;
  border-radius: 12px;
  padding: 0 16px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-primary);
  font: 700 14px var(--font-base);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  transition: .18s ease;
  white-space: nowrap;
}
.btn-head:hover { transform: translateY(-1px); color: var(--text-primary); }
.btn-head-primary { background: var(--accent-light); border-color: #bfdbfe; color: var(--accent-dark); }
.btn-head-outline { border-color: var(--accent); color: var(--accent); }

/* ── Summary row (4 boxes stato) ───────────────────── */
.summary-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.summary-box {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  border-radius: 14px;
  padding: 14px;
}
.summary-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .07em;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.summary-value { font-size: 14px; font-weight: 700; margin-bottom: 5px; }
.summary-note  { font-size: 11.5px; color: var(--text-secondary); line-height: 1.45; }

/* ── Status pill (nei summary box) ─────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
}
.status-pill::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.status-pill.success { background: #f0fdf4; color: #15803d; border-color: #86efac; }
.status-pill.warning { background: #fffbeb; color: #d97706; border-color: #fcd34d; }
.status-pill.danger  { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.status-pill.info    { background: #ecfeff; color: #0891b2; border-color: #a5f3fc; }
.status-pill.neutral { background: #f8fafc; color: #6b7280; border-color: var(--border); }

/* ── Tab custom (sostituisce Bootstrap nav-tabs) ────── */
.detail-tabs {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  padding: 0 2px;
}
.detail-tab {
  position: relative;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 12px 12px 0 0;
  background: transparent;
  color: var(--accent);
  padding: 11px 16px;
  font: 700 13.5px var(--font-base);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: .15s ease;
  margin-bottom: -1px;
  white-space: nowrap;
}
.detail-tab:hover { background: rgba(37,99,235,.04); }
.detail-tab.active {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border);
  box-shadow: 0 -3px 10px rgba(15,23,42,.03);
}
.dtab-count {
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #6b7280;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
}
.dtab-count.cyan { background: #06b6d4; }

/* ── Tab panel ──────────────────────────────────────── */
.detail-tab-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.detail-tab-panel.active { display: block; }
.panel-actions { display: flex; justify-content: flex-end; gap: 10px; margin-bottom: 14px; }

/* ── Section card (dentro i panel) ─────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.section-card { border: 1px solid var(--border); background: #f8fafc; border-radius: 14px; overflow: hidden; }
.section-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
}
.section-title { margin: 0; font-size: 13px; font-weight: 800; color: var(--text-primary); }
.section-note  { font-size: 11.5px; color: var(--text-secondary); }

/* ── KV table (key-value nei section-card) ──────────── */
.kv { width: 100%; border-collapse: collapse; }
.kv tr { border-bottom: 1px solid var(--border); }
.kv tr:last-child { border-bottom: none; }
.kv th, .kv td { padding: 11px 14px; text-align: left; vertical-align: top; }
.kv th {
  width: 38%;
  color: #64748b;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
  font-size: 11px;
  background: rgba(255,255,255,.55);
}
.kv td { font-size: 13.5px; color: var(--text-primary); font-weight: 500; line-height: 1.55; }
.value-mono    { font-family: var(--font-mono); }
.value-success { color: #15803d !important; font-weight: 800 !important; }
.value-danger  { color: #dc2626 !important; font-weight: 800 !important; }

/* ── Inline status (dot + label) ───────────────────── */
.inline-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
  font-size: 13px;
}
.inline-status::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.inline-status.done    { color: #15803d; }
.inline-status.working { color: #d97706; }
.inline-status.blocked { color: #dc2626; }
.inline-status.todo    { color: #6b7280; }
.inline-status.info    { color: #0891b2; }

/* ── Table data (pratiche e commesse collegate) ─────── */
table.dtable { width: 100%; border-collapse: collapse; }
table.dtable thead th {
  background: #f8fafc;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
}
table.dtable tbody tr { border-bottom: 1px solid var(--border); transition: background .12s; }
table.dtable tbody tr:last-child { border-bottom: none; }
table.dtable tbody tr:hover { background: #f8fbff; }
table.dtable td { padding: 12px 12px; font-size: 13.5px; vertical-align: middle; }

/* ── Icon button / open button (azioni righe) ───────── */
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: .15s ease;
}
.icon-btn:hover { border-color: var(--accent); }
.icon-btn.warning { color: #eab308; border-color: #fcd34d; background: #fffef0; }
.icon-btn.success { color: #15803d; border-color: #86efac; background: #f0fdf4; }
.open-btn {
  min-height: 34px; padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--accent);
  background: #fff; color: var(--accent);
  font: 700 13px var(--font-base);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  text-decoration: none;
  transition: .15s ease;
}
.tag-yes {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 22px; padding: 0 7px;
  border-radius: 7px; background: #198754; color: #fff;
  font-size: 11px; font-weight: 800;
}

@media (max-width: 992px) {
  .summary-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}

/* ── Dashboard Direzione ─────────────────────────────── */

/* Tab switcher dashboard */
.dash-tab-bar {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
}
.dash-tab {
  display: inline-flex;
  align-items: center;
  padding: 8px 18px 10px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px 8px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  position: relative;
  bottom: -1px;
  transition: color .15s ease;
}
.dash-tab:hover { color: var(--accent); }
.dash-tab.active {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--border);
  border-bottom-color: var(--surface);
}

/* Etichetta sezione */
.dash-section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .09em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: .75rem;
}

/* Card KPI Direzione */
.dash-kpi-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.dash-kpi-card .card-body {
  padding: 1.1rem 1.25rem;
}
.dash-kpi-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: .35rem;
}
.dash-kpi-big {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-primary);
  margin-bottom: .3rem;
  font-variant-numeric: tabular-nums;
}
.dash-kpi-sub {
  font-size: .78rem;
  color: var(--text-muted);
}
.dash-kpi-red    { color: #dc2626; }
.dash-kpi-orange { color: #d97706; }
.dash-kpi-green  { color: #16a34a; }

/* Righe semaforo nelle card stati lavorazione */
.dash-sem-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
}
.dash-sem-dot { font-size: .6rem; flex-shrink: 0; }
.dash-sem-label { flex: 1; font-size: .85rem; color: var(--text-secondary); }
.dash-sem-count {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 24px;
  text-align: right;
}

/* Tabelle riepilogative dashboard */
.dash-table thead th {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  color: var(--text-muted);
  text-transform: uppercase;
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding-top: .5rem;
  padding-bottom: .5rem;
}
.dash-table tbody td {
  font-size: .875rem;
  color: var(--text-primary);
  padding-top: .55rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--border);
}

/* Tabella per operatore */
.dash-op-table thead th {
  font-size: .65rem;
  line-height: 1.3;
  vertical-align: bottom;
}
.dash-th-sub {
  font-size: .6rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
}
.dash-area-col { min-width: 90px; }

/* Badge scaduti / in scadenza nella tabella operatori */
.badge-op-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 20px;
  background: #fee2e2;
  color: #dc2626;
  font-weight: 700;
  font-size: .82rem;
}
.badge-op-warning {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 20px;
  background: #fef3c7;
  color: #d97706;
  font-weight: 700;
  font-size: .82rem;
}

/* Chip per dettaglio area (tot / rosso / giallo) */
.dash-area-chip {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-size: .78rem;
}
.dash-area-tot  { color: var(--text-primary); font-weight: 600; }
.dash-area-red  { color: #dc2626; font-weight: 700; font-size: .72rem; }
.dash-area-yel  { color: #d97706; font-weight: 700; font-size: .72rem; }

/* Riga "Non assegnata" nella tabella operatori */
.dash-op-unassigned {
  background: #fffbeb;
}
.dash-op-unassigned td {
  color: #92400e;
}
.dash-op-unassigned .dash-area-tot { color: #92400e; }
