/* AC Studio – tema scuro: pochi bordi, un solo accento (indaco) */
:root {
	--bg: #0d0f14;
	--surface: #161922;
	--surface-2: #1d212c;      /* campi, hover */
	--text: #e7e9ee;
	--muted: #98a1b0;
	--line: #232836;
	--border: #2e3445;
	--accent: #8b93f8;         /* link e icone */
	--accent-strong: #5b5bd6;  /* pulsanti */
	--accent-dark: #2a2870;    /* timer, stato attivo */
	--accent-soft: rgba(139, 147, 248, 0.14);
	--accent-text: #c7cbff;
	--hero-muted: #b9bdf5;
	--danger: #f87171;
	--ok: #4ade80;
	--radius: 16px;
	color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
	-webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-text); }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin: 0; line-height: 1.2; }
h2 { font-size: 17px; font-weight: 600; margin: 0; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.errore { color: var(--danger); }

/* Struttura pagina */
.page { display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .sopra { color: var(--muted); font-size: 14px; font-weight: 500; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.azioni { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.colonne { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-start; }
.colonne > * { flex: 1 1 360px; min-width: 0; }
.colonne > .larga { flex: 3 1 440px; }
.colonne > .stretta { flex: 2 1 300px; }

/* Pannelli */
.panel { background: var(--surface); border-radius: var(--radius); padding: 20px 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.panel-head a, .panel-head button.link { font-size: 14px; font-weight: 500; }
.vuoto { color: var(--muted); padding: 16px 0 12px; font-size: 14px; }

/* Righe lista */
.row { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: 0; }
.row .main { flex: 1; min-width: 0; }
.row .titolo { font-weight: 600; }
.row .sotto { color: var(--muted); font-size: 14px; }
.row .dx { text-align: right; white-space: nowrap; }
a.row { color: inherit; }
a.row:hover .titolo { color: var(--accent); }

/* KPI */
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.kpi .panel { padding: 20px 22px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; }
.kpi .valore { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; }
.barra { height: 8px; background: var(--surface-2); border-radius: 99px; margin-top: 14px; overflow: hidden; }
.barra > div { height: 100%; background: var(--ok); border-radius: 99px; }

/* Pulsanti */
button, .btn {
	font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
	padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
	background: var(--surface); color: var(--text);
	display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px;
}
button:hover, .btn:hover { border-color: #3d4458; background: var(--surface-2); color: var(--text); }
.primary { background: var(--text); color: var(--bg); border-color: var(--text); }
.primary:hover { background: #ffffff; color: var(--bg); }
.accent { background: var(--accent-strong); color: #fff; border-color: var(--accent-strong); }
.accent:hover { background: #6a6ae6; border-color: #6a6ae6; color: #fff; }
.soft { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.soft:hover { background: rgba(139, 147, 248, 0.22); border-color: transparent; color: #fff; }
.danger { color: var(--danger); }
.ghost { background: none; border-color: transparent; color: var(--muted); padding: 8px; min-height: 36px; }
.ghost:hover { color: var(--text); background: var(--surface-2); border-color: transparent; }
button.link { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.play {
	width: 42px; height: 42px; min-height: 0; padding: 0; border-radius: 999px; flex: none; color: var(--accent);
}
.play:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.play.on { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.add {
	width: 100%; border: 1px dashed #3d4380; color: var(--accent); background: none; margin-top: 8px;
}

/* Form */
label.f { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
.in, label.f input, label.f select, label.f textarea {
	display: block; width: 100%; margin-top: 6px; font: inherit; font-size: 15px; color: var(--text);
	padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.in::placeholder, input::placeholder, textarea::placeholder { color: #6b7385; }
select option { background: var(--surface-2); color: var(--text); }
.in { margin-top: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(139, 147, 248, 0.45); outline-offset: 0; border-color: var(--accent); }
.griglia { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.check input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Pillole di stato */
.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: rgba(152, 161, 176, 0.14); color: #c3c9d4; display: inline-block; }
.pill.aperta, .pill.inviato, .pill.emessa { background: rgba(139, 147, 248, 0.16); color: #c7cbff; }
.pill.preventivata { background: rgba(251, 191, 36, 0.14); color: #fcd34d; }
.pill.in_lavorazione { background: rgba(56, 189, 248, 0.14); color: #7dd3fc; }
.pill.completata, .pill.accettato, .pill.pagata { background: rgba(74, 222, 128, 0.14); color: #86efac; }
.pill.rifiutato { background: rgba(248, 113, 113, 0.14); color: #fca5a5; }
.pill.chiusa { background: rgba(152, 161, 176, 0.12); color: var(--muted); }

/* Filtri a chip */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 7px 14px; border-radius: 99px; font-size: 14px; font-weight: 500; color: var(--text); background: var(--surface); border: 1px solid var(--border); }
.chip:hover { color: var(--text); background: var(--surface-2); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* Tabelle semplici */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 4px; }
td { padding: 10px 4px; border-top: 1px solid var(--line); vertical-align: middle; }
td.dx, th.dx { text-align: right; white-space: nowrap; }
.scroll { overflow-x: auto; }

/* Documento stampabile (preventivo / fattura) */
.foglio {
	background: #fff; border-radius: 6px; padding: 36px; font-size: 13px; line-height: 1.55; color: #1e293b;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
	--muted: #64748b; --line: #e6e8ec; --text: #0f172a; /* il foglio resta "carta": colori chiari */
}
.foglio .testata { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.foglio h3 { font-size: 20px; margin: 28px 0 12px; }
.foglio td { border-top: 0; border-bottom: 1px solid var(--line); padding: 8px 0; vertical-align: top; }
.foglio .totali { margin-left: auto; width: 240px; margin-top: 12px; display: flex; flex-direction: column; gap: 4px; }
.foglio .totali div { display: flex; justify-content: space-between; }
.foglio .totali .tot { font-weight: 700; font-size: 15px; border-top: 1px solid var(--text); padding-top: 6px; margin-top: 4px; }
.foglio .legale { color: var(--muted); font-size: 11px; margin-top: 24px; }

@media print {
	.no-print { display: none !important; }
	body { background: #fff; color: #0f172a; }
	.foglio { box-shadow: none; padding: 0; }
	.colonne > * { flex-basis: 100%; }
}


/* ===== Cornice: menu laterale e barra in basso ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
	width: 240px; flex: none; padding: 24px 16px; display: flex; flex-direction: column; gap: 4px;
	position: sticky; top: 0; height: 100vh;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 12px 24px; font-weight: 700; font-size: 17px; color: var(--text); }
.logo-icona { width: 32px; height: 32px; border-radius: 9px; background: var(--accent-strong); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; letter-spacing: -0.02em; }
.nav { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav:hover { background: var(--surface); color: var(--text); }
.nav.on { background: var(--surface-2); color: var(--text); }
.timer-mini {
	margin-top: 16px; display: flex; gap: 10px; align-items: center; padding: 12px; border-radius: 12px;
	background: var(--accent-dark); color: #fff;
}
.timer-mini:hover { color: #fff; background: #35338a; }
.tm-testo { display: flex; flex-direction: column; font-weight: 600; min-width: 0; }
.tm-testo small { font-weight: 400; color: var(--hero-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.punto { width: 8px; height: 8px; border-radius: 99px; background: var(--ok); flex: none; }
.contenuto { flex: 1; min-width: 0; padding: 32px 40px 64px; max-width: 1180px; }
.timer-top { display: none; }
.tabbar { display: none; }

@media (max-width: 900px) {
	.sidebar { display: none; }
	.contenuto { padding: 20px 16px calc(100px + env(safe-area-inset-bottom)); }
	.timer-top {
		display: flex; align-items: center; gap: 8px; margin: -4px 0 16px; padding: 10px 14px; border-radius: 12px;
		background: var(--accent-dark); color: #fff; font-weight: 600; font-size: 14px;
		white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	}
	.tabbar {
		display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
		background: var(--surface); border-top: 1px solid var(--line);
		padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
	}
	.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 0; }
	.tab.on { color: var(--accent); }
}
@media print {
	.contenuto { padding: 0; max-width: none; }
}


/* ===== Oggi ===== */
.hero {
	background: var(--accent-dark); color: #fff; border-radius: 20px; padding: 26px 30px;
	display: flex; align-items: center; gap: 28px; flex-wrap: wrap;
}
.hero.spento { background: var(--surface); color: var(--text); }
.hero-stato { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--hero-muted); flex-basis: 100%; }
.punto { width: 8px; height: 8px; border-radius: 99px; background: var(--ok); }
.hero-tempo { font-size: 60px; font-weight: 600; letter-spacing: -0.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.spento .hero-tempo { color: #3a4152; }
.hero-info { flex: 1 1 260px; min-width: 0; }
.hero-titolo { font-size: 20px; font-weight: 600; color: inherit; display: block; }
.hero-sotto { color: var(--hero-muted); font-size: 15px; margin-top: 2px; }
.hero-sotto a { color: #fff; text-decoration: underline; text-decoration-color: rgba(255, 255, 255, 0.4); }
.spento .hero-sotto { color: var(--muted); }
.hero-form input {
	margin-top: 14px; width: 100%; max-width: 440px; font: inherit; font-size: 14px; padding: 10px 14px; border-radius: 10px;
	border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.08); color: #fff;
}
.hero-form input::placeholder { color: #9599dd; }
.hero-stop {
	width: 76px; height: 76px; border-radius: 999px; border: 0; background: #fff; color: var(--accent-dark); flex: none; padding: 0;
}
.hero-stop:hover { background: #e0e2ff; color: var(--accent-dark); }
.giorni { display: flex; gap: 6px; align-items: flex-end; height: 32px; margin-top: 12px; }
.g { flex: 1; background: #343a6e; border-radius: 4px; }
.g.oggi { background: var(--accent); }

@media (max-width: 600px) {
	.hero { padding: 22px 20px; gap: 16px; flex-direction: column; align-items: stretch; text-align: center; }
	.hero-stato { justify-content: center; }
	.hero-tempo { font-size: 52px; }
	.hero-form input { max-width: none; }
	.hero-stop { width: 100%; height: 54px; border-radius: 14px; }
}


/* ===== Richieste ===== */
.barra-filtri { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.cerca { flex: 0 1 320px; }
@media (max-width: 600px) {
	.nascondi-mobile { display: none; }
	.cerca { flex-basis: 100%; }
	.chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
	.chip { white-space: nowrap; }
}


/* ===== Richiesta ===== */
.stepper { display: flex; gap: 6px; flex-wrap: wrap; }
.stepper form { flex: 1 1 120px; }
.step {
	width: 100%; justify-content: flex-start; background: var(--surface); border-color: transparent; color: var(--muted);
	font-weight: 500; padding: 10px 12px;
}
.step.fatto { color: var(--text); }
.step.attuale { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; font-weight: 600; }
.pallino {
	width: 22px; height: 22px; border-radius: 99px; background: var(--surface-2); color: var(--muted);
	display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex: none;
}
.fatto .pallino { background: rgba(74, 222, 128, 0.16); color: #86efac; }
.attuale .pallino { background: rgba(255, 255, 255, 0.2); color: #fff; }
.chiuso { opacity: 0.55; }
.nuovo { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 4px; }
.segmented { display: inline-flex; background: var(--bg); border-radius: 10px; padding: 4px; gap: 4px; align-self: flex-start; }
.segmented label { padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented label.on { background: var(--surface-2); color: var(--text); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.riepilogo { margin: 0; display: flex; flex-direction: column; }
.riepilogo div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.riepilogo div:first-child { border-top: 0; }
.riepilogo dt { color: var(--muted); font-size: 14px; }
.riepilogo dd { margin: 0; font-weight: 600; }
@media (max-width: 600px) {
	.stepper { flex-wrap: nowrap; overflow-x: auto; }
	.stepper form { flex: none; }
	.step { white-space: nowrap; }
}


/* ===== Preventivo ===== */
.stato-box { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; }
.chip { min-height: 0; }


/* ===== Lavoro ===== */
.giorno { font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0.04em; margin: 18px 0 2px; text-transform: uppercase; }
.giorno:first-of-type { margin-top: 4px; }
.ses { display: grid; grid-template-columns: 104px minmax(0, 1fr) 80px 36px; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.orari { font-size: 14px; color: var(--muted); }
.dur { text-align: right; font-weight: 600; font-size: 14px; }
.nota-txt { font-size: 15px; }
.nota-in { width: 100%; font: inherit; font-size: 15px; border: 1px solid transparent; background: none; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.nota-in:hover { border-color: var(--border); }
.nota-in:focus { background: var(--surface-2); }
@media (max-width: 600px) {
	.ses { grid-template-columns: 1fr auto 36px; }
	.orari { grid-column: 1 / -1; margin-bottom: -6px; }
}


/* ===== Fatture ===== */
.filtri-barra { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
form.row { border-top: 1px solid var(--line); }
form.row:first-of-type { border-top: 0; }


/* ===== Fattura ===== */
.ico { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; flex: none; }
.arr { width: 88px; padding: 8px; }
.imp { width: 110px; text-align: right; }
form.row { flex-wrap: wrap; }
.acconto { border-top: 1px solid var(--line); padding-top: 16px; margin-top: 8px; }
.problemi { margin: 0; padding-left: 18px; color: var(--danger); font-size: 14px; }
@media (max-width: 600px) {
	form.row .main { flex-basis: calc(100% - 50px); }
	form.row .arr, form.row .imp { flex: 1; width: auto; }
}


/* ===== Clienti ===== */
.iniziale { width: 38px; height: 38px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.row .titolo { color: var(--text); }
.row.sel .titolo { color: var(--accent); }
.solo-mobile { display: none; }
@media (max-width: 900px) {
	.nascondi-mobile { display: none; }
	.solo-mobile { display: inline; }
}


/* ===== Editor righe ===== */
.ln { display: grid; grid-template-columns: minmax(0, 1fr) 76px 104px 96px 36px; gap: 8px; align-items: start; padding: 8px 0; border-top: 1px solid var(--line); }
.testa { border-top: 0; font-size: 12px; font-weight: 600; color: var(--muted); padding-bottom: 2px; }
.dx { text-align: right; }
.tot { font-weight: 600; padding-top: 10px; }
.descr { display: flex; flex-direction: column; gap: 4px; }
.descr textarea { resize: vertical; field-sizing: content; min-height: 42px; }
.tag { align-self: flex-start; font-size: 11px; font-weight: 600; color: var(--accent-text); background: var(--accent-soft); padding: 1px 8px; border-radius: 99px; }
.in:disabled { background: transparent; border-color: transparent; color: var(--text); }
@media (max-width: 600px) {
	.testa { display: none; }
	.ln { grid-template-columns: 1fr 1fr 1fr 36px; }
	.descr { grid-column: 1 / -1; }
	.tot { padding-top: 10px; }
}

/* ===== Aggiunte versione PHP ===== */
.foglio .testata > div:last-child { margin-left: auto; }
textarea:disabled { resize: none; }
.avviso { padding: 12px 16px; border-radius: 12px; margin: 0 0 20px; font-weight: 500; }
.avviso.errore { background: rgba(248, 113, 113, 0.12); color: #fca5a5; }
.avviso.ok { background: rgba(74, 222, 128, 0.12); color: #86efac; }
.row.avvolgi { flex-wrap: wrap; }
.stepper button { flex: 1 1 120px; }
.segmented label:has(input:checked) { background: var(--surface-2); color: var(--text); }
.elenco-clienti .row { color: var(--muted); }
textarea.in { resize: vertical; }
@media (max-width: 600px) {
	.row.avvolgi .main { flex-basis: calc(100% - 50px); }
	.row.avvolgi .arr, .row.avvolgi .imp { flex: 1; width: auto; }
	.stepper button { flex: none; }
}

/* ===== Allegati ===== */
.allegato { border-top: 1px solid var(--line); }
.allegato .row { border-top: 0; }
.panel-head + .row, .panel-head + .allegato, .panel-head + form.row { border-top: 0; }
.ico-file {
	width: 42px; height: 42px; border-radius: 10px; flex: none; object-fit: cover;
	background: var(--surface-2); color: var(--accent-text); display: flex; align-items: center; justify-content: center;
	font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}
.modifica-allegato { padding: 4px 0 16px 56px; }
.carica { margin-top: 12px; }
.zona {
	display: flex; align-items: center; gap: 12px; padding: 16px; border: 1px dashed #3d4380; border-radius: 12px;
	color: var(--accent); cursor: pointer; font-size: 14px;
}
.zona:hover, .zona.sopra { background: var(--accent-soft); border-color: var(--accent); }
.zona strong { color: var(--text); }
input[type=file].in { padding: 8px; }
@media (max-width: 600px) { .modifica-allegato { padding-left: 0; } }
