/* Tailwind directives — preflight è disabilitato in tailwind.config per
   non rompere il CSS vanilla esistente */

/* ════════════════════════════════════════════════
   shadcn/ui design tokens, mappati ai colori FA Petroli
   ════════════════════════════════════════════════ */
:root {
  --background: 0 0% 100%;
  --foreground: 222 47% 11%;
  --card: 0 0% 100%;
  --card-foreground: 222 47% 11%;
  --popover: 0 0% 100%;
  --popover-foreground: 222 47% 11%;
  --primary: 217 53% 14%;          /* blu navy FA Petroli */
  --primary-foreground: 0 0% 100%;
  --secondary: 210 40% 96%;
  --secondary-foreground: 217 53% 14%;
  --muted: 210 40% 96%;
  --muted-foreground: 215 16% 47%;
  --accent: 27 88% 50%;            /* arancio FA Petroli */
  --accent-foreground: 0 0% 100%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 100%;
  --border: 214 32% 91%;
  --input: 214 32% 91%;
  --ring: 27 88% 50%;
  --radius: 10px;
}

:root {
  --blue: #1a3aad;
  --blue-dark: #0f2276;
  --blue-mid: #1f45c7;
  --blue-light: #e8edf8;
  --blue-ultra: #f0f3fb;
  --orange: #f07e10;
  --orange-dark: #c96800;
  --orange-light: #fff4e6;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --amber: #d97706;
  --amber-light: #fffbeb;
  --red: #dc2626;
  --red-light: #fef2f2;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --white: #fff;
  --sidebar: 248px;
  --r: 10px;
  --sh: 0 1px 3px rgba(0, 0, 0, 0.07), 0 4px 16px rgba(0, 0, 0, 0.05);
  --sh-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

:root {
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Manrope", var(--font-sans);
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html,
body {
  font-family: var(--font-sans);
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
  line-height: 1.2;
}
tbody td,
.font-display {
  font-variant-numeric: tabular-nums;
}
button {
  cursor: pointer;
  font-family: var(--font-sans);
  border: none;
}
input,
select,
textarea {
  font-family: var(--font-sans);
}
a {
  color: inherit;
  text-decoration: none;
}

/* ════ LOGIN / REGISTER ════ */
.auth-page {
  min-height: 100vh;
  display: flex;
  background: var(--blue-dark);
  position: relative;
  overflow: hidden;
}
.auth-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
      ellipse 800px 600px at -5% 50%,
      rgba(240, 126, 16, 0.12) 0%,
      transparent 65%
    ),
    radial-gradient(
      ellipse 600px 600px at 105% 100%,
      rgba(26, 58, 173, 0.5) 0%,
      transparent 65%
    );
  pointer-events: none;
}
.auth-grid {
  display: grid;
  grid-template-columns: 1fr 480px;
  min-height: 100vh;
  width: 100%;
  position: relative;
  z-index: 1;
}
.auth-left {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 80px 72px;
}
.auth-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 72px;
}
.auth-brand-icon {
  width: 54px;
  height: 54px;
  background: var(--orange);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-family: var(--font-display);
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.02em;
  box-shadow: 0 6px 24px rgba(240, 126, 16, 0.4);
}
.auth-brand-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}
.auth-brand-name small {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.auth-headline {
  font-size: 52px;
  font-weight: 800;
  color: #fff;
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
}
.auth-headline em {
  font-style: normal;
  color: var(--orange);
}
.auth-sub {
  color: rgba(255, 255, 255, 0.5);
  font-size: 17px;
  line-height: 1.7;
  max-width: 400px;
  margin-bottom: 48px;
}
.auth-bullets {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.auth-bullet {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 15px;
}
.auth-bullet::before {
  content: "";
  width: 7px;
  height: 7px;
  background: var(--orange);
  border-radius: 50%;
  flex-shrink: 0;
}
.auth-right {
  width: 480px;
  background: var(--white);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px 52px;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.15);
  overflow-y: auto;
}
.auth-form-title {
  font-size: 30px;
  font-weight: 700;
  color: var(--blue-dark);
  margin-bottom: 6px;
}
.auth-form-sub {
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 32px;
}
.auth-footer {
  margin-top: 24px;
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
  line-height: 1.7;
}
.auth-footer a {
  color: var(--orange);
  font-weight: 600;
}

/* ════ FORM ════ */
.form-group {
  margin-bottom: 18px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r);
  font-size: 15px;
  color: var(--gray-900);
  background: #fff;
  transition: border 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 58, 173, 0.1);
}
.form-group input:disabled {
  background: var(--gray-50);
  color: var(--gray-700);
}
.form-group textarea {
  resize: vertical;
  min-height: 90px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ════ BUTTONS ════ */
.btn-primary {
  width: 100%;
  padding: 15px;
  background: var(--blue);
  color: #fff;
  border-radius: var(--r);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(26, 58, 173, 0.3);
}
.btn-primary:hover {
  background: var(--blue-mid);
  box-shadow: 0 6px 24px rgba(26, 58, 173, 0.4);
  transform: translateY(-1px);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-secondary {
  padding: 10px 20px;
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 600;
  border: 1.5px solid var(--gray-200);
}
.btn-secondary:hover {
  background: var(--gray-200);
}
.btn-orange {
  padding: 11px 24px;
  background: var(--orange);
  color: #fff;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 3px 12px rgba(240, 126, 16, 0.3);
}
.btn-orange:hover {
  background: var(--orange-dark);
}
.btn-ghost {
  padding: 10px 20px;
  background: transparent;
  color: var(--blue);
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 600;
  border: 1.5px solid var(--blue-light);
}
.btn-ghost:hover {
  background: var(--blue-ultra);
}
.btn-danger {
  padding: 10px 20px;
  background: var(--red);
  color: #fff;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 600;
}
.btn-danger:hover {
  background: #b91c1c;
}
.btn-success {
  padding: 10px 20px;
  background: var(--green);
  color: #fff;
  border-radius: var(--r);
  font-size: 14px;
  font-weight: 600;
}

/* ════ APP SHELL ════ */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  background: var(--blue-dark);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  position: sticky;
  top: 0;
  align-self: flex-start;
  overflow: hidden;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}
.sidebar-brand {
  padding: 28px 24px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-brand-icon {
  width: 56px;
  height: 56px;
  background: var(--orange);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  letter-spacing: -0.02em;
  box-shadow: 0 3px 10px rgba(240, 126, 16, 0.35);
}
.sidebar-brand-text {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}
.sidebar-brand-text small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}
.sidebar-client {
  padding: 14px 16px;
  margin: 14px 12px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--r);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-client-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.sidebar-client-name {
  font-weight: 700;
  color: #fff;
  font-size: 14px;
  line-height: 1.3;
}
.sidebar-client-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.45);
  margin-top: 2px;
}
.sidebar-nav {
  flex: 1;
  padding: 8px 12px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 3px;
}
.sidebar-brand,
.sidebar-client {
  flex-shrink: 0;
}
.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 16px 12px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--r);
  color: rgba(255, 255, 255, 0.6);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.nav-item.active {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 2px 12px rgba(26, 58, 173, 0.4);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  background: var(--orange);
  border-radius: 0 3px 3px 0;
}
.nav-icon {
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.nav-icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.75;
}
.nav-badge {
  margin-left: auto;
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 32px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.topbar-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue-dark);
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.topbar-uname {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
}
button.topbar-user {
  padding: 4px 8px 4px 4px;
  margin-right: -8px;
  background: transparent;
  border: 1.5px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  transition: background 0.15s ease, border-color 0.15s ease;
}
button.topbar-user:hover,
button.topbar-user[aria-expanded="true"] {
  background: var(--gray-50);
  border-color: var(--gray-200);
}
button.topbar-user:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.topbar-chevron {
  display: inline-flex;
  color: var(--gray-500);
  transition: transform 0.15s ease;
}
button.topbar-user[aria-expanded="true"] .topbar-chevron {
  transform: rotate(180deg);
}
.user-menu {
  min-width: 250px;
}
.user-menu-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 10px 6px;
}
.user-menu-id {
  min-width: 0;
}
.user-menu-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-menu-sub {
  font-size: 12px;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-menu .row-menu-item {
  text-decoration: none;
}
.user-menu .row-menu-item svg {
  color: var(--gray-500);
  flex: 0 0 auto;
}
.user-menu .row-menu-item.danger svg {
  color: inherit;
}

.content {
  padding: 32px;
  max-width: 1280px;
  width: 100%;
  min-width: 0;
  margin: 0 auto;
}

/* ════ DASHBOARD / CARDS ════ */
.dashboard-greeting {
  margin-bottom: 28px;
}
.dashboard-greeting h2 {
  font-size: 32px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}
.dashboard-greeting p {
  color: var(--gray-500);
  font-size: 15px;
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.kpi-card {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  box-shadow: var(--sh);
  border-left: 4px solid var(--gray-300);
  position: relative;
}
.kpi-card.blue {
  border-left-color: var(--blue);
}
.kpi-card.orange {
  border-left-color: var(--orange);
}
.kpi-card.green {
  border-left-color: var(--green);
}
.kpi-icon {
  font-size: 28px;
  margin-bottom: 8px;
}
.kpi-label {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.kpi-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--gray-900);
  font-family: var(--font-display);
  line-height: 1;
}
.kpi-sub {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 6px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
.card {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--sh);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-100);
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
}
.card-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
}

/* ════ ROW ACTIONS ════ */
.td-actions {
  white-space: nowrap;
  width: 1%;
}
.td-nowrap {
  white-space: nowrap;
}
.row-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.row-actions > button,
.row-actions > a {
  white-space: nowrap;
}
.row-menu-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--gray-500);
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer;
}
.row-menu-btn:hover,
.row-menu-btn[aria-expanded="true"] {
  background: var(--gray-50);
  color: var(--gray-900);
}
.row-menu-list {
  position: fixed;
  z-index: 60;
  min-width: 210px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 30, 55, 0.16);
  padding: 6px;
  display: none;
}
.row-menu-list.open {
  display: block;
}
.row-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  background: transparent;
  border: none;
  border-radius: 7px;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}
.row-menu-item:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}
.row-menu-item.danger {
  color: var(--red);
}
.row-menu-item.danger:hover {
  background: var(--red-light);
}
.row-menu-sep {
  height: 1px;
  background: var(--gray-100);
  margin: 4px 2px;
}

/* Colonne secondarie: sparizione progressiva su schermi stretti, niente scroll orizzontale */
.table-clients thead th,
.table-clients tbody td {
  padding-left: 14px;
  padding-right: 14px;
}
.td-email {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-ref-inline { display: none; }
@media (max-width: 1600px) {
  .col-orders { display: none; }
}
@media (max-width: 1500px) {
  .col-code { display: none; }
  .row-actions .btn-label { display: none; }
}
@media (max-width: 1350px) {
  .col-ref { display: none; }
  .col-ref-inline { display: block; }
  .td-email { max-width: 170px; }
}
@media (max-width: 1150px) {
  .col-piva { display: none; }
}
@media (max-width: 900px) {
  .col-ip { display: none; }
}

/* ════ TABLES ════ */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  background: var(--gray-50);
  text-align: left;
  padding: 12px 22px;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--gray-200);
}
tbody td {
  padding: 14px 22px;
  font-size: 14px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
}
tbody tr:last-child td {
  border-bottom: none;
}
.td-bold {
  font-weight: 700;
  color: var(--blue-dark);
}
.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge-waiting {
  background: var(--amber-light);
  color: var(--amber);
}
.badge-processing {
  background: var(--blue-ultra);
  color: var(--blue);
}
.badge-done {
  background: var(--green-light);
  color: var(--green);
}
.badge-cancelled {
  background: var(--red-light);
  color: var(--red);
}
.badge-pending {
  background: var(--amber-light);
  color: var(--amber);
}
.badge-active {
  background: var(--green-light);
  color: var(--green);
}
.badge-suspended {
  background: var(--red-light);
  color: var(--red);
}
.badge-locked {
  background: #fff1f2;
  color: #be123c;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.action-btn {
  background: var(--gray-100);
  border: none;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
}
.action-btn:hover {
  background: var(--gray-200);
}

/* ════ PAGE HEADER ════ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-header h2 {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 4px;
}
.page-header p {
  color: var(--gray-500);
  font-size: 14px;
}

/* ════ ORDER FORM ════ */
.order-form-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
}
@media (max-width: 1100px) {
  .order-form-grid {
    grid-template-columns: 1fr;
  }
}
.order-card {
  background: #fff;
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--sh);
}
.order-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 16px;
  text-transform: none;
  letter-spacing: 0;
}
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.prod-tile {
  background: #fff;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
  cursor: pointer;
}
.prod-tile:hover {
  border-color: var(--blue-light);
  background: var(--blue-ultra);
}
.prod-tile.selected {
  border-color: var(--blue);
  background: var(--blue-ultra);
  box-shadow: 0 4px 16px rgba(26, 58, 173, 0.15);
}
.prod-tile-icon {
  font-size: 32px;
}
.prod-tile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  text-align: center;
  line-height: 1.3;
}
.qty-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: var(--r);
}
.qty-tab {
  flex: 1;
  text-align: center;
  padding: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  border-radius: 7px;
  cursor: pointer;
}
.qty-tab.active {
  background: #fff;
  color: var(--blue);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.qty-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.qty-preset {
  padding: 14px;
  background: var(--gray-50);
  border: 2px solid var(--gray-200);
  border-radius: var(--r);
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.2s;
}
.qty-preset:hover {
  border-color: var(--blue-light);
}
.qty-preset.selected {
  border-color: var(--blue);
  background: var(--blue-ultra);
  color: var(--blue);
}
.delivery-points {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dp-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--r);
  cursor: pointer;
  transition: all 0.2s;
}
.dp-option:hover {
  border-color: var(--blue-light);
}
.dp-option.selected {
  border-color: var(--blue);
  background: var(--blue-ultra);
}
.dp-radio {
  width: 18px;
  height: 18px;
  border: 2px solid var(--gray-300);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}
.dp-option.selected .dp-radio {
  border-color: var(--blue);
}
.dp-option.selected .dp-radio::after {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--blue);
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
.dp-name {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 14px;
}
.dp-addr {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

.order-summary-card {
  background: var(--blue-dark);
  border-radius: 14px;
  padding: 24px;
  position: sticky;
  top: 88px;
  color: #fff;
}
.order-summary-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 18px;
}
.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 12px;
}
.summary-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.summary-value {
  font-size: 14px;
  text-align: right;
}
.summary-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 16px 0;
}
.btn-submit {
  width: 100%;
  padding: 15px;
  background: var(--orange);
  color: #fff;
  border-radius: var(--r);
  font-size: 15px;
  font-weight: 700;
  margin-top: 16px;
  box-shadow: 0 4px 16px rgba(240, 126, 16, 0.3);
}
.btn-submit:hover {
  background: var(--orange-dark);
}

.success-screen {
  background: #fff;
  border-radius: 14px;
  padding: 60px 40px;
  text-align: center;
  box-shadow: var(--sh);
}
.success-icon {
  font-size: 72px;
  margin-bottom: 16px;
}
.success-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--green);
  margin-bottom: 12px;
}
.success-msg {
  color: var(--gray-500);
  font-size: 15px;
  max-width: 480px;
  margin: 0 auto 24px;
  line-height: 1.6;
}
.success-code {
  display: inline-block;
  padding: 12px 24px;
  background: var(--blue-ultra);
  color: var(--blue-dark);
  border-radius: var(--r);
  font-size: 18px;
  font-weight: 800;
  font-family: var(--font-display);
  margin-bottom: 24px;
}
.success-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ════ FILTERS ════ */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--sh);
}
.filter-bar input,
.filter-bar select {
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: #fff;
}
.filter-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
}

/* ── Ricerca con autocompletamento ── */
.ac-wrap {
  position: relative;
  width: 280px;
  max-width: 100%;
}
.ac-wrap input {
  width: 100%;
  padding-right: 34px;
}
.ac-wrap input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.ac-clear {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--gray-100, #f1f5f9);
  color: var(--gray-500);
  cursor: pointer;
}
.ac-clear:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}
.ac-list {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: auto;
  width: max(100%, 340px);
  max-width: 92vw;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(15, 30, 55, 0.16);
  padding: 5px;
  max-height: 320px;
  overflow-y: auto;
}
.ac-item {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.ac-item:hover,
.ac-item.active {
  background: var(--gray-50);
}
.ac-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-sub {
  display: block;
  font-size: 12px;
  color: var(--gray-500);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-tag {
  display: inline-block;
  margin-top: 3px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
#c-card {
  transition: opacity 0.15s ease;
}
#c-card.is-loading {
  opacity: 0.5;
  pointer-events: none;
}
@media (max-width: 768px) {
  .ac-wrap {
    width: 100%;
  }
}

/* ════ PROFILE ════ */
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 900px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}
.profile-header-card {
  grid-column: 1 / -1;
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--sh);
}
.profile-avatar-big {
  width: 70px;
  height: 70px;
  border-radius: 14px;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  font-family: var(--font-display);
}
.profile-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
}
.profile-since {
  color: var(--gray-500);
  font-size: 13px;
  margin-top: 2px;
}
.profile-piva {
  margin-left: auto;
  padding: 8px 14px;
  background: var(--blue-ultra);
  color: var(--blue);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
}
.profile-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--sh);
  overflow: hidden;
}
.profile-card-body {
  padding: 22px;
}
.profile-card {
  scroll-margin-top: 84px;
  transition: box-shadow 0.4s ease;
}
.profile-card-focus {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35), var(--sh);
}

/* ════ ALERTS / TOASTS ════ */
.alert {
  padding: 14px 18px;
  border-radius: var(--r);
  margin-bottom: 18px;
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-error {
  background: var(--red-light);
  color: var(--red);
  border: 1px solid #fecaca;
}
.alert-success {
  background: var(--green-light);
  color: var(--green);
  border: 1px solid #bbf7d0;
}
.alert-info {
  background: var(--blue-ultra);
  color: var(--blue);
  border: 1px solid var(--blue-light);
}

/* ════ EMPTY STATE ════ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.hidden {
  display: none !important;
}

/* ════ MOBILE HAMBURGER ════ */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px 8px;
  color: var(--blue-dark);
}
.sidebar-overlay {
  display: none;
}

/* ════ RESPONSIVE ════ */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    z-index: 100;
    width: 280px;
    transition: left 0.3s ease;
  }
  .sidebar.open {
    left: 0;
  }
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
  }
  .sidebar-overlay.open {
    display: block;
  }
  .hamburger-btn {
    display: block;
  }
  .main-area {
    margin-left: 0;
    width: 100%;
  }
  .topbar {
    padding: 0 16px;
    padding-left: 52px;
    height: 56px;
  }
  .topbar-title {
    font-size: 18px;
  }
  .topbar-uname {
    display: none;
  }
  .content {
    padding: 16px;
  }
  .auth-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .auth-left {
    display: none;
  }
  .auth-right {
    width: 100%;
    min-height: 100vh;
    padding: 32px 24px;
    box-shadow: none;
  }
  .auth-form-title {
    font-size: 24px;
  }
  .dashboard-greeting h2 {
    font-size: 24px;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .kpi-card {
    padding: 18px;
  }
  .kpi-value {
    font-size: 26px;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .page-header h2 {
    font-size: 22px;
  }
  thead th,
  tbody td {
    padding: 10px 14px;
    font-size: 12px;
  }
  .order-form-grid {
    grid-template-columns: 1fr;
  }
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .qty-presets {
    grid-template-columns: repeat(2, 1fr);
  }
  .order-summary-card {
    position: static;
  }
  .profile-grid {
    grid-template-columns: 1fr;
  }
  .profile-header-card {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  .profile-piva {
    margin-left: 0;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar input,
  .filter-bar select {
    width: 100% !important;
  }
  .filter-label {
    display: none;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .success-screen {
    padding: 40px 20px;
  }
  .success-title {
    font-size: 22px;
  }
  .success-actions {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .auth-right {
    padding: 24px 16px;
  }
  .products-grid {
    grid-template-columns: 1fr;
  }
}

/* ════ MOBILE BRAND (auth pages) ════ */
.auth-mobile-brand {
  display: none;
}
.sidebar-close-btn {
  display: none;
}

/* ════ ENHANCED RESPONSIVE ════ */
@media (max-width: 768px) {
  /* iOS safe areas */
  body {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  /* Mobile brand on auth pages */
  .auth-mobile-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--gray-200);
  }
  .auth-mobile-brand .auth-brand-icon {
    width: 46px;
    height: 46px;
    font-size: 18px;
  }
  .auth-mobile-brand .auth-brand-name {
    font-size: 22px;
  }

  /* Better hamburger button */
  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 98;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    border: 1px solid var(--gray-200);
    color: var(--blue-dark);
    padding: 0;
  }

  /* Sidebar close button */
  .sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    border: none;
    color: rgba(255,255,255,0.6);
    font-size: 16px;
    cursor: pointer;
  }
  .sidebar-close-btn:hover {
    background: rgba(255,255,255,0.2);
    color: white;
  }

  /* Smooth sidebar */
  .sidebar {
    position: fixed;
    left: -290px;
    top: 0;
    z-index: 100;
    width: 280px;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }
  .sidebar.open {
    left: 0;
    box-shadow: 8px 0 32px rgba(0,0,0,0.3);
  }

  /* Overlay animation */
  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0);
    z-index: 99;
    pointer-events: none;
    transition: background 0.3s ease;
  }
  .sidebar-overlay.open {
    background: rgba(0,0,0,0.5);
    pointer-events: auto;
  }

  /* Topbar */
  .topbar {
    padding: 0 16px;
    padding-left: 56px;
    height: 56px;
  }
  .topbar-title {
    font-size: 17px;
  }
  .topbar-uname {
    display: none;
  }
  .topbar-avatar {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }

  /* Content */
  .content {
    padding: 16px;
  }

  /* Auth pages */
  .auth-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .auth-left {
    display: none;
  }
  .auth-right {
    width: 100%;
    min-height: 100dvh;
    padding: 40px 24px;
    box-shadow: none;
    justify-content: flex-start;
    padding-top: 48px;
  }
  .auth-form-title {
    font-size: 26px;
  }
  .auth-form-sub {
    font-size: 14px;
    margin-bottom: 24px;
  }

  /* Better touch targets on forms */
  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 14px 16px;
    font-size: 16px; /* prevents iOS zoom */
  }
  .btn-primary {
    padding: 16px;
    font-size: 16px;
  }

  /* Dashboard */
  .dashboard-greeting {
    margin-bottom: 20px;
  }
  .dashboard-greeting h2 {
    font-size: 22px;
  }
  .dashboard-greeting p {
    font-size: 13px;
  }

  /* KPI */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
  }
  .kpi-card {
    padding: 16px;
    border-radius: 12px;
    border-left-width: 3px;
  }
  .kpi-icon {
    font-size: 22px;
    margin-bottom: 4px;
  }
  .kpi-label {
    font-size: 11px;
    margin-bottom: 2px;
  }
  .kpi-value {
    font-size: 22px;
  }
  .kpi-sub {
    font-size: 11px;
    margin-top: 4px;
  }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-header h2 {
    font-size: 20px;
  }
  .page-header p {
    font-size: 13px;
  }

  /* Tables */
  .card {
    border-radius: 12px;
  }
  .card-header {
    padding: 14px 16px;
  }
  .card-title {
    font-size: 14px;
  }
  thead th {
    padding: 10px 12px;
    font-size: 10px;
    white-space: nowrap;
  }
  tbody td {
    padding: 12px 12px;
    font-size: 13px;
  }
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* Scroll hint gradient */
  .table-wrap::after {
    content: "";
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
    pointer-events: none;
  }
  .card {
    position: relative;
    overflow: hidden;
  }

  /* Order form */
  .order-form-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .order-card {
    padding: 18px;
    border-radius: 12px;
  }
  .order-card h3 {
    font-size: 15px;
    margin-bottom: 12px;
  }
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .prod-tile {
    padding: 12px 8px;
    border-radius: 10px;
  }
  .prod-tile-icon {
    font-size: 26px;
  }
  .prod-tile-name {
    font-size: 12px;
  }
  .qty-presets {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .qty-preset {
    padding: 12px 8px;
    font-size: 14px;
  }
  .order-summary-card {
    position: static;
    border-radius: 12px;
    padding: 20px;
  }
  .order-summary-card h3 {
    font-size: 16px;
    margin-bottom: 14px;
  }

  /* Profile */
  .profile-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .profile-header-card {
    flex-direction: column;
    text-align: center;
    gap: 12px;
    padding: 20px;
    border-radius: 12px;
  }
  .profile-avatar-big {
    width: 56px;
    height: 56px;
    font-size: 20px;
    border-radius: 12px;
  }
  .profile-name {
    font-size: 18px;
  }
  .profile-piva {
    margin-left: 0;
  }
  .profile-card {
    border-radius: 12px;
  }
  .profile-card-body {
    padding: 16px;
  }

  /* Filters */
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 12px;
  }
  .filter-bar input,
  .filter-bar select {
    width: 100% !important;
    padding: 12px 14px;
    font-size: 14px;
  }
  .filter-label {
    display: none;
  }

  /* Form rows */
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* Badges */
  .badge {
    font-size: 11px;
    padding: 3px 8px;
  }

  /* Action buttons */
  .btn-orange {
    width: 100%;
    text-align: center;
    padding: 12px 20px;
  }
  .btn-secondary,
  .btn-success,
  .btn-danger {
    padding: 8px 14px;
    font-size: 13px;
  }

  /* Success screen */
  .success-screen {
    padding: 40px 20px;
    border-radius: 12px;
  }
  .success-icon {
    font-size: 56px;
  }
  .success-title {
    font-size: 22px;
  }
  .success-msg {
    font-size: 14px;
  }
  .success-actions {
    flex-direction: column;
    gap: 10px;
  }

  /* Alerts */
  .alert {
    font-size: 13px;
    padding: 12px 14px;
    border-radius: 8px;
  }

  /* Empty state */
  .empty-state {
    padding: 40px 16px;
    font-size: 13px;
  }
  .empty-state-icon {
    font-size: 36px;
    margin-bottom: 8px;
  }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .order-form-grid {
    grid-template-columns: 1fr 300px;
  }
  .auth-left {
    padding: 60px 48px;
  }
  .auth-headline {
    font-size: 40px;
  }
}

@media (max-width: 480px) {
  .auth-right {
    padding: 32px 16px;
    padding-top: 40px;
  }
  .auth-mobile-brand .auth-brand-name {
    font-size: 20px;
  }
  .products-grid {
    grid-template-columns: 1fr 1fr;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .kpi-card {
    padding: 14px;
  }
  .qty-presets {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ════════════════════════════════════════════════════════════
   LOGIN V2 — Modern Card Design
   ════════════════════════════════════════════════════════════ */

@keyframes loginFadeIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes loginSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes loginFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-8px, -12px); }
}
@keyframes loginFloat2 {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(10px, -8px); }
}
@keyframes loginShine {
  from { left: -100%; }
  to { left: 200%; }
}
@keyframes dotPulse {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.35; }
}

.login-v2-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8edf8 0%, #f0f3fb 50%, #fff4e6 100%);
  padding: 24px;
}

.login-v2-card {
  display: flex;
  width: 100%;
  max-width: 960px;
  min-height: 580px;
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(15, 34, 118, 0.12), 0 1px 3px rgba(0,0,0,0.06);
  animation: loginFadeIn 0.6s ease-out;
}

/* ── Left Panel ── */
.login-v2-left {
  width: 420px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 60%, var(--blue-mid) 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-v2-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.12) 1px, transparent 1px);
  background-size: 20px 20px;
  animation: dotPulse 4s ease-in-out infinite;
}
.login-v2-left-content {
  position: relative;
  z-index: 2;
  padding: 48px 36px;
  text-align: center;
}
.login-v2-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
  animation: loginSlideUp 0.6s ease-out 0.3s both;
}
.login-v2-logo-icon {
  width: 60px;
  height: 60px;
  background: var(--orange);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  color: #fff;
  letter-spacing: -0.02em;
  box-shadow: 0 8px 24px rgba(240, 126, 16, 0.4);
}
.login-v2-brand-title {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 4px;
  animation: loginSlideUp 0.6s ease-out 0.4s both;
}
.login-v2-brand-sub {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 36px;
  animation: loginSlideUp 0.6s ease-out 0.5s both;
}
.login-v2-features {
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
  animation: loginSlideUp 0.6s ease-out 0.6s both;
}
.login-v2-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.7);
  font-size: 14px;
  line-height: 1.4;
}
.login-v2-feature-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(240, 126, 16, 0.5);
}

/* Decorative circles */
.login-v2-circle {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.08);
}
.login-v2-circle-1 {
  width: 300px;
  height: 300px;
  top: -80px;
  right: -100px;
  animation: loginFloat 8s ease-in-out infinite;
}
.login-v2-circle-2 {
  width: 200px;
  height: 200px;
  bottom: -60px;
  left: -40px;
  background: rgba(240, 126, 16, 0.06);
  animation: loginFloat2 6s ease-in-out infinite;
}
.login-v2-circle-3 {
  width: 120px;
  height: 120px;
  top: 40%;
  right: -30px;
  background: rgba(255,255,255,0.03);
  animation: loginFloat 10s ease-in-out infinite reverse;
}

/* ── Right Panel ── */
.login-v2-right {
  flex: 1;
  padding: 48px 44px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-v2-right-scroll {
  overflow-y: auto;
  justify-content: flex-start;
  padding-top: 36px;
}
.login-v2-mobile-brand {
  display: none;
}
.login-v2-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: var(--blue-dark);
  margin-bottom: 4px;
  animation: loginSlideUp 0.5s ease-out 0.2s both;
}
.login-v2-subtitle {
  color: var(--gray-500);
  font-size: 15px;
  margin-bottom: 32px;
  animation: loginSlideUp 0.5s ease-out 0.3s both;
}

/* ── Form ── */
.login-v2-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  animation: loginSlideUp 0.5s ease-out 0.4s both;
}
.login-v2-field label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.login-v2-required {
  color: var(--orange);
}
.login-v2-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.login-v2-input-icon {
  position: absolute;
  left: 14px;
  color: var(--gray-400);
  pointer-events: none;
  z-index: 1;
}
.login-v2-input-wrap input {
  width: 100%;
  padding: 13px 16px 13px 42px;
  border: 1.5px solid var(--gray-200);
  border-radius: 12px;
  font-size: 15px;
  color: var(--gray-900);
  background: var(--gray-50);
  transition: all 0.2s;
  outline: none;
  font-family: var(--font-sans);
}
.login-v2-input-wrap input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(26, 58, 173, 0.1);
  background: #fff;
}
.login-v2-input-wrap input::placeholder {
  color: var(--gray-400);
}
.login-v2-eye-btn {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  padding: 4px;
  color: var(--gray-400);
  cursor: pointer;
  display: flex;
  border-radius: 6px;
  transition: all 0.2s;
}
.login-v2-eye-btn:hover {
  color: var(--gray-700);
  background: var(--gray-100);
}

.login-v2-submit {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-mid) 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 16px rgba(26, 58, 173, 0.3);
  margin-top: 4px;
}
.login-v2-submit:hover {
  box-shadow: 0 6px 24px rgba(26, 58, 173, 0.4);
  transform: translateY(-1px);
}
.login-v2-submit:hover .login-v2-submit-shine {
  animation: loginShine 0.8s ease-in-out;
}
.login-v2-submit:active {
  transform: translateY(0);
}
.login-v2-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.login-v2-submit-shine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -100%;
  width: 60px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  filter: blur(6px);
  pointer-events: none;
}

.login-v2-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--red-light);
  color: var(--red);
  border: 1px solid #fecaca;
  border-radius: 10px;
  font-size: 14px;
}

/* ── Footer ── */
.login-v2-footer {
  margin-top: 28px;
  text-align: center;
  animation: loginSlideUp 0.5s ease-out 0.5s both;
}
.login-v2-footer p {
  color: var(--gray-400);
  font-size: 13px;
  line-height: 1.7;
}
.login-v2-footer a {
  color: var(--orange);
  font-weight: 700;
  text-decoration: none;
  transition: color 0.2s;
}
.login-v2-footer a:hover {
  color: var(--orange-dark);
}
.login-v2-contact {
  margin-top: 12px;
}
.login-v2-contact a {
  color: var(--blue);
}

/* ── Mobile Brand ── */
.login-v2-logo-icon-sm {
  width: 42px;
  height: 42px;
  background: var(--orange);
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 12px rgba(240, 126, 16, 0.3);
}
.login-v2-mobile-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--blue-dark);
}
.login-v2-mobile-sub {
  font-size: 12px;
  color: var(--gray-400);
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* ── Login V2 Responsive ── */
@media (max-width: 768px) {
  .login-v2-wrapper {
    padding: 0;
    align-items: flex-start;
  }
  .login-v2-card {
    flex-direction: column;
    border-radius: 0;
    min-height: 100dvh;
    max-width: 100%;
    box-shadow: none;
  }
  .login-v2-left {
    display: none;
  }
  .login-v2-right {
    padding: 32px 24px;
    padding-top: 48px;
  }
  .login-v2-mobile-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--gray-200);
  }
  .login-v2-title {
    font-size: 26px;
  }
  .login-v2-subtitle {
    font-size: 14px;
    margin-bottom: 24px;
  }
  .login-v2-input-wrap input {
    font-size: 16px;
    padding: 14px 16px 14px 42px;
  }
  .login-v2-submit {
    padding: 16px 24px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .login-v2-right {
    padding: 24px 16px;
    padding-top: 40px;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .login-v2-left {
    width: 340px;
  }
  .login-v2-left-content {
    padding: 36px 28px;
  }
  .login-v2-brand-title {
    font-size: 30px;
  }
}

/* ════ LOADING SCREEN ════ */
@keyframes loaderLetter {
  0% { opacity: 0; transform: translateY(20px) rotateX(-90deg); text-shadow: 0 0 0px rgba(255,255,255,0); }
  10% { opacity: 1; transform: translateY(0) rotateX(0deg); text-shadow: 0 0 10px rgba(255,255,255,0.8); }
  30% { opacity: 1; transform: translateY(0) rotateX(0deg); text-shadow: 0 0 10px rgba(255,255,255,0.8); }
  50% { opacity: 0; transform: translateY(-20px) rotateX(90deg); text-shadow: 0 0 0px rgba(255,255,255,0); }
  100% { opacity: 0; }
}
@keyframes loaderBar {
  0% { left: -100%; }
  50% { left: 100%; }
  100% { left: -100%; }
}
@keyframes loaderFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 60%, var(--blue-mid) 100%);
  animation: loaderFadeIn 0.3s ease-out;
}
.loading-screen-logo {
  width: 64px;
  height: 64px;
  background: var(--orange);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 26px;
  color: #fff;
  letter-spacing: -0.02em;
  box-shadow: 0 8px 32px rgba(240, 126, 16, 0.4);
  margin-bottom: 24px;
}
.loading-screen-text {
  display: flex;
  gap: 2px;
  margin-bottom: 20px;
  perspective: 500px;
}
.loading-screen-letter {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
  opacity: 0;
  display: inline-block;
  animation: loaderLetter 2.5s ease-in-out infinite;
}
.loading-screen-letter:nth-child(1) { animation-delay: 0s; }
.loading-screen-letter:nth-child(2) { animation-delay: 0.08s; }
.loading-screen-letter:nth-child(3) { animation-delay: 0.16s; }
.loading-screen-letter:nth-child(4) { animation-delay: 0.24s; }
.loading-screen-letter:nth-child(5) { animation-delay: 0.32s; }
.loading-screen-letter:nth-child(6) { animation-delay: 0.4s; }
.loading-screen-letter:nth-child(7) { animation-delay: 0.48s; }
.loading-screen-letter:nth-child(8) { animation-delay: 0.56s; }
.loading-screen-letter:nth-child(9) { animation-delay: 0.64s; }
.loading-screen-letter:nth-child(10) { animation-delay: 0.72s; }
.loading-screen-letter:nth-child(11) { animation-delay: 0.8s; }
.loading-screen-letter:nth-child(12) { animation-delay: 0.88s; }
.loading-screen-letter:nth-child(13) { animation-delay: 0.96s; }
.loading-screen-letter:nth-child(14) { animation-delay: 1.04s; }
.loading-screen-letter:nth-child(15) { animation-delay: 1.12s; }

.loading-screen-bar-wrap {
  width: 180px;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}
.loading-screen-bar {
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, var(--orange), transparent);
  border-radius: 10px;
  animation: loaderBar 1.8s ease-in-out infinite;
}
.loading-screen-sub {
  margin-top: 16px;
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.5px;
}

/* ════════════════════════════════════════════════
   FA Petroli — Logo image overrides
   ════════════════════════════════════════════════ */
.sidebar-brand-icon.has-logo,
.login-v2-logo-icon.has-logo,
.login-v2-logo-icon-sm.has-logo,
.loading-screen-logo.has-logo {
  background: #fff;
  padding: 4px;
  overflow: hidden;
}
.sidebar-brand-icon.has-logo img,
.login-v2-logo-icon.has-logo img,
.login-v2-logo-icon-sm.has-logo img,
.loading-screen-logo.has-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ════════════════════════════════════════════════
   Skeleton loader — feedback istantaneo durante la
   navigazione lato server
   ════════════════════════════════════════════════ */
@keyframes skelPulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}
.skel {
  display: block;
  background: linear-gradient(
    90deg,
    var(--gray-100) 0%,
    #f4f6fa 50%,
    var(--gray-100) 100%
  );
  background-size: 200% 100%;
  border-radius: 6px;
  animation: skelPulse 1.1s ease-in-out infinite,
             skelShimmer 1.6s linear infinite;
  height: 14px;
}
@keyframes skelShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel-text { height: 14px; width: 80%; }
.skel-h2 { height: 30px; width: 40%; max-width: 320px; border-radius: 8px; }
.skel-row {
  height: 44px;
  width: 100%;
  border-radius: 10px;
}
.skel-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
}
.skel-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gray-100);
  animation: skelPulse 1.1s ease-in-out infinite;
}

.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 16px);
  background: #0f1e37;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(15, 30, 55, 0.35);
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 9999;
  max-width: 90vw;
}
.app-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.app-toast.error {
  background: #dc2626;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 55, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}
.modal-backdrop.open {
  display: flex;
}
.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(15, 30, 55, 0.3);
}

.ui-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(215 16% 47%);
  line-height: 1;
}
.ui-input {
  display: flex;
  height: 44px;
  width: 100%;
  border-radius: calc(10px - 2px);
  border: 1px solid hsl(214 32% 91%);
  background: #fff;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font-sans);
  transition: border-color 0.15s, box-shadow 0.15s;
  color: hsl(222 47% 11%);
}
.ui-input::placeholder { color: hsl(215 16% 47%); }
.ui-input:focus-visible {
  outline: none;
  border-color: #f07e10;
  box-shadow: 0 0 0 2px rgba(240, 126, 16, 0.2);
}
.ui-input:disabled { cursor: not-allowed; opacity: 0.6; }
textarea.ui-input { height: auto; min-height: 88px; resize: vertical; }
select.ui-input { appearance: auto; }
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  border-radius: calc(10px - 2px);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  height: 40px;
  padding: 8px 16px;
  font-family: var(--font-sans);
  transition: all 0.15s;
  text-decoration: none;
  background: #0f1e37;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.ui-btn:hover { background: #1a3a5c; }
.ui-btn:disabled { pointer-events: none; opacity: 0.5; }
.ui-btn:focus-visible { outline: none; box-shadow: 0 0 0 2px #fff, 0 0 0 4px #f07e10; }
.ui-btn.accent {
  background: #f07e10;
  box-shadow: 0 4px 12px rgba(240, 126, 16, 0.35);
}
.ui-btn.accent:hover {
  background: #d86e08;
  box-shadow: 0 6px 18px rgba(240, 126, 16, 0.45);
}
.ui-btn.destructive { background: hsl(0 72% 51%); }
.ui-btn.destructive:hover { background: hsl(0 72% 45%); }
.ui-btn.outline {
  border: 1px solid hsl(214 32% 91%);
  background: #fff;
  color: hsl(222 47% 11%);
  box-shadow: none;
}
.ui-btn.outline:hover { background: hsl(210 40% 96%); }
.ui-btn.secondary { background: hsl(210 40% 96%); color: hsl(217 53% 14%); box-shadow: none; }
.ui-btn.secondary:hover { background: hsl(210 40% 92%); }
.ui-btn.ghost { background: transparent; color: hsl(222 47% 11%); box-shadow: none; }
.ui-btn.ghost:hover { background: hsl(210 40% 96%); }
.ui-btn.link { background: transparent; color: #f07e10; box-shadow: none; height: auto; padding: 0; }
.ui-btn.link:hover { text-decoration: underline; text-underline-offset: 4px; }
.ui-btn.sm { height: 36px; padding: 0 12px; font-size: 12px; }
.ui-btn.lg { height: 48px; padding: 0 32px; font-size: 16px; }
.ui-btn.icononly { width: 40px; padding: 0; }
.ui-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  border: 1px solid transparent;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 600;
}
.ui-badge.default { background: #0f1e37; color: #fff; }
.ui-badge.secondary { background: hsl(210 40% 96%); color: hsl(217 53% 14%); }
.ui-badge.accent { background: rgba(240, 126, 16, 0.1); color: #d86e08; }
.ui-badge.success { background: #d1fae5; color: #047857; }
.ui-badge.warning { background: #fef3c7; color: #92400e; }
.ui-badge.destructive { background: #ffe4e6; color: #be123c; }
.ui-badge.outline { border-color: hsl(214 32% 91%); color: hsl(222 47% 11%); background: transparent; }
.ui-card {
  border-radius: 12px;
  border: 1px solid hsl(214 32% 91%);
  background: #fff;
  color: hsl(222 47% 11%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.border-beam {
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: calc(var(--border-width, 1.5) * 1px) solid transparent;
  mask: linear-gradient(transparent, transparent), linear-gradient(white, white);
  mask-clip: padding-box, border-box;
  mask-composite: intersect;
}
.border-beam::after {
  content: "";
  position: absolute;
  aspect-ratio: 1;
  width: calc(var(--size, 200) * 1px);
  background: linear-gradient(to left, var(--color-from, #f07e10), var(--color-to, #1a3a5c), transparent);
  offset-anchor: calc(var(--anchor, 90) * 1%) 50%;
  offset-path: rect(0 auto auto 0 round calc(var(--size, 200) * 1px));
  animation: border-beam calc(var(--duration, 15) * 1s) infinite linear;
}
@keyframes border-beam {
  100% { offset-distance: 100%; }
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes fade-in {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes lv3-card-in {
  0% { opacity: 0; transform: scale(0.95); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes lv3-rise {
  0% { opacity: 0; transform: translateY(-20px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes lv3-rise-up {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes lv3-shine {
  0% { left: -30%; }
  100% { left: 110%; }
}
.lv3-card { animation: lv3-card-in 0.5s ease-out both; }
.lv3-rise { animation: lv3-rise 0.5s ease-out both; }
.lv3-rise-up { animation: lv3-rise-up 0.5s ease-out both; }
.lv3-btn {
  position: relative;
  overflow: hidden;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-sans);
  color: #fff;
  background: linear-gradient(to right, #f07e10, #d86e08);
  transition: all 0.3s;
}
.lv3-btn:hover {
  background: linear-gradient(to right, #e07408, #c96800);
  box-shadow: 0 10px 25px rgba(240, 126, 16, 0.35);
  transform: scale(1.01);
}
.lv3-btn:active { transform: scale(0.98); }
.lv3-btn::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -30%;
  width: 80px;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3), transparent);
  filter: blur(8px);
  opacity: 0;
}
.lv3-btn:hover::after {
  opacity: 1;
  animation: lv3-shine 1s ease-in-out infinite;
}
.lv3-input {
  display: flex;
  height: 44px;
  width: 100%;
  border-radius: calc(10px - 2px);
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 8px 12px;
  font-size: 14px;
  font-family: var(--font-sans);
  color: #1f2937;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.lv3-input::placeholder { color: #9ca3af; }
.lv3-input:focus-visible {
  outline: none;
  border-color: #f07e10;
  box-shadow: 0 0 0 2px rgba(240, 126, 16, 0.2);
}
.lv3-title-gradient {
  background: linear-gradient(to right, #1a3a5c, #2a5a8a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ── Profilo di sola lettura: la UI operativa resta nascosta (il blocco vero è lato server) ── */
.role-viewer .admin-only,
.role-viewer .row-actions,
.role-viewer .th-actions,
.role-viewer .td-actions,
.role-viewer .c-check,
.role-viewer .td-check,
.role-viewer #c-all,
.role-viewer #c-bulkbar {
  display: none !important;
}
.viewer-note {
  margin: 18px 32px -6px;
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
  padding: 11px 16px;
  border-radius: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 13px;
  font-weight: 600;
}
.viewer-note svg {
  flex: 0 0 auto;
}
@media (max-width: 768px) {
  .viewer-note {
    margin: 16px 16px -4px;
  }
}
body:not(.role-viewer) .viewer-note {
  display: none;
}
.user-menu-role {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--blue);
}
.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.role-pill.admin {
  background: #e0e7ff;
  color: #3730a3;
}
.role-pill.viewer {
  background: #ecfdf5;
  color: #047857;
}
.role-pill.me {
  background: var(--gray-100, #f1f5f9);
  color: var(--gray-500);
}

/* ── Segno di account protetto da verifica in due passaggi ── */
.name-with-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.tfa-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ecfdf5;
  color: #047857;
  flex: 0 0 auto;
}
.tfa-mark svg {
  width: 14px;
  height: 14px;
}

/* ════ CAMPO CODICE OTP ════ */
.otp {
  display: flex;
  gap: clamp(4px, 1.6%, 8px);
  justify-content: center;
  width: 100%;
  max-width: 340px;
}
.otp-cell {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: 46px;
  height: 56px;
  transition: transform 0.18s cubic-bezier(0.23, 1, 0.32, 1);
}
.otp-cell.otp-gap {
  margin-left: clamp(6px, 3%, 14px);
}
.otp-cell.is-pop {
  transform: translateY(-2px);
}
.otp-box {
  width: 100%;
  height: 100%;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  background: #f8fafc;
  box-shadow: inset 0 1px 2px rgba(15, 30, 55, 0.07);
  text-align: center;
  font-size: 20px;
  color: transparent;
  caret-color: transparent;
  outline: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}
.otp-box::selection {
  background: transparent;
}
.otp-cell.has-char .otp-box {
  background: #fff;
  border-color: var(--gray-300, #cbd5e1);
  box-shadow: none;
}
.otp-cell.is-active .otp-box {
  background: #fff;
  border-color: var(--brand-orange, #F07E10);
  box-shadow: 0 0 0 3px rgba(240, 126, 16, 0.18);
}
.otp-box:disabled {
  opacity: 0.6;
}
.otp-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}
.otp-char {
  grid-area: 1 / 1;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 21px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--blue-dark, #0F1E37);
  animation: otp-char-in 0.24s cubic-bezier(0.23, 1, 0.32, 1) both;
}
.otp-char.is-leaving {
  animation: otp-char-out 0.16s cubic-bezier(0.23, 1, 0.32, 1) both;
}
@keyframes otp-char-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}
@keyframes otp-char-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateY(-6px) scale(0.98);
    filter: blur(3px);
  }
}
.otp-caret {
  grid-area: 1 / 1;
  width: 2px;
  height: 22px;
  border-radius: 1px;
  background: var(--blue-dark, #0F1E37);
  opacity: 0;
}
.otp-cell.is-active:not(.has-char) .otp-caret {
  animation: otp-blink 1.06s steps(1) infinite;
}
@keyframes otp-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
.otp.is-error .otp-box {
  border-color: var(--red, #dc2626);
  background: #fff;
  box-shadow: none;
}
.otp.is-error .otp-char {
  color: var(--red, #dc2626);
}
.otp.is-success .otp-box {
  border-color: #10b981;
  background: #fff;
  box-shadow: none;
}
.otp.is-success .otp-char {
  color: #047857;
}
.otp.is-busy {
  opacity: 0.65;
}
.otp.shake {
  animation: otp-shake 0.34s cubic-bezier(0.23, 1, 0.32, 1);
}
@keyframes otp-shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-3px); }
  100% { transform: translateX(0); }
}
.otp-alt {
  margin-top: 14px;
  text-align: center;
  font-size: 13px;
}
.otp-alt button {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--brand-orange-dark, #c2620a);
  cursor: pointer;
  text-decoration: underline;
}
@media (max-width: 420px) {
  .otp-cell {
    height: 50px;
  }
  .otp-char {
    font-size: 19px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .otp-cell {
    transition: none;
  }
  .otp-char,
  .otp-char.is-leaving {
    animation: none;
    opacity: 1;
  }
  .otp.shake {
    animation: none;
  }
  .otp-cell.is-active:not(.has-char) .otp-caret {
    animation: none;
    opacity: 1;
  }
}

/* ════ PUNTI DI CONSEGNA (lato cliente) ════ */
.dp-empty-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-600);
  background: var(--blue-ultra);
  border-radius: var(--r);
  padding: 10px 12px;
  margin: 0 0 12px;
}
.dp-add-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 11px 14px;
  border: 2px dashed var(--gray-300);
  border-radius: var(--r);
  background: transparent;
  color: var(--blue);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}
.dp-add-toggle:hover {
  border-color: var(--blue);
  background: var(--blue-ultra);
}
.dp-add-form {
  margin-top: 12px;
  padding: 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r);
  background: var(--gray-50);
}
.dp-add-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.dp-add-actions .btn-orange,
.dp-add-actions .btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.dp-manage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.dp-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--r);
  background: #fff;
}
.dp-item-icon {
  color: var(--orange-dark);
  flex-shrink: 0;
}
.dp-item-body {
  flex: 1;
  min-width: 0;
}
.dp-item-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
  font-size: 14px;
  color: var(--gray-900);
}
.dp-item-addr {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}
.dp-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.dp-item-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1.5px solid var(--blue-light);
  border-radius: 8px;
  background: transparent;
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.dp-item-btn:hover {
  background: var(--blue-ultra);
}
.dp-item-btn.danger {
  color: var(--red);
  border-color: #f0c4c4;
}
.dp-item-btn.danger:hover {
  background: var(--red-light);
}
.dp-item-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}
.dp-item-locked {
  display: inline-flex;
  padding: 7px;
  color: var(--gray-400);
}
@media (max-width: 600px) {
  .dp-item {
    flex-wrap: wrap;
  }
  .dp-item-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .dp-add-form .form-row {
    grid-template-columns: 1fr;
  }
}

/* ════ PREZZO APPLICATO (admin richieste) ════ */
.td-price-total {
  font-weight: 700;
  color: var(--orange);
  white-space: nowrap;
}
.td-price-unit {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--gray-500);
  white-space: nowrap;
}
.td-price-custom {
  color: var(--blue);
  font-weight: 700;
}
.td-price-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: #fff;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.2s;
}
.td-price-edit:hover {
  border-color: var(--blue);
  color: var(--blue);
  background: var(--blue-ultra);
}
.pr-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.pr-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: 8px;
}
.pr-stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
}
.pr-stat-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
}
.pr-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 10px;
  background: #0f1e37;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}
.pr-total strong {
  font-size: 20px;
  font-weight: 800;
  color: var(--orange);
}
#price-modal .btn-orange,
#price-modal .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}
@media (max-width: 480px) {
  .pr-grid {
    grid-template-columns: 1fr;
  }
}

/* ════ TABELLA RICHIESTE (admin) ════ */
.orders-table {
  table-layout: auto;
}
.orders-table thead th {
  padding: 12px 14px;
  white-space: nowrap;
}
.orders-table thead th:first-child,
.orders-table tbody td:first-child {
  padding-left: 22px;
}
.orders-table thead th:last-child,
.orders-table tbody td:last-child {
  padding-right: 22px;
}
.orders-table tbody td {
  padding: 14px;
  vertical-align: middle;
  line-height: 1.35;
}
.orders-table .td-main {
  font-weight: 600;
  color: var(--gray-900);
  font-size: 13.5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.orders-table .td-sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.orders-table .td-order {
  white-space: nowrap;
}
.td-order-code {
  font-weight: 800;
  color: var(--blue-dark);
  font-size: 14px;
  letter-spacing: 0.2px;
}
.orders-table .td-client {
  min-width: 160px;
  max-width: 240px;
}
.orders-table .td-product {
  min-width: 130px;
  max-width: 200px;
}
.orders-table .td-price {
  white-space: nowrap;
}
.orders-table .td-dp {
  max-width: 180px;
}
.td-dp-name {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  font-size: 12.5px;
  color: var(--gray-600);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.td-dp-name svg {
  flex-shrink: 0;
  color: var(--gray-400);
}
.status-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  border-radius: 20px;
  padding: 0;
  transition: box-shadow 0.15s;
}
.status-pill:focus-within {
  box-shadow: 0 0 0 3px rgba(26, 58, 173, 0.18);
}
.status-pill .status-select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  padding: 7px 28px 7px 13px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: inherit;
  cursor: pointer;
  outline: none;
  max-width: 170px;
}
.status-pill .status-select:disabled {
  cursor: wait;
  opacity: 0.6;
}
.status-pill .status-select option {
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  color: var(--gray-900);
  background: #fff;
}
.status-pill-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: 0.75;
}
.orders-table .td-actions {
  text-align: right;
  white-space: nowrap;
}
.btn-contact {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-contact:hover {
  background: var(--blue-mid);
}
@media (max-width: 1400px) {
  .orders-table .col-dp { display: none; }
}
@media (max-width: 1250px) {
  .btn-contact .btn-label { display: none; }
  .btn-contact { padding: 9px 10px; }
}
@media (max-width: 1100px) {
  .orders-table .td-client { max-width: 180px; }
  .orders-table thead th,
  .orders-table tbody td { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 860px) {
  .orders-table thead { display: none; }
  .orders-table,
  .orders-table tbody,
  .orders-table tr,
  .orders-table td { display: block; }
  .orders-table tr#o-empty td { padding: 0; }
  .orders-table tr.order-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--gray-100);
  }
  .orders-table tr.order-row:last-child { border-bottom: none; }
  .orders-table tbody td {
    padding: 0 !important;
    border: none;
    max-width: none !important;
    min-width: 0 !important;
  }
  .orders-table tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    margin-bottom: 3px;
  }
  .orders-table tbody td[data-label=""]::before { display: none; }
  .orders-table .td-order { grid-column: 1; grid-row: 1; }
  .orders-table .td-status { grid-column: 2; grid-row: 1; justify-self: end; text-align: right; }
  .orders-table .td-status[data-label]::before { display: none; }
  .orders-table .td-client { grid-column: 1 / -1; grid-row: 2; }
  .orders-table .td-product { grid-column: 1; grid-row: 3; }
  .orders-table .td-price { grid-column: 2; grid-row: 3; }
  .orders-table .col-dp { display: block; grid-column: 1 / -1; grid-row: 4; }
  .orders-table .td-actions { grid-column: 1 / -1; grid-row: 5; text-align: left; width: auto !important; margin-top: 4px; }
  .orders-table .td-actions-empty { display: none; }
  .btn-contact { width: 100%; justify-content: center; padding: 11px 14px; }
  .btn-contact .btn-label { display: inline; }
  .orders-table .td-main { white-space: normal; }
}

/* ════ INVITO VIA EMAIL (creazione account) ════ */
.invite-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  background: var(--gray-50);
  margin-bottom: 20px;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-900);
  transition: opacity 0.2s;
}
.invite-check input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
  flex-shrink: 0;
}
.invite-check-sub {
  font-size: 12px;
  color: var(--gray-500);
}
.invite-check.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.invite-result {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}
.invite-result svg {
  flex-shrink: 0;
  margin-top: 2px;
}
.invite-result.ok {
  background: var(--green-light);
  border: 1px solid #a7f3d0;
  color: #065f46;
}
.invite-result.ko {
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
}
