:root {
    --primary: #2b5797;
    --primary-dark: #1f4275;
    --bg: #f3f5f8;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e2e6ea;
    --danger: #c0392b;
    --success: #1e8449;
    --warning: #b9770e;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.4; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 18px 0 10px; color: var(--primary-dark); }
h1 .count { font-size: 14px; color: var(--muted); font-weight: normal; }
code { background: #eef1f5; padding: 1px 5px; border-radius: 3px; font-size: 12px; }

/* Top bar */
.topbar { background: var(--primary-dark); color: #fff; display: flex; align-items: center; padding: 0 16px; height: 52px; gap: 20px; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 17px; white-space: nowrap; }
.topbar .brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: 2px; flex: 1; align-items: center; }
.mainnav a, .nav-group-btn { color: #d8e1f0; padding: 8px 11px; border-radius: 6px; white-space: nowrap; font-size: 14px; background: none; border: 0; cursor: pointer; font-family: inherit; }
.mainnav a:hover, .nav-group-btn:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.mainnav a.active, .nav-group.active > .nav-group-btn { background: rgba(255,255,255,.18); color: #fff; }
.nav-group { position: relative; }
.nav-group .caret { font-size: 10px; opacity: .7; }
.nav-menu { display: none; position: absolute; top: 100%; left: 0; min-width: 190px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 45; flex-direction: column; }
.nav-menu a { color: var(--text); padding: 8px 12px; border-radius: 6px; }
.nav-menu a:hover { background: #eef2f8; }
.nav-menu a.active { background: var(--primary); color: #fff; }
.nav-group.open .nav-menu { display: flex; }
@media (hover: hover) { .nav-group:hover .nav-menu { display: flex; } }
.userbox { display: flex; gap: 12px; align-items: center; color: #d8e1f0; font-size: 13px; }
.userbox a { color: #fff; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
.solo-mobile { display: none; }

.container { max-width: 1280px; margin: 0 auto; padding: 20px 16px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-success { background: #e6f4ea; border-color: #b7dfc2; color: #1e5631; }
.alert-error { background: #fdecea; border-color: #f5c2c0; color: #7b1f17; }
.alert-warning { background: #fff5e0; border-color: #f2d59b; color: #6b4a06; }
.alert-info { background: #e8f0fb; border-color: #bcd0ee; color: #1f3d6b; }

/* Buttons */
.btn { display: inline-block; padding: 7px 13px; border-radius: 6px; border: 1px solid #c8d0da; background: #fff; color: var(--text); cursor: pointer; font-size: 14px; line-height: 1.2; text-decoration: none; }
.btn:hover { background: #f1f4f8; text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #e8b4ae; }
.btn-danger:hover { background: #fdecea; }
.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; }
button.mini { border: 1px solid #d0d7e0; background: #fff; border-radius: 3px; font-size: 9px; padding: 1px 4px; cursor: pointer; color: #555; display: block; margin: 1px 0; }
button.mini[disabled] { opacity: .3; }

/* Cards & forms */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 16px 18px; margin-bottom: 16px; }
.card h2:first-child { margin-top: 0; }
.card.narrow { max-width: 640px; }
.form label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
.form label > input, .form label > select, .form label > textarea, .form .input-group { margin-top: 4px; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time], input[type=url], select, textarea {
    width: 100%; padding: 7px 9px; border: 1px solid #c8d0da; border-radius: 6px; font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(43,87,151,.25); border-color: var(--primary); }
input[disabled] { background: #f3f5f8; color: var(--muted); }
input[type=color] { width: 60px; height: 34px; padding: 2px; border: 1px solid #c8d0da; border-radius: 6px; background: #fff; }
input[type=file] { font-size: 13px; }
textarea { resize: vertical; }
textarea.code { font-family: Consolas, Menlo, monospace; font-size: 12.5px; }
.form .hint { display: block; font-weight: normal; color: var(--muted); font-size: 12px; margin-top: 4px; }
.chk-inline, .chk { font-weight: normal !important; display: flex !important; align-items: center; gap: 6px; }
.chk-inline input, .chk input { width: auto; }
.grid-2, .grid-3, .grid-4 { display: grid; gap: 0 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
.input-group { display: flex; gap: 6px; }
.input-group select { flex: 1; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.form-actions.sticky { position: sticky; bottom: 0; background: rgba(243,245,248,.95); padding: 10px 0; border-top: 1px solid var(--border); z-index: 5; }
.form-actions .spacer { flex: 1; }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filters input[type=search] { max-width: 320px; }
.filters select { width: auto; }

/* Tables */
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { background: #f7f9fb; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: #555; }
/* Header sempre visibile scorrendo la pagina (il bordo sotto è un'ombra: con border-collapse il bordo non seguirebbe l'header) */
.table thead th { position: sticky; top: 0; z-index: 2; border-bottom: 0; box-shadow: inset 0 -1px 0 var(--border); }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th.sort-asc::after { content: ' \25B2'; font-size: 9px; }
.table th.sort-desc::after { content: ' \25BC'; font-size: 9px; }
/* Righe alternate: conta solo quelle visibili, così il filtro dal vivo non sfalsa le strisce */
.table tbody tr:nth-child(even of :not([style*="display: none"])) { background: #f6f8fb; }
.table tbody tr:hover { background: #eaf0f8; }
.table tr.inactive td { color: var(--muted); }
.table.small td, .table.small th { padding: 5px 8px; font-size: 13px; }
.table-edit input, .table-edit textarea { padding: 5px 7px; font-size: 13px; }
.table-edit td { padding: 4px 5px; vertical-align: top; }
.table-edit td.drag { width: 26px; padding: 4px 2px; }
.r { text-align: right !important; }
.c { text-align: center !important; }
.nowrap { white-space: nowrap; }
.mono { font-family: Consolas, Menlo, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.text-danger { color: var(--danger); }
.inline { display: inline; }
.tag-auto { background: #fbefd9 !important; color: #7a4d06 !important; }
.tag { display: inline-block; background: #eef1f5; color: #555; font-size: 11px; padding: 1px 6px; border-radius: 10px; margin-left: 4px; vertical-align: middle; }
.w-xs { width: 60px !important; display: inline-block !important; }
.w-s { width: 80px; }
.w-m { width: 110px; }
.w-cod { width: 100px; }
.w-qta { width: 80px; }
.w-un { width: 70px; }
.w-prezzo { width: 110px; }
.w-sc { width: 70px; }
.w-iva { width: 70px; }
.w-tot { width: 110px; }
.riga-titolo td { background: #f4f6fa; }
.riga-titolo input { font-weight: 700; }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; font-weight: 600; vertical-align: middle; }
.badge-bozza { background: #eef1f5; color: #555; }
.badge-inviato { background: #e3edfb; color: #1f4b8f; }
.badge-accettato { background: #e2f4e8; color: #1e6b3a; }
.badge-rifiutato { background: #fbe4e2; color: #8a2a22; }
.badge-scaduto { background: #fbefd9; color: #7a4d06; }
select.badge-select { width: auto; padding: 2px 22px 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; display: flex; flex-direction: column; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--primary); }
.stat .n { font-size: 24px; font-weight: 700; color: var(--primary-dark); }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }

/* Paging */
.paging { display: flex; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.paging a, .paging .current { padding: 4px 9px; border: 1px solid var(--border); border-radius: 4px; background: #fff; }
.paging .current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--muted); }
.tabs a.active { border-color: var(--primary); color: var(--primary-dark); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* Impostazioni: menu delle sezioni a sinistra (su schermo stretto: una riga che scorre) */
.imp { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; align-items: start; }
.imp-nav { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 1px; padding: 8px; margin-bottom: 0; }
.imp-gruppo { font-size: 12px; font-weight: 600; color: var(--muted); padding: 12px 10px 4px; }
.imp-gruppo:first-child { padding-top: 4px; }
.imp-nav a { display: block; padding: 6px 10px; border-radius: 6px; color: var(--text); font-size: 13.5px; }
.imp-nav a:hover { background: #eef2f8; text-decoration: none; }
.imp-nav a.active { background: #e6edf7; color: var(--primary-dark); font-weight: 600; box-shadow: inset 3px 0 0 var(--primary); }
.imp-nav a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
@media (max-width: 900px) {
    .imp { grid-template-columns: 1fr; gap: 0; }
    .imp-nav { position: static; flex-direction: row; overflow-x: auto; gap: 4px; padding: 6px; margin-bottom: 16px; scrollbar-width: thin; }
    .imp-gruppo { display: none; }
    .imp-nav a { white-space: nowrap; flex: none; }
    .imp-nav a.active { box-shadow: inset 0 -2px 0 var(--primary); }
}

/* Preventivo builder */
.righe-toolbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.listino-box { display: flex; gap: 10px; align-items: flex-end; }
.listino-box label { margin-bottom: 0; }
.listino-box select { width: auto; }
.totali-box { display: flex; justify-content: flex-end; margin-top: 14px; }
table.totali td { padding: 5px 10px; }
table.totali tr.tot td { font-weight: 700; font-size: 16px; border-top: 2px solid var(--primary); color: var(--primary-dark); }
table.totali .r { min-width: 130px; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow: auto; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 10px; width: 100%; max-width: 980px; padding: 16px 18px; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-head h2 { margin: 0; }
.picker-results { margin-top: 10px; max-height: 60vh; overflow: auto; }
.picker-filtro { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; cursor: pointer; }
.picker-filtro[hidden] { display: none; }
.picker-filtro input { width: auto; margin: 0; }

/* Template builder */
.tpl-layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.placeholders { list-style: none; padding: 0; margin: 0; }
.placeholders li { padding: 3px 0; border-bottom: 1px dashed #eee; }
.placeholders code { cursor: pointer; }
.placeholders code.copied { background: #c9ecd3; }
.preview-frame { width: 100%; height: 900px; border: 1px solid var(--border); border-radius: 6px; background: #e5e7eb; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; padding: 30px 32px; border-radius: 10px; width: 100%; max-width: 380px; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.login-box h1 { text-align: center; margin-bottom: 20px; color: var(--primary-dark); }
.login-box label { display: block; margin-bottom: 12px; font-weight: 600; font-size: 13px; }
.login-box label input { margin-top: 4px; }

/* Responsive */
@media (max-width: 900px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .tpl-layout { grid-template-columns: 1fr; }
    .table { display: block; overflow-x: auto; }
}
@media (max-width: 700px) {
    .nav-toggle { display: block; }
    .mainnav { display: none; position: absolute; top: 52px; left: 0; right: 0; background: var(--primary-dark); flex-direction: column; align-items: stretch; padding: 8px; z-index: 40; max-height: calc(100vh - 52px); overflow: auto; }
    body.nav-open .mainnav { display: flex; }
    .nav-group-btn { display: none; }
    .nav-menu { display: flex; position: static; background: none; border: 0; box-shadow: none; padding: 0 0 6px; }
    .nav-menu::before { content: attr(data-label); color: #8fa3c4; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 8px 11px 2px; }
    .nav-menu a { color: #d8e1f0; }
    .nav-menu a:hover { background: rgba(255,255,255,.1); }
    .nav-menu a.active { background: rgba(255,255,255,.18); color: #fff; }
    .userbox span { display: none; }
    /* Da telefono: "Esci" dentro il menu ☰, al suo posto nella barra il collegamento ai To-do */
    .userbox .solo-desktop { display: none; }
    .userbox .solo-mobile { display: inline-block; padding: 6px 10px; border-radius: 6px; background: rgba(255,255,255,.15); font-size: 14px; }
    .mainnav .solo-mobile { display: block; }
    .mainnav .nav-esci { margin-top: 6px; border-top: 1px solid rgba(255,255,255,.15); border-radius: 0; padding-top: 12px; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
}

/* Flag rivalsa/bollo nella tabella totali */
table.totali label.chk-inline { margin-bottom: 0; font-weight: normal; }

/* Miniature prodotto */
.thumb-cell { width: 44px; padding: 3px 4px !important; }
img.thumb { width: 38px; height: 38px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 4px; display: block; }
.img-preview img { max-width: 100%; max-height: 120px; border: 1px solid var(--border); border-radius: 6px; background: #fff; margin-top: 22px; }

/* Ordini */
.progress { height: 8px; background: #e5e9f0; border-radius: 4px; overflow: hidden; min-width: 90px; }
.progress .bar { height: 100%; background: var(--success); }
.fatte-cell input[type=text] { width: 80px; display: inline-block; vertical-align: middle; }
.badge-ord-materiale { background: #fbefd9; color: #7a4d06; }
.badge-ord-preparazione { background: #e3edfb; color: #1f4b8f; }
.badge-ord-chiuso { background: #e2f4e8; color: #1e6b3a; }
.badge-ord-annullato { background: #fbe4e2; color: #8a2a22; }
.stepper { list-style: none; display: flex; gap: 8px; padding: 0; margin: 14px 0 0; flex-wrap: wrap; }
.stepper li { flex: 1; min-width: 160px; padding: 8px 12px; border-radius: 6px; background: #f1f4f8; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.stepper li span { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: #d0d7e0; color: #fff; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
.stepper li.done { color: var(--text); }
.stepper li.done span { background: var(--success); }
.stepper li.current { background: #e3edfb; color: var(--primary-dark); font-weight: 600; }
.stepper li.current span { background: var(--primary); }
.card-collapsed { opacity: .85; }
.row-ok td { background: #f0faf3 !important; }
.ok { color: var(--success); font-weight: 700; }
.tag-ok { background: #e2f4e8; color: #1e6b3a; }
.tag-warn { background: #fbefd9; color: #7a4d06; }
.ordinare-box { margin-top: 16px; padding: 12px 14px; border: 1px dashed #c8d0da; border-radius: 8px; background: #fbfcfe; }
.ordinare-box h3 { margin: 0 0 6px; font-size: 15px; color: var(--primary-dark); }
.ordinare-box h4 { margin: 10px 0 4px; font-size: 13px; text-transform: uppercase; color: var(--muted); }
.mov-form select, .mov-form input { display: inline-block; width: auto; }

/* Dettaglio taglie/colori ordine */
.dett-row td { background: #fbfcfe !important; padding: 6px 10px !important; }
.dett-table { border-collapse: collapse; margin: 6px 0; }
.dett-table td { padding: 2px 6px 2px 0; border: 0; }
.dett-table select { width: auto; max-width: 340px; padding: 4px 6px; font-size: 13px; }

/* Ricerca globale */
.topsearch input { width: 170px; padding: 5px 9px; border-radius: 14px; border: 0; font-size: 13px; background: rgba(255,255,255,.15); color: #fff; }
.topsearch input::placeholder { color: #c7d2e3; }
.topsearch input:focus { background: #fff; color: var(--text); outline: 0; width: 240px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0 14px; }
/* Margine */
.margine-box { display: flex; gap: 18px; justify-content: flex-end; align-items: baseline; margin-top: 8px; padding: 8px 12px; background: #f4f9f5; border: 1px dashed #b7dfc2; border-radius: 6px; font-size: 13px; }
.margine-box.neg { background: #fdecea; border-color: #f5c2c0; }
/* Allegati */
.allegati { list-style: none; padding: 0; margin: 0 0 10px; }
.allegati li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px dashed #eee; }
.allegati .file-icon { display: inline-flex; width: 38px; height: 38px; align-items: center; justify-content: center; font-size: 22px; }
.inline-upload { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline-upload input[type=file] { width: auto; }
/* Fatture */
.badge-fat-bozza { background: #eef1f5; color: #555; }
.badge-fat-caricata { background: #e2f4e8; color: #1e6b3a; }
.badge-fe-da_incassare { background: #fbefd9; color: #7a4d06; }
.badge-fe-parziale { background: #e3edfb; color: #1f4b8f; }
.badge-fe-saldata { background: #e2f4e8; color: #1e6b3a; }
.badge-fe-nota { background: #eef1f5; color: #555; }
.badge-fe-scartata { background: #fbe4e2; color: #8a2a22; }
.table tr.selected td { background: #eef4fc; }
.badge-fat-errore { background: #fbe4e2; color: #8a2a22; }
.xml-preview { font-size: 11px; max-height: 420px; overflow: auto; background: #f7f9fb; padding: 10px; border-radius: 6px; }
/* Calendario */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { font-size: 12px; text-transform: uppercase; color: var(--muted); padding: 4px; text-align: center; }
.cal-day { background: #fff; border: 1px solid var(--border); border-radius: 6px; min-height: 92px; padding: 4px; font-size: 12px; }
.cal-day.empty { background: transparent; border: 0; }
.cal-day.weekend { background: #fafbfd; }
.cal-day.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.cal-num { font-weight: 700; color: var(--muted); margin-bottom: 3px; }
.cal-ev { display: block; padding: 3px 5px; border-radius: 4px; margin-bottom: 3px; color: #fff; text-decoration: none; font-size: 11px; line-height: 1.25; }
.cal-ev:hover { text-decoration: none; filter: brightness(.92); }
.cal-ev .pct { float: right; opacity: .85; }
.ev-materiale { background: #c98a1b; } .ev-preparazione { background: #2b5797; } .ev-chiuso { background: #1e8449; } .ev-late { background: #c0392b; }
.legend { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; }
.legend-ord-materiale { background: #c98a1b; } .legend-ord-preparazione { background: #2b5797; } .legend-ord-chiuso { background: #1e8449; } .legend-late { background: #c0392b; }
/* Statistiche */
.chart-row { display: flex; gap: 8px; }
.chart-axis { display: flex; flex-direction: column; justify-content: flex-end; padding-top: 10px; }
.chart-axis .ticks { height: 130px; display: flex; flex-direction: column; justify-content: space-between; align-items: flex-end; }
.chart-axis .ticks span { font-size: 10px; color: var(--muted); white-space: nowrap; }
.chart-axis .spacer { height: 29px; }
.chart { flex: 1; display: flex; align-items: flex-end; gap: 6px; height: 180px; padding: 10px 4px 0; border-bottom: 1px solid var(--border); }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.chart-col .bars { display: flex; align-items: flex-end; gap: 2px; height: 130px; width: 100%; justify-content: center; }
.chart-col .bar-v { width: 40%; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 1px; }
.chart-col .bar-a { width: 40%; background: #c98a1b; border-radius: 3px 3px 0 0; min-height: 1px; }
.chart-col .lbl { font-size: 11px; color: var(--muted); margin-top: 4px; }
.chart-col .val { font-size: 10px; color: var(--text); height: 14px; }
.legend-v { background: var(--primary); } .legend-a { background: #c98a1b; }
@media (max-width: 900px) { .grid-5 { grid-template-columns: repeat(2, 1fr); } .topsearch { display: none; } }

/* Composizione servizi */
#comp .cp-dim span { display: none; white-space: nowrap; }
#comp tr[data-tipo=materiale_area] .d-area, #comp tr[data-tipo=materiale_area] .d-q, #comp tr[data-tipo=materiale_lineare] .d-lin, #comp tr[data-tipo=materiale_lineare] .d-q, #comp tr[data-tipo=materiale_pezzo] .d-q { display: inline; }
#comp tr[data-tipo=macchina] .cp-dim, #comp tr[data-tipo=manodopera] .cp-dim { color: #aaa; }
#comp .cp-dim input.w-s { width: 64px; display: inline-block; }

/* Mercatini: pagina rapida vendite da telefono */
.vendi { max-width: 560px; margin: 0 auto; }
.vendi-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.vendi-tot strong { font-size: 22px; color: var(--primary-dark); }
.vendi-form { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.vendi-form label { display: block; font-weight: 600; margin-bottom: 12px; }
.vendi-form input { margin-top: 4px; font-size: 22px; padding: 12px 14px; }
.vendi-form #importo { font-size: 34px; font-weight: 700; text-align: right; }
.btn-xl { font-size: 20px; padding: 16px; border-radius: 10px; }
.vendi-list { list-style: none; padding: 0; margin: 0; }
.vendi-list li { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; }
.vendi-item { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; color: var(--text); text-decoration: none; padding: 6px 4px; }
.vendi-item:hover { text-decoration: none; }
.vendi-when { color: var(--muted); font-size: 13px; min-width: 42px; text-align: center; }
.vendi-nota { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.vendi-imp { font-weight: 700; font-size: 18px; white-space: nowrap; }
.vendi-list form { margin: 0; }
.vendi-list .btn-sm { padding: 10px 12px; }

/* Guida */
.guida { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
.guida-indice { position: sticky; top: 16px; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; }
.guida-indice strong { margin-bottom: 6px; }
.guida-indice a { color: var(--text); padding: 4px 6px; border-radius: 5px; font-size: 13.5px; }
.guida-indice a:hover { background: #eef2f8; text-decoration: none; }
.guida-testo section { scroll-margin-top: 16px; }
.guida-testo p, .guida-testo li { font-size: 14.5px; line-height: 1.55; max-width: 820px; }
.guida-testo ol, .guida-testo ul { padding-left: 22px; }
.guida-testo li { margin-bottom: 6px; }
.guida-flusso { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 12px 0; }
.guida-flusso div { background: #f3f6fb; border-left: 4px solid var(--primary); border-radius: 6px; padding: 10px 12px; font-size: 13.5px; line-height: 1.45; }
@media (max-width: 900px) { .guida { grid-template-columns: 1fr; } .guida-indice { position: static; } .guida-flusso { grid-template-columns: 1fr 1fr; } }
@media (max-width: 700px) { .guida-flusso { grid-template-columns: 1fr; } }

/* Mercatini: listino rapido a pulsanti e carrello */
.vendi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-bottom: 12px; }
.vendi-btn { background: #f3f6fb; border: 1px solid #c8d0da; border-radius: 10px; padding: 12px 8px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font-family: inherit; min-height: 64px; }
.vendi-btn:active, .vendi-btn.flash { background: var(--primary); color: #fff; }
.vendi-btn .vb-nome { font-weight: 600; font-size: 14px; text-align: center; }
.vendi-btn .vb-prezzo { font-size: 13px; opacity: .8; }
.cart-list { list-style: none; padding: 0; margin: 0 0 10px; border-top: 1px solid var(--border); }
.cart-list li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.cart-list .cl-nome { flex: 1; }
.cart-list .cl-q { white-space: nowrap; }
.cart-list .cl-q .btn { padding: 6px 12px; font-size: 16px; }
.cart-list .cl-tot { min-width: 80px; text-align: right; font-weight: 600; }
.cart-sconto { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.cart-sconto .sc-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.cart-sconto input { width: 80px; font-size: 14px; padding: 6px 8px; }
.cart-tot { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 18px; }
.cart-tot strong { font-size: 28px; color: var(--primary-dark); }
.vendi-libero { margin-top: 12px; }
.vendi-libero input { font-size: 18px; padding: 8px 10px; }
.vendi-libero #importo { font-size: 22px; }

/* Link pubblico preventivo */
.link-box { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.link-box input { flex: 1; font-family: Consolas, Menlo, monospace; font-size: 13px; }

/* Acquisti: creazione rapida prodotto da riga non abbinata */
.crea-prodotto { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crea-prodotto input[type=text] { width: 220px; }
.crea-prodotto select { width: auto; }

/* Crea su WooCommerce */
.wc-suggerito { display: flex; align-items: center; gap: 8px; min-height: 36px; font-size: 16px; }
.wc-radio { display: flex; gap: 24px; margin-bottom: 8px; }
.wc-categorie { max-height: 280px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; padding: 6px; margin: 8px 0 12px; columns: 2; }
.wc-categorie label { margin: 0 0 4px; break-inside: avoid; }
.wc-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.wc-chips .tag { border: 0; cursor: pointer; margin: 0; }
.wc-galleria { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0; }
.wc-galleria figure { margin: 0; width: 150px; }
.wc-galleria img { width: 150px; height: 150px; object-fit: contain; background: #fff; border: 1px solid var(--border); border-radius: 6px; display: block; }
.wc-galleria figcaption { margin-top: 4px; font-size: 12px; }
.wc-anteprima { border: 1px dashed var(--border); border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; background: #fff; }
.wc-riepilogo { display: flex; gap: 14px; align-items: flex-start; }
.wc-riepilogo img { width: 90px; height: 90px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.ai-confronto { border: 2px solid #c9d7ee; background: #f7faff; border-radius: 8px; padding: 12px; margin: 10px 0 14px; }
.ai-confronto-head, .ai-campo-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ai-confronto .spacer { flex: 1; }
.ai-campo { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 10px; margin-top: 10px; }
.ai-campo.ai-deciso { opacity: .55; }
.ai-colonne { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.ai-testo { font-size: 13px; line-height: 1.5; max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 4px; padding: 8px; background: #fff; }
.ai-testo del { background: #fbe4e2; color: #8a2a22; }
.ai-testo ins { background: #e2f4e8; color: #1e6b3a; text-decoration: none; }
.ai-campo details { margin-top: 6px; }
@media (max-width: 700px) { .wc-categorie { columns: 1; } .ai-colonne { grid-template-columns: 1fr; } }

/* Annunci Vinted */
.vt-colori { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 2px 10px; margin-bottom: 8px; }
.vt-colori label { margin: 0; }
.vt-categoria { margin: 4px 0 6px; }
#cat-lista { width: 100%; margin-top: 4px; }

/* To-do */
.todo { max-width: 760px; }
.todo-add { display: flex; gap: 8px; align-items: center; }
.todo-add input[type=text] { flex: 1; min-width: 0; font-size: 16px; padding: 10px 12px; }
.todo-lista { padding: 4px 12px; }
.todo-lista > p { padding: 12px 6px; margin: 0; }
.todo-item { border-bottom: 1px solid var(--border); padding: 4px 0; }
.todo-item:last-child { border-bottom: 0; }
.todo-row { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; }
.todo-check { flex: none; }
.todo-box { width: 40px; height: 40px; margin: -6px -4px -6px -6px; padding: 0; border: 0; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.todo-box::before { content: ""; width: 22px; height: 22px; border: 2px solid #9aa5b1; border-radius: 4px; box-sizing: border-box; }
.todo-row.fatto .todo-box::before { content: "✓"; background: var(--success); border-color: var(--success); color: #fff; font-size: 15px; font-weight: 700; line-height: 18px; text-align: center; }
.todo-main { flex: 1; min-width: 0; padding-top: 2px; }
.todo-titolo { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; font-family: inherit; color: var(--text); font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.todo-row.fatto .todo-titolo { text-decoration: line-through; color: var(--muted); }
.todo-desc { color: var(--muted); font-size: 13px; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.todo-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.todo-scad.oggi { color: var(--warning); font-weight: 600; }
.todo-scad.scaduto { color: var(--danger); font-weight: 600; }
.todo-row.fatto .todo-scad { color: var(--muted); font-weight: normal; }
.todo-sub { margin-left: 34px; }
.todo-item:not(.aperto) .todo-sub { display: none; }
.todo-azioni { flex: none; display: flex; margin: -6px -6px -6px 0; }
.todo-act { width: 38px; height: 38px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.todo-act:hover { background: #eef2f8; color: var(--primary); }
.todo-act svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.todo-espandi svg { transition: transform .15s; }
.todo-item.aperto .todo-espandi svg { transform: rotate(180deg); }
.todo-sub .todo-titolo { font-size: 15px; }
.todo-add-sub { margin: 2px 0 8px; }
.todo-add[hidden] { display: none; }
.todo-add-sub input[type=text] { font-size: 15px; padding: 8px 10px; }
.todo-fatti summary { cursor: pointer; padding: 10px 6px; font-weight: 600; color: var(--muted); }
@media (max-width: 700px) {
    .container:has(.todo) { padding-left: 10px; padding-right: 10px; }
    .todo-sub { margin-left: 26px; }
    .todo-add.card { flex-wrap: wrap; }
    .todo-add.card input[type=text] { flex-basis: 100%; }
}

/* PWA: barra offline / modifiche da inviare */
.crm-barra-offline { position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 100; max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 20px; background: #374151; color: #fff; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.25); text-align: center; }
.crm-barra-offline a { color: #fff; text-decoration: underline; }
.crm-barra-offline[hidden] { display: none; }
.tag-attesa { background: #fff5e0; color: #6b4a06; }

/* Impostazioni > To-do automatici */
#passi .passo { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; max-width: 520px; }
