/* ===========================
   RESET BASE
   =========================== */
* {
  box-sizing: border-box;
}

:root {
  --bg-app: #f4f7fb;
  --bg-surface: #ffffff;
  --bg-surface-soft: #f8fafc;
  --border-color: #e5e7eb;
  --border-strong: #dbe3ee;
  --text-main: #0f172a;
  --text-soft: #64748b;
  --text-muted: #94a3b8;
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.10);
  --primary-soft-2: rgba(37, 99, 235, 0.16);
  --success: #16a34a;
  --danger: #dc2626;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --sidebar-width: 272px;
  --sidebar-collapsed-width: 82px;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg-app);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===========================
   LAYOUT APP SHELL
   =========================== */
.app-shell {
  display: flex;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.05), transparent 26%),
    linear-gradient(180deg, #f8fbff 0%, #f4f7fb 100%);
}

/* ===========================
   SIDEBAR
   =========================== */
.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.04);
  transition:
    width .22s ease,
    flex-basis .22s ease,
    padding .22s ease;
}

.sidebar__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 8px;
}

.sidebar__brand {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.sidebar__brandLink {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
  max-width: 100%;
  padding: 6px 8px;
  border-radius: 14px;
  transition: background .18s ease, transform .18s ease;
}

.sidebar__brandLink:hover {
  background: rgba(148, 163, 184, 0.08);
}

.sidebar__brandLogo {
  height: 42px;
  width: auto;
  max-width: 100%;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 10px rgba(37, 99, 235, 0.10));
}

.sidebar__brandText {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}

.sidebar__brandText strong {
  font-size: 15px;
  font-weight: 900;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__brandText small {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.68);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar__toggle {
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.82);
  box-shadow: none;
  transition: all .18s ease;
  flex: 0 0 38px;
}

.sidebar__toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 0;
}

.sidebar__navMain {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.sidebar__nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  text-decoration: none;
  color: rgba(255, 255, 255, 0.96);
  border: 1px solid transparent;
  transition:
    background .16s ease,
    border-color .16s ease,
    color .16s ease,
    transform .16s ease,
    box-shadow .16s ease;
}

.sidebar__nav a:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(255, 255, 255, 0.10);
  color: #ffffff;
  transform: translateX(1px);
}

.sidebar__nav a:hover .sidebar-label {
  color: #ffffff;
}

.sidebar__nav a:hover .sidebar-ico {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.sidebar__nav a.is-active {
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.24), rgba(37, 99, 235, 0.20));
  border-color: rgba(96, 165, 250, 0.34);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 8px 18px rgba(37, 99, 235, 0.18);
  transform: translateX(2px);
}

.sidebar__nav hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  margin: 8px 2px;
}

.sidebar-ico {
  width: 32px;
  height: 32px;
  min-width: 32px;
  flex: 0 0 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-size: 16px;
  line-height: 1;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}

.sidebar-label {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: font-size .16s ease, font-weight .16s ease, color .16s ease;
}

.sidebar__nav a.is-active .sidebar-label {
  color: #ffffff;
  font-size: 15px;
  font-weight: 900;
}

.sidebar__nav a.is-active .sidebar-ico {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.sidebar__bottom {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.10);
}

.sidebar__bottom a {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.sidebar__bottom a .sidebar-ico {
  background: rgba(255, 255, 255, 0.14);
}

.sidebar__bottom a:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.14);
}

.sidebar__bottom a:hover .sidebar-ico {
  background: rgba(255, 255, 255, 0.20);
}

.sidebar__bottom a .sidebar-label {
  font-weight: 900;
}

/* compatibilità minima legacy */
.sidebar__sectionTitle {
  margin-top: 10px;
  font-size: 12px;
  opacity: .7;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 12px;
  text-decoration: none;
  color: #111827;
}

.sidebar__link:hover {
  background: #f3f4f6;
}

.sidebar__icon {
  width: 22px;
  text-align: center;
  flex: 0 0 22px;
}

.sidebar__text {
  white-space: nowrap;
}

.sidebar__logoutForm {
  margin: 0;
}

.sidebar__link--danger {
  width: 100%;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: #991b1b;
  padding: 10px 10px;
  border-radius: 12px;
}

.sidebar__link--danger:hover {
  background: #fee2e2;
}
/* ===========================
   MAIN / TOPBAR / CONTENT
   =========================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(219, 227, 238, 0.85);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.topbar__title {
  min-width: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.content {
  padding: 22px;
}

/* ===========================
   PROPERTY SELECTOR
   =========================== */
.prop-select {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border-color);
  padding: 8px 10px;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  flex-wrap: wrap;
}

.prop-select label {
  font-size: 12px;
  font-weight: 900;
  color: var(--text-soft);
  opacity: 1;
  white-space: nowrap;
}

.prop-select select {
  min-width: 180px;
  height: 44px;
  min-height: 44px;
  padding: 10px 40px 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: #fff;
  font-weight: 800;
  color: var(--text-main);
  -webkit-appearance: none;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.prop-select__value {
  font-weight: 900;
  color: var(--text-main);
}
/* ===========================
   SIDEBAR COLLAPSED
   =========================== */
body.sidebar-collapsed .sidebar {
  width: var(--sidebar-collapsed-width);
  flex-basis: var(--sidebar-collapsed-width);
  padding-left: 10px;
  padding-right: 10px;
}

body.sidebar-collapsed .sidebar__brand {
  justify-content: center;
}

body.sidebar-collapsed .sidebar__brandText,
body.sidebar-collapsed .sidebar__text,
body.sidebar-collapsed .sidebar__sectionTitle,
body.sidebar-collapsed .sidebar-label {
  display: none !important;
}

body.sidebar-collapsed .sidebar__brandLink {
  justify-content: center;
  align-items: center;
  padding-left: 0;
  padding-right: 0;
}

body.sidebar-collapsed .sidebar__brandLogo {
  height: 36px;
}

body.sidebar-collapsed .sidebar__nav {
  align-items: center;
}

body.sidebar-collapsed .sidebar__nav a {
  width: 100%;
  justify-content: center;
  gap: 0;
  padding-left: 0;
  padding-right: 0;
  position: relative;
}

body.sidebar-collapsed .sidebar__nav hr {
  width: 70%;
  margin-left: auto;
  margin-right: auto;
}

body.sidebar-collapsed .sidebar__nav a:hover::after {
  content: attr(data-label);
  position: absolute;
  left: 84px;
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #fff;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.10);
  z-index: 9999;
  pointer-events: none;
}

body.sidebar-collapsed .sidebar__nav a:hover::before {
  content: "";
  position: absolute;
  left: 76px;
  top: 50%;
  transform: translateY(-50%);
  border-width: 7px;
  border-style: solid;
  border-color: transparent #0f172a transparent transparent;
  z-index: 9999;
  pointer-events: none;
}
/* ===========================
   COMPONENTI UI
   =========================== */
.card {
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: var(--radius-lg);
  padding: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-sm);
}

label {
  font-size: 13px;
  opacity: .92;
  color: var(--text-soft);
}

/* form controls */
input,
select {
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--text-main);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
  font: inherit;
  line-height: 1.2;
}

textarea {
  width: 100%;
  height: 120px;
  min-height: 120px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--text-main);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
  font: inherit;
  line-height: 1.4;
  resize: none;
}

select {
  -webkit-appearance: none;
  appearance: none;
  padding-right: 40px;
  background-image:
    linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, 0.36);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

/* ===========================
   BUTTONS
   =========================== */
button {
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
  background: none;
}

.btn {
  display: inline-block;
  padding: 9px 13px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  cursor: pointer;
  font-weight: 900;
  font-size: 14px;
  line-height: 1.2;
  background: #ffffff;
  color: var(--text-main);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition:
    transform .16s ease,
    opacity .16s ease,
    box-shadow .16s ease,
    border-color .16s ease;
}

.btn:hover,
.btn-primary:hover,
.btn-danger:hover {
  opacity: .96;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary,
.btn.btn-primary {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  border-color: #2563eb;
  color: #ffffff;
}

.btn-danger,
.btn.btn-danger {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  border-color: #dc2626;
  color: #ffffff;
}

.btn:disabled,
button:disabled {
  opacity: .6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button,
.btn,
.btn-primary,
.btn-danger {
  -webkit-text-fill-color: currentColor;
}

/* ===========================
   TABELLE / DETTAGLI
   =========================== */
.price-details-row td {
  background: #f8fafc;
  border-top: none;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px 18px;
  padding: 10px 6px;
}

.details-reason {
  grid-column: 1 / -1;
  opacity: 0.92;
  color: var(--text-soft);
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (max-width: 960px) {
  .topbar {
    padding: 14px 16px;
  }

  .content {
    padding: 16px;
  }

  .prop-select select {
    min-width: 140px;
  }

  .details-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .sidebar {
    width: 88px;
    flex-basis: 88px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .sidebar__brandText,
  .sidebar-label {
    display: none;
  }

  .sidebar__brand {
    justify-content: center;
  }

  .sidebar__brandLink {
    justify-content: center;
    align-items: center;
    padding-left: 0;
    padding-right: 0;
  }

  .sidebar__nav a {
    justify-content: center;
    gap: 0;
    padding-left: 0;
    padding-right: 0;
  }

  .topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .topbar__title {
    font-size: 18px;
  }

  .prop-select {
    width: 100%;
    justify-content: space-between;
  }

  .prop-select select {
    min-width: 0;
    width: auto;
    flex: 1;
  }

  .details-grid {
    grid-template-columns: 1fr;
  }
}

/* ===========================
   DASHBOARD / KPI / WIDGETS PREMIUM
   =========================== */
.dashboard-grid {
  display: grid;
  gap: 18px;
}

.dashboard-grid--kpi {
  grid-template-columns: repeat(4, minmax(220px, 1fr));
}

.dashboard-grid--2 {
  grid-template-columns: repeat(2, minmax(320px, 1fr));
}

.dashboard-grid--3 {
  grid-template-columns: repeat(3, minmax(260px, 1fr));
}

.card {
  position: relative;
  overflow: hidden;
}

.card--premium {
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.96) 100%);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.05),
    0 10px 30px rgba(15, 23, 42, 0.06);
}

.card--premium::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb 0%, #22c55e 100%);
  opacity: 0.95;
}

.card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.card__titleWrap {
  min-width: 0;
}

.card__title {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: -0.01em;
  color: #0f172a;
}

.card__subtitle {
  margin: 4px 0 0;
  font-size: 12px;
  color: #64748b;
  font-weight: 700;
}

.card__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.kpi-card {
  position: relative;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(248,250,252,0.96) 100%);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.05),
    0 10px 28px rgba(15, 23, 42, 0.06);
}

.kpi-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-card__label {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}

.kpi-card__icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(37, 99, 235, 0.10);
  color: #2563eb;
  font-size: 18px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
}

.kpi-card__value {
  font-size: 32px;
  line-height: 1;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.kpi-card__meta {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.kpi-card__hint {
  font-size: 12px;
  color: #64748b;
  font-weight: 700;
}

.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid transparent;
}

.kpi-trend--up {
  background: rgba(22, 163, 74, 0.10);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.18);
}

.kpi-trend--down {
  background: rgba(220, 38, 38, 0.10);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.18);
}

.kpi-trend--neutral {
  background: rgba(100, 116, 139, 0.10);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.18);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.section-header__title {
  margin: 0;
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: #0f172a;
}

.section-header__subtitle {
  margin: 4px 0 0;
  font-size: 13px;
  color: #64748b;
  font-weight: 700;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.toolbar--card {
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(226, 232, 240, 0.95);
  background: rgba(255,255,255,0.88);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.toolbar .field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar .field-inline label {
  margin: 0;
  white-space: nowrap;
  font-weight: 800;
}

.chart-card {
  min-height: 360px;
}

.chart-card__body {
  position: relative;
  min-height: 280px;
}

.chart-placeholder {
  min-height: 280px;
  border-radius: 14px;
  border: 1px dashed rgba(148, 163, 184, 0.45);
  background:
    linear-gradient(180deg, rgba(248,250,252,0.9) 0%, rgba(255,255,255,0.9) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-weight: 800;
  font-size: 14px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid rgba(226, 232, 240, 0.95);
  border-radius: 18px;
  background: rgba(255,255,255,0.96);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.table-premium {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
}

.table-premium thead th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 900;
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.table-premium tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid #eef2f7;
  color: #0f172a;
  font-size: 14px;
  vertical-align: middle;
}

.table-premium tbody tr:hover td {
  background: rgba(37, 99, 235, 0.03);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  font-weight: 900;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge--blue {
  background: rgba(37, 99, 235, 0.10);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.18);
}

.badge--green {
  background: rgba(22, 163, 74, 0.10);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.18);
}

.badge--amber {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.22);
}

.badge--red {
  background: rgba(220, 38, 38, 0.10);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.18);
}

.badge--slate {
  background: rgba(100, 116, 139, 0.10);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.18);
}

.stats-list {
  display: grid;
  gap: 12px;
}

.stats-list__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(248,250,252,0.9);
  border: 1px solid rgba(226, 232, 240, 0.95);
}

.stats-list__label {
  font-size: 13px;
  font-weight: 800;
  color: #64748b;
}

.stats-list__value {
  font-size: 16px;
  font-weight: 900;
  color: #0f172a;
}

.empty-state {
  padding: 26px 20px;
  border-radius: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.40);
  background: rgba(255,255,255,0.72);
  text-align: center;
}

.empty-state__title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 900;
  color: #0f172a;
}

.empty-state__text {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: #64748b;
}

@media (max-width: 1200px) {
  .dashboard-grid--kpi {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .dashboard-grid--3 {
    grid-template-columns: repeat(2, minmax(260px, 1fr));
  }
}

@media (max-width: 860px) {
  .dashboard-grid--kpi,
  .dashboard-grid--2,
  .dashboard-grid--3 {
    grid-template-columns: 1fr;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar .field-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .kpi-card__value {
    font-size: 28px;
  }
}
/* ===========================
   DAILY PRICE CALENDAR - FIX LAYOUT UNIFORME
   (mettere IN FONDO al CSS)
   =========================== */

/* container grid: prova più selector per compatibilità */
.daily-price-grid,
.dailyprice-grid,
.calendar-grid,
.dp-grid,
.daily-grid,
#dailyPriceGrid,
[data-role="daily-price-grid"] {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
  /* righe uniformi: tutte le celle stessa altezza */
  grid-auto-rows: 1fr;
}

/* su mobile: 2 colonne poi 1 */
@media (max-width: 960px) {
  .daily-price-grid,
  .dailyprice-grid,
  .calendar-grid,
  .dp-grid,
  .daily-grid,
  #dailyPriceGrid,
  [data-role="daily-price-grid"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .daily-price-grid,
  .dailyprice-grid,
  .calendar-grid,
  .dp-grid,
  .daily-grid,
  #dailyPriceGrid,
  [data-role="daily-price-grid"] {
    grid-template-columns: 1fr;
  }
}

/* card day: forza altezza coerente e prevenzione collassi */
.day-card,
.dp-day-card,
.daily-day-card,
.calendar-day-card,
[data-role="daily-price-day"] {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 132px; /* alza/abbassa se vuoi */
  border-radius: 16px;
}

/* se le day-card usano già .card, garantiamo coerenza */
.day-card.card,
.dp-day-card.card,
.daily-day-card.card,
.calendar-day-card.card,
.card[data-role="daily-price-day"] {
  height: 100%;
}

/* header/body: header fisso, body cresce senza "spaccare" */
.day-card .card__header,
.dp-day-card .card__header,
.daily-day-card .card__header,
.calendar-day-card .card__header,
[data-role="daily-price-day"] .card__header {
  flex: 0 0 auto;
  margin-bottom: 10px;
}

.day-card .card__body,
.dp-day-card .card__body,
.daily-day-card .card__body,
.calendar-day-card .card__body,
[data-role="daily-price-day"] .card__body {
  flex: 1 1 auto;
  min-height: 0;      /* CRITICO per evitare che sparisca in flex */
  overflow: hidden;   /* non rompe la card */
}

/* contenuti lunghi: non devono far "saltare" la griglia */
.day-card .truncate,
.dp-day-card .truncate,
.daily-day-card .truncate,
.calendar-day-card .truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* clamp testo descrittivo se presente */
.day-card .muted,
.dp-day-card .muted,
.daily-day-card .muted,
.calendar-day-card .muted,
.day-card .details-reason,
.dp-day-card .details-reason,
.daily-day-card .details-reason,
.calendar-day-card .details-reason {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* se hai una lista interna, falla scrollare invece di rompere la card */
.day-card .body-scroll,
.dp-day-card .body-scroll,
.daily-day-card .body-scroll,
.calendar-day-card .body-scroll,
[data-role="daily-price-day"] .body-scroll {
  overflow: auto;
  max-height: 100%;
}

/* badge/events: evita che facciano wrap infinito */
.day-card .badge,
.dp-day-card .badge,
.daily-day-card .badge,
.calendar-day-card .badge {
  max-width: 100%;
}
/* =========================================================
   AI Copilot / Revenue Advisor Widget
   ========================================================= */
.ai-copilot-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 22px;
  padding: 20px;
  background:
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 34%),
    #ffffff;
  box-shadow: 0 14px 35px rgba(15, 23, 42, 0.06);
}

.ai-copilot-card--good {
  border-color: rgba(22, 163, 74, 0.18);
}

.ai-copilot-card--warn {
  border-color: rgba(245, 158, 11, 0.25);
}

.ai-copilot-card--bad,
.ai-copilot-card--error {
  border-color: rgba(220, 38, 38, 0.24);
}

.ai-copilot-card--loading {
  opacity: 0.88;
}

.ai-copilot-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 16px;
}

.ai-copilot-kicker {
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #2563eb;
}

.ai-copilot-head h3 {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
  font-weight: 950;
  letter-spacing: -0.03em;
  color: #0f172a;
}

.ai-copilot-head p {
  margin: 8px 0 0;
  max-width: 820px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.45;
  color: #64748b;
}

.ai-copilot-score {
  min-width: 82px;
  min-height: 82px;
  border-radius: 22px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 950;
  line-height: 1;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #f8fafc;
  color: #0f172a;
}

.ai-copilot-score small {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 900;
  color: #64748b;
}

.ai-copilot-score--good {
  background: rgba(22, 163, 74, 0.09);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.20);
}

.ai-copilot-score--warn {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.24);
}

.ai-copilot-score--bad {
  background: rgba(220, 38, 38, 0.10);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.22);
}

.ai-copilot-score--muted {
  background: rgba(100, 116, 139, 0.10);
  color: #64748b;
}

.ai-copilot-status-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.ai-copilot-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 950;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.ai-copilot-badge--good {
  background: rgba(22, 163, 74, 0.09);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.18);
}

.ai-copilot-badge--warn {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.22);
}

.ai-copilot-badge--bad {
  background: rgba(220, 38, 38, 0.10);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.18);
}

.ai-copilot-muted {
  font-size: 13px;
  font-weight: 750;
  color: #64748b;
}

.ai-copilot-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.ai-copilot-grid h4 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #334155;
}

.ai-copilot-findings {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.ai-copilot-findings li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 11px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.035);
}

.ai-copilot-finding-icon {
  flex: 0 0 auto;
  width: 22px;
  text-align: center;
}

.ai-copilot-findings strong {
  display: block;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 900;
  color: #0f172a;
}

.ai-copilot-findings small {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 700;
  color: #64748b;
}

.ai-copilot-actions {
  display: grid;
  gap: 9px;
}

.ai-copilot-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #0f172a;
  color: #ffffff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
}

.ai-copilot-action:hover {
  background: #1e293b;
  text-decoration: none;
}

@media (max-width: 980px) {
  .ai-copilot-head {
    flex-direction: column;
  }

  .ai-copilot-score {
    width: 100%;
  }

  .ai-copilot-grid {
    grid-template-columns: 1fr;
  }
}
