:root {
  --pf-bg: #f4f7fb;
  --pf-sidebar: #101828;
  --pf-primary: #465fff;
  --pf-primary-soft: #eef0ff;
  --pf-text: #101828;
  --pf-muted: #667085;
  --pf-border: #e4e7ec;
  --pf-card: #ffffff;
  --pf-radius: 22px;
}

body {
  min-height: 100vh;
  background: var(--pf-bg);
  color: var(--pf-text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
  width: 200px;
  background: radial-gradient(circle at top left, #344054 0, var(--pf-sidebar) 38%, #0b1220 100%);
  color: #fff;
  padding: 22px 14px;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 1040;
  overflow-y: auto;
}
.brand-mark {
  width: 44px; height: 44px; display: inline-grid; place-items: center;
  border-radius: 16px; background: linear-gradient(135deg, #5d6bff, #9b7bff);
  box-shadow: 0 14px 35px rgba(70, 95, 255, .35);
}
.sidebar .nav-link {
  color: rgba(255,255,255,.72); border-radius: 14px; padding: 12px 14px;
  margin-bottom: 6px; display: flex; align-items: center; gap: 12px; transition: .2s ease;
}
.sidebar .nav-link:hover, .sidebar .nav-link.active { color: #fff; background: rgba(255,255,255,.11); }
.sidebar-footer { border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.07); border-radius: 20px; padding: 16px; margin-top: 26px; }
.main-content { width: 100%; margin-left: 200px; padding: 26px; }
.topbar {
  background: rgba(255,255,255,.78); backdrop-filter: blur(16px);
  border: 1px solid rgba(228,231,236,.9); border-radius: var(--pf-radius);
  padding: 14px 18px; position: sticky; top: 18px; z-index: 1020;
  box-shadow: 0 16px 40px rgba(16, 24, 40, .06);
}
.page-title { font-weight: 800; letter-spacing: -.035em; }
.soft-card { background: var(--pf-card); border: 1px solid var(--pf-border); border-radius: var(--pf-radius); box-shadow: 0 18px 50px rgba(16,24,40,.06); }
.stat-card { padding: 20px; overflow: hidden; position: relative; }
.stat-card::after { content:""; position:absolute; right:-30px; top:-30px; width:120px; height:120px; border-radius:50%; background:var(--pf-primary-soft); z-index:0; }
.stat-card > * { position: relative; z-index: 1; }
.icon-bubble { width:46px; height:46px; display:inline-grid; place-items:center; border-radius:16px; background:var(--pf-primary-soft); color:var(--pf-primary); font-size:1.25rem; }
.badge-status { border-radius:999px; padding:.48rem .72rem; font-weight:700; font-size:.72rem; letter-spacing:.01em; white-space: nowrap; }
.status-todo { background:#f2f4f7; color:#344054; }
.status-progress { background:#eaf1ff; color:#175cd3; }
.status-standby { background:#fffaeb; color:#b54708; }
.status-review { background:#f4ebff; color:#6941c6; }
.status-approved { background:#ecfdf3; color:#067647; }
.status-print { background:#fff4ed; color:#c4320a; }
.status-delivered { background:#e7f8ef; color:#05603a; }
.priority-dot { width:10px; height:10px; border-radius:50%; display:inline-block; }
.dot-high { background:#f04438; } .dot-medium { background:#f79009; } .dot-low { background:#12b76a; }
.table-modern th { color:var(--pf-muted); font-size:.78rem; text-transform:uppercase; letter-spacing:.04em; font-weight:800; background:#f9fafb; }
.table-modern td, .table-modern th { padding:15px 16px; vertical-align:middle; border-color:var(--pf-border); }
.avatar, .avatar-sm { display:inline-grid; place-items:center; border-radius:50%; background:linear-gradient(135deg,#eef0ff,#f4ebff); color:#465fff; font-weight:800; border:2px solid #fff; }
.avatar { width:42px; height:42px; } .avatar-sm { width:32px; height:32px; font-size:.78rem; margin-left:-8px; }
.avatar-stack { display:flex; align-items:center; }
.search-wrap { position:relative; } .search-wrap i { position:absolute; left:15px; top:50%; transform:translateY(-50%); color:var(--pf-muted); }
.search-input { background:#f9fafb; border:1px solid var(--pf-border); border-radius:16px; padding-left:42px; }
.form-control, .form-select { border-radius:14px; border-color:var(--pf-border); padding:.72rem .9rem; }
.btn { border-radius:14px; font-weight:700; }
.btn-primary { background:var(--pf-primary); border-color:var(--pf-primary); box-shadow:0 12px 24px rgba(70,95,255,.22); }
.btn-light { background:#fff; border-color:var(--pf-border); }
.timeline { position:relative; padding-left:26px; }
.timeline::before { content:""; position:absolute; left:9px; top:4px; bottom:4px; width:2px; background:var(--pf-border); }
.timeline-item { position:relative; padding-bottom:20px; }
.timeline-item::before { content:""; position:absolute; left:-22px; top:4px; width:12px; height:12px; border-radius:50%; background:var(--pf-primary); box-shadow:0 0 0 4px #eef0ff; }
.file-card { border:1px dashed #cbd5e1; border-radius:18px; padding:16px; background:#fbfcff; }
.upload-box { min-height:160px; border:2px dashed #cbd5e1; border-radius:22px; background:linear-gradient(180deg,#fff,#f9fafb); display:grid; place-items:center; text-align:center; padding:24px; }
.mobile-toggle { display:none; }
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); transition:.24s ease; }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left:0; padding:16px; }
  .mobile-toggle { display:inline-flex; }
  .topbar { top:10px; }
}

/* Card list layout inspired by modern packaging dashboards */
.listing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.listing-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.entity-card {
  position: relative;
  min-height: 230px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--pf-border);
  border-radius: 18px;
  box-shadow: 0 12px 36px rgba(16,24,40,.045);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
  overflow: hidden;
}

.entity-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 48px rgba(16,24,40,.08);
  border-color: #d0d5dd;
}

.entity-card.project-card {
  min-height: 330px;
}

.entity-card.user-card {
  min-height: 260px;
}

.card-status-ribbon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  border-radius: 0 0 10px 10px;
  padding: 9px 14px;
  margin: -18px 0 16px -6px;
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.card-status-ribbon.status-todo,
.card-status-ribbon.status-progress,
.card-status-ribbon.status-standby,
.card-status-ribbon.status-review,
.card-status-ribbon.status-approved,
.card-status-ribbon.status-print,
.card-status-ribbon.status-delivered {
  border-radius: 0 0 10px 10px;
}

.card-status-ribbon.is-active { background:#22c55e; color:#fff; }
.card-status-ribbon.is-paused { background:#94a3b8; color:#fff; }
.card-status-ribbon.is-client { background:#3b82f6; color:#fff; }
.card-status-ribbon.is-bemark { background:#10b981; color:#fff; }
.card-status-ribbon.is-superadmin { background:#111827; color:#fff; }

.card-top-action {
  position: absolute;
  right: 16px;
  top: 16px;
}

.card-title-strong {
  font-size: 1.05rem;
  font-weight: 850;
  line-height: 1.18;
  letter-spacing: -.02em;
  color: var(--pf-text);
}

.card-subtitle-muted {
  color: #7b8da8;
  font-size: .78rem;
  line-height: 1.25;
}

.card-meta-stack {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.card-meta-label {
  display: block;
  font-size: .72rem;
  color: #7b8da8;
  font-weight: 750;
  line-height: 1.1;
}

.card-meta-value {
  display: block;
  font-size: .88rem;
  color: #1f2937;
  font-weight: 750;
  line-height: 1.2;
}

.card-meta-value.text-danger,
.card-meta-danger {
  color: #ef4444 !important;
}

.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 18px;
}

.mini-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #64748b;
  font-size: .74rem;
  font-weight: 750;
  padding: .35rem .55rem;
}

.avatar-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.avatar-dot {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: #dcfce7;
  color: #166534;
  font-size: .68rem;
  font-weight: 850;
  border: 2px solid #fff;
  box-shadow: 0 4px 14px rgba(16,24,40,.08);
}

.avatar-dot.client { background:#fce7f3; color:#9d174d; }
.avatar-dot.superadmin { background:#e5e7eb; color:#111827; }

.report-timeline {
  position: relative;
  display: grid;
  gap: 12px;
}

.report-item {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--pf-border);
  border-radius: 18px;
  background: linear-gradient(180deg, #fff, #fbfcff);
}

.report-icon {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border-radius: 16px;
  background: var(--pf-primary-soft);
  color: var(--pf-primary);
  font-size: 1.1rem;
}

.report-title {
  font-weight: 850;
  letter-spacing: -.01em;
}

.report-description {
  color: var(--pf-muted);
  font-size: .9rem;
  margin-top: 2px;
}

.report-time {
  color: #98a2b3;
  font-size: .78rem;
  font-weight: 700;
  margin-top: 6px;
}

@media (max-width: 575px) {
  .listing-grid { grid-template-columns: 1fr; }
  .entity-card { min-height: auto; }
}
.avatar.client { background:linear-gradient(135deg,#fce7f3,#ffe4e6); color:#9d174d; }
.avatar.superadmin { background:linear-gradient(135deg,#e5e7eb,#f3f4f6); color:#111827; }

/* Client-oriented refinement patch */
.project-card.phase-overdue-card {
  border-color: rgba(220, 38, 38, .65) !important;
  box-shadow: 0 0 0 1px rgba(220, 38, 38, .08), 0 18px 42px rgba(220, 38, 38, .10);
}

.phase-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  width: fit-content;
  border-radius: 999px;
  padding: .36rem .62rem;
  font-size: .72rem;
  font-weight: 800;
  border: 1px solid rgba(148, 163, 184, .28);
  margin-bottom: 12px;
}

.phase-client { background:#eef2ff; color:#3730a3; }
.phase-commercial { background:#ecfeff; color:#155e75; }
.phase-technical { background:#f0fdf4; color:#166534; }
.phase-brief { background:#fff7ed; color:#9a3412; }
.phase-bemark { background:#eff6ff; color:#1d4ed8; }
.phase-approval { background:#f5f3ff; color:#6d28d9; }
.phase-print { background:#fff1f2; color:#be123c; }
.phase-closed { background:#f3f4f6; color:#374151; }
.phase-default { background:#f8fafc; color:#475569; }

.dashboard-project-grid {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

/* Patch UI 2026-07-13: totalizzatori riepilogo + ricerca con icona */
.stat-card.bg-danger-subtle::after,
.stat-card.border-danger-subtle::after {
  background: rgba(220, 38, 38, .15) !important;
}

.stat-card.bg-warning-subtle::after,
.stat-card.border-warning-subtle::after {
  background: rgba(245, 158, 11, .24) !important;
}

.stat-card.bg-success-subtle::after,
.stat-card.border-success-subtle::after {
  background: rgba(22, 163, 74, .16) !important;
}

.stat-card.bg-info-subtle::after,
.stat-card.border-info-subtle::after {
  background: rgba(14, 165, 233, .16) !important;
}

.search-wrap {
  position: relative;
}

.search-wrap i,
.search-wrap .bi-search {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--pf-muted);
  z-index: 2;
  pointer-events: none;
  line-height: 1;
}

.search-wrap .search-input,
.search-wrap input.form-control {
  padding-left: 52px !important;
}


/* Patch UI compatta: sidebar ridotta, titoli e card utenti */
.main-content h2,
.main-content .h2 {
  font-size: clamp(1.25rem, 1vw + .9rem, 1.65rem);
  line-height: 1.15;
}

.sidebar .nav-link {
  padding: 11px 12px;
  gap: 10px;
}

.sidebar .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 14px;
}

.sidebar .client-brand-logo-card {
  padding: 12px;
  border-radius: 18px;
}

.sidebar .client-brand-title {
  font-size: 1rem;
  line-height: 1.16;
}

.sidebar .client-brand-subtitle {
  font-size: .78rem;
}

.responsibilities-grid {
  align-items: stretch;
}

.responsibilities-grid .user-card-link {
  height: 100%;
}

.responsibilities-grid .responsibility-user-card {
  min-height: 560px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.responsibilities-grid .phase-count-list {
  margin-top: 1rem;
}

.responsibilities-grid .phase-count-row {
  min-height: 36px;
}

@media (max-width: 991px) {
  .sidebar { width: 260px; padding: 24px 18px; }
  .main-content { margin-left: 0; }
}


/* Patch UI compatta 2: titoli, spaziature e fornitori */
.main-content h1,
.main-content .h1,
.page-title {
  font-size: clamp(1.55rem, 1.15vw + 1.05rem, 2.05rem);
  line-height: 1.12;
  letter-spacing: -.04em;
}

.main-content h2,
.main-content .h2 {
  font-size: clamp(1.18rem, .85vw + .9rem, 1.5rem);
}

.main-content h3,
.main-content .h3 {
  font-size: clamp(1.05rem, .65vw + .86rem, 1.28rem);
}

.main-content h4,
.main-content .h4 {
  font-size: 1rem;
}

.main-content {
  padding: 22px;
}

.topbar {
  padding: 12px 16px;
  border-radius: 18px;
}

.soft-card {
  border-radius: 18px;
}

.soft-card.p-4 {
  padding: 1.25rem !important;
}

.soft-card.p-5 {
  padding: 1.75rem !important;
}

.entity-card {
  padding: 16px;
  min-height: 210px;
  border-radius: 17px;
}

.entity-card.project-card {
  min-height: 300px;
}

.entity-card.supplier-card {
  min-height: 275px;
  cursor: pointer;
}

.entity-card.supplier-card .card-meta-stack {
  margin-top: 16px;
  gap: 8px;
}

.entity-card.supplier-card .card-title-strong {
  padding-right: 42px;
}

.entity-card.supplier-card .supplier-status-row {
  margin-top: auto;
  padding-top: 16px;
}

.entity-card.supplier-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 48px rgba(15, 23, 42, .10);
}

.card-meta-stack {
  gap: 8px;
  margin-top: 18px;
}

.card-title-strong {
  font-size: 1rem;
}

.card-subtitle-muted {
  font-size: .76rem;
}

.form-control,
.form-select {
  min-height: 42px;
  padding-top: .62rem;
  padding-bottom: .62rem;
}

.btn {
  padding-top: .55rem;
  padding-bottom: .55rem;
}

.btn-sm {
  padding-top: .32rem;
  padding-bottom: .32rem;
}

.badge-status,
.badge.rounded-pill {
  font-size: .70rem;
}

@media (max-width: 991px) {
  .main-content { padding: 16px; }
}

/* Packstage: select ricercabili della gerarchia e del Brand */
.pack-searchable-select { position: relative; width: 100%; }
.pack-searchable-select-native { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; opacity: 0 !important; pointer-events: none !important; }
.pack-searchable-trigger { position: relative; display: flex; align-items: center; width: 100%; min-height: 39px; padding-right: 2.2rem !important; cursor: pointer; text-align: left; background-image: none !important; overflow: hidden; white-space: nowrap; }
.pack-searchable-trigger:after { content: ''; position: absolute; right: 1.15rem; top: calc(50% - 4px); width: 8px; height: 8px; border-right: 1.7px solid currentColor; border-bottom: 1.7px solid currentColor; transform: rotate(45deg); pointer-events: none; }
.pack-searchable-value { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pack-searchable-trigger.pack-searchable-placeholder { color: #667085; }
.pack-searchable-trigger:focus-visible { outline: 2px solid var(--pf-primary, #465fff); outline-offset: 1px; }
.pack-searchable-popup { position: fixed; z-index: 2050; display: flex; flex-direction: column; min-width: 170px; border: 1px solid #d0d5dd; border-radius: 12px; background: #fff; box-shadow: 0 15px 40px rgba(16,24,40,.19); padding: 6px; overflow: hidden; color: #1d2939; }
.pack-searchable-input-wrap { flex: 0 0 auto; padding: 3px 3px 7px; }
.pack-searchable-input { min-height: 37px; font-size: 14px; }
.pack-searchable-options { overflow-y: auto; min-height: 0; flex: 1; overscroll-behavior: contain; }
.pack-searchable-option { display: block; width: 100%; background: none; border: 0; border-radius: 7px; padding: 9px 11px; text-align: left; color: inherit; line-height: 1.3; cursor: pointer; font-size: 14px; }
.pack-searchable-option:hover, .pack-searchable-option.active { background: #eef2ff; color: #1d2939; }
.pack-searchable-option.pack-searchable-selected { font-weight: 700; }
.pack-searchable-no-results { padding: 13px; color: #667085; font-size: 14px; }
.pack-searchable-status { flex: 0 0 auto; padding: 6px 9px 2px; border-top: 1px solid #eaecf0; color: #667085; font-size: 12px; }
