/* WP ERP Open Cloud – app gestionale.
 * Linguaggio visivo della modulistica fiscale italiana: carta verde chiara, inchiostro,
 * blu carta carbone per le azioni, rosso timbro solo per errori ed eliminazioni.
 * Font di sistema: nessuna richiesta a server esterni.
 */

/* Tutto è confinato in .erp-root: l'app può stare dentro una pagina del tema
 * (shortcode [erp_app]) senza cambiare il resto del sito, e il prefisso dà ai
 * selettori abbastanza peso da non farsi sovrascrivere dagli stili del tema. */
.erp-root {
	--paper: #eef2ec;
	--paper-deep: #e1e9e2;
	--sheet: #fbfcfa;
	--ink: #1d2622;
	--ink-2: #56635c;
	--ink-3: #7d8a83;
	--rule: #b9c8bd;
	--rule-soft: #d8e2da;
	--carbon: #23408e;
	--carbon-deep: #1a3170;
	--carbon-soft: #e3e9f6;
	--stamp: #b3261e;
	--stamp-soft: #f7e4e2;
	--good: #2f6b3f;
	--good-soft: #e1efe4;

	--sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;

	--side: 248px;
	--radius: 6px;
	--focus: 0 0 0 3px rgba(35, 64, 142, .32);
}

.erp-root {
	color: var(--ink);
	font: 15px/1.5 var(--sans);
	font-variant-numeric: tabular-nums;
	-webkit-font-smoothing: antialiased;
	text-align: left;
}
.erp-root, .erp-root *, .erp-root *::before, .erp-root *::after { box-sizing: border-box; }

/* Pagina dedicata /erp */
body.erp-standalone { margin: 0; background: #eef2ec; -webkit-text-size-adjust: 100%; }
body.erp-locked { overflow: hidden; }

.erp-root :is(h1, h2, h3, p) { margin: 0; padding: 0; border: 0; background: none; font-family: inherit; color: inherit; text-transform: none; letter-spacing: normal; }
.erp-root ul, .erp-root ol { margin: 0; }
.erp-root a { color: var(--carbon); }
.erp-root :is(button, input, select, textarea) { font: inherit; color: inherit; letter-spacing: normal; text-transform: none; box-shadow: none; margin: 0; }
.erp-root :focus-visible { outline: none; box-shadow: var(--focus); }

.erp-root .erp-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.erp-root .erp-boot { padding: 48px 24px; color: var(--ink-2); text-align: center; }
.erp-root .erp-muted { color: var(--ink-2); }
.erp-root .erp-pad { padding: 24px; }

.erp-root .erp-skip { position: absolute; left: 12px; top: -48px; z-index: 50; background: var(--carbon); color: #fff; padding: 8px 12px; border-radius: var(--radius); }
.erp-root .erp-skip:focus { top: 12px; }

/* ------------------------------------------------------------------
 * Guscio: menu laterale + contenuto
 * ------------------------------------------------------------------ */

.erp-root .erp-shell { min-height: 100vh; display: grid; grid-template-columns: var(--side) minmax(0, 1fr); }
.erp-root .erp-topbar { display: none; }

.erp-root .erp-side {
	position: sticky; top: 0; height: 100vh;
	display: flex; flex-direction: column;
	background: var(--paper-deep);
	/* Doppia riga di margine, come sul bordo di un registro */
	border-right: 1px solid var(--rule);
	box-shadow: inset -4px 0 0 var(--paper-deep), inset -5px 0 0 var(--rule);
	padding: 20px 20px 16px 16px;
}

.erp-root .erp-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; letter-spacing: -.005em; padding: 0 8px 18px; }
.erp-root .erp-mark {
	width: 28px; height: 16px; flex: none;
	border: 1.5px solid var(--ink);
	border-radius: 2px;
	background: linear-gradient(90deg, transparent 0 8px, var(--ink) 8px 9.5px, transparent 9.5px 17px, var(--ink) 17px 18.5px, transparent 18.5px);
}

.erp-root .erp-company { display: block; margin: 0 0 18px; }
.erp-root .erp-company select {
	width: 100%; padding: 9px 30px 9px 10px; border: 1px solid var(--rule); border-radius: var(--radius);
	background: var(--sheet) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2356635c' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center;
	appearance: none; font-weight: 600;
}
.erp-root .erp-company.is-single { padding: 10px 10px; border-radius: var(--radius); background: var(--sheet); border: 1px solid var(--rule-soft); }
.erp-root .erp-company.is-single strong { display: block; font-size: 14px; line-height: 1.3; }
.erp-root .erp-company.is-single small { display: block; color: var(--ink-2); font-size: 12.5px; margin-top: 2px; font-family: var(--mono); letter-spacing: .02em; }

.erp-root .erp-side nav ul { list-style: none; margin: 0; padding: 0; }
.erp-root .erp-nav-link {
	display: block; padding: 8px 10px; margin-bottom: 2px;
	color: var(--ink); text-decoration: none; border-radius: var(--radius);
}
.erp-root .erp-nav-link:hover { background: rgba(255, 255, 255, .55); }
.erp-root .erp-nav-link.is-on { background: var(--sheet); color: var(--carbon); font-weight: 600; box-shadow: inset 3px 0 0 var(--carbon); }

.erp-root .erp-side-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--rule); display: grid; gap: 4px; font-size: 13px; }
.erp-root .erp-side-foot > span:first-child { font-weight: 600; }
.erp-root .erp-side-links { display: flex; gap: 14px; }
.erp-root .erp-side-foot small { color: var(--ink-3); font-size: 12px; }

.erp-root .erp-main { padding: 32px clamp(20px, 4vw, 48px) 64px; max-width: 1180px; outline: none; }

/* ------------------------------------------------------------------
 * Intestazioni di pagina
 * ------------------------------------------------------------------ */

.erp-root .erp-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.erp-root .erp-page-head h1 { font-size: 26px; line-height: 1.2; font-weight: 650; letter-spacing: -.015em; }
.erp-root .erp-count { color: var(--ink-2); margin-top: 4px; font-size: 14px; }
.erp-root .erp-greet { color: var(--ink-2); font-size: 15px; margin-bottom: 2px; }
.erp-root .erp-page-head.is-overview h1 { font-size: 32px; }

/* ------------------------------------------------------------------
 * Pulsanti
 * ------------------------------------------------------------------ */

.erp-root .erp-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 38px; padding: 0 16px; border-radius: var(--radius);
	border: 1px solid transparent; background: none; cursor: pointer;
	font-weight: 600; font-size: 14.5px; white-space: nowrap;
	transition: background-color .12s, border-color .12s, color .12s;
}
.erp-root a.erp-btn { text-decoration: none; }
.erp-root .erp-btn:disabled { opacity: .55; cursor: not-allowed; }
.erp-root .erp-btn.is-primary { background: var(--carbon); color: #fff; }
.erp-root .erp-btn.is-primary:not(:disabled):hover { background: var(--carbon-deep); }
.erp-root .erp-btn.is-plain { border-color: var(--rule); background: var(--sheet); color: var(--ink); }
.erp-root .erp-btn.is-plain:not(:disabled):hover { border-color: var(--ink-3); }
.erp-root .erp-btn.is-danger { background: var(--stamp); color: #fff; }
.erp-root .erp-btn.is-danger-text { color: var(--stamp); border-color: transparent; background: none; padding: 0 8px; }
.erp-root .erp-btn.is-danger-text:hover { background: var(--stamp-soft); }

.erp-root .erp-icon-btn { width: 36px; height: 36px; border: 0; background: none; border-radius: var(--radius); font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-2); }
.erp-root .erp-icon-btn:hover { background: var(--paper-deep); color: var(--ink); }

/* ------------------------------------------------------------------
 * Barra strumenti: schede e ricerca
 * ------------------------------------------------------------------ */

.erp-root .erp-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.erp-root .erp-tabs { display: inline-flex; border-bottom: 1px solid var(--rule); }
.erp-root .erp-tab {
	border: 0; background: none; cursor: pointer; padding: 8px 14px; margin-bottom: -1px;
	color: var(--ink-2); border-bottom: 2px solid transparent; font-weight: 500;
}
.erp-root .erp-tab:hover { color: var(--ink); }
.erp-root .erp-tab.is-on { color: var(--carbon); border-bottom-color: var(--carbon); font-weight: 600; }

.erp-root .erp-search { position: relative; flex: 1; min-width: 220px; max-width: 460px; margin-left: auto; }
.erp-root .erp-search input {
	width: 100%; height: 38px; padding: 0 36px 0 12px;
	border: 1px solid var(--rule); border-radius: var(--radius); background: var(--sheet);
}
.erp-root .erp-search input::placeholder { color: var(--ink-3); }
.erp-root .erp-search input:focus { border-color: var(--carbon); }
.erp-root .erp-search kbd {
	position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
	font: 12px var(--mono); color: var(--ink-3); border: 1px solid var(--rule); border-radius: 4px; padding: 0 5px;
}
.erp-root .erp-search input:focus + kbd { display: none; }

/* ------------------------------------------------------------------
 * Tabella
 * ------------------------------------------------------------------ */

.erp-root .erp-table-wrap { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); overflow-x: auto; transition: opacity .15s; }
.erp-root .erp-table-wrap.is-loading { opacity: .55; }
.erp-root .erp-table { width: 100%; border-collapse: collapse; }
.erp-root .erp-table th {
	text-align: left; font-size: 13px; font-weight: 600; color: var(--ink-2);
	padding: 10px 14px; border-bottom: 1px solid var(--rule); background: var(--paper);
	white-space: nowrap;
}
.erp-root .erp-table td { padding: 11px 14px; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
.erp-root .erp-table tbody tr { cursor: pointer; }
.erp-root .erp-table tbody tr:last-child td { border-bottom: 0; }
.erp-root .erp-table tbody tr:hover td { background: var(--carbon-soft); }
.erp-root .erp-table tbody tr:focus-visible { box-shadow: none; }
.erp-root .erp-table tbody tr:focus-visible td { background: var(--carbon-soft); }
.erp-root .erp-table tbody tr:focus-visible td:first-child { box-shadow: inset 3px 0 0 var(--carbon); }
.erp-root .erp-table .is-num { text-align: right; white-space: nowrap; }
.erp-root .erp-table td.is-primary { min-width: 200px; }

.erp-root .erp-cell-main { font-weight: 600; }
.erp-root .erp-cell-sub { display: block; color: var(--ink-2); font-size: 13px; margin-top: 1px; }
.erp-root .erp-table td.erp-fiscal, .erp-root .erp-table td.erp-code { font-family: var(--mono); font-size: 13.5px; letter-spacing: .04em; white-space: nowrap; }
.erp-root .erp-rate { font-weight: 650; font-size: 16px; }

.erp-root .erp-tag {
	display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 3px;
	font-size: 12px; font-weight: 600; vertical-align: 1px;
	border: 1px solid var(--carbon); color: var(--carbon);
}
.erp-root .erp-tag.is-ink { background: var(--carbon); color: #fff; }
.erp-root .erp-tag.is-muted { border-color: var(--rule); color: var(--ink-2); }

.erp-root .erp-state {
	background: var(--sheet); border: 1px dashed var(--rule); border-radius: var(--radius);
	padding: 48px 24px; text-align: center; display: grid; gap: 16px; justify-items: center;
}
.erp-root .erp-state p { max-width: 46ch; color: var(--ink-2); }
.erp-root .erp-state.is-error { border-style: solid; border-color: var(--stamp); }
.erp-root .erp-state.is-error p { color: var(--stamp); }

.erp-root .erp-pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 14px; color: var(--ink-2); font-size: 14px; }

/* ------------------------------------------------------------------
 * Pannello laterale
 * ------------------------------------------------------------------ */

.erp-root .erp-drawer-layer { position: fixed; inset: 0; z-index: 30; display: flex; justify-content: flex-end; }
.erp-root .erp-scrim { position: absolute; inset: 0; background: rgba(29, 38, 34, .32); }
.erp-root .erp-drawer {
	position: relative; width: min(560px, 100%); height: 100%;
	display: flex; flex-direction: column; background: var(--sheet);
	box-shadow: -8px 0 32px rgba(29, 38, 34, .18);
	animation: erp-slide .2s ease-out;
}
@keyframes erp-slide { from { transform: translateX(32px); opacity: 0; } to { transform: none; opacity: 1; } }

.erp-root .erp-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 24px 16px; border-bottom: 1px solid var(--rule); }
.erp-root .erp-drawer-kicker { color: var(--ink-2); font-size: 13px; }
.erp-root .erp-drawer-head h2 { font-size: 20px; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; overflow-wrap: anywhere; }
.erp-root .erp-drawer-body { flex: 1; overflow-y: auto; padding: 8px 24px 24px; }
.erp-root .erp-drawer-foot {
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	padding: 14px 24px; border-top: 1px solid var(--rule); background: var(--paper);
}
.erp-root .erp-foot-actions { display: flex; gap: 8px; }
.erp-root .erp-confirm { display: flex; align-items: center; gap: 8px; color: var(--stamp); font-weight: 600; font-size: 14px; }

.erp-root .erp-alert { margin: 16px 0 0; padding: 10px 12px; border-left: 3px solid var(--stamp); background: var(--stamp-soft); color: var(--stamp); font-weight: 600; font-size: 14px; border-radius: 0 var(--radius) var(--radius) 0; }
.erp-root .erp-note { margin: 16px 0 0; padding: 10px 12px; background: var(--paper); border-radius: var(--radius); color: var(--ink-2); font-size: 14px; }

/* ------------------------------------------------------------------
 * Moduli
 * ------------------------------------------------------------------ */

.erp-root .erp-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.erp-root .erp-group { padding-top: 20px; }
.erp-root .erp-group + .erp-group { margin-top: 8px; border-top: 1px solid var(--rule-soft); }
.erp-root .erp-group h3 { font-size: 14px; font-weight: 650; color: var(--ink); margin-bottom: 12px; }
.erp-root .erp-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.erp-root .erp-grid > * { grid-column: 1 / -1; }
.erp-root .erp-grid > .is-half { grid-column: auto; }

.erp-root .erp-field { display: grid; gap: 5px; align-content: start; min-width: 0; }
.erp-root .erp-label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.erp-root .erp-req { color: var(--stamp); }

.erp-root .erp-input {
	width: 100%; min-height: 38px; padding: 7px 10px;
	border: 1px solid var(--rule); border-radius: var(--radius); background: #fff;
}
.erp-root .erp-input:focus { border-color: var(--carbon); }
.erp-root .erp-input.is-narrow { max-width: 140px; }
.erp-root .erp-input.is-num { text-align: right; max-width: 180px; }
.erp-root textarea.erp-input { resize: vertical; min-height: 76px; }
.erp-root select.erp-input {
	appearance: none; padding-right: 30px;
	background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2356635c' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 11px center;
}
.erp-root .has-error .erp-input { border-color: var(--stamp); }

.erp-root .erp-help { font-size: 13px; color: var(--ink-2); line-height: 1.4; }
.erp-root .erp-help.is-bad { color: var(--stamp); font-weight: 600; }
.erp-root .erp-help.is-good { color: var(--good); font-weight: 600; }
.erp-root .erp-help.is-good::before { content: "✓ "; }

/* Caselle dei codici fiscali, come su F24 e 730: un carattere per casella.
 * Il riquadro esterno taglia lo spazio dopo l'ultima lettera, così il campo non scorre. */
.erp-root .erp-comb-box {
	--cell: 1.9ch;
	display: block;
	width: calc(var(--cells) * var(--cell) + 2px);
	max-width: 100%;
	overflow: hidden;
	/* clip, non hidden: impedisce al browser di far scorrere il riquadro quando il cursore arriva in fondo */
	overflow: clip;
	border: 1px solid var(--ink-3);
	border-radius: 3px;
	background: #fff;
	font: 600 clamp(12px, calc((100vw - 56px) / (var(--cells) * 1.18)), 17px) / 40px var(--mono);
}
.erp-root .erp-comb-box:focus-within { border-color: var(--carbon); box-shadow: var(--focus); }
.erp-root .erp-comb-box.is-good { border-color: var(--good); }
.erp-root .erp-comb-box.is-bad { border-color: var(--stamp); background: #fffafa; }
.erp-root .erp-comb {
	display: block;
	width: calc(var(--cells) * var(--cell) + 2ch);
	height: 40px;
	margin: 0;
	padding: 0 0 0 .45ch;
	border: 0;
	font: inherit;
	letter-spacing: .9ch;
	text-transform: uppercase;
	color: var(--ink);
	background-color: transparent;
	background-image: repeating-linear-gradient(90deg, transparent 0 calc(var(--cell) - 1px), var(--rule) calc(var(--cell) - 1px) var(--cell));
	background-size: calc((var(--cells) - 1) * var(--cell)) 100%;
	background-repeat: no-repeat;
	/* Le righe partono dal bordo, non dal padding: ogni carattere resta al centro della sua casella. */
	background-origin: border-box;
	caret-color: var(--carbon);
}
.erp-root .erp-comb:focus { box-shadow: none; outline: none; }

.erp-root .erp-segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; padding: 2px; gap: 2px; justify-self: start; }
.erp-root .erp-segment { border: 0; background: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; color: var(--ink-2); font-weight: 500; font-size: 14px; }
.erp-root .erp-segment:hover { color: var(--ink); }
.erp-root .erp-segment.is-on { background: var(--carbon); color: #fff; font-weight: 600; }

.erp-root .erp-toggle { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; position: relative; }
.erp-root .erp-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.erp-root .erp-toggle-track { flex: none; width: 36px; height: 20px; margin-top: 1px; border-radius: 10px; background: var(--rule); position: relative; transition: background-color .15s; }
.erp-root .erp-toggle-track::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.erp-root .erp-toggle input:checked + .erp-toggle-track { background: var(--carbon); }
.erp-root .erp-toggle input:checked + .erp-toggle-track::after { transform: translateX(16px); }
.erp-root .erp-toggle input:focus-visible + .erp-toggle-track { box-shadow: var(--focus); }
.erp-root .erp-toggle-text { display: grid; gap: 2px; font-size: 14.5px; }
.erp-root .erp-toggle-text small { color: var(--ink-2); font-size: 13px; line-height: 1.4; }
.erp-root fieldset:disabled .erp-toggle { cursor: default; opacity: .7; }

/* ------------------------------------------------------------------
 * Panoramica
 * ------------------------------------------------------------------ */

.erp-root .erp-overview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.erp-root .erp-ledger { grid-column: 1 / -1; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 6px 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); column-gap: 32px; }
.erp-root .erp-ledger-row { display: flex; align-items: baseline; gap: 8px; padding: 12px 0; color: var(--ink); text-decoration: none; }
.erp-root .erp-ledger-row span:first-child { white-space: nowrap; }
/* Puntini di guida, come in un indice */
.erp-root .erp-ledger-dots { flex: 1; border-bottom: 2px dotted var(--rule); transform: translateY(-4px); min-width: 16px; }
.erp-root .erp-ledger-row strong { font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.erp-root .erp-ledger-row:hover span:first-child { color: var(--carbon); text-decoration: underline; text-underline-offset: 3px; }

.erp-root .erp-panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 18px 20px 20px; }
.erp-root .erp-panel h2 { font-size: 16px; font-weight: 650; margin-bottom: 12px; }
.erp-root .erp-panel.is-todo { border-top: 3px solid var(--carbon); }
.erp-root .erp-panel.is-done { border-top: 3px solid var(--good); }
.erp-root .erp-panel.is-done p { color: var(--ink-2); max-width: 52ch; }
.erp-root .erp-todo { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.erp-root .erp-todo li a {
	display: flex; gap: 12px; align-items: flex-start; padding: 8px 6px; border-radius: var(--radius);
	color: var(--ink); text-decoration: none;
}
.erp-root .erp-todo li a::before { content: ""; flex: none; width: 16px; height: 16px; margin-top: 3px; border: 1.5px solid var(--ink-3); border-radius: 3px; background: #fff; }
.erp-root .erp-todo li a:hover { background: var(--carbon-soft); color: var(--carbon); }

.erp-root .erp-activity ol { list-style: none; margin: 0; padding: 0; }
.erp-root .erp-activity li { display: grid; gap: 1px; padding: 9px 0; border-bottom: 1px solid var(--rule-soft); }
.erp-root .erp-activity li:last-child { border-bottom: 0; }
.erp-root .erp-activity-what { font-size: 14.5px; }
.erp-root .erp-activity-what em { font-style: normal; font-weight: 600; }
.erp-root .erp-activity-meta { color: var(--ink-2); font-size: 13px; }

/* ------------------------------------------------------------------
 * Scheda azienda
 * ------------------------------------------------------------------ */

.erp-root .erp-sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 4px 24px 24px; max-width: 760px; }
.erp-root .erp-sheet + .erp-sheet { margin-top: 20px; padding-top: 20px; }
.erp-root .erp-sheet-foot { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--rule-soft); display: flex; justify-content: flex-end; }
.erp-root .erp-users h2 { font-size: 16px; font-weight: 650; margin-bottom: 8px; }
.erp-root .erp-users ul { list-style: none; margin: 0 0 12px; padding: 0; }
.erp-root .erp-users li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule-soft); }
.erp-root .erp-users li > span:nth-child(2) { flex: 1; display: grid; }
.erp-root .erp-users small { color: var(--ink-2); font-size: 13px; }
.erp-root .erp-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--carbon-soft); color: var(--carbon); display: grid; place-items: center; font-weight: 700; flex: none; }
.erp-root .erp-role { font-size: 13px; color: var(--ink-2); border: 1px solid var(--rule); border-radius: 3px; padding: 1px 8px; }
.erp-root .erp-users code { font-family: var(--mono); font-size: 13px; background: var(--paper); padding: 1px 5px; border-radius: 3px; }
.erp-root .erp-users .erp-muted { font-size: 14px; }

/* ------------------------------------------------------------------
 * Primo avvio
 * ------------------------------------------------------------------ */

.erp-root .erp-welcome { max-width: 560px; margin: 10vh auto 0; padding: 32px; background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); display: grid; gap: 16px; }
.erp-root .erp-welcome h1 { font-size: 26px; font-weight: 650; letter-spacing: -.015em; }
.erp-root .erp-welcome > p { color: var(--ink-2); }
.erp-root .erp-welcome .erp-btn { justify-self: start; }

/* ------------------------------------------------------------------
 * Avviso temporaneo
 * ------------------------------------------------------------------ */

.erp-root .erp-toast {
	position: fixed; left: 50%; bottom: 24px; z-index: 40;
	transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
	background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius);
	font-weight: 600; font-size: 14px; transition: opacity .2s, transform .2s;
}
.erp-root .erp-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ------------------------------------------------------------------
 * Schermi stretti
 * ------------------------------------------------------------------ */

@media (max-width: 1100px) { .erp-root .hide-md { display: none; } }

@media (max-width: 860px) {
	.erp-root .erp-shell { grid-template-columns: minmax(0, 1fr); align-content: start; }
	.erp-root .erp-topbar {
		display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20;
		padding: 8px 12px; background: var(--paper-deep); border-bottom: 1px solid var(--rule);
	}
	.erp-root .erp-topbar-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.erp-root .erp-side {
		position: fixed; z-index: 35; left: 0; top: 0; width: min(300px, 86vw);
		transform: translateX(-100%); transition: transform .2s ease-out; visibility: hidden;
	}
	.erp-root .nav-open .erp-side { transform: none; visibility: visible; }
	.erp-root .erp-nav-scrim { display: none; z-index: 34; position: fixed; }
	.erp-root .nav-open .erp-nav-scrim { display: block; }
	.erp-root .erp-main { padding: 20px 16px 48px; }
	.erp-root .erp-overview { grid-template-columns: minmax(0, 1fr); }
	.erp-root .erp-page-head { flex-wrap: wrap; align-items: flex-start; }
	.erp-root .erp-page-head.is-overview h1 { font-size: 26px; }
	.erp-root .erp-search { max-width: none; margin-left: 0; flex-basis: 100%; }
}

@media (min-width: 861px) { .erp-root .erp-nav-scrim { display: none; } }

@media (max-width: 600px) {
	.erp-root .hide-sm { display: none; }
	.erp-root .erp-grid { grid-template-columns: minmax(0, 1fr); }
	.erp-root .erp-grid > .is-half { grid-column: 1 / -1; }
	.erp-root .erp-drawer-head, .erp-root .erp-drawer-body, .erp-root .erp-drawer-foot { padding-left: 16px; padding-right: 16px; }
	.erp-root .erp-tabs { width: 100%; overflow-x: auto; }
	.erp-root .erp-sheet { padding-left: 16px; padding-right: 16px; }
	.erp-root .erp-table td.is-primary { min-width: 160px; }
}

.erp-root .erp-from { color: var(--ink-3); }
.erp-root .erp-low { color: var(--stamp); font-weight: 600; }

/* Provenienza dei dati (moduli A360) */
.erp-root .erp-source {
	display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 16px 0 0; padding: 10px 12px;
	border: 1px solid var(--rule-soft); border-left: 3px solid var(--carbon); border-radius: 0 var(--radius) var(--radius) 0;
	background: var(--carbon-soft); font-size: 13.5px; color: var(--ink);
}
.erp-root .erp-source .erp-tag { margin-left: 0; }
.erp-root .erp-source-stock.is-low strong { color: var(--stamp); }

.erp-root .erp-warn { grid-column: 1 / -1; padding: 12px 14px; border: 1px solid #e3c98a; border-left: 3px solid #b07a12; border-radius: 0 var(--radius) var(--radius) 0; background: #fbf4e2; font-size: 14px; }
.erp-root .erp-warn p + p { margin-top: 6px; }
.erp-root .erp-warn ul { margin: 6px 0 0 18px; padding: 0; }

.erp-root .erp-links ul { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.erp-root .erp-links li { display: flex; align-items: baseline; gap: 10px; }
.erp-root .erp-links small { color: var(--ink-2); font-size: 13px; }
.erp-root .erp-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--rule); transform: translateY(-1px); }
.erp-root .erp-links li.is-on .erp-dot { background: var(--good); }
.erp-root .erp-links li.is-off strong { color: var(--ink-2); font-weight: 500; }
.erp-root .erp-links .erp-muted { font-size: 13px; }

/* Fatture */
.erp-root .erp-toolbar-note { margin-left: auto; color: var(--ink-2); font-size: 13.5px; }
.erp-root .erp-status { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--rule); color: var(--ink-2); white-space: nowrap; }
.erp-root .erp-status.is-bozza { border-style: dashed; }
.erp-root .erp-status.is-inviata { border-color: var(--carbon); color: var(--carbon); }
.erp-root .erp-status.is-consegnata { border-color: var(--good); color: #fff; background: var(--good); }
.erp-root .erp-status.is-mancata { border-color: #b07a12; color: #8a5f0c; }
.erp-root .erp-status.is-scartata, .erp-root .erp-status.is-errore { border-color: var(--stamp); color: #fff; background: var(--stamp); }

.erp-root .erp-drawer.is-wide { width: min(880px, 100%); }
.erp-root .erp-picked { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; }
.erp-root .erp-picked > span { display: grid; }
.erp-root .erp-picked small, .erp-root .erp-picker small { color: var(--ink-2); font-size: 13px; }
.erp-root .erp-picker { list-style: none; margin: 4px 0 0; padding: 4px; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; box-shadow: 0 6px 18px rgba(29, 38, 34, .12); }
.erp-root .erp-picker button { display: grid; width: 100%; text-align: left; border: 0; background: none; padding: 7px 8px; border-radius: 4px; cursor: pointer; }
.erp-root .erp-picker button:hover, .erp-root .erp-picker button:focus-visible { background: var(--carbon-soft); }

.erp-root .erp-line {
	display: grid; gap: 6px 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule-soft);
	grid-template-columns: minmax(0, 1.9fr) minmax(0, 1.3fr) 60px 24px 84px 76px 84px 32px;
}
.erp-root .erp-line .erp-input { min-height: 34px; padding: 5px 8px; font-size: 14px; }
.erp-root .erp-line .erp-input.is-num { max-width: none; }
.erp-root .erp-line-unit { color: var(--ink-2); font-size: 13px; }
.erp-root .erp-line-total { text-align: right; font-weight: 600; font-size: 14px; white-space: nowrap; }
.erp-root .erp-line-err { grid-column: 1 / -1; }
.erp-root .erp-line.has-error .erp-input { border-color: var(--stamp); }
.erp-root .erp-group > .erp-btn.is-plain { margin-top: 10px; }
.erp-root .erp-totals { display: grid; grid-template-columns: auto auto; justify-content: end; gap: 2px 24px; margin: 14px 0 0; font-variant-numeric: tabular-nums; }
.erp-root .erp-totals dt { color: var(--ink-2); text-align: right; }
.erp-root .erp-totals dd { margin: 0; text-align: right; min-width: 100px; }
.erp-root .erp-totals dt:last-of-type, .erp-root .erp-totals dd:last-of-type { font-weight: 700; color: var(--ink); font-size: 16px; padding-top: 4px; border-top: 1px solid var(--rule); }
.erp-root .erp-done { display: grid; gap: 14px; justify-items: start; padding-top: 20px; }
.erp-root .erp-done h3 { font-size: 18px; font-weight: 650; }
.erp-root .erp-done .erp-warn { width: 100%; }

@media (max-width: 700px) {
	.erp-root .erp-line { grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) 32px; }
	.erp-root .erp-line-product, .erp-root .erp-line-desc { grid-column: 1 / -1; }
	.erp-root .erp-line-qty { grid-column: 1; }
	.erp-root .erp-line-unit { grid-column: 2; }
	.erp-root .erp-line-price { grid-column: 3; }
	.erp-root .erp-line-rate { grid-column: 1; }
	.erp-root .erp-line-total { grid-column: 2 / 4; }
	.erp-root .erp-line-del { grid-column: 4; grid-row: 1; }
	.erp-root .erp-line-product { grid-column: 1 / 4; }
	.erp-root .erp-toolbar-note { margin-left: 0; flex-basis: 100%; }
}

/* ------------------------------------------------------------------
 * Modalità incorporata in una pagina (shortcode [erp_app])
 * L'app occupa un riquadro ad altezza fissa; la disposizione segue la
 * larghezza del riquadro (container query), non quella della finestra.
 * ------------------------------------------------------------------ */

.erp-root.is-embedded {
	container: erp / inline-size;
	position: relative;
	height: var(--erp-height, 760px);
	max-width: 100%;
	overflow: hidden;
	background: var(--paper);
	border: 1px solid var(--rule);
	border-radius: 8px;
}
.erp-root.is-embedded .erp-shell { min-height: 0; height: 100%; }
.erp-root.is-embedded .erp-side { position: relative; height: 100%; }
.erp-root.is-embedded .erp-main { height: 100%; overflow-y: auto; max-width: none; }
.erp-root.is-embedded .erp-welcome { margin-top: 32px; }
.erp-root.is-embedded .erp-drawer-layer,
.erp-root.is-embedded .erp-toast { position: absolute; }

@container erp (max-width: 1100px) { .erp-root.is-embedded .hide-md { display: none; } }

@container erp (max-width: 860px) {
	.erp-root.is-embedded .erp-shell { grid-template-rows: auto minmax(0, 1fr); }
	.erp-root.is-embedded .erp-main { height: auto; min-height: 0; }
	.erp-root.is-embedded .erp-shell { grid-template-columns: minmax(0, 1fr); align-content: start; }
	.erp-root.is-embedded .erp-topbar {
		display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20;
		padding: 8px 12px; background: var(--paper-deep); border-bottom: 1px solid var(--rule);
	}
	.erp-root.is-embedded .erp-topbar-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
	.erp-root.is-embedded .erp-side {
		position: absolute; z-index: 35; left: 0; top: 0; height: 100%; width: min(300px, 86vw);
		transform: translateX(-100%); transition: transform .2s ease-out; visibility: hidden;
	}
	.erp-root.is-embedded .nav-open .erp-side { transform: none; visibility: visible; }
	.erp-root.is-embedded .erp-nav-scrim { display: none; z-index: 34; position: absolute; }
	.erp-root.is-embedded .nav-open .erp-nav-scrim { display: block; }
	.erp-root.is-embedded .erp-main { padding: 20px 16px 48px; }
	.erp-root.is-embedded .erp-overview { grid-template-columns: minmax(0, 1fr); }
	.erp-root.is-embedded .erp-page-head { flex-wrap: wrap; align-items: flex-start; }
	.erp-root.is-embedded .erp-page-head.is-overview h1 { font-size: 26px; }
	.erp-root.is-embedded .erp-search { max-width: none; margin-left: 0; flex-basis: 100%; }
}

@container erp (max-width: 600px) {
	.erp-root.is-embedded .hide-sm { display: none; }
	.erp-root.is-embedded .erp-grid { grid-template-columns: minmax(0, 1fr); }
	.erp-root.is-embedded .erp-grid > .is-half { grid-column: 1 / -1; }
	.erp-root.is-embedded .erp-drawer-head, .erp-root.is-embedded .erp-drawer-body, .erp-root.is-embedded .erp-drawer-foot { padding-left: 16px; padding-right: 16px; }
	.erp-root.is-embedded .erp-tabs { width: 100%; overflow-x: auto; }
	.erp-root.is-embedded .erp-sheet { padding-left: 16px; padding-right: 16px; }
	.erp-root.is-embedded .erp-table td.is-primary { min-width: 160px; }
}

/* In un riquadro largo resta la disposizione desktop anche se la finestra è stretta */
@container erp (min-width: 861px) {
	.erp-root.is-embedded .erp-nav-scrim { display: none; }
}
@media (max-width: 860px) {
	.erp-root.is-embedded { height: var(--erp-height-mobile, 640px); }
}

@media (prefers-reduced-motion: reduce) {
	.erp-root *, .erp-root *::before, .erp-root *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
