/* ============================================
   Finint Fondi Manager - Stylesheet
   Institutional financial application
   v2 — Professional login, RBAC UI, Biometric
   ============================================ */

:root {
  --navy: #0d2b45;
  --navy-light: #1a3d5c;
  --navy-dark: #081b2e;
  --navy-deep: #050f1a;
  --gold: #c8a45c;
  --gold-light: #d4b976;
  --gold-dark: #b08d3e;
  --bg: #f5f6fa;
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --green: #059669;
  --green-bg: #ecfdf5;
  --red: #dc2626;
  --red-bg: #fef2f2;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 40px rgba(0,0,0,0.15), 0 8px 16px rgba(0,0,0,0.08);
  --transition: 150ms ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--gray-800);
  line-height: 1.5;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ============================================
   LOGIN SCREEN — INSTITUTIONAL DESIGN
   ============================================ */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.login-backdrop {
  width: 100%;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--navy-deep) 0%, var(--navy) 40%, var(--navy-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.login-backdrop::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 80%;
  height: 200%;
  background: radial-gradient(ellipse at center, rgba(200,164,92,0.04) 0%, transparent 70%);
  pointer-events: none;
}

.login-backdrop::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--gold) 50%, transparent 100%);
}

.login-panel {
  display: flex;
  width: 100%;
  max-width: 960px;
  min-height: 580px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-xl);
  position: relative;
  z-index: 1;
}

.login-panel-left {
  flex: 1;
  background: linear-gradient(175deg, var(--navy-dark) 0%, var(--navy) 60%, var(--navy-light) 100%);
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid rgba(200,164,92,0.15);
  position: relative;
}

.login-panel-left::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent 0%, var(--gold-dark) 30%, var(--gold-dark) 70%, transparent 100%);
  opacity: 0.3;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 2.5rem;
}

.login-logo {
  height: 44px;
  filter: brightness(1.1);
}

.login-brand-text {
  display: flex;
  flex-direction: column;
}

.login-brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.01em;
}

.login-brand-sub {
  font-size: 0.78rem;
  color: var(--gold-light);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.login-hero-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-hero-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.3;
  margin-bottom: 0.8rem;
}

.login-hero-desc {
  font-size: 0.9rem;
  color: rgba(255,255,255,0.6);
  line-height: 1.6;
  max-width: 360px;
}

.login-hero-features {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.login-hero-feat {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.55);
}

.feat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
}

/* RIGHT PANEL (form) */
.login-panel-right {
  flex: 0 0 400px;
  background: var(--white);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-form-area {
  padding: 2.5rem 2.2rem 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.25rem;
}

.login-subtitle-text {
  font-size: 0.88rem;
  color: var(--gray-500);
  margin-bottom: 1.8rem;
}

.pw-wrap {
  position: relative;
}

.pw-wrap input {
  width: 100%;
  padding-right: 2.8rem;
}

.pw-toggle {
  position: absolute;
  right: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
}

.pw-toggle:hover { color: var(--gray-600); }

.btn-login-main {
  margin-top: 0.5rem;
  padding: 0.7rem 1.2rem;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.biometric-section {
  margin-top: 0.5rem;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 0.8rem 0;
  color: var(--gray-400);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

.btn-biometric {
  background: var(--gray-50);
  color: var(--navy);
  border: 1px solid var(--gray-200);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  transition: all var(--transition);
}

.btn-biometric:hover {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

.btn-biometric svg {
  flex-shrink: 0;
}

.login-error {
  color: var(--red);
  font-size: 0.85rem;
  margin-top: 0.6rem;
  display: none;
}

/* Forgot password link */
.forgot-pw-link {
  text-align: center;
  margin-top: 0.7rem;
}
.forgot-pw-link a {
  color: var(--gray-500);
  font-size: 0.82rem;
  text-decoration: none;
  transition: color 0.2s;
}
.forgot-pw-link a:hover {
  color: var(--navy);
  text-decoration: underline;
}
.forgot-pw-msg {
  margin-top: 0.8rem;
  padding: 1rem 1.1rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 0.82rem;
  color: var(--gray-600);
  line-height: 1.6;
}
.forgot-pw-msg p { margin: 0 0 0.5rem; }
.forgot-pw-title {
  font-weight: 600;
  color: var(--navy);
  font-size: 0.88rem;
  margin-bottom: 0.6rem !important;
}
.forgot-pw-steps {
  margin: 0.7rem 0;
}
.forgot-pw-step {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  line-height: 1.5;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  background: var(--navy);
  color: #fff;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 600;
  flex-shrink: 0;
}
.forgot-pw-note {
  font-size: 0.78rem;
  color: var(--gray-500);
  font-style: italic;
  margin-top: 0.3rem !important;
}
.forgot-pw-close {
  color: var(--navy-light);
  font-size: 0.8rem;
  text-decoration: none;
}
.forgot-pw-close:hover { text-decoration: underline; }

/* Security info link in login footer */
.security-info-link {
  color: var(--gray-400);
  text-decoration: none;
  font-size: 0.78rem;
  transition: color 0.2s;
}
.security-info-link:hover {
  color: var(--navy-light);
  text-decoration: underline;
}

/* Security info modal content */
.security-info-content {
  padding: 0.5rem 0;
}
.security-info-intro {
  font-size: 0.9rem;
  color: var(--gray-600);
  line-height: 1.6;
  margin-bottom: 1.2rem;
}
.security-info-section {
  margin-bottom: 1.2rem;
}
.security-info-section h3 {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--gray-200);
}
.security-info-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.security-info-section li {
  position: relative;
  padding-left: 1.2rem;
  margin-bottom: 0.4rem;
  font-size: 0.84rem;
  color: var(--gray-600);
  line-height: 1.5;
}
.security-info-section li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5rem;
  width: 6px;
  height: 6px;
  background: var(--navy-light);
  border-radius: 50%;
}
.security-info-disclaimer {
  margin-top: 1rem;
  padding: 0.8rem 1rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
}
.security-info-disclaimer p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--gray-500);
  line-height: 1.5;
  font-style: italic;
}

/* Footer area in login */
.login-footer-area {
  padding: 1rem 2.2rem 1.5rem;
  border-top: 1px solid var(--gray-100);
}

.login-disclaimer {
  font-size: 0.72rem;
  color: var(--gray-400);
  line-height: 1.55;
}

.login-disclaimer p + p { margin-top: 0.4rem; }

.login-footer-info {
  margin-top: 0.7rem;
  font-size: 0.72rem;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.sep-dot::before {
  content: '\00B7';
  font-weight: 700;
}

/* ---- MOBILE LOGIN ---- */
@media (max-width: 768px) {
  .login-panel {
    flex-direction: column;
    max-width: 100%;
    min-height: auto;
    border-radius: 0;
  }
  .login-panel-left {
    padding: 1.5rem;
    border-right: none;
    border-bottom: 1px solid rgba(200,164,92,0.15);
  }
  .login-panel-left::after { display: none; }
  .login-hero-text { display: none; }
  .login-hero-features { display: none; }
  .login-panel-right { flex: 1; }
  .login-form-area { padding: 1.8rem 1.5rem 1rem; }
  .login-footer-area { padding: 0.8rem 1.5rem 1.2rem; }
  .login-backdrop { padding: 0; }
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  backdrop-filter: blur(2px);
}

.modal-card {
  background: var(--white);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-xl);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-wide {
  max-width: 700px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--navy);
}

.modal-desc {
  font-size: 0.88rem;
  color: var(--gray-500);
  margin-bottom: 1.2rem;
  line-height: 1.5;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--gray-700); }

.profile-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ============================================
   FONDO FORM MODAL (create/edit — 58 campi)
   ============================================ */
.modal-xwide { max-width: 980px; }
.fondo-form-group {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 0.85rem 1.1rem 1.1rem;
  margin-bottom: 1.1rem;
  background: var(--gray-50);
}
.fondo-group-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.8rem;
}
.fondo-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.75rem 1rem;
}
.fondo-field { text-align: left; min-width: 0; }
.fondo-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.fondo-field input,
.fondo-field select,
.fondo-field textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.fondo-field textarea { resize: vertical; min-height: 62px; }
.fondo-field input:focus,
.fondo-field select:focus,
.fondo-field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 164, 92, 0.15);
}
.fondo-field.required label::after { content: ' *'; color: var(--red); }
.fondo-field-full { grid-column: 1 / -1; }
.fondo-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--gray-200);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.btn-primary { background: var(--navy); color: var(--white); }
.btn-primary:hover { background: var(--navy-light); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-small { padding: 0.35rem 0.75rem; font-size: 0.8rem; }
.btn-full { width: 100%; }
.btn-gold { background: var(--gold); color: var(--white); }
.btn-gold:hover { background: var(--gold-dark); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-danger:hover { background: #b91c1c; }

.form-group {
  text-align: left;
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 0.3rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.form-group input, .form-group select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-group input:focus, .form-group select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(200, 164, 92, 0.15);
}

/* ============================================
   HEADER
   ============================================ */
header {
  background: var(--navy);
  color: var(--white);
  border-bottom: 3px solid var(--gold);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.8rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-left { display: flex; align-items: center; gap: 1rem; }
.header-logo { height: 36px; }
.header-titles h1 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.header-titles .subtitle { font-size: 0.78rem; color: var(--gold-light); opacity: 0.9; }
.header-right { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; }
.header-right .btn-secondary {
  background: rgba(255,255,255,0.1);
  color: var(--white);
  border-color: rgba(255,255,255,0.2);
}
.header-right .btn-secondary:hover { background: rgba(255,255,255,0.2); }

.user-welcome-badge {
  font-weight: 600;
  color: var(--white);
}

.role-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(200,164,92,0.2);
  color: var(--gold-light);
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
  border: 1px solid rgba(200,164,92,0.3);
}

/* ============================================
   TAB NAV
   ============================================ */
.tab-nav {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.tab-nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-btn {
  background: none;
  border: none;
  padding: 0.85rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--navy); background: var(--gray-50); }
.tab-btn.active { color: var(--navy); font-weight: 600; border-bottom-color: var(--gold); }
.tab-btn.tab-hidden { display: none; }

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content { max-width: 1400px; margin: 0 auto; padding: 1.5rem; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.page-title { margin-bottom: 1.5rem; }
.page-title h2 { font-size: 1.5rem; font-weight: 700; color: var(--navy); }
.page-desc { font-size: 0.9rem; color: var(--gray-500); margin-top: 0.2rem; }
.section-subtitle { font-size: 1.05rem; font-weight: 700; color: var(--navy); margin: 1.5rem 0 0.2rem; }

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  border: 1px solid var(--gray-200);
}
.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--gray-100);
}
.card-desc { font-size: 0.85rem; color: var(--gray-500); margin-bottom: 1rem; }

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.dash-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--gold);
}
.dash-card .dc-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  margin-bottom: 0.4rem;
}
.dash-card .dc-value { font-size: 1.8rem; font-weight: 700; color: var(--navy); line-height: 1.2; }
.dash-card .dc-sub { font-size: 0.8rem; color: var(--gray-400); margin-top: 0.3rem; }
.dash-card.card-green { border-left-color: var(--green); }
.dash-card.card-blue { border-left-color: var(--blue); }
.dash-card.card-amber { border-left-color: var(--amber); }
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

/* ============================================
   TOOLBAR
   ============================================ */
.toolbar { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; align-items: center; }
.search-input {
  flex: 1;
  min-width: 200px;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.search-input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200, 164, 92, 0.15); }
.filter-select {
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--white);
  outline: none;
  cursor: pointer;
}
.filter-select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(200, 164, 92, 0.15); }

/* ============================================
   DATA TABLES
   ============================================ */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
  scrollbar-width: auto;
  scrollbar-color: var(--gray-400) var(--gray-100);
  max-width: 100%;
  position: relative;
}
#tab-raccolta .table-wrap { max-height: 50vh; overflow-x: scroll; }
#tab-fondi .table-wrap,
#tab-sottoscrittori .table-wrap,
#tab-eventi .table-wrap { max-height: 60vh; overflow-y: auto; }
.data-table { min-width: 700px; width: 100%; border-collapse: collapse; font-size: 0.88rem; }
#table-raccolta { min-width: 2200px; width: max-content; }
.data-table thead { background: var(--navy); color: var(--white); }
.data-table th {
  padding: 0.7rem 0.9rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--navy);
}
.data-table th:hover { background: var(--navy-light); }
.data-table th[data-sort]::after {
  content: '';
  display: inline-block;
  width: 0; height: 0;
  margin-left: 0.4rem;
  vertical-align: middle;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid rgba(255,255,255,0.4);
}
.data-table th.sort-asc::after { border-top: none; border-bottom: 4px solid var(--gold); }
.data-table th.sort-desc::after { border-top: 4px solid var(--gold); }
.data-table td { padding: 0.65rem 0.9rem; border-bottom: 1px solid var(--gray-100); white-space: nowrap; }
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table tbody tr.clickable { cursor: pointer; }
.data-table tbody tr.clickable:hover { background: var(--blue-bg); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============================================
   BADGES
   ============================================ */
.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 10px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.badge-active { background: var(--green-bg); color: var(--green); }
.badge-closed { background: var(--gray-100); color: var(--gray-500); }
.badge-pending { background: var(--amber-bg); color: var(--amber); }
.badge-raccolta { background: var(--blue-bg); color: var(--blue); }
.badge-error { background: var(--red-bg); color: var(--red); }
.badge-admin { background: rgba(200,164,92,0.15); color: var(--gold-dark); }
.badge-editor { background: var(--blue-bg); color: var(--blue); }
.badge-viewer { background: var(--gray-100); color: var(--gray-500); }
.badge-auditor { background: var(--amber-bg); color: var(--amber); }

/* ============================================
   FUND DETAIL
   ============================================ */
.fund-detail-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.fund-info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.fund-info-item .fi-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-500); margin-bottom: 0.2rem; }
.fund-info-item .fi-value { font-size: 1rem; font-weight: 600; color: var(--navy); }

/* ============================================
   COMPLIANCE
   ============================================ */
.compliance-sections { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
.checklist-group { margin-bottom: 1rem; }
.checklist-group-title { font-size: 0.85rem; font-weight: 700; color: var(--navy); margin-bottom: 0.5rem; padding-bottom: 0.3rem; border-bottom: 1px solid var(--gray-200); }
.checklist-item { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0; font-size: 0.88rem; border-bottom: 1px solid var(--gray-50); }
.checklist-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--green); cursor: pointer; }
.checklist-item .cl-label { flex: 1; color: var(--gray-700); }
.checklist-item .cl-status { font-size: 0.75rem; font-weight: 600; }
.cl-status.done { color: var(--green); }
.cl-status.pending { color: var(--amber); }
.cl-status.missing { color: var(--red); }

/* ============================================
   REPORT
   ============================================ */
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.report-card { display: flex; flex-direction: column; }
.report-card .btn { margin-top: auto; align-self: flex-start; }

/* ============================================
   ADMIN PANEL
   ============================================ */
.admin-user-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.88rem;
}
.admin-user-row:last-child { border-bottom: none; }
.admin-user-name { flex: 1; font-weight: 600; color: var(--navy); }
.admin-user-role { font-size: 0.75rem; }
.admin-user-meta { font-size: 0.78rem; color: var(--gray-400); }
.admin-user-actions { display: flex; gap: 0.3rem; }

.admin-session-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.82rem;
}
.admin-session-row:last-child { border-bottom: none; }

/* ============================================
   MINI TABLE
   ============================================ */
.mini-table { width: 100%; font-size: 0.85rem; }
.mini-table td { padding: 0.45rem 0; border-bottom: 1px solid var(--gray-100); }
.mini-table td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ============================================
   FOOTER
   ============================================ */
footer {
  background: var(--navy-dark);
  color: var(--gray-400);
  text-align: center;
  padding: 1rem;
  font-size: 0.78rem;
  margin-top: 2rem;
  letter-spacing: 0.02em;
}

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--gray-400); }
.empty-state .es-icon { font-size: 2rem; margin-bottom: 0.5rem; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; gap: 0.5rem; text-align: center; }
  .header-left { flex-direction: column; gap: 0.5rem; }
  .header-titles { text-align: center; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-cards { grid-template-columns: 1fr 1fr; }
  .tab-nav-inner { padding: 0 0.75rem; }
  .tab-btn { padding: 0.7rem 0.9rem; font-size: 0.8rem; }
  .main-content { padding: 1rem; }
  .toolbar { flex-direction: column; }
  .search-input { min-width: unset; }
  .report-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .dashboard-cards { grid-template-columns: 1fr; }
}

/* ============================================
   PERFORMANCE & MISC
   ============================================ */
.perf-positive { color: var(--green); }
.perf-negative { color: var(--red); }

.table-wrap::-webkit-scrollbar { height: 14px; width: 14px; display: block !important; }
.table-wrap::-webkit-scrollbar-track { background: #e2e6ea; border-radius: 7px; }
.table-wrap::-webkit-scrollbar-thumb { background: #6c7a89; border-radius: 7px; min-width: 60px; min-height: 40px; border: 2px solid #e2e6ea; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #3d4f5f; }

/* Force scrollbar always visible on Edge/Chrome (overlay scrollbar mode) */
@supports (scrollbar-gutter: stable) {
  .table-wrap { scrollbar-gutter: stable; }
}

/* Fallback: add bottom padding so the scrollbar area is always reserved */
.table-wrap { padding-bottom: 4px; }

.chart-wrap { position: relative; height: 260px; width: 100%; }
.dashboard-kpi { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.kpi-box { flex: 1; min-width: 180px; background: #fff; border: 1px solid var(--gray-200); border-left: 4px solid var(--navy); border-radius: 8px; padding: 0.9rem 1.1rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.kpi-lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--gray-500); margin-bottom: 0.35rem; }
.kpi-val { font-size: 1.4rem; font-weight: 700; color: var(--navy); }
.pager { display: flex; align-items: center; justify-content: center; gap: 1rem; margin: 1rem 0; }
.pager-info { font-size: 0.88rem; color: var(--gray-500); }
.pager button[disabled] { opacity: 0.45; cursor: not-allowed; }
.date-lbl { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.85rem; color: var(--gray-500); }
.date-input { padding: 0.45rem 0.6rem; border: 1px solid var(--gray-300); border-radius: 6px; font-size: 0.85rem; }
.clickable-cl { cursor: pointer; transition: background 0.15s; }
.clickable-cl:hover { background: rgba(26,35,50,0.05); }

/* Profile info items */
.profile-info-item { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--gray-50); font-size: 0.88rem; }
.profile-info-item:last-child { border-bottom: none; }
.profile-info-label { color: var(--gray-500); font-weight: 500; }
.profile-info-value { color: var(--navy); font-weight: 600; }

/* WebAuthn credential list */
.webauthn-cred-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--gray-50);
  font-size: 0.85rem;
}
.webauthn-cred-item:last-child { border-bottom: none; }
.webauthn-cred-name { font-weight: 600; color: var(--navy); }
.webauthn-cred-date { font-size: 0.78rem; color: var(--gray-400); }

/* ==== B2-06 Processi (sottoscrizione/rimborso/trasferimento) ==== */
.proc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; }
.proc-result {
  margin-top: 0.75rem; padding: 0.75rem 1rem; border-radius: 8px;
  background: var(--gray-50); border: 1px solid var(--gray-200, #e5e7eb);
  font-size: 0.9rem; line-height: 1.5;
}
.proc-alert { color: var(--red); font-weight: 700; }
.proc-ok { color: var(--green); font-weight: 600; }

/* B2-07 — Gestione anagrafiche / lookup */
.lookup-toolbar {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 0.85rem;
}
.lookup-controls { display: flex; align-items: center; gap: 0.6rem; }
.lookup-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.75rem 1rem;
}
.lookup-actions-col { white-space: nowrap; text-align: right; }
.btn-icon {
  padding: 0.28rem 0.6rem; font-size: 0.75rem; border-radius: 6px;
  border: 1px solid var(--gray-300); background: var(--white);
  color: var(--gray-700); cursor: pointer; margin-left: 0.35rem;
  transition: background var(--transition), border-color var(--transition);
}
.btn-icon:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-icon.btn-icon-danger { color: var(--red); border-color: #f3c6c6; }
.btn-icon.btn-icon-danger:hover { background: #fdeaea; border-color: var(--red); }
.lookup-pk-badge {
  display: inline-block; font-size: 0.72rem; font-weight: 700;
  color: var(--gray-500); background: var(--gray-100, #f3f4f6);
  padding: 0.05rem 0.4rem; border-radius: 4px;
}

/* ---- Indicatori Compliance toolbar (B2-10) ---- */
.indic-toolbar {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-end;
  margin: 0.75rem 0 1rem;
}
.indic-field { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.8rem; color: var(--gray-500); }
.indic-field > span { font-weight: 600; }
.indic-field .filter-select { min-width: 160px; }
#indic-meta { margin-bottom: 0.5rem; font-weight: 600; }

/* ---- App Download Section (login) ---- */
.login-app-download { margin-bottom: 1rem; }
.app-download-card {
  display: flex; align-items: center; gap: 1rem; padding: 0.9rem 1.2rem;
  background: linear-gradient(135deg, #f8f6f0 0%, #f0ece4 100%);
  border: 1px solid var(--gold-200, #d4c9a8); border-radius: 10px;
}
.app-download-icon {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 10px;
  background: var(--gold-500, #8b7a3c); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.app-download-text { flex: 1; min-width: 0; }
.app-download-title { font-weight: 700; font-size: 0.88rem; color: var(--gray-800, #1a1a2e); margin: 0; }
.app-download-desc { font-size: 0.76rem; color: var(--gray-500, #64748b); margin: 0.15rem 0 0; }
.app-download-btn { white-space: nowrap; display: inline-flex; align-items: center; gap: 0.4rem; }

/* ---- Alert Tab ---- */
.alert-card-mini {
  padding: 0.75rem 1rem; border-radius: 8px; background: var(--gray-50, #f9f9fb);
  border-left: 4px solid var(--gray-300, #ccc); min-width: 140px; text-align: center;
}
.alert-card-mini.critical { border-left-color: #e74c3c; }
.alert-card-mini.warning { border-left-color: #f39c12; }
.alert-card-mini.ok { border-left-color: #27ae60; }
.alert-card-mini .alert-card-count { font-size: 1.6rem; font-weight: 800; color: var(--gray-800, #1a1a2e); }
.alert-card-mini .alert-card-label { font-size: 0.72rem; color: var(--gray-500); margin-top: 0.15rem; }

.alert-row {
  display: flex; align-items: center; gap: 1rem; padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--gray-100, #f1f1f1);
}
.alert-row:last-child { border-bottom: none; }
.alert-row:hover { background: var(--gray-50, #f9f9fb); }
.alert-urgency {
  flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%;
}
.alert-urgency.critical { background: #e74c3c; }
.alert-urgency.warning { background: #f39c12; }
.alert-urgency.info { background: #3498db; }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-weight: 600; font-size: 0.85rem; color: var(--gray-800); }
.alert-detail { font-size: 0.75rem; color: var(--gray-500); margin-top: 0.1rem; }
.alert-actions { flex-shrink: 0; }
.alert-dismiss-btn {
  border: none; background: none; color: var(--gray-400); cursor: pointer;
  font-size: 0.75rem; padding: 0.25rem 0.5rem; border-radius: 4px;
}
.alert-dismiss-btn:hover { background: var(--gray-100); color: var(--gray-600); }

.alert-toggle-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.75rem; background: var(--gray-50); border-radius: 6px;
}
.alert-toggle-row label { font-size: 0.82rem; font-weight: 500; cursor: pointer; }
.alert-toggle-switch {
  position: relative; width: 36px; height: 20px; cursor: pointer;
}
.alert-toggle-switch input { opacity: 0; width: 0; height: 0; }
.alert-toggle-slider {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: #ccc; border-radius: 20px; transition: 0.2s;
}
.alert-toggle-slider:before {
  content: ''; position: absolute; width: 16px; height: 16px;
  left: 2px; bottom: 2px; background: #fff; border-radius: 50%; transition: 0.2s;
}
.alert-toggle-switch input:checked + .alert-toggle-slider { background: var(--gold-500, #8b7a3c); }
.alert-toggle-switch input:checked + .alert-toggle-slider:before { transform: translateX(16px); }

/* ============ IMPORT WIZARD (B2-08 / B2-08b NAV) ============ */
.import-steps{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0 18px}
.import-step{display:flex;align-items:center;gap:6px;padding:6px 12px;border-radius:20px;background:#f1f0ea;color:#8a8676;font-size:13px;font-weight:600}
.import-step-num{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:#d8d5c6;color:#fff;font-size:12px}
.import-step.active{background:var(--gold-500,#8b7a3c);color:#fff}
.import-step.active .import-step-num{background:#fff;color:var(--gold-500,#8b7a3c)}
.import-step.done{background:#e8efe6;color:#4a7a45}
.import-step.done .import-step-num{background:#4a7a45;color:#fff}
.import-form-row{margin-bottom:12px}
.import-label{display:block;font-weight:600;font-size:13px;color:#555}
.import-dropzone{border:2px dashed #cfc9b4;border-radius:10px;padding:26px;text-align:center;background:#faf9f5;cursor:pointer;transition:all .15s}
.import-dropzone.dragover{border-color:var(--gold-500,#8b7a3c);background:#f3efe0}
.import-dropzone-icon{font-size:30px;color:var(--gold-500,#8b7a3c)}
.import-hint{font-size:12px;color:#999;margin-top:4px}
.import-filename{margin-top:8px;font-weight:600;color:#4a7a45}
.import-actions{display:flex;justify-content:space-between;gap:10px;margin-top:16px}
.import-col-code{font-size:11px;color:#aaa;font-family:monospace}
.import-req{color:#c0392b;font-weight:700}
.import-type-badge{display:inline-block;padding:2px 8px;border-radius:10px;font-size:11px;font-weight:600}
.import-type-num{background:#e6eef7;color:#2c5aa0}
.import-type-text{background:#eee;color:#666}
.import-type-key{background:#f7ecd9;color:#a6771f}
.import-type-date{background:#e8f0e6;color:#4a7a45}
.import-summary{display:flex;gap:12px;flex-wrap:wrap;margin:14px 0}
.import-stat{flex:1;min-width:90px;background:#faf9f5;border:1px solid #eae7db;border-radius:8px;padding:10px 12px;text-align:center}
.import-stat-val{font-size:22px;font-weight:700;color:#333}
.import-stat-lbl{font-size:11px;color:#888;margin-top:2px}
.import-stat-ok{background:#eef6ec;border-color:#cfe4c8}
.import-stat-ok .import-stat-val{color:#3f7a3a}
.import-stat-warn{background:#fdf3e6;border-color:#f0dcbf}
.import-stat-warn .import-stat-val{color:#b57d1a}
.import-row-badge{display:inline-block;padding:2px 8px;border-radius:10px;font-size:11px;font-weight:600}
.import-row-insert,.import-row-update{background:#eef6ec;color:#3f7a3a}
.import-row-dup-file,.import-row-skip-existing{background:#f2f2f2;color:#888}
.import-row-dup-db{background:#fdf3e6;color:#b57d1a}
.import-row-skip-certified{background:#f7e6e6;color:#b03030}
.import-row-fondo-non-risolto,.import-row-skip{background:#f7e6e6;color:#b03030}
.import-null{color:#bbb}
.import-dedup-box{background:#faf9f5;border:1px solid #eae7db;border-radius:8px;padding:12px;margin-bottom:12px}
.import-dedup-label{font-weight:600;font-size:13px;color:#555;margin-bottom:6px}
.import-dedup-chips{display:flex;gap:8px;flex-wrap:wrap}
.import-chip{display:inline-flex;align-items:center;gap:5px;background:#fff;border:1px solid #ddd;border-radius:16px;padding:4px 10px;font-size:12px;cursor:pointer}
.import-result-ok{font-size:16px;font-weight:700;color:#3f7a3a;margin-bottom:12px}
