/* ============================================================================
   NOVA — Demo CRM · Design System
   Brand: dark fintech/premium (docs/NOVA_BRAND.md). Night-blue base + lime
   signal + cyan secondary. Font Onest. Zero dipendenze, vanilla.
   ========================================================================== */

:root {
  /* Brand tokens (NOVA :root ufficiali) */
  --bg:        #000229;  /* night-blue */
  --bg-2:      #050833;  /* sezioni leggermente sollevate */
  --card:      #0C1131;  /* card/popover */
  --muted:     #1C2040;
  --border:    #1F2347;
  --border-2:  #2A2F5C;
  --text:      #F2F2F2;
  --text-2:    #8A94A8;  /* muted-foreground */
  --text-3:    #5A6480;
  --lime:      #C4F415;  /* CTA / segnale d'azione */
  --lime-dim:  #9BC10F;
  --blue:      #091CAE;  /* nova-blue */
  --cyan:      #00CCFF;  /* accent secondario */
  --danger:    #EF4444;
  --ok:        #34D399;

  --grad-hero: linear-gradient(135deg, #000229 0%, #091CAE 100%);
  --grad-cta:  linear-gradient(135deg, #091CAE 0%, #00CCFF 100%);
  --lime-glow: 0 0 28px rgba(196,244,21,.35);

  --radius:    14px;
  --radius-sm: 9px;
  --sidebar-w: 256px;
  --topbar-h:  62px;

  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: Onest, ui-sans-serif, system-ui, -apple-system, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  /* sottile blueprint fintech */
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(9,28,174,.30), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(0,204,255,.10), transparent 55%);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--lime); color: var(--bg); }

/* ----- App shell ---------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  background: linear-gradient(180deg, #06082E, #000229);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 8px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand svg, .brand img { height: 26px; width: auto; }
.brand .tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em;
  color: var(--text-3); text-transform: uppercase; margin-left: auto;
}

.nav-group { margin-top: 12px; }
.nav-group > .label {
  font-family: var(--mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--text-3); padding: 6px 10px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
  border: 1px solid transparent; transition: .12s;
}
.nav-item:hover { background: var(--muted); color: var(--text); }
.nav-item.active {
  background: rgba(196,244,21,.08); color: var(--text);
  border-color: rgba(196,244,21,.28);
}
.nav-item.active .ico { color: var(--lime); }
.nav-item .ico { width: 17px; height: 17px; color: var(--text-3); flex: none; }
.nav-item .count {
  margin-left: auto; font-family: var(--mono); font-size: 11px;
  color: var(--text-3); background: var(--muted); padding: 1px 7px; border-radius: 20px;
}

.sidebar .foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid var(--border); }
.sidebar .foot .who { font-size: 12px; color: var(--text-2); }
.sidebar .foot .who b { color: var(--text); font-weight: 600; }

/* ----- Topbar ------------------------------------------------------------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 26px;
  background: rgba(0,2,41,.72); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.topbar .crumb { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.topbar h1 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.topbar .spacer { flex: 1; }

.view { padding: 26px; max-width: 1280px; width: 100%; }
.view-head { margin-bottom: 20px; }
.view-head h2 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.view-head p { color: var(--text-2); margin-top: 5px; max-width: 70ch; }

/* ----- Badges: REALE vs SCENARIO (onestà visiva) -------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em;
  text-transform: uppercase; padding: 3px 9px; border-radius: 20px;
  border: 1px solid; font-weight: 600; white-space: nowrap;
}
.badge.real     { color: var(--cyan); border-color: rgba(0,204,255,.4);  background: rgba(0,204,255,.07); }
.badge.scenario { color: #F5B546;    border-color: rgba(245,181,70,.4); background: rgba(245,181,70,.07); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ----- Panels & cards ----------------------------------------------------- */
.panel {
  background: linear-gradient(180deg, var(--card), #0A0E2A);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.panel > .head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel > .head h3 { font-size: 13.5px; font-weight: 700; }
.panel > .head .sub { font-size: 12px; color: var(--text-3); margin-left: auto; font-family: var(--mono); }
.panel > .body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2,1fr); } .grid.cols-3 { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 720px)  { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

/* Stat card */
.stat {
  background: linear-gradient(180deg, var(--card), #0A0E2A);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.stat .eyebrow {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-3);
}
.stat .num { font-size: 30px; font-weight: 800; letter-spacing: -.03em; margin-top: 6px; }
.stat .num.lime { color: var(--lime); }
.stat .num.cyan { color: var(--cyan); }
.stat .delta { font-size: 12px; margin-top: 4px; color: var(--text-2); }
.stat .delta b.up { color: var(--ok); } .stat .delta b.down { color: var(--danger); }
.stat .spark { position: absolute; right: 0; bottom: 0; opacity: .5; }

/* ----- Chips -------------------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 3px 10px; border-radius: 20px;
  border: 1px solid var(--border-2); color: var(--text-2); background: var(--muted);
}
.chip.lime { color: var(--lime); border-color: rgba(196,244,21,.35); background: rgba(196,244,21,.06); }
.chip.cyan { color: var(--cyan); border-color: rgba(0,204,255,.35); background: rgba(0,204,255,.06); }
.chip.b    { color: var(--cyan); border-color: rgba(0,204,255,.30); }
.chip.a    { color: #F5B546; border-color: rgba(245,181,70,.30); }

/* ----- Buttons ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 15px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px;
  border: 1px solid var(--border-2); background: var(--muted); color: var(--text);
  transition: .14s;
}
.btn:hover { border-color: var(--text-3); }
.btn.lime { background: var(--lime); color: var(--bg); border-color: var(--lime); box-shadow: var(--lime-glow); }
.btn.lime:hover { background: #d2ff2e; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 11px; font-size: 12px; }

/* ----- Tabs / role-switch ------------------------------------------------- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--muted); border-radius: 11px; border: 1px solid var(--border); }
.tabs button {
  padding: 7px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 600;
  background: transparent; color: var(--text-2); border: none;
}
.tabs button.active { background: var(--card); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.04); }
.tabs button.active.lime { color: var(--lime); }

/* ----- Tables ------------------------------------------------------------- */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--text-3); font-weight: 600;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); color: var(--text); }
.table tr:hover td { background: rgba(255,255,255,.02); }
.table .muted { color: var(--text-3); }
.table .right { text-align: right; font-family: var(--mono); }

/* ----- Bars (distribuzioni) ----------------------------------------------- */
.bar-row { display: grid; grid-template-columns: 130px 1fr 56px; align-items: center; gap: 12px; padding: 5px 0; }
.bar-row .lab { font-size: 12.5px; color: var(--text-2); }
.bar-track { height: 8px; background: var(--muted); border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--grad-cta); }
.bar-fill.lime { background: linear-gradient(90deg, var(--lime-dim), var(--lime)); }
.bar-row .val { font-family: var(--mono); font-size: 12px; color: var(--text); text-align: right; }

/* ----- Sliders (calcolatore) ---------------------------------------------- */
.slider-row { margin-bottom: 16px; }
.slider-row .top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.slider-row .top .lab { font-size: 13px; color: var(--text-2); }
.slider-row .top .v { font-family: var(--mono); font-weight: 700; color: var(--lime); font-size: 14px; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px;
  background: var(--muted); border-radius: 6px; outline: none;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 17px; height: 17px; border-radius: 50%;
  background: var(--lime); border: 3px solid var(--bg); box-shadow: var(--lime-glow); cursor: pointer;
}
input[type=range]::-moz-range-thumb {
  width: 17px; height: 17px; border-radius: 50%; background: var(--lime);
  border: 3px solid var(--bg); cursor: pointer;
}

select.input, input.input {
  background: var(--muted); border: 1px solid var(--border-2); color: var(--text);
  padding: 8px 11px; border-radius: var(--radius-sm); font-size: 13px; font-family: inherit; width: 100%;
}
select.input:focus, input.input:focus { outline: none; border-color: var(--lime); }

/* ----- Funnel ------------------------------------------------------------- */
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel .step { position: relative; }
.funnel .bar {
  background: var(--grad-cta); border-radius: 9px; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; color: #fff;
}
.funnel .bar.s1 { background: linear-gradient(90deg,#091CAE,#1430D6); }
.funnel .bar.s2 { background: linear-gradient(90deg,#1430D6,#0070C9); }
.funnel .bar.s3 { background: linear-gradient(90deg,#0070C9,#00A3DD); }
.funnel .bar.s4 { background: linear-gradient(90deg,#00A3DD,#00CCFF); color:#00121b; }
.funnel .bar.s5 { background: linear-gradient(90deg,#9BC10F,#C4F415); color:#0a0f01; }
.funnel .bar .k { font-weight: 600; font-size: 13px; }
.funnel .bar .n { font-family: var(--mono); font-weight: 700; }
.funnel .conv { font-family: var(--mono); font-size: 11px; color: var(--text-3); padding: 2px 0 2px 16px; }

/* ----- Kanban / pipeline cards -------------------------------------------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kcol { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.kcol .h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kcol .h .t { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); }
.kcol .h .c { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.kcard { background: var(--card); border: 1px solid var(--border-2); border-radius: var(--radius-sm); padding: 11px; margin-bottom: 9px; }
.kcard .co { font-weight: 600; font-size: 13px; }
.kcard .meta { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.kcard .val { font-family: var(--mono); font-size: 12px; color: var(--lime); margin-top: 8px; }

/* ----- Email mockup ------------------------------------------------------- */
.mailframe { background: #fff; color: #1a1a2e; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.mailframe .mhead { background: var(--bg); color: #fff; padding: 12px 16px; display: flex; align-items: center; gap: 10px; }
.mailframe .mhead .subj { font-size: 13px; color: var(--text-2); }
.mailframe .mbody { padding: 20px 22px; font-size: 13.5px; line-height: 1.6; }
.mailframe .mbody p { margin-bottom: 12px; }
.mailframe .mcta { display: inline-block; background: var(--lime); color: #0a0f01; font-weight: 700; padding: 10px 18px; border-radius: 8px; margin-top: 6px; }
.mailframe .mfoot { background: #f3f4f7; color: #5a6480; font-size: 11px; padding: 12px 16px; border-top: 1px solid #e3e6ee; }

/* ----- Flow diagram (sequenze) -------------------------------------------- */
.flow { display: flex; flex-direction: column; gap: 0; }
.fnode {
  background: var(--card); border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  padding: 12px 15px; display: flex; align-items: center; gap: 12px; position: relative; z-index: 2;
}
.fnode .badge-day { font-family: var(--mono); font-size: 11px; color: var(--bg); background: var(--lime); padding: 2px 8px; border-radius: 6px; font-weight: 700; flex: none; }
.fnode .ftitle { font-weight: 600; font-size: 13px; }
.fnode .fsub { font-size: 12px; color: var(--text-3); }
.fnode.trigger { border-color: rgba(0,204,255,.4); background: rgba(0,204,255,.05); }
.fnode.terminal { border-color: rgba(196,244,21,.4); background: rgba(196,244,21,.05); }
.fconn { width: 2px; height: 22px; background: var(--border-2); margin-left: 26px; z-index: 1; }
.fbranch { display: flex; gap: 10px; margin: 6px 0 6px 26px; }
.fbranch .pill { font-size: 11px; font-family: var(--mono); color: var(--text-2); border: 1px dashed var(--border-2); border-radius: 20px; padding: 3px 10px; }
.fbranch .pill.open { color: var(--cyan); border-color: rgba(0,204,255,.35); }
.fbranch .pill.reply { color: var(--lime); border-color: rgba(196,244,21,.35); }

/* ----- Misc --------------------------------------------------------------- */
.note { font-size: 12px; color: var(--text-3); font-style: italic; }
.hr { height: 1px; background: var(--border); margin: 18px 0; border: none; }
.kbd { font-family: var(--mono); font-size: 11px; background: var(--muted); border: 1px solid var(--border-2); border-radius: 5px; padding: 1px 6px; color: var(--text-2); }
.scenario-banner {
  display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: #F5B546;
  background: rgba(245,181,70,.07); border: 1px solid rgba(245,181,70,.25);
  border-radius: var(--radius-sm); padding: 9px 14px; margin-bottom: 16px;
}
.real-banner {
  display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--cyan);
  background: rgba(0,204,255,.06); border: 1px solid rgba(0,204,255,.22);
  border-radius: var(--radius-sm); padding: 9px 14px; margin-bottom: 16px;
}
