/* ============================================================
   IPIS WMS — Design System v1.0
   Conforme a .claude/BRAND_BOOK.md
   ============================================================ */

/* ── Design Tokens ── */
:root {
  /* Colori brand IPIS */
  --ipis-navy: #1A2B4A;
  --ipis-navy-light: #243660;
  --ipis-blue: #2E6DA4;
  --ipis-blue-mid: #3D80BF;
  --ipis-blue-light: #5A9FD4;
  --ipis-teal: #1D8C72;
  --ipis-teal-light: #2BAA8A;
  --ipis-accent: #E8A020;
  --ipis-accent-light: #F5BC4A;
  --ipis-alert: #C0392B;

  /* Superfici */
  --ipis-bg: #F7F8FA;
  --ipis-surface: #FFFFFF;
  --ipis-border: #E2E6EF;

  /* Testo */
  --ipis-text: #1A2B4A;
  --ipis-text-secondary: #4A5568;
  --ipis-text-muted: #8A9BB0;

  /* Tipografia */
  --font-main: 'DM Sans', sans-serif;
  --font-display: 'DM Serif Display', serif;
  --font-mono: 'Courier New', Courier, monospace;

  /* Spaziatura (base 4px) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
  --sp-8: 64px;

  /* Border radius */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  /* Layout strutturale */
  --sidebar-w: 240px;
  --sidebar-w-mini: 60px;
  --topbar-h: 48px;

  /* Ombre */
  --shadow-card: 0 1px 3px rgba(26, 43, 74, .06), 0 1px 2px rgba(26, 43, 74, .04);
  --shadow-modal: 0 8px 24px rgba(26, 43, 74, .12);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ipis-text);
  background: var(--ipis-bg);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--ipis-blue);
  text-decoration: none;
}

a:hover {
  color: var(--ipis-blue-mid);
}

ul,
ol {
  list-style: none;
}

h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--ipis-navy);
}

h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--ipis-navy);
}

h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ipis-navy);
}

p,
td {
  font-size: 14px;
  font-weight: 400;
  color: var(--ipis-text-secondary);
  line-height: 1.7;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ipis-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

small {
  font-size: 12px;
  font-weight: 400;
  color: var(--ipis-text-muted);
}

code {
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--ipis-blue);
  background: #EEF1F8;
  padding: 2px 7px;
  border-radius: 4px;
}

/* ============================================================
   LAYOUT STRUTTURALE
   ============================================================ */

.wms-body {
  display: flex;
  min-height: 100vh;
  font-family: var(--font-main);
  background: var(--ipis-bg);
  color: var(--ipis-text);
  font-size: 14px;
  line-height: 1.6;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--ipis-navy);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.sidebar.mini {
  width: var(--sidebar-w-mini);
}

/* ── Logo ── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 64px;
  flex-shrink: 0;
  overflow: hidden;
}

.logo-mark {
  width: 36px;
  height: 36px;
  min-width: 36px;
  background: var(--ipis-blue);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 20px;
  flex-shrink: 0;
}

/* Logo immagine via background-image (pattern <i> inline) */
.sidebar-logo>i {
  flex-shrink: 0;
  border-radius: 8px;
}

.app-name {
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.2s, width 0.28s;
  color: #fff;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.25;
}

.app-name strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  letter-spacing: 0.04em;
}

.app-name span {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 400;
}

/* ── Nav ── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}

.sidebar-nav::-webkit-scrollbar {
  width: 3px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.32);
  padding: 14px 16px 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity 0.2s;
}

.nav-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.07);
  margin: 5px 0;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 9px 13px;
  color: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
  border-left: 3px solid transparent;
  white-space: nowrap;
  position: relative;
  user-select: none;
}

.nav-link:hover {
  background: var(--ipis-navy-light);
  color: #fff;
}

.nav-link.active {
  background: rgba(90, 159, 212, 0.12);
  color: #fff;
  border-left-color: var(--ipis-blue-light);
}

.nav-link i.ti {
  font-size: 18px;
  width: 20px;
  flex-shrink: 0;
  text-align: center;
}

.nav-label {
  overflow: hidden;
  white-space: nowrap;
  flex: 1;
  transition: opacity 0.2s;
}

.nav-chevron {
  font-size: 13px;
  margin-left: auto;
  flex-shrink: 0;
  transition: transform 0.22s;
  color: rgba(255, 255, 255, 0.4);
}

.nav-link.open>.nav-chevron {
  transform: rotate(90deg);
}

/* Submenu */
.nav-submenu {
  display: none;
  background: rgba(0, 0, 0, 0.14);
}

.nav-submenu.open {
  display: block;
}

.nav-submenu .nav-link {
  padding: 7px 16px 7px 49px;
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.58);
  border-left: 3px solid transparent;
}

.nav-submenu .nav-link:hover {
  color: #fff;
  background: var(--ipis-navy-light);
}

.nav-submenu .nav-link.active {
  color: #fff;
  border-left-color: var(--ipis-blue-light);
  background: rgba(90, 159, 212, 0.10);
}

/* Sidebar footer (Backoffice + Logout) */
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding: 6px 0;
}

/* ── Mini sidebar ──
   Layout invariato: nessun cambio di padding/justify/gap.
   La sidebar riduce solo la width; overflow:hidden taglia il contenuto.
   Le etichette spariscono con opacity, le icone restano ferme. */
.sidebar.mini .app-name,
.sidebar.mini .nav-label,
.sidebar.mini .nav-chevron,
.sidebar.mini .nav-section-label {
  opacity: 0;
  pointer-events: none;
}

.sidebar.mini .nav-submenu {
  display: none !important;
}

/* Tooltip label al mouseover della singola voce */
.sidebar.mini .nav-item:hover>.nav-link::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-w-mini) + 6px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--ipis-navy-light);
  color: #fff;
  padding: 5px 12px;
  border-radius: var(--r-md);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 200;
  pointer-events: none;
  box-shadow: var(--shadow-modal);
}

/* Sidebar espansa via JS (classe .mini rimossa): z-index elevato per overlay sul content */
.sidebar:not(.mini) {
  z-index: 300;
}

/* ── Main wrapper ── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.main-wrapper.mini {
  margin-left: var(--sidebar-w-mini);
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--ipis-surface);
  border-bottom: 1px solid var(--ipis-border);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  flex-shrink: 0;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.breadcrumb a {
  color: var(--ipis-text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--ipis-blue);
}

.breadcrumb-sep {
  color: var(--ipis-border);
}

.breadcrumb-current {
  font-weight: 600;
  color: var(--ipis-text);
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--ipis-blue);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Content ── */
.content {
  flex: 1;
  padding: var(--sp-5) var(--sp-6);
  overflow-y: auto;
}

/* ============================================================
   PAGE HEADER
   ============================================================ */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
  gap: var(--sp-4);
}

.page-eyebrow {
  font-size: 11px;
  color: var(--ipis-text-muted);
  margin-bottom: 4px;
  font-weight: 500;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--ipis-navy);
  line-height: 1.15;
}

.page-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-shrink: 0;
}

/* ============================================================
   PULSANTI
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 18px;
  height: 36px;
  border-radius: var(--r-sm);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn i {
  font-size: 15px;
}

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

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

.btn-secondary {
  background: transparent;
  color: var(--ipis-blue);
  border-color: var(--ipis-blue);
}

.btn-secondary:hover {
  background: rgba(46, 109, 164, 0.07);
  color: var(--ipis-blue);
}

.btn-success {
  background: var(--ipis-teal);
  color: #fff;
  border-color: var(--ipis-teal);
}

.btn-success:hover {
  background: var(--ipis-teal-light);
  border-color: var(--ipis-teal-light);
  color: #fff;
}

.btn-danger {
  background: var(--ipis-alert);
  color: #fff;
  border-color: var(--ipis-alert);
}

.btn-danger:hover {
  background: #a93226;
  border-color: #a93226;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--ipis-text-secondary);
  border-color: var(--ipis-border);
}

.btn-ghost:hover {
  background: var(--ipis-bg);
}

.btn-sm {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

.btn-lg {
  height: 42px;
  padding: 0 24px;
  font-size: 14px;
}

/* ============================================================
   BADGE DI STATO
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.badge i {
  font-size: 11px;
}

.badge-green {
  background: #E0F4EE;
  color: #145E4A;
}

.badge-amber {
  background: #FEF3DC;
  color: #7A5010;
}

.badge-red {
  background: #FDECEA;
  color: #7A1E15;
}

.badge-blue {
  background: #E3EEF8;
  color: #1B4F7A;
}

.badge-gray {
  background: #EAECF0;
  color: #4A5568;
}

/* ============================================================
   CARD
   ============================================================ */

.card {
  background: var(--ipis-surface);
  border: 1px solid var(--ipis-border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ipis-text-muted);
  margin-bottom: 16px;
}

.card.card-accent {
  border-top: 3px solid var(--ipis-blue);
}

.card.card-green {
  border-top: 3px solid var(--ipis-teal);
}

.card.card-amber {
  border-top: 3px solid var(--ipis-accent);
}

.card.card-red {
  border-top: 3px solid var(--ipis-alert);
}

/* ============================================================
   STAT CARDS — DASHBOARD
   ============================================================ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ipis-text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--ipis-navy);
  line-height: 1;
}

.stat-sub {
  font-size: 11px;
  color: var(--ipis-text-muted);
  margin-top: 5px;
}

/* ============================================================
   TABELLE
   ============================================================ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--r-lg);
  border: 1px solid var(--ipis-border);
  background: var(--ipis-surface);
}

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

.wms-table thead th {
  background: var(--ipis-bg);
  color: var(--ipis-text-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--ipis-border);
  white-space: nowrap;
}

.wms-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--ipis-border);
  color: var(--ipis-text);
  vertical-align: middle;
}

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

.wms-table tbody tr:hover td {
  background: #F4F7FB;
}

.wms-table .col-code code {
  background: #EEF1F8;
  color: var(--ipis-blue);
  padding: 2px 7px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.wms-table .qty-ok {
  font-weight: 600;
  color: var(--ipis-teal);
}

.wms-table .qty-low {
  font-weight: 600;
  color: var(--ipis-accent);
}

.wms-table .qty-zero {
  font-weight: 600;
  color: var(--ipis-alert);
}

.wms-table .col-actions {
  text-align: right;
  white-space: nowrap;
}

/* ============================================================
   FORM
   ============================================================ */

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--ipis-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1.5px solid var(--ipis-border);
  border-radius: var(--r-sm);
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--ipis-text);
  background: var(--ipis-surface);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--ipis-blue);
  box-shadow: 0 0 0 3px rgba(46, 109, 164, 0.12);
}

.form-input::placeholder {
  color: var(--ipis-text-muted);
}

.form-textarea {
  height: auto;
  min-height: 90px;
  padding: 10px 12px;
  resize: vertical;
}

.form-helper {
  font-size: 12px;
  color: var(--ipis-text-muted);
  margin-top: 5px;
}

.form-error {
  font-size: 12px;
  color: var(--ipis-alert);
  margin-top: 5px;
}

.form-input.is-invalid,
.form-select.is-invalid {
  border-color: var(--ipis-alert);
}

/* Form row/grid */
.form-row {
  display: grid;
  gap: 16px;
}

.form-row.cols-2 {
  grid-template-columns: 1fr 1fr;
}

.form-row.cols-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-row.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* ============================================================
   ALERT
   ============================================================ */

.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 13px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 12px;
  border-left: 4px solid;
}

.alert i {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert strong {
  display: block;
  margin-bottom: 2px;
  font-weight: 600;
}

.alert-success {
  background: #E6F7F2;
  border-color: var(--ipis-teal);
  color: #145E4A;
}

.alert-warning {
  background: #FEF6E6;
  border-color: var(--ipis-accent);
  color: #7A5010;
}

.alert-danger {
  background: #FDECEA;
  border-color: var(--ipis-alert);
  color: #7A1E15;
}

.alert-info {
  background: #EBF4FB;
  border-color: var(--ipis-blue);
  color: #1B4F7A;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 20px;
  color: var(--ipis-text-muted);
}

.empty-state i {
  font-size: 52px;
  margin-bottom: 16px;
  color: var(--ipis-border);
}

.empty-state h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--ipis-navy);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 13px;
  max-width: 340px;
  margin-bottom: 20px;
  line-height: 1.6;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--ipis-surface);
  border-radius: var(--r-md);
  border-left: 4px solid var(--ipis-blue);
  box-shadow: var(--shadow-modal);
  font-size: 13px;
  min-width: 280px;
  max-width: 380px;
  pointer-events: auto;
  animation: toastIn 0.25s ease;
}

.toast.toast-success {
  border-left-color: var(--ipis-teal);
}

.toast.toast-warning {
  border-left-color: var(--ipis-accent);
}

.toast.toast-danger {
  border-left-color: var(--ipis-alert);
}

.toast i {
  font-size: 16px;
  margin-top: 1px;
  flex-shrink: 0;
}

.toast-success i {
  color: var(--ipis-teal);
}

.toast-warning i {
  color: var(--ipis-accent);
}

.toast-danger i {
  color: var(--ipis-alert);
}

.toast-info i {
  color: var(--ipis-blue);
}

.toast-body {
  flex: 1;
}

.toast-title {
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--ipis-text);
}

.toast-msg {
  color: var(--ipis-text-secondary);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ============================================================
   MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26, 43, 74, 0.45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--ipis-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.22s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--ipis-border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--ipis-navy);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ipis-text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 2px;
  border-radius: var(--r-sm);
  transition: color 0.15s;
}

.modal-close:hover {
  color: var(--ipis-alert);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--ipis-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ipis-bg);
  padding: 24px;
}

.login-card {
  background: var(--ipis-surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-modal);
  padding: 40px 44px;
  width: 100%;
  max-width: 400px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo .logo-mark {
  width: 44px;
  height: 44px;
  font-size: 24px;
}

.login-logo .app-name strong {
  font-size: 16px;
  color: var(--ipis-navy);
}

.login-logo .app-name span {
  font-size: 12px;
  color: var(--ipis-text-muted);
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--ipis-navy);
  margin-bottom: 6px;
}

.login-sub {
  font-size: 13px;
  color: var(--ipis-text-muted);
  margin-bottom: 28px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 500px) {
  .sidebar {
    width: var(--sidebar-w-mini);
  }

  .sidebar .app-name,
  .sidebar .nav-label,
  .sidebar .nav-chevron,
  .sidebar .nav-section-label {
    opacity: 0;
    pointer-events: none;
  }

  .sidebar .nav-submenu {
    display: none !important;
  }

  .main-wrapper {
    margin-left: var(--sidebar-w-mini);
  }
}

@media (max-width: 768px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .content {
    padding: var(--sp-4);
  }

  .topbar {
    padding: 0 var(--sp-4);
  }

  .page-header {
    flex-direction: column;
  }

  .form-row.cols-2,
  .form-row.cols-3,
  .form-row.cols-4 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 28px 20px;
  }
}

/* ============================================================
   BACKOFFICE — Widget (bo-* classes)
   ============================================================ */

.bo-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  margin-bottom: 20px;
  font-size: 13.5px;
  line-height: 1.5;
}

.bo-alert i {
  flex-shrink: 0;
  font-size: 16px;
  margin-top: 1px;
}

.bo-alert--info {
  background: #EBF4FB;
  border: 1px solid #93C5E8;
  color: #1B4F7A;
}

.bo-alert--successo {
  background: #E6F7F2;
  border: 1px solid #6FCFB8;
  color: #145E4A;
}

.bo-alert--errore {
  background: #FDECEA;
  border: 1px solid #EFA8A3;
  color: #7A1E15;
}

.bo-alert--avviso {
  background: #FEF6E6;
  border: 1px solid #F5C26A;
  color: #7A5010;
}

.bo-card {
  background: var(--ipis-surface);
  border: 1px solid var(--ipis-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}

.bo-card--no-mb {
  margin-bottom: 0;
}

.bo-card__intestazione {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--ipis-border);
}

.bo-card__icona {
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 17px;
}

.bo-card__icona--verde {
  background: #E6F7F2;
  color: var(--ipis-teal);
}

.bo-card__icona--ambra {
  background: #FEF6E6;
  color: var(--ipis-accent);
}

.bo-card__icona--brand {
  background: #EBF4FB;
  color: var(--ipis-blue);
}

.bo-card__icona--errore {
  background: #FDECEA;
  color: var(--ipis-alert);
}

.bo-card__icona--blu {
  background: #EBF4FB;
  color: var(--ipis-blue);
}

.bo-card__titolo {
  font-size: 14px;
  font-weight: 600;
  color: var(--ipis-text);
}

.bo-card__sottotitolo {
  font-size: 11.5px;
  color: var(--ipis-text-muted);
  margin-top: 2px;
}

.bo-card__corpo {
  padding: 20px;
}

.bo-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
}

.bo-badge--attivo {
  background: #E6F7F2;
  color: #145E4A;
}

.bo-badge--modifica {
  background: #FEF6E6;
  color: #7A5010;
}

.bo-badge--rimosso {
  background: #FDECEA;
  color: #7A1E15;
}

.bo-badge--muted {
  background: var(--ipis-bg);
  color: var(--ipis-text-muted);
}

.bo-tabella {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.bo-tabella thead th {
  background: var(--ipis-bg);
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ipis-text-muted);
  border-bottom: 1px solid var(--ipis-border);
  white-space: nowrap;
}

.bo-tabella tbody td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--ipis-border);
  vertical-align: middle;
}

.bo-tabella tbody tr:last-child td {
  border-bottom: none;
}

.bo-tabella tbody tr:hover td {
  background: #F4F7FB;
}

.bo-tabella tbody tr.row-attivo td {
  background: rgba(34, 139, 87, 0.06);
}

.bo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.bo-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bo-btn--primario {
  background: var(--ipis-blue);
  color: #fff;
  border-color: var(--ipis-blue);
}

.bo-btn--primario:hover:not(:disabled) {
  background: var(--ipis-blue-mid);
  border-color: var(--ipis-blue-mid);
}

.bo-btn--ghost {
  background: transparent;
  color: var(--ipis-text-secondary);
  border-color: var(--ipis-border);
}

.bo-btn--ghost:hover:not(:disabled) {
  border-color: var(--ipis-blue);
  color: var(--ipis-blue);
}

.bo-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.bo-stat-card {
  background: var(--ipis-surface);
  border: 1px solid var(--ipis-border);
  border-radius: var(--r-lg);
  padding: 20px 16px;
  text-align: center;
  box-shadow: var(--shadow-card);
}

.bo-stat-card__numero {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 5px;
  color: var(--ipis-navy);
}

.bo-stat-card__etichetta {
  font-size: 11.5px;
  color: var(--ipis-text-muted);
}

.text-center {
  text-align: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  .bo-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ============================================================
   UTILITÀ
   ============================================================ */

.text-muted {
  color: var(--ipis-text-muted) !important;
}

.text-success {
  color: var(--ipis-teal) !important;
}

.text-warning {
  color: var(--ipis-accent) !important;
}

.text-danger {
  color: var(--ipis-alert) !important;
}

.text-blue {
  color: var(--ipis-blue) !important;
}

.fw-600 {
  font-weight: 600;
}

.fw-700 {
  font-weight: 700;
}

/* ── Tabs backoffice Defaults ── */
.bo-tab-btn {
  padding: 10px 22px;
  border: none;
  border-bottom: 3px solid transparent;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--ipis-text-muted);
  font-family: var(--font-main);
  transition: color .15s, border-color .15s;
  white-space: nowrap;
  outline: none;
}
.bo-tab-btn:hover {
  color: var(--ipis-navy);
}
.bo-tab-btn.active {
  color: var(--ipis-navy);
  border-bottom-color: var(--ipis-navy);
}

.mt-1 {
  margin-top: var(--sp-1);
}

.mt-2 {
  margin-top: var(--sp-2);
}

.mt-3 {
  margin-top: var(--sp-3);
}

.mt-4 {
  margin-top: var(--sp-4);
}

.mt-5 {
  margin-top: var(--sp-5);
}

.mb-1 {
  margin-bottom: var(--sp-1);
}

.mb-2 {
  margin-bottom: var(--sp-2);
}

.mb-3 {
  margin-bottom: var(--sp-3);
}

.mb-4 {
  margin-bottom: var(--sp-4);
}

.mb-5 {
  margin-bottom: var(--sp-5);
}

.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 {
  gap: var(--sp-2);
}

.gap-3 {
  gap: var(--sp-3);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}