@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=Jost:wght@300;400;500;600&display=swap');
:root {
    --brand: #B5A27E;
    --brand-dark: #9C8862;
    --brand-soft: #EFE8DA;
    --ink: #221F21;
    --ink-soft: #5C564E;
    --muted: #9C9488;
    --line: #E6DFD2;
    --bg: #F6F1E9;
    --card: #FFFFFF;
    --sidebar-bg: #221F21;
    --table-stripe: #FBF7EF;
    --input-bg: #FFFFFF;
    --green: #2F7D5B;
    --red: #A6402E;
    --shadow: 0 1px 3px rgba(34,31,33,.05), 0 6px 18px rgba(34,31,33,.04);
    --serif: 'Cormorant Garamond', 'Times New Roman', Georgia, serif;
    --sans: 'Jost', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    color-scheme: light;
}

html.dark {
    --brand: #C7B188;
    --brand-dark: #D8C7A0;
    --brand-soft: #2A2521;
    --ink: #F4EFE6;
    --ink-soft: #C3BBAC;
    --muted: #8C8475;
    --line: #353029;
    --bg: #1A1715;
    --card: #221F21;
    --sidebar-bg: #1A1715;
    --table-stripe: #2A2521;
    --input-bg: #2A2521;
    --green: #5FB68E;
    --red: #D08A78;
    --shadow: 0 1px 3px rgba(0,0,0,.3), 0 6px 24px rgba(0,0,0,.25);
    color-scheme: dark;
}
html.dark body { background: var(--bg); }
html.dark .sidebar { background: var(--sidebar-bg); border-right-color: var(--line); }
html.dark .card,
html.dark .kpi:not(.brand) { background: var(--card); border-color: var(--line); }
html.dark table th { background: #2A2521; color: var(--muted); }
html.dark table tr:hover td { background: #2A2521; }
html.dark input[type=text], html.dark input[type=email], html.dark input[type=password],
html.dark input[type=number], html.dark input[type=date], html.dark input[type=url],
html.dark textarea, html.dark select {
    background: var(--input-bg); color: var(--ink); border-color: var(--line);
}
html.dark .btn-ghost { background: var(--input-bg); border-color: var(--line); color: var(--ink); }
html.dark .btn-ghost:hover { background: #353029; }
html.dark .modal-toolbar { background: #2A2521; border-bottom-color: var(--line); }
html.dark .donor-list { border-color: var(--line); }
html.dark .guide { background: #2A2521; border-color: #4A4031; color: #E7D9BC; }
html.dark .guide h3 { color: var(--brand); }
html.dark .guide code { background: #221F21; border-color: var(--line); color: var(--ink); }
html.dark .topbar .user .avatar { color: var(--ink); }
html.dark .login-page { background: linear-gradient(135deg, #1A1715 0%, #221F21 100%); }
html.dark .login-card { background: var(--card); }
html.dark .flash-success { background: #16291F; color: #8FD3B0; border-color: #2A4D3A; }
html.dark .flash-error { background: #2D1812; color: #E0A593; border-color: #4F2E22; }
html.dark .flash-info { background: #2A2521; color: #D8C7A0; border-color: #4A4031; }
html.dark .badge-active, html.dark .badge-completed { background: #16291F; color: #8FD3B0; }
html.dark .badge-pending, html.dark .badge-draft { background: #2A2410; color: #D8C7A0; }
html.dark .badge-failed, html.dark .badge-closed { background: #2D1812; color: #E0A593; }
html.dark .menu a { color: var(--ink-soft); }
html.dark .menu a:hover { background: #2A2521; color: var(--brand); }
html.dark .menu a.active { background: var(--brand); color: var(--ink); }

/* Theme toggle (iOS-style) */
.theme-toggle-wrap {
    margin: 16px 24px 8px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--bg) 0%, var(--card) 100%);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.theme-toggle-wrap .label {
    display: flex; align-items: center; gap: 8px;
    color: var(--ink-soft); font-size: 13px; font-weight: 500;
}
.theme-toggle-wrap .label i { color: var(--brand); width: 16px; text-align: center; }
.ios-switch {
    position: relative;
    display: inline-block;
    width: 46px; height: 26px;
    flex-shrink: 0;
}
.ios-switch input { opacity: 0; width: 0; height: 0; }
.ios-switch .track {
    position: absolute; cursor: pointer; inset: 0;
    background: #E6DFD2; border-radius: 999px;
    transition: background .2s;
}
html.dark .ios-switch .track { background: #353029; }
.ios-switch .track::before {
    content: "";
    position: absolute;
    height: 22px; width: 22px;
    left: 2px; top: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform .25s cubic-bezier(.4,1.4,.6,1), background .2s;
    box-shadow: 0 2px 4px rgba(34,31,33,.2);
}
.ios-switch input:checked + .track {
    background: var(--brand);
}
.ios-switch input:checked + .track::before {
    transform: translateX(20px);
    background: #fff;
}
.ios-switch:hover .track::before { box-shadow: 0 2px 8px rgba(34,31,33,.3); }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }
body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    font-weight: 300;
    -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
pre, code { word-break: break-word; overflow-wrap: anywhere; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; max-width: 100%; }
.layout > * { min-width: 0; } /* impedisce ai grid items di forzare overflow */
.sidebar { background: var(--sidebar-bg, #221F21); border-right: 1px solid var(--line); padding: 24px 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(34,31,33,.45); z-index: 89; backdrop-filter: blur(2px); }
.sidebar-overlay.open { display: block; }
.mobile-toggle { display: none; background: var(--ink); color: #F4EFE6; border: none; width: 40px; height: 40px; border-radius: 8px; cursor: pointer; font-size: 17px; align-items: center; justify-content: center; flex-shrink: 0; }
.mobile-toggle:hover { background: var(--brand); color: var(--ink); }
.sidebar-close { display: none; position: absolute; top: 18px; right: 18px; background: rgba(244,239,230,.1); border: none; width: 32px; height: 32px; border-radius: 6px; cursor: pointer; color: #F4EFE6; }
.sidebar .brand { padding: 0 22px 20px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; border-bottom: 1px solid rgba(244,239,230,.12); margin-bottom: 16px; }
.sidebar .brand img { display: block; height: auto; width: auto; max-width: 150px; max-height: 26px; }
.sidebar .brand .title { font-family: var(--serif); font-weight: 500; font-size: 14px; line-height: 1.15; letter-spacing: .04em; color: #F4EFE6; }
.sidebar .brand .title small { display: block; font-family: var(--sans); color: #A79F90; font-weight: 400; font-size: 10px; text-transform: uppercase; letter-spacing: .14em; margin-top: 1px; }

.menu { list-style: none; padding: 0; margin: 0; }
.menu li { margin: 2px 12px; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 9px 14px; color: #C7BFB0; border-radius: 4px; font-weight: 400; letter-spacing: .02em; }
.menu a:hover { background: rgba(199,177,136,.14); color: #C7B188; text-decoration: none; }
.menu a.active { background: var(--brand); color: var(--ink); }
.menu a.active:hover { color: var(--ink); background: var(--brand-dark); }
.menu .group-title { padding: 16px 26px 6px; font-size: 11px; text-transform: uppercase; color: #8C8475; letter-spacing: .14em; font-weight: 500; }

.main { padding: 24px 32px; min-width: 0; max-width: 100%; overflow-x: hidden; }
.topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.topbar h1 { font-family: var(--serif); font-size: 28px; margin: 0; font-weight: 500; letter-spacing: .005em; }
.topbar .user { display: flex; align-items: center; gap: 14px; color: var(--ink-soft); font-size: 13px; }
.topbar .user .avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; font-weight: 500; font-family: var(--serif); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; max-width: 100%; min-width: 0; word-break: break-word; }
.card h2 { font-family: var(--serif); margin: 0 0 16px; font-size: 22px; font-weight: 500; letter-spacing: .005em; }
.card .card-sub { color: var(--muted); font-size: 13px; margin-top: -10px; margin-bottom: 16px; }

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

.kpi { padding: 18px 20px; border-radius: 8px; background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; font-weight: 500; }
.kpi .value { font-family: var(--serif); font-size: 34px; font-weight: 600; margin-top: 6px; color: var(--ink); }
.kpi.brand { background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); color: var(--ink); border: none; }
.kpi.brand .label, .kpi.brand .value { color: var(--ink); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
table th, table td { padding: 12px 12px; text-align: left; border-bottom: 1px solid var(--line); }
table th { font-weight: 500; color: var(--muted); text-transform: uppercase; font-size: 11px; letter-spacing: .1em; background: var(--table-stripe); }
table tr:hover td { background: var(--table-stripe); }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 4px; font-weight: 500; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; font-family: var(--sans); border: 1px solid transparent; cursor: pointer; text-decoration: none; transition: all .2s ease; }
.btn-primary { background: var(--ink); color: #F4EFE6; }
.btn-primary:hover { background: var(--brand); text-decoration: none; color: var(--ink); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--brand-soft); border-color: var(--brand); text-decoration: none; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #8A3324; color: #fff; text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; color: var(--ink-soft); }
.form-row .help { color: var(--muted); font-size: 12px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], textarea, select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; font-size: 13px; font-family: var(--sans); font-weight: 300;
    background: #fff; color: var(--ink);
}
textarea { min-height: 100px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(181,162,126,.18); }

.flash { padding: 12px 16px; border-radius: 4px; margin-bottom: 16px; font-size: 13px; }
.flash-success { background: #E6F0EA; color: #1F6347; border: 1px solid #BFD9CB; }
.flash-error { background: #F6E6E2; color: #8A2F1F; border: 1px solid #E2C2BA; }
.flash-info { background: var(--brand-soft); color: #6b5a30; border: 1px solid var(--gold-line, rgba(181,162,126,.45)); }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .1em; }
.badge-active { background: #E6F0EA; color: #1F6347; }
.badge-closed { background: #EFE8DA; color: #5C564E; }
.badge-draft { background: #F2EAD7; color: #7A6A3F; }
.badge-completed { background: #E6F0EA; color: #1F6347; }
.badge-pending { background: #F2EAD7; color: #7A6A3F; }
.badge-failed { background: #F6E6E2; color: #8A2F1F; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.inline-form { display: inline; }

.copy-link { display: flex; gap: 8px; }
.copy-link input { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }

.guide { background: #FBF7EF; border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.guide h3 { font-family: var(--serif); margin-top: 0; color: var(--brand-dark); font-size: 18px; font-weight: 500; }
.guide ol { margin: 8px 0 0 20px; padding: 0; }
.guide li { margin-bottom: 6px; font-size: 13px; }
.guide code { background: #fff; padding: 2px 6px; border-radius: 4px; font-size: 12px; border: 1px solid var(--line); }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { width: auto; }

.muted { color: var(--muted); font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.no-data { padding: 40px; text-align: center; color: var(--muted); }

.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #F6F1E9 0%, #EFE8DA 100%); padding: 20px; }
.login-card { width: 100%; max-width: 420px; background: #fff; border-radius: 8px; box-shadow: 0 16px 48px rgba(34,31,33,.12); overflow: hidden; }
.login-card .header { padding: 32px 32px 0; text-align: center; }
.login-card .header img { height: 56px; }
.login-card .header h1 { font-family: var(--serif); font-size: 26px; font-weight: 500; margin: 16px 0 4px; }
.login-card .header p { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.login-card form { padding: 24px 32px 32px; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: 12px; }

/* Detail header (Donazioni/Condivisione/Modifica/Invita) */
.detail-top {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    border-bottom: none;
    padding: 22px;
    box-shadow: var(--shadow);
    margin-bottom: 0;
}
.detail-back { font-size: 13px; }
.detail-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.detail-head-info { min-width: 0; flex: 1 1 200px; }
.detail-title { font-family: var(--serif); margin: 0 0 4px; font-size: 26px; font-weight: 500; word-break: break-word; }
.detail-meta { color: var(--muted); font-size: 13px; word-break: break-word; line-height: 1.7; }
.detail-meta .sep { margin: 0 4px; opacity: .6; }
.share-code-pill { background: var(--brand-soft); padding: 2px 8px; border-radius: 4px; font-weight: 500; color: var(--brand-dark); letter-spacing: .1em; }
.detail-head-actions { flex-shrink: 0; }
.detail-shell {
    background: var(--card);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    padding: 0 22px;
    margin: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.detail-tabs { margin: 0; }
.detail-body {
    background: var(--card);
    border: 1px solid var(--line);
    border-top: none;
    border-radius: 0 0 8px 8px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    max-width: 100%;
    min-width: 0;
}

/* Modal */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(34,31,33,.55);
    display: none; align-items: flex-start; justify-content: center;
    z-index: 200; padding: 40px 20px; overflow-y: auto;
    backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; animation: fadeIn .15s ease; }
@keyframes fadeIn { from {opacity:0} to {opacity:1} }
.modal {
    background: var(--card); border-radius: 8px; max-width: 880px; width: 100%;
    box-shadow: 0 24px 64px rgba(34,31,33,.24); overflow: hidden;
    animation: slideUp .2s ease;
}
@keyframes slideUp { from {transform: translateY(12px); opacity: 0;} to {transform: none; opacity: 1;} }
.modal-header {
    padding: 22px 28px; border-bottom: 1px solid var(--line);
    display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
}
.modal-header h2 { font-family: var(--serif); margin: 0 0 4px; font-size: 24px; font-weight: 500; }
.modal-header .sub { color: var(--muted); font-size: 13px; }
.modal-close {
    background: transparent; border: none; cursor: pointer; color: var(--muted);
    width: 32px; height: 32px; border-radius: 6px; font-size: 16px;
    display: inline-flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--brand-soft); color: var(--ink); }

.modal-body { padding: 24px 28px; }
.modal-toolbar {
    display: flex; gap: 8px; flex-wrap: wrap;
    padding: 12px 28px; background: var(--table-stripe); border-bottom: 1px solid var(--line);
}
.modal-stats { display: flex; gap: 24px; flex-wrap: wrap; padding: 16px 28px 20px; }
.modal-stat .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; font-weight: 500; }
.modal-stat .val { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--ink); margin-top: 2px; }
.modal-stat .val.brand { color: var(--brand-dark); }

.donor-list { max-height: 50vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.donor-list table { font-size: 13px; }
.donor-list table th { position: sticky; top: 0; z-index: 1; }
.donor-list .demo-tag {
    display: inline-block; background: var(--brand); color: var(--ink); font-size: 10px;
    padding: 1px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: .08em; margin-left: 6px;
    font-weight: 600;
}

.dialog {
    background: var(--card); border-radius: 8px; max-width: 480px; width: 100%;
    box-shadow: 0 24px 64px rgba(34,31,33,.28); padding: 28px;
}
.dialog h3 { font-family: var(--serif); margin: 0 0 8px; font-size: 22px; font-weight: 500; }
.dialog p { color: var(--ink-soft); margin: 0 0 20px; }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-end; }

.tabs {
    display: flex; gap: 4px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    flex-wrap: nowrap;
}
.tabs::-webkit-scrollbar { height: 0; }
.tabs a { padding: 10px 18px; color: var(--ink-soft); font-weight: 500; font-size: 13px; border-bottom: 2px solid transparent; white-space: nowrap; flex-shrink: 0; }
.tabs a.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.tabs a:hover { text-decoration: none; color: var(--brand-dark); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 6px; max-width: 100%; }
.table-wrap table { min-width: 640px; }

@media (max-width: 960px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0; left: -280px;
        width: 260px;
        height: 100vh;
        z-index: 90;
        transition: left .25s ease;
        box-shadow: 0 0 24px rgba(34,31,33,.18);
    }
    .sidebar.open { left: 0; }
    .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }
    html.dark .sidebar-close { background: var(--input-bg); color: var(--ink); }
    .mobile-toggle { display: inline-flex; }
    .main { padding: 14px; }
    .topbar { margin-bottom: 16px; gap: 10px; min-width: 0; }
    .topbar h1 { font-size: 22px; min-width: 0; }
    .topbar > div { min-width: 0; flex: 1; }
    .topbar .user span:not(.avatar) { display: none; }
    .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
    .grid > * { min-width: 0; }
    .card { padding: 16px; border-radius: 8px; }
    .card h2 { font-size: 20px; }
    .kpi { padding: 14px 16px; }
    .kpi .value { font-size: 26px; }
    .modal { border-radius: 8px 8px 0 0; max-height: 92vh; }
    .modal-backdrop { padding: 0; align-items: flex-end; }
    .modal-header, .modal-body, .modal-stats, .modal-toolbar { padding-left: 18px; padding-right: 18px; }
    .modal-stats { gap: 14px; flex-wrap: wrap; }
    .modal-stat .val { font-size: 20px; }
    .donor-list { max-height: 60vh; }
    .dialog { border-radius: 8px; padding: 22px; margin: 0 16px; max-width: calc(100% - 32px); }
    .dialog .actions { flex-wrap: wrap; }
    .dialog .actions .btn { flex: 1 1 auto; justify-content: center; }
    .actions { flex-wrap: wrap; min-width: 0; }
    .actions .btn-sm { padding: 6px 10px; font-size: 11.5px; }
    .login-card { max-width: 100%; }
    .login-card form, .login-card .header { padding-left: 24px; padding-right: 24px; }
    table th, table td { padding: 10px 8px; font-size: 12.5px; }
    .copy-link { flex-direction: column; gap: 8px; }
    .copy-link input { min-width: 0; width: 100%; }
}

@media (max-width: 540px) {
    .main { padding: 12px; }
    .grid.cols-4 { grid-template-columns: 1fr; }
    .topbar { flex-wrap: nowrap; }
    .topbar h1 { font-size: 20px; }
    .tabs a { padding: 8px 12px; font-size: 12.5px; }
    .actions .btn span { display: inline; }
    .actions { gap: 6px; }
    .actions .btn { padding: 8px 12px; font-size: 12px; }
    .modal-toolbar { gap: 6px; }
    .modal-toolbar .btn { padding: 7px 10px; font-size: 12px; }
    .receipt .row { flex-wrap: wrap; }
    .login-card .header { padding: 24px 18px 0; }
    .login-card form { padding: 18px; }
}

/* Forza colonna singola su mobile per le griglie inline */
@media (max-width: 760px) {
    [style*="grid-template-columns:repeat(2,1fr)"],
    [style*="grid-template-columns: repeat(2, 1fr)"],
    [style*="grid-template-columns:1.6fr 1fr"],
    [style*="grid-template-columns: 1.6fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 960px) {
    .detail-top { padding: 16px; border-radius: 8px 8px 0 0; }
    .detail-title { font-size: 22px; }
    .detail-meta { font-size: 12.5px; }
    .detail-shell { padding: 0 12px; }
    .detail-body { padding: 18px 16px; border-radius: 0 0 8px 8px; }
    .detail-head { gap: 10px; }
    .detail-head-actions { width: 100%; }
    .detail-tabs a { padding: 9px 14px; font-size: 12.5px; }
}

@media (max-width: 540px) {
    .detail-top { padding: 14px; }
    .detail-body { padding: 16px 14px; }
    .detail-shell { padding: 0 8px; }
    .detail-tabs a i { display: none; }
    .detail-tabs a { padding: 9px 12px; }
}

/* ============================================================
   Template picker (admin edit list)
   ============================================================ */
.tpl-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-top: 6px;
}
.tpl-card-pick {
    text-align: left;
    background: var(--surface, #fff);
    border: 2px solid var(--line);
    border-radius: 8px;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    transition: border-color .15s, transform .15s, box-shadow .15s;
    display: flex;
    flex-direction: column;
    font: inherit;
    color: inherit;
    min-width: 0;
}
.tpl-card-pick:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px -16px rgba(34,31,33,.18);
    border-color: var(--brand, #B5A27E);
}
.tpl-card-pick.is-active {
    border-color: var(--brand, #B5A27E);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand, #B5A27E) 22%, transparent);
}
.tpl-card-pick-swatch {
    height: 88px;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    padding: 10px;
}
.tpl-card-pick-mood {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .1em;
    background: rgba(255,255,255,.92);
    color: #221F21;
    padding: 4px 10px;
    border-radius: 999px;
}
.tpl-card-pick-mood.mood-giocoso { background: #F2EAD7; color: #7A6A3F; }
.tpl-card-pick-mood.mood-scatenato { background: #F0DAD2; color: #8A3324; }
.tpl-card-pick-mood.mood-elegante { background: #E1D7C5; color: #4A3722; }
.tpl-card-pick-mood.mood-sobrio { background: #E6DFD2; color: #5C564E; }
.tpl-card-pick-meta {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.tpl-card-pick-name {
    font-family: var(--serif);
    font-weight: 500;
    font-size: 17px;
    line-height: 1.25;
}
.tpl-card-pick-desc {
    font-size: 12.5px;
    color: var(--muted, #9C9488);
    line-height: 1.4;
}
.tpl-card-pick-cat {
    font-size: 11.5px;
    color: var(--muted, #9C9488);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
@media (max-width: 540px) {
    .tpl-picker { grid-template-columns: 1fr 1fr; gap: 10px; }
    .tpl-card-pick-swatch { height: 64px; }
    .tpl-card-pick-meta { padding: 10px 12px 12px; }
    .tpl-card-pick-name { font-size: 15px; }
    .tpl-card-pick-desc { font-size: 11.5px; }
}

/* ===================== TABS (admin edit lista) ===================== */
.bo-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--line);
    margin: -10px -20px 22px;
    padding: 0 20px;
    background: linear-gradient(180deg, rgba(181,162,126,.06), transparent);
}
.bo-tab-btn {
    background: transparent;
    border: 0;
    padding: 14px 18px;
    font-family: var(--sans); font-size: 13px; font-weight: 500;
    letter-spacing: .06em; text-transform: uppercase;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
    display: inline-flex; align-items: center; gap: 9px;
    transition: color .18s ease;
}
.bo-tab-btn:hover { color: var(--brand-dark); }
.bo-tab-btn.is-active {
    color: var(--brand-dark);
    border-bottom-color: var(--brand-dark);
}
.bo-tab-btn .bo-tab-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--line); color: var(--ink);
    font-size: 11.5px; font-weight: 600;
    transition: background .2s, color .2s;
}
.bo-tab-btn.is-active .bo-tab-num {
    background: linear-gradient(135deg, var(--brand-dark), #B5A27E);
    color: var(--ink);
}
.bo-tab-pane { display: none; }
.bo-tab-pane.is-active {
    display: block;
    animation: boTabIn .25s ease;
}
@keyframes boTabIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===================== COLOR FIELD (Coloris wrapper) ===================== */
.color-field {
    display: flex; align-items: center; gap: 10px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 5px 10px 5px 5px;
    transition: border-color .15s, box-shadow .2s;
}
.color-field:hover { border-color: var(--brand); }
.color-field:focus-within {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(181,162,126,.18);
}
.color-field .coloris-preview {
    width: 34px; height: 34px;
    border-radius: 6px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--line), 0 2px 4px rgba(34,31,33,.06);
    flex-shrink: 0;
    cursor: pointer;
    background: #fff;
    background-image:
        linear-gradient(45deg, #eee 25%, transparent 25%),
        linear-gradient(-45deg, #eee 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eee 75%),
        linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0;
    transition: transform .15s;
}
.color-field .coloris-preview:hover { transform: scale(1.05); }
.color-field .coloris-preview.has-color { background-image: none; }
.color-field .coloris-input {
    flex: 1;
    padding: 9px 4px;
    border: 0; background: transparent;
    font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 14px;
    text-transform: uppercase;
    color: var(--ink);
    min-width: 0;
    outline: none;
}
.clr-picker { z-index: 100 !important; }

/* ===== Vecchio picker — disattivato ===== */
.acc-color-picker-OBSOLETE { position: relative; }
.acc-color-picker-row {
    display: flex; align-items: center; gap: 8px;
    background: var(--card);
    border: 1px solid var(--line); border-radius: 6px;
    padding: 6px 8px 6px 6px;
    transition: border-color .15s, box-shadow .2s;
    cursor: pointer;
}
.acc-color-picker.is-open .acc-color-picker-row,
.acc-color-picker-row:hover {
    border-color: var(--brand);
}
.acc-color-picker.is-open .acc-color-picker-row {
    box-shadow: 0 0 0 3px rgba(181,162,126,.18);
}
.acc-color-picker-caret {
    background: transparent; border: 0; cursor: pointer;
    padding: 6px 8px; color: var(--muted);
    transition: transform .2s, color .15s;
}
.acc-color-picker.is-open .acc-color-picker-caret {
    transform: rotate(180deg); color: var(--brand-dark);
}
.acc-color-picker-panel {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px);
    background: var(--card);
    border: 1px solid var(--line); border-radius: 8px;
    padding: 14px;
    box-shadow: 0 18px 42px -16px rgba(34,31,33,.28), 0 4px 12px rgba(34,31,33,.08);
    z-index: 20;
    opacity: 0;
    transform: translateY(-8px) scale(.98);
    pointer-events: none;
    transition: opacity .2s, transform .2s cubic-bezier(.4,1.4,.6,1);
}
.acc-color-picker.is-open .acc-color-picker-panel {
    opacity: 1; transform: translateY(0) scale(1); pointer-events: auto;
}
.acc-color-picker-row .preview {
    width: 32px; height: 32px; border-radius: 6px;
    border: 2px solid #fff; flex-shrink: 0;
    box-shadow: 0 0 0 1px var(--line), 0 2px 4px rgba(34,31,33,.06);
    background: #fff;
    background-image:
        linear-gradient(45deg, #eee 25%, transparent 25%),
        linear-gradient(-45deg, #eee 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #eee 75%),
        linear-gradient(-45deg, transparent 75%, #eee 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0;
    cursor: pointer;
    transition: transform .15s;
}
.acc-color-picker-row .preview:hover { transform: scale(1.05); }
.acc-color-picker-row .preview.has-color { background-image: none; }
.acc-color-picker-row input[type="text"] {
    flex: 1; padding: 7px 4px;
    border: 0; background: transparent;
    font-family: 'SF Mono', Menlo, Monaco, Consolas, monospace;
    font-size: 14px; text-transform: uppercase;
    color: var(--ink);
    min-width: 0;
}
.acc-color-picker-row input[type="text"]:focus { outline: none; }
.acc-color-picker-clear {
    padding: 7px 12px; background: transparent; color: var(--muted);
    border: 0; border-radius: 4px; cursor: pointer;
    font-family: inherit; font-size: 12.5px; font-weight: 500;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.acc-color-picker-clear:hover { background: var(--red); color: #fff; }
.acc-color-picker-swatches {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
    gap: 8px;
}
.acc-color-picker-swatches button {
    aspect-ratio: 1; border-radius: 6px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--line), 0 2px 4px rgba(34,31,33,.06);
    cursor: pointer; padding: 0;
    transition: transform .15s cubic-bezier(.4,1.4,.6,1), box-shadow .2s;
    position: relative;
}
.acc-color-picker-swatches button:hover {
    transform: scale(1.15) translateY(-2px);
    box-shadow: 0 0 0 1px var(--line), 0 8px 18px -4px rgba(34,31,33,.25);
    z-index: 2;
}
.acc-color-picker-swatches button.is-selected {
    box-shadow: 0 0 0 2px var(--ink), 0 4px 8px rgba(34,31,33,.15);
}
.acc-color-picker-swatches button.is-selected::after {
    content: "✓"; position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 600; font-size: 13px;
    text-shadow: 0 1px 2px rgba(34,31,33,.4);
}
.acc-color-picker-slider {
    margin: 10px 0 4px; height: 14px; border-radius: 999px;
    background: linear-gradient(
        90deg, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%,
        #0000ff 67%, #ff00ff 83%, #ff0000 100%
    );
    cursor: pointer; position: relative;
}
.acc-color-picker-slider input {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 14px;
    background: transparent; cursor: pointer;
    margin: 0; padding: 0; border: 0; outline: 0;
}
.acc-color-picker-slider input::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 22px; height: 22px;
    background: #fff; border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(34,31,33,.3), 0 2px 5px rgba(34,31,33,.3);
    border-radius: 50%; cursor: grab; margin-top: -4px;
}
.acc-color-picker-slider input::-moz-range-thumb {
    width: 22px; height: 22px;
    background: #fff; border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(34,31,33,.3), 0 2px 5px rgba(34,31,33,.3);
    border-radius: 50%; cursor: grab;
}
