/* ============================================================
   base.css  –  Trigol.io shared design tokens & layout
   ============================================================ */
:root {
  --bg:     #0b0f1a;
  --bg2:    #0f1629;
  --card:   #121a2b;
  --text:   #e6eaf2;
  --muted:  #9aa3b2;
  --brand:  #6EE7F9;
  --accent: #7C3AED;
  --border: #1e2a44;
  --radius: 14px;
  --green:  #22c55e;
  --red:    #ef4444;
}

*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
html, body {
  margin: 0; padding: 0;
  background: linear-gradient(180deg, var(--bg) 0%, #0a1224 100%);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  min-height: 100vh;
  /* Evita che una tabella larga faccia scorrere l'intera pagina in orizzontale
     (trascinerebbe con se' anche eventuali elementi position:fixed) — lo
     scroll orizzontale resta confinato dentro i singoli wrapper con overflow-x:auto. */
  overflow-x: hidden;
  max-width: 100%;
}
a { color: var(--brand); text-decoration: none; }

/* ─── Header ─── */
header {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(11,15,26,.90);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.nav {
  max-width: 1120px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
}
.logo { display: flex; gap: 10px; align-items: center; font-weight: 800; font-size: 27px; }
.logo .dot { width: 12px; height: 12px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--accent)); }
.logo a { text-decoration: none; color: inherit; }
.logo .io { background: linear-gradient(135deg,var(--brand),var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }

.menu { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px; border-radius: 999px; font-weight: 600;
  border: 1px solid var(--border); color: var(--text);
  font-size: 14px; background: transparent; cursor: pointer;
  font-family: inherit; text-decoration: none;
  transition: border-color .18s, color .18s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: linear-gradient(135deg,var(--brand),var(--accent)); color: #0b0f1a; border-color: transparent; }
.btn.active-page { background: linear-gradient(135deg,var(--brand),var(--accent)); color: #0b0f1a; border-color: transparent; }

/* hamburger */
.menu-toggle { display: none; flex-direction: column; justify-content: space-around; width: 30px; height: 25px; background: transparent; border: none; cursor: pointer; padding: 0; z-index: 1001; }
.menu-toggle span { width: 100%; height: 3px; background: var(--brand); border-radius: 10px; transition: .3s; }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-toggle { background: transparent; cursor: pointer; font-family: inherit; font-size: 14px; transition: border-color .2s, color .2s, background .2s, box-shadow .2s; }
.dropdown-toggle .chevron { transition: transform .25s cubic-bezier(.4,0,.2,1); flex-shrink: 0; }
.dropdown.open .dropdown-toggle { border-color: var(--brand); color: var(--brand); background: rgba(110,231,249,.08); box-shadow: 0 0 0 3px rgba(110,231,249,.15); outline: none; }
.dropdown.open .dropdown-toggle .chevron { transform: rotate(180deg); }
.dropdown-menu { display: none; position: absolute; top: calc(100% + 8px); right: 0; min-width: 260px; background: #1a2540; border: 1px solid var(--border); border-radius: 14px; padding: 6px; z-index: 2000; box-shadow: 0 8px 32px rgba(0,0,0,.4); animation: dropIn .2s cubic-bezier(.4,0,.2,1) both; }
@keyframes dropIn { from { opacity:0; transform: translateY(-6px) scale(.97); } to { opacity:1; transform: translateY(0) scale(1); } }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 10px; color: var(--text); font-size: 14px; font-weight: 500; text-decoration: none; transition: background .15s; white-space: nowrap; }
.dropdown-item:hover { background: rgba(110,231,249,.08); }
.dropdown-icon { flex-shrink: 0; width: 42px; height: 42px; border-radius: 10px; background: rgba(110,231,249,.1); border: 1px solid rgba(110,231,249,.18); display: flex; align-items: center; justify-content: center; color: var(--brand); transition: background .15s, border-color .15s; }
.dropdown-item:hover .dropdown-icon { background: rgba(110,231,249,.18); border-color: rgba(110,231,249,.35); }
.dropdown-text { display: flex; flex-direction: column; gap: 3px; }
.dropdown-title { font-weight: 700; font-size: 14px; color: var(--brand); line-height: 1.2; }
.dropdown-sub   { font-size: 12px; color: var(--muted); font-weight: 400; line-height: 1.3; white-space: normal; }
.dropdown-item + .dropdown-item { border-top: 1px solid rgba(30,42,68,.9); }

/* Footer */
footer { padding: 28px 20px; text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }
footer a { color: var(--muted); margin: 0 8px; }
footer a:hover { color: var(--brand); }

/* Controls */
.control-group { display: flex; flex-direction: column; gap: 10px; }
.control-label { color: var(--text); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.switcher { display: flex; gap: 10px; flex-wrap: wrap; }
.switcher a, .switcher button {
  text-decoration: none; color: rgba(255,255,255,.25); padding: 10px 16px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.10); background: transparent; transition: all .18s ease;
  font-size: 14px; font-weight: 600; cursor: pointer; font-family: 'Inter', system-ui, sans-serif;
}
.switcher a:hover, .switcher button:hover { border-color: rgba(255,255,255,.30); color: rgba(255,255,255,.55); }
.switcher a.active, .switcher button.active {
  border-color: var(--brand);
  color: #fff;
  font-weight: 700;
  background: rgba(110,231,249,.20);
}
.switcher-bench a.active, .switcher-bench button.active {
  border-color: #60A5FA;
  color: #60A5FA;
  background: rgba(96,165,250,.08);
}

/* Stat cards */
.stats { display: grid; gap: 14px; margin-bottom: 20px; }
.stats-5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.stats-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .08em; }
.stat .value { color: var(--text); font-size: 28px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .value.small { font-size: 18px; }
.stat .mini-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }

/* Panel */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel + .panel { margin-top: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.panel-title { font-size: 20px; font-weight: 600; color: #3fa9f5; }
.chip { display: inline-flex; align-items: center; border: 1px solid var(--border); background: var(--bg2); color: var(--muted); border-radius: 999px; padding: 8px 14px; font-size: 12px; }

/* Gain colours */
.gain-pos { color: var(--green); }
.gain-neg { color: var(--red); }

/* Error */
.error { margin-top: 18px; padding: 14px 16px; border-radius: var(--radius); background: rgba(239,68,68,.14); border: 1px solid rgba(239,68,68,.28); color: #fecaca; font-size: 14px; line-height: 1.6; }
.error-box { padding: 14px 18px; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.28); border-radius: var(--radius); color: #fecaca; font-size: 13px; }

/* Loading spinner */
.spinner { display: flex; align-items: center; justify-content: center; padding: 60px; color: var(--muted); font-size: 14px; gap: 12px; }
.spinner::before { content:''; width:20px; height:20px; border:2px solid var(--border); border-top-color:var(--brand); border-radius:50%; animation: spin .7s linear infinite; flex-shrink:0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 900px) {
  .menu-toggle { display: flex; }
  .menu { display: none !important; flex-direction: column; position: absolute; top: 100%; left: 0; width: 100%; background: var(--bg2); padding: 20px; border-bottom: 1px solid var(--border); gap: 15px; }
  .menu.active { display: flex !important; }
  .menu .btn { width: 100%; justify-content: center; }
  .menu-toggle.open span:nth-child(1) { transform: rotate(45deg) translate(5px,5px); }
  .menu-toggle.open span:nth-child(2) { opacity: 0; }
  .menu-toggle.open span:nth-child(3) { transform: rotate(-45deg) translate(7px,-8px); }
  .dropdown { width: 100%; }
  .dropdown-toggle { width: 100%; justify-content: center; }
  .dropdown-menu { left: 0; right: 0; min-width: 0; width: 100%; }
}
@media (max-width: 980px) { .stats-5 { grid-template-columns: repeat(3,minmax(0,1fr)); } .stats-4 { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 760px) { .stats-5 { grid-template-columns: repeat(2,minmax(0,1fr)); } }
@media (max-width: 640px) { .stats-5, .stats-4 { grid-template-columns: 1fr; } }
