/* custom.css — Material Design 3 */

/* ═══════════════════════════════════════════════════════════
   Tipografia — font ospitati in proprio, non da Google
   ═══════════════════════════════════════════════════════════

   Caricando i font da fonts.googleapis.com, il browser di chi apre bi2 manda il
   proprio indirizzo IP a Google prima ancora del login. Ospitarli toglie il
   problema alla radice invece di doverlo dichiarare da qualche parte.

   I file arrivano da Google Fonts (SIL Open Font License) e stanno in
   `files/fonts/`, serviti da `/fonts/<file>` (route pubblica in app.py, CORS
   aperto perché questo CSS è letto anche dalle altre app).

   Albert Sans è un font VARIABILE: un file solo copre tutti i pesi da 400 a 700,
   ed è il motivo per cui qui c'è `font-weight: 400 700` e non quattro blocchi
   identici. Il peso 300 che l'URL di Google chiedeva non è mai usato in bi2.  */

@font-face {
  font-family: 'Albert Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/albert-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Albert Sans';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/albert-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ═══════════════════════════════════════════════════════════
   MD3 Design Tokens — seed #769CDF
   ═══════════════════════════════════════════════════════════ */

:root {
  /* Tipografia — unico posto dove il nome del font compare.
     Chi scrive stile usa var(--font-sans), mai il letterale. */
  --font-sans: 'Albert Sans', system-ui, sans-serif;
  --brand-logo: #F60000;     /* colore del logo (pagina di login) */

  /* Primary */
  --md-primary:              #415F91;
  --md-on-primary:           #FFFFFF;
  --md-primary-container:    #D6E3FF;
  --md-on-primary-container: #001B3E;

  /* Secondary */
  --md-secondary:              #565F71;
  --md-on-secondary:           #FFFFFF;
  --md-secondary-container:    #DAE2F9;
  --md-on-secondary-container: #131C2B;

  /* Tertiary */
  --md-tertiary:              #705575;
  --md-on-tertiary:           #FFFFFF;
  --md-tertiary-container:    #FAD8FD;
  --md-on-tertiary-container: #28132E;

  /* Error */
  --md-error:              #BA1A1A;
  --md-on-error:           #FFFFFF;
  --md-error-container:    #FFDAD6;
  --md-on-error-container: #93000A;

  /* Surfaces */
  --md-background:                #FFFFFF;
  --md-on-background:             #191C20;
  --md-surface:                   #F9F9FF;
  --md-on-surface:                #191C20;
  --md-surface-variant:           #E0E2EC;
  --md-on-surface-variant:        #44474E;
  --md-surface-container-lowest:  #FFFFFF;
  --md-surface-container-low:     #F3F3FA;
  --md-surface-container:         #EDEDF4;
  --md-surface-container-high:    #E7E8EE;
  --md-surface-container-highest: #E2E2E9;
  --md-inverse-surface:           #2E3036;
  --md-inverse-on-surface:        #F0F0F7;
  --md-inverse-primary:           #AAC7FF;

  /* Outline */
  --md-outline:         #74777F;
  --md-outline-variant: #C4C6D0;

  /* State layers */
  --md-state-hover:   rgba(65,95,145,.08);
  --md-state-pressed: rgba(65,95,145,.12);
  --md-state-hover-on-dark: rgba(255,255,255,.08);

  /* Shape */
  --md-shape-xs:   4px;
  --md-shape-sm:   8px;
  --md-shape-md:   12px;
  --md-shape-lg:   16px;
  --md-shape-xl:   28px;
  --md-shape-full: 50px;

  /* Elevation */
  --md-elev-1: 0 1px 2px rgba(0,0,0,.10), 0 1px 3px 1px rgba(0,0,0,.05);
  --md-elev-2: 0 1px 2px rgba(0,0,0,.10), 0 2px 6px 2px rgba(0,0,0,.05);
  --md-elev-3: 0 1px 3px rgba(0,0,0,.10), 0 4px 8px 3px rgba(0,0,0,.05);

  /* Navigation drawer */
  --nav-bg:           #13131F;
  --nav-active-bg:    rgba(170,199,255,.14);
  --nav-active-color: #AAC7FF;
  --nav-color:        rgba(255,255,255,.65);
  --nav-hover-bg:     rgba(255,255,255,.07);
  --nav-divider:      rgba(255,255,255,.08);
  --sidebar-w:        64px;
  --panel-w:          220px;
  --topbar-h:         56px;
  --bottom-nav-h:     56px;

  /* Bootstrap CSS vars → MD3 */
  --bs-body-font-family:          var(--font-sans);
  --bs-body-font-size:            .875rem;
  --bs-body-color:                var(--md-on-surface);
  --bs-body-bg:                   var(--md-background);
  --bs-border-radius:             var(--md-shape-md);
  --bs-border-radius-sm:          var(--md-shape-sm);
  --bs-border-radius-lg:          var(--md-shape-lg);
  --bs-border-radius-xl:          var(--md-shape-xl);
  --bs-border-radius-pill:        var(--md-shape-full);
  --bs-border-color:              var(--md-outline-variant);
  --bs-border-color-translucent:  rgba(116,119,127,.12);
  --bs-card-border-width:         0;
  --bs-card-border-color:         transparent;
  --bs-card-border-radius:        var(--md-shape-md);
  --bs-card-bg:                   var(--md-surface-container-low);
  --bs-card-box-shadow:           none;
  --bs-btn-border-radius:         var(--md-shape-full);
  --bs-badge-border-radius:       var(--md-shape-full);
  --bs-input-border-color:        var(--md-outline);
  --bs-input-focus-border-color:  var(--md-primary);
  --bs-input-bg:                  var(--md-surface-container-lowest);
  --bs-input-color:               var(--md-on-surface);
  --bs-form-select-bg:            var(--md-surface-container-lowest);
  --bs-table-border-color:        var(--md-surface-container-high);
  --bs-table-hover-bg:            var(--md-state-hover);
  --bs-nav-tabs-border-color:     transparent;
  --bs-nav-tabs-border-width:     0;
  --bs-nav-tabs-link-active-bg:   transparent;
  --bs-nav-tabs-link-active-border-color: transparent;
  --bs-link-color:                var(--md-primary);
  --bs-link-hover-color:          var(--md-primary);
  --bs-alert-border-radius:       var(--md-shape-md);
  --bs-modal-border-radius:       var(--md-shape-lg);
  --bs-modal-content-border-width: 0;
  --bs-modal-content-bg:          var(--md-surface-container-low);
}

/* ═══════════════════════════════════════════════════════════
   Base
   ═══════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--md-background);
  color: var(--md-on-surface);
  font-family: var(--font-sans);
  font-size: .875rem;
  line-height: 1.5;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--md-primary); }

/* ═══════════════════════════════════════════════════════════
   MD3 Navigation Drawer (Sidebar)
   ═══════════════════════════════════════════════════════════ */

.sidebar {
  font-family: var(--font-sans);
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--nav-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform .3s cubic-bezier(.2,0,0,1),
              width   .3s cubic-bezier(.2,0,0,1);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 0;
  color: #fff;
  border-bottom: 1px solid var(--nav-divider);
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  white-space: nowrap;
  min-height: 64px;
  gap: 0;
}

.sidebar-brand > span:not(svg):not([class]) { display: none; }

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: .5rem .5rem;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar { display: none; }

/* Nav item — icon only when collapsed */
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: .65rem 0;
  color: var(--nav-color);
  font-size: 0;
  text-decoration: none;
  border-radius: var(--md-shape-full);
  border: none;
  background: transparent;
  transition: background .2s, color .2s;
  position: relative;
  margin: .1rem 0;
  gap: 0;
}

.sidebar-nav .nav-link:hover {
  color: #fff;
  background: var(--nav-hover-bg);
}

/* MD3 active indicator */
.sidebar-nav .nav-link.active {
  color: var(--nav-active-color);
  background: var(--nav-active-bg);
}

.sidebar-nav .nav-link .material-symbols-rounded {
  font-size: 1.2rem;
  flex-shrink: 0;
  line-height: 1;
}

/* Tooltip (collapsed mode) */
.sidebar-nav .nav-link[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--md-inverse-surface);
  color: var(--md-inverse-on-surface);
  font-size: .75rem;
  font-family: var(--font-sans);
  font-weight: 500;
  padding: .35rem .8rem;
  border-radius: var(--md-shape-sm);
  white-space: nowrap;
  z-index: 9999;
  box-shadow: var(--md-elev-2);
  pointer-events: none;
}

/* Footer */
.sidebar-footer {
  padding: .75rem .5rem;
  border-top: 1px solid var(--nav-divider);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
}

.sidebar-footer .btn,
.sidebar-footer > div {
  width: 40px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  border-radius: var(--md-shape-full);
  color: rgba(255,255,255,.7);
  flex-shrink: 0;
  overflow: hidden;
  min-width: 0;
}
.sidebar-footer .btn {
  border-color: rgba(255,255,255,.3);
}

.sidebar-footer .btn:hover { background: var(--nav-hover-bg); }
.sidebar-footer .btn .material-symbols-rounded,
.sidebar-footer > div .material-symbols-rounded { font-size: .9rem; margin: 0 !important; }
#last-update { display: none; }

.sb-txt { display: none; }

/* ── Expanded state (desktop) ── */

.sidebar.expanded { width: 240px; }
.sidebar.expanded ~ .main-wrapper { margin-left: 240px; }

.sidebar.expanded .sidebar-brand {
  justify-content: flex-start;
  padding: 1rem 1.25rem;
  gap: .75rem;
}

.sidebar.expanded .sidebar-brand > span:not(svg):not([class]) {
  display: inline;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .01em;
  color: #fff;
}

.sidebar.expanded .sidebar-nav { padding: .5rem .75rem; }

.sidebar.expanded .sidebar-nav .nav-link {
  justify-content: flex-start;
  padding: .65rem 1rem;
  font-size: .85rem;
  gap: .75rem;
  color: var(--nav-color);
}

.sidebar.expanded .sidebar-nav .nav-link.active {
  color: var(--nav-active-color);
}

.sidebar.expanded .sidebar-nav .nav-link .material-symbols-rounded {
  font-size: 1.1rem;
  width: 1.25rem;
}

.sidebar.expanded .sidebar-nav .nav-link[title]:hover::after { display: none; }

.sidebar.expanded .sidebar-footer {
  align-items: stretch;
  padding: .75rem 1rem;
}

.sidebar.expanded .sidebar-footer .btn,
.sidebar.expanded .sidebar-footer > div {
  width: 100%;
  height: auto;
  font-size: .8rem;
  justify-content: flex-start;
  padding: .4rem .9rem;
  gap: .6rem;
  overflow: visible;
}

.sidebar.expanded .sidebar-footer .btn .material-symbols-rounded,
.sidebar.expanded .sidebar-footer > div .material-symbols-rounded { font-size: .85rem; }
.sidebar.expanded #last-update { display: inline-block; }
.sidebar.expanded .sb-txt { display: inline; }

/* ── Nav groups accordion ── */

.nav-group-header {
  display: none;
  align-items: center;
  gap: .75rem;
  padding: .4rem 1rem .2rem;
  color: rgba(255,255,255,.38);
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  cursor: pointer;
  user-select: none;
  transition: color .15s;
  margin-top: .5rem;
}

.nav-group-header .material-symbols-rounded:first-child {
  font-size: .8rem;
  width: 1.25rem;
  text-align: center;
}

.nav-group-header:hover { color: rgba(255,255,255,.7); }
.sidebar.expanded .nav-group-header { display: flex; }

.nav-group-arrow { margin-left: auto; font-size: .7rem; transition: transform .2s; }
.nav-group.open .nav-group-arrow { transform: rotate(180deg); }
.nav-group-items { overflow: hidden; max-height: 0; transition: max-height .25s ease; }
.nav-group.open .nav-group-items { max-height: 500px; }
.sidebar:not(.expanded) .nav-group-items { max-height: none !important; overflow: visible; }

/* ═══════════════════════════════════════════════════════════
   Main layout
   ═══════════════════════════════════════════════════════════ */

.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left .3s cubic-bezier(.2,0,0,1);
}

/* ── MD3 Top App Bar (mobile) ── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  background: var(--nav-bg);
  color: #fff;
  height: var(--topbar-h);
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

.topbar .btn {
  color: rgba(255,255,255,.85);
  border: none;
  background: transparent !important;
  border-radius: var(--md-shape-full);
  width: 48px;
  height: 48px;
  min-height: unset;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0;
  transition: background .2s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.topbar .btn:hover { background: rgba(255,255,255,.1); }
.topbar .btn .material-symbols-rounded { font-size: 1.4rem; }
.topbar .fw-bold { font-size: .95rem; font-family: var(--font-sans); }

/* ═══════════════════════════════════════════════════════════
   Loading overlay
   ═══════════════════════════════════════════════════════════ */

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,13,31,.9);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ═══════════════════════════════════════════════════════════
   Page layout
   ═══════════════════════════════════════════════════════════ */

.page-content { padding: 1.5rem; }

.page-header { margin-bottom: 1.5rem; }

.page-header h4 {
  font-size: 1.375rem;
  font-weight: 400;
  color: var(--md-on-surface);
  letter-spacing: 0;
  margin: 0;
}

.page-header p {
  font-size: .875rem;
  color: var(--md-on-surface-variant);
  margin: .15rem 0 0;
}

/* ═══════════════════════════════════════════════════════════
   MD3 Cards (Filled)
   ═══════════════════════════════════════════════════════════ */

.card {
  background: var(--md-surface-container-low) !important;
  border: none !important;
  border-radius: var(--md-shape-md) !important;
  box-shadow: none !important;
  transition: box-shadow .2s;
}

.card:hover { box-shadow: var(--md-elev-1) !important; }

.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--md-surface-container-high) !important;
  border-radius: var(--md-shape-md) var(--md-shape-md) 0 0 !important;
  font-size: .875rem;
  font-weight: 500;
  padding: .8rem 1rem;
  color: var(--md-on-surface);
}

.card-body { color: var(--md-on-surface); }

/* ═══════════════════════════════════════════════════════════
   KPI Cards
   ═══════════════════════════════════════════════════════════ */

.kpi-card {
  background: var(--md-surface-container-low) !important;
  border: none !important;
  border-radius: var(--md-shape-md) !important;
  padding: 1rem 1.25rem;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  transition: box-shadow .2s;
}

.kpi-card:hover { box-shadow: var(--md-elev-1); }

.kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--md-shape-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* MD3 tonal icon containers */
.kpi-icon.bg-primary-subtle   { background: var(--md-primary-container)   !important; color: var(--md-on-primary-container)   !important; }
.kpi-icon.bg-secondary-subtle { background: var(--md-secondary-container) !important; color: var(--md-on-secondary-container) !important; }
.kpi-icon.bg-success-subtle   { background: #C4EED0 !important; color: #0A3818 !important; }
.kpi-icon.bg-warning-subtle   { background: #FDEFC3 !important; color: #5C3D00 !important; }
.kpi-icon.bg-danger-subtle    { background: var(--md-error-container)      !important; color: var(--md-on-error-container)      !important; }
.kpi-icon.bg-info-subtle      { background: #C2E8FF !important; color: #003549 !important; }

.kpi-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--md-on-surface);
  letter-spacing: -.01em;
}

.kpi-label {
  font-size: .7rem;
  color: var(--md-on-surface-variant);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 500;
}

/* Inline variant */
.kpi-inline {
  flex-direction: row;
  align-items: center;
  gap: .65rem;
  padding: .65rem 1rem;
}

.kpi-inline .kpi-value { font-size: 1.1rem; line-height: 1.2; }
.kpi-inline .kpi-label {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--md-on-surface);
  text-transform: none;
  letter-spacing: 0;
}

.kpi-inline > div:not(.kpi-icon) {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: .35rem;
  min-width: 0;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════
   MD3 Data Table
   ═══════════════════════════════════════════════════════════ */

.table {
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--md-surface-container-high);
  --bs-table-hover-bg: var(--md-state-hover);
  color: var(--md-on-surface);
  border-color: var(--md-surface-container-high);
}

.table th {
  font-size: .825rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--md-on-surface-variant);
  border-bottom: 1px solid var(--md-surface-container-high) !important;
  padding: .65rem .75rem;
  border-top: none;
}

.table td {
  font-size: .965rem;
  vertical-align: middle;
  border-color: var(--md-surface-container-high);
  padding: .55rem .75rem;
}

.table-dark {
  --bs-table-bg: var(--md-inverse-surface);
  --bs-table-color: var(--md-inverse-on-surface);
  --bs-table-border-color: rgba(255,255,255,.08);
}

.table-light {
  --bs-table-bg: var(--md-surface-container);
  --bs-table-color: var(--md-on-surface-variant);
  --bs-table-border-color: var(--md-surface-container-high);
}

/* ═══════════════════════════════════════════════════════════
   MD3 Buttons
   ═══════════════════════════════════════════════════════════ */

.btn {
  border-radius: var(--md-shape-full) !important;
  font-weight: 500;
  font-size: .875rem;
  letter-spacing: .006em;
  transition: box-shadow .2s, background .2s, border-color .2s;
  line-height: 1.4;
}

.btn:hover  { box-shadow: var(--md-elev-1); }
.btn:active { box-shadow: none; transform: none; }
.btn-sm { font-size: .8rem; }

/* Filled */
.btn-primary {
  background: var(--md-primary) !important;
  border-color: var(--md-primary) !important;
  color: var(--md-on-primary) !important;
}
.btn-primary:hover { background: color-mix(in srgb, var(--md-primary) 90%, #fff) !important; }

/* Tonal */
.btn-secondary {
  background: var(--md-secondary-container) !important;
  border-color: transparent !important;
  color: var(--md-on-secondary-container) !important;
}

/* Outlined */
.btn-outline-primary {
  border-color: var(--md-outline) !important;
  color: var(--md-primary) !important;
  background: transparent !important;
}
.btn-outline-primary:hover {
  background: var(--md-state-hover) !important;
  border-color: var(--md-primary) !important;
}

.btn-outline-secondary {
  border-color: var(--md-outline) !important;
  color: var(--md-on-surface-variant) !important;
  background: transparent !important;
}
.btn-outline-secondary:hover {
  background: var(--md-state-hover) !important;
  border-color: var(--md-outline) !important;
  color: var(--md-on-surface) !important;
}

.btn-outline-danger {
  border-color: var(--md-error) !important;
  color: var(--md-error) !important;
  background: transparent !important;
}
.btn-outline-danger:hover { background: rgba(186,26,26,.08) !important; }

.btn-outline-light {
  border-color: rgba(255,255,255,.35) !important;
  color: rgba(255,255,255,.85) !important;
  background: transparent !important;
}
.btn-outline-light:hover { background: rgba(255,255,255,.1) !important; }

.btn-outline-warning {
  border-color: #8B6A00 !important;
  color: #8B6A00 !important;
  background: transparent !important;
}
.btn-outline-warning:hover { background: rgba(139,106,0,.08) !important; }

.btn-dark {
  background: var(--md-inverse-surface) !important;
  border-color: transparent !important;
  color: var(--md-inverse-on-surface) !important;
}

/* ═══════════════════════════════════════════════════════════
   MD3 Chips (Badges)
   ═══════════════════════════════════════════════════════════ */

.badge {
  border-radius: var(--md-shape-full) !important;
  font-weight: 500;
  font-size: .7rem;
  letter-spacing: .01em;
  padding: .3em .7em;
}

.badge.bg-primary   { background: var(--md-primary-container)   !important; color: var(--md-on-primary-container)   !important; }
.badge.bg-secondary { background: var(--md-surface-container-highest) !important; color: var(--md-on-surface-variant) !important; }
.badge.bg-success   { background: #C4EED0 !important; color: #0A3818 !important; }
.badge.bg-warning   { background: #FDEFC3 !important; color: #5C3D00 !important; }
.badge.bg-warning.text-dark { color: #5C3D00 !important; }
.badge.bg-danger    { background: var(--md-error-container)   !important; color: var(--md-on-error-container)   !important; }
.badge.bg-info      { background: #C2E8FF !important; color: #003549 !important; }
.badge.bg-info.text-dark { color: #003549 !important; }
.badge.bg-dark      { background: var(--md-inverse-surface) !important; color: var(--md-inverse-on-surface) !important; }
.badge.text-bg-secondary { background: var(--md-surface-container-highest) !important; color: var(--md-on-surface-variant) !important; }

/* ═══════════════════════════════════════════════════════════
   MD3 Form Controls — Outlined text field
   ═══════════════════════════════════════════════════════════ */

.form-control,
.form-select {
  border-radius: var(--md-shape-xs) !important;
  border: 1px solid var(--md-outline) !important;
  background: var(--md-surface-container-lowest) !important;
  color: var(--md-on-surface) !important;
  font-size: .875rem;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: none !important;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--md-primary) !important;
  box-shadow: 0 0 0 1px var(--md-primary) !important;
  outline: none;
}

.form-control-sm, .form-select-sm {
  border-radius: var(--md-shape-xs) !important;
  font-size: .8rem;
}

.form-control::placeholder { color: var(--md-on-surface-variant); opacity: .7; }

/* ── Input group ── */
.input-group .form-control { border-radius: var(--md-shape-xs) 0 0 var(--md-shape-xs) !important; }
.input-group .btn:last-child { border-radius: 0 var(--md-shape-xs) var(--md-shape-xs) 0 !important; }

/* ── Form check/switch ── */
.form-check-input:checked {
  background-color: var(--md-primary);
  border-color: var(--md-primary);
}
.form-check-input:focus { box-shadow: 0 0 0 2px rgba(65,95,145,.25); }

/* ── Form label ── */
.form-label {
  font-size: .8rem;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  margin-bottom: .25rem;
}

/* ═══════════════════════════════════════════════════════════
   MD3 Primary Tabs
   ═══════════════════════════════════════════════════════════ */

.nav-tabs {
  border-bottom: 1px solid var(--md-surface-container-high) !important;
  margin-bottom: 0 !important;
  gap: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tabs .nav-link {
  border: none !important;
  border-bottom: 3px solid transparent !important;
  border-radius: 0 !important;
  margin-bottom: -1px;
  padding: .75rem 1.25rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--md-on-surface-variant);
  background: transparent !important;
  white-space: nowrap;
  transition: color .2s, background .2s;
}

.nav-tabs .nav-link:hover {
  color: var(--md-on-surface);
  background: var(--md-state-hover) !important;
}

.nav-tabs .nav-link.active {
  color: var(--md-primary) !important;
  border-bottom-color: var(--md-primary) !important;
  background: transparent !important;
}

.tab-pane {
  background: var(--md-surface-container-lowest);
  border: none;
  padding: 1rem;
}

/* ═══════════════════════════════════════════════════════════
   MD3 Alerts
   ═══════════════════════════════════════════════════════════ */

.alert {
  border: none !important;
  border-radius: var(--md-shape-md) !important;
}

.alert-danger {
  background: var(--md-error-container) !important;
  color: var(--md-on-error-container) !important;
}

.alert-success {
  background: #C4EED0 !important;
  color: #0A3818 !important;
}

.alert-warning {
  background: #FDEFC3 !important;
  color: #5C3D00 !important;
}

.alert-info {
  background: #C2E8FF !important;
  color: #003549 !important;
}

/* ═══════════════════════════════════════════════════════════
   MD3 Modal
   ═══════════════════════════════════════════════════════════ */

.modal-content {
  background: var(--md-surface-container-low) !important;
  border: none !important;
  border-radius: var(--md-shape-xl) !important;
  box-shadow: var(--md-elev-3) !important;
}

.modal-header {
  border-bottom: 1px solid var(--md-surface-container-high) !important;
  padding: 1.25rem 1.5rem 1rem;
}

.modal-footer {
  border-top: 1px solid var(--md-surface-container-high) !important;
  padding: 1rem 1.5rem 1.25rem;
}

.modal-title { font-weight: 500; color: var(--md-on-surface); }

/* ═══════════════════════════════════════════════════════════
   Misc
   ═══════════════════════════════════════════════════════════ */

.section-title {
  font-size: .7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--md-on-surface-variant);
  margin-bottom: .75rem;
  margin-top: .5rem;
}

.strategy-info {
  font-size: .78rem;
  color: var(--md-on-surface-variant);
  padding: .4rem .9rem;
  background: var(--md-surface-container);
  border-bottom: 1px solid var(--md-surface-container-high);
}

.strategy-table { max-height: 300px; overflow-y: auto; }

.bg-orange { background-color: #8B6A00 !important; color: #fff; }

.text-muted { color: var(--md-on-surface-variant) !important; }

/* ═══════════════════════════════════════════════════════════
   Service cards
   ═══════════════════════════════════════════════════════════ */

.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem;
}

.service-card {
  background: var(--md-surface-container);
  border: none;
  border-radius: var(--md-shape-md);
  padding: .75rem 1rem;
  transition: box-shadow .2s;
}

.service-card:hover { box-shadow: var(--md-elev-2); cursor: pointer; }
.service-card.discontinued { opacity: .5; }

.service-name { font-size: .85rem; font-weight: 500; color: var(--md-on-surface); margin-bottom: .2rem; }
.service-meta { font-size: .75rem; color: var(--md-on-surface-variant); margin-bottom: .3rem; }
.service-price { font-size: .9rem; font-weight: 700; color: var(--md-primary); }

/* ═══════════════════════════════════════════════════════════
   Document totals
   ═══════════════════════════════════════════════════════════ */

.totals-table { display: flex; flex-direction: column; gap: .2rem; }

.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .3rem 0;
  font-size: .84rem;
  border-bottom: 1px solid var(--md-surface-container-high);
  color: var(--md-on-surface-variant);
}

.totals-row span:last-child { font-weight: 500; color: var(--md-on-surface); }
.totals-grand { border-bottom: none; padding-top: .5rem; font-size: 1rem; font-weight: 700; }
.totals-grand span { color: var(--md-on-surface) !important; font-size: 1rem; font-weight: 700 !important; }

/* ═══════════════════════════════════════════════════════════
   Kanban board
   ═══════════════════════════════════════════════════════════ */

.kanban-board {
  display: flex;
  gap: .75rem;
  overflow-x: auto;
  padding-bottom: 1.5rem;
  align-items: flex-start;
}

.kanban-col {
  min-width: 320px;
  max-width: 320px;
  background: var(--md-surface-container);
  border-radius: var(--md-shape-md);
  border: none;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.kanban-col-header {
  padding: .65rem .85rem .55rem;
  border-radius: var(--md-shape-md) var(--md-shape-md) 0 0;
  background: var(--md-inverse-surface);
  color: var(--md-inverse-on-surface);
}

.kanban-col-title { font-size: .78rem; font-weight: 500; letter-spacing: .01em; }

.kanban-cards {
  padding: .5rem;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  flex: 1;
  min-height: 60px;
  max-height: calc(100vh - 380px);
  overflow-y: auto;
}

.kanban-card {
  background: var(--md-surface-container-lowest);
  border-radius: var(--md-shape-sm);
  border: none;
  border-left: 3px solid transparent;
  padding: .65rem .85rem;
  box-shadow: var(--md-elev-1);
  text-decoration: none;
  display: block;
  color: inherit;
  transition: box-shadow .2s;
}

.kanban-card:hover { box-shadow: var(--md-elev-2); color: inherit; }
.kanban-card[draggable] { cursor: grab; }
.kanban-card[draggable]:active { cursor: grabbing; }
.kanban-card-link { cursor: pointer; text-decoration: none; color: inherit; }
.kanban-card-link:hover { text-decoration: underline; color: inherit; }
.kanban-drop-target {
  background: color-mix(in srgb, var(--bs-primary) 10%, transparent);
  border: 2px dashed var(--bs-primary);
  border-radius: var(--md-shape-sm);
  min-height: 80px;
  transition: background .15s;
}

.kanban-card-title {
  font-size: .8rem;
  font-weight: 500;
  color: var(--md-on-surface);
  line-height: 1.3;
  margin-bottom: .2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-card-account {
  font-size: .72rem;
  color: var(--md-on-surface-variant);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-card-amount { font-size: .82rem; font-weight: 700; color: var(--md-primary); }
.kanban-card-meta   { font-size: .68rem; color: var(--md-on-surface-variant); margin-top: .25rem; opacity: .8; }
.kanban-col-total   { font-size: .8rem; font-weight: 700; color: var(--md-primary-container); margin-top: .15rem; }

.kanban-col-footer {
  padding: .45rem .85rem;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .78rem;
  font-weight: 700;
  color: var(--md-primary-container);
  border-radius: 0 0 var(--md-shape-md) var(--md-shape-md);
  background: var(--md-inverse-surface);
  text-align: right;
}

/* ═══════════════════════════════════════════════════════════
   Rep cards (Commerciali)
   ═══════════════════════════════════════════════════════════ */

.rep-card { transition: box-shadow .2s; }
.rep-card:hover { box-shadow: var(--md-elev-2) !important; }

.rep-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--md-shape-full);
  background: linear-gradient(135deg, var(--md-primary), var(--md-tertiary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.rep-stat-box {
  background: var(--md-surface-container);
  border-radius: var(--md-shape-sm);
  padding: .5rem .75rem;
  text-align: center;
}

.rep-stat-val { font-size: .9rem; font-weight: 700; line-height: 1.2; color: var(--md-on-surface); }
.rep-stat-lbl { font-size: .65rem; text-transform: uppercase; letter-spacing: .05em; color: var(--md-on-surface-variant); }

/* ═══════════════════════════════════════════════════════════
   Misc overrides
   ═══════════════════════════════════════════════════════════ */

.btn-outline-secondary.bg-white:hover,
.btn-outline-secondary.bg-white:focus {
  background: var(--md-surface-container) !important;
  border-color: var(--md-outline) !important;
  color: var(--md-on-surface) !important;
}

.fic-inv-link:hover,
.link-hover-underline:hover { text-decoration: underline !important; }
.link-hover-underline { text-decoration: none !important; }

/* Pagination */
.page-link {
  border-radius: var(--md-shape-full) !important;
  border: none !important;
  color: var(--md-primary);
  background: transparent;
  margin: 0 .1rem;
}
.page-link:hover { background: var(--md-state-hover) !important; color: var(--md-primary); }
.page-item.active .page-link { background: var(--md-primary) !important; color: var(--md-on-primary) !important; }
.page-item.disabled .page-link { color: var(--md-on-surface-variant) !important; opacity: .4; }

/* Dropdown */
.dropdown-menu {
  border: none !important;
  border-radius: var(--md-shape-md) !important;
  background: var(--md-surface-container-low) !important;
  box-shadow: var(--md-elev-2) !important;
  padding: .4rem;
}
.dropdown-item {
  border-radius: var(--md-shape-sm);
  color: var(--md-on-surface) !important;
  font-size: .875rem;
  padding: .45rem .85rem;
}
.dropdown-item:hover { background: var(--md-state-hover) !important; }
.dropdown-divider { border-color: var(--md-surface-container-high) !important; }

/* ═══════════════════════════════════════════════════════════
   Sidebar backdrop (mobile)
   ═══════════════════════════════════════════════════════════ */

#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 999;
  animation: fadeIn .25s ease;
}

#sidebar-backdrop.show { display: block; }

@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

/* ═══════════════════════════════════════════════════════════
   Mobile — MD3 responsive
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 767.98px) {

  /* Rail: completamente nascosto su mobile */
  .sidebar { display: none !important; }

  .main-wrapper { margin-left: 0 !important; transition: none; }

  /* Panel: drawer completo da sinistra — !important per battere i valori desktop */
  .nav-panel {
    left: 0 !important;
    width: 280px !important;
    z-index: 1050 !important;   /* > backdrop(999) e > base nav-panel(998) */
    transform: translate3d(-100%, 0, 0) !important;  /* translate3d per hit-testing iOS */
    transition: transform .3s cubic-bezier(.2,0,0,1) !important;
    overflow-y: auto;
    padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom) + 8px);
    pointer-events: none !important;  /* non intercetta eventi quando chiuso */
  }

  .nav-panel.mobile-open {
    transform: translate3d(0, 0, 0) !important;
    box-shadow: var(--md-elev-3), 6px 0 24px rgba(0,0,0,.4);
    pointer-events: auto !important;  /* riattiva eventi quando aperto */
  }

  /* Link più grandi e leggibili nel drawer mobile */
  .nav-panel .nav-panel-link {
    font-size: .95rem;
    padding: .75rem 1rem;
    min-height: 48px;
    color: rgba(255,255,255,.88);
    border-radius: var(--md-shape-md);
  }

  .nav-panel .nav-panel-link .material-symbols-rounded { font-size: 1.2rem; }

  .nav-panel .nav-panel-link.active { color: var(--nav-active-color); }

  .nav-panel .nav-panel-section-head {
    font-size: .72rem;
    padding: 1rem 1.1rem .3rem;
    color: rgba(255,255,255,.5);
  }

  /* Page */
  .page-content { padding: .75rem; }
  .page-header { margin-bottom: .75rem; }
  .page-header h4 { font-size: 1.1rem; }
  .page-header > p { display: none; }

  /* KPI */
  .kpi-value { font-size: 1rem; }
  .kpi-card { padding: .65rem .85rem; }

  /* Tables */
  .table td, .table th { font-size: .875rem; padding: .35rem .5rem; }

  /* Touch targets */
  .btn { min-height: 44px; }
  .sidebar-nav .nav-link { min-height: 44px; }

  /* Extra bottom padding so content isn't hidden behind bottom nav */
  .main-wrapper { padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom)); }

  /* Hide secondary table columns */
  table:has(#tbody-clienti) th:nth-child(3),
  table:has(#tbody-clienti) th:nth-child(4),
  table:has(#tbody-clienti) th:nth-child(5),
  #tbody-clienti td:nth-child(3),
  #tbody-clienti td:nth-child(4),
  #tbody-clienti td:nth-child(5) { display: none; }

  table:has(#tbody-trattative) th:nth-child(3),
  table:has(#tbody-trattative) th:nth-child(5),
  #tbody-trattative td:nth-child(3),
  #tbody-trattative td:nth-child(5) { display: none; }

  table:has(#tbody-prev) th:nth-child(4),
  table:has(#tbody-prev) th:nth-child(5),
  #tbody-prev td:nth-child(4),
  #tbody-prev td:nth-child(5) { display: none; }

  table:has(#tbody-so) th:nth-child(4),
  table:has(#tbody-so) th:nth-child(5),
  #tbody-so td:nth-child(4),
  #tbody-so td:nth-child(5) { display: none; }

  table:has(#tbody-proj) th:nth-child(4),
  table:has(#tbody-proj) th:nth-child(5),
  #tbody-proj td:nth-child(4),
  #tbody-proj td:nth-child(5) { display: none; }

  /* Kanban */
  .kanban-col { min-width: 200px; max-width: 200px; }
  .kanban-col-header { padding: .5rem .65rem; }
  .kanban-card { padding: .5rem .65rem; }
  .kanban-cards { max-height: calc(100vh - 260px); }

  /* Filters: stack vertically */
  .card-body .row.g-2 > [class*="col-sm"],
  .card-body .row.g-2 > [class*="col-md"] { width: 100%; }
  .card-body .row.g-2 > .col-auto { width: auto; }

  /* Tabs: scrollable */
  .nav-tabs { flex-wrap: nowrap; overflow-x: auto; }
  .nav-tabs .nav-link { padding: .6rem .9rem; font-size: .82rem; }
}

/* ── thead Bootstrap override → MD3 ── */
thead.table-dark tr th, thead.table-dark th {
  background-color: var(--md-inverse-surface) !important;
  color: var(--md-inverse-on-surface) !important;
  border-color: rgba(255,255,255,.08) !important;
  font-size: .825rem !important;
  font-weight: 500 !important;
  text-transform: uppercase !important;
  letter-spacing: .07em !important;
}

thead.table-light tr th, thead.table-light th {
  background-color: var(--md-surface-container) !important;
  color: var(--md-on-surface-variant) !important;
  border-color: var(--md-surface-container-high) !important;
  font-size: .825rem !important;
  font-weight: 500 !important;
  text-transform: uppercase !important;
  letter-spacing: .07em !important;
}

/* Modal backdrop più scuro */
.modal-backdrop { opacity: .75 !important; }

/* ═══════════════════════════════════════════════════════════
   Navigation Rail items
   ═══════════════════════════════════════════════════════════ */

.rail-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: calc(100% - .6rem);
  margin: .1rem .3rem;
  padding: .55rem 4px;
  color: var(--nav-color);
  background: none;
  border: none;
  cursor: pointer;
  font-size: .6rem;
  font-weight: 500;
  font-family: var(--font-sans);
  letter-spacing: .01em;
  border-radius: var(--md-shape-sm);
  transition: color .2s, background .2s;
  -webkit-tap-highlight-color: transparent;
}

.rail-item .material-symbols-rounded { font-size: 1.2rem; line-height: 1; }
.rail-item .rail-label { line-height: 1.2; text-align: center; }

.rail-item:hover  { color: #fff; background: var(--nav-hover-bg); }
.rail-item.active { color: var(--nav-active-color); background: var(--nav-active-bg); }

/* ═══════════════════════════════════════════════════════════
   Navigation Panel (secondary)
   ═══════════════════════════════════════════════════════════ */

.nav-panel {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  width: var(--panel-w);
  height: 100vh;
  background: #1b1b2c;
  border-right: 1px solid var(--nav-divider);
  z-index: 998;
  transform: translateX(-110%);
  transition: transform .3s cubic-bezier(.2,0,0,1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: none;
}

.nav-panel::-webkit-scrollbar { display: none; }
.nav-panel.open { transform: translateX(0); }

/* Push content on desktop when panel open */
@media (min-width: 768px) {
  body.panel-open .main-wrapper {
    margin-left: calc(var(--sidebar-w) + var(--panel-w));
    transition: margin-left .3s cubic-bezier(.2,0,0,1);
  }
}

/* Panel header (area title) */
.nav-panel-head {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1rem 1.1rem .7rem;
  color: rgba(255,255,255,.4);
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
  border-bottom: 1px solid var(--nav-divider);
  flex-shrink: 0;
}

.nav-panel-head .material-symbols-rounded { font-size: .85rem; }

/* Panel nav links */
.nav-panel-nav { padding: .4rem; }

.nav-panel-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .9rem;
  color: var(--nav-color);
  text-decoration: none;
  font-size: .85rem;
  border-radius: var(--md-shape-full);
  transition: background .2s, color .2s;
  white-space: nowrap;
}

.nav-panel-link .material-symbols-rounded { font-size: 1rem; flex-shrink: 0; }
.nav-panel-link:hover  { color: #fff; background: var(--nav-hover-bg); }
.nav-panel-link.active { color: var(--nav-active-color); background: var(--nav-active-bg); }
.nav-separator { border: none; border-top: 1px solid rgba(255,255,255,.12); margin: .35rem .4rem; }

/* Mobile drawer: section headers */
.nav-panel-section { margin-bottom: .25rem; }

.nav-panel-section-head {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .9rem 1.1rem .25rem;
  color: rgba(255,255,255,.35);
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .1em;
}

.nav-panel-section-head .material-symbols-rounded { font-size: .8rem; }

/* Header del drawer mobile */
.nav-panel-mobile-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .9rem 1rem .9rem 1.25rem;
  border-bottom: 1px solid var(--nav-divider);
  flex-shrink: 0;
}

.nav-panel-mobile-header > span {
  flex: 1;
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .01em;
}

.nav-panel-close {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: rgba(255,255,255,.65);
  border-radius: var(--md-shape-full);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s, color .2s;
  -webkit-tap-highlight-color: transparent;
}

.nav-panel-close:hover { background: var(--nav-hover-bg); color: #fff; }
.nav-panel-close .material-symbols-rounded { font-size: 1.3rem; }

/* ═══════════════════════════════════════════════════════════
   Command Palette
   ═══════════════════════════════════════════════════════════ */

#cmd-palette {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 9500;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  animation: fadeIn .15s ease;
}

#cmd-palette[hidden] { display: none; }

.cmd-dialog {
  width: 520px;
  max-width: calc(100vw - 2rem);
  background: var(--md-surface-container-low);
  border-radius: var(--md-shape-xl);
  box-shadow: 0 8px 32px rgba(0,0,0,.45);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 60vh;
}

.cmd-search-wrap {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--md-surface-container-high);
  flex-shrink: 0;
}

.cmd-search-icon { color: var(--md-on-surface-variant); font-size: 1.2rem; flex-shrink: 0; }

#cmd-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--md-on-surface);
  font-size: .95rem;
  font-family: var(--font-sans);
  outline: none;
}

#cmd-input::placeholder { color: var(--md-on-surface-variant); opacity: .7; }

.cmd-esc-hint {
  font-size: .7rem;
  color: var(--md-on-surface-variant);
  background: var(--md-surface-container);
  border: 1px solid var(--md-outline-variant);
  border-radius: var(--md-shape-xs);
  padding: .15rem .4rem;
  flex-shrink: 0;
}

#cmd-results { overflow-y: auto; padding: .3rem 0; }

.cmd-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.1rem;
  text-decoration: none;
  color: var(--md-on-surface);
  cursor: pointer;
  transition: background .1s;
}

.cmd-item:hover,
.cmd-item.focused { background: var(--md-state-hover); }

.cmd-item-icon { font-size: 1.1rem; color: var(--md-on-surface-variant); flex-shrink: 0; }

.cmd-item-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.cmd-item-label { font-size: .875rem; font-weight: 500; }
.cmd-item-area  { font-size: .72rem; color: var(--md-on-surface-variant); }
.cmd-empty      { padding: 1.5rem; text-align: center; color: var(--md-on-surface-variant); font-size: .875rem; }

/* Trigger button in topbar (mobile) */
.cmd-trigger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: transparent !important;
  border: none;
  border-radius: var(--md-shape-full);
  color: rgba(255,255,255,.85);
  cursor: pointer;
  transition: background .2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.cmd-trigger-btn:hover { background: rgba(255,255,255,.1) !important; }
.cmd-trigger-btn .material-symbols-rounded { font-size: 1.4rem; }

/* ═══════════════════════════════════════════════════════════
   Bottom Navigation Bar (mobile only)
   ═══════════════════════════════════════════════════════════ */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--nav-bg);
  border-top: 1px solid var(--nav-divider);
  display: flex;
  align-items: stretch;
  z-index: 998;
  box-shadow: 0 -2px 8px rgba(0,0,0,.25);
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--nav-color);
  text-decoration: none;
  font-size: .62rem;
  font-weight: 500;
  letter-spacing: .01em;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 4px 4px;
  position: relative;
  transition: color .2s;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-sans);
}

.bottom-nav-item .material-symbols-rounded {
  font-size: 1.3rem;
  line-height: 1;
  position: relative;
  z-index: 1;
}

.bottom-nav-item span:not(.material-symbols-rounded) {
  position: relative;
  z-index: 1;
}

/* Active indicator pill */
.bottom-nav-item.active {
  color: var(--nav-active-color);
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 56px;
  height: 28px;
  background: var(--nav-active-bg);
  border-radius: var(--md-shape-full);
}

.bottom-nav-item:active { opacity: .7; }

/* Allinea col sinistra a opp-name (dopo back button + gap) */
@media (min-width: 768px) {
  .ps-md-opp { padding-left: 3.75rem !important; padding-right: 1.5rem !important; }
}

/* Rimuovi bordo inferiore card-header quando il corpo è collassato */
.card:has(> .collapse:not(.show)) > .card-header {
  border-bottom: 0 !important;
  border-radius: var(--bs-card-inner-border-radius) !important;
}


/* Underline on hover for text-decoration-none links */
a.text-decoration-none:hover { text-decoration: underline !important; }
