/* ================================================================
   EWEKA GESTIONALE — Design System v2
   Ispirazione: Bigin by Zoho (clean, minimal, white-first)
   Font: Outfit (Google Fonts)
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ─────────────────────────────────────────────── */
:root {
  --primary:       #f15d60;
  --primary-dark:  #d94346;
  --primary-light: #fde8e8;
  --primary-mid:   rgba(241,93,96,0.12);

  --text:          #111827;
  --text-muted:    #6b7280;
  --text-light:    #9ca3af;

  --bg:            #f3f4f6;
  --bg-card:       #ffffff;
  --bg-white:      #ffffff;

  --border:        #e5e7eb;
  --border-md:     #d1d5db;

  --sidebar-bg:    #ffffff;
  --sidebar-border: #e5e7eb;
  --sidebar-w:     220px;

  --success:  #27ae60;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --info:     #6366f1;

  --radius:    6px;
  --radius-lg: 10px;
  --shadow:    0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
}

/* ── Reset & Base ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  scrollbar-width: thin;
  scrollbar-color: #e5e7eb transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 2px; }

.sidebar-logo {
  padding: 1.1rem 1rem 0.9rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo img { height: 26px; width: auto; display: block; }

.sidebar-logo .tagline {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 4px;
  letter-spacing: 0.3px;
}

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 1rem;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.13s;
  border-left: 2px solid transparent;
  text-decoration: none;
  border-radius: 0 6px 6px 0;
  margin-right: 8px;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  border-left-color: var(--primary);
  font-weight: 500;
}

.nav-item i { font-size: 15px; flex-shrink: 0; }
.nav-item.active i { color: var(--primary); }

.nav-bottom {
  padding: 0.75rem 0;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

/* ── Main content ──────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  padding: 1.5rem 1.75rem;
  min-height: 100vh;
}

/* ── Top bar ───────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

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

/* ── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

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

/* ── Metric cards ──────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow);
  transition: box-shadow .15s;
}

.metric-card:hover { box-shadow: var(--shadow-md); }

.metric-card .m-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

.metric-card .m-value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.metric-card .m-sub {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

.metric-card.accent {
  background: var(--primary);
  border-color: var(--primary-dark);
}

.metric-card.accent .m-label,
.metric-card.accent .m-value,
.metric-card.accent .m-sub { color: rgba(255,255,255,0.92); }

/* ── Grid layouts ──────────────────────────────────────────────── */
.grid-2   { display: grid; grid-template-columns: 1fr 1fr;     gap: 12px; }
.grid-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr;     gap: 12px; }
.grid-3-1 { display: grid; grid-template-columns: 3fr 1fr;     gap: 12px; }

.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

/* ── Tables ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table.eweka-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.eweka-table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  white-space: nowrap;
}

table.eweka-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

table.eweka-table tbody tr {
  transition: background .1s;
}

table.eweka-table tbody tr:hover {
  background: #f8f8fb;
}

table.eweka-table tbody tr:last-child td { border-bottom: none; }

/* Checkbox column (Bigin-style bulk select) */
table.eweka-table th:first-child,
table.eweka-table td:first-child {
  width: 36px;
  padding-right: 4px;
}

/* ── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Outfit', sans-serif;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.13s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-dark);
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border-md);
}
.btn-outline:hover { background: var(--bg); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 7px; font-size: 11px; border-radius: 4px; }

.btn-danger  { background: var(--danger);  color: #fff; border-color: #c0392b; }
.btn-success { background: var(--success); color: #fff; border-color: #219a52; }
.btn-info    { background: var(--info);    color: #fff; border-color: #4f46e5; }

/* Icon button */
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--border-md);
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer; transition: all .13s;
  font-size: 15px;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }

/* ── Forms ─────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }

/* ── Panel form rows (stile crm-attivita) ─────────────────────── */
.pf-row { margin-bottom: 14px; }
.pf-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); margin-bottom: 5px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-control {
  width: 100%;
  padding: 8px 11px;
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  background: var(--bg-white);
  color: var(--text);
  transition: border-color 0.13s, box-shadow 0.13s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(241,93,96,0.1);
}

select.form-control { cursor: pointer; }

.form-row   { display: grid; grid-template-columns: 1fr 1fr;       gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr;   gap: 12px; }

/* ── Search bar ────────────────────────────────────────────────── */
.search-input {
  position: relative; display: flex; align-items: center;
}

.search-input input {
  padding: 7px 11px 7px 34px;
  font-size: 13px;
  font-family: 'Outfit', sans-serif;
  border: 1px solid var(--border-md);
  border-radius: var(--radius);
  background: var(--bg-white);
  color: var(--text);
  transition: border-color .13s, box-shadow .13s;
  width: 220px;
}

.search-input input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(241,93,96,0.08);
}

.search-input i {
  position: absolute; left: 10px;
  color: var(--text-muted); font-size: 14px; pointer-events: none;
}

/* ── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #e0e7ff; color: #3730a3; }
.badge-neutral { background: #f1f2f4; color: #52535a; }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }

/* ── Row items ─────────────────────────────────────────────────── */
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: none; }

.list-row-link {
  text-decoration: none; color: inherit; cursor: pointer;
  transition: background .13s;
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 0 -8px;
}
.list-row-link:last-child { border-bottom: none; }
.list-row-link:hover { background: var(--bg); text-decoration: none; }

.list-row .row-main,
.list-row-link .row-main { font-size: 13px; font-weight: 500; }

.list-row .row-sub,
.list-row-link .row-sub  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ── Progress bar occupazione ──────────────────────────────────── */
.occ-bar {
  width: 80px; height: 5px;
  background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 3px;
}
.occ-fill { height: 100%; border-radius: 3px; }
.occ-high { background: var(--success); }
.occ-mid  { background: var(--warning); }
.occ-low  { background: var(--danger); }

/* ── Login page ────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo img { height: 40px; }
.login-title { font-size: 20px; font-weight: 600; text-align: center; margin-bottom: 0.25rem; }
.login-sub   { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 1.75rem; }

/* ── Alerts ────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}
.alert-danger  { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-success { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fde68a; }

/* ── Divider ───────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ── Breadcrumb ────────────────────────────────────────────────── */
.breadcrumb { font-size: 12px; color: var(--text-muted); margin-bottom: 0.5rem; }
.breadcrumb a   { color: var(--text-muted); }
.breadcrumb span { color: var(--text); font-weight: 500; }

/* ── Empty state ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 1rem; opacity: 0.25; display: block; }
.empty-state p { font-size: 14px; }

/* ── Tabs ──────────────────────────────────────────────────────── */
.eweka-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}

.eweka-tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  font-family: 'Outfit', sans-serif;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all .13s;
}
.eweka-tab-btn:hover { color: var(--text); }
.eweka-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.eweka-tab-panel { display: none; }
.eweka-tab-panel.active { display: block; }

/* ── Slide-in panel (CRM detail) ───────────────────────────────── */
.slide-panel {
  position: fixed;
  top: 0; right: -480px; bottom: 0;
  width: 460px;
  background: var(--bg-white);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.08);
  z-index: 500;
  transition: right .25s ease;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.slide-panel.open { right: 0; }

.slide-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.slide-panel-header h3 { font-size: 15px; font-weight: 600; }

.slide-panel-body {
  flex: 1; overflow-y: auto; padding: 1.25rem;
}

.slide-panel-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.2); z-index: 499;
}
.slide-panel-overlay.active { display: block; }

/* ── View toggle (list/kanban/table) ───────────────────────────── */
.view-toggle {
  display: flex; gap: 2px;
  background: var(--bg); border: 1px solid var(--border-md);
  border-radius: var(--radius); padding: 3px;
}
.view-toggle-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 4px; border: none; background: none;
  color: var(--text-muted); cursor: pointer; transition: all .13s;
  font-size: 15px;
}
.view-toggle-btn.active,
.view-toggle-btn:hover { background: var(--bg-white); color: var(--text); box-shadow: var(--shadow); }

/* ── Kanban board ──────────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 500px;
}

.kanban-col {
  flex: 0 0 230px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
  padding: 0 2px;
}

.kanban-col-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  display: flex; align-items: center; gap: 6px;
}

.kanban-col-count {
  font-size: 11px;
  background: var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 1px 7px;
  font-weight: 600;
}

.kanban-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 11px;
  margin-bottom: 7px;
  cursor: grab;
  transition: box-shadow .13s, transform .1s;
  box-shadow: var(--shadow);
}
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: .5; transform: rotate(1deg); }

.kanban-card-title { font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.kanban-card-meta  { font-size: 11px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.kanban-col.drag-over { background: var(--primary-mid); border: 1.5px dashed var(--primary); }

/* ── Avatar ────────────────────────────────────────────────────── */
.avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff;
  flex-shrink: 0;
}

/* ── Filters bar (Bigin-style) ─────────────────────────────────── */
.filters-bar {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 1rem; flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px;
  font-size: 12px; font-weight: 500;
  background: var(--bg-white);
  border: 1px solid var(--border-md);
  border-radius: 20px;
  cursor: pointer;
  transition: all .13s;
  color: var(--text);
  white-space: nowrap;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chip.active { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.filter-chip i { font-size: 13px; }

/* ── Toolbar (Bigin sheet header) ──────────────────────────────── */
.sheet-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
  flex-wrap: wrap;
}
.sheet-toolbar-left  { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; }
.sheet-toolbar-right { display: flex; align-items: center; gap: 6px; }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(16,17,35,.45); z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  padding: 1.5rem;
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px;
  border-radius: 6px; border: none;
  background: var(--bg); color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; transition: all .13s;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 1.25rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ── Notifica dot ──────────────────────────────────────────────── */
.notif-dot {
  display: inline-block; width: 7px; height: 7px;
  background: var(--primary); border-radius: 50%;
  margin-left: 4px; vertical-align: middle;
}

/* ── Mobile header (visibile solo via CSS, niente JS) ──────────── */
.mobile-header {
  display: none;
  position: fixed; top: 0; left: 0; right: 0;
  height: 52px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  z-index: 200;
  align-items: center;
  padding: 0 1rem;
  gap: 12px;
}
.mobile-header img { height: 26px; width: auto; }

.hamburger {
  background: none; border: none; cursor: pointer;
  padding: 10px; margin-left: auto;
  min-width: 44px; min-height: 44px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 5px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.hamburger span {
  display: block; width: 22px; height: 2px;
  background: var(--text-muted); border-radius: 2px;
  transition: all 0.25s;
}

/* Overlay mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 150;
}
.sidebar-overlay.active { display: block; }

/* ── Touch targets globali ─────────────────────────────────────── */
.btn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.nav-item {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.list-row-link {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-2, .grid-2-1, .grid-3-1 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 160;
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }

  .main {
    margin-left: 0;
    padding: 1.25rem 1rem;
    padding-top: calc(52px + 1.25rem);
  }

  .topbar {
    flex-wrap: wrap; gap: 10px;
    margin-bottom: 1rem;
  }
  .topbar h1 { font-size: 16px; }
  .topbar-right { flex-wrap: wrap; gap: 8px; }

  .metrics-grid { grid-template-columns: 1fr 1fr !important; }
  .grid-2, .grid-2-1, .grid-3-1, .grid-3 { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  /* Tabelle: card impilate invece di scroll orizzontale (data-label iniettato da sidebar.php) */
  .table-wrap { overflow-x: visible; }
  table.eweka-table { min-width: 0; }
  table.eweka-table thead, table.eweka-table tfoot { display: none; }
  table.eweka-table, table.eweka-table tbody, table.eweka-table tr, table.eweka-table td {
    display: block; width: 100%;
  }
  table.eweka-table tbody tr {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 10px;
    padding: 2px 0;
  }
  table.eweka-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--bg);
    text-align: right;
    width: auto;
  }
  table.eweka-table td:last-child { border-bottom: none; }
  table.eweka-table td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .4px;
    color: var(--text-muted);
    text-align: left;
    flex-shrink: 0;
  }
  table.eweka-table td:not([data-label])::before,
  table.eweka-table td[data-label=""]::before { content: none; }
  /* Tabelle esplicitamente escluse dalla vista a card (es. calendario) */
  table.eweka-table.no-card-mobile,
  table.eweka-table.no-card-mobile tbody,
  table.eweka-table.no-card-mobile tr,
  table.eweka-table.no-card-mobile td {
    display: revert;
  }

  .card { padding: 1rem; }
  .metric-card { padding: 1rem; }
  .metric-card .m-value { font-size: 22px; }

  /* Bottoni touch-friendly */
  .btn {
    font-size: 13px;
    padding: 8px 14px;
    min-height: 38px;
  }
  .btn-sm {
    font-size: 12px;
    padding: 6px 12px;
    min-height: 34px;
  }

  /* Nav items più alti su mobile */
  .nav-item { padding: 9px 1rem; min-height: 40px; }

  .slide-panel { width: 100%; right: -100%; }
  .hide-mobile { display: none !important; }

  /* P&L responsive: non usare larghezze fisse inline */
  .pl-row-label { width: 52px !important; min-width: 52px; }
  .pl-row-value { width: 80px !important; min-width: 80px; }

  /* ── Tab nav scorrevoli su mobile ─────────────────────────────── */
  /* Le schede (tabs) scorrono orizzontalmente invece di comprimersi  */
  .eweka-tabs,
  .cal-tab-nav,
  .pan-tab-nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    scrollbar-width: none;        /* Firefox: nasconde scrollbar */
    -ms-overflow-style: none;     /* IE/Edge: nasconde scrollbar */
    /* Padding per non tagliare il bordo attivo dell'ultima tab */
    padding-bottom: 0;
  }
  .eweka-tabs::-webkit-scrollbar,
  .cal-tab-nav::-webkit-scrollbar,
  .pan-tab-nav::-webkit-scrollbar { display: none; }

  /* I singoli bottoni tab non si restringono */
  .eweka-tab-btn,
  .cal-tab,
  .pan-tab {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* ── Calendario mensile: scroll orizzontale su mobile ─────────── */
  .cal-grid-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 10px;
    /* Indicatore scroll a destra */
    background:
      linear-gradient(to right, white 30%, rgba(255,255,255,0)) left center / 40px 100% no-repeat,
      linear-gradient(to left,  #f0f0f0 0%, rgba(255,255,255,0)) right center / 24px 100% no-repeat;
    background-attachment: local, scroll;
  }
  .cal-grid-scroll-wrap .cal-grid {
    min-width: 560px; /* 7 col × 80px min */
  }
  /* Celle con altezza minima uniforme — risolve righe irregolari */
  .cal-grid-scroll-wrap .cal-cell {
    min-height: 80px;
  }
}

/* ── Barra filtri responsive (usata da tutte le pagine con form GET
   immobile/mese/anno/canale/stato ecc.) — aggiungere class="filtri-form"
   al <form> per attivarla. Su desktop resta il layout esistente (flex-wrap
   inline nel markup); qui sotto sovrascriviamo solo tablet/mobile. ── */
@media (max-width: 900px) {
  .filtri-form {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px 12px !important;
    align-items: flex-end !important;
  }
  .filtri-form .form-group {
    flex: 1 1 calc(50% - 6px) !important;
    min-width: 130px !important;
    margin: 0 !important;
  }
  .filtri-form .form-group.filtro-full { flex-basis: 100% !important; }
  .filtri-form > .btn,
  .filtri-form > button,
  .filtri-form > a.btn {
    flex: 1 1 calc(50% - 6px) !important;
    height: 42px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
  }
}

@media (max-width: 560px) {
  .filtri-form .form-group {
    flex: 1 1 100% !important;
  }
  .filtri-form > .btn,
  .filtri-form > button,
  .filtri-form > a.btn {
    flex: 1 1 100% !important;
  }
}

/* ── Stessa cura per le toolbar di ricerca/filtro delle pagine CRM
   (.sheet-toolbar, usata da crm-ospiti/proprietari/fornitori/attivita) ── */
@media (max-width: 900px) {
  .sheet-toolbar-left {
    flex: 1 1 100% !important;
  }
  .sheet-toolbar-left .search-input {
    flex: 1 1 100% !important;
  }
  .sheet-toolbar-left .search-input input {
    width: 100% !important;
  }
  .sheet-toolbar-left select,
  .sheet-toolbar-left .form-control {
    flex: 1 1 calc(50% - 4px) !important;
    width: auto !important;
  }
  .sheet-toolbar-right {
    flex: 1 1 100% !important;
    justify-content: flex-start !important;
  }
}
@media (max-width: 560px) {
  .sheet-toolbar-left select,
  .sheet-toolbar-left .form-control {
    flex: 1 1 100% !important;
  }
}

/* ── Pannello filtri collassabile su mobile/tablet ────────────────────────
   Su desktop il pannello è sempre aperto (il toggle è nascosto). Su schermi
   stretti la barra filtri intera occupava troppo spazio verticale prima
   della lista sottostante: qui la nascondiamo di default e la si apre
   toccando il pulsante "Filtri". Puro CSS (checkbox nascosto + label),
   nessun JS necessario.
   Markup atteso:
   <div class="card mb-4 filtri-card">
     <input type="checkbox" id="ID" class="filtri-toggle-cb">
     <label for="ID" class="filtri-toggle-btn"><i class="ti ti-filter"></i> Filtri <i class="ti ti-chevron-down filtri-chevron"></i></label>
     <form class="filtri-form" ...>...</form>
   </div>                                                                    ── */
.filtri-toggle-cb { position: absolute; opacity: 0; pointer-events: none; }
.filtri-toggle-btn { display: none; }
@media (max-width: 900px) {
  .filtri-card { position: relative; }
  .filtri-toggle-btn {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 4px; margin: -4px 0 0;
    font-size: 13px; font-weight: 600; color: var(--text);
    cursor: pointer; user-select: none;
  }
  .filtri-chevron { margin-left: auto; transition: transform .18s; font-size: 15px; color: var(--text-muted); }
  .filtri-toggle-cb:checked ~ .filtri-toggle-btn .filtri-chevron { transform: rotate(180deg); }
  .filtri-toggle-cb ~ .filtri-form {
    max-height: 0; overflow: hidden; opacity: 0;
    margin: 0; padding-top: 0; padding-bottom: 0;
    transition: max-height .22s ease, opacity .18s ease;
  }
  .filtri-toggle-cb:checked ~ .filtri-form {
    max-height: 600px; overflow: visible; opacity: 1;
    margin-top: 10px;
  }
}

@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr 1fr !important; }
  .main { padding: 0.875rem 0.75rem; padding-top: calc(52px + 0.875rem); }

  /* Su schermi molto piccoli le card KPI rimangono 2 colonne
     ma con font ridotto */
  .metric-card .m-value { font-size: 20px; }
  .metric-card .m-label { font-size: 11px; }

  /* Topbar semplificato */
  .topbar h1 { font-size: 15px; }
  .breadcrumb { display: none; }

  /* Tabelle: scroll più evidente */
  .table-wrap::after {
    content: '';
    position: absolute; top: 0; right: 0; bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
    pointer-events: none;
  }
  .table-wrap { position: relative; }
}
