:root {
  --bg: #0F0D1A;
  --surface: #181428;
  --surface-2: #211B38;
  --border: #2C2645;
  --text: #F4F2FA;
  --text-soft: #948CB0;
  --mint: #34E5B0;
  --coral: #FB6F84;
  --violet: #8B5CF6;
  --violet-soft: rgba(139, 92, 246, 0.16);
}

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

body {
  background: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.045) 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, -apple-system, 'Helvetica Neue', sans-serif;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: ui-monospace, 'SF Mono', monospace; }

.page { max-width: 880px; margin: 0 auto; padding: 40px 28px 64px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 44px; }
.logo { display: flex; align-items: center; gap: 10px; }
.logo .dot { width: 22px; height: 22px; border-radius: 50%; background: linear-gradient(135deg, var(--violet), var(--mint)); }
.logo span { font-weight: 600; font-size: 15px; letter-spacing: 0.02em; }

.status-pill {
  display: flex; align-items: center; gap: 7px;
  background: var(--violet-soft); border: 1px solid rgba(139, 92, 246, 0.35);
  color: #C9B8FF; font-size: 12px; font-weight: 500;
  padding: 6px 12px; border-radius: 999px;
}
.status-pill .pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--violet);
  animation: pulse 2.2s infinite;
}
.status-pill.paused .pulse { background: var(--text-soft); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.55); }
  70% { box-shadow: 0 0 0 6px rgba(139, 92, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

.hero-label { font-size: 13px; color: var(--text-soft); margin-bottom: 10px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 18px; }
.hero-number { font-size: 48px; font-weight: 600; letter-spacing: -0.01em; }
.hero-right { display: flex; align-items: center; gap: 14px; }
.delta-chip {
  font-size: 13px; font-weight: 600; color: #0F0D1A;
  background: var(--mint); padding: 5px 11px; border-radius: 999px;
}
.delta-chip.neutral { background: var(--text-soft); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px 22px 18px;
}
.card h3 {
  font-size: 12.5px; font-weight: 600;
  color: var(--text-soft); letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 16px;
}

.ai-card {
  margin-top: 28px;
  background: linear-gradient(150deg, rgba(139, 92, 246, 0.14), rgba(52, 229, 176, 0.06));
  border: 1px solid rgba(139, 92, 246, 0.4);
  border-radius: 18px;
  padding: 18px 20px;
  display: flex; gap: 14px; align-items: flex-start;
  box-shadow: 0 0 36px -10px rgba(139, 92, 246, 0.45);
}
.ai-card .spark-icon {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  background: linear-gradient(135deg, var(--violet), var(--mint));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.ai-card p { font-size: 14px; line-height: 1.5; color: var(--text); }
.ai-card .tag { display: block; margin-top: 6px; font-size: 11.5px; color: var(--text-soft); }

.chart-card { margin-top: 22px; }

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
@media (max-width: 640px) { .row2 { grid-template-columns: 1fr; } }

.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.legend { font-size: 13px; flex: 1; min-width: 160px; }
.legend div { display: flex; align-items: center; justify-content: space-between; padding: 7px 0; }
.legend .name { display: flex; align-items: center; gap: 8px; color: var(--text); }
.legend .pct { color: var(--text-soft); }
.legend .sw { width: 8px; height: 8px; border-radius: 50%; flex: none; }

.tx-list { display: flex; flex-direction: column; }
.tx-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid var(--border); }
.tx-row:last-child { border-bottom: none; }
.tx-left { display: flex; align-items: center; gap: 12px; }
.tx-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 14px; flex: none; }
.tx-meta {}
.tx-type { font-size: 13.5px; font-weight: 500; color: var(--text); }
.tx-sub { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.tx-amt { font-weight: 600; font-size: 13.5px; }
.tx-amt.in { color: var(--mint); }
.tx-amt.out { color: var(--coral); }

.empty-state { color: var(--text-soft); font-size: 13.5px; padding: 8px 0; }

.section-title { font-size: 12.5px; font-weight: 600; color: var(--text-soft); letter-spacing: 0.04em; text-transform: uppercase; margin: 32px 0 0; }

.footnote { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-soft); line-height: 1.6; }

/* --- Navigazione (pagine oltre alla dashboard) --- */
.navlinks { display: flex; gap: 4px; margin-left: 24px; flex-wrap: wrap; }
.navlinks a {
  color: var(--text-soft); font-size: 13px; text-decoration: none;
  padding: 7px 12px; border-radius: 8px;
}
.navlinks a:hover { color: var(--text); background: var(--surface-2); }
.navlinks a.active { color: var(--text); background: var(--violet-soft); }

/* --- Form --- */
.form { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--text-soft); }
.field input, .field select, .field textarea {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); font-size: 13.5px; padding: 9px 11px; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--violet); }
.field textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); font-size: 13px; font-weight: 500; padding: 9px 16px;
  cursor: pointer; font-family: inherit;
}
.btn:hover { border-color: var(--violet); }
.btn-primary { background: linear-gradient(135deg, var(--violet), #7048d6); border: none; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: transparent; border: 1px solid rgba(251, 111, 132, 0.4); color: var(--coral); }
.btn-danger:hover { background: rgba(251, 111, 132, 0.12); }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- Tabelle --- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
  text-align: left; font-size: 11.5px; font-weight: 600; color: var(--text-soft);
  letter-spacing: 0.04em; text-transform: uppercase; padding: 0 10px 10px 0; border-bottom: 1px solid var(--border);
}
table.data-table td { padding: 11px 10px 11px 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table td.num { font-family: ui-monospace, 'SF Mono', monospace; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 9px;
  border-radius: 999px; letter-spacing: 0.02em;
}
.badge.buy, .badge.positive, .badge.approved, .badge.executed { background: rgba(52, 229, 176, 0.16); color: var(--mint); }
.badge.sell, .badge.negative, .badge.rejected, .badge.execution_failed { background: rgba(251, 111, 132, 0.16); color: var(--coral); }
.badge.pending, .badge.neutral { background: rgba(148, 140, 176, 0.18); color: var(--text-soft); }

.alert { border-radius: 12px; padding: 12px 16px; font-size: 13px; margin-top: 6px; }
.alert-ok { background: rgba(52, 229, 176, 0.1); border: 1px solid rgba(52, 229, 176, 0.35); color: var(--mint); }
.alert-error { background: rgba(251, 111, 132, 0.1); border: 1px solid rgba(251, 111, 132, 0.35); color: var(--coral); }

.detail-panel { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); }
.report-content { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; color: var(--text); }
.stack { display: flex; flex-direction: column; gap: 18px; }
