:root{
  --bg:#0b0c10;
  --bg-soft:#111217;
  --card:rgba(31,33,41,.62);
  --card-strong:rgba(40,42,52,.82);
  --text:#f7f7f8;
  --muted:#a7aab4;
  --border:rgba(255,255,255,.13);
  --border-strong:rgba(255,255,255,.22);
  --primary:#ff8a1f;
  --primary-2:#ffb15f;
  --dark-gray:#1b1d24;
  --green:#22c55e;
  --yellow:#facc15;
  --red:#ef4444;
  --shadow:0 24px 80px rgba(0,0,0,.42);
}

*{box-sizing:border-box}
html{min-height:100%}
body{
  margin:0;
  min-height:100vh;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(255,138,31,.24), transparent 34%),
    radial-gradient(circle at 88% 18%, rgba(255,177,95,.12), transparent 30%),
    linear-gradient(135deg,#08090d 0%,#111217 48%,#1b1d24 100%);
  color:var(--text);
}
body:before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background:linear-gradient(120deg,rgba(255,255,255,.055),transparent 28%,rgba(255,255,255,.035) 58%,transparent 76%);
  mask-image:linear-gradient(#000,transparent 85%);
}

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

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  min-height:72px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:0 30px;
  background:rgba(17,18,23,.72);
  border-bottom:1px solid var(--border);
  backdrop-filter:blur(22px) saturate(145%);
  -webkit-backdrop-filter:blur(22px) saturate(145%);
  box-shadow:0 10px 40px rgba(0,0,0,.22);
}
.brand{font-weight:800}
.brand:before{
  content:"";
  display:inline-block;
  width:11px;
  height:11px;
  margin-right:10px;
  border-radius:999px;
  background:var(--primary);
  box-shadow:0 0 22px var(--primary);
}
.topbar a{
  color:#fff;
  margin-left:16px;
  padding:9px 12px;
  border-radius:999px;
}
.topbar a:hover{
  background:rgba(255,255,255,.08);
  text-decoration:none;
}

.container{
  max-width:1160px;
  margin:32px auto;
  padding:0 18px;
}
.page-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}
h1{font-size:34px;margin:0 0 20px}
h2{margin-top:0}

.cards{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(190px,1fr));
  gap:16px;
  margin:20px 0;
}
.card,.panel,.form-card,.auth-card,table,.filters{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:22px;
  box-shadow:var(--shadow);
  backdrop-filter:blur(24px) saturate(145%);
  -webkit-backdrop-filter:blur(24px) saturate(145%);
}
.card,.panel,.form-card,.auth-card{padding:22px}
.card{position:relative;overflow:hidden}
.card:after{
  content:"";
  position:absolute;
  right:-30px;
  top:-35px;
  width:110px;
  height:110px;
  border-radius:50%;
  background:rgba(255,138,31,.16);
}
.card span{
  display:block;
  color:var(--muted);
  font-size:14px;
}
.card strong{
  display:block;
  font-size:36px;
  margin-top:8px;
}
.panel{margin-top:18px}
.dashboard-charts{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(320px,1fr));
  gap:18px;
  margin-top:18px;
}
.chart-panel{overflow:hidden}
.chart-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:18px;
}
.chart-head h2{
  margin:0;
  font-size:21px;
}
.chart-head strong{
  white-space:nowrap;
  font-size:18px;
}
.chart-layout{
  display:grid;
  grid-template-columns:180px minmax(0,1fr);
  align-items:center;
  gap:20px;
}
.pie-chart{
  width:180px;
  aspect-ratio:1;
  border-radius:50%;
  background:conic-gradient(var(--pie-gradient));
  border:1px solid var(--border-strong);
  box-shadow:inset 0 0 0 14px rgba(11,12,16,.74),0 18px 44px rgba(0,0,0,.28);
}
.chart-legend{
  display:grid;
  gap:10px;
  min-width:0;
}
.legend-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  min-width:0;
  padding-bottom:10px;
  border-bottom:1px solid var(--border);
}
.legend-row:last-child{
  padding-bottom:0;
  border-bottom:0;
}
.legend-row span{
  min-width:0;
  color:#e9eaf0;
}
.legend-row strong{
  flex:0 0 auto;
  text-align:right;
}
.legend-row small{
  display:block;
  margin-top:2px;
  color:var(--muted);
  font-size:12px;
  font-weight:700;
}

.btn{
  border:1px solid var(--border-strong);
  background:rgba(255,255,255,.06);
  color:var(--text);
  padding:10px 15px;
  border-radius:14px;
  text-decoration:none;
  cursor:pointer;
  display:inline-block;
  font-weight:700;
}
.btn:hover{
  background:rgba(255,255,255,.1);
  text-decoration:none;
}
.btn.primary{
  background:linear-gradient(135deg,var(--primary),#ff6b00);
  border-color:rgba(255,138,31,.7);
  color:#111;
  box-shadow:0 10px 30px rgba(255,138,31,.22);
}
.btn.danger{
  background:rgba(239,68,68,.18);
  border-color:rgba(239,68,68,.42);
  color:#fecaca;
}
.icon-button{
  width:36px;
  height:36px;
  display:inline-grid;
  place-items:center;
  border:1px solid var(--border);
  border-radius:12px;
  background:rgba(255,255,255,.055);
  color:var(--text);
  cursor:pointer;
}
.icon-button:hover{
  background:rgba(255,255,255,.1);
}
.icon-button.add-button{
  width:44px;
  height:44px;
  background:linear-gradient(135deg,var(--primary),#ff6b00);
  border-color:rgba(255,138,31,.7);
  color:#111;
  box-shadow:0 10px 30px rgba(255,138,31,.22);
}
.icon-button.danger{
  color:#fca5a5;
  border-color:rgba(239,68,68,.28);
}
.icon-button svg{
  width:18px;
  height:18px;
  fill:none;
  stroke:currentColor;
  stroke-width:2;
  stroke-linecap:round;
  stroke-linejoin:round;
}

table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  overflow:hidden;
}
th,td{
  padding:14px;
  text-align:left;
  border-bottom:1px solid var(--border);
  vertical-align:top;
}
th{
  background:rgba(255,255,255,.055);
  color:#d8dbe3;
  font-size:14px;
}
tr:last-child td{border-bottom:0}
tbody tr:hover{background:rgba(255,138,31,.055)}

.table-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.icon-actions{gap:8px}
.inline-delete{
  display:inline;
  margin:0;
}
.link-button{
  border:0;
  background:none;
  color:var(--primary-2);
  padding:0;
  font:inherit;
  cursor:pointer;
}
.link-button:hover{text-decoration:underline}
.danger-link{color:#fca5a5}

.badge{
  display:inline-block;
  padding:6px 11px;
  border-radius:999px;
  font-size:13px;
  font-weight:800;
}
.badge.green{
  background:rgba(34,197,94,.18);
  color:#86efac;
  border:1px solid rgba(34,197,94,.32);
}
.badge.yellow{
  background:rgba(250,204,21,.16);
  color:#fde68a;
  border:1px solid rgba(250,204,21,.32);
}
.badge.red{
  background:rgba(239,68,68,.16);
  color:#fca5a5;
  border:1px solid rgba(239,68,68,.32);
}
.badge.custom{
  background:rgba(167,170,180,.16);
  color:#fff;
  border:1px solid rgba(167,170,180,.36);
  background:color-mix(in srgb,var(--badge-color) 18%,transparent);
  color:color-mix(in srgb,var(--badge-color) 82%,#fff);
  border:1px solid color-mix(in srgb,var(--badge-color) 44%,transparent);
}
.status-cell-button{
  border:0;
  background:transparent;
  padding:0;
  color:inherit;
  cursor:pointer;
}
.status-cell-button:hover .badge{
  filter:brightness(1.16);
  box-shadow:0 0 0 3px rgba(255,255,255,.07);
}
.color-dot{
  display:inline-block;
  width:14px;
  height:14px;
  border-radius:50%;
  background:var(--dot-color);
  border:1px solid rgba(255,255,255,.45);
  vertical-align:-2px;
  margin-right:8px;
}
.settings-table td{vertical-align:middle}
.drag-col{
  width:48px;
  text-align:center;
}
.drag-handle{cursor:grab}
.drag-handle:active{cursor:grabbing}
.settings-table tr.is-dragging{
  opacity:.52;
  background:rgba(255,138,31,.12);
}
.settings-table tr.is-drop-target{
  box-shadow:inset 0 2px 0 var(--primary);
}
.muted-text{
  color:var(--muted);
  margin:0 0 18px;
}
.muted-inline{
  color:var(--muted);
  font-size:13px;
}
.modal{
  width:min(480px,calc(100vw - 32px));
  padding:0;
  border:0;
  background:transparent;
  color:var(--text);
}
.modal::backdrop{
  background:rgba(0,0,0,.62);
  backdrop-filter:blur(6px);
}
.modal-card{
  padding:22px;
  border:1px solid var(--border);
  border-radius:22px;
  background:rgba(31,33,41,.96);
  box-shadow:var(--shadow);
}
.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin-bottom:18px;
}
.modal-head h2{margin:0}
.modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  margin-top:18px;
}

.filters{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin:16px 0;
  padding:14px;
}
.filters input,.filters select,label input,label textarea,label select{
  width:100%;
  padding:11px 12px;
  border:1px solid var(--border);
  border-radius:14px;
  background:rgba(10,11,15,.72);
  color:var(--text);
  outline:none;
}
.filters input:focus,.filters select:focus,label input:focus,label textarea:focus,label select:focus{
  border-color:rgba(255,138,31,.8);
  box-shadow:0 0 0 4px rgba(255,138,31,.12);
}
.filters input,.filters select{width:auto}
.filters .filter-checkbox{
  min-height:42px;
  margin:0;
  padding:0 4px;
  color:#e9eaf0;
  white-space:nowrap;
}
label{
  display:block;
  font-weight:700;
  margin-bottom:14px;
  color:#e9eaf0;
}
label input,label textarea,label select{
  display:block;
  margin-top:7px;
  font-weight:400;
}
.field-block{
  margin-bottom:14px;
}
.field-block > label{
  margin-bottom:7px;
}
.wysiwyg-editor{
  overflow:hidden;
  border:1px solid var(--border);
  border-radius:16px;
  background:rgba(10,11,15,.72);
}
.wysiwyg-toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  padding:8px;
  border-bottom:1px solid var(--border);
  background:rgba(255,255,255,.045);
}
.wysiwyg-toolbar button,.wysiwyg-toolbar select{
  height:34px;
  display:inline-grid;
  place-items:center;
  border:1px solid var(--border);
  border-radius:10px;
  background:rgba(255,255,255,.055);
  color:var(--text);
  font:700 13px/1 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  cursor:pointer;
}
.wysiwyg-toolbar button{
  width:34px;
}
.wysiwyg-toolbar select{
  width:auto;
  min-width:126px;
  padding:0 9px;
}
.wysiwyg-toolbar button:hover,.wysiwyg-toolbar button:focus-visible,.wysiwyg-toolbar select:focus-visible{
  border-color:rgba(255,138,31,.72);
  background:rgba(255,138,31,.14);
  outline:none;
}
.wysiwyg-surface{
  min-height:270px;
  padding:13px 14px;
  color:#e9eaf0;
  background:transparent;
  font:400 14px/1.5 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
  outline:none;
  overflow:auto;
}
.wysiwyg-surface:focus{
  box-shadow:inset 0 0 0 1px rgba(255,138,31,.72),0 0 0 4px rgba(255,138,31,.1);
}
.quote-html h2,.quote-html h3,.quote-html h4{
  margin:0 0 10px;
  color:#fff;
  line-height:1.25;
}
.quote-html h2{font-size:22px}
.quote-html h3{font-size:18px}
.quote-html h4{font-size:16px}
.quote-html p,.quote-html ul,.quote-html ol,.quote-html blockquote,.quote-html table,.quote-html pre{
  margin:0 0 12px;
}
.quote-html ul,.quote-html ol{
  padding-left:22px;
}
.quote-html blockquote{
  padding-left:12px;
  border-left:3px solid var(--primary);
  color:#d8dbe3;
}
.quote-html code{
  padding:2px 5px;
  border-radius:7px;
  background:rgba(255,255,255,.09);
  color:#ffcf99;
}
.quote-html pre{
  padding:12px;
  overflow:auto;
  border:1px solid var(--border);
  border-radius:12px;
  background:rgba(0,0,0,.22);
}
.quote-html pre code{
  padding:0;
  background:transparent;
  white-space:pre;
}
.quote-html table{
  width:100%;
  border-collapse:collapse;
  overflow:visible;
  background:transparent;
  box-shadow:none;
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
}
.quote-html th,.quote-html td{
  min-width:90px;
  padding:8px 9px;
  border:1px solid var(--border-strong);
  vertical-align:top;
}
.quote-html th{
  background:rgba(255,255,255,.075);
  color:#fff;
}
.quote-html a{
  overflow-wrap:anywhere;
}
.quote-html .q-size-small{font-size:12px}
.quote-html .q-size-large{font-size:18px}
.quote-html .q-size-xlarge{font-size:24px}
.wysiwyg-surface:empty:before{
  content:"Descrizione del preventivo";
  color:var(--muted);
}
.checkbox-label{
  display:flex;
  align-items:center;
  gap:10px;
  font-weight:700;
}
.checkbox-label input{
  display:inline-block;
  flex:0 0 auto;
  width:18px;
  height:18px;
  margin:0;
  padding:0;
  border:0;
  background:transparent;
  accent-color:var(--primary);
}
.auth-card{
  max-width:420px;
  margin:60px auto;
}
.form-card{max-width:780px}
.form-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.alert{
  padding:12px;
  border-radius:14px;
  margin-bottom:12px;
}
.alert.error{
  background:rgba(239,68,68,.16);
  color:#fecaca;
  border:1px solid rgba(239,68,68,.28);
}

.toast-stack{
  position:fixed;
  right:18px;
  bottom:18px;
  z-index:50;
  display:grid;
  gap:10px;
  max-width:min(380px,calc(100vw - 36px));
}
.toast{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  padding:14px 16px;
  border:1px solid var(--border);
  border-radius:16px;
  background:rgba(31,33,41,.94);
  box-shadow:var(--shadow);
  backdrop-filter:blur(18px) saturate(145%);
  -webkit-backdrop-filter:blur(18px) saturate(145%);
  animation:toast-in .18s ease-out;
}
.toast.success{
  border-color:rgba(34,197,94,.38);
  color:#dcfce7;
}
.toast.error{
  border-color:rgba(239,68,68,.42);
  color:#fecaca;
}
.toast-close{
  border:0;
  background:transparent;
  color:inherit;
  font-size:20px;
  line-height:1;
  cursor:pointer;
  opacity:.78;
}
.toast-close:hover{opacity:1}
.toast.is-hiding{
  opacity:0;
  transform:translateY(8px);
  transition:opacity .2s ease,transform .2s ease;
}
@keyframes toast-in{
  from{opacity:0;transform:translateY(8px)}
  to{opacity:1;transform:translateY(0)}
}

@media(max-width:760px){
  .topbar{
    height:auto;
    align-items:flex-start;
    flex-direction:column;
    padding:16px;
  }
  .topbar nav{margin-top:6px}
  .topbar a{
    margin:0 10px 8px 0;
    display:inline-block;
  }
  .page-head{
    align-items:flex-start;
    flex-direction:column;
  }
  table{
    font-size:14px;
    display:block;
    overflow-x:auto;
  }
  .modal-actions{
    flex-direction:column-reverse;
  }
  .modal-actions .btn{
    width:100%;
    text-align:center;
  }
  .chart-layout{
    grid-template-columns:1fr;
    justify-items:center;
  }
  .chart-legend{
    width:100%;
  }
  .wysiwyg-toolbar select{
    flex:1 1 150px;
  }
  .filters input,.filters select{width:100%}
  .filters .filter-checkbox{width:100%}
  .filters .filter-checkbox input{width:18px}
  .toast-stack{
    right:12px;
    bottom:12px;
    max-width:calc(100vw - 24px);
  }
}
