/* ═══════════════════════════════════════════════════════════════
   OfficinaPRO — style.css v2
   Palette: arancione #F97316, sidebar scura #0F172A
═══════════════════════════════════════════════════════════════ */

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

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

:root {
  --primary:     #F97316;
  --primary-d:   #EA6C0A;
  --primary-l:   #FEF3E2;
  --primary-xl:  #FFFBF5;

  --blue:        #3B82F6;
  --blue-d:      #2563EB;
  --blue-l:      #DBEAFE;

  --accent-g:    #10B981;
  --accent-g-l:  #D1FAE5;
  --accent-r:    #EF4444;
  --accent-r-l:  #FEE2E2;
  --accent-y:    #F59E0B;
  --accent-y-l:  #FEF3C7;
  --accent-b:    #3B82F6;
  --accent-b-l:  #DBEAFE;

  --sidebar-bg:  #0F172A;
  --sidebar-txt: #94A3B8;
  --sidebar-act: #F97316;
  --sidebar-act-bg: rgba(249,115,22,.12);

  --gray-50:     #F8FAFC;
  --gray-100:    #F1F5F9;
  --gray-200:    #E2E8F0;
  --gray-300:    #CBD5E1;
  --gray-400:    #94A3B8;
  --gray-600:    #475569;
  --gray-700:    #334155;
  --gray-900:    #0F172A;

  --bg:          #F1F5F9;
  --sidebar-w:   230px;
  --topbar-h:    62px;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 1px 4px rgba(15,23,42,.06), 0 4px 16px rgba(15,23,42,.06);
  --shadow-md:   0 4px 24px rgba(15,23,42,.10);
  --shadow-lg:   0 8px 40px rgba(15,23,42,.16);
  --transition:  all .16s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--gray-700);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  /* Subtle diagonal grid — gives texture without distraction */
  background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 40L40 0' stroke='%23CBD5E1' stroke-width='.3' fill='none' opacity='.4'/%3E%3C/svg%3E");
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  padding: 0 20px 0 0;
  z-index: 100;
  gap: 16px;
  border-bottom: 1px solid rgba(255,255,255,.05);
  /* Subtle orange shimmer at the very top */
  box-shadow: 0 1px 0 rgba(249,115,22,.25), 0 2px 12px rgba(0,0,0,.3);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  text-decoration: none;
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding: 0 16px;
  height: 100%;
  border-right: 1px solid rgba(255,255,255,.06);
  letter-spacing: -.01em;
}
.topbar-logo-img {
  width: 38px; height: 38px;
  object-fit: contain;
  flex-shrink: 0;
  margin-right: 10px;
  filter: drop-shadow(0 0 6px rgba(59,130,246,.4));
}
.topbar-brand .brand-name {
  display: flex; flex-direction: column; line-height: 1;
}
.topbar-brand .brand-name .brand-main {
  font-size: 15px; font-weight: 800; color: #e2e8f0; letter-spacing: -.02em;
}
.topbar-brand .brand-name .brand-main .brand-gest {
  color: #3B82F6;
}
.topbar-brand .brand-name .brand-sub {
  font-size: 9.5px; font-weight: 700; color: #94A3B8; letter-spacing: .12em; text-transform: uppercase; margin-top: 2px;
}
/* Fallback se logo.png non esiste ancora */
.topbar-logo-img[src="/assets/logo.jpg"]:not([complete]) {
  display: none;
}
.topbar-spacer { flex: 1; }
/* Quick info in topbar */
.topbar-info {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: #CBD5E1; font-weight: 500;
  padding: 5px 14px;
  border-right: 1px solid rgba(255,255,255,.12);
}
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px; color: #E2E8F0;
}
.topbar-user .avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 13px;
  box-shadow: 0 0 0 2px rgba(249,115,22,.45);
}
.topbar-user span { color: #F1F5F9; font-weight: 600; }

/* Logout: bottone visibile, non più un link quasi invisibile */
.topbar-logout {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 4px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
  color: #E2E8F0 !important;
  font-size: 12.5px; font-weight: 600;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
}
.topbar-logout .icon {
  width: 15px; height: 15px; margin-right: 0; opacity: 1;
}
.topbar-logout:hover {
  background: rgba(239,68,68,.18);
  border-color: rgba(239,68,68,.55);
  color: #FCA5A5 !important;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h));
  background: var(--sidebar-bg);
  overflow-y: auto;
  padding: 10px 0;
  z-index: 90;
  border-right: 1px solid rgba(255,255,255,.04);
}
.sidebar-section {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #2D3F55;
  padding: 16px 16px 5px;
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-left: 3px solid transparent;
  color: var(--sidebar-txt);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  margin-bottom: 1px;
}
.sidebar a:hover {
  background: rgba(255,255,255,.05);
  color: #CBD5E1;
  border-left-color: rgba(249,115,22,.3);
}
.sidebar a.active {
  background: rgba(249,115,22,.08);
  color: #fff;
  font-weight: 600;
  border-left-color: var(--primary);
}
.sidebar a.active .icon { color: var(--primary); }
.sidebar a .icon {
  width: 16px; height: 16px;
  flex-shrink: 0;
  opacity: .6;
}
.sidebar a.active .icon { opacity: 1; }
.sidebar a:hover .icon { opacity: .85; }

/* ── Main content ────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 28px 32px;
  min-height: calc(100vh - var(--topbar-h));
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 {
  font-size: 23px;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.03em;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 14px;
  border-left: 4px solid var(--primary);
  line-height: 1.15;
}
.page-header .subtitle {
  font-size: 12.5px;
  color: var(--gray-400);
  margin-top: 4px;
  font-weight: 400;
  padding-left: 18px;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  border: 1px solid var(--gray-200);
  transition: box-shadow .18s;
}
.card:hover { box-shadow: var(--shadow-md); }
/* Card accent variants */
.card-accent-orange { border-top: 3px solid var(--primary); }
.card-accent-green  { border-top: 3px solid var(--accent-g); }
.card-accent-red    { border-top: 3px solid var(--accent-r); }
.card-accent-blue   { border-top: 3px solid var(--blue); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -.01em;
}

/* ── KPI Cards ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  border-radius: var(--radius);
  padding: 22px 20px;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute;
  right: -10px; top: -10px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
}
.kpi-card .kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .8;
  order: 1;
}
.kpi-card .kpi-value {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1;
  order: 2;
}
.kpi-card .kpi-icon {
  position: absolute;
  right: 16px;
  bottom: 16px;
  opacity: .18;
  transform: scale(2.2);
  transform-origin: right bottom;
}

/* Colori KPI */
.kpi-card.kpi-primary {
  background: linear-gradient(135deg, #F97316 0%, #EA580C 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(249,115,22,.3);
}
.kpi-card.kpi-success {
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(16,185,129,.25);
}
.kpi-card.kpi-warning {
  background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(245,158,11,.25);
}
.kpi-card.kpi-danger {
  background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(239,68,68,.25);
}
.kpi-card.kpi-info {
  background: linear-gradient(135deg, #3B82F6 0%, #2563EB 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(59,130,246,.25);
}
.kpi-card.kpi-dark {
  background: linear-gradient(135deg, #334155 0%, #1E293B 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(15,23,42,.2);
}

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

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: var(--gray-900);
  color: #CBD5E1;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 11px 14px;
  text-align: left;
}
thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }
tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background .1s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:nth-child(even) { background: #FAFBFC; }
tbody tr:hover { background: #FFF7F0; }
tbody td { padding: 11px 14px; vertical-align: middle; }
tbody td.mono { font-family: 'Courier New', monospace; font-size: 13px; }
tfoot td {
  padding: 11px 14px;
  font-weight: 700;
  background: var(--gray-50);
  border-top: 2px solid var(--gray-200);
  color: var(--gray-900);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(249,115,22,.3);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-d);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(249,115,22,.4);
}
.btn-success   { background: var(--accent-g); color: #fff; box-shadow: 0 2px 8px rgba(16,185,129,.25); }
.btn-success:hover:not(:disabled) { filter: brightness(.92); transform: translateY(-1px); }
.btn-danger    { background: var(--accent-r); color: #fff; }
.btn-danger:hover:not(:disabled)  { filter: brightness(.92); }
.btn-warning   { background: var(--accent-y); color: #fff; }
.btn-warning:hover:not(:disabled) { filter: brightness(.92); }
.btn-info      { background: var(--blue); color: #fff; }
.btn-info:hover:not(:disabled)    { filter: brightness(.92); }
.btn-ghost {
  background: #fff;
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
}
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); border-color: var(--gray-300); }
.btn-dark { background: var(--gray-900); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #1E293B; }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-lg  { padding: 11px 24px; font-size: 15px; }
.btn-icon { padding: 7px; }
.btn .spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: none;
}
.btn.loading .spinner { display: inline-block; }
.btn.loading .btn-text { display: none; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.form-label .req { color: var(--accent-r); }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-900);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}
.form-control:disabled { background: var(--gray-50); color: var(--gray-400); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-hint  { font-size: 11.5px; color: var(--gray-400); margin-top: 3px; }
.form-error { font-size: 12px; color: var(--accent-r); margin-top: 3px; }
.input-group { display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge-success   { background: #D1FAE5; color: #065F46; }
.badge-danger    { background: #FEE2E2; color: #991B1B; }
.badge-warning   { background: #FEF3C7; color: #92400E; }
.badge-primary   { background: #FEF3E2; color: #C2410C; }
.badge-info      { background: #DBEAFE; color: #1E40AF; }
.badge-secondary { background: var(--gray-100); color: var(--gray-600); }

/* ── Modal ───────────────────────────────────────────────────── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
}
#modal-overlay.open { display: flex; }
#modal-inner {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  animation: modalIn .2s ease;
}
#modal-inner.modal-lg { max-width: 900px; }
#modal-inner.modal-xl { max-width: 1100px; }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.modal-content { display: none; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--gray-900);
  letter-spacing: -.01em;
}
.modal-close {
  background: var(--gray-100); border: none; cursor: pointer;
  color: var(--gray-400); font-size: 18px; line-height: 1;
  padding: 6px 8px; border-radius: 6px;
  transition: var(--transition);
}
.modal-close:hover { color: var(--gray-700); background: var(--gray-200); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 0 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.modal-divider {
  border: none;
  border-top: 1px solid var(--gray-100);
  margin: 12px 24px 0;
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
  gap: 4px;
}
.tab-btn {
  padding: 9px 18px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}
.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Toast ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}
.toast {
  background: var(--gray-900);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 12px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 360px;
  animation: toastIn .25s ease;
  border-left: 4px solid var(--primary);
}
.toast.toast-success { border-left-color: var(--accent-g); }
.toast.toast-error   { border-left-color: var(--accent-r); }
.toast.toast-warning { border-left-color: var(--accent-y); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(24px); height: 0; padding: 0; margin: 0; }
}
.toast.removing { animation: toastOut .25s ease forwards; }

/* ── Search bar ──────────────────────────────────────────────── */
.search-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.search-bar .form-control { max-width: 280px; }

/* ── Filter row ──────────────────────────────────────────────── */
.filter-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

/* ── Pagination ──────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 20px;
}
.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--gray-600);
  border: 1.5px solid var(--gray-200);
  transition: var(--transition);
}
.pagination a:hover  { background: var(--primary-l); border-color: var(--primary); color: var(--primary); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 2px 8px rgba(249,115,22,.3); }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: var(--accent-g-l); color: #065F46; }
.alert-danger  { background: var(--accent-r-l); color: #991B1B; }
.alert-warning { background: var(--accent-y-l); color: #92400E; }
.alert-info    { background: var(--blue-l);     color: #1E40AF; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--gray-400);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h3 { font-size: 16px; color: var(--gray-600); margin-bottom: 6px; font-weight: 600; }

/* ── Chart bars ──────────────────────────────────────────────── */
.chart-bar-container {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 130px;
  padding: 0 2px;
}
.chart-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}
.chart-bar-col:hover .chart-tooltip { display: block; }
.chart-tooltip {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 5px;
  white-space: nowrap;
  margin-bottom: 5px;
  z-index: 10;
}
.chart-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--primary) 0%, #C2410C 100%);
  border-radius: 5px 5px 0 0;
  min-height: 3px;
  transition: height .5s cubic-bezier(.34,1.56,.64,1);
  cursor: default;
}
.chart-bar:hover { filter: brightness(1.08); }
.chart-label {
  font-size: 9.5px;
  color: var(--gray-400);
  margin-top: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Scheda lavoro righe ─────────────────────────────────────── */
.righe-table input, .righe-table select {
  width: 100%;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #fff;
}
.righe-table input:focus, .righe-table select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(249,115,22,.12);
}
.righe-table td { padding: 6px 8px; vertical-align: middle; }
.righe-table .tipo-badge { font-size: 10px; padding: 2px 6px; border-radius: 4px; }

/* ── Planning ────────────────────────────────────────────────── */
.planning-grid {
  display: grid;
  grid-template-columns: 80px repeat(7, 1fr);
  gap: 1px;
  background: var(--gray-200);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.planning-header {
  background: var(--gray-900);
  color: #CBD5E1;
  text-align: center;
  padding: 8px 4px;
  font-size: 11.5px;
  font-weight: 700;
}
.planning-time-label {
  background: var(--gray-50);
  text-align: center;
  padding: 8px 4px;
  font-size: 11px;
  color: var(--gray-400);
  font-weight: 600;
}
.planning-cell {
  background: #fff;
  min-height: 44px;
  padding: 2px;
  position: relative;
}
.planning-event {
  background: rgba(249,115,22,.1);
  border-left: 3px solid var(--primary);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-d);
  cursor: pointer;
  margin: 1px 0;
}
.planning-event:hover { background: var(--primary); color: #fff; }

/* ── Login ───────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-900);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(249,115,22,.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(59,130,246,.1) 0%, transparent 50%);
}
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.35);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .name {
  font-size: 26px;
  font-weight: 800;
  color: var(--gray-900);
  display: block;
  letter-spacing: -.03em;
}
.login-logo .name span { color: var(--primary); }
.login-logo .tagline { font-size: 12.5px; color: var(--gray-400); }
.login-logo .icon-wrap {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  font-size: 26px;
  box-shadow: 0 4px 20px rgba(249,115,22,.35);
}

/* ── Stampa ──────────────────────────────────────────────────── */
@media print {
  .topbar, .sidebar, .no-print { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  body { background: #fff !important; }
}

/* ── Autocomplete ────────────────────────────────────────────── */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: #fff;
  border: 1.5px solid var(--primary);
  border-top: none;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
  z-index: 500;
}
.autocomplete-item {
  padding: 9px 12px;
  cursor: pointer;
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--gray-100);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover, .autocomplete-item.selected {
  background: var(--primary-l);
  color: var(--primary-d);
}
.autocomplete-item .code { font-family: monospace; font-size: 11.5px; color: var(--gray-400); }

/* ── Under-scorta alert ──────────────────────────────────────── */
.scorta-alert {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-y-l);
  border-left: 4px solid var(--accent-y);
  margin-bottom: 6px;
  font-size: 13px;
}

/* ── Stampa documento ────────────────────────────────────────── */
.doc-header { display: flex; justify-content: space-between; margin-bottom: 32px; }
.doc-logo-name { font-size: 22px; font-weight: 800; color: var(--gray-900); }
.doc-info table { width: 100%; }
.doc-info td { padding: 3px 0; font-size: 13px; }
.doc-title {
  font-size: 18px; font-weight: 800;
  letter-spacing: .02em; color: var(--gray-900);
  border-bottom: 3px solid var(--primary);
  padding-bottom: 8px;
  margin: 24px 0;
}
.doc-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; margin-bottom: 28px; }
.doc-party h4 { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--gray-400); margin-bottom: 6px; font-weight: 700; }
.doc-party p { font-size: 13.5px; line-height: 1.7; }
.doc-totals { max-width: 300px; margin-left: auto; margin-top: 24px; }
.doc-totals table { width: 100%; }
.doc-totals td { padding: 5px 8px; font-size: 14px; }
.doc-totals .total-row td { font-size: 16px; font-weight: 800; color: var(--primary); border-top: 2px solid var(--primary); }

/* ── Responsive ──────────────────────────────────────────────── */

/* Hamburger button — visibile solo mobile */
.btn-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  border-radius: 8px;
  flex-shrink: 0;
  transition: background .15s;
  margin-left: 8px;
}
.btn-hamburger:hover { background: rgba(255,255,255,.08); }
.btn-hamburger svg { width: 22px; height: 22px; stroke: #fff; }

/* Overlay per chiudere sidebar su mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 89;
}
.sidebar-overlay.open { display: block; }

@media (max-width: 900px) {
  /* Variabile sidebar = 0 così il main non è spostato */
  :root { --sidebar-w: 0px; }

  /* Hamburger visibile */
  .btn-hamburger { display: flex; }

  /* Topbar: comprimi brand, mantieni logout leggibile */
  .topbar { gap: 8px; padding: 0 12px 0 0; }
  .topbar-brand { width: auto; border-right: none; padding: 0 10px; }
  .topbar-brand .brand-name .brand-sub { display: none; }
  .topbar-info  { display: none !important; }
  .topbar-user  { gap: 8px; }
  .topbar-user > span:not(.badge) { display: none; }
  .topbar-user .badge-primary { display: none; }
  /* Il logout resta visibile ma diventa solo icona */
  .topbar-logout { padding: 7px 10px; }
  .topbar-logout .logout-label { display: none; }

  /* Sidebar: fuori schermo a sinistra, slide-in con classe .open */
  .sidebar {
    transform: translateX(-100%);
    transition: transform .22s cubic-bezier(.4,0,.2,1);
    z-index: 200;
    width: 250px;
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,.4);
  }
  /* Voci sidebar più alte: comode da toccare */
  .sidebar a { padding-top: 11px; padding-bottom: 11px; }

  /* Main content: niente margine sx */
  .main-content {
    margin-left: 0;
    padding: 16px;
  }

  /* Griglie: tutto su colonna singola */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .form-row, .form-row-3    { grid-template-columns: 1fr !important; }

  /* KPI: 2 colonne su mobile */
  .kpi-grid { grid-template-columns: 1fr 1fr; }

  /* Page header: stack verticale, bottoni a tutta larghezza */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-header h1 { font-size: 18px; }
  .page-header > div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-header .btn,
  .page-header > div:last-child > a {
    flex: 1 1 auto;
    justify-content: center;
    min-height: 40px;
  }
  .page-header .btn + .btn { margin-left: 0; }

  /* ── Tabelle: scroll orizzontale SOLO sul wrapper, non sulla card ──
     Così i menu/dropdown dentro la card non vengono tagliati. */
  .card { overflow: visible; }
  .table-wrap,
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Ombra a destra: segnala che si può scorrere */
    background:
      linear-gradient(to right, #fff 30%, rgba(255,255,255,0)) left center / 24px 100% no-repeat,
      linear-gradient(to left,  #fff 30%, rgba(255,255,255,0)) right center / 24px 100% no-repeat,
      linear-gradient(to right, rgba(0,0,0,.10), rgba(0,0,0,0)) left center / 10px 100% no-repeat,
      linear-gradient(to left,  rgba(0,0,0,.10), rgba(0,0,0,0)) right center / 10px 100% no-repeat;
    background-attachment: local, local, scroll, scroll;
  }
  .table-wrap table,
  .table-responsive table,
  .card table { min-width: 620px; }

  /* Colonna azioni sempre raggiungibile e leggibile */
  table td .d-flex { flex-wrap: nowrap; gap: 6px; }

  /* ── Touch target: bottoni icona da 30px → 40px ── */
  .btn-icon {
    padding: 0;
    width: 40px;
    height: 40px;
    min-width: 40px;
    justify-content: center;
  }
  .btn-icon .icon { margin-right: 0; width: 18px; height: 18px; }
  .btn-sm.btn-icon { width: 36px; height: 36px; min-width: 36px; }
  .btn-sm.btn-icon .icon { width: 17px; height: 17px; }

  /* Bottoni normali: altezza minima comoda */
  .btn { min-height: 38px; }

  /* Stat strip: 2 colonne */
  .stat-strip { flex-wrap: wrap; }
  .stat-strip-item { flex: 1 1 48%; border-bottom: 1px solid var(--gray-200); }

  /* Cards doc (fatture/preventivi) */
  .doc-parties { grid-template-columns: 1fr; gap: 16px; }
  .doc-totals  { max-width: 100%; }

  /* Modal: full-width su mobile */
  #modal-inner {
    width: calc(100% - 24px) !important;
    max-width: 100% !important;
    margin: 12px !important;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* ── Barre filtri/ricerca: stack verticale, campi full width ── */
  .search-bar,
  .filter-bar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .search-bar .form-control,
  .filter-bar input,
  .filter-bar select,
  .search-bar input,
  .search-bar select {
    max-width: 100% !important;
    min-width: 0;
    flex: 1 1 100%;
  }
  .search-bar .btn,
  .filter-bar .btn { flex: 1 1 auto; justify-content: center; }

  /* Form: campi comodi da toccare, niente zoom iOS (font >= 16px) */
  .form-control { font-size: 16px; min-height: 42px; }
  textarea.form-control { min-height: 70px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .stat-strip-item { flex: 1 1 100%; }
  .main-content { padding: 12px; }
  .card { padding: 14px; }
  .page-header h1 { font-size: 16px; }

  /* Topbar compatta */
  .topbar { padding: 0 8px 0 0; gap: 4px; }
  .topbar-brand { padding: 0 6px; }
  .topbar-logo-img { width: 32px; height: 32px; margin-right: 7px; }
  .topbar-brand .brand-name .brand-main { font-size: 14px; }
  .topbar-user .avatar { width: 30px; height: 30px; font-size: 12px; }
  .topbar-logout { padding: 6px 9px; }

  /* Bottoni page-header: uno per riga */
  .page-header > div:last-child { flex-direction: column; }
  .page-header .btn,
  .page-header > div:last-child > a { width: 100%; }

  /* Tabelle leggermente più compatte */
  th, td { padding-left: 8px !important; padding-right: 8px !important; }
}

/* ── Lucide Icons ────────────────────────────────────────────── */
.icon {
  width: 16px; height: 16px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
  flex-shrink: 0;
}
/* Lucide sostituisce <i data-lucide> con <svg class="icon">: forziamo
   stroke/fill così l'icona è sempre visibile qualunque sia il contesto. */
svg.icon {
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Un <i data-lucide> non ancora convertito occupa spazio ma è invisibile:
   evita che il layout "salti" e non lascia buchi nei bottoni icona. */
i.icon[data-lucide] { width: 16px; height: 16px; }

.icon-lg { width: 20px; height: 20px; }
.sidebar-link .icon { width: 18px; height: 18px; margin-right: 10px; opacity: .85; }
/* Bottoni con sola icona: niente margine che sbilancia il centraggio */
.btn-icon .icon { margin-right: 0; }

/* ── Spinner ─────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin .6s linear infinite; }

/* ── Status rows (table rows with left-border color accent) ──── */
tbody tr.row-danger  { border-left: 3px solid var(--accent-r); }
tbody tr.row-warning { border-left: 3px solid var(--accent-y); }
tbody tr.row-success { border-left: 3px solid var(--accent-g); }
tbody tr.row-info    { border-left: 3px solid var(--blue); }

/* ── Quick stat strip (inline mini-numbers row) ──────────────── */
.stat-strip {
  display: flex;
  gap: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  margin-bottom: 20px;
}
.stat-strip-item {
  flex: 1;
  padding: 12px 16px;
  border-right: 1px solid var(--gray-200);
  text-align: center;
}
.stat-strip-item:last-child { border-right: none; }
.stat-strip-item .val {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--gray-900);
  line-height: 1;
}
.stat-strip-item .lbl {
  font-size: 10.5px;
  color: var(--gray-400);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 3px;
}

/* ── Section divider ─────────────────────────────────────────── */
.section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--gray-400);
  padding: 0 0 8px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 16px;
}

/* ── Misc ────────────────────────────────────────────────────── */
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-muted  { color: var(--gray-400); }
.fw-bold     { font-weight: 700; }
.mono        { font-family: 'Courier New', monospace; }
.mt-0  { margin-top: 0; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.d-flex { display: flex; align-items: center; gap: 8px; }
.flex-1 { flex: 1; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.w-100  { width: 100%; }
hr.sep  { border: none; border-top: 1px solid var(--gray-100); margin: 16px 0; }
