/* ============================================================
   LAMBDA — interfaccia Decision Engine · v4 "premium"
   Palette invariata: Soft Linen · Alabaster Grey · Tuscan Sun · Carbon Black
   ============================================================ */

:root {
  --font-display: "Space Grotesk", "IBM Plex Sans", system-ui, sans-serif;
  --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --r-card: 18px;
  --r-input: 12px;
  --r-cta: 14px;
  --r-ghost: 12px;
  --r-chip: 8px;
  --r-pill: 999px;

  --home: var(--ink);     --home-d: var(--ink);
  --away: var(--accent);  --away-d: var(--ink-soft);
  --ok: var(--ink);       --bad: var(--warn);

  --ease: cubic-bezier(.32, .72, .28, 1);
}

/* ---- Tema chiaro ---- */
html[data-theme="light"] {
  --page: #E8EDDF;
  --card: #FFFFFF;
  --card-2: #F1F4EB;
  --sunken: #DFE6DD;
  --ink: #242423;
  --ink-soft: #45463F;
  --muted: #73776B;
  --line: #D9E1D8;
  --line-strong: #242423;
  --header: #242423;
  --header-ink: #E8EDDF;
  --accent: #F5CB5C;
  --accent-press: #E4B63F;
  --accent-wash: rgba(245, 203, 92, .16);
  --on-accent: #242423;
  --draw: #767A6D;
  --warn: #A6743B;
  --good: #4C7A46;
  --input-bg: #FFFFFF;
  --ring: rgba(245, 203, 92, .55);
  --shadow-1: 0 1px 2px rgba(36, 36, 35, .05), 0 4px 16px rgba(36, 36, 35, .05);
  --shadow-2: 0 2px 6px rgba(36, 36, 35, .08), 0 16px 40px rgba(36, 36, 35, .12);
  --topbar-sep: 0 1px 0 rgba(0, 0, 0, .12);
  --glass: rgba(255, 255, 255, .82);
}

/* ---- Tema scuro ---- */
html[data-theme="dark"] {
  --page: #242423;
  --card: #2C2D29;
  --card-2: #34352F;
  --sunken: #1D1E1B;
  --ink: #E8EDDF;
  --ink-soft: #C6CCBD;
  --muted: #8D9284;
  --line: #43443C;
  --line-strong: #CFDBD5;
  --header: #1B1C1A;
  --header-ink: #E8EDDF;
  --accent: #F5CB5C;
  --accent-press: #FFD974;
  --accent-wash: rgba(245, 203, 92, .14);
  --on-accent: #242423;
  --draw: #A6AA9B;
  --warn: #D89B62;
  --good: #8FBF88;
  --input-bg: #1D1E1B;
  --ring: rgba(245, 203, 92, .4);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .25), 0 6px 20px rgba(0, 0, 0, .22);
  --shadow-2: 0 4px 10px rgba(0, 0, 0, .35), 0 18px 48px rgba(0, 0, 0, .4);
  --topbar-sep: 0 1px 0 rgba(0, 0, 0, .5);
  --glass: rgba(44, 45, 41, .85);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
button, a, input, select, label { -webkit-tap-highlight-color: transparent; }
button { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
body {
  font-family: var(--font-sans);
  background: var(--page);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: 48px;
  overscroll-behavior-x: none;
  transition: background .2s, color .2s;
}
::selection { background: var(--accent); color: var(--on-accent); }
svg { display: block; }
/* niente spinner sui campi numerici: più pulito e uniforme ovunque */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  padding-left: max(16px, env(safe-area-inset-left, 16px));
  padding-right: max(16px, env(safe-area-inset-right, 16px));
  background: var(--header); color: var(--header-ink);
  border-bottom: 1px solid rgba(207, 219, 213, .14);
  box-shadow: var(--topbar-sep);
  transition: box-shadow .25s var(--ease);
}
.topbar.scrolled { box-shadow: 0 4px 20px rgba(0, 0, 0, .22); }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--header-ink); }
.brand-mark {
  width: 38px; height: 34px; border-radius: 10px; flex-shrink: 0;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: .92rem;
  font-family: var(--font-display); letter-spacing: .5px;
  display: flex; align-items: center; justify-content: center;
}
.brand-txt { font-family: var(--font-display); line-height: 1.05; font-weight: 600; font-size: 1.06rem; letter-spacing: -.2px; }
.brand-txt small {
  display: block; font-family: var(--font-mono); font-size: .58rem; font-weight: 500;
  color: var(--header-ink); opacity: .6; letter-spacing: 1px; margin-top: 3px; text-transform: uppercase;
}
.topnav { display: flex; align-items: center; gap: 10px; }
.user { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: .78rem; opacity: .9; }
.user svg { width: 15px; height: 15px; opacity: .8; }
.icon-btn {
  background: transparent; border: 1px solid rgba(207, 219, 213, .3);
  color: var(--header-ink); width: 40px; height: 40px; border-radius: var(--r-pill); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: border-color .18s, color .18s, transform .18s var(--ease);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); transform: scale(1.06); }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 18px; height: 18px; }
html[data-theme="dark"] .theme-ico-dark { display: none; }
html[data-theme="light"] .theme-ico-light { display: none; }

.container { max-width: 820px; margin: 0 auto; padding: 20px 16px; }

/* ---------- Elementi comuni ---------- */
.muted { color: var(--muted); }
.hidden { display: none !important; }
.ta-c { text-align: center; }
.pos { color: var(--good); }
.neg { color: var(--warn); }

.alert {
  padding: 12px 16px; border-radius: var(--r-input); font-size: .9rem;
  border: 1px solid var(--line); background: var(--card-2); margin-bottom: 14px;
}
.alert.warn { border-color: var(--warn); color: var(--warn); }
.alert.ok { border-color: var(--ok); }

.btn-primary {
  font-family: var(--font-display); font-weight: 700; letter-spacing: .02em;
  background: var(--accent); color: var(--on-accent);
  border: none; border-radius: var(--r-cta); padding: 13px 28px; font-size: 1rem; cursor: pointer;
  box-shadow: 0 2px 10px rgba(245, 203, 92, .35);
  transition: background .18s, transform .18s var(--ease), box-shadow .18s;
}
.btn-primary:hover { background: var(--accent-press); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(245, 203, 92, .45); }
.btn-primary:active { transform: translateY(0) scale(.98); }
.btn-primary:disabled { opacity: .6; transform: none; box-shadow: none; cursor: default; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; color: inherit; border: 1px solid var(--line);
  border-radius: var(--r-ghost); padding: 10px 16px; font-size: .88rem; cursor: pointer;
  text-decoration: none;
  transition: border-color .18s, color .18s, background .18s, transform .18s var(--ease);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-press); background: var(--accent-wash); }
.btn-ghost:active { transform: scale(.98); }
.btn-ghost svg { width: 15px; height: 15px; }
.btn-primary.sm { padding: 9px 16px; font-size: .85rem; }
.btn-ghost.sm { padding: 8px 12px; font-size: .82rem; }
.link-btn { background: none; border: none; color: var(--accent-press); cursor: pointer; font-size: .85rem; text-decoration: underline; }

input[type="text"], input[type="number"], input[type="password"] {
  width: 100%; padding: 11px 13px;
  background: var(--input-bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-input);
  font-family: var(--font-mono); font-size: .95rem;
  -webkit-appearance: none; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
input::placeholder { color: var(--muted); opacity: .6; }

select {
  width: 100%; padding: 11px 36px 11px 13px; background: var(--input-bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-input);
  font-family: var(--font-sans); font-size: .92rem; cursor: pointer;
  -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%238D9284' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center;
  transition: border-color .15s, box-shadow .15s;
}
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* ---------- Auth ---------- */
.auth-card {
  max-width: 380px; margin: 8vh auto 0; padding: 30px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: var(--shadow-1);
}
.auth-card h1 { font-family: var(--font-display); margin: 0 0 4px; font-size: 1.4rem; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.auth-card label { font-size: .82rem; color: var(--muted); display: block; margin-bottom: 4px; }
.auth-card .btn-primary { width: 100%; margin-top: 6px; }
.auth-foot { text-align: center; margin-top: 14px; font-size: .85rem; }
.auth-foot a { color: var(--accent-press); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab {
  display: flex; align-items: center;
  font-family: var(--font-display); font-size: .95rem; font-weight: 600;
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 10px 16px; border-radius: var(--r-pill);
  transition: color .18s, background .18s, transform .16s var(--ease);
}
.tab:hover { color: var(--ink); background: var(--accent-wash); }
.tab:active { transform: scale(.95); }
.tab.active { color: var(--ink); background: var(--accent); color: var(--on-accent); }
.tab-ic { margin-right: 9px; opacity: .8; display: inline-flex; }
.tab-ic svg { width: 19px; height: 19px; display: block; }
.tab.active .tab-ic { opacity: 1; animation: tab-pop .35s var(--ease); }
@keyframes tab-pop { 0% { transform: scale(1); } 45% { transform: scale(1.18); } 100% { transform: scale(1); } }
.tabpane { display: none; }
.tabpane.active { display: block; animation: pane-in .3s var(--ease) both; }
.tabpane.active.from-right { animation-name: pane-in-r; }
.tabpane.active.from-left { animation-name: pane-in-l; }
@keyframes pane-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pane-in-r { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: none; } }
@keyframes pane-in-l { from { opacity: 0; transform: translateX(-22px); } to { opacity: 1; transform: none; } }

/* ---------- Card / sezioni ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  margin-bottom: 16px; box-shadow: var(--shadow-1);
}
.sec { overflow: hidden; }
.sec-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px 12px;
}
.sec-num {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 9px;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--font-mono); font-weight: 600; font-size: .85rem;
  display: flex; align-items: center; justify-content: center;
}
/* chip icona stile Revolut: quadrato morbido colorato + icona a tratto */
.sec-ic {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 12px;
  background: var(--accent-wash); color: var(--accent-press);
  display: flex; align-items: center; justify-content: center;
}
.sec-ic svg { width: 19px; height: 19px; display: block; }
.sec-title { font-family: var(--font-display); font-weight: 600; font-size: 1.04rem; letter-spacing: -.2px; }
.sec-sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.sec-body { padding: 4px 18px 18px; }

.teams-row { display: flex; align-items: flex-end; gap: 12px; }
.team-field { flex: 1; }
.team-field label { font-size: .8rem; color: var(--muted); display: block; margin-bottom: 5px; }
.vs { font-family: var(--font-mono); color: var(--muted); padding-bottom: 12px; }

.ht-score { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 16px 0 4px; }
.ht-box { text-align: center; }
.ht-box small { display: block; font-size: .72rem; color: var(--muted); margin-bottom: 4px; }
.ht-box input { width: 76px; text-align: center; font-size: 1.35rem; font-weight: 600; }
.ht-sep { font-size: 1.4rem; color: var(--muted); }

.odds-block { margin-top: 16px; }
.odds-title { font-size: .85rem; font-weight: 600; margin-bottom: 8px; }
.odds-title .opt { font-style: normal; font-weight: 400; color: var(--muted); font-size: .78rem; }
.odds-inputs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.odds-inputs small { display: block; font-size: .72rem; color: var(--muted); margin-bottom: 4px; }
.odds-inputs.live-ou { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 560px) { .odds-inputs.live-ou { grid-template-columns: repeat(4, 1fr); } }

.prep-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.prep-hint { font-size: .78rem; }

.stat-grid { padding: 0 18px 16px; }
.grid-head {
  display: grid; grid-template-columns: 1fr 96px 96px; gap: 8px;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.stat-row {
  display: grid; grid-template-columns: 1fr 96px 96px; gap: 8px;
  align-items: center; padding: 5px 0;
}
.stat-row label { font-size: .86rem; }
.stat-row input { text-align: center; padding: 8px 6px; }

.actions {
  display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin: 16px 0 22px;
}
.save-check { font-size: .85rem; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-right: auto; }

.edit-banner {
  background: var(--accent-wash); border: 1px solid var(--accent);
  border-radius: var(--r-input); padding: 10px 14px; font-size: .88rem; margin-bottom: 14px;
}

/* layout manuale: due colonne su desktop */
.manual-grid { display: grid; gap: 0 20px; }
@media (min-width: 1100px) {
  .manual-grid { grid-template-columns: minmax(420px, 1fr) minmax(420px, 1fr); align-items: start; }
  .mg-right { position: sticky; top: 76px; }
}

/* ---------- Risultato: verdetto DE ---------- */
.result { margin-top: 8px; }
.res-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow-1); }
.res-head {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--header); color: var(--header-ink);
  font-family: var(--font-mono); font-size: .78rem; letter-spacing: .5px; text-transform: uppercase;
  padding: 10px 18px;
}
.res-body { padding: 16px 18px; }

.de-verdict {
  font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
  padding: 13px 16px; border-radius: var(--r-input); margin-bottom: 12px;
  border: 1px solid var(--line);
}
.de-verdict.yes { background: var(--accent-wash); border-color: var(--accent); }
.de-verdict.no { background: var(--card-2); color: var(--muted); }
.de-verdict.info { background: var(--card-2); color: var(--ink-soft); font-weight: 500; font-size: .9rem; }

.bet-row {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--r-input); padding: 11px 14px; margin-bottom: 8px;
}
.bet-mark {
  font-family: var(--font-mono); font-weight: 600; color: var(--on-accent);
  background: var(--accent); border-radius: 7px;
  width: 24px; height: 24px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.bet-main { flex: 1; min-width: 0; }
.bet-play { font-weight: 600; font-size: .95rem; }
.bet-sub { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.bet-nums { text-align: right; font-family: var(--font-mono); }
.bet-ev { display: block; font-weight: 600; font-size: .92rem; }
.bet-stake { display: block; font-size: .76rem; color: var(--muted); margin-top: 2px; }

.rej-list summary { cursor: pointer; font-size: .84rem; color: var(--muted); padding: 8px 2px; }
.rej-row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: .82rem; padding: 7px 4px; border-bottom: 1px solid var(--line);
}
.rej-row:last-child { border-bottom: none; }
.rej-out { font-weight: 500; }
.rej-why { color: var(--muted); flex: 1; text-align: right; }

/* ---------- Numeri del modello ---------- */
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.metric {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-input);
  padding: 13px 10px; text-align: center; box-shadow: var(--shadow-1);
}
.res-body .metric { box-shadow: none; background: var(--card-2); }
.metric .m-val { font-family: var(--font-mono); font-weight: 600; font-size: 1.25rem; }
.metric .m-lab { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }
.metric .m-val.pos { color: var(--good); }
.metric .m-val.neg { color: var(--warn); }
.metric.warn .m-val { color: var(--warn); }

.prob-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.prob-table th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line-strong);
}
.prob-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.prob-table tr:last-child td { border-bottom: none; }
.prob-table .num { font-family: var(--font-mono); text-align: right; }
.prob-table .closed { color: var(--muted); font-style: italic; }
.prob-bar {
  position: relative; background: var(--sunken); border-radius: var(--r-pill);
  height: 6px; min-width: 60px; overflow: hidden;
}
.prob-bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: inherit; }

.res-foot {
  font-size: .74rem; color: var(--muted); font-family: var(--font-mono);
  padding: 10px 18px; border-top: 1px solid var(--line);
}

/* ---------- Badge & pill ---------- */
.badge {
  font-family: var(--font-mono); font-size: .7rem; letter-spacing: .4px;
  padding: 3px 9px; border-radius: var(--r-pill); border: 1px solid var(--line);
}
.badge.vinta { border-color: var(--good); color: var(--good); background: rgba(76, 122, 70, .1); }
.badge.persa, .badge.mista { border-color: var(--warn); color: var(--warn); background: rgba(166, 116, 59, .09); }
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .badge.vinta { background: color-mix(in srgb, var(--good) 10%, transparent); }
  .badge.persa, .badge.mista { background: color-mix(in srgb, var(--warn) 8%, transparent); }
}
.badge.aperta { border-color: var(--accent); color: var(--accent-press); }
.badge.auto { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }

/* ---------- Storico: card riprogettate ---------- */
.hist-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.hist-metrics { grid-template-columns: repeat(4, 1fr); margin: 0 0 14px; }

.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--sunken); border-radius: var(--r-pill);
}
.seg-btn {
  border: none; background: transparent; color: var(--muted); cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: .82rem;
  padding: 7px 14px; border-radius: var(--r-pill);
  transition: background .18s, color .18s, box-shadow .18s;
}
.seg-btn.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-1); }
.seg-btn:active { transform: scale(.93); }
.seg-btn { transition: background .18s, color .18s, box-shadow .18s, transform .15s var(--ease); }

/* comparsa "a cascata" delle card (storico, bozze, quote) */
@keyframes card-in { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.hist-card, .draft-item, .dw-group { animation: card-in .38s var(--ease) backwards; }
.hist-card:nth-child(2), .dw-group:nth-child(2) { animation-delay: .05s; }
.hist-card:nth-child(3), .dw-group:nth-child(3) { animation-delay: .1s; }
.hist-card:nth-child(4), .dw-group:nth-child(4) { animation-delay: .15s; }
.hist-card:nth-child(5), .dw-group:nth-child(5) { animation-delay: .2s; }
.hist-card:nth-child(n+6) { animation-delay: .24s; }
/* oltre l'ottava niente animazione (sono fuori schermo al render: si evita il
   "pop" durante lo scroll) e niente paint finche' non entrano nel viewport.
   NB: content-visibility SOLO su card non animate — con un'animazione attiva
   il browser la fa ripartire a ogni rientro nel viewport (card invisibili). */
.hist-card:nth-child(n+9), .dw-group:nth-child(n+9) { animation: none; }
@supports (content-visibility: auto) {
  .hist-card:nth-child(n+9) { content-visibility: auto; contain-intrinsic-size: auto 230px; }
}

.hist-grid { display: grid; gap: 14px; grid-template-columns: repeat(var(--hist-cols, 1), 1fr); align-items: start; }
.hist-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.hist-col .card { margin-bottom: 0; }

.hist-card { margin: 0; }
.hc-top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 10px; cursor: pointer;
  transition: opacity .15s;
}
.hc-top:active { opacity: .7; }
.hc-main { min-width: 0; }
.hc-title { font-family: var(--font-display); font-weight: 600; font-size: 1rem; letter-spacing: -.1px; }
.hc-meta { font-size: .74rem; color: var(--muted); font-family: var(--font-mono); margin-top: 3px; font-variant-numeric: tabular-nums; }
.hc-score { text-align: center; flex-shrink: 0; }
.hc-ft { font-family: var(--font-mono); font-weight: 700; font-size: 1.25rem; letter-spacing: 1px; }
.hc-ht { font-size: .68rem; color: var(--muted); font-family: var(--font-mono); }
.hc-badges { display: flex; gap: 6px; align-items: center; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

.hc-bets { padding: 0 16px 6px; }
.hc-bet {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--line);
  font-size: .86rem;
}
.hc-dot { width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .68rem; font-weight: 700; }
.hc-dot.win { background: rgba(76, 122, 70, .15); color: var(--good); }
.hc-dot.loss { background: rgba(166, 116, 59, .13); color: var(--warn); }
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .hc-dot.win { background: color-mix(in srgb, var(--good) 16%, transparent); }
  .hc-dot.loss { background: color-mix(in srgb, var(--warn) 14%, transparent); }
}
.hc-dot.open { background: var(--accent-wash); color: var(--accent-press); }
.hc-bet-main { flex: 1; min-width: 0; }
.hc-bet-play { font-weight: 600; }
.hc-bet-sub { font-size: .74rem; color: var(--muted); font-family: var(--font-mono); }
.hc-bet-pnl { font-family: var(--font-mono); font-weight: 600; font-size: .9rem; text-align: right; white-space: nowrap; }
.hc-nobet { padding: 8px 0 10px; border-top: 1px solid var(--line); font-size: .8rem; color: var(--muted); }

.hc-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 16px; border-top: 1px solid var(--line); background: var(--card-2);
  font-size: .8rem; border-radius: 0 0 var(--r-card) var(--r-card);
}
.hc-foot .hc-roi { color: var(--muted); font-family: var(--font-mono); }
.hc-pnl { font-family: var(--font-mono); font-weight: 700; }

.hc-more { padding: 4px 16px 14px; }
.final-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.final-row input { width: 64px; text-align: center; }
.final-sep { color: var(--muted); }
.hist-actions { display: flex; gap: 8px; margin-top: 12px; }

/* backup calibrazioni */
.bk-row { display: flex; justify-content: space-between; gap: 10px; align-items: center;
  font-size: .85rem; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bk-row:last-child { border-bottom: none; }
.bk-row .badge { margin-left: 6px; }
.bk-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.hist-bets { margin: 12px 0; }
.hist-bet {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: .85rem; padding: 7px 2px; border-bottom: 1px solid var(--line);
}
.hist-bet:last-child { border-bottom: none; }
.hb-won { color: var(--good); font-weight: 600; }
.hb-lost { color: var(--warn); font-weight: 600; }

@media (max-width: 540px) {
  .metrics { grid-template-columns: repeat(3, 1fr); }
  .odds-inputs { grid-template-columns: repeat(3, 1fr); }
  .grid-head, .stat-row { grid-template-columns: 1fr 72px 72px; }
  .hist-metrics { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   Desktop ≥ 1100px: sidebar + contenuto largo
   ============================================================ */
.tab-txt { display: inline; }
.nav-badge {
  margin-left: 8px; background: var(--on-accent); color: var(--accent);
  font-family: var(--font-mono); font-size: .68rem; font-weight: 600;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  display: inline-flex; align-items: center; justify-content: center;
}
.tab:not(.active) .nav-badge { background: var(--accent); color: var(--on-accent); }

@media (min-width: 1100px) {
  .container { max-width: 1500px; padding: 24px 32px; }
  body { padding-bottom: 24px; }

  .tabs {
    position: fixed; left: 0; top: 61px; bottom: 0; width: 216px;
    flex-direction: column; gap: 4px; padding: 18px 12px;
    border-right: 1px solid var(--line);
    background: var(--card); margin: 0; z-index: 20;
  }
  .tab { text-align: left; padding: 12px 14px; border-radius: var(--r-ghost); font-size: 1rem; }
  .tab.active { background: var(--accent); }
  .tabpane.active { margin-left: 232px; }
  .odds-inputs.live-ou { grid-template-columns: repeat(4, 1fr); }

  /* storico: barra filtri e riepilogo sulla stessa riga, meno vuoto */
  #tab-storico .hist-metrics { grid-template-columns: repeat(4, minmax(0, 220px)); }
  .card { margin-bottom: 18px; }
}

/* ============================================================
   Dashboard
   ============================================================ */
.dash-hero {
  display: flex; gap: 24px; align-items: stretch;
  padding: 24px 26px; margin-bottom: 14px;
}
.dh-cap { display: flex; flex-direction: column; justify-content: center; gap: 6px; min-width: 240px; }
.dh-label { font-family: var(--font-mono); font-size: .72rem; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); }
.dh-value { font-family: var(--font-display); font-size: 2.7rem; font-weight: 700; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.dh-delta { font-size: .9rem; font-weight: 600; }
.dh-chart { flex: 1; min-width: 0; display: flex; align-items: center; }
.dh-chart svg { width: 100%; height: 150px; }
.eq-line { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.eq-area { fill: var(--accent-wash); stroke: none; }
.eq-base { stroke: var(--line); stroke-dasharray: 4 4; }
.eq-dot { fill: var(--accent); }
.dash-metrics { grid-template-columns: repeat(6, 1fr); margin-bottom: 14px; }
@media (max-width: 900px) { .dash-metrics { grid-template-columns: repeat(3, 1fr); } .dash-hero { flex-direction: column; } }

/* --- empty state --- */
.empty-state { text-align: center; padding: 56px 32px; }
.empty-state.small { padding: 24px; box-shadow: none; }
.empty-state .es-mark {
  width: 64px; height: 56px; margin: 0 auto 16px; border-radius: 16px;
  background: var(--accent); color: var(--on-accent);
  font-family: var(--font-display); font-size: 2rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.empty-state h2 { font-family: var(--font-display); margin: 0 0 10px; }
.empty-state p { color: var(--muted); line-height: 1.65; margin: 0 0 18px; }
.es-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ============================================================
   Oggi: partite + drawer quote live
   ============================================================ */
.oggi-grid { display: grid; gap: 16px; }
@media (min-width: 1100px) { .oggi-grid { grid-template-columns: 3fr 2fr; align-items: start; } }

.today-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px; margin-bottom: 10px; cursor: pointer;
  transition: transform .18s var(--ease), box-shadow .18s, border-color .18s;
}
.today-item:hover { transform: translateY(-1px); box-shadow: var(--shadow-2); border-color: var(--accent); }
.today-item:active { transform: scale(.985); box-shadow: var(--shadow-1); }
.today-item.followed { border-color: var(--accent); }
.today-main { flex: 1; min-width: 0; }
.today-title { font-weight: 600; font-size: .98rem; }
.today-meta { font-size: .8rem; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.today-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.star {
  background: none; border: none; cursor: pointer; padding: 4px;
  font-size: 1.25rem; line-height: 1; color: var(--line); transition: color .15s, transform .2s var(--ease);
}
.star:hover { transform: scale(1.2); color: var(--accent); }
.star:active { transform: scale(.82); }
.star.on { color: var(--accent); }
.draft-odds b { font-family: var(--font-mono); font-weight: 600; }

.wbadge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: var(--r-pill);
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.wbadge.w-live { border-color: var(--accent); color: var(--accent-press, var(--accent)); background: var(--accent-wash); }
.wbadge.w-pred { border-color: var(--good); color: var(--good); }
.wbadge.w-done { opacity: .75; }
.wbadge.w-skip { border-style: dashed; opacity: .65; }

.live-item { padding: 14px 16px; margin-bottom: 10px; }
.live-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
#live-list a { color: var(--accent-press, var(--accent)); }
.live-wait {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
  font-size: .85rem; color: var(--muted);
}
.pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  flex-shrink: 0; animation: wp-blink 1.8s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } }

/* --- drawer quote live --- */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 20, 18, .45);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .3s var(--ease);
}
.drawer-overlay.open { opacity: 1; }
.drawer-overlay[hidden], .odds-drawer[hidden] { display: none; }
.odds-drawer {
  position: fixed; z-index: 61; display: flex; flex-direction: column;
  background: var(--card); box-shadow: var(--shadow-2);
  /* mobile: bottom sheet */
  left: 0; right: 0; bottom: 0; max-height: 78vh;
  border-radius: 22px 22px 0 0; border: 1px solid var(--line); border-bottom: none;
  transform: translateY(102%); transition: transform .42s cubic-bezier(.32, .72, 0, 1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  will-change: transform;
}
@supports (max-height: 78dvh) { .odds-drawer { max-height: 78dvh; } }
.odds-drawer.open { transform: translateY(0); }
.drawer-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 10px auto 2px; flex-shrink: 0; }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 18px 12px; border-bottom: 1px solid var(--line); flex-shrink: 0;
}
.drawer-title { font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; letter-spacing: -.2px; }
.drawer-sub { font-size: .78rem; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.drawer-close {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--sunken); color: var(--muted); font-size: .9rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  transition: background .15s, color .15s;
}
.drawer-close:hover { background: var(--accent-wash); color: var(--ink); }
.drawer-close:active { transform: scale(.88); }
.drawer-close { transition: background .15s, color .15s, transform .15s var(--ease); }
.drawer-body { overflow-y: auto; padding: 14px 18px 20px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

@media (min-width: 1100px) {
  /* desktop: pannello laterale destro */
  .odds-drawer {
    left: auto; top: 61px; bottom: 0; right: 0; width: 420px; max-height: none;
    border-radius: 0; border: none; border-left: 1px solid var(--line);
    transform: translateX(102%);
  }
  .odds-drawer.open { transform: translateX(0); }
  .drawer-grip { display: none; }
  .drawer-head { padding-top: 16px; }
}

.dw-group { margin-bottom: 16px; }
.dw-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.dw-odds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dw-odds.cols-2 { grid-template-columns: repeat(2, 1fr); }
.dw-cell {
  background: var(--card-2); border: 1px solid var(--line); border-radius: var(--r-input);
  padding: 9px 6px; text-align: center;
}
.dw-cell small { display: block; font-size: .7rem; color: var(--muted); margin-bottom: 3px; }
.dw-cell b { font-family: var(--font-mono); font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.dw-cell.off b { color: var(--muted); font-weight: 400; }
/* variazione live: il numero conta (JS) e la cella lampeggia verde/rossa
   (classi .up/.down messe dal JS anche sulla cella: compatibile con ogni browser) */
.dw-cell b.up { animation: dw-up 1.6s var(--ease); }
.dw-cell b.down { animation: dw-down 1.6s var(--ease); }
@keyframes dw-up {
  0% { color: var(--good); }
  25% { color: var(--good); transform: translateY(-1px); }
  100% { color: inherit; }
}
@keyframes dw-down {
  0% { color: var(--warn); }
  25% { color: var(--warn); transform: translateY(1px); }
  100% { color: inherit; }
}
.dw-cell { transition: border-color 1.4s var(--ease), background 1.4s var(--ease); }
.dw-cell.up { border-color: var(--good); background: rgba(76, 122, 70, .08); }
.dw-cell.down { border-color: var(--warn); background: rgba(166, 116, 59, .08); }
@supports (color: color-mix(in srgb, red 50%, blue)) {
  .dw-cell.up { border-color: color-mix(in srgb, var(--good) 45%, var(--line)); background: color-mix(in srgb, var(--good) 7%, var(--card-2)); }
  .dw-cell.down { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); background: color-mix(in srgb, var(--warn) 7%, var(--card-2)); }
}
.dw-note { font-size: .78rem; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.dw-empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: .9rem; }

/* ============================================================
   Bozze (Manuale)
   ============================================================ */
.draft-item {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 16px; margin-bottom: 10px;
}
.draft-title { font-weight: 600; font-size: 1rem; }
.draft-meta { font-size: .8rem; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.draft-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ============================================================
   Impostazioni
   ============================================================ */
.set-grid { display: grid; gap: 16px; }
@media (min-width: 1280px) { .set-grid { grid-template-columns: 1fr 1fr; align-items: start; } }

.tools-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
@media (max-width: 700px) { .tools-grid { grid-template-columns: 1fr; } }
.tiered-config { margin-top: 6px; padding-top: 4px; border-top: 1px dashed var(--line); }
.tiered-grid { grid-template-columns: repeat(5, 1fr); gap: 10px; }
@media (max-width: 700px) { .tiered-grid { grid-template-columns: repeat(2, 1fr); } }
.tool-label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }

.stake-hint { font-size: .84rem; margin-top: 14px; }
.stake-hint:empty { display: none; }
.kv-rows { display: grid; gap: 6px; }
.kv-row {
  display: grid; grid-template-columns: 170px 1fr; gap: 10px;
  align-items: baseline; font-size: .88rem;
}
.kv-row .kv-k { color: var(--muted); font-size: .8rem; }
.kv-row .kv-v { color: var(--ink); }
@media (max-width: 560px) { .kv-row { grid-template-columns: 1fr; gap: 2px; } }

/* scelte a card (ricalibrazione) */
.choice-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 6px 0 4px; }
@media (max-width: 700px) { .choice-cards { grid-template-columns: 1fr; } }
.choice {
  text-align: left; cursor: pointer; font-family: var(--font-sans);
  background: var(--card-2); border: 1.5px solid var(--line); border-radius: var(--r-input);
  padding: 12px 14px; color: var(--ink);
  display: flex; flex-direction: column; gap: 4px;
  transition: border-color .18s, background .18s, transform .18s var(--ease);
}
.choice:hover { border-color: var(--accent); transform: translateY(-1px); }
.choice:active { transform: scale(.98); }
.choice.active { border-color: var(--accent); background: var(--accent-wash); box-shadow: 0 0 0 1px var(--accent) inset; }
.choice b { font-family: var(--font-display); font-size: .92rem; }
.choice span { font-size: .76rem; color: var(--muted); line-height: 1.45; }

.sub-details { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 4px; }
.sub-details > summary {
  cursor: pointer; list-style: none; user-select: none;
  padding: 10px 2px; color: var(--muted); font-size: .86rem; font-weight: 600;
}
.sub-details > summary::-webkit-details-marker { display: none; }
.sub-details > summary::after { content: " ▾"; font-size: .76rem; }
.sub-details[open] > summary::after { content: " ▴"; }
.sub-details[open] > summary { color: var(--ink); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--header); color: var(--header-ink);
  padding: 12px 22px; border-radius: var(--r-pill); font-size: .9rem;
  box-shadow: var(--shadow-2); z-index: 100;
  animation: toast-in .22s var(--ease);
}
.toast.bad { background: var(--warn); color: #fff; }
.toast.out { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 8px); } }

.prob-table .num, .metric .m-val, .bet-nums, .hc-meta, .hc-ft { font-variant-numeric: tabular-nums; }

/* ============================================================
   Watcher pill
   ============================================================ */
.watcher-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: var(--r-pill);
  font-size: .78rem; font-weight: 600; letter-spacing: .01em;
  border: 1px solid rgba(207, 219, 213, .3); color: var(--header-ink, var(--ink));
}
.watcher-pill .wp-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.watcher-pill.on .wp-dot { background: #4CAF50; box-shadow: 0 0 6px #4CAF5088; animation: wp-blink 2.4s ease-in-out infinite; }
.watcher-pill.off .wp-dot { background: var(--warn); }
.watcher-pill.off { opacity: .8; }
@keyframes wp-blink { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .watcher-pill.on .wp-dot { animation: none; } }

/* ============================================================
   Smartphone (< 720px): topbar compatta + tab bar in basso
   ============================================================ */
@media (max-width: 719.98px) {
  .brand-txt small { display: none; }
  .brand-mark { width: 34px; height: 30px; font-size: .85rem; }
  .brand { gap: 9px; }
  .topnav { gap: 8px; }
  .user { display: none; }
  .topbar .btn-ghost span { display: none; }
  .topbar .btn-ghost { padding: 10px; border-radius: var(--r-pill); }

  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px;
    margin: 0; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--glass); backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -2px 16px rgba(0, 0, 0, .08);
  }
  .tab {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; margin: 0; padding: 5px 2px; min-height: 52px;
    border: none; border-radius: var(--r-ghost);
    font-size: .64rem; font-weight: 600; letter-spacing: .02em;
  }
  .tab-ic { margin: 0; opacity: .8; }
  .tab-ic svg { width: 22px; height: 22px; }
  .tab.active { background: var(--accent-wash); color: var(--ink); }
  .tab.active .tab-ic { opacity: 1; }
  .nav-badge {
    position: absolute; top: 2px; right: calc(50% - 24px); margin: 0;
    min-width: 17px; height: 17px; font-size: .6rem;
    background: var(--accent); color: var(--on-accent);
  }
  body { padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }
  .toast {
    bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 24px); text-align: center;
  }
  .odds-drawer { max-height: calc(100vh - 120px); }
  @supports (max-height: 100dvh) { .odds-drawer { max-height: calc(100dvh - 120px); } }

  /* niente auto-zoom iOS sui campi (serve >= 16px) */
  input[type="text"], input[type="number"], input[type="password"], select { font-size: 16px; }

  .today-item, .draft-item { flex-wrap: wrap; }
  .today-side { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; }
  .hc-top { flex-wrap: wrap; }
  .actions { flex-wrap: wrap; }
  .actions .btn-primary { flex: 1 1 auto; }
  .res-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dash-hero { padding: 18px 16px; }
  .dh-value { font-size: 2.2rem; }
  .container { padding: 14px 12px; }
  .sec-head { padding: 13px 14px 10px; }
  .sec-body { padding: 2px 14px 14px; }
  .stat-grid { padding: 0 14px 14px; }
}

@media (max-width: 419.98px) {
  .watcher-pill { padding: 6px 8px; }
  .watcher-pill .wp-txt { display: none; }
}

/* ---------- Touch ---------- */
@media (pointer: coarse) {
  .btn-ghost { padding: 11px 15px; }
  .icon-btn { width: 42px; height: 42px; }
  .star { padding: 8px; font-size: 1.35rem; }
  .hc-top { padding: 15px 16px 10px; }
  select, input[type="text"], input[type="number"], input[type="password"] { min-height: 44px; }
  .seg-btn { padding: 9px 15px; }
  /* niente effetti hover "appiccicosi" sui touch screen */
  .today-item:hover { transform: none; box-shadow: var(--shadow-1); }
  .choice:hover { transform: none; }
  .icon-btn:hover { transform: none; }
  .star:hover { transform: none; }
}

/* ---------- Analisi completa della partita (modal) ---------- */
body.no-scroll { overflow: hidden; }
.md-overlay { z-index: 70; }
.match-detail {
  position: fixed; z-index: 71; display: flex; flex-direction: column;
  background: var(--bg); box-shadow: var(--shadow-2);
  /* mobile: foglio a tutto schermo dal basso */
  inset: 0; top: max(12px, env(safe-area-inset-top, 0px));
  border-radius: 22px 22px 0 0; border: 1px solid var(--line); border-bottom: none;
  transform: translateY(103%); transition: transform .46s cubic-bezier(.32, .72, 0, 1);
  will-change: transform;
}
.match-detail[hidden] { display: none; }
.match-detail.open { transform: translateY(0); }
.match-detail .drawer-grip { margin: 10px auto 0; }
.md-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  background: var(--card); border: 1px solid var(--line);
}
.md-body {
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding: 10px 16px calc(28px + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 720px) {
  /* desktop/tablet: dialog centrato */
  .match-detail {
    inset: auto; top: 50%; left: 50%; width: min(820px, calc(100vw - 48px));
    max-height: min(88vh, 980px); border-radius: 22px; border-bottom: 1px solid var(--line);
    transform: translate(-50%, 46%) scale(.96); opacity: 0;
    transition: transform .42s cubic-bezier(.32, .72, 0, 1), opacity .3s var(--ease);
  }
  @supports (max-height: 88dvh) { .match-detail { max-height: min(88dvh, 980px); } }
  .match-detail.open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .match-detail .drawer-grip { display: none; }
  .md-body { padding: 22px 28px 30px; }
}

/* hero */
.md-hero { text-align: center; padding: 18px 8px 6px; }
.md-comp { font-size: .72rem; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); font-weight: 600; }
.md-score {
  display: flex; align-items: center; justify-content: center; gap: 16px; margin: 12px 0 4px;
}
.md-team {
  font-family: var(--font-display); font-weight: 700; font-size: 1.25rem;
  letter-spacing: -.3px; flex: 1; min-width: 0;
}
.md-team:first-child { text-align: right; }
.md-team:last-child { text-align: left; }
.md-ft {
  font-family: var(--font-mono); font-weight: 700; font-size: 1.9rem; letter-spacing: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 6px 14px; flex-shrink: 0;
}
.md-sub { font-size: .8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.md-badges { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }

/* sezioni: entrano a cascata */
.md-sec {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 16px 18px; margin-top: 14px;
}
.match-detail.open .md-hero,
.match-detail.open .md-sec { animation: card-in .4s var(--ease) backwards; }
.match-detail.open .md-sec:nth-of-type(2) { animation-delay: .05s; }
.match-detail.open .md-sec:nth-of-type(3) { animation-delay: .1s; }
.match-detail.open .md-sec:nth-of-type(4) { animation-delay: .15s; }
.match-detail.open .md-sec:nth-of-type(n+5) { animation-delay: .2s; }
.md-sec-title {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); font-weight: 600; margin-bottom: 12px;
}
.md-note { font-size: .8rem; color: var(--muted); line-height: 1.5; margin-top: 10px; }
.md-note b { color: var(--ink); }
.md-foot-note { text-align: center; padding-bottom: 4px; }

/* grafico 1X2: barre modello vs mercato */
.mx-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; align-items: center; padding: 7px 0; }
.mx-row + .mx-row { border-top: 1px dashed var(--line); }
.mx-lab { font-size: .84rem; font-weight: 600; letter-spacing: -.1px; }
.mx-check { color: var(--good); font-weight: 700; }
.mx-row.hit .mx-lab { color: var(--good); }
.mxb { display: flex; align-items: center; gap: 8px; }
.mxb + .mxb { margin-top: 4px; }
.mxb i {
  display: block; height: 12px; border-radius: 6px; width: 0;
  transition: width .9s cubic-bezier(.25, .8, .25, 1);
}
.mxb.model i { background: var(--accent); }
.mxb.market i { background: var(--line); }
.mxb span { font-family: var(--font-mono); font-size: .74rem; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.match-detail.open .mxb i { width: var(--w); }
.md-legend { display: flex; gap: 16px; margin-top: 12px; }
.md-legend .lg { display: flex; align-items: center; gap: 6px; font-size: .74rem; color: var(--muted); }
.md-legend .sw { width: 14px; height: 8px; border-radius: 4px; display: inline-block; }
.md-legend .sw.model { background: var(--accent); }
.md-legend .sw.market { background: var(--line); }

/* distribuzione gol totali */
.md-dist { display: flex; gap: 8px; align-items: flex-end; height: 130px; padding-top: 14px; }
.dist-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; min-width: 0; height: 100%; }
.dist-col b { font-family: var(--font-mono); font-size: .62rem; color: var(--muted); font-weight: 500; white-space: nowrap; }
.dist-col i {
  display: block; width: 100%; max-width: 46px; border-radius: 7px 7px 3px 3px;
  background: var(--accent-wash); border: 1px solid var(--line); border-bottom: none;
  height: 0; transition: height .8s cubic-bezier(.25, .8, .25, 1);
}
.match-detail.open .dist-col i { height: var(--h); }
.dist-col span { font-family: var(--font-mono); font-size: .72rem; color: var(--muted); }
.dist-col.actual i { background: var(--accent); border-color: var(--accent); }
.dist-col.actual span { color: var(--ink); font-weight: 700; }

/* spiegazione del modello */
.why-row { display: flex; gap: 12px; padding: 9px 0; }
.why-row + .why-row { border-top: 1px dashed var(--line); }
.why-row i {
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  flex-shrink: 0; margin-top: 7px;
}
.why-row p { margin: 0; font-size: .86rem; line-height: 1.55; color: var(--ink-2, var(--ink)); }
.why-row b { color: var(--ink); }

/* valore quota per quota */
.ev-rows { margin-top: 12px; }
.ev-row { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-input); margin-bottom: 8px; background: var(--card-2); }
.ev-row.gioca { border-color: rgba(76, 122, 70, .45); background: rgba(76, 122, 70, .06); }
.ev-head { display: flex; align-items: center; gap: 10px; }
.ev-dot {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: .68rem; font-weight: 700;
  background: var(--sunken); color: var(--muted);
}
.ev-row.gioca .ev-dot { background: rgba(76, 122, 70, .15); color: var(--good); }
.ev-out { flex: 1; min-width: 0; font-weight: 600; font-size: .88rem; letter-spacing: -.1px; }
.ev-out small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.ev-q { font-family: var(--font-mono); font-size: .84rem; font-variant-numeric: tabular-nums; }
.ev-q em { font-style: normal; color: var(--warn); cursor: help; margin-left: 2px; }
.ev-v { font-family: var(--font-mono); font-size: .84rem; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 56px; text-align: right; }
.ev-why { font-size: .76rem; color: var(--muted); margin-top: 6px; padding-left: 30px; line-height: 1.5; }
.ev-why b { color: var(--ink); }

/* statistiche 1T a barre contrapposte */
.sd-head { display: flex; justify-content: space-between; font-size: .78rem; font-weight: 700; margin-bottom: 8px; }
.sd-row { display: grid; grid-template-columns: 44px 1fr 44px; gap: 10px; align-items: center; padding: 6px 0; }
.sd-row + .sd-row { border-top: 1px dashed var(--line); }
.sd-v { font-family: var(--font-mono); font-size: .84rem; font-weight: 500; color: var(--muted); text-align: center; font-variant-numeric: tabular-nums; }
.sd-v.lead { color: var(--ink); font-weight: 700; }
.sd-mid span { display: block; text-align: center; font-size: .74rem; color: var(--muted); margin-bottom: 4px; }
.sd-track { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; height: 8px; }
.sd-track i { display: block; border-radius: 4px; width: 0; height: 100%; transition: width .8s cubic-bezier(.25, .8, .25, 1); }
.sd-track .h { background: var(--accent); justify-self: end; }
.sd-track .a { background: var(--line); }
.match-detail.open .sd-track i { width: var(--w); }

/* bottone "Analisi completa" nelle card dello storico */
.hc-open {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: calc(100% - 32px); margin: 4px 16px 12px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: var(--r-ghost);
  background: var(--sunken); color: var(--ink); font-weight: 600; font-size: .8rem;
  cursor: pointer; transition: background .15s, border-color .15s, transform .15s var(--ease);
}
.hc-open svg { width: 15px; height: 15px; color: var(--accent-press, var(--accent)); }
.hc-open:hover { background: var(--accent-wash); border-color: var(--accent); }
.hc-open:active { transform: scale(.97); }

@media (max-width: 719.98px) {
  .mx-row { grid-template-columns: 96px 1fr; }
  .md-team { font-size: 1.02rem; }
  .md-ft { font-size: 1.5rem; padding: 5px 10px; }
  .md-dist { gap: 5px; height: 110px; }
  .dist-col b { font-size: .56rem; }
  .md-sec { padding: 14px 14px; }
  .ev-why { padding-left: 0; }
}

/* ---------- Accessibilità: meno animazioni se richiesto dal sistema ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  html { scroll-behavior: auto; }
}
