/* Marketing Professionals Online — foglio di stile unico dell'app.
   Sistema: blu del marchio (#023F82, come nel logo) + verde acqua per le azioni positive, Inter, card con angoli morbidi. */

:root {
  --primary: #023F82;
  --primary-dark: #012C5C;
  --primary-tint: #EAF2FC;
  --accent: #0D9488;
  --accent-tint: #E6F6F4;
  --ink: #141833;
  --text: #3F4463;
  --muted: #6B7090;
  --line: #E4E6F0;
  --bg: #F6F7FB;
  --white: #FFFFFF;
  --green: #127049;
  --green-bg: #E6F5EE;
  --red: #B42318;
  --red-bg: #FDECEA;
  --amber: #A15C07;
  --amber-bg: #FEF3E2;
  --blue: #1F5FBF;
  --blue-bg: #EAF2FC;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 24, 51, .05), 0 8px 24px -12px rgba(20, 24, 51, .18);
  --sidebar: 248px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 1em; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Caricamento */
.loading { display: grid; place-items: center; min-height: 40vh; }
.loading span { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Struttura: barra laterale + contenuto */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--white); border-right: 1px solid var(--line); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 4px 8px 14px; color: var(--ink); line-height: 1.15; }
.brand-logo { display: block; height: 36px; width: auto; max-width: 100%; }
.auth-side .brand-logo { height: 42px; }
.brand:hover { text-decoration: none; }
.brand small { display: block; padding-left: 2px; font-weight: 600; color: var(--muted); font-size: 11px; letter-spacing: .02em; text-transform: uppercase; }
.nav-group { margin-top: 10px; }
.nav-group-title { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 0 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); font-weight: 550; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--primary-tint); color: var(--primary); }
.nav .count { margin-left: auto; background: var(--primary); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.plan-pill { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px; border-radius: var(--radius-sm); background: var(--bg); font-size: 13px; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.content { padding: 28px; max-width: 1180px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.eyebrow { font-size: 12px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 6px; }

/* Pulsanti */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: var(--radius-sm); border: 1.5px solid var(--primary); background: var(--primary); color: #fff; font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; line-height: 1.2; white-space: nowrap; }
.btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-outline { background: var(--white); color: var(--primary); }
.btn-outline:hover { background: var(--primary-tint); color: var(--primary); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); border-color: transparent; }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #8f1b12; border-color: #8f1b12; }
.btn-accent { background: var(--accent); border-color: var(--accent); }
.btn-accent:hover { background: #0b7a70; border-color: #0b7a70; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--bg); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }

/* Card e griglie */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card h2 { font-size: 17px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid .card + .card { margin-top: 0; }
.stack > * + * { margin-top: 16px; }
.stat { padding: 16px 18px; }
.stat .value { font-size: 26px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.stat .label { font-size: 13px; color: var(--muted); }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }

/* Elenchi */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--ink); }
.list a.title:hover { color: var(--primary); }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }

/* Badge e chip */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--bg); color: var(--text); white-space: nowrap; }
.badge-brand { background: var(--primary-tint); color: var(--primary); }
.badge-success { background: var(--green-bg); color: var(--green); }
.badge-warn { background: var(--amber-bg); color: var(--amber); }
.badge-danger { background: var(--red-bg); color: var(--red); }
.badge-info { background: var(--blue-bg); color: var(--blue); }
.badge-accent { background: var(--accent-tint); color: var(--accent); }
.verified { display: inline-flex; align-items: center; gap: 4px; color: var(--accent); font-weight: 700; font-size: 13px; }
.verified .icon { width: 16px; height: 16px; stroke-width: 2.2; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { padding: 3px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 12.5px; color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--white); font-size: 13px; font-weight: 550; cursor: pointer; user-select: none; }
.chip input:checked + span { background: var(--primary-tint); border-color: var(--primary); color: var(--primary); }
.chip input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Moduli */
.form { display: grid; gap: 16px; }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field label, .field .label { display: block; font-weight: 600; color: var(--ink); font-size: 14px; margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="url"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); font: inherit; color: var(--ink); background: var(--white);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.check input { margin-top: 3px; }
.form-error { color: var(--red); background: var(--red-bg); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar input[type="search"], .toolbar select { width: auto; min-width: 180px; }

/* Schede (tab) */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs a:hover, .tabs button:hover { color: var(--ink); text-decoration: none; }
.tabs [aria-current="page"], .tabs [aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

/* Barra di avanzamento e punteggio */
.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; }
.score { display: inline-grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; font-weight: 800; color: var(--ink); font-size: 15px; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0); position: relative; }
.score::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: var(--white); }
.score b { position: relative; }
.reasons { margin: 6px 0 0; padding: 0; list-style: none; font-size: 13px; }
.reasons li { padding: 1px 0; }
.reasons .ok::before { content: "✓ "; color: var(--accent); font-weight: 700; }
.reasons .ko::before { content: "! "; color: var(--amber); font-weight: 700; }

/* Card di professionisti e opportunità */
.pro-card { display: flex; gap: 14px; align-items: flex-start; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-tint); color: var(--primary); display: grid; place-items: center; font-weight: 800; flex: none; }
.avatar.lg { width: 72px; height: 72px; font-size: 24px; }

/* Stati vuoti, avvisi, limiti */
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-title { font-weight: 700; color: var(--ink); font-size: 16px; margin-bottom: 6px; }
.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--blue-bg); color: var(--blue); font-size: 14px; display: flex; gap: 10px; align-items: flex-start; }
.notice.warn { background: var(--amber-bg); color: var(--amber); }
.notice.success { background: var(--green-bg); color: var(--green); }
.notice.danger { background: var(--red-bg); color: var(--red); }
.notice .btn { margin-left: auto; }
.upsell { border: 1.5px dashed var(--primary); background: var(--primary-tint); }
.lock { color: var(--muted); }

/* Testi formattati (markdown essenziale) */
.prose { color: var(--text); }
.prose h4, .prose .md-h { font-size: 16px; margin: 1.2em 0 .4em; color: var(--ink); }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin: .2em 0; }

/* Editor di documenti */
.doc-section { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: var(--white); }
.doc-section + .doc-section { margin-top: 12px; }
.doc-section-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.doc-section-head input { font-weight: 700; }
.calendar-table input, .calendar-table select { padding: 6px 8px; font-size: 13px; }
.calendar-table td { padding: 6px; }

/* Piani */
.plans { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.plan { display: flex; flex-direction: column; gap: 10px; }
.plan.current { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-tint), var(--shadow); }
.plan .price { font-size: 30px; font-weight: 800; color: var(--ink); }
.plan .price small { font-size: 14px; color: var(--muted); font-weight: 500; }
.plan ul { padding-left: 1.1em; margin: 0; flex: 1; }
.usage-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; font-size: 14px; }
.usage-row .progress { grid-column: 1 / -1; }

/* Pagine condivise (white label) e pagine pubbliche (accesso) */
.public-page { min-height: 100vh; background: var(--bg); }
.share-head { background: var(--brand, var(--primary)); color: #fff; padding: 22px 0; }
.share-head .wrap { display: flex; align-items: center; gap: 14px; }
.share-head img { max-height: 44px; max-width: 180px; background: #fff; border-radius: 8px; padding: 4px 8px; }
.share-head h1 { color: #fff; margin: 0; font-size: 20px; }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 20px; }
.share-body { padding: 28px 0 60px; }
.share-foot { text-align: center; color: var(--muted); font-size: 13px; padding: 20px; }
.share-section h2 { font-size: 18px; border-left: 4px solid var(--brand, var(--primary)); padding-left: 10px; }
.totals { margin-left: auto; max-width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-weight: 800; color: var(--ink); font-size: 18px; border-top: 1px solid var(--line); padding-top: 8px; }
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: linear-gradient(150deg, var(--primary-dark), var(--primary) 55%, var(--accent)); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { color: #fff; font-size: 30px; max-width: 460px; }
.auth-side ul { padding-left: 1.1em; opacity: .92; }
.auth-side .brand { color: #fff; }
.auth-side .brand small { color: rgba(255, 255, 255, .75); }
.auth-main { display: grid; place-items: center; padding: 32px 20px; background: var(--white); }
.auth-box { width: 100%; max-width: 420px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.segmented label { border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 12px; cursor: pointer; }
.segmented label:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); }
.segmented input { margin-right: 6px; }

/* Finestre (sheet) */
.sheet-open { overflow: hidden; }
.sheet-backdrop { position: fixed; inset: 0; background: rgba(20, 24, 51, .45); z-index: 100; display: grid; place-items: center; padding: 20px; animation: fade .15s ease; }
.sheet-backdrop.out { opacity: 0; transition: opacity .15s; }
.sheet { background: var(--white); border-radius: 14px; width: 100%; max-height: calc(100vh - 40px); overflow-y: auto; position: relative; box-shadow: 0 30px 60px -20px rgba(20, 24, 51, .45); }
.sheet-sm { max-width: 440px; }
.sheet-md { max-width: 620px; }
.sheet-lg { max-width: 860px; }
.sheet-body { padding: 24px; }
.sheet-close { position: absolute; top: 12px; right: 12px; }
@keyframes fade { from { opacity: 0; } }

/* Notifiche e toast */
.popover { position: absolute; right: 16px; top: 56px; width: 360px; max-width: calc(100vw - 32px); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); z-index: 50; max-height: 70vh; overflow-y: auto; }
.popover .list li { padding: 10px 14px; }
.popover .unread .title { color: var(--primary); }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 14px; animation: fade .2s ease; }
.toast.danger { background: var(--red); }
.toast.success { background: var(--green); }

/* Telefono e tablet */
@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .split { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-grid; }
  .content { padding: 18px 16px; }
  .topbar { padding: 10px 16px; }
  .grid-2, .form-row, .form-row.three { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .shell { display: block; }
  .card { box-shadow: none; }
}

/* Calendario del piano editoriale: colonne leggibili, scorrimento orizzontale su schermi stretti */
.calendar-table { min-width: 900px; }
.calendar-table td:nth-child(1) { width: 150px; }
.calendar-table td:nth-child(2) { width: 130px; }
.calendar-table td:nth-child(4) { min-width: 220px; }
.calendar-table td:nth-child(6) { width: 150px; }

/* Selettore dell'organizzazione nella barra laterale */
.org-switch { padding: 0 8px 10px; }
.org-switch select { width: 100%; font-weight: 600; }
.org-switch small { color: var(--muted); }

/* Percorso del progetto: questionario → audit → piano e KPI → incarichi → report */
.path { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 18px; flex-wrap: wrap; counter-reset: none; }
.path li { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: var(--white); border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: 14px; }
.path li span { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--bg); font-size: 12px; }
.path li span .icon { width: 14px; height: 14px; }
.path li.done { color: var(--green); border-color: var(--green-bg); background: var(--green-bg); }
.path li.done span { background: var(--white); }
.path li.current { color: var(--white); background: var(--primary); border-color: var(--primary); }
.path li.current span { background: rgba(255, 255, 255, .2); }

/* Risposte del questionario */
.answers { margin: 0 0 16px; }
.answers dt { font-weight: 600; color: var(--ink); margin-top: 10px; }
.answers dd { margin: 2px 0 0; white-space: pre-line; }
fieldset.field { border: 0; padding: 0; margin: 0; }
fieldset.field legend { font-weight: 600; color: var(--ink); margin-bottom: 6px; }

/* Storico delle approvazioni */
.history { list-style: none; margin: 8px 0 0; padding: 0 0 0 12px; border-left: 2px solid var(--line); font-size: 13px; color: var(--text); }
.history li { margin: 4px 0; }

/* Grafico previsto / reale dei KPI (SVG fatto a mano: un solo asse, tooltip e tabella alternativa) */
.kpi-chart { margin: 12px 0 0; }
.kpi-chart svg { width: 100%; max-width: 640px; height: auto; display: block; }
.kpi-chart .grid { stroke: var(--line); stroke-width: 1; }
.kpi-chart .axis { fill: var(--muted); font-size: 11px; }
.kpi-chart .expected { stroke: #9aa0b8; stroke-width: 2; stroke-dasharray: 6 5; }
.kpi-chart .real { fill: none; stroke: #2a78d6; stroke-width: 2.5; }
.kpi-chart .dot { fill: #2a78d6; stroke: #fff; stroke-width: 2; }
.legend { display: inline-block; width: 18px; height: 0; border-top: 2px dashed #9aa0b8; vertical-align: middle; margin: 0 4px 0 10px; }
.legend.real { border-top: 3px solid #2a78d6; }

/* Vista del cliente: il prossimo passo in evidenza e il marchio dell'organizzazione */
.next-step { border-left: 5px solid var(--primary); }
.next-step h2 { font-size: 24px; }
.next-step.next-attesa { border-left-color: var(--green); }
.client-brand { display: flex; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 16px; border-radius: var(--radius); background: var(--brand); color: #fff; }
.client-brand img { max-height: 40px; width: auto; }
