:root {
  color-scheme: light;
  --bp-bar-start: #0d47a1;
  --bp-bar-end: #1976d2;
  --bp-snap-active: #1976d2;
  --bp-teal: #00838f;
}

::-webkit-scrollbar {
  width: 0;
  height: 0;
}

body {
  min-height: 100vh;
}

.bg-body-panel {
  background: #e8edf3;
}

.bp-topbar {
  background: #142042;
  box-shadow: 0 2px 8px rgba(13, 71, 161, 0.22);
  position: relative;
  z-index: 1100;
}

/* Overlay cliccabile: sopra al main, sotto alla topbar (brand + strumenti + sheet menu) */
.bp-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1040;
  background: rgba(15, 23, 42, 0.42);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity;
}

.bp-nav-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile: Attività + utente + hamburger sulla stessa riga del brand */
.bp-topbar-tools .nav-pill.dropdown-toggle {
  padding-inline: 0.45rem;
}

.bp-topbar-tools .navbar-toggler {
  padding: 0.2rem 0.35rem;
}

@media (max-width: 991.98px) {
  /* Sheet-style: overlay quando è aperto il menu principale o un dropdown toolbar */
  .bp-topbar {
    overflow: visible;
  }

  .bp-topbar-inner,
  .bp-topbar-tools {
    overflow: visible;
  }

  .bp-brand {
    position: relative;
    z-index: 1060;
  }

  .bp-topbar-tools {
    position: relative;
    z-index: 1060;
  }

  /*
   * Menu hamburger: foglio fisso anche in fase .collapsing, così non si vede l'animazione
   * altezza di Bootstrap (scatto). Transizione opacity+transform allineata all'overlay.
   */
  #mainNav.bp-topbar-nav-collapse:not(.show):not(.collapsing) {
    transition: none !important;
  }

  #mainNav.bp-topbar-nav-collapse.collapsing,
  #mainNav.bp-topbar-nav-collapse.show {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    z-index: 1048 !important;
    max-height: min(82dvh, 34rem) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    border-radius: 1.1rem 1.1rem 0 0 !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.28) !important;
    background: var(--bs-body-bg);
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    overscroll-behavior: contain;
    transition:
      opacity 0.42s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.46s cubic-bezier(0.22, 1, 0.36, 1) !important;
  }

  #mainNav.bp-topbar-nav-collapse.collapsing {
    opacity: 0;
    transform: translate3d(0, 18px, 0);
    pointer-events: none;
  }

  #mainNav.bp-topbar-nav-collapse.show {
    opacity: 1;
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
  }

  @keyframes bpToolbarSheetIn {
    from {
      opacity: 0;
    }

    to {
      opacity: 1;
    }
  }

  .bp-mainnav-mobilebar {
    position: relative;
    flex-shrink: 0;
    padding-top: 0.55rem;
  }

  .bp-mainnav-mobilebar::before {
    content: "";
    position: absolute;
    top: 0.28rem;
    left: 50%;
    transform: translateX(-50%);
    width: 2.25rem;
    height: 0.3rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.12);
  }

  #mainNav.bp-topbar-nav-collapse.collapsing .navbar-nav,
  #mainNav.bp-topbar-nav-collapse.show .navbar-nav {
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 0.4rem;
    padding: 0.35rem 0.85rem 0.5rem;
    margin-inline-start: 0 !important;
  }

  #mainNav.bp-topbar-nav-collapse.collapsing .navbar-nav .nav-link,
  #mainNav.bp-topbar-nav-collapse.show .navbar-nav .nav-link {
    width: 100%;
    justify-content: flex-start;
    gap: 0.55rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.65rem;
    color: var(--bs-body-color);
    background: rgba(0, 0, 0, 0.04);
    white-space: normal;
  }

  #mainNav.bp-topbar-nav-collapse.collapsing .navbar-nav .nav-link:hover,
  #mainNav.bp-topbar-nav-collapse.show .navbar-nav .nav-link:hover {
    color: var(--bs-body-color);
    background: rgba(0, 0, 0, 0.07);
  }

  #mainNav.bp-topbar-nav-collapse.collapsing .navbar-nav .nav-link.active,
  #mainNav.bp-topbar-nav-collapse.show .navbar-nav .nav-link.active {
    color: #0d47a1;
    background: rgba(13, 110, 253, 0.14);
    font-weight: 600;
  }

  #mainNav.bp-topbar-nav-collapse.collapsing .navbar-nav .nav-link .bp-nav-ico,
  #mainNav.bp-topbar-nav-collapse.show .navbar-nav .nav-link .bp-nav-ico {
    opacity: 0.85;
  }

  .bp-topbar-tools .bp-topbar-dropdown .dropdown-menu {
    animation: bpToolbarSheetIn 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    transform: none !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
    border-radius: 1.1rem 1.1rem 0 0 !important;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.28) !important;
    z-index: 1070 !important;
    max-height: min(82dvh, 34rem) !important;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .bp-topbar-tools .bp-topbar-dropdown .dropdown-menu::before {
    content: "";
    display: block;
    width: 2.25rem;
    height: 0.3rem;
    margin: 0.2rem auto 0.65rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.12);
  }

  .bp-topbar-tools .bp-nav-ops-menu.dropdown-menu {
    min-width: 0 !important;
    max-width: none !important;
  }

  @media (prefers-reduced-motion: reduce) {
    .bp-nav-backdrop {
      transition-duration: 0.01ms;
    }

    #mainNav.bp-topbar-nav-collapse.collapsing,
    #mainNav.bp-topbar-nav-collapse.show {
      transition-duration: 0.01ms !important;
    }
  }
}

.bp-brand-icon svg {
  display: block;
}

.bp-topbar .nav-pill {
  color: rgba(255, 255, 255, 0.92);
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.bp-topbar .nav-pill:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.bp-topbar .nav-pill.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.28);
  font-weight: 600;
}

.bp-topbar .navbar-toggler {
  filter: brightness(0) invert(1);
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}

.bp-topbar .navbar-toggler:focus {
  outline: none;
}

.bp-topbar .navbar-toggler:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.45);
  outline-offset: 2px;
}

.bp-topbar .navbar-toggler:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none !important;
}

.bp-nav-ico {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
  opacity: 0.92;
}

/* Icone più grandi: operazioni in corso + account (toolbar destra) */
.bp-topbar-tools .bp-topbar-tool-ico {
  width: 1.35rem;
  height: 1.35rem;
}

.bp-nav-ops-badge {
  top: 6px !important;
  left: 6px !important;
}

.bp-topbar .nav-pill.d-inline-flex {
  gap: 0.35rem;
}

.bp-page-header-ico {
  line-height: 0;
  margin-top: 0.1rem;
}

.bp-page-header-ico svg {
  width: 26px;
  height: 26px;
  display: block;
}

.bp-explorer-card {
  border-radius: 0.65rem;
}

.bp-snap-aside {
  min-height: min(52vh, 360px);
}

/* Impostazioni: barra laterale con pochi link — evita altezza eccessiva */
.bp-settings-aside.bp-snap-aside {
  min-height: auto;
}

.bp-settings-panel {
  /*max-width: min(52rem, 100%);*/
  max-width: 100%;
}

.bp-snap-list .bp-snap-item {
  padding: 0.5rem 0.65rem;
  color: inherit;
  border-left: 3px solid transparent;
}

.bp-snap-list .bp-snap-item:hover {
  background: rgba(25, 118, 210, 0.06);
}

.bp-snap-list .bp-snap-item.is-active {
  background: var(--bp-snap-active);
  color: #fff;
  border-left-color: #0d47a1;
}

.bp-snap-list .bp-snap-item.is-active .text-muted {
  color: rgba(255, 255, 255, 0.85) !important;
}

.bp-snap-list .bp-snap-item.is-active .text-secondary {
  color: rgba(255, 255, 255, 0.9) !important;
}

.bp-breadcrumb a {
  color: var(--bs-primary);
}

.bp-file-table thead th {
  font-size: 0.8rem;
  text-transform: none;
  letter-spacing: 0;
}

.bp-file-table a {
  color: #000000;
}

.bp-badge-dir {
  background: #ffca28;
  color: #3e2723;
  font-weight: 600;
  font-size: 0.7rem;
}

.bp-badge-file {
  background: #546e7a;
  color: #fff;
  font-weight: 600;
  font-size: 0.7rem;
}

.bp-btn-teal {
  background: var(--bp-teal);
  border-color: var(--bp-teal);
}

.bp-btn-teal:hover {
  background: #006064;
  border-color: #006064;
  color: #fff;
}

.app-shell {
  max-width: min(1680px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.bp-main-wide {
  max-width: min(1680px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

@media (min-width: 761px) {
  .page-header > .page-header-actions {
    align-self: center;
  }
}

.page-header .h3 {
  font-size: 1.15rem;
  line-height: 1.3;
}

.page-header p {
  margin-bottom: 0;
}

.table td,
.table th {
  vertical-align: middle;
}

.table-responsive {
  border-radius: .5rem;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.form-panel {
  max-width: min(960px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
}

.metric-card strong {
  display: block;
  font-size: clamp(1.35rem, 3.2vw, 2.1rem);
  line-height: 1;
}

main .card.metric-card > .card-body {
  padding: 0.5rem 0.65rem;
}

.metric-card span {
  color: var(--bs-secondary-color);
}

.log-detail {
  white-space: pre-wrap;
  width: 100%;
  font-size: 9px;
  padding: 10px;
  background: #eeeeee;
  border-radius: 10px;
}

/* Log: pannello contesto (offcanvas) */
.bp-log-context-offcanvas.offcanvas {
  --bs-offcanvas-width: min(100vw - 1rem, 520px);
}

.bp-log-context-pre {
  margin: 0;
  padding: 0.85rem 1rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  max-height: calc(100vh - 11rem);
  overflow: auto;
}

.bp-log-context-code {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  white-space: pre;
  word-break: break-word;
  color: #0f172a;
}

code {
  word-break: break-word;
}

@media (max-width: 760px) {
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .bp-page-header-toolrow .page-header-actions {
    width: 100%;
  }

  .bp-page-header-toolrow .page-header-actions > .btn,
  .bp-page-header-toolrow .page-header-actions > a.btn {
    width: 100%;
  }

  .bp-dash-newtask {
    width: 100%;
    min-height: 2.55rem;
    font-weight: 600;
    border-radius: 0.7rem;
    box-shadow: 0 2px 10px rgba(13, 110, 253, 0.22);
  }

  .bp-dash-newtask-ico {
    flex-shrink: 0;
  }

  .bp-storage-refresh-label {
    display: none;
  }

  .bp-storage-refresh-btn {
    padding: 0.4rem 0.55rem;
    gap: 0;
  }
}

tr.remote-browse-dir {
  cursor: pointer;
}

.bp-restore-dock {
  position: sticky;
  bottom: 0;
  z-index: 2;
}

.bp-dist-ico {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  opacity: 0.92;
}

/* Contenuto principale: card e tabelle più compatte */
main .card > .card-body {
  padding: 0.6rem 0.75rem;
}

main .card > .card-header {
  padding: 0.45rem 0.65rem;
}

main .card > .card-header .h3,
main .card > .card-header h2 {
  font-size: 1.05rem;
}

main .table {
  font-size: 0.875rem;
}

main .table > :not(caption) > * > * {
  padding: 0.4rem 0.55rem;
}

main .row.g-2,
main .row.g-3 {
  --bs-gutter-y: 0.55rem;
  --bs-gutter-x: 0.55rem;
}

/* Filtri: form che unisce .card e .card-body */
main form.card.card-body {
  padding: 0.5rem 0.65rem;
}

.bp-storage-widget .bp-storage-bar-used {
  background: linear-gradient(90deg, var(--bp-bar-start), var(--bp-bar-end));
}

/* Dashboard: metriche compatte con accento colore */
.bp-metric-tile .card-body {
  padding: 0.75rem 1rem;
}

.bp-metric-tile__icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bp-metric-tile__icon svg {
  width: 1.35rem;
  height: 1.35rem;
}

.bp-metric-tile__text strong {
  display: block;
  font-size: clamp(1.35rem, 3vw, 1.95rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.bp-metric-tile__text span {
  font-size: 0.8125rem;
  color: var(--bs-secondary-color);
}

.bp-metric-tile--servers .bp-metric-tile__icon {
  background: rgba(25, 118, 210, 0.12);
  color: #1565c0;
}

.bp-metric-tile--tasks .bp-metric-tile__icon {
  background: rgba(0, 131, 143, 0.12);
  color: var(--bp-teal);
}

.bp-metric-tile--restore .bp-metric-tile__icon {
  background: rgba(245, 127, 23, 0.12);
  color: #e65100;
}

.bp-dash-card-ico {
  line-height: 0;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.bp-dash-card-ico svg {
  width: 1.35rem;
  height: 1.35rem;
  display: block;
}

.bp-overview-widget .bp-overview-list li {
  padding-left: 0.1rem;
}

.bp-overview-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  margin-top: 0.35rem;
  flex-shrink: 0;
}

.bp-overview-dot--ok {
  background: #00897b;
}

.bp-overview-dot--restore {
  background: #fb8c00;
}

.bp-overview-dot--log {
  background: #5c6bc0;
}

/* Task form: cron-input-ui (web component) */
.bp-cron-input-host {
  max-width: 100%;
}

.bp-cron-input-host cron-input-ui {
  display: block;
  max-width: 100%;
}

cron-input-ui .modal-body, cron-input-ui .modal-header {
  margin: 0rem !important;
}
cron-input-ui .nav-tabs .nav-link {
  font-size: 13px;
  padding: 10px;
}

/* Toast flash (Bootstrap): sopra la topbar (1100) e sotto eventuali modal molto alte */
.bp-toast-stack {
  z-index: 1200;
  top: calc(3.5rem + env(safe-area-inset-top, 0px));
  max-width: min(100vw - 1.5rem, 22rem);
}

.bp-toast-stack .toast {
  width: 100%;
}

/* Navbar: operazioni backup / ripristino in corso */
.bp-nav-ops-menu {
  min-width: min(100vw - 1rem, 22rem);
  max-width: 24rem;
  max-height: min(70vh, 480px);
  overflow-y: auto;
}

.bp-nav-ops--busy .bp-nav-ico {
  animation: bp-nav-ops-pulse 1.15s ease-in-out infinite;
}

@keyframes bp-nav-ops-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.42; }
}

.bp-nav-ops-meta {
  font-size: 0.72rem;
}

.bp-nav-ops-section-label {
  font-size: 0.65rem;
  letter-spacing: 0.04em;
}

/* Form task: colonna destra (stato / notifiche + strumenti) */
@media (min-width: 992px) {
  .bp-task-aside {
    position: sticky;
    top: 0.75rem;
  }
}