*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #0C50A0;
  --primary-light: #1a6fcc;
  --primary-dark: #083a73;
  --accent: #8bc53f;
  --success: #8bc53f;
  --warning: #f39c12;
  --danger: #c0392b;
  --gray-50: #f8f9fa;
  --gray-100: #e9ecef;
  --gray-200: #dee2e6;
  --gray-300: #ced4da;
  --gray-500: #6c757d;
  --gray-700: #495057;
  --gray-900: #212529;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- NAV --- */
.portal-nav {
  background: var(--primary);
  color: white;
  padding: 0 24px;
  display: flex;
  align-items: center;
  height: 56px;
  gap: 24px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.portal-nav .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: white;
}
.portal-nav .logo img {
  height: 28px;
  width: auto;
}
.portal-nav .nav-links {
  display: flex;
  gap: 8px;
  flex: 1;
}
.portal-nav .nav-links a {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}
.portal-nav .nav-links a:hover,
.portal-nav .nav-links a.active {
  background: rgba(255,255,255,0.15);
  color: white;
}
.portal-nav .user-info {
  font-size: 13px;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 12px;
}
.portal-nav .btn-logout {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
}
.portal-nav .btn-logout:hover { background: rgba(255,255,255,0.25); }
.vedi-come-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #d32f2f;
  color: white;
  text-align: center;
  padding: 6px 16px;
  font-size: 13px;
  z-index: 1000;
}
body:has(.vedi-come-banner) .portal-nav { margin-top: 34px; }
body:has(.vedi-come-banner) .page-content { margin-top: 0; }

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  width: 90%;
}

/* --- LAYOUT --- */
.page-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  width: 100%;
  flex: 1;
}
.page-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--primary-dark);
}

/* --- CARDS --- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
}
.stat-card .stat-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}
.stat-card.success .stat-value { color: var(--success); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }

/* --- TABLE --- */
.table-container {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}
th {
  background: var(--gray-50);
  font-weight: 600;
  color: var(--gray-700);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tr:hover { background: var(--gray-50); }
tr { cursor: pointer; }

/* --- BADGES --- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: #e8f5d8; color: #3d6b10; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: var(--gray-200); color: var(--gray-700); }

/* --- FORMS --- */
.form-container {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  max-width: 480px;
  margin: 0 auto;
}
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
}

/* --- BUTTONS --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  font-family: inherit;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* --- DETAIL SECTIONS --- */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
  margin-bottom: 32px;
}
.detail-section {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.detail-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-100);
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-50);
  font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: var(--gray-500); }
.detail-value { font-weight: 500; text-align: right; max-width: 60%; }

/* --- DOCUMENTS GRID --- */
.docs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
}
.doc-item.has-file { border-color: var(--success); background: #f0faf4; }
.doc-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.doc-icon.uploaded { background: #d4edda; color: var(--success); }
.doc-icon.missing { background: var(--gray-100); color: var(--gray-500); }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 14px; font-weight: 500; }
.doc-status { font-size: 12px; color: var(--gray-500); }
.doc-actions { display: flex; gap: 6px; }

/* --- PIPELINE STEPPER (arrow/chevron style) --- */
.pipeline-stepper {
  display: flex;
  align-items: center;
  overflow-x: auto;
  padding: 16px 0;
  margin-bottom: 24px;
}
.pipeline-step {
  position: relative;
  padding: 8px 16px 8px 24px;
  font-size: 11px;
  white-space: nowrap;
  background: var(--gray-100);
  color: var(--gray-500);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%);
  margin-left: -6px;
}
.pipeline-step:first-child {
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%);
  margin-left: 0;
  padding-left: 14px;
  border-radius: 4px 0 0 4px;
}
.pipeline-step:last-child {
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%, 12px 50%);
  border-radius: 0 4px 4px 0;
}
.pipeline-step.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}
.pipeline-step.completed {
  background: var(--success);
  color: white;
}

/* --- ALERT --- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
}
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* --- FILTERS --- */
.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 6px 14px;
  border: 1px solid var(--gray-300);
  border-radius: 20px;
  background: white;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--primary-light); }
.filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* --- LOGIN SPECIFIC --- */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-light) 100%);
}
.login-box {
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}
.login-box h1 {
  font-size: 24px;
  color: var(--primary-dark);
  margin-bottom: 8px;
}
.login-box .subtitle {
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 28px;
}
.login-box .link {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--primary-light);
  text-decoration: none;
}
.login-box .link:hover { text-decoration: underline; }

/* --- LOADING --- */
.loading {
  text-align: center;
  padding: 60px 0;
  color: var(--gray-500);
}
.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- EMPTY STATE --- */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--gray-500);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { color: var(--gray-700); margin-bottom: 8px; }

/* --- FOOTER --- */
.portal-footer {
  background: #0C50A0;
  color: #ffffff;
  padding: 48px 24px 24px;
  margin-top: auto;
  font-size: 14px;
  line-height: 1.7;
}
.portal-footer a {
  color: #b0c8e0;
  text-decoration: none;
  transition: color 0.15s;
}
.portal-footer a:hover {
  color: #ffffff;
  text-decoration: underline;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 40px;
}
.footer-col h4 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
  color: #ffffff;
  font-weight: 600;
}
.footer-col p {
  margin: 0 0 4px;
  color: #c5d5e4;
  font-size: 13px;
}
.footer-logo {
  height: 40px;
  width: auto;
  margin-bottom: 16px;
  display: block;
}
.footer-social {
  display: flex;
  gap: 16px;
  margin: 12px 0;
}
.footer-social a {
  color: #b0c8e0;
  font-size: 13px;
  font-weight: 600;
}
.footer-links {
  display: flex;
  gap: 16px;
  margin: 8px 0;
}
.footer-links a {
  font-size: 12px;
  color: #b0c8e0;
}
.footer-bottom {
  max-width: 1200px;
  margin: 32px auto 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.15);
  text-align: center;
  font-size: 12px;
  color: #8ba4bd;
}
.footer-contact-label {
  color: #ffffff;
  font-weight: 600;
}

/* --- RESPONSIVE --- */
@media (max-width: 768px) {
  .portal-nav { padding: 0 12px; gap: 12px; }
  .portal-nav .nav-links a { padding: 8px 10px; font-size: 13px; }
  .portal-nav .user-info .user-name { display: none; }
  .page-content { padding: 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-inner { grid-template-columns: 1fr; gap: 24px; }
}

.valore { padding: 8px 0; font-size: 14px; color: var(--gray-800, #222); }
