/* Investment Portfolio — Zibetti & Partners
   Palette: rosso istituzionale su fondo nero. Il rosso #dc1814 e' campionato
   direttamente dal logo aziendale. */

:root {
  --red: #dc1814;
  --red-soft: rgba(220, 24, 20, 0.14);
  --red-line: rgba(220, 24, 20, 0.38);
  --bg: #0a0a0b;
  --surface: #141416;
  --surface-2: #1b1b1f;
  --line: #2b2b31;
  --text: #f3f3f4;
  --muted: #9b9ba4;
  --up: #2ecc8f;
  --down: #ff5f56;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
a { color: var(--text); }
[hidden] { display: none !important; }

/* ── Marchio ─────────────────────────────────────────────── */

.brand-logo { display: block; height: 54px; width: auto; }
.brand-logo.sm { height: 30px; }

.wordmark {
  font-size: clamp(2.4rem, 7vw, 4.6rem);
  line-height: 0.95;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--red);
  text-transform: uppercase;
  margin: 0.5rem 0 0;
}

.wordmark.sm {
  font-size: 1.05rem;
  line-height: 1.1;
  letter-spacing: 0.06em;
  font-weight: 800;
  margin: 0;
}
.wordmark.sm span { color: var(--text); }

/* ── Accesso ─────────────────────────────────────────────── */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(220, 24, 20, 0.22), transparent 70%),
    var(--bg);
}

.login-card { max-width: 460px; text-align: center; }
.login-sub { color: var(--muted); margin: 0.9rem 0 2rem; letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.74rem; }
.login-note { color: var(--muted); font-size: 0.8rem; margin-top: 1.4rem; }
.login-card .brand-logo { margin: 0 auto; }

/* ── Barra superiore ─────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: rgba(10, 10, 11, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-brand { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }
.topbar-actions { display: flex; align-items: center; gap: 0.6rem; flex-shrink: 0; }
.status { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }

.tabs {
  position: sticky;
  top: 61px;
  z-index: 19;
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  overflow-x: auto;
  background: rgba(10, 10, 11, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 550;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.is-active { color: #fff; background: var(--red); }

main { padding: 1.25rem; max-width: 1400px; margin: 0 auto; }

/* ── Contenitori ─────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem 1.2rem;
  margin-bottom: 1.1rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.card-head h2 { font-size: 0.95rem; letter-spacing: 0.02em; }
.card-head h2::before {
  content: "";
  display: inline-block;
  width: 3px; height: 0.85em;
  background: var(--red);
  margin-right: 0.55rem;
  vertical-align: -0.08em;
  border-radius: 2px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.hint { color: var(--muted); font-size: 0.78rem; margin: 0.7rem 0 0; }
.error { color: var(--down); font-size: 0.85rem; }

/* ── KPI ─────────────────────────────────────────────────── */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1.1rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.kpi .label { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; }
.kpi .value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 0.2rem; }
.kpi .sub { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ── Tabelle ─────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { padding: 0.55rem 0.7rem; text-align: right; white-space: nowrap; }
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--surface);
}
td { border-bottom: 1px solid rgba(43, 43, 49, 0.6); font-variant-numeric: tabular-nums; }
th:first-child, td:first-child { text-align: left; }
tbody tr:hover td { background: var(--surface-2); }
.ticker { font-weight: 700; }
.sub-name { color: var(--muted); font-weight: 400; font-size: 0.78rem; display: block; }
.up { color: var(--up); }
.down { color: var(--down); }
.num { font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); padding: 1.6rem 0; text-align: center; }

/* ── Controlli ───────────────────────────────────────────── */

.btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  padding: 0.45rem 0.95rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-lg { padding: 0.7rem 1.8rem; font-size: 0.95rem; width: 100%; }
.btn-icon {
  background: none; border: 0; color: var(--muted);
  cursor: pointer; font-size: 1rem; padding: 0 0.3rem;
}
.btn-icon:hover { color: var(--down); }

.input {
  font: inherit;
  font-size: 0.85rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  width: 100%;
}
.input:focus { outline: none; border-color: var(--red-line); box-shadow: 0 0 0 3px var(--red-soft); }

label { display: block; font-size: 0.76rem; color: var(--muted); }
label .input { margin-top: 0.25rem; }
label small { display: block; margin-top: 0.25rem; font-size: 0.7rem; }

.form-row { display: flex; gap: 0.7rem; align-items: end; flex-wrap: wrap; }
.form-row label { flex: 1 1 130px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.9rem; align-items: end; }
.check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; }
.check input { accent-color: var(--red); }

.seg { display: flex; gap: 2px; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.seg button {
  background: none; border: 0; color: var(--muted); font: inherit;
  font-size: 0.76rem; font-weight: 600; padding: 0.28rem 0.65rem;
  border-radius: 6px; cursor: pointer;
}
.seg button.is-active { background: var(--red); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.9rem; }
.chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.25rem 0.5rem 0.25rem 0.75rem;
  font-size: 0.8rem; font-weight: 600;
}

/* ── Grafici ─────────────────────────────────────────────── */

.chart-wrap { position: relative; height: 300px; }
.chart-wrap.sm { height: 260px; }

/* ── Heatmap correlazioni ────────────────────────────────── */

#heatmap table { font-size: 0.75rem; }
#heatmap td.cell {
  text-align: center;
  font-weight: 650;
  color: #fff;
  border: 1px solid var(--bg);
  min-width: 54px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}
#heatmap th { background: var(--surface); }
#heatmap th.rowhead { text-align: left; position: sticky; left: 0; z-index: 2; }

.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin: 0 0.25rem 0 0.5rem; vertical-align: -1px; }
.sw-hi { background: var(--red); }
.sw-lo { background: #2b6cb0; }

.pair-list { list-style: none; margin: 0; padding: 0; }
.pair-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-bottom: 1px solid rgba(43,43,49,0.6); font-size: 0.83rem; }
.pair-list b { font-variant-numeric: tabular-nums; }

/* ── News ────────────────────────────────────────────────── */

.news-list { display: flex; flex-direction: column; }
.news-item { padding: 0.7rem 0; border-bottom: 1px solid rgba(43, 43, 49, 0.6); }
.news-item:last-child { border-bottom: 0; }
.news-item a { color: var(--text); text-decoration: none; font-weight: 600; font-size: 0.9rem; }
.news-item a:hover { color: var(--red); }
.news-meta { color: var(--muted); font-size: 0.72rem; margin-top: 0.2rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.news-tag {
  background: var(--red-soft); color: var(--red);
  border: 1px solid var(--red-line);
  border-radius: 4px; padding: 0 0.35rem; font-weight: 700;
}
.news-list.compact .news-item { padding: 0.5rem 0; }
.news-group-title { font-size: 0.8rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 1.1rem 0 0.2rem; }
.news-group-title:first-child { margin-top: 0; }

/* ── Avvertenza ──────────────────────────────────────────── */

.disclaimer { border-left: 3px solid var(--red); }
.disclaimer h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--red); margin-bottom: 0.5rem; }
.disclaimer p { color: var(--muted); font-size: 0.82rem; margin: 0; }

/* ── Toast ───────────────────────────────────────────────── */

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  z-index: 60;
  max-width: min(90vw, 460px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

@media (max-width: 620px) {
  main { padding: 0.9rem; }
  .topbar { flex-wrap: wrap; }
  .status { width: 100%; order: 3; }
  .wordmark.sm { font-size: 0.9rem; }
  .kpi .value { font-size: 1.25rem; }
}
