/* ==== Reset & base ==== */
*, *::before, *::after { box-sizing: border-box; }
/* I valori qui sono fallback; il tema reale viene iniettato via <style id="theme-vars"> */
:root {
    --bg: #ffffff;
    --bg-alt: #f5f6f8;
    --text: #15181c;
    --muted: #6b7280;
    --line: #e5e7eb;
    --primary: #3056d3;
    --primary-dark: #1f3a9a;
    --secondary: #1f9d55;
    --danger: #c0392b;
    --success: #1f9d55;
    --shadow: 0 4px 14px rgba(0,0,0,0.06);
    --radius: 10px;
    --font-heading: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
h1, h2, h3, h4, h5, h6 { font-family: var(--font-heading); }
img { max-width: 100%; display: block; }
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }
h1, h2, h3, h4 { line-height: 1.25; margin-top: 0; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.5rem; margin-top: 2rem; }
h3 { font-size: 1.15rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
.narrow { max-width: 720px; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.section { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.section-head { display:flex; justify-content:space-between; align-items:center; gap:1rem; margin-bottom:1.5rem; flex-wrap: wrap; }
.eyebrow { color: var(--secondary); font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; font-size: 0.85rem; margin: 0 0 0.5rem; }
.lead { font-size: 1.1rem; color: #2b2f36; }
.link { color: var(--primary); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ==== Header ==== */
.site-header { border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 30; }
.nav {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1.5rem;
    padding: 0.85rem 1.25rem;
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    justify-self: start;
}
.brand-mark { font-size: 1.3rem; color: var(--primary); }
.brand-logo { height: var(--logo-height, 48px); width: auto; max-width: 320px; object-fit: contain; }
.brand-name { font-size: 1.05rem; }

/* Desktop Navigation - centered */
.primary-nav {
    display: flex;
    gap: 0.25rem;
    align-items: center;
    justify-self: center;
}
.nav-item { position: relative; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--text);
    text-decoration: none;
    padding: 0.5rem 0.85rem;
    border-radius: calc(var(--radius) * 0.6);
    font-weight: 500;
    background: none;
    border: none;
    font: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.nav-link:hover { background: var(--bg-alt); }
.nav-link.active, .dropdown-item.active { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary-dark); }

/* Dropdown */
.dropdown-icon {
    transition: transform 0.2s;
    opacity: 0.7;
}
.dropdown-toggle[aria-expanded="true"] .dropdown-icon {
    transform: rotate(180deg);
}
.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.25rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-width: 180px;
    padding: 0.4rem 0;
    display: none;
    z-index: 100;
}
.has-dropdown.is-open .dropdown-menu {
    display: block;
}
.dropdown-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s;
}
.dropdown-item:hover {
    background: var(--bg-alt);
}

.user-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-self: end;
}
.user-greet { color: var(--muted); font-size: 0.9rem; }

/* ==== Buttons ==== */
.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 0.55rem 0.95rem;
    border-radius: var(--radius);
    text-decoration: none;
    border: 1px solid var(--primary);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #98271c; border-color: #98271c; }
.btn-small { padding: 0.35rem 0.65rem; font-size: 0.85rem; }

/* ==== Hero (home) ==== */
.hero { background: linear-gradient(180deg, #f4f7ff 0%, #ffffff 100%); padding: 3rem 0; }
.hero-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 2.5rem; align-items: center; }
.hero h1 { font-size: 2.5rem; margin: 0.25rem 0 0.75rem; }
.hero-cta { display: flex; gap: 0.6rem; margin-top: 1.5rem; flex-wrap: wrap; }
.hero-photo img,
.placeholder-photo {
    width: 100%; max-width: 320px; aspect-ratio: 1/1; border-radius: 50%;
    object-fit: cover; box-shadow: var(--shadow); margin-left: auto;
}
.placeholder-photo { background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 18%, var(--bg)), color-mix(in srgb, var(--primary) 35%, var(--bg))); }
@media (max-width: 800px) { .hero-grid { grid-template-columns: 1fr; } .hero-photo { order: -1; } .hero-photo img { margin: 0 auto; } }

/* ==== Cards ==== */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 1.2rem; }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; display: flex; flex-direction: column; }
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card-img { width: 100%; aspect-ratio: 16/9; background-size: cover; background-position: center; background-color: var(--bg-alt); }
.card-body { padding: 1rem 1.1rem 1.2rem; }
.card-body h3 { margin: 0 0 0.4rem; }

/* ==== Bio detail ==== */
.bio { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; }
.bio-head { display: flex; gap: 1.5rem; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; }
.bio-photo { width: 140px; height: 140px; border-radius: 50%; object-fit: cover; }
.meta-list { list-style: none; padding: 0; margin: 0.6rem 0 0; color: var(--muted); display: flex; gap: 1rem; flex-wrap: wrap; }
.prose img { border-radius: 8px; margin: 1rem 0; }
.prose p { margin: 0.6em 0 1em; }
.prose blockquote { border-left: 4px solid var(--line); padding: 0.25rem 1rem; color: var(--muted); margin: 1rem 0; }
.prose pre { background: #0f172a; color: #f1f5f9; padding: 1rem; border-radius: 8px; overflow: auto; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word; }

/* ==== Timeline ==== */
.timeline { list-style: none; padding: 0; margin: 1.5rem 0 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 14px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.timeline-item { position: relative; padding-left: 50px; margin-bottom: 1.5rem; }
.timeline-dot { position: absolute; left: 6px; top: 14px; width: 18px; height: 18px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, var(--bg)); }
.timeline-card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; }
.timeline-card h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }

/* ==== Card list ==== */
.card-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.entry { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; }
.entry h3 { margin: 0 0 0.25rem; font-size: 1.05rem; }

/* ==== Events list ==== */
.event-list { list-style: none; padding: 0; margin: 1rem 0; }
.event-list li { padding: 0.6rem 0; border-bottom: 1px solid var(--line); display: flex; gap: 1rem; flex-wrap: wrap; align-items: baseline; }
.event-list time { color: var(--primary); font-weight: 600; min-width: 200px; }

/* ==== Article cover ==== */
.article-cover { width: 100%; max-height: 380px; object-fit: cover; border-radius: var(--radius); margin-bottom: 1.5rem; }

/* ==== Episodes ==== */
.episodes-section { }
.episodes-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem; }
.episode-card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem; display: flex; gap: 1rem; transition: box-shadow 0.2s, border-color 0.2s; }
.episode-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.episode-number { flex-shrink: 0; }
.badge { display: inline-block; background: var(--primary); color: white; padding: 0.35rem 0.6rem; border-radius: 0.25rem; font-size: 0.85rem; font-weight: 600; }
.episode-content { flex: 1; }
.episode-content h3 { font-size: 1.05rem; color: var(--text); }
.episode-content p { margin: 0.5rem 0; font-size: 0.95rem; line-height: 1.5; }

/* ==== Forum ==== */
.thread-list { list-style: none; padding: 0; margin: 1rem 0; }
.thread { padding: 1rem 1.2rem; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 0.6rem; background: var(--bg); }
.thread-title { font-weight: 600; text-decoration: none; color: var(--text); display: block; margin-bottom: 0.25rem; }
.thread-title:hover { color: var(--primary); }
.thread-detail { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem; }
.post-list { list-style: none; padding: 0; margin: 0; }
.post { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 0.7rem; }
.post-head { margin-bottom: 0.4rem; }
.post-body { white-space: pre-wrap; }

/* ==== Forms ==== */
.form { display: flex; flex-direction: column; gap: 1rem; max-width: 720px; }
.form label { display: flex; flex-direction: column; gap: 0.35rem; }
.form label > span,
.form-label { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.form input[type=text], .form input[type=email], .form input[type=password], .form input[type=date], .form input[type=datetime-local], .form input[type=url], .form input[type=number], .form select, .form textarea {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.55rem 0.7rem;
    font: inherit;
    background: var(--bg);
    color: var(--text);
    width: 100%;
}
.form textarea { resize: vertical; }
.form .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.form-actions { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 0.5rem; }
.checkbox { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 500; }
.logo-block { border: 1px dashed var(--line); border-radius: var(--radius); padding: 1rem; background: var(--bg-alt); }
.current-image { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.current-image img { max-height: 80px; max-width: 200px; border-radius: 8px; background: var(--bg); padding: 6px; }
.current-image img.round { border-radius: 50%; padding: 0; height: 80px; width: 80px; object-fit: cover; }

/* ==== Alerts ==== */
.alert { padding: 0.85rem 1.1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert.error { background: #fde7e4; color: #98271c; border: 1px solid #f5c1bb; }
.alert.success { background: #e0f5ea; color: #136a39; border: 1px solid #b7e2c7; }

/* ==== Tables ==== */
.table { width: 100%; border-collapse: collapse; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { background: var(--bg-alt); font-size: 0.9rem; }
.table tr:last-child td { border-bottom: none; }
.actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.actions form { margin: 0; }

/* ==== Tags ==== */
.tag { display: inline-block; background: var(--bg-alt); color: var(--muted); padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600; }
.tag.cert { background: #e0f5ea; color: #136a39; }
.tag.certification { background: #e0f5ea; color: #136a39; }
.tag.education { background: #e8edff; color: var(--primary-dark); }

/* ==== Admin nav ==== */
.admin-nav { display: flex; flex-wrap: wrap; gap: 0.3rem; padding: 0.6rem; background: var(--bg-alt); border-radius: var(--radius); margin-bottom: 1.5rem; }
.admin-nav a { padding: 0.45rem 0.8rem; border-radius: calc(var(--radius) * 0.6); text-decoration: none; color: var(--text); font-weight: 500; font-size: 0.92rem; }
.admin-nav a:hover { background: var(--bg); }
.admin-nav a.active { background: var(--primary); color: #fff; }

/* ==== Stats ==== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); gap: 1rem; margin: 1.5rem 0; }
.stat { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; }
.stat-num { display: block; font-size: 2rem; font-weight: 700; color: var(--primary-dark); }
.stat-label { color: var(--muted); font-size: 0.9rem; }
.stat.highlight { background: #fff7e0; border-color: #f0d18a; }

/* ==== Messages ==== */
.msg-list { list-style: none; padding: 0; margin: 1rem 0; }
.msg { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 0.6rem; }
.msg.unread { border-left: 4px solid var(--primary); background: #f7faff; }
.msg header { margin-bottom: 0.4rem; display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
.msg-subject { font-weight: 600; margin: 0.2rem 0; }
.msg-body { white-space: pre-wrap; margin: 0.4rem 0 0.7rem; }
.msg .actions { margin-top: 0.4rem; }

/* ==== Editor ==== */
.editor { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg); }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; background: var(--bg-alt); border-bottom: 1px solid var(--line); padding: 6px; }
.editor-toolbar button { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 4px 8px; cursor: pointer; font: inherit; font-size: 0.9rem; }
.editor-toolbar button:hover { background: #eef1f7; }
.editor-toolbar .sep { width: 1px; background: var(--line); margin: 0 4px; }
.editor-area { min-height: 280px; padding: 1rem; outline: none; }
.editor-area:focus { background: #fffcf2; }
.editor-area h2, .editor-area h3 { margin-top: 1rem; }
.editor-area img { max-width: 100%; height: auto; }

/* ==== Footer ==== */
.site-footer { border-top: 1px solid var(--line); padding: 2rem 0; margin-top: 3rem; background: var(--bg-alt); }
.site-footer p { margin: 0.25rem 0; color: var(--muted); }
.site-footer a { color: var(--primary); }

/* ==== Design admin pannello ==== */
.design-grid { display: grid; grid-template-columns: 380px 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .design-grid { grid-template-columns: 1fr; } }
.design-form { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; position: sticky; top: 80px; }
.design-form h2 { margin-top: 1.4rem; font-size: 1.05rem; border-bottom: 1px solid var(--line); padding-bottom: 0.4rem; }
.color-row { display: grid; grid-template-columns: 1fr auto auto; gap: 0.5rem; align-items: center; margin-bottom: 0.7rem; }
.color-row span { font-size: 0.92rem; color: var(--text); }
.color-row input[type=color] { width: 40px; height: 40px; padding: 2px; border: 1px solid var(--line); border-radius: calc(var(--radius) * 0.6); background: var(--bg); cursor: pointer; }
.color-row input[type=text] { width: 92px; font-family: ui-monospace, monospace; padding: 0.4rem 0.5rem; border: 1px solid var(--line); border-radius: calc(var(--radius) * 0.6); background: var(--bg); color: var(--text); }

.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.preset-card { display: flex; flex-direction: column; align-items: stretch; gap: 0.35rem; padding: 0.7rem 0.8rem; background: var(--bg); border: 1px solid var(--line); border-radius: calc(var(--radius) * 0.8); cursor: pointer; text-align: left; font: inherit; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.preset-card:hover { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 15%, transparent); }
.preset-card.active { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent); }
.preset-card strong { font-size: 0.95rem; }
.preset-swatches { display: flex; gap: 4px; }
.preset-swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--text) 25%, transparent); }
.preset-card small { font-size: 0.78rem; color: var(--muted); }

.radius-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.radius-row label { flex: 1 1 30%; cursor: pointer; padding: 0.6rem; text-align: center; border: 1px solid var(--line); background: var(--bg); transition: border-color .15s, background .15s; }
.radius-row label:has(input:checked) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, var(--bg)); }
.radius-row input { display: none; }
.radius-row .swatch { display: block; width: 100%; height: 22px; background: var(--primary); margin-bottom: 6px; }
.radius-row [data-r="none"] .swatch { border-radius: 0; }
.radius-row [data-r="medium"] .swatch { border-radius: 8px; }
.radius-row [data-r="large"] .swatch { border-radius: 16px; }
.radius-row [data-r="none"] { border-radius: 0; }
.radius-row [data-r="medium"] { border-radius: 8px; }
.radius-row [data-r="large"] { border-radius: 16px; }

.design-preview { background: var(--bg-alt); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.design-preview header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; flex-wrap: wrap; gap: 0.6rem; }
.design-preview iframe { width: 100%; height: 720px; border: 1px solid var(--line); border-radius: calc(var(--radius) * 0.8); background: var(--bg); }
.design-preview .preview-pages { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.design-preview .preview-pages button { background: var(--bg); border: 1px solid var(--line); color: var(--text); padding: 0.3rem 0.6rem; border-radius: calc(var(--radius) * 0.6); cursor: pointer; font: inherit; font-size: 0.85rem; }
.design-preview .preview-pages button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: var(--bg); padding: 0.8rem 1.1rem; border-radius: var(--radius); box-shadow: var(--shadow); z-index: 999; opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: #136a39; color: #fff; }

/* ==== Servizi ==== */
.services-intro { font-size: 1.1rem; color: var(--text); max-width: 720px; margin-bottom: 2rem; }
.services-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.2rem; }
.service-card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; display: flex; flex-direction: column; gap: 0.6rem; transition: box-shadow .15s, transform .15s; }
.service-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.service-icon { font-size: 2.2rem; line-height: 1; width: 56px; height: 56px; border-radius: var(--radius); background: color-mix(in srgb, var(--primary) 12%, var(--bg)); color: var(--primary); display: flex; align-items: center; justify-content: center; }
.service-card h3 { margin: 0; font-size: 1.2rem; }
.service-card p { margin: 0; color: var(--text); white-space: pre-wrap; }
.service-card .btn { align-self: flex-start; margin-top: auto; }
.service-modes { list-style: none; padding: 0; margin: 0.4rem 0 0; display: flex; flex-direction: column; gap: 0.4rem; }
.service-modes li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; font-size: 0.95rem; }
.service-mode-tag { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.2rem 0.6rem; border-radius: 999px; background: color-mix(in srgb, var(--primary) 10%, var(--bg)); color: var(--primary); font-weight: 600; font-size: 0.85rem; }
.service-price { color: var(--text); font-weight: 500; }

/* ==== Dashboard analytics ==== */
.range-tabs { display: inline-flex; gap: 0.25rem; background: var(--bg-alt); padding: 0.3rem; border-radius: var(--radius); }
.range-tabs a { padding: 0.4rem 0.85rem; border-radius: calc(var(--radius) * 0.7); text-decoration: none; color: var(--text); font-weight: 500; font-size: 0.92rem; }
.range-tabs a:hover { background: var(--bg); }
.range-tabs a.active { background: var(--primary); color: #fff; }

.card-block { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.4rem; margin: 1.2rem 0; }
.card-block-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.8rem; flex-wrap: wrap; gap: 0.6rem; }
.card-block-head h2 { margin: 0; font-size: 1.1rem; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; margin-top: 1rem; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.two-col .card-block { margin: 0; }

.chart { width: 100%; }
.chart svg { width: 100%; height: 160px; }
.chart-bar { fill: var(--primary); opacity: 0.85; }
.chart-bar:hover { opacity: 1; }
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 11px; font-family: ui-monospace, monospace; }

.source-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.source-list li header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.25rem; }
.source-label { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600; background: var(--bg-alt); color: var(--text); }
.source-linkedin { background: #0a66c2; color: #fff; }
.source-google { background: #ea4335; color: #fff; }
.source-direct { background: var(--primary); color: #fff; }
.source-other { background: color-mix(in srgb, var(--text) 15%, var(--bg)); color: var(--text); }
.source-bar { background: var(--bg-alt); border-radius: 999px; height: 8px; overflow: hidden; }
.source-bar > span { display: block; height: 100%; background: var(--primary); transition: width .3s; }

.table.compact th, .table.compact td { padding: 0.45rem 0.7rem; font-size: 0.92rem; }

/* ==== LinkedIn icon ==== */
.linkedin-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius); background: var(--bg-alt); color: var(--text); transition: background .15s, color .15s; text-decoration: none; }
.linkedin-icon:hover { background: #0a66c2; color: #fff; }
.linkedin-icon svg { width: 18px; height: 18px; }

/* ==== Newsletter pubblica ==== */
.newsletter-block {
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 8%, var(--bg)) 0%, var(--bg) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2rem 1.8rem;
    margin: 2.5rem 0;
}
.newsletter-block h2 { margin: 0 0 0.5rem; font-size: 1.35rem; }
.newsletter-block p { margin: 0 0 1.2rem; color: var(--text); max-width: 560px; }
.newsletter-form { display: flex; gap: 0.5rem; flex-wrap: wrap; max-width: 520px; }
.newsletter-form input[type=email] {
    flex: 1; min-width: 200px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 0.6rem 0.8rem;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}
.newsletter-block .small.muted { display: block; margin-top: 0.6rem; }

/* ==== Logo settings (range slider visualizzazione) ==== */
.range-row { display: flex; align-items: center; gap: 0.8rem; }
.range-row input[type=range] { flex: 1; }
.range-value { min-width: 56px; text-align: right; font-family: ui-monospace, monospace; color: var(--muted); }
.logo-preview { display: flex; align-items: center; gap: 1rem; padding: 0.8rem; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); margin-top: 0.5rem; }
.logo-preview img { object-fit: contain; transition: height .15s; }

/* ==== Mobile Menu Toggle ==== */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text);
    margin-left: auto;
}
.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

/* ==== RESPONSIVE - TABLET (max-width: 900px) ==== */
@media (max-width: 900px) {
    /* Navigation mobile */
    .mobile-menu-toggle {
        display: block;
    }

    .nav {
        grid-template-columns: 1fr auto;
        position: relative;
    }

    .primary-nav {
        display: none;
        position: fixed;
        top: 61px;
        left: 0;
        right: 0;
        background: var(--bg);
        border-bottom: 1px solid var(--line);
        flex-direction: column;
        gap: 0;
        padding: 0.5rem 0;
        max-height: calc(100vh - 61px);
        overflow-y: auto;
        z-index: 1000;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        grid-column: 1 / -1;
    }

    .primary-nav.is-open {
        display: flex;
    }

    .nav-item {
        width: 100%;
    }

    .nav-link {
        padding: 0.85rem 1.25rem;
        border-radius: 0;
        width: 100%;
        text-align: left;
        justify-content: space-between;
    }

    /* Dropdown mobile - accordion style */
    .dropdown-menu {
        position: static;
        border: none;
        border-top: 1px solid var(--line);
        border-radius: 0;
        box-shadow: none;
        background: var(--bg-alt);
        margin: 0;
        padding: 0;
    }

    .dropdown-item {
        padding: 0.75rem 1.25rem 0.75rem 2.5rem;
    }

    .has-dropdown.is-open .dropdown-menu {
        display: block;
    }

    .user-nav {
        gap: 0.3rem;
        justify-self: end;
    }

    .user-greet {
        display: none;
    }

    /* Hero */
    .hero h1 {
        font-size: 2rem;
    }

    /* Stats */
    .stat-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    /* Card grid */
    .card-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    /* Services */
    .services-grid {
        grid-template-columns: 1fr;
    }

    /* Timeline */
    .timeline-item {
        padding-left: 40px;
    }

    /* Admin nav */
    .admin-nav {
        gap: 0.2rem;
    }

    .admin-nav a {
        padding: 0.4rem 0.65rem;
        font-size: 0.88rem;
    }
}

/* ==== RESPONSIVE - MOBILE (max-width: 768px) ==== */
@media (max-width: 768px) {
    html {
        font-size: 14px !important;
    }

    body {
        font-size: 14px !important;
    }

    h1 {
        font-size: 1.5rem !important;
    }

    h2 {
        font-size: 1.2rem !important;
    }

    h3 {
        font-size: 1.05rem !important;
    }

    p {
        font-size: 1rem !important;
    }

    .lead {
        font-size: 1rem !important;
    }

    .container {
        padding: 0 2rem;
    }

    /* Previeni overflow di testo */
    h1, h2, h3, h4, h5, h6, p {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .section {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    /* Brand */
    .brand-name {
        font-size: 0.95rem;
    }

    .brand-logo {
        max-height: 40px;
    }

    /* Tables - Responsive scroll */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0;
        padding: 0;
    }

    .table {
        min-width: 600px;
    }

    .table th,
    .table td {
        padding: 0.6rem 0.7rem;
        font-size: 0.9rem;
    }

    /* Data table scrollable */
    .data-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Cards - Single column */
    .card-grid {
        grid-template-columns: 1fr;
    }

    .card-list {
        grid-template-columns: 1fr;
    }

    /* Stats */
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }

    .stat {
        padding: 0.9rem;
    }

    .stat-num {
        font-size: 1.75rem;
    }

    /* Two column layouts */
    .two-col {
        grid-template-columns: 1fr;
    }

    /* Bio */
    .bio {
        padding: 1.5rem;
    }

    .bio-head {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }

    .bio-photo {
        width: 120px;
        height: 120px;
    }

    /* Forms - Full width */
    .form {
        max-width: 100%;
    }

    .form input,
    .form select,
    .form textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        text-align: center;
    }

    /* Buttons */
    .btn {
        padding: 0.65rem 1rem;
    }

    /* Hero CTA */
    .hero-cta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .hero-cta .btn {
        width: 100%;
        text-align: center;
    }

    /* Section headers */
    .section-head {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Newsletter block */
    .newsletter-block {
        padding: 1.5rem 1.25rem;
    }

    .newsletter-form {
        flex-direction: column;
    }

    .newsletter-form input[type=email] {
        width: 100%;
        min-width: 100%;
    }

    .newsletter-form .btn {
        width: 100%;
    }

    /* Event list */
    .event-list li {
        flex-direction: column;
        align-items: flex-start;
    }

    .event-list time {
        min-width: auto;
    }

    /* Timeline */
    .timeline::before {
        left: 10px;
    }

    .timeline-item {
        padding-left: 35px;
    }

    .timeline-dot {
        left: 3px;
        width: 16px;
        height: 16px;
    }

    .timeline-card {
        padding: 0.9rem 1rem;
    }

    /* Articles */
    .article-cover {
        max-height: 240px;
        margin: 0 0 1.5rem;
        border-radius: var(--radius);
    }

    /* Editor */
    .editor-toolbar {
        padding: 4px;
        gap: 2px;
    }

    .editor-toolbar button {
        padding: 4px 6px;
        font-size: 0.85rem;
    }

    /* Messages */
    .msg-list .msg {
        padding: 0.85rem 1rem;
    }

    /* Range tabs */
    .range-tabs {
        width: 100%;
        justify-content: space-between;
    }

    .range-tabs a {
        flex: 1;
        text-align: center;
        padding: 0.45rem 0.5rem;
        font-size: 0.85rem;
    }

    /* Card blocks */
    .card-block {
        padding: 1rem 1.15rem;
    }

    /* Chart */
    .chart svg {
        height: 140px;
    }

    /* Admin panels - Design grid */
    .design-grid {
        grid-template-columns: 1fr;
    }

    .design-form {
        position: static;
    }

    /* Preset grid */
    .preset-grid {
        grid-template-columns: 1fr;
    }

    /* Footer */
    .site-footer {
        padding: 1.5rem 0;
        margin-top: 2rem;
        text-align: center;
    }
}

/* ==== RESPONSIVE - SMALL MOBILE (max-width: 480px) ==== */
@media (max-width: 480px) {
    html {
        font-size: 13px !important;
    }

    body {
        font-size: 13px !important;
    }

    h1 {
        font-size: 1.4rem !important;
    }

    h2 {
        font-size: 1.1rem !important;
    }

    h3 {
        font-size: 1rem !important;
    }

    p {
        font-size: 1rem !important;
    }

    .lead {
        font-size: 0.95rem !important;
    }

    .container {
        padding: 0 2rem;
    }

    .section {
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
    }

    /* Previeni overflow di testo */
    h1, h2, h3, h4, h5, h6, p {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Brand */
    .brand-name {
        font-size: 0.9rem;
    }

    .brand-logo {
        max-height: 36px;
    }

    /* Stats - Full width on very small screens */
    .stat-grid {
        grid-template-columns: 1fr;
    }

    /* Bio */
    .bio {
        padding: 1.25rem;
    }

    .bio-photo {
        width: 100px;
        height: 100px;
    }

    /* Hero */
    .hero {
        padding: 2rem 0;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .lead {
        font-size: 0.95rem;
    }

    .services-intro {
        font-size: 1rem;
    }

    .hero-photo img,
    .placeholder-photo {
        max-width: 240px;
    }

    /* Card body */
    .card-body {
        padding: 0.85rem 0.95rem;
    }

    /* Services */
    .service-card {
        padding: 1.25rem;
    }

    .service-icon {
        width: 48px;
        height: 48px;
        font-size: 1.9rem;
    }

    /* Timeline */
    .timeline-item {
        padding-left: 30px;
        margin-bottom: 1.25rem;
    }

    .timeline-dot {
        left: 2px;
        width: 14px;
        height: 14px;
    }

    .timeline::before {
        left: 8px;
    }

    /* Buttons */
    .btn {
        padding: 0.6rem 0.85rem;
        font-size: 0.95rem;
    }

    /* Newsletter */
    .newsletter-block {
        padding: 1.25rem 1rem;
    }

    .newsletter-block h2 {
        font-size: 1.2rem;
    }

    /* Actions */
    .actions {
        flex-direction: column;
    }

    .actions .btn,
    .actions button {
        width: 100%;
    }

    /* Color row - Stack vertically */
    .color-row {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    .color-row input[type=text] {
        width: 100%;
    }

    /* Radius row */
    .radius-row label {
        flex: 1 1 100%;
    }

    /* Toast notifications */
    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}

/* ==== Print Styles ==== */
@media print {
    .site-header,
    .site-footer,
    .mobile-menu-toggle,
    .user-nav,
    .btn,
    .actions,
    .admin-nav {
        display: none !important;
    }

    body {
        font-size: 12pt;
        color: #000;
        background: #fff;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }

    a {
        color: #000;
        text-decoration: underline;
    }

    .card,
    .bio,
    .timeline-card {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
}
