:root { color-scheme: light; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: Inter, system-ui, sans-serif; color: #1C1A17; background: #161412; }

/* ---- Layout shell ---- */
.admin-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; max-width: 1440px; margin-inline: auto; }
.sidebar { background: #161412; color: #EDE9E2; display: flex; flex-direction: column; padding: 24px 16px; gap: 8px; }
.sidebar__logo { display: block; height: 40px; margin: 4px 8px 24px; }
.sidebar__link { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 10px; color: #B8B2A8; font: 600 14px Inter; text-decoration: none; cursor: pointer; transition: background-color .15s ease, color .15s ease, transform .06s ease; }
.sidebar__link:hover { background: #221F1B; color: #EDE9E2; }
.sidebar__link:not(.is-disabled):active { transform: translateY(1px); }
.sidebar__link.is-active { background: #C20E1A; color: #fff; }
.sidebar__link.is-disabled { color: #6B665E; cursor: default; }
.sidebar__link.is-disabled:hover { background: none; color: #6B665E; }
.sidebar__spacer { flex: 1; }
.sidebar__logout { background: transparent; border: 1px solid #3A352F; color: #B8B2A8; padding: 10px; border-radius: 10px; font: 600 13px Inter; cursor: pointer; transition: color .15s ease, border-color .15s ease, transform .06s ease; }
.sidebar__logout:hover { color: #fff; border-color: #5A534A; }
.sidebar__logout:active { transform: translateY(1px); }
/* Pallino "novità non viste" sul link Richieste. NB: niente `display` qui, così
   l'attributo [hidden] funziona; la regola esplicita sotto è una difesa in più
   (il vecchio .sidebar__badge con display:inline-block sovrascriveva [hidden]). */
.sidebar__dot {
  width: 8px;
  height: 8px;
  margin-left: 8px;
  border-radius: 999px;
  background: #C20E1A;
  box-shadow: 0 0 0 3px rgba(194, 14, 26, 0.18);
}
.sidebar__dot[hidden] { display: none; }

.main { padding: 32px 40px; overflow: auto; background: #F4F2EE; }
.page-title { font: 800 26px Archivo; letter-spacing: -0.3px; margin-bottom: 4px; }
.page-eyebrow { font: 700 11px Archivo; letter-spacing: 1.6px; color: #857F77; text-transform: uppercase; margin-bottom: 24px; }
.content { max-width: 1100px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.muted { color: #857F77; }

/* ---- Card ---- */
.card { background: #fff; border: 1px solid #E5E0D8; border-radius: 14px; padding: 20px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat__n { font: 800 34px Archivo; }
.stat__l { font: 600 13px Inter; color: #857F77; margin-top: 4px; }
.card--alert { display: block; text-decoration: none; color: inherit; transition: border-color .15s, background .15s; }
.card--alert:hover { border-color: #C9C2B8; background: #FAF8F4; }
.card--alert.is-active { border-color: #C20E1A; background: #FDF3F3; }
.card--alert.is-active .stat__n { color: #C20E1A; }

/* ---- Grafico volume ticket ---- */
.dash-chart-card { background: #fff; border: 1px solid #E5E0D8; border-radius: 14px; padding: 20px; }
.dash-chart-head { font: 600 13px Inter; color: #857F77; margin-bottom: 14px; }
.dash-chart { display: flex; align-items: flex-end; gap: 4px; height: 140px; }
.dash-bar { flex: 1; background: #3A3530; border-radius: 2px 2px 0 0; min-height: 2px; }

/* ---- Table ---- */
.table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #E5E0D8; border-radius: 14px; overflow: hidden; }
.table th { text-align: left; font: 700 11px Archivo; letter-spacing: 0.8px; text-transform: uppercase; color: #857F77; padding: 14px 18px; border-bottom: 1px solid #E5E0D8; background: #FAF8F4; }
.table td { padding: 14px 18px; border-bottom: 1px solid #F0ECE4; font: 500 14px Inter; }
.table tr:last-child td { border-bottom: none; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-clickable:hover td { background: #FAF8F4; }
.table tr.is-deleted td { opacity: 0.5; }

/* ---- Badge ---- */
.badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font: 700 11px Inter; letter-spacing: 0.3px; }
.badge--aperto { background: #FDE7E5; color: #C20E1A; }
.badge--in_lavorazione { background: #FEF1DD; color: #B5790B; }
.badge--chiuso { background: #E4EFE6; color: #2F7D3A; }
.badge--annullato { background: #E8E5E2; color: #5A534A; }
.badge--in_scadenza { background: #FEF1DD; color: #B5790B; }
.badge--scaduto { background: #FDE7E5; color: #C20E1A; }

/* ---- Chip filter ---- */
.chips { display: flex; gap: 8px; margin-bottom: 20px; }
.chip { padding: 7px 16px; border-radius: 999px; border: 1px solid #E5E0D8; background: #fff; font: 600 13px Inter; color: #5A534A; cursor: pointer; transition: background-color .15s ease, border-color .15s ease, color .15s ease, transform .06s ease; }
.chip:hover:not(.chip--active) { background: #FAF8F4; border-color: #D9D3C9; }
.chip:active { transform: translateY(1px); }
.chip--active { background: #161412; color: #fff; border-color: #161412; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 18px; border-radius: 10px; font: 600 14px Inter; border: none; cursor: pointer; transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .06s ease; }
.btn--primary { background: #C20E1A; color: #fff; }
.btn--primary:hover { background: #A60B16; }
.btn--ghost { background: #fff; border: 1px solid #E5E0D8; color: #1C1A17; }
.btn--ghost:hover { background: #FAF8F4; }
.btn--danger { background: #fff; border: 1px solid #E7B7B3; color: #C20E1A; }
.btn--danger:hover { background: #FDE7E5; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible { outline: 2px solid rgba(194, 14, 26, 0.45); outline-offset: 2px; }

/* ---- Forms ---- */
.field-label { display: block; font: 600 12px Inter; color: #5A534A; margin: 14px 0 6px; }
.input, select.input, textarea.input { width: 100%; padding: 11px 13px; border: 1px solid #D9D3C9; border-radius: 10px; font: 500 14px Inter; background: #fff; color: #1C1A17; }
.input:focus { outline: 2px solid #C20E1A; border-color: #C20E1A; }
textarea.input { min-height: 96px; resize: vertical; }
.form-error { color: #C20E1A; font: 600 13px Inter; min-height: 18px; margin-top: 8px; }
.search { max-width: 320px; }

/* ---- Modal ---- */
.modal__backdrop { position: fixed; inset: 0; background: rgba(22,20,18,0.55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: 16px; padding: 28px; width: 440px; max-width: calc(100vw - 32px); max-height: calc(100vh - 64px); overflow: auto; }
.modal__title { font: 800 20px Archivo; margin-bottom: 4px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #161412; }
.login-card { width: 360px; background: #1F1C19; border: 1px solid #2E2A25; border-radius: 18px; padding: 36px 30px; }
.login-card img { height: 30px; margin-bottom: 6px; }
.login-card .eyebrow { font: 700 11px Archivo; letter-spacing: 1.8px; color: #857F77; margin-bottom: 24px; }
.input-dark { width: 100%; padding: 12px 14px; border: 1px solid #3A352F; border-radius: 10px; background: #161412; color: #EDE9E2; font: 500 14px Inter; }
.input-dark:focus { outline: 2px solid #C20E1A; border-color: #C20E1A; }

.section-title { font: 800 16px Archivo; margin: 28px 0 12px; }
.models-group { margin: 24px 0 8px; font: 700 13px Inter; letter-spacing: .04em; text-transform: uppercase; color: #8A8378; }
.models-group:first-child { margin-top: 4px; }
.empty { padding: 40px; text-align: center; color: #857F77; }
a.plain { color: inherit; text-decoration: none; }

/* ---- Report (mock) ---- */
.rp { background: #F7F6F4; padding: 0; }
.rp-head { position: sticky; top: 0; z-index: 2; background: #fff; border-bottom: 1px solid #E8E5E2; padding: 20px 64px 20px 40px; display: flex; align-items: center; justify-content: space-between; }
.rp-period { font: 500 13px Inter; color: #79736C; margin-top: 2px; }
.rp-head__actions { display: flex; align-items: center; gap: 12px; }
.rp-seg { display: inline-flex; background: #F4F3F1; border: 1px solid #E8E5E2; border-radius: 9px; padding: 3px; }
.rp-seg__opt { border: 0; background: transparent; color: #57534E; font: 700 12px Archivo; padding: 6px 12px; border-radius: 7px; cursor: pointer; transition: background-color .15s ease, color .15s ease, transform .06s ease; }
.rp-seg__opt:active { transform: translateY(1px); }
.rp-seg__opt.is-active { background: #fff; color: #1C1A18; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.rp-export { background: #161412; color: #fff; border: 0; border-radius: 9px; font: 700 12px Archivo; letter-spacing: .04em; text-transform: uppercase; padding: 10px 16px; cursor: pointer; transition: background-color .15s ease, transform .06s ease; }
.rp-export:hover { background: #2A2622; }
.rp-export:active { transform: translateY(1px); }
.rp-export-msg { font: 600 12px Inter; color: #B3121A; }
.rp-body { padding: 24px 40px; }
.rp-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.rp-kpi { background: #fff; border: 1px solid #E8E5E2; border-radius: 12px; padding: 16px 18px; }
.rp-kpi__label { font: 700 11px Archivo; letter-spacing: .06em; text-transform: uppercase; color: #79736C; }
.rp-kpi__val { font: 800 30px Archivo; color: #1C1A18; margin: 6px 0 4px; }
.rp-delta { font: 700 13px Archivo; }
.rp-delta.is-pos { color: #1E7F3C; }
.rp-delta.is-crit { color: #B3121A; }
.rp-kpi__cap { font: 500 12px Inter; color: #A39C94; }
.rp-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 14px; }
.rp-card { background: #fff; border: 1px solid #E8E5E2; border-radius: 12px; padding: 18px; }
.rp-card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.rp-card__head h3 { font: 800 15px Archivo; color: #1C1A18; }
.rp-legend, .rp-donut-legend { font: 600 12px Inter; color: #57534E; display: flex; gap: 14px; align-items: center; }
.rp-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }
.rp-dot--a { background: #C20E1A; } .rp-dot--r { background: #3A3530; }
.rp-bars { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding-top: 10px; }
.rp-bar { flex: 1; display: flex; flex-direction: column; align-items: center; }
.rp-bar__stack { display: flex; flex-direction: column-reverse; width: 70%; }
.rp-bar__seg--a { background: #C20E1A; border-radius: 3px 3px 0 0; }
.rp-bar__seg--r { background: #3A3530; }
.rp-bar__x { font: 600 11px Inter; color: #79736C; margin-top: 6px; }
.rp-donut-wrap { display: flex; align-items: center; gap: 18px; }
.rp-donut { width: 132px; height: 132px; border-radius: 50%; background: conic-gradient(#C20E1A 0 68%, #3A3530 68% 100%); display: flex; align-items: center; justify-content: center; }
.rp-donut__hole { width: 84px; height: 84px; border-radius: 50%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.rp-donut__hole strong { font: 800 22px Archivo; } .rp-donut__hole span { font: 700 9px Archivo; letter-spacing: .1em; color: #A39C94; }
.rp-donut-legend { flex-direction: column; align-items: flex-start; gap: 8px; }
.rp-donut-legend em { color: #A39C94; font-style: normal; }
.rp-table { width: 100%; border-collapse: collapse; }
.rp-table th { font: 700 11px Archivo; letter-spacing: .04em; text-transform: uppercase; color: #79736C; text-align: left; padding: 8px 6px; border-bottom: 1px solid #E8E5E2; }
.rp-table td { font: 500 14px Inter; color: #1C1A18; padding: 12px 6px; border-bottom: 1px solid #F0EEEB; }
.ta-r { text-align: right; }
.rp-tnum { font: 700 14px Archivo; } .rp-tnum.is-top { color: #C20E1A; }
.rp-pill { font: 700 11px Archivo; padding: 3px 10px; border-radius: 999px; }
.rp-pill.pill--crit { color: #B3121A; background: #FCE9E9; }
.rp-pill.pill--neutro { color: #57534E; background: #EEECE9; }
.rp-pill.pill--ok { color: #1E7F3C; background: #E4F3E9; }
.rp-guasto { margin-bottom: 12px; }
.rp-guasto__top { display: flex; justify-content: space-between; font: 600 13px Inter; color: #1C1A18; margin-bottom: 5px; }
.rp-guasto__track { background: #F0EEEB; border-radius: 4px; height: 8px; }
.rp-guasto__fill { background: #3A3530; height: 8px; border-radius: 4px; }
.rp-guasto:nth-child(1) .rp-guasto__fill, .rp-guasto:nth-child(2) .rp-guasto__fill { background: #C20E1A; }
@media (max-width: 1000px) { .rp-kpis { grid-template-columns: repeat(2, 1fr); } .rp-grid { grid-template-columns: 1fr; } }

/* ---- Vista ampia ---- */
.view-toggle { position: fixed; top: 12px; right: 16px; z-index: 40; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: #fff; color: #1C1A17; border: 1px solid #00000022; border-radius: 9px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.12); transition: border-color .15s ease, box-shadow .15s ease, transform .06s ease; }
.view-toggle:hover { border-color: #00000044; }
.view-toggle:active { transform: translateY(1px); }
body.is-wide .admin-shell { max-width: none; }
body.is-wide .content { max-width: none; }
/* Clearance: l'header di pagina (titolo + bottone azione) non deve finire sotto il toggle fixed in alto a destra */
.content > .row-between:first-child { padding-right: 56px; }

/* ---- Puntino "nuova arrivata" sulle righe richieste ---- */
.novita-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #C20E1A;
  vertical-align: middle;
}

.machines-panel { padding: 8px 0 16px; }
.machines-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.machine-azienda { display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: inherit; }
