/* ============================================================================
   BBR — Components v2
   ----------------------------------------------------------------------------
   Tutte le classi usano i token di bbr-tokens.css.
   Naming: .bbr-{component}__{element}--{modifier}
   Componenti coperti:
     Tipografia · Layout (app shell, sidebar, header, banner, content)
     Buttons · Inputs · Selects · Textareas · Switches
     Cards · KPI widget · Tables · Badges · Status dots
     Avatars · Dropdowns · Menus · Modals · Toasts
     Tabs (orizzontali, fallback) · Empty state · Skeleton
   ========================================================================== */


/* =========================================================================
   TIPOGRAFIA — classi utility, NON tag-based (riusabili ovunque)
   ========================================================================= */

.bbr-display {
  font-family: var(--bbr-font-display);
  font-weight: var(--fw-regular);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
  color: var(--bbr-fg-primary);
}
.bbr-display--xl { font-size: var(--text-4xl); }
.bbr-display--lg { font-size: var(--text-3xl); }
.bbr-display--md { font-size: var(--text-2xl); }

.bbr-h1, .bbr-h2 {
  font-family: var(--bbr-font-display);
  font-weight: var(--fw-regular);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
  color: var(--bbr-fg-primary);
  margin: 0;
}
.bbr-h1 { font-size: var(--text-3xl); }
.bbr-h2 { font-size: var(--text-2xl); }

/* Heading "sans" — per card/section, più funzionale */
.bbr-h3 {
  font-family: var(--bbr-font-sans);
  font-weight: var(--fw-semibold);
  font-size: var(--text-xl);
  line-height: var(--lh-snug);
  letter-spacing: -0.005em;
  color: var(--bbr-fg-primary);
  margin: 0;
}
.bbr-h4 {
  font-family: var(--bbr-font-sans);
  font-weight: var(--fw-semibold);
  font-size: var(--text-lg);
  line-height: var(--lh-snug);
  color: var(--bbr-fg-primary);
  margin: 0;
}

.bbr-text-body  { font-size: var(--text-base); color: var(--bbr-fg-primary); }
.bbr-text-muted { font-size: var(--text-base); color: var(--bbr-fg-muted); }
.bbr-text-small { font-size: var(--text-sm); color: var(--bbr-fg-muted); }
.bbr-text-meta  { font-size: var(--text-xs); color: var(--bbr-fg-muted); letter-spacing: 0.01em; }

.bbr-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--bbr-fg-muted);
}

.bbr-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 var(--space-100);
  font-family: var(--bbr-font-mono);
  font-size: 11px;
  color: var(--bbr-fg-secondary);
  background: var(--bbr-bg-sunken);
  border: 1px solid var(--bbr-bd-default);
  border-bottom-width: 2px;
  border-radius: 4px;
}


/* =========================================================================
   APP SHELL — sidebar + header + content
   ========================================================================= */

.bbr-app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  min-height: 100vh;
  background: var(--bbr-bg-app);
}
.bbr-app--with-banner {
  grid-template-rows: auto auto 1fr;
  grid-template-areas:
    "sidebar banner"
    "sidebar header"
    "sidebar main";
}

/* --- Sidebar --- */
.bbr-sidebar {
  grid-area: sidebar;
  background: var(--bbr-bg-surface);
  border-right: 1px solid var(--bbr-bd-default);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.bbr-sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  padding: var(--space-400) var(--space-400);
  border-bottom: 1px solid var(--bbr-bd-soft);
  font-family: var(--bbr-font-display);
  font-size: var(--text-lg);
  color: var(--bbr-fg-primary);
  letter-spacing: var(--tracking-tight);
}
.bbr-sidebar__brand-mark {
  width: 28px; height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bbr-accent);
  color: var(--bbr-fg-on-accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--bbr-font-sans);
  font-weight: var(--fw-semibold);
  font-size: 13px;
  letter-spacing: 0;
}

.bbr-sidebar__section {
  padding: var(--space-300) var(--space-200);
  display: flex;
  flex-direction: column;
  gap: var(--space-050);
}
.bbr-sidebar__section + .bbr-sidebar__section {
  border-top: 1px solid var(--bbr-bd-soft);
}
.bbr-sidebar__section-label {
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--bbr-fg-soft);
  padding: var(--space-200) var(--space-300) var(--space-100);
}

.bbr-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-300);
  padding: 7px var(--space-300);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--bbr-fg-secondary);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  font-family: inherit;
  transition: background var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.bbr-nav-item:hover { background: var(--bbr-bg-sunken); color: var(--bbr-fg-primary); }
.bbr-nav-item__icon {
  width: 16px; height: 16px;
  color: var(--bbr-fg-soft);
  flex-shrink: 0;
}
.bbr-nav-item:hover .bbr-nav-item__icon { color: var(--bbr-fg-secondary); }
.bbr-nav-item--active {
  background: var(--bbr-bg-sunken);
  color: var(--bbr-fg-primary);
  font-weight: var(--fw-medium);
}
.bbr-nav-item--active .bbr-nav-item__icon { color: var(--bbr-fg-primary); }
.bbr-nav-item__badge {
  margin-left: auto;
  font-size: var(--text-xs);
  background: var(--bbr-accent-soft);
  color: var(--bbr-accent-soft-fg);
  padding: var(--space-025) var(--space-150);
  border-radius: var(--radius-full);
  font-weight: var(--fw-medium);
}
.bbr-nav-item__kbd {
  margin-left: auto;
  opacity: 0.6;
}

.bbr-sidebar__footer {
  margin-top: auto;
  padding: var(--space-300);
  border-top: 1px solid var(--bbr-bd-soft);
}


/* --- Header --- */
.bbr-header {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: var(--space-300);
  height: var(--header-h);
  padding: 0 var(--space-600);
  background: var(--bbr-bg-app);
  border-bottom: 1px solid var(--bbr-bd-default);
  position: sticky;
  top: 0;
  z-index: 30;
}
.bbr-header__crumbs {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  font-size: var(--text-sm);
  color: var(--bbr-fg-muted);
}
.bbr-header__crumbs strong {
  color: var(--bbr-fg-primary);
  font-weight: var(--fw-medium);
}
.bbr-header__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-200);
}


/* --- Workspace switcher (header) --- */
.bbr-ws-switcher {
  display: inline-flex;
  align-items: center;
  gap: var(--space-200);
  padding: var(--space-150) 10px var(--space-150) var(--space-150);
  background: var(--bbr-bg-surface);
  border: 1px solid var(--bbr-bd-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  font: inherit;
  color: var(--bbr-fg-primary);
  transition: border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.bbr-ws-switcher:hover { border-color: var(--bbr-bd-strong); background: var(--bbr-bg-sunken); }
.bbr-ws-switcher__avatar {
  width: 22px; height: 22px;
  border-radius: var(--radius-sm);
  background: var(--bbr-accent);
  color: var(--bbr-fg-on-accent);
  font-size: 11px;
  font-weight: var(--fw-semibold);
  display: flex; align-items: center; justify-content: center;
  text-transform: uppercase;
}
.bbr-ws-switcher__name {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}
.bbr-ws-switcher__role {
  font-size: var(--text-xs);
  color: var(--bbr-fg-muted);
  line-height: 1;
  margin-top: var(--space-050);
}
.bbr-ws-switcher__chevron {
  width: 14px; height: 14px;
  color: var(--bbr-fg-soft);
  margin-left: var(--space-100);
}


/* --- Banner contestuale workspace cliente --- */
.bbr-banner {
  grid-area: banner;
  display: flex;
  align-items: center;
  gap: var(--space-300);
  padding: 10px var(--space-600);
  background: var(--bbr-context-soft);
  border-bottom: 1px solid var(--bbr-context-bd);
  font-size: var(--text-sm);
  color: var(--bbr-fg-primary);
  min-height: var(--banner-h);
}
.bbr-banner__dot {
  width: 8px; height: 8px;
  border-radius: var(--radius-full);
  background: var(--bbr-context);
  flex-shrink: 0;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--bbr-context) 25%, transparent);
}
.bbr-banner__label { color: var(--bbr-fg-muted); }
.bbr-banner__name {
  font-weight: var(--fw-semibold);
  color: var(--bbr-fg-primary);
}
.bbr-banner__exit { margin-left: auto; }


/* --- Main content --- */
.bbr-main {
  grid-area: main;
  padding: var(--space-800) var(--space-600) var(--space-1200);
  max-width: 100%;
  overflow-x: hidden;
}
.bbr-page {
  max-width: var(--container-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-800);
}
.bbr-page__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-400);
  flex-wrap: wrap;
}
.bbr-page__title-group { display: flex; flex-direction: column; gap: var(--space-200); }


/* =========================================================================
   BUTTONS
   ========================================================================= */

.bbr-btn {
  --_h: 36px;
  --_px: 14px;
  --_fs: var(--text-sm);

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-200);
  height: var(--_h);
  min-width: var(--_h);
  padding: 0 var(--_px);
  font-family: inherit;
  font-size: var(--_fs);
  font-weight: var(--fw-medium);
  line-height: 1;
  color: var(--bbr-fg-primary);
  background: var(--bbr-bg-surface);
  border: 1px solid var(--bbr-bd-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
  user-select: none;
}
.bbr-btn:hover { background: var(--bbr-bg-sunken); border-color: var(--bbr-bd-strong); }
.bbr-btn:active { transform: translateY(0.5px); }
.bbr-btn:disabled, .bbr-btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.bbr-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

/* Variants */
.bbr-btn--primary {
  background: var(--bbr-accent);
  border-color: var(--bbr-accent);
  color: var(--bbr-fg-on-accent);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.10),
    0 1px 2px rgba(15,18,30,0.10);
}
.bbr-btn--primary:hover {
  background: var(--bbr-accent-hover);
  border-color: var(--bbr-accent-hover);
}
.bbr-btn--primary:active {
  background: var(--bbr-accent-active);
  border-color: var(--bbr-accent-active);
}

.bbr-btn--secondary {
  /* alias del default — esiste per esplicitezza nel mark-up */
}

.bbr-btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--bbr-fg-secondary);
}
.bbr-btn--ghost:hover {
  background: var(--bbr-bg-sunken);
  border-color: transparent;
  color: var(--bbr-fg-primary);
}

.bbr-btn--destructive {
  background: var(--bbr-bg-surface);
  border-color: var(--bbr-bd-default);
  color: var(--bbr-red-fg);
}
.bbr-btn--destructive:hover {
  background: var(--bbr-red-soft);
  border-color: var(--bbr-red);
  color: var(--bbr-red-fg);
}
.bbr-btn--destructive-solid {
  background: var(--bbr-red);
  border-color: var(--bbr-red);
  color: white;
}
.bbr-btn--destructive-solid:hover {
  background: oklch(48% 0.20 25);
  border-color: oklch(48% 0.20 25);
}

/* Sizes */
.bbr-btn--sm { --_h: 28px; --_px: 10px; --_fs: var(--text-sm); }
.bbr-btn--lg { --_h: 44px; --_px: 18px; --_fs: var(--text-base); }
.bbr-btn--icon { --_px: 0; width: var(--_h); }

.bbr-btn--block { display: flex; width: 100%; }


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

.bbr-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-150);
}
.bbr-field__label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--bbr-fg-primary);
}
.bbr-field__hint {
  font-size: var(--text-sm);
  color: var(--bbr-fg-muted);
}
.bbr-field__error {
  font-size: var(--text-sm);
  color: var(--bbr-red-fg);
  display: flex;
  align-items: center;
  gap: var(--space-150);
}

.bbr-input,
.bbr-textarea,
.bbr-select {
  width: 100%;
  height: 38px;
  padding: 0 var(--space-300);
  font-family: inherit;
  font-size: var(--text-base);
  color: var(--bbr-fg-primary);
  background: var(--bbr-bg-surface);
  border: 1px solid var(--bbr-bd-default);
  border-radius: var(--radius-md);
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow   var(--dur-fast) var(--ease-out),
    background   var(--dur-fast) var(--ease-out);
}
.bbr-input::placeholder, .bbr-textarea::placeholder { color: var(--bbr-fg-soft); }
.bbr-input:hover, .bbr-textarea:hover, .bbr-select:hover { border-color: var(--bbr-bd-strong); }
.bbr-input:focus, .bbr-textarea:focus, .bbr-select:focus {
  border-color: var(--bbr-accent);
  box-shadow: var(--shadow-focus);
}
.bbr-input:disabled, .bbr-textarea:disabled, .bbr-select:disabled {
  background: var(--bbr-bg-sunken);
  color: var(--bbr-fg-muted);
  cursor: not-allowed;
}
.bbr-textarea { height: auto; padding: 10px var(--space-300); line-height: var(--lh-base); min-height: 96px; resize: vertical; }

.bbr-input--error,
.bbr-textarea--error,
.bbr-select--error {
  border-color: var(--bbr-red);
}
.bbr-input--error:focus { box-shadow: 0 0 0 3px color-mix(in oklch, var(--bbr-red) 25%, transparent); }

/* Select arrow custom — niente vendor default */
.bbr-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23636366' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: var(--space-800);
}

/* Input con icona leading */
.bbr-input-group {
  position: relative;
  display: flex;
  align-items: center;
}
.bbr-input-group__icon {
  position: absolute;
  left: 10px;
  width: 16px; height: 16px;
  color: var(--bbr-fg-soft);
  pointer-events: none;
}
.bbr-input-group .bbr-input { padding-left: 34px; }

/* Switch */
.bbr-switch { position: relative; display: inline-block; width: 36px; height: 20px; }
.bbr-switch input { opacity: 0; width: 0; height: 0; }
.bbr-switch__slider {
  position: absolute; inset: 0;
  background: var(--bbr-ink-5);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}
.bbr-switch__slider::before {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: white;
  border-radius: var(--radius-full);
  box-shadow: 0 1px 2px rgba(0,0,0,0.20);
  transition: transform var(--dur-fast) var(--ease-out);
}
.bbr-switch input:checked + .bbr-switch__slider { background: var(--bbr-accent); }
.bbr-switch input:checked + .bbr-switch__slider::before { transform: translateX(16px); }
.bbr-switch input:focus-visible + .bbr-switch__slider { box-shadow: var(--shadow-focus); }


/* =========================================================================
   CARDS
   ========================================================================= */

.bbr-card {
  background: var(--bbr-bg-surface);
  border: 1px solid var(--bbr-bd-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.bbr-card--elev { box-shadow: var(--shadow-sm); }
.bbr-card--interactive {
  cursor: pointer;
  transition:
    border-color var(--dur-fast) var(--ease-out),
    box-shadow   var(--dur-fast) var(--ease-out),
    transform    var(--dur-fast) var(--ease-out);
}
.bbr-card--interactive:hover {
  border-color: var(--bbr-bd-strong);
  box-shadow: var(--shadow-md);
}
.bbr-card__header {
  padding: var(--space-500) var(--space-500) var(--space-300);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-400);
}
.bbr-card__title { display: flex; flex-direction: column; gap: var(--space-050); }
.bbr-card__body { padding: var(--space-500); }
.bbr-card__body:not(:first-child) { padding-top: 0; }
.bbr-card__footer {
  padding: var(--space-300) var(--space-500);
  border-top: 1px solid var(--bbr-bd-soft);
  background: var(--bbr-bg-sunken);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-300);
}


/* --- KPI widget --- */
.bbr-kpi {
  display: flex;
  flex-direction: column;
  gap: var(--space-200);
  padding: var(--space-500);
  background: var(--bbr-bg-surface);
  border: 1px solid var(--bbr-bd-default);
  border-radius: var(--radius-lg);
}
.bbr-kpi__label {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  font-size: var(--text-sm);
  color: var(--bbr-fg-muted);
}
.bbr-kpi__label svg { width: 14px; height: 14px; }
/* Il numero di un KPI è UI, non marchio: va in Inter come il resto del cruscotto. Stava in
   --bbr-font-display (Space Grotesk), che la brand-guide riserva al marchio «Lenzuoli»: nel
   Report CRM i sei numeri uscivano in un font che non si usa da nessun'altra parte nell'app.
   Inter ha le cifre della stessa larghezza, quindi i numeri restano incolonnati. */
.bbr-kpi__value {
  font-family: var(--bbr-font-sans);
  font-size: var(--text-3xl);
  font-weight: 600;
  line-height: 1;
  letter-spacing: var(--tracking-tight);
  font-variant-numeric: tabular-nums;
  color: var(--bbr-fg-primary);
}
.bbr-kpi__delta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-100);
  font-size: var(--text-sm);
  color: var(--bbr-fg-muted);
}
.bbr-kpi__delta--up { color: var(--bbr-green-fg); }
.bbr-kpi__delta--down { color: var(--bbr-red-fg); }


/* =========================================================================
   TABLES
   ========================================================================= */

.bbr-table-wrap {
  background: var(--bbr-bg-surface);
  border: 1px solid var(--bbr-bd-default);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.bbr-table-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-300);
  padding: var(--space-300) var(--space-400);
  border-bottom: 1px solid var(--bbr-bd-soft);
}
.bbr-table-toolbar__search { flex: 1; max-width: 320px; }
.bbr-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}
.bbr-table thead th {
  text-align: left;
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--bbr-fg-muted);
  padding: var(--space-300) var(--space-400);
  background: var(--bbr-bg-sunken);
  border-bottom: 1px solid var(--bbr-bd-default);
  white-space: nowrap;
}
.bbr-table tbody td {
  padding: var(--space-300) var(--space-400);
  border-bottom: 1px solid var(--bbr-bd-soft);
  color: var(--bbr-fg-primary);
  vertical-align: middle;
}
.bbr-table tbody tr:last-child td { border-bottom: none; }
.bbr-table tbody tr {
  transition: background var(--dur-fast) var(--ease-out);
}
.bbr-table tbody tr:hover { background: var(--bbr-bg-sunken); }
.bbr-table td.bbr-table__cell--muted { color: var(--bbr-fg-muted); }
.bbr-table td.bbr-table__cell--num   { font-variant-numeric: tabular-nums; }
.bbr-table td.bbr-table__cell--actions { text-align: right; }

.bbr-table__sort {
  display: inline-flex;
  align-items: center;
  gap: var(--space-100);
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  padding: 0;
  text-transform: inherit;
  letter-spacing: inherit;
}
.bbr-table__sort:hover { color: var(--bbr-fg-primary); }


/* =========================================================================
   BADGES + STATUS DOTS
   ========================================================================= */

.bbr-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-150);
  padding: var(--space-050) var(--space-200);
  height: 22px;
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-full);
  background: var(--bbr-bg-sunken);
  color: var(--bbr-fg-secondary);
  border: 1px solid var(--bbr-bd-soft);
  white-space: nowrap;
}
.bbr-badge--success { background: var(--bbr-green-soft); color: var(--bbr-green-fg); border-color: transparent; }
.bbr-badge--warning { background: var(--bbr-amber-soft); color: var(--bbr-amber-fg); border-color: transparent; }
.bbr-badge--danger  { background: var(--bbr-red-soft);   color: var(--bbr-red-fg);   border-color: transparent; }
.bbr-badge--accent  { background: var(--bbr-accent-soft);color: var(--bbr-accent-soft-fg); border-color: transparent; }

.bbr-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: var(--radius-full);
  background: var(--bbr-ink-4);
  flex-shrink: 0;
}
.bbr-dot--success { background: var(--bbr-green); }
.bbr-dot--warning { background: var(--bbr-amber); }
.bbr-dot--danger  { background: var(--bbr-red); }
.bbr-dot--accent  { background: var(--bbr-accent); }
.bbr-dot--pulse {
  box-shadow: 0 0 0 0 currentColor;
  animation: bbr-pulse 1.8s var(--ease-out) infinite;
  color: var(--bbr-green);
}
@keyframes bbr-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklch, currentColor 40%, transparent); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}


/* =========================================================================
   AVATAR
   ========================================================================= */

.bbr-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--bbr-bg-sunken);
  color: var(--bbr-fg-secondary);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  overflow: hidden;
  flex-shrink: 0;
}
.bbr-avatar--sm { width: 24px; height: 24px; font-size: 11px; }
.bbr-avatar--lg { width: 44px; height: 44px; font-size: var(--text-base); }
.bbr-avatar img { width: 100%; height: 100%; object-fit: cover; }


/* =========================================================================
   DROPDOWN / MENU
   ========================================================================= */

.bbr-menu {
  background: var(--bbr-bg-elev);
  border: 1px solid var(--bbr-bd-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-100);
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: var(--space-025);
}
.bbr-menu__group + .bbr-menu__group {
  border-top: 1px solid var(--bbr-bd-soft);
  margin-top: var(--space-100);
  padding-top: var(--space-100);
}
.bbr-menu__label {
  padding: var(--space-150) 10px var(--space-050);
  font-size: var(--text-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--bbr-fg-soft);
}
.bbr-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-200);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--bbr-fg-primary);
  cursor: pointer;
  text-decoration: none;
  background: transparent;
  border: none;
  text-align: left;
  width: 100%;
  font-family: inherit;
  transition: background var(--dur-fast) var(--ease-out);
}
.bbr-menu__item:hover { background: var(--bbr-bg-sunken); }
.bbr-menu__item svg { width: 14px; height: 14px; color: var(--bbr-fg-soft); flex-shrink: 0; }
.bbr-menu__item__body {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;             /* permette il truncate del figlio */
  gap: var(--space-025);
}
.bbr-menu__item__body > :first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bbr-menu__item--danger { color: var(--bbr-red-fg); }
.bbr-menu__item--danger svg { color: var(--bbr-red); }
.bbr-menu__item-kbd { margin-left: auto; }


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

.bbr-modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bbr-bg-overlay);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-500);
  z-index: 100;
  animation: bbr-fadein var(--dur-base) var(--ease-out);
}
.bbr-modal {
  background: var(--bbr-bg-surface);
  border: 1px solid var(--bbr-bd-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - var(--space-1200));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: bbr-modalin var(--dur-base) var(--ease-out);
}
.bbr-modal--lg { max-width: 640px; }
.bbr-modal__header {
  padding: var(--space-500) var(--space-500) var(--space-300);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-300);
}
.bbr-modal__title { display: flex; flex-direction: column; gap: var(--space-100); }
.bbr-modal__body  { padding: var(--space-200) var(--space-500) var(--space-500); overflow-y: auto; }
.bbr-modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-200);
  padding: var(--space-400) var(--space-500);
  background: var(--bbr-bg-sunken);
  border-top: 1px solid var(--bbr-bd-soft);
}
.bbr-modal__close {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--bbr-fg-muted);
  cursor: pointer;
  padding: var(--space-100);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
}
.bbr-modal__close:hover { background: var(--bbr-bg-sunken); color: var(--bbr-fg-primary); }

@keyframes bbr-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes bbr-modalin {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0)  scale(1); }
}


/* =========================================================================
   TOASTS
   ========================================================================= */

.bbr-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-300);
  padding: var(--space-300) var(--space-400);
  background: var(--bbr-bg-elev);
  border: 1px solid var(--bbr-bd-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  min-width: 280px;
  max-width: 420px;
  color: var(--bbr-fg-primary);
  font-size: var(--text-sm);
}
.bbr-toast__icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: var(--space-050); }
.bbr-toast__body { flex: 1; }
.bbr-toast__title { font-weight: var(--fw-medium); }
.bbr-toast--success .bbr-toast__icon { color: var(--bbr-green); }
.bbr-toast--error   .bbr-toast__icon { color: var(--bbr-red); }
.bbr-toast--info    .bbr-toast__icon { color: var(--bbr-accent); }


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

.bbr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-1200) var(--space-500);
  gap: var(--space-300);
  color: var(--bbr-fg-muted);
}
.bbr-empty__icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bbr-bg-sunken);
  color: var(--bbr-fg-soft);
  border-radius: var(--radius-md);
}
.bbr-empty__title {
  font-size: var(--text-lg);
  font-weight: var(--fw-medium);
  color: var(--bbr-fg-primary);
}


/* =========================================================================
   SKELETON
   ========================================================================= */

.bbr-skel {
  display: block;
  background: linear-gradient(
    90deg,
    var(--bbr-bg-sunken) 0%,
    color-mix(in oklch, var(--bbr-bg-sunken) 60%, var(--bbr-ink-5)) 50%,
    var(--bbr-bg-sunken) 100%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-sm);
  animation: bbr-shimmer 1.4s var(--ease-in-out) infinite;
  height: 12px;
}
@keyframes bbr-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}


/* =========================================================================
   RESPONSIVE — collassi base
   ========================================================================= */

@media (max-width: 960px) {
  .bbr-app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "header"
      "main";
  }
  .bbr-app--with-banner {
    grid-template-areas:
      "banner"
      "header"
      "main";
  }
  .bbr-sidebar { display: none; } /* sostituire con drawer mobile in futuro */
  .bbr-main    { padding: var(--space-500) var(--space-400) var(--space-800); }
  .bbr-page    { gap: var(--space-600); }
}

@media (max-width: 640px) {
  .bbr-header { padding: 0 var(--space-400); gap: var(--space-200); }
  .bbr-ws-switcher__role { display: none; }
  .bbr-page__header { align-items: flex-start; }
}
