@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f0;
  --border-strong: #d3dae5;
  --text: #0b1220;
  --text-2: #2f3b4f;
  --muted: #64748b;
  --primary: #1e5eff;
  --primary-600: #1a4fd6;
  --primary-700: #173fae;
  --primary-soft: #e8efff;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --success: #15803d;
  --success-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --violet: #6d28d9;
  --violet-soft: #ede9fe;
  --sidebar: #ffffff;
  --sidebar-text: #3b4758;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 0 rgba(15, 23, 42, 0.02);
  --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, 0.35);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
/* ---------- tema scuro ---------- */
html[data-theme="dark"] {
  --bg: #0d1320;
  --surface: #151d2e;
  --surface-2: #1b2438;
  --border: #243048;
  --border-strong: #2e3c58;
  --text: #e8edf6;
  --text-2: #c3cdde;
  --muted: #8494ab;
  --primary: #4d82ff;
  --primary-600: #3b6ef2;
  --primary-700: #a8c1ff;
  --primary-soft: rgba(77, 130, 255, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.13);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.13);
  --violet: #a78bfa;
  --violet-soft: rgba(167, 139, 250, 0.14);
  --sidebar: #10182a;
  --sidebar-text: #aab6c9;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px -16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
}
html[data-theme="dark"] input, html[data-theme="dark"] select, html[data-theme="dark"] textarea { background: #101828; color: var(--text); }
html[data-theme="dark"] input[readonly] { background: var(--surface-2); }
html[data-theme="dark"] .topbar { background: rgba(13, 19, 32, 0.85); }
html[data-theme="dark"] .btn.danger { background: transparent; border-color: rgba(248, 113, 113, 0.35); }
html[data-theme="dark"] tr.clickable:hover { background: rgba(77, 130, 255, 0.07); }
html[data-theme="dark"] .warning { background: rgba(251, 191, 36, 0.1); border-color: rgba(251, 191, 36, 0.3); color: #fcd34d; }
html[data-theme="dark"] .brand img, html[data-theme="dark"] .print-bar img { filter: invert(1); }
html[data-theme="dark"] .anteprima-wrap { background: #0a0f1a; }
html[data-theme="dark"] .cal .day.out { background: transparent; }
html[data-theme="dark"] .stepper .st .n { background: var(--surface-2); }
html[data-theme="dark"] ::placeholder { color: #5c6b84; }
html[data-theme="dark"] .btn.danger { border-color: rgba(248, 113, 113, 0.35); }
html[data-theme="dark"] .toast { background: #f1f5f9; color: #0f172a; }
html[data-theme="dark"] .toast.err { background: var(--danger); color: #fff; }
html[data-theme="dark"] .toast.ok { background: #14532d; color: #dcfce7; }
html[data-theme="dark"] .kpi:hover { box-shadow: 0 10px 28px -14px rgba(0, 0, 0, 0.6); }
html[data-theme="dark"] .login-card .brand img { filter: invert(1); }
/* il documento di stampa resta sempre "carta" */
.print-doc { background: #fff !important; color: #000 !important; }
.print-doc h1, .print-doc h2, .print-doc h3 { color: #000; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14.5px; -webkit-font-smoothing: antialiased; }
a { color: var(--primary-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; font-weight: 700; letter-spacing: -0.015em; color: var(--text); }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; }
p { margin: .25rem 0; }
code { background: var(--surface-2); border: 1px solid var(--border); padding: .05rem .35rem; border-radius: 5px; font-size: .85em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.flex { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--border); color: var(--sidebar-text); padding: 1.1rem .9rem 1rem; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; justify-content: center; padding: .4rem .5rem 1.3rem; border-bottom: 1px solid var(--border); margin-bottom: .9rem; }
.brand img { height: 44px; }
.nav a { display: flex; align-items: center; gap: .65rem; padding: .55rem .75rem; margin-bottom: 2px; border-radius: 8px; color: var(--sidebar-text); font-weight: 500; font-size: .9rem; transition: background .12s, color .12s; }
.nav a .ico { width: 20px; text-align: center; display: inline-flex; justify-content: center; color: var(--muted); }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-700); font-weight: 600; }
.nav a.active .ico { color: var(--primary); }
.nav .sep { margin: 1rem .75rem .35rem; font-size: .66rem; text-transform: uppercase; letter-spacing: .1em; color: #94a3b8; font-weight: 700; }
.sidebar .user { margin-top: auto; padding: .9rem .5rem 0; border-top: 1px solid var(--border); font-size: .84rem; display: grid; grid-template-columns: 36px 1fr; gap: .6rem; align-items: center; }
.sidebar .user .avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-700); display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.sidebar .user b { color: var(--text); display: block; font-weight: 600; line-height: 1.2; }
.sidebar .user .links { grid-column: 2; }
.sidebar .user a { color: var(--muted); }
.sidebar .user a:hover { color: var(--text); }
.main { padding: 0 0 3rem; width: 100%; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .85rem 2rem; margin-bottom: 1.4rem; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 1.2rem; }
.topbar .crumb { font-size: .78rem; color: var(--muted); margin-bottom: .1rem; }
#page { padding: 0 2rem; max-width: 1320px; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.2rem 1.35rem; }
.card + .card { margin-top: 1rem; }
.card > h2, .card > .flex.between > h2 { margin-bottom: .9rem; padding-bottom: .65rem; border-bottom: 1px solid var(--border); font-size: .95rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); }
.card > h2 .badge { text-transform: none; letter-spacing: 0; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.2rem; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--primary); }
.kpi.green::before { background: var(--success); }
.kpi.amber::before { background: var(--warn); }
.kpi.violet::before { background: var(--violet); }
.kpi .label { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi .value { font-size: 1.6rem; font-weight: 800; margin-top: .2rem; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: .8rem; color: var(--muted); margin-top: .15rem; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); padding: .5rem .95rem; border-radius: var(--radius-sm); font-size: .88rem; font-weight: 600; cursor: pointer; transition: background .12s, border-color .12s, box-shadow .12s, transform .05s; white-space: nowrap; line-height: 1.2; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); border-color: var(--primary-600); }
.btn.danger { color: var(--danger); border-color: var(--danger-soft); background: var(--surface); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: .32rem .65rem; font-size: .78rem; border-radius: 7px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.menu-btn { display: none; }
.theme-toggle { width: 38px; height: 38px; padding: 0; justify-content: center; border-radius: 50%; font-size: 1.05rem; }
.card { transition: box-shadow .15s, border-color .15s; }
.kpi { transition: transform .12s, box-shadow .15s; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 10px 28px -14px rgba(15, 23, 42, 0.25); }
.btn.primary { background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%); }


/* ---------- forms ---------- */
label { display: block; font-size: .76rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; letter-spacing: .01em; }
input, select, textarea { width: 100%; border: 1px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-sm); padding: .55rem .7rem; font: inherit; color: var(--text); transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7a90' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem; }
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
.field { margin-bottom: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .85rem 1rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.checkbox { display: flex; align-items: center; gap: .5rem; font-weight: 500; color: var(--text); }
.checkbox input { width: auto; }
.inline-search { max-width: 340px; }
form.card h2, .card > h2 { display: flex; align-items: center; gap: .5rem; }

/* ---------- wizard / stepper ---------- */
.stepper { display: flex; gap: .25rem; margin-bottom: 1.2rem; overflow-x: auto; padding-bottom: .25rem; }
.stepper .st { flex: 1; min-width: 110px; display: flex; align-items: center; gap: .5rem; padding: .5rem .65rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .76rem; line-height: 1.15; font-weight: 600; cursor: pointer; transition: all .12s; }
.stepper .st .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); font-size: .75rem; font-weight: 700; flex: none; }
.stepper .st.active { border-color: var(--primary); color: var(--primary-700); background: var(--primary-soft); }
.stepper .st.active .n { background: var(--primary); color: #fff; }
.stepper .st.done { color: var(--text-2); }
.stepper .st.done .n { background: var(--success-soft); color: var(--success); }
.stepper .st.done .n::before { content: '✓'; }
.stepper .st.done .n span { display: none; }
.wizard .step { display: none; }
.wizard .step.active { display: block; animation: fade .18s ease; }
.wizard .step-title { font-size: 1.05rem; font-weight: 700; margin-bottom: .25rem; }
.wizard .step-hint { color: var(--muted); font-size: .85rem; margin-bottom: 1rem; }
.wizard-nav { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.modal .wizard-nav { margin-top: 0; padding-top: 0; border: 0; }
.riepilogo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.riepilogo-grid .blk { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .8rem .9rem; }
.riepilogo-grid .blk h4 { margin: 0 0 .4rem; font-size: .72rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.riepilogo-grid .blk div { font-size: .88rem; padding: .12rem 0; }
.riepilogo-grid .blk div b { font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -.4rem; padding: 0 .4rem; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .69rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; background: var(--surface-2); border-bottom: 1px solid var(--border-strong); }
thead th:first-child { border-radius: 6px 0 0 0; } thead th:last-child { border-radius: 0 6px 0 0; }
tbody tr:last-child td { border-bottom: 0; }
tfoot th { text-transform: none; font-size: .85rem; color: var(--text); letter-spacing: 0; border-top: 1px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }
tr.clickable { cursor: pointer; transition: background .1s; }
tr.clickable:hover { background: var(--primary-soft); }
td.actions { white-space: nowrap; text-align: right; }
td b { font-weight: 600; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }
.empty .big { font-size: 2rem; margin-bottom: .4rem; opacity: .5; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap; letter-spacing: .01em; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.bozza { background: var(--surface-2); color: var(--muted); }
.badge.confermato { background: var(--primary-soft); color: var(--primary-700); }
.badge.saldato { background: var(--success-soft); color: var(--success); }
.badge.concluso { background: var(--violet-soft); color: var(--violet); }
.badge.annullato { background: var(--danger-soft); color: var(--danger); }
.badge.admin { background: var(--warn-soft); color: var(--warn); }
.badge.collaboratore { background: var(--primary-soft); color: var(--primary-700); }
.badge.off { background: var(--surface-2); color: var(--muted); }
.badge.admin::before, .badge.collaboratore::before, .badge.off::before { display: none; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1000px 600px at 85% -10%, #1e5eff 0%, transparent 60%), radial-gradient(800px 500px at -10% 110%, #173fae 0%, transparent 55%), #0b1220; padding: 1rem; }
.login-card { background: var(--surface); color: var(--text); border-radius: 18px; padding: 2.25rem 2rem; width: 100%; max-width: 390px; box-shadow: var(--shadow-lg); }
.login-card .brand { padding: 0 0 .8rem; }
.login-card .brand img { height: 72px; }
.error { color: var(--danger); background: var(--danger-soft); padding: .55rem .75rem; border-radius: var(--radius-sm); font-size: .85rem; margin: .5rem 0; }
.warning { color: #92400e; background: var(--warn-soft); padding: .6rem .8rem; border-radius: var(--radius-sm); font-size: .85rem; margin: .25rem 0; border: 1px solid #fde68a; }

/* ---------- toast ---------- */
#toast { position: fixed; bottom: 1.25rem; right: 1.25rem; display: flex; flex-direction: column; gap: .5rem; z-index: 1000; }
.toast { background: #0f172a; color: #fff; padding: .7rem 1.05rem; border-radius: 10px; font-size: .88rem; font-weight: 500; box-shadow: var(--shadow-lg); animation: fade .2s ease; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11,22,38,.5); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 900; padding: 1rem; animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: 16px; max-width: 720px; width: 100%; max-height: 92vh; overflow: auto; box-shadow: var(--shadow-lg); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.3rem; border-bottom: 1px solid var(--border); }
.modal header h2 { margin: 0; }
.modal .body { padding: 1.3rem; }
.modal footer { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.3rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.modal.wide { max-width: 960px; }

/* ---------- calendar ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: center; padding: .3rem 0 .5rem; font-weight: 600; }
.cal .day { min-height: 100px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: .35rem .45rem; font-size: .8rem; box-shadow: var(--shadow); }
.cal .day.out { background: transparent; border-color: transparent; box-shadow: none; }
.cal .day.today { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.cal .day.today .num { color: var(--primary-600); }
.cal .day .num { font-weight: 600; color: var(--muted); margin-bottom: .25rem; font-size: .78rem; }
.cal .ev { display: block; padding: .2rem .45rem; border-radius: 6px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .74rem; font-weight: 500; cursor: pointer; color: #fff; background: var(--primary); }
.cal .ev:hover { text-decoration: none; filter: brightness(1.08); }
.cal .ev.bozza { background: #94a3b8; }
.cal .ev.saldato { background: var(--success); }
.cal .ev.concluso { background: #7c3aed; }
.cal .ev.annullato { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }

/* ---------- mini bar chart ---------- */
.bars { display: flex; align-items: flex-end; justify-content: center; gap: 10px; height: 130px; padding-top: .5rem; }
.bars .bar { flex: 1; background: linear-gradient(180deg, var(--primary) 0%, var(--primary-600) 100%); border-radius: 6px 6px 2px 2px; position: relative; min-width: 14px; max-width: 64px; transition: filter .1s; }
.bars .bar:hover { filter: brightness(1.1); }
.bars .bar span { position: absolute; bottom: -1.35rem; left: 0; right: 0; text-align: center; font-size: .66rem; color: var(--muted); font-weight: 600; }
.bars .bar:hover::after { content: attr(data-label); position: absolute; top: -1.7rem; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; font-size: .7rem; padding: .2rem .45rem; border-radius: 5px; white-space: nowrap; }

/* ---------- detail ---------- */
.dl { display: grid; grid-template-columns: 160px 1fr; gap: .45rem 1rem; font-size: .9rem; }
.dl dt { color: var(--muted); font-size: .82rem; padding-top: .1rem; }
.dl dd { margin: 0; color: var(--text); }
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, #22c55e, var(--success)); transition: width .3s; }

/* ---------- print ---------- */
.print-doc { background: #fff; color: #000; font-family: Georgia, "Times New Roman", serif; font-size: 12.5pt; line-height: 1.45; max-width: 800px; margin: 0 auto; padding: 2rem; }
.print-doc h1 { font-size: 1.4rem; text-align: center; margin-bottom: 1.2rem; color: #000; }
.print-doc h3 { color: #000; }
.print-doc .head { display: flex; justify-content: space-between; margin-bottom: 1.2rem; font-size: .95em; }
.print-doc table.k { width: 100%; border-collapse: collapse; margin: .75rem 0 1rem; font-size: .95em; }
.print-doc table.k td { border: 1px solid #999; padding: .3rem .5rem; }
.print-doc table.k td:first-child { width: 35%; background: #f2f2f2; }
.print-doc .cond { white-space: pre-wrap; font-size: .9em; }
.print-doc .firme { display: flex; justify-content: space-between; margin-top: 3rem; }
.print-doc .firme div { width: 45%; border-top: 1px solid #000; padding-top: .3rem; text-align: center; font-size: .9em; }
.print-doc.contratto { font-size: 10.5pt; line-height: 1.4; max-width: 860px; }
.print-doc.contratto h1 { font-size: 1.25rem; margin: .5rem 0 .25rem; line-height: 1.25; }
.print-doc.contratto h3 { font-size: 1em; margin: 1rem 0 .3rem; border-bottom: 1px solid #bbb; padding-bottom: .15rem; }
.print-doc.contratto p { margin: .3rem 0; text-align: justify; }
.print-doc.contratto ol { margin: .3rem 0; padding-left: 1.4rem; }
.print-doc.contratto ol li { margin-bottom: .2rem; text-align: justify; }
.print-doc.contratto .blank { display: inline-block; min-width: 110px; border-bottom: 1px solid #000; }
.print-doc.contratto .chk { font-size: 1.15em; margin-right: .2rem; }
.print-doc.contratto .opts { margin: .3rem 0 .5rem 1rem; }
.print-doc.contratto .opts > div { margin: .25rem 0; }
.print-doc.contratto table.k { margin: .4rem 0 .5rem; }
.print-doc.contratto table.k td:first-child { width: 32%; }
.print-doc.contratto .box { border: 1px solid #999; min-height: 60px; padding: .4rem .6rem; }
.print-doc.contratto .firme { margin-top: 1.5rem; }
.print-doc.contratto .firme div:empty { border: 0; }
.print-doc.contratto .foot { margin-top: 2rem; border-top: 1px solid #bbb; padding-top: .3rem; }
@media print {
  .sidebar, .topbar, #toast { display: none !important; }
  body, html { background: #fff; }
  .print-doc { padding: 0; max-width: none; border: 0; box-shadow: none; }
  .print-doc.contratto { font-size: 9.5pt; }
  .print-doc.contratto h3 { page-break-after: avoid; }
  .print-doc.contratto table, .print-doc.contratto .opts, .print-doc.contratto .firme { page-break-inside: avoid; }
  .layout { display: block; }
  .main { padding: 0; max-width: none; }
  #page { padding: 0; max-width: none; }
  @page { margin: 15mm 14mm; }
}

/* ---------- anteprima contratto nel wizard ---------- */
.anteprima-wrap { border: 1px dashed var(--border-strong); border-radius: 12px; padding: .5rem; background: #eef1f6; }
.anteprima-wrap .print-doc { box-shadow: var(--shadow); }
@media print {
  body:has(.anteprima-wrap) #app > * { visibility: hidden; }
  body:has(.anteprima-wrap) .anteprima-wrap, body:has(.anteprima-wrap) .anteprima-wrap * { visibility: visible; }
  body:has(.anteprima-wrap) .anteprima-wrap { position: absolute; left: 0; top: 0; width: 100%; border: 0; padding: 0; background: #fff; }
}

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -270px; width: 250px; z-index: 500; transition: left .2s; height: 100vh; }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: .7rem 1rem; }
  #page { padding: 0 1rem; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; }
  .dl { grid-template-columns: 1fr; }
  .cal .day { min-height: 60px; }
}
@media (max-width: 560px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}
