/* ==========================================================================
   RCH OS Components v1 — pre-v0.19
   Buttons, fields, badges, cards, lists, overlays, popup and modal components.
   ========================================================================== */

/* Buttons */
.btn {
  min-height: var(--rch-control-comfort);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--rch-space-2);
  padding: 0 var(--rch-space-4);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-control);
  color: var(--rch-neutral-700);
  background: var(--rch-white);
  box-shadow: var(--rch-shadow-xs);
  font-size: var(--rch-text-small);
  font-weight: 750;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease;
}

.btn:hover:not(:disabled) {
  border-color: var(--rch-neutral-300);
  background: var(--rch-neutral-50);
  box-shadow: var(--rch-shadow-sm);
  transform: translateY(-1px);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn svg {
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
}

.btn.primary {
  color: var(--rch-white);
  border-color: var(--rch-primary-600);
  background: linear-gradient(135deg, var(--rch-primary-600), var(--rch-primary-700));
  box-shadow: 0 8px 20px rgba(20, 124, 255, 0.22);
}

.btn.primary:hover:not(:disabled) {
  border-color: var(--rch-primary-700);
  background: linear-gradient(135deg, #2389ff, var(--rch-primary-700));
}

.btn.secondary {
  color: var(--rch-neutral-700);
  border-color: var(--rch-neutral-200);
  background: var(--rch-white);
}

.btn.tiny {
  min-height: 2rem;
  padding-inline: var(--rch-space-3);
  font-size: var(--rch-text-micro);
}

.btn-disabled {
  pointer-events: none;
  opacity: 0.46;
}

/* Fields */
input,
select,
textarea {
  width: 100%;
  min-width: 0;
  color: var(--rch-neutral-900);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-control);
  outline: 0;
  background: var(--rch-white);
  box-shadow: var(--rch-shadow-xs);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

input,
select {
  min-height: var(--rch-control-comfort);
  padding: 0 var(--rch-space-3);
}

textarea {
  min-height: 6.5rem;
  padding: var(--rch-space-3);
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: #8795a9;
  opacity: 1;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #66adff;
  box-shadow: 0 0 0 3px rgba(20, 124, 255, 0.12);
}

label {
  color: var(--rch-neutral-700);
  font-size: var(--rch-text-small);
  font-weight: 700;
}

/* Pills and badges */
.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--rch-space-1);
  border-radius: var(--rch-radius-pill);
  font-size: var(--rch-text-micro);
  font-weight: 800;
  line-height: 1.2;
}

.status-pill {
  min-height: 2.25rem;
  padding: 0 var(--rch-space-3);
  color: var(--rch-neutral-700);
  border: 1px solid var(--rch-neutral-200);
  background: var(--rch-white);
}

.badge {
  min-height: 1.75rem;
  padding: 0 var(--rch-space-2);
  color: var(--rch-neutral-700);
  background: var(--rch-neutral-100);
}

.badge.info,
.status-pill.info {
  color: #145bc2;
  background: #eaf3ff;
}

.badge.success,
.status-pill.success {
  color: #087a4e;
  background: #e9f9f2;
}

.badge.warning,
.status-pill.warning {
  color: #9a6100;
  background: #fff6de;
}

.badge.danger,
.status-pill.danger {
  color: #b22e33;
  background: #fff0f0;
}

.badge.purple,
.status-pill.purple {
  color: #5a3bc2;
  background: #f1edff;
}

/* Panels and cards */
.panel-card {
  min-width: 0;
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background: var(--rch-white);
  box-shadow: var(--rch-shadow-xs);
}

.panel-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--rch-space-3);
}

.panel-title-row h2,
.panel-card h2 {
  margin: 0;
  color: var(--rch-neutral-900);
  font-size: var(--rch-text-card);
  line-height: 1.25;
}

/* Operational lists */
.area-list,
.notifications-list,
.route-list,
.route-items,
.history-list,
.selection-list,
.quality-list {
  display: grid;
  gap: var(--rch-space-2);
}

.area-item,
.notification-item,
.route-item,
.history-item,
.selection-row,
.quality-item {
  min-width: 0;
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-small);
  color: var(--rch-neutral-700);
  background: var(--rch-neutral-25);
}

.area-item,
.notification-item,
.route-item,
.history-item,
.quality-item {
  padding: var(--rch-space-3);
}

.area-item strong,
.notification-item strong,
.route-item strong,
.history-item strong,
.quality-item strong {
  display: block;
  color: var(--rch-neutral-900);
}

.notification-item.high {
  border-color: #f4b5b8;
  background: #fff4f4;
}

.notification-item.medium {
  border-color: #f0d18e;
  background: #fff9e9;
}

.notification-item.low {
  background: var(--rch-neutral-50);
}

.route-disabled {
  opacity: 0.58;
}

.route-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--rch-space-3);
}

.route-index {
  width: 1.9rem;
  height: 1.9rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--rch-white);
  background: var(--rch-primary-600);
  font-size: var(--rch-text-micro);
  font-weight: 850;
}

.route-content {
  min-width: 0;
}

.route-content span,
.route-content small {
  display: block;
  overflow: hidden;
  color: var(--rch-neutral-500);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-remove-btn {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--rch-radius-control);
  color: var(--rch-danger-600);
  background: #fff0f0;
}

.route-actions,
.detail-action-row,
.popup-actions,
.bulk-actions,
.selection-route-actions,
.quality-header-actions,
.reader-login-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--rch-space-2);
}

/* Selection */
.bulk-actions {
  display: grid;
  gap: var(--rch-space-2);
  margin-top: var(--rch-space-3);
}

.selection-list {
  max-height: 22rem;
  margin-top: var(--rch-space-3);
  overflow: auto;
  scrollbar-gutter: stable;
}

.selection-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--rch-space-2);
  padding: var(--rch-space-3);
  text-align: left;
}

.selection-row.active {
  border-color: var(--rch-primary-600);
  background: var(--rch-primary-100);
}

.selection-row-main {
  min-width: 0;
}

.selection-row-main strong,
.selection-row-main span {
  display: block;
}

.selection-row-main span,
.selection-row-meta {
  color: var(--rch-neutral-500);
  font-size: var(--rch-text-micro);
}

.selection-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--rch-space-2);
}

/* Detail */
.activity-hero,
.field-activity-hero {
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr);
  gap: var(--rch-space-3);
  align-items: center;
  margin: var(--rch-space-3) 0;
  padding: var(--rch-space-3);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background: linear-gradient(135deg, #f8fbff, #eef5ff);
}

.activity-image-placeholder {
  width: 4rem;
  height: 4rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--rch-white);
  background: linear-gradient(135deg, var(--rch-primary-600), var(--rch-primary-700));
  font-size: 1.1rem;
  font-weight: 850;
}

.activity-hero-content,
.detail-title,
.detail-meta {
  min-width: 0;
}

.detail-title {
  color: var(--rch-neutral-900);
  font-size: var(--rch-text-card);
  font-weight: 850;
  line-height: 1.2;
}

.detail-meta {
  margin-top: var(--rch-space-1);
  color: var(--rch-neutral-500);
  font-size: var(--rch-text-small);
}

.activity-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--rch-space-1);
  margin-top: var(--rch-space-2);
}

.field-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--rch-space-3);
}

.field-mode-notice,
.readonly-notice {
  padding: var(--rch-space-3);
  border: 1px solid #cfe0f5;
  border-radius: var(--rch-radius-small);
  color: #315d8f;
  background: #f1f7ff;
}

/* Leaflet marker and popup */
.marker-pin {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 3px solid var(--rch-white);
  border-radius: 50% 50% 50% 0;
  color: var(--rch-white);
  box-shadow: 0 5px 14px rgba(10, 37, 70, 0.28);
  font-size: 0.68rem;
  font-weight: 900;
  transform: rotate(-45deg);
}

.marker-pin span {
  transform: rotate(45deg);
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background: rgba(20, 124, 255, 0.20);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  color: var(--rch-white);
  background: var(--rch-primary-600);
  font-weight: 850;
}

.leaflet-popup-content-wrapper {
  border-radius: var(--rch-radius-card);
  box-shadow: var(--rch-shadow-md);
}

.leaflet-popup-content {
  margin: var(--rch-space-3);
}

.popup-card {
  min-width: 13.5rem;
  color: var(--rch-neutral-700);
  font-size: var(--rch-text-small);
}

.popup-title {
  margin-bottom: var(--rch-space-1);
  color: var(--rch-neutral-900);
  font-size: var(--rch-text-card);
  font-weight: 850;
}

.popup-actions {
  margin-top: var(--rch-space-3);
}

.popup-actions button {
  min-height: 2.25rem;
  flex: 1 1 0;
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-control);
  color: var(--rch-primary-700);
  background: var(--rch-white);
  font-weight: 750;
}

/* Modal shells */
.analytics-modal,
.reader-modal {
  position: fixed;
  z-index: var(--rch-z-dialog);
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--rch-space-4);
}

.analytics-backdrop,
.reader-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 15, 33, 0.66);
  backdrop-filter: blur(5px);
}

.analytics-panel,
.quality-panel,
.reader-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 72rem);
  max-height: min(90dvh, 58rem);
  overflow: auto;
  padding: var(--rch-space-6);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--rch-radius-hero);
  background: var(--rch-white);
  box-shadow: var(--rch-shadow-lg);
  scrollbar-gutter: stable;
}

.reader-panel {
  width: min(100%, 54rem);
}

.analytics-header,
.reader-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--rch-space-4);
  margin-bottom: var(--rch-space-5);
}

.analytics-header h2,
.reader-header h2 {
  margin: 0;
  font-size: var(--rch-text-section);
}

.analytics-header p,
.reader-header p {
  margin: var(--rch-space-1) 0 0;
  color: var(--rch-neutral-500);
}

.analytics-kpi-grid,
.reader-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--rch-space-3);
}

.analytics-kpi,
.reader-kpi {
  min-height: 7rem;
  display: grid;
  align-content: center;
  padding: var(--rch-space-4);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background: var(--rch-neutral-25);
}

.analytics-kpi span,
.reader-kpi span {
  color: var(--rch-neutral-900);
  font-size: 2rem;
  font-weight: 880;
  line-height: 1;
}

.analytics-kpi small,
.reader-kpi small {
  margin-top: var(--rch-space-2);
  color: var(--rch-neutral-500);
}

.analytics-kpi.warning,
.reader-kpi.warning {
  border-color: #efd59e;
  background: #fff9ea;
}

.analytics-kpi.danger,
.reader-kpi.danger {
  border-color: #efbdc0;
  background: #fff4f4;
}

.analytics-kpi.info,
.reader-kpi.info {
  border-color: #c7ddfa;
  background: #f1f7ff;
}

.analytics-kpi.purple,
.reader-kpi.purple {
  border-color: #d8cdf9;
  background: #f6f2ff;
}

.analytics-grid,
.reader-grid,
.quality-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--rch-space-4);
  margin-top: var(--rch-space-4);
}

.analytics-card,
.reader-card,
.quality-card {
  min-width: 0;
  padding: var(--rch-space-4);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background: var(--rch-white);
}

.analytics-card-wide,
.reader-card-wide {
  grid-column: 1 / -1;
}

.analytics-card h3,
.reader-card h3,
.quality-card h3 {
  margin: 0 0 var(--rch-space-3);
  font-size: var(--rch-text-card);
}

.analytics-bars,
.reader-bars,
.assignee-progress-item,
.quality-list {
  display: grid;
  gap: var(--rch-space-2);
}

.analytics-bar-row,
.reader-bar-row {
  display: grid;
  grid-template-columns: minmax(7rem, 0.7fr) minmax(0, 1fr);
  gap: var(--rch-space-3);
  align-items: center;
}

.analytics-bar-label,
.reader-bar-label {
  overflow: hidden;
  color: var(--rch-neutral-700);
  font-size: var(--rch-text-small);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-bar-track,
.reader-bar-track,
.analytics-progress-bar,
.reader-progress-bar {
  height: 0.65rem;
  overflow: hidden;
  border-radius: var(--rch-radius-pill);
  background: var(--rch-neutral-100);
}

.analytics-bar-track > *,
.reader-bar-track > *,
.analytics-progress-bar > *,
.reader-progress-bar > * {
  height: 100%;
  border-radius: inherit;
  background: var(--rch-primary-600);
}

.analytics-progress-card,
.reader-progress-card {
  padding: var(--rch-space-4);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background: var(--rch-neutral-25);
}

.analytics-mini-stats,
.assignee-progress-top,
.assignee-progress-meta,
.quality-card-head,
.quality-severity-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--rch-space-2);
}

.quality-card.attention {
  border-color: #efbdc0;
  background: #fff8f8;
}

.quality-severity {
  font-size: var(--rch-text-micro);
  font-weight: 850;
}

.quality-filter-btn {
  min-height: 2.25rem;
  padding: 0 var(--rch-space-3);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-control);
  color: var(--rch-primary-700);
  background: var(--rch-white);
  font-size: var(--rch-text-small);
  font-weight: 750;
}

.reader-login-box {
  padding: var(--rch-space-4);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background: var(--rch-neutral-50);
}

.reader-login-row {
  margin-top: var(--rch-space-2);
}

.reader-login-row input {
  flex: 1 1 16rem;
}

.reader-help,
.reader-message {
  margin: var(--rch-space-3) 0 0;
  color: var(--rch-neutral-500);
  font-size: var(--rch-text-small);
}

.reader-message.error {
  color: var(--rch-danger-600);
}

.reader-message.warning {
  color: var(--rch-warning-600);
}

/* Scrollbar */
.selection-list,
.analytics-panel,
.quality-panel,
.reader-panel {
  scrollbar-color: #a8bad0 transparent;
  scrollbar-width: thin;
}

@media (max-width: 767px) {
  .analytics-modal,
  .reader-modal {
    padding: 0;
  }

  .analytics-panel,
  .quality-panel,
  .reader-panel {
    width: 100%;
    height: 100dvh;
    max-height: none;
    padding:
      calc(var(--rch-space-5) + var(--rch-safe-top))
      var(--rch-space-4)
      calc(var(--rch-space-5) + var(--rch-safe-bottom));
    border: 0;
    border-radius: 0;
  }

  .analytics-header,
  .reader-header {
    display: grid;
  }

  .analytics-grid,
  .reader-grid,
  .quality-grid,
  .field-detail-grid {
    grid-template-columns: 1fr;
  }

  .analytics-bar-row,
  .reader-bar-row {
    grid-template-columns: 1fr;
    gap: var(--rch-space-1);
  }
}

/* ==========================================================================
   Fase 2.3 — Analytics Territory UI
   Ripristina una personalizzazione completa del pannello Andamento.
   Rimane nello stesso file consolidato rch-components-v1.css.
   ========================================================================== */

.analytics-modal {
  position: fixed;
  z-index: var(--rch-z-dialog);
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(12px, 2vw, 28px);
}

.analytics-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(20, 124, 255, 0.15), transparent 28rem),
    rgba(4, 17, 37, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.analytics-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 1180px);
  max-height: min(92dvh, 900px);
  overflow-y: auto;
  padding: clamp(20px, 2.4vw, 30px);
  border: 1px solid rgba(211, 224, 240, 0.92);
  border-radius: 28px;
  background:
    radial-gradient(circle at 0 0, rgba(20, 124, 255, 0.09), transparent 25rem),
    radial-gradient(circle at 100% 0, rgba(113, 78, 234, 0.06), transparent 22rem),
    #f8fbff;
  box-shadow:
    0 34px 90px rgba(4, 17, 37, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  scrollbar-gutter: stable;
}

.analytics-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--rch-space-5);
  margin-bottom: var(--rch-space-5);
}

.analytics-header h2 {
  margin: 0;
  color: var(--rch-neutral-900);
  font-size: clamp(1.7rem, 2.4vw, 2.25rem);
  line-height: 1.06;
  letter-spacing: -0.035em;
}

.analytics-header p {
  margin: var(--rch-space-2) 0 0;
  color: var(--rch-neutral-500);
  font-size: 0.95rem;
  font-weight: 600;
}

.analytics-header .btn {
  min-width: 5.5rem;
  min-height: 2.8rem;
  border-radius: var(--rch-radius-small);
}

/* KPI */
.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--rch-space-3);
  margin-bottom: var(--rch-space-4);
}

.analytics-kpi {
  position: relative;
  min-width: 0;
  min-height: 8.7rem;
  display: grid;
  align-content: center;
  padding: var(--rch-space-5);
  overflow: hidden;
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-panel);
  background:
    radial-gradient(circle at 100% 0, rgba(20, 124, 255, 0.12), transparent 5.2rem),
    var(--rch-white);
  box-shadow: var(--rch-shadow-sm);
}

.analytics-kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--rch-primary-600);
}

.analytics-kpi::after {
  content: "";
  position: absolute;
  top: -2.4rem;
  right: -2.4rem;
  width: 7rem;
  height: 7rem;
  border-radius: 50%;
  background: rgba(20, 124, 255, 0.07);
}

.analytics-kpi.danger {
  border-color: #f2c4c6;
  background:
    radial-gradient(circle at 100% 0, rgba(223, 63, 68, 0.10), transparent 5.2rem),
    #fff9f9;
}

.analytics-kpi.danger::before {
  background: var(--rch-danger-600);
}

.analytics-kpi.danger::after {
  background: rgba(223, 63, 68, 0.07);
}

.analytics-kpi.info {
  border-color: #c8ddfa;
  background:
    radial-gradient(circle at 100% 0, rgba(22, 127, 255, 0.10), transparent 5.2rem),
    #f7fbff;
}

.analytics-kpi.purple {
  border-color: #d9cff9;
  background:
    radial-gradient(circle at 100% 0, rgba(113, 78, 234, 0.11), transparent 5.2rem),
    #faf8ff;
}

.analytics-kpi.purple::before {
  background: var(--rch-violet-600);
}

.analytics-kpi.purple::after {
  background: rgba(113, 78, 234, 0.07);
}

.analytics-kpi span {
  position: relative;
  z-index: 1;
  display: block;
  color: var(--rch-neutral-900);
  font-size: clamp(2.15rem, 3.2vw, 3rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.analytics-kpi small {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: var(--rch-space-3);
  color: var(--rch-neutral-500);
  font-size: 0.78rem;
  font-weight: 780;
  line-height: 1.25;
}

/* Progress overview */
.analytics-progress-card {
  margin-bottom: var(--rch-space-4);
  padding: var(--rch-space-5);
  border: 1px solid #cfe0f5;
  border-radius: var(--rch-radius-panel);
  background:
    linear-gradient(135deg, rgba(234, 243, 255, 0.95), rgba(255, 255, 255, 0.96));
  box-shadow: var(--rch-shadow-xs);
}

.analytics-progress-main {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: var(--rch-space-5);
  align-items: center;
}

.analytics-progress-main > div:first-child {
  min-width: 0;
}

.analytics-progress-main strong {
  display: block;
  color: var(--rch-primary-700);
  font-size: clamp(2.45rem, 4vw, 3.5rem);
  font-weight: 900;
  line-height: 0.92;
  letter-spacing: -0.06em;
}

.analytics-progress-main span {
  display: block;
  margin-top: var(--rch-space-2);
  color: var(--rch-neutral-700);
  font-size: 0.82rem;
  font-weight: 780;
  line-height: 1.3;
}

.analytics-progress-bar {
  position: relative;
  height: 16px;
  overflow: hidden;
  border-radius: var(--rch-radius-pill);
  background:
    repeating-linear-gradient(
      135deg,
      #e7edf5,
      #e7edf5 8px,
      #edf2f8 8px,
      #edf2f8 16px
    );
  box-shadow: inset 0 1px 2px rgba(18, 46, 78, 0.08);
}

.analytics-progress-bar.segmented i {
  position: absolute;
  top: 0;
  bottom: 0;
  display: block;
  min-width: 0;
  border-radius: 0;
}

.analytics-progress-bar.segmented .progress-verified {
  left: 0;
  background: linear-gradient(90deg, var(--rch-primary-600), var(--rch-success-600));
}

.analytics-progress-bar.segmented .progress-attention {
  background: linear-gradient(90deg, #e99a12, var(--rch-magenta-600));
}

.analytics-mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--rch-space-3);
  margin-top: var(--rch-space-4);
}

.analytics-mini-stats div {
  min-width: 0;
  padding: var(--rch-space-3) var(--rch-space-4);
  border: 1px solid rgba(207, 224, 245, 0.92);
  border-radius: var(--rch-radius-card);
  background: rgba(255, 255, 255, 0.82);
}

.analytics-mini-stats strong,
.analytics-mini-stats span {
  display: block;
}

.analytics-mini-stats strong {
  color: var(--rch-neutral-900);
  font-size: 1.45rem;
  font-weight: 900;
  line-height: 1;
}

.analytics-mini-stats span {
  margin-top: var(--rch-space-1);
  color: var(--rch-neutral-500);
  font-size: 0.73rem;
  font-weight: 720;
}

/* Analytics cards */
.analytics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--rch-space-4);
  margin-top: 0;
}

.analytics-card {
  min-width: 0;
  padding: var(--rch-space-5);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-panel);
  background: var(--rch-white);
  box-shadow: var(--rch-shadow-xs);
}

.analytics-card h3 {
  margin: 0 0 var(--rch-space-4);
  color: var(--rch-neutral-900);
  font-size: 1.05rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.analytics-card-wide {
  grid-column: 1 / -1;
}

/* Bar rows */
.analytics-bars {
  display: grid;
  gap: var(--rch-space-3);
}

.analytics-bar-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(135px, 0.9fr) minmax(120px, 1.45fr) 48px;
  gap: var(--rch-space-3);
  align-items: center;
}

.analytics-bar-label {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--rch-space-2);
}

.analytics-bar-label span {
  min-width: 0;
  overflow: hidden;
  color: var(--rch-neutral-700);
  font-size: 0.78rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.analytics-bar-label strong {
  flex: 0 0 auto;
  color: var(--rch-neutral-900);
  font-size: 0.82rem;
  font-weight: 900;
}

.analytics-bar-track {
  position: relative;
  height: 11px;
  overflow: hidden;
  border-radius: var(--rch-radius-pill);
  background: #e8eef6;
  box-shadow: inset 0 1px 2px rgba(18, 46, 78, 0.07);
}

.analytics-bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--rch-primary-600), var(--rch-violet-600));
  box-shadow: 0 0 12px rgba(20, 124, 255, 0.18);
}

.analytics-bar-row small {
  color: var(--rch-neutral-500);
  font-size: 0.7rem;
  font-weight: 760;
  text-align: right;
  white-space: nowrap;
}

/* Assignee rows */
.assignee-progress-item {
  padding: var(--rch-space-4);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-card);
  background: linear-gradient(180deg, #fbfdff, #f7faff);
}

.assignee-progress-item + .assignee-progress-item {
  margin-top: var(--rch-space-3);
}

.assignee-progress-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--rch-space-4);
  margin-bottom: var(--rch-space-3);
}

.assignee-progress-top > div {
  min-width: 0;
}

.assignee-progress-top strong {
  display: block;
  color: var(--rch-neutral-900);
  font-size: 0.92rem;
  font-weight: 900;
  line-height: 1.2;
}

.assignee-progress-top span {
  display: block;
  margin-top: var(--rch-space-1);
  color: var(--rch-neutral-500);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.35;
}

.assignee-progress-top b {
  flex: 0 0 auto;
  color: var(--rch-primary-700);
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.04em;
}

.assignee-progress-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--rch-space-2);
  margin-top: var(--rch-space-3);
}

.assignee-progress-meta span {
  min-height: 1.7rem;
  display: inline-flex;
  align-items: center;
  padding: 0 var(--rch-space-2);
  border: 1px solid var(--rch-neutral-200);
  border-radius: var(--rch-radius-pill);
  color: var(--rch-neutral-700);
  background: var(--rch-white);
  font-size: 0.66rem;
  font-weight: 760;
}

/* Responsive analytics */
@media (max-width: 900px) {
  .analytics-panel {
    width: min(100%, 760px);
  }

  .analytics-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analytics-progress-main,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .analytics-progress-main {
    gap: var(--rch-space-4);
  }

  .analytics-bar-row {
    grid-template-columns: minmax(120px, 0.9fr) minmax(100px, 1fr) 45px;
  }
}

@media (max-width: 600px) {
  .analytics-modal {
    padding: 0;
  }

  .analytics-panel {
    width: 100%;
    height: 100dvh;
    max-height: none;
    padding:
      calc(var(--rch-space-5) + var(--rch-safe-top))
      var(--rch-space-4)
      calc(var(--rch-space-6) + var(--rch-safe-bottom));
    border: 0;
    border-radius: 0;
  }

  .analytics-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: var(--rch-space-3);
  }

  .analytics-header h2 {
    font-size: 1.7rem;
  }

  .analytics-header p {
    font-size: 0.82rem;
  }

  .analytics-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--rch-space-2);
  }

  .analytics-kpi {
    min-height: 7.3rem;
    padding: var(--rch-space-4);
  }

  .analytics-kpi span {
    font-size: 2.05rem;
  }

  .analytics-mini-stats {
    grid-template-columns: 1fr;
  }

  .analytics-bar-row {
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: var(--rch-space-2);
  }

  .analytics-bar-label {
    grid-column: 1 / -1;
  }

  .analytics-bar-track {
    grid-column: 1;
  }

  .analytics-bar-row small {
    grid-column: 2;
  }

  .analytics-card {
    padding: var(--rch-space-4);
  }

  .assignee-progress-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }
}


/* ==========================================================================
   Fase 2.3.1 — Fine tuning analytics layout
   - Sistema il testo "verificato" nelle righe area
   - Ordina le descrizioni stato sotto la barra principale
   ========================================================================== */

.analytics-progress-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--rch-space-2) var(--rch-space-3);
  margin-top: var(--rch-space-4);
  padding-top: var(--rch-space-4);
  border-top: 1px solid rgba(207, 224, 245, 0.92);
}

.analytics-progress-legend span {
  min-height: 1.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 var(--rch-space-3);
  border: 1px solid rgba(207, 224, 245, 0.92);
  border-radius: var(--rch-radius-pill);
  background: rgba(255, 255, 255, 0.82);
  color: var(--rch-neutral-700);
  font-size: 0.72rem;
  font-weight: 780;
  line-height: 1;
  white-space: nowrap;
}

.analytics-progress-legend i {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 999px;
  flex: 0 0 auto;
}

.analytics-progress-legend .verified-dot { background: linear-gradient(90deg, var(--rch-primary-600), var(--rch-success-600)); }
.analytics-progress-legend .investigate-dot { background: linear-gradient(90deg, #e99a12, var(--rch-magenta-600)); }
.analytics-progress-legend .assigned-dot { background: linear-gradient(90deg, #4f7cff, var(--rch-violet-600)); }
.analytics-progress-legend .validated-dot { background: var(--rch-danger-600); }
.analytics-progress-legend .alert-dot { background: var(--rch-magenta-600); }

.analytics-progress-card .analytics-mini-stats {
  margin-bottom: 0;
}

.analytics-grid .analytics-card {
  overflow: hidden;
}

.analytics-bar-row {
  grid-template-columns: minmax(150px, 0.95fr) minmax(170px, 1.5fr) minmax(70px, auto);
  gap: var(--rch-space-3);
}

.analytics-bar-row .analytics-bar-label strong {
  margin-left: auto;
}

.analytics-bar-row.area-row {
  grid-template-columns: minmax(180px, 1.1fr) minmax(180px, 1.45fr) minmax(96px, auto);
}

.analytics-bar-row.area-row small {
  display: grid;
  justify-items: end;
  align-content: center;
  gap: 2px;
  white-space: normal;
  line-height: 1.05;
  text-align: right;
}

.analytics-bar-row.area-row small b {
  color: var(--rch-neutral-700);
  font-size: 0.82rem;
  font-weight: 900;
  line-height: 1;
}

.analytics-bar-row.area-row small span {
  color: var(--rch-neutral-500);
  font-size: 0.66rem;
  font-weight: 760;
  letter-spacing: 0.01em;
  text-transform: none;
}

.analytics-bar-row.area-row .analytics-bar-label span {
  max-width: 100%;
}

@media (max-width: 900px) {
  .analytics-bar-row.area-row {
    grid-template-columns: minmax(150px, 1fr) minmax(140px, 1.2fr) minmax(84px, auto);
  }
}

@media (max-width: 600px) {
  .analytics-progress-legend {
    gap: var(--rch-space-2);
  }

  .analytics-progress-legend span {
    min-height: 1.8rem;
    padding: 0 var(--rch-space-2);
    font-size: 0.68rem;
  }

  .analytics-bar-row.area-row,
  .analytics-bar-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .analytics-bar-row.area-row .analytics-bar-track,
  .analytics-bar-row .analytics-bar-track {
    grid-column: 1;
  }

  .analytics-bar-row.area-row small,
  .analytics-bar-row small {
    justify-items: start;
    text-align: left;
  }
}

