/* ============================================================
   SellInvoice — Pannello UI
   Brand: Blue #0071BC · Green #87c71f
   Font:  Codec Pro → DM Sans fallback
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800&display=swap');

/* ── Codec Pro (locale — se disponibile) ── */
@font-face {
  font-family: 'Codec Pro';
  src: local('Codec Pro'), local('CodecPro');
  font-weight: 100 900;
  font-display: swap;
}

/* ── Variabili brand ── */
:root {
  --blue:         #0071BC;
  --blue-mid:     #0088d8;
  --blue-light:   #e8f4fd;
  --blue-deep:    #005a96;
  --green:        #87c71f;
  --green-mid:    #9ad925;
  --green-light:  #eef9d3;
  --green-deep:   #6ba018;

  --bg:           #eef3fb;
  --surface:      #ffffff;
  --surface2:     #f8fafd;
  --border:       #dde8f5;
  --border2:      #c8d9ee;
  --text:         #0d2137;
  --muted:        #6b7fa3;
  --muted2:       #a0aec0;

  --primary:      var(--blue);
  --accent:       var(--green);
  --danger:       #e53e3e;
  --warning:      #dd6b20;
  --orange:       #ed8936;
  --purple:       #805ad5;

  --sidebar-w:    260px;
  --topbar-h:     64px;
  --radius:       14px;
  --radius-sm:    9px;
  --radius-xs:    6px;

  --shadow-xs: 0 1px 3px rgba(0,113,188,.07);
  --shadow-sm: 0 2px 8px rgba(0,113,188,.08), 0 1px 3px rgba(0,0,0,.04);
  --shadow:    0 4px 20px rgba(0,113,188,.10), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg: 0 12px 40px rgba(0,113,188,.14), 0 4px 12px rgba(0,0,0,.06);
  --shadow-blue: 0 6px 20px rgba(0,113,188,.35);
  --shadow-green: 0 6px 20px rgba(135,199,31,.35);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Codec Pro', 'DM Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--blue); text-decoration: none; transition: color .18s; }
a:hover { color: var(--blue-deep); text-decoration: none; }

/* ── Animazioni ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes pulseBadge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229,62,62,.5); }
  60%       { box-shadow: 0 0 0 5px rgba(229,62,62,0); }
}
@keyframes gradientShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes spinIn {
  from { transform: rotate(-90deg) scale(.6); opacity: 0; }
  to   { transform: rotate(0) scale(1); opacity: 1; }
}

/* ══════════════════════════════════════════════════════════
   LAYOUT
════════════════════════════════════════════════════════════ */
.app-layout { display: flex; min-height: 100vh; }

/* ══════════════════════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  box-shadow: 2px 0 16px rgba(0,113,188,.06);
}

/* Scrollbar sidebar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* Logo area — gradiente brand */
.sidebar-logo {
  padding: 0;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 60%, var(--green) 100%);
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 110px;
  position: relative;
  overflow: hidden;
}

/* Pattern geometrico sfondo logo */
.sidebar-logo::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(255,255,255,.12) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,.08) 0%, transparent 50%);
  pointer-events: none;
}

.sidebar-logo-img {
  width: 198px;
  height: 66px;    /* 3:1 ratio per logo 1500×500 */
  object-fit: contain;
  object-position: center;
  filter: brightness(0) invert(1);
  position: relative;
  z-index: 1;
  animation: fadeIn .6s ease;
}

.sidebar-company {
  position: relative;
  z-index: 1;
  color: rgba(255,255,255,.82);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .4px;
  margin-top: 6px;
  max-width: 200px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 12px;
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 16px 10px;
}

.nav-section {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted2);
  padding: 16px 12px 5px;
  animation: fadeIn .5s ease;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: all .2s cubic-bezier(.4, 0, .2, 1);
  position: relative;
  cursor: pointer;
  animation: slideInLeft .3s ease both;
}

.nav-item:nth-child(1) { animation-delay: .04s; }
.nav-item:nth-child(2) { animation-delay: .08s; }
.nav-item:nth-child(3) { animation-delay: .12s; }
.nav-item:nth-child(4) { animation-delay: .16s; }
.nav-item:nth-child(5) { animation-delay: .20s; }
.nav-item:nth-child(6) { animation-delay: .24s; }
.nav-item:nth-child(7) { animation-delay: .28s; }

.nav-item::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px; height: 60%;
  background: linear-gradient(to bottom, var(--blue), var(--green));
  border-radius: 0 3px 3px 0;
  transition: transform .22s cubic-bezier(.4, 0, .2, 1);
}

.nav-item:hover {
  background: var(--blue-light);
  color: var(--blue);
  text-decoration: none;
  transform: translateX(2px);
}
.nav-item:hover::before { transform: translateY(-50%) scaleY(.6); }

.nav-item.active {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,113,188,.28);
  transform: none;
}
.nav-item.active::before { display: none; }

.nav-item.active .nav-icon { stroke: #fff; }

.nav-icon {
  width: 17px; height: 17px;
  flex-shrink: 0;
  stroke: currentColor;
  transition: transform .2s;
}
.nav-item:hover .nav-icon { transform: scale(1.1); }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
  animation: pulseBadge 2s ease-in-out infinite;
}

/* Footer sidebar */
.sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
}
.user-info  { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--green) 100%);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: #fff; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,113,188,.3);
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--muted); }
.logout-btn {
  color: var(--muted);
  padding: 6px;
  border-radius: var(--radius-xs);
  display: flex; align-items: center;
  transition: all .2s;
}
.logout-btn:hover { color: var(--danger); background: rgba(229,62,62,.08); }

/* ══════════════════════════════════════════════════════════
   MAIN CONTENT
════════════════════════════════════════════════════════════ */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  height: var(--topbar-h);
  padding: 0 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 8px rgba(0,113,188,.06);
}

/* Riga gradiente sotto topbar */
.topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--blue) 0%, var(--green) 100%);
}

.page-title {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}

/* Body */
.page-body {
  padding: 28px 32px;
  animation: fadeInUp .35s cubic-bezier(.4, 0, .2, 1) both;
}

/* ══════════════════════════════════════════════════════════
   CARDS
════════════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s, transform .2s;
}
.card:hover { box-shadow: var(--shadow); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.15px;
}

/* Accent left border */
.card-accent {
  border-left: 3px solid var(--blue);
}

/* ── STAT CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  border-radius: var(--radius);
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  transition: transform .22s cubic-bezier(.4,0,.2,1), box-shadow .22s;
  cursor: default;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

/* Varianti stat */
.stat-blue   { background: linear-gradient(135deg, #0071BC 0%, #0095d8 100%); box-shadow: var(--shadow-blue); }
.stat-green  { background: linear-gradient(135deg, #6ba018 0%, #87c71f 100%); box-shadow: var(--shadow-green); }
.stat-teal   { background: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%); box-shadow: 0 6px 20px rgba(8,145,178,.32); }
.stat-purple { background: linear-gradient(135deg, #6d28d9 0%, #8b5cf6 100%); box-shadow: 0 6px 20px rgba(109,40,217,.32); }
.stat-orange { background: linear-gradient(135deg, #c2410c 0%, #f97316 100%); box-shadow: 0 6px 20px rgba(249,115,22,.32); }
.stat-red    { background: linear-gradient(135deg, #c53030 0%, #e53e3e 100%); box-shadow: 0 6px 20px rgba(229,62,62,.32); }
.stat-white  { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }

.stat-card::before {
  content: '';
  position: absolute;
  right: -20px; top: -20px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,.10);
}
.stat-card::after {
  content: '';
  position: absolute;
  right: 20px; bottom: -30px;
  width: 70px; height: 70px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: rgba(255,255,255,.80);
  margin-bottom: 8px;
}
.stat-white .stat-label { color: var(--muted); }

.stat-value {
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.5px;
  line-height: 1;
  margin-bottom: 4px;
}
.stat-white .stat-value { color: var(--text); }

.stat-sub {
  font-size: 12px;
  color: rgba(255,255,255,.72);
}
.stat-white .stat-sub { color: var(--muted); }

.stat-icon {
  position: absolute;
  right: 20px; top: 50%;
  transform: translateY(-50%);
  opacity: .25;
  width: 44px; height: 44px;
}

/* ══════════════════════════════════════════════════════════
   TABELLE
════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead { background: var(--surface2); }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
.td-r { text-align: right !important; }

td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
  transition: background .15s;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f0f6fd; }
tbody tr { transition: background .15s; }

.td-mono  { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 12px; }
.td-muted { color: var(--muted); font-size: 12.5px; }

/* ══════════════════════════════════════════════════════════
   BADGES
════════════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  letter-spacing: .2px;
}
.badge-green  { background: #ecfccb; color: #3f6212; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }
.badge-gray   { background: #f1f5f9; color: var(--muted); }

/* ══════════════════════════════════════════════════════════
   BOTTONI
════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .2s cubic-bezier(.4,0,.2,1);
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -.1px;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(.97); }

/* Ripple effect */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.18);
  opacity: 0;
  border-radius: inherit;
  transition: opacity .15s;
}
.btn:active::after { opacity: 1; }

.btn-primary {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(0,113,188,.30);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--blue-deep) 0%, var(--blue) 100%);
  box-shadow: var(--shadow-blue);
  color: #fff;
  transform: translateY(-1px);
  text-decoration: none;
}

.btn-success {
  background: linear-gradient(135deg, var(--green-deep) 0%, var(--green) 100%);
  color: #fff;
  box-shadow: 0 3px 10px rgba(135,199,31,.30);
}
.btn-success:hover {
  box-shadow: var(--shadow-green);
  transform: translateY(-1px);
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1.5px solid var(--border2);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-light);
  text-decoration: none;
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(229,62,62,.08);
  color: var(--danger);
  border: 1.5px solid rgba(229,62,62,.25);
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  text-decoration: none;
}

.btn-sm { padding: 5px 12px; font-size: 12px; border-radius: var(--radius-xs); }
.btn-lg { padding: 13px 28px; font-size: 15px; border-radius: var(--radius-sm); }

/* ══════════════════════════════════════════════════════════
   FORM
════════════════════════════════════════════════════════════ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .1px;
}

input, select, textarea {
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
input:hover, select:hover { border-color: #a8bfd8; }
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0,113,188,.12);
}
input::placeholder { color: var(--muted2); }
input[readonly] { background: var(--surface2); color: var(--muted); cursor: not-allowed; }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7fa3' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

/* Riga fattura */
.riga-row {
  display: grid;
  grid-template-columns: 2fr 70px 70px 120px 1fr 40px;
  gap: 8px;
  align-items: end;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  transition: border-color .2s, box-shadow .2s;
  animation: fadeInUp .25s ease both;
}
.riga-row:hover { border-color: var(--border2); box-shadow: var(--shadow-xs); }

/* Riga descrittiva: solo testo, nessun campo prezzo/IVA */
.riga-desc {
  grid-template-columns: 24px 1fr 40px;
  background: #f9fafb;
  border-style: dashed;
}
.riga-desc-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--muted2);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  flex-shrink: 0;
}

.btn-remove-riga {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted2);
  padding: 8px;
  font-size: 18px;
  line-height: 1;
  border-radius: var(--radius-xs);
  transition: all .18s;
  display: flex; align-items: center; justify-content: center;
}
.btn-remove-riga:hover { color: var(--danger); background: rgba(229,62,62,.08); }

/* ══════════════════════════════════════════════════════════
   ALERT
════════════════════════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 13.5px;
  animation: fadeInUp .3s ease both;
  border: 1px solid transparent;
}
.alert-error   { background: #fff5f5; border-color: #fed7d7; color: #c53030; }
.alert-success { background: #f0fff4; border-color: #c6f6d5; color: #276749; }
.alert-info    { background: var(--blue-light); border-color: #bee3f8; color: #2c5282; }
.alert-warn    { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ══════════════════════════════════════════════════════════
   PAGINAZIONE
════════════════════════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  padding: 6px 13px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 500;
  border: 1.5px solid var(--border2);
  color: var(--text);
  transition: all .18s;
}
.pagination a:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); text-decoration: none; }
.pagination .current {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
  box-shadow: 0 2px 8px rgba(0,113,188,.28);
}

/* ══════════════════════════════════════════════════════════
   LOGIN
════════════════════════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  background: var(--bg);
}

/* Pannello sinistro — brand */
.login-brand {
  width: 45%;
  background: linear-gradient(145deg, var(--blue) 0%, var(--blue-mid) 50%, var(--green) 100%);
  background-size: 200% 200%;
  animation: gradientShift 8s ease infinite;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 48px;
  position: relative;
  overflow: hidden;
}
.login-brand::before {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: rgba(255,255,255,.06);
  top: -100px; right: -100px;
}
.login-brand::after {
  content: '';
  position: absolute;
  width: 250px; height: 250px;
  border-radius: 50%;
  background: rgba(255,255,255,.05);
  bottom: -60px; left: -60px;
}
.login-brand-logo {
  width: 270px;
  height: 90px;    /* 3:1 ratio per logo 1500×500 */
  object-fit: contain;
  object-position: center;
  filter: brightness(0) invert(1);
  margin-bottom: 32px;
  position: relative; z-index: 1;
  animation: fadeIn .8s ease;
}
.login-brand-headline {
  color: rgba(255,255,255,.95);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  position: relative; z-index: 1;
  letter-spacing: -.3px;
  line-height: 1.4;
}
.login-brand-sub {
  color: rgba(255,255,255,.70);
  font-size: 14px;
  text-align: center;
  margin-top: 12px;
  position: relative; z-index: 1;
  max-width: 280px;
  line-height: 1.6;
}

/* Pannello destro — form */
.login-form-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 60px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  animation: fadeInUp .45s ease both;
}
.login-card h2 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -.4px;
}
.login-card .login-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 32px;
}

/* ══════════════════════════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--muted);
  animation: fadeIn .4s ease;
}
.empty-state svg {
  margin-bottom: 16px;
  opacity: .3;
  color: var(--blue);
  stroke: var(--blue);
}
.empty-state p { font-size: 14px; }
.empty-state .empty-action { margin-top: 20px; }

/* ══════════════════════════════════════════════════════════
   ANNO TABS (tx.php / rx.php)
════════════════════════════════════════════════════════════ */
.anno-tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.anno-tab {
  padding: 7px 20px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: 1.5px solid var(--border2);
  color: var(--muted);
  background: var(--surface);
  transition: all .2s cubic-bezier(.4,0,.2,1);
  box-shadow: var(--shadow-xs);
}
.anno-tab:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-light);
  text-decoration: none;
  transform: translateY(-1px);
}
.anno-tab.active {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(0,113,188,.28);
  transform: none;
}

/* ══════════════════════════════════════════════════════════
   AZIONI TABELLA
════════════════════════════════════════════════════════════ */
.tbl-actions { display: flex; gap: 6px; align-items: center; }

.btn-pdf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-xs);
  background: var(--surface2);
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  border: 1.5px solid var(--border);
  transition: all .2s;
}
.btn-pdf:hover {
  background: var(--blue-light);
  border-color: var(--blue);
  color: var(--blue);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0,113,188,.18);
}

/* ══════════════════════════════════════════════════════════
   TOPBAR TOPBAR extra (titolo + utente a destra)
════════════════════════════════════════════════════════════ */
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-company {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 20px;
}

/* ══════════════════════════════════════════════════════════
   KPI STRIP ECONOMICA (dashboard)
════════════════════════════════════════════════════════════ */
.kpi-strip {
  display: grid;
  grid-template-columns: auto 1fr 1fr 1fr;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 24px;
}

/* Label anno — colonna verticale a sinistra */
.kpi-label-year {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 0 6px;
  border-left: 2px solid var(--border);
}
.kpi-label-year svg {
  transform: rotate(180deg);
  flex-shrink: 0;
}

/* Singola card KPI */
.kpi-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow-sm);
  transition: transform .2s, box-shadow .2s;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 4px 0 0 4px;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

/* Icona KPI */
.kpi-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Testo KPI */
.kpi-body { flex: 1; min-width: 0; }
.kpi-name  { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin-bottom: 3px; }
.kpi-value { font-size: 22px; font-weight: 800; letter-spacing: -.5px; line-height: 1; margin-bottom: 3px; }
.kpi-sub   { font-size: 11px; color: var(--muted2); }

/* Variante Fatturato — verde */
.kpi-fatturato::before        { background: var(--green); }
.kpi-fatturato .kpi-icon      { background: var(--green-light); color: var(--green-deep); }
.kpi-fatturato .kpi-icon svg  { stroke: var(--green-deep); }
.kpi-fatturato .kpi-value     { color: var(--green-deep); }

/* Variante Costi — arancio */
.kpi-costi::before            { background: var(--orange); }
.kpi-costi .kpi-icon          { background: #fff7ed; color: var(--orange); }
.kpi-costi .kpi-icon svg      { stroke: var(--orange); }
.kpi-costi .kpi-value         { color: var(--orange); }

/* Variante Margine positivo — blu */
.kpi-margine-pos::before      { background: var(--blue); }
.kpi-margine-pos .kpi-icon    { background: var(--blue-light); }
.kpi-margine-pos .kpi-icon svg { stroke: var(--blue); }
.kpi-margine-pos .kpi-value   { color: var(--blue); }

/* Variante Margine negativo — rosso */
.kpi-margine-neg::before      { background: var(--danger); }
.kpi-margine-neg .kpi-icon    { background: #fff5f5; }
.kpi-margine-neg .kpi-icon svg { stroke: var(--danger); }
.kpi-margine-neg .kpi-value   { color: var(--danger); }

/* Responsive KPI */
@media (max-width: 900px) {
  .kpi-strip {
    grid-template-columns: 1fr 1fr;
  }
  .kpi-label-year { display: none; }
}
@media (max-width: 560px) {
  .kpi-strip { grid-template-columns: 1fr; }
}

/* v=20260427 */
/* ══════════════════════════════════════════════════════════
   KPI YEAR NAVIGATOR
════════════════════════════════════════════════════════════ */
.kpi-year-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.kpi-year-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s;
  flex-shrink: 0;
}
.kpi-year-btn:hover {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.kpi-year-btn--disabled {
  opacity: .35;
  cursor: not-allowed;
  pointer-events: none;
}
.kpi-year-display {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
  position: relative;
}
.kpi-year-display svg { color: var(--muted); flex-shrink: 0; }
.kpi-year-select {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  font-size: 14px;
}
.kpi-year-label {
  margin-left: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* Sidebar year switcher */
.sidebar-year-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  margin: 6px 12px;
  background: rgba(0,113,188,.08);
  border-radius: 10px;
  gap: 6px;
}
.sidebar-year-nav a,
.sidebar-year-nav span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
  transition: background .15s;
}
.sidebar-year-nav a:hover { background: rgba(0,113,188,.15); }
.sidebar-year-nav span   { opacity: .35; cursor: not-allowed; }
.sidebar-year-value {
  font-size: 13px;
  font-weight: 800;
  color: var(--blue);
  flex: 1;
  text-align: center;
  letter-spacing: .3px;
}

/* ══════════════════════════════════════════════════════════
   UTILITY
════════════════════════════════════════════════════════════ */
.text-blue   { color: var(--blue); }
.text-green  { color: var(--green); }
.text-muted  { color: var(--muted); }
.text-danger { color: var(--danger); }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

/* Divider gradiente */
.divider-gradient {
  border: none;
  height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--green));
  border-radius: 2px;
  margin: 20px 0;
}

/* ══════════════════════════════════════════════════════════
   COMPANY SWITCHER (topbar)
════════════════════════════════════════════════════════════ */
.company-switcher {
  position: relative;
}
.company-switcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 10px 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
  max-width: 220px;
}
.company-switcher-btn:hover {
  background: var(--bg);
  border-color: var(--blue);
  color: var(--blue);
}
.company-switcher-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}
.company-switcher-caret {
  flex-shrink: 0;
  transition: transform .2s;
}
.company-switcher-dropdown.open ~ .company-switcher-btn .company-switcher-caret,
.company-switcher:has(.company-switcher-dropdown.open) .company-switcher-caret {
  transform: rotate(180deg);
}
.company-switcher-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  z-index: 200;
  overflow: hidden;
}
.company-switcher-dropdown.open {
  display: block;
}
.company-switcher-header {
  padding: 10px 14px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.company-switcher-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 14px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: left;
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.company-switcher-item:last-child { border-bottom: none; }
.company-switcher-item:hover:not(:disabled) { background: var(--bg); }
.company-switcher-item--active {
  background: rgba(0,113,188,.06);
  cursor: default;
}
.company-switcher-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.company-switcher-item--active .company-switcher-item-name {
  color: var(--blue);
}
.company-switcher-item-piva {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
}
.company-switcher-check {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--blue);
  display: flex;
  align-items: center;
}

/* ══════════════════════════════════════════════════════════════════════
   TEMA SELL — stessa grafica dell'app SellInvoice (variante verde)
   Verde profondo + lime del logo, azione principale arancio,
   dati di fatturato nel blu del logo. Sovrascrive gli stili sopra.
════════════════════════════════════════════════════════════════════════ */

:root {
  --blue:         #2D7F3E;   /* colore principale (come l'app) */
  --blue-mid:     #3C8F3A;
  --blue-light:   #EAF5E6;
  --blue-deep:    #1E5E2D;
  --green:        #5E9E14;   /* esiti positivi / pagata */
  --green-mid:    #84C31C;
  --green-light:  #F0F8E4;
  --green-deep:   #4A7F10;
  --lime:         #84C31C;
  --accent-o:     #F07820;   /* azione principale */
  --dato:         #1B6CB4;   /* fatturato */

  --bg:           #F5F6FA;
  --surface2:     #F8F9FC;
  --border:       #E6E8F0;
  --border2:      #D5D9E3;
  --text:         #1B2033;
  --muted:        #5B6378;
  --muted2:       #9AA1B2;
  --danger:       #E5484D;

  --sidebar-grad: linear-gradient(160deg, #1B5E4A 0%, #24734A 45%, #3C8F3A 100%);
  --accent-grad:  linear-gradient(135deg, #FFB03A 0%, #F07820 100%);

  --radius:       16px;
  --radius-sm:    12px;
  --radius-xs:    8px;

  --shadow-xs: 0 1px 3px rgba(27,32,51,.06);
  --shadow-sm: 0 3px 10px rgba(27,32,51,.06);
  --shadow:    0 6px 20px rgba(27,32,51,.08);
  --shadow-lg: 0 14px 40px rgba(27,32,51,.12);
  --shadow-blue:  0 6px 18px rgba(45,127,62,.32);
  --shadow-green: 0 6px 18px rgba(94,158,20,.30);
}

body { font-family: 'Inter', 'DM Sans', -apple-system, BlinkMacSystemFont, system-ui, sans-serif; }

/* ── Barra laterale a gradiente verde ── */
.sidebar {
  background: var(--sidebar-grad);
  border-right: none;
  box-shadow: 4px 0 24px rgba(27,94,74,.18);
}
.sidebar::before, .sidebar::after {
  content: ''; position: fixed; pointer-events: none; border-radius: 50%;
}
.sidebar::before { width: 340px; height: 340px; left: -150px; top: -120px; background: rgba(255,255,255,.06); }
.sidebar::after  { width: 300px; height: 300px; left: -110px; bottom: -130px; background: rgba(255,255,255,.05); }
.sidebar > * { position: relative; z-index: 1; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.25); }

.sidebar-logo {
  background: none;
  animation: none;
  min-height: 0;
  padding: 26px 22px 14px;
  align-items: flex-start;
}
.sidebar-logo::before { display: none; }
.sidebar-logo-img {
  width: 196px; height: auto; max-height: 40px;
  filter: none;
  object-position: left center;
}
.sidebar-company {
  margin-top: 14px; max-width: none; width: 100%;
  text-align: left; padding: 9px 12px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 12px;
  color: #fff; font-size: 12.5px; font-weight: 700; letter-spacing: 0;
}

.nav-section { color: rgba(255,255,255,.55); }
.nav-item { color: rgba(255,255,255,.88); font-weight: 600; border-radius: 14px; margin: 2px 4px; }
.nav-item::before { display: none; }
.nav-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav-item.active {
  background: #fff;
  color: var(--blue);
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(0,0,0,.14);
}
.nav-item.active .nav-icon { stroke: var(--blue); }
.nav-badge { background: var(--accent-o); }

/* "Nuova fattura" come pulsante principale arancio */
.sidebar-nav a[href$="/fatture/nuova"] {
  background: var(--accent-grad);
  color: #fff;
  font-weight: 800;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(240,120,32,.40);
  margin: 6px 4px 10px;
  padding: 11px 12px;
  border-radius: 30px;
}
.sidebar-nav a[href$="/fatture/nuova"] .nav-icon { stroke: #fff; }
.sidebar-nav a[href$="/fatture/nuova"]:hover { color: #fff; filter: brightness(1.05); transform: translateY(-1px); }
.sidebar-nav a[href$="/fatture/nuova"].active { outline: 2px solid rgba(255,255,255,.7); outline-offset: 2px; }

.sidebar-year-nav { color: #fff; }
.sidebar-year-nav a, .sidebar-year-nav span { color: rgba(255,255,255,.85); }
.sidebar-year-value { color: #fff; font-weight: 800; }

.sidebar-footer { background: transparent; border-top: 1px solid rgba(255,255,255,.15); }
.user-avatar { background: #fff; color: var(--blue); box-shadow: none; }
.user-name { color: #fff; }
.user-role { color: rgba(255,255,255,.65); }
.logout-btn { color: rgba(255,255,255,.85); }
.logout-btn:hover { color: #fff; background: rgba(255,255,255,.14); }

/* ── Barra superiore ── */
.topbar { box-shadow: none; }
.topbar::after { height: 3px; background: linear-gradient(90deg, #1B5E4A 0%, #3C8F3A 60%, var(--lime) 100%); }
.page-title { font-weight: 800; letter-spacing: -.4px; }

/* ── Schede ── */
.card { border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card:hover { box-shadow: var(--shadow); }

.stat-card { border-radius: var(--radius); }
.stat-blue   { background: linear-gradient(135deg, #1B6CB4 0%, #1E78C8 100%); box-shadow: 0 6px 18px rgba(27,108,180,.30); }
.stat-green  { background: linear-gradient(135deg, #4A7F10 0%, #84C31C 100%); box-shadow: var(--shadow-green); }
.stat-teal   { background: linear-gradient(135deg, #1B5E4A 0%, #2D7F3E 100%); box-shadow: var(--shadow-blue); }
.stat-orange { background: var(--accent-grad); box-shadow: 0 6px 18px rgba(240,120,32,.32); }

/* ── Pulsanti ── */
.btn { border-radius: var(--radius-sm); }
.btn-primary { background: linear-gradient(135deg, #2D7F3E 0%, #3C8F3A 100%); box-shadow: 0 3px 10px rgba(45,127,62,.30); }
.btn-primary:hover { background: linear-gradient(135deg, #1E5E2D 0%, #2D7F3E 100%); }
.btn-success { background: var(--accent-grad); box-shadow: 0 3px 10px rgba(240,120,32,.30); }
.btn-success:hover { box-shadow: 0 6px 18px rgba(240,120,32,.38); }
.anno-tab.active,
.pagination .current { box-shadow: 0 4px 12px rgba(45,127,62,.28); }

/* ── Badge ── */
.badge-green { background: var(--green-light); color: #3F6B0E; }
.badge-blue  { background: #E8F1FA; color: #1B6CB4; }

/* ── Campi ── */
input:focus, select:focus, textarea:focus { border-color: var(--blue) !important; box-shadow: 0 0 0 3px rgba(45,127,62,.14) !important; }

/* ── Login / registrazione ── */
.login-brand {
  background: var(--sidebar-grad);
  animation: none;
}
.login-brand::before { background: rgba(255,255,255,.07); }
.login-brand::after  { background: none; border: 10px solid rgba(132,195,28,.35); width: 150px; height: 150px; bottom: 12%; left: auto; right: 10%; }
.login-brand-logo { filter: none; width: 300px; height: auto; max-height: 64px; }
.login-card h2 { font-weight: 900; }

/* ── Cambio azienda in alto ── */
.company-switcher-btn { border-radius: 12px; }
.company-switcher-item--active { background: var(--blue-light); }

/* ── KPI dashboard: stessi colori della Home dell'app ── */
.kpi-card { border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.kpi-fatturato::before       { background: var(--dato); }
.kpi-fatturato .kpi-icon     { background: #E8F1FA; color: var(--dato); }
.kpi-fatturato .kpi-icon svg { stroke: var(--dato); }
.kpi-fatturato .kpi-value    { color: var(--dato); }
.kpi-costi::before, .kpi-costi .kpi-value { color: #F97316; }
.kpi-costi::before           { background: #F97316; }
.kpi-margine-pos::before     { background: var(--green); }
.kpi-margine-pos .kpi-icon   { background: var(--green-light); }
.kpi-margine-pos .kpi-icon svg { stroke: var(--green); }
.kpi-margine-pos .kpi-value  { color: var(--green-deep); }
.kpi-year-select, .kpi-year-display { font-weight: 800; }

/* ── Incassi (pulsante pagata/da incassare) ── */
.pill-pagata { border: 1.5px solid; border-radius: 20px; padding: 3px 11px; font-size: 11.5px; font-weight: 700;
  cursor: pointer; background: #fff; font-family: inherit; white-space: nowrap; transition: all .15s; }
.pill-pagata.is-aperta { color: #C2570C; border-color: rgba(240,120,32,.45); background: #FFF6EC; }
.pill-pagata.is-pagata { color: #3F6B0E; border-color: rgba(94,158,20,.45); background: var(--green-light); }
.pill-pagata:hover { filter: brightness(.97); transform: translateY(-1px); }
.pill-pagata:disabled { opacity: .6; cursor: wait; }

/* Filtri a pillola sopra le liste */
.chip-filtri { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.chip-filtro { padding: 6px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 700; border: 1.5px solid var(--border2);
  color: var(--muted); background: #fff; text-decoration: none; }
.chip-filtro:hover { border-color: var(--blue); color: var(--blue); }
.chip-filtro.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip-filtro.on-o { background: var(--accent-o); border-color: var(--accent-o); color: #fff; }

.banner-incassi { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; margin-bottom: 14px;
  background: #FFF7ED; border: 1.5px solid rgba(240,120,32,.35); color: #C2570C; font-weight: 700; }
.banner-incassi .val { margin-left: auto; font-size: 17px; font-weight: 900; }

/* Finestre modali */
.si-modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: none; align-items: center; justify-content: center; z-index: 500; padding: 16px; }
.si-modal.open { display: flex; }
.si-modal-box { background: #fff; border-radius: 18px; width: 100%; max-width: 540px; overflow: hidden; box-shadow: var(--shadow-lg); }
.si-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; color: #fff; background: var(--sidebar-grad); }
.si-modal-x { background: rgba(255,255,255,.15); border: none; color: #fff; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 14px; }

/* ── Dashboard: incassi ── */
.incassi-body { display: grid; grid-template-columns: auto 1fr 1.2fr; gap: 28px; align-items: center; }
.incassi-anello { width: 132px; height: 132px; border-radius: 50%; display: grid; place-items: center; }
.incassi-anello > div { width: 100px; height: 100px; border-radius: 50%; background: #fff; display: flex; flex-direction: column;
  align-items: center; justify-content: center; }
.incassi-anello b { font-size: 26px; font-weight: 900; color: var(--text); line-height: 1; }
.incassi-anello span { font-size: 11px; color: var(--muted); }
.incassi-valori { display: flex; flex-direction: column; gap: 14px; }
.incassi-valori > div { display: grid; grid-template-columns: 12px 1fr; column-gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.incassi-valori b { grid-column: 2; font-size: 20px; font-weight: 900; color: var(--text); }
.incassi-valori small { grid-column: 2; font-size: 11.5px; color: var(--muted2); }
.incassi-valori .pt { width: 11px; height: 11px; border-radius: 3px; margin-top: 4px; }
.incassi-esiti { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.incassi-esiti > div { border-radius: 12px; padding: 12px 8px; text-align: center; font-size: 12px; font-weight: 700; }
.incassi-esiti b { display: block; font-size: 22px; font-weight: 900; }
@media (max-width: 1100px) { .incassi-body { grid-template-columns: auto 1fr; } .incassi-esiti { grid-column: 1 / -1; } }

/* ── Sidebar: codice destinatario SDI (compatto) ── */
.sidebar-codice { margin: 6px 14px 10px; padding: 6px 8px 6px 11px; border-radius: 10px; display: flex; align-items: center;
  justify-content: space-between; gap: 8px; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.18); color: #fff; cursor: help; }
.sidebar-codice .sc-label { font-size: 9px; font-weight: 700; color: rgba(255,255,255,.72); }
.sidebar-codice .sc-codice { font-size: 13px; font-weight: 900; letter-spacing: 1.2px; line-height: 1.2; }
.sidebar-codice .sc-copia { font: inherit; font-size: 10.5px; font-weight: 700; color: #fff; cursor: pointer;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.28); border-radius: 7px; padding: 2px 8px; }
.sidebar-codice .sc-copia:hover { background: rgba(255,255,255,.24); }

/* ── Duplica anagrafica: scelta azienda ── */
.dup-scelte { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.dup-scelta { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; }
.dup-scelta:has(input:checked) { border-color: var(--blue); background: var(--blue-light); }
.dup-scelta input { width: auto; }
.dup-scelta b { display: block; font-size: 13px; }
.dup-scelta small { font-size: 11.5px; color: var(--muted); }

/* ── Contabilità: piano dei conti ── */
.pc-breadcrumb { font-size: 12.5px; color: var(--muted); margin: -6px 0 14px; }
.pc-breadcrumb span { margin: 0 6px; color: var(--muted2); }
.pc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 22px; align-items: start; }
@media (max-width: 1200px) { .pc-grid { grid-template-columns: 1fr; } }
.pc-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.pc-toolbar input { flex: 1; min-width: 220px; }
.pc-toolbar .chip-filtro { cursor: pointer; }
.pc-legenda { font-size: 11.5px; color: var(--muted); display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
#pc-albero { max-height: calc(100vh - 260px); overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; }
.pc-riga { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; }
.pc-riga:hover { background: var(--surface2); }
.pc-riga.sel { background: var(--blue-light); }
.pc-riga.l1 { background: #F1F5F3; font-weight: 800; }
.pc-riga.l1.sel { background: var(--blue-light); }
.pc-riga.l2 { padding-left: 28px; font-weight: 700; }
.pc-riga.l3 { padding-left: 52px; }
.pc-riga.disattivo { opacity: .5; }
.pc-freccia { width: 16px; color: var(--muted); font-size: 12px; text-align: center; flex-shrink: 0; }
.pc-freccia.vuota { visibility: hidden; }
.pc-cod { font-family: 'SF Mono', Menlo, monospace; font-size: 12.5px; min-width: 96px; color: var(--blue-deep); }
.pc-cod i { color: var(--accent-o); font-style: normal; font-weight: 900; margin-left: 2px; }
.pc-desc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-tag-az { font-size: 9.5px; font-weight: 800; color: #fff; background: var(--green); border-radius: 5px; padding: 1px 5px; }
.pc-tag-an { font-size: 10px; font-weight: 700; color: var(--dato); background: #E8F1FA; border-radius: 5px; padding: 1px 6px; }
.pc-segno { font-size: 10px; font-weight: 700; color: var(--muted); }
.pc-add { border: 1.5px solid var(--blue); color: var(--blue); background: #fff; border-radius: 7px; width: 24px; height: 22px;
  font-weight: 800; cursor: pointer; line-height: 1; }
.pc-add:hover { background: var(--blue); color: #fff; }
.pc-dettaglio { position: sticky; top: 84px; }
.pc-dhead { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 12px; }
.pc-dcod { font-family: 'SF Mono', Menlo, monospace; font-size: 14px; color: var(--blue-deep); font-weight: 700; }
.pc-ddesc { font-size: 17px; font-weight: 800; }
.pc-props td { padding: 5px 0; font-size: 13px; border: none; }
.pc-props td:first-child { color: var(--muted); width: 170px; }
.pc-gruppo { margin-top: 12px; }
.pc-gtit { font-size: 10px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--muted2); margin-bottom: 5px; }
.pc-flag { display: inline-block; font-size: 11.5px; padding: 3px 8px; border-radius: 7px; margin: 0 4px 4px 0; background: var(--bg); color: var(--muted2); }
.pc-flag.si { background: var(--green-light); color: var(--green-deep); font-weight: 700; }
.pc-checks { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin-top: 10px; font-size: 12.5px; }
.pc-checks input { width: auto; margin-right: 4px; }
.pc-azioni { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ── Contabilità: raccordo anagrafiche ── */
.rc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .rc-grid { grid-template-columns: 1fr; } }
.rc-stato { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-radius: 12px;
  background: var(--green-light); margin-bottom: 18px; font-size: 13px; }
.rc-stato.warn { background: #FFF7ED; }
.rc-stato button, .rc-stato .badge { margin-left: auto; }
.rc-regola { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.rc-regola:last-child { border-bottom: none; }
.rc-seg { grid-column: 1 / -1; font-weight: 800; font-size: 13.5px; }
.rc-conti { display: flex; flex-direction: column; gap: 4px; }
.rc-conto { display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.rc-n { font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--muted2); min-width: 70px; }
.rc-occ { margin-left: auto; font-size: 11px; color: var(--muted); }
.rc-occ.pieno { color: var(--danger); font-weight: 800; }
.rc-regola > .btn { align-self: center; }

/* ── Contabilità: prima nota e mastrini ── */
.pn-riga { cursor: pointer; }
.pn-riga:hover td { background: var(--blue-light); }
.pn-riga.saltata td { background: #FFF7ED; }
.pn-testata { display: grid; grid-template-columns: 1fr 2fr auto; gap: 14px; align-items: center; font-size: 13px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.pn-testata span { display: block; font-size: 10px; font-weight: 800; text-transform: uppercase; color: var(--muted2); }
.pn-tab tfoot td { border-top: 2px solid var(--border2); }
.ms-grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1100px) { .ms-grid { grid-template-columns: 1fr; } }
#ms-saldi { max-height: calc(100vh - 330px); overflow-y: auto; }
.ms-conto { display: flex; justify-content: space-between; gap: 10px; padding: 8px 8px; border-radius: 10px; cursor: pointer; align-items: center; }
.ms-conto:hover { background: var(--surface2); }
.ms-conto.sel { background: var(--blue-light); }
.ms-cdesc { font-size: 12px; color: var(--text); }
.ms-csaldo { font-family: 'SF Mono', Menlo, monospace; font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--blue-deep); }
.ms-csaldo.avere { color: #C2570C; }
.ms-head { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.ms-saldo-fin { text-align: right; } .ms-saldo-fin span { display: block; font-size: 11px; color: var(--muted); }
.ms-saldo-fin b { font-size: 20px; font-family: 'SF Mono', Menlo, monospace; }
.ms-iniziale td { background: var(--surface2); font-style: italic; }

/* L'animazione d'ingresso non lascia un transform permanente (rompeva position:fixed delle finestre) */
.page-body { animation-fill-mode: backwards; }

/* ── Nuova scrittura di prima nota ── */
.ns-testata { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 10px 14px; margin-bottom: 14px; }
@media (max-width: 800px) { .ns-testata { grid-template-columns: 1fr 1fr; } }
.ns-righe { width: 100%; }
.ns-righe td { padding: 4px 4px; vertical-align: top; border: none; }
.ns-righe th { font-size: 10.5px; }
.ns-righe input { width: 100%; padding: 7px 9px; }
.ns-righe input.td-r { text-align: right; font-family: 'SF Mono', Menlo, monospace; }
.ns-cdesc { font-size: 11px; color: var(--muted); margin-top: 2px; min-height: 13px; }
.ns-cdesc.err { color: var(--danger); font-weight: 700; }
.ns-x { border: none; background: none; color: var(--muted2); cursor: pointer; font-size: 14px; padding: 8px 4px; }
.ns-x:hover { color: var(--danger); }
.ns-righe tfoot td { border-top: 2px solid var(--border2); padding-top: 8px; }
.ns-quadra { margin-top: 10px; }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; transform: none !important; box-shadow: none !important; filter: grayscale(.3); }
.pn-tab .td-mono { white-space: nowrap; }

/* ── Scadenzario ── */
.sc-kpi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.sc-k { background: #fff; border-radius: 14px; padding: 14px 18px; box-shadow: var(--shadow-sm); border-left: 4px solid var(--dato); }
.sc-k span { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.sc-k b { font-size: 22px; font-weight: 900; }
.sc-k.rosso { border-left-color: var(--danger); } .sc-k.rosso b { color: var(--danger); }
.sc-k.verde { border-left-color: var(--green); }
.sc-gruppo { border: 1px solid var(--border); border-radius: 12px; margin-top: 14px; overflow: hidden; }
.sc-ghead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--surface2); }
.sc-gtot { display: flex; gap: 14px; align-items: center; font-size: 13px; }
.sc-gtot .rosso { color: var(--danger); font-weight: 800; }
.sc-scaduta td { background: #FEF4F4; }
.sc-ritardo { font-size: 11px; color: var(--danger); font-weight: 700; }
.sc-imp { width: 100%; padding: 6px 8px; text-align: right; font-family: 'SF Mono', Menlo, monospace; }
.sc-imp.err { border-color: var(--danger) !important; background: #FEF4F4; }
.sc-anteprima { margin-top: 12px; }
.sc-ant-tit { font-size: 11px; font-weight: 800; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

.sc-storico td { background: var(--surface2); }
.sc-pag { display: flex; gap: 14px; align-items: center; padding: 4px 0; font-size: 12.5px; flex-wrap: wrap; }

.sc-nuovo-conto { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px 10px; margin-top: 8px; }

.sc-doc { font-weight: 700; color: var(--blue); }
.sc-ico { border: 1px solid var(--border); background: #fff; border-radius: 8px; width: 30px; height: 28px; cursor: pointer; color: var(--blue); display: inline-flex; align-items: center; justify-content: center; }
.sc-ico:hover { background: var(--blue-light); border-color: var(--blue); }

/* ── Importazione fatture passive ── */
.imp-drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; border: 2px dashed var(--border2); border-radius: 14px; cursor: pointer; text-align: center; background: var(--surface2); }
.imp-drop.over, .imp-drop:hover { border-color: var(--blue); background: var(--blue-light); }
.imp-elenco { margin-top: 8px; font-size: 12.5px; text-align: left; width: 100%; max-height: 140px; overflow: auto; }
