:root {
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #eef2f6;
  --border: #dde3e9;
  --border-strong: #c8d1da;
  --text: #15202e;
  --text-2: #46566a;
  --text-3: #7c8a9c;
  --sidebar: #14202e;
  --sidebar-2: #1c2c3d;
  --sidebar-text: #9fb0c2;
  --sidebar-text-dim: #64788f;
  --accent: #1f5fd6;
  --accent-d: #1a4fb4;
  --accent-soft: #e7eefb;
  --ok: #18915a;
  --ok-soft: #e1f3ea;
  --warn: #c47d12;
  --warn-soft: #faf0db;
  --danger: #cf3636;
  --danger-soft: #fbe7e7;
  --idle: #7c8a9c;
  --idle-soft: #eceff3;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(20,32,46,.06), 0 1px 3px rgba(20,32,46,.04);
  --shadow-md: 0 4px 14px rgba(20,32,46,.10);
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
#root { height: 100vh; }

/* ===== App shell ===== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.brand {
  display: flex; flex-direction: column; align-items: stretch; gap: 11px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand-meta { display: flex; flex-direction: column; gap: 1px; padding: 0 2px; }
.brand-name-sm { font-weight: 600; font-size: 12.5px; color: #fff; letter-spacing: -.01em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 7px; flex-shrink: 0;
  background: var(--accent);
  display: grid; place-items: center;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
}
.brand-mark .dots { display: grid; grid-template-columns: repeat(3, 5px); gap: 3px; }
.brand-mark .dots i { width: 5px; height: 5px; border-radius: 50%; display: block; }
.brand-name { font-weight: 600; font-size: 14.5px; color: #fff; letter-spacing: -.01em; }
.brand-sub { font-family: var(--mono); font-size: 10px; color: var(--sidebar-text-dim); letter-spacing: .08em; text-transform: uppercase; margin-top: 1px; }

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--sidebar-text-dim); padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--radius-sm);
  color: var(--sidebar-text); cursor: pointer; font-size: 13.5px; font-weight: 450;
  border: none; background: none; text-align: left; width: 100%;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #dde6ef; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item.active .nav-ic { opacity: 1; }
.nav-ic { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.nav-badge { margin-left: auto; font-family: var(--mono); font-size: 11px; background: rgba(255,255,255,.12); color: #cdd8e3; padding: 1px 7px; border-radius: 20px; }
.nav-item.active .nav-badge { background: rgba(255,255,255,.22); color: #fff; }

.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--sidebar-2); display: grid; place-items: center; font-family: var(--mono); font-size: 12px; color: #cdd8e3; font-weight: 600; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.sidebar-foot .who { font-size: 12.5px; color: #cdd8e3; font-weight: 500; }
.sidebar-foot .role { font-size: 11px; color: var(--sidebar-text-dim); }

/* ===== Main ===== */
.main { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar {
  height: 60px; flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 18px;
  padding: 0 28px;
}
.crumb { font-family: var(--mono); font-size: 11px; letter-spacing: .06em; color: var(--text-3); text-transform: uppercase; }
.topbar h1 { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -.015em; }
.topbar-spacer { flex: 1; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 7px 12px; width: 280px;
  color: var(--text-3);
}
.search input { border: none; background: none; outline: none; font-family: var(--sans); font-size: 13px; color: var(--text); width: 100%; }
.icon-btn { width: 36px; height: 36px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--text-2); position: relative; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; background: var(--danger); border-radius: 50%; border: 1.5px solid var(--surface); }

.content { flex: 1; overflow-y: auto; padding: 26px 28px 48px; }
.content-inner { max-width: 1280px; margin: 0 auto; }

/* ===== Generic ===== */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  padding: 8px 14px; border-radius: var(--radius); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-d); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-3); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #b82f2f; }
.btn.danger-ghost { border-color: transparent; background: transparent; color: var(--danger); }
.btn.danger-ghost:hover { background: var(--danger-soft); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 26px 20px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); cursor: pointer; background: var(--surface-2); transition: border-color .12s, background .12s; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.card-head .sub { font-family: var(--mono); font-size: 10.5px; color: var(--text-3); letter-spacing: .06em; text-transform: uppercase; }
.card-body { padding: 18px; }

.mono { font-family: var(--mono); }
.muted { color: var(--text-3); }

/* status pill */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 3px 9px 3px 8px; border-radius: 20px; line-height: 1.3; white-space: nowrap; }
.pill .led { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.ok .led { background: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); } .pill.warn .led { background: var(--warn); }
.pill.danger { background: var(--danger-soft); color: var(--danger); } .pill.danger .led { background: var(--danger); }
.pill.idle { background: var(--idle-soft); color: var(--idle); } .pill.idle .led { background: var(--idle); }
.pill.accent { background: var(--accent-soft); color: var(--accent-d); } .pill.accent .led { background: var(--accent); }

.prio { font-family: var(--mono); font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; font-weight: 500; padding: 2px 7px; border-radius: var(--radius-sm); }
.prio.alta { background: var(--danger-soft); color: var(--danger); }
.prio.media { background: var(--warn-soft); color: var(--warn); }
.prio.bassa { background: var(--idle-soft); color: var(--text-2); }

/* ===== Tables ===== */
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  text-align: left; font-family: var(--mono); font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-3); font-weight: 500; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  position: sticky; top: 0;
}
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
table.tbl tbody tr { cursor: pointer; transition: background .1s; }
table.tbl tbody tr:hover { background: var(--surface-2); }
table.tbl tbody tr.sel { background: var(--accent-soft); }
table.tbl tbody tr:last-child td { border-bottom: none; }
.cell-id { font-family: var(--mono); font-size: 12.5px; font-weight: 500; color: var(--accent-d); }
.cell-strong { font-weight: 600; }

/* ===== KPI ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi .top { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.kpi .kic { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; }
.kpi .kic svg { width: 16px; height: 16px; }
.kpi .lbl { font-size: 12px; color: var(--text-2); font-weight: 500; }
.kpi .val { font-size: 30px; font-weight: 600; letter-spacing: -.02em; font-feature-settings: "tnum"; line-height: 1; }
.kpi .val small { font-size: 14px; color: var(--text-3); font-weight: 500; margin-left: 2px; }
.kpi .delta { font-family: var(--mono); font-size: 11px; margin-top: 8px; display: inline-flex; align-items: center; gap: 4px; }
.kpi .delta.up { color: var(--ok); } .kpi .delta.down { color: var(--danger); } .kpi .delta.flat { color: var(--text-3); }

.dash-grid { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; }
.dash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 18px; }

/* bar chart */
.chart { display: flex; align-items: flex-end; gap: 18px; height: 190px; padding: 8px 4px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart .bars { display: flex; align-items: flex-end; gap: 5px; height: 100%; width: 100%; justify-content: center; }
.chart .bar { width: 18px; border-radius: 3px 3px 0 0; transition: height .4s ease; }
.chart .bar.p { background: var(--accent); }
.chart .bar.g { background: #c9d6e8; }
.chart .xlab { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.legend { display: flex; gap: 16px; align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: block; }

/* list items */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-item:hover { background: var(--surface-2); }
.list-item:last-child { border-bottom: none; }
.li-main { min-width: 0; flex: 1; }
.li-title { font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { font-family: var(--mono); font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ===== Detail drawer / split ===== */
.split { display: grid; grid-template-columns: 1fr 400px; gap: 18px; align-items: start; }
.detail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); position: sticky; top: 0; overflow: hidden; }
.detail-head { padding: 18px; border-bottom: 1px solid var(--border); }
.detail-head .dh-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-title { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.detail-id { font-family: var(--mono); font-size: 12px; color: var(--accent-d); margin-top: 2px; }
.detail-body { padding: 18px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field .k { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.field .v { font-size: 13.5px; font-weight: 500; }
.field .v.mono { font-family: var(--mono); font-size: 12.5px; font-weight: 500; }

.section-title { font-family: var(--mono); font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); margin: 22px 0 10px; }
hr.sep { border: none; border-top: 1px solid var(--border); margin: 18px 0; }

.empty-detail { display: grid; place-items: center; height: 100%; min-height: 420px; color: var(--text-3); text-align: center; padding: 30px; }
.empty-detail svg { width: 38px; height: 38px; opacity: .4; margin-bottom: 12px; }

/* timeline */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding: 0 0 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -22px; top: 3px; width: 13px; height: 13px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--accent); }
.tl-dot.ok { border-color: var(--ok); } .tl-dot.warn { border-color: var(--warn); } .tl-dot.danger { border-color: var(--danger); } .tl-dot.idle { border-color: var(--idle); }
.tl-date { font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.tl-title { font-weight: 500; font-size: 13.5px; margin-top: 2px; }
.tl-note { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

/* page toolbar */
.page-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: var(--radius); padding: 3px; gap: 2px; }
.seg button { border: none; background: none; font-family: var(--sans); font-size: 12.5px; font-weight: 500; color: var(--text-2); padding: 6px 13px; border-radius: var(--radius-sm); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tool-spacer { flex: 1; }
.count-note { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }

/* progress bar */
.pbar { height: 6px; background: var(--surface-3); border-radius: 20px; overflow: hidden; }
.pbar > i { display: block; height: 100%; background: var(--accent); border-radius: 20px; }

/* misc */
.row-flex { display: flex; align-items: center; gap: 10px; }

/* scheda macchina dentro la scheda cliente */
.mac-card { display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 13px; cursor: pointer; transition: border-color .12s, background .12s; }
.mac-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.mac-ic { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-d); display: grid; place-items: center; flex-shrink: 0; }
.gap6 { display: flex; align-items: center; gap: 6px; }
.stat-line { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--border); }
.stat-line:last-child { border-bottom: none; }
.stat-line .sl-name { font-size: 13px; font-weight: 500; }
.stat-line .sl-sub { font-family: var(--mono); font-size: 11px; color: var(--text-3); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #c7d0da; border-radius: 20px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #b0bcc9; }
.content::-webkit-scrollbar-track { background: var(--bg); }

/* ===== Logout sidebar ===== */
.sidebar-logout { border: none; background: rgba(255,255,255,.06); color: var(--sidebar-text); width: 32px; height: 32px; border-radius: var(--radius-sm); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.sidebar-logout:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ===== LOGIN ===== */
.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card2 {
  position: relative; width: 100%; max-width: 430px;
  background: var(--surface); border-radius: 22px;
  box-shadow: 0 24px 60px -18px rgba(20, 32, 46, .28), 0 2px 8px rgba(20, 32, 46, .06);
  padding: 44px 46px 30px; overflow: hidden;
}
.login-card2::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 50%, var(--danger) 50%, var(--danger) 100%);
}
.login-logo { margin-bottom: 30px; }
.login-logo img { height: 56px; width: auto; max-width: 100%; object-fit: contain; display: block; }
.login-h1 { font-size: 27px; font-weight: 700; letter-spacing: -.025em; color: var(--text); margin: 0 0 8px; line-height: 1.15; }
.login-p { font-size: 15px; color: var(--text-3); margin: 0 0 30px; line-height: 1.45; }
.login-seg2 { display: flex; width: 100%; margin: 0 0 22px; padding: 4px; gap: 3px; border-radius: 12px; background: var(--surface-3); }
.login-seg2 button { flex: 1; border: none; background: none; font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--text-2); padding: 10px 8px; border-radius: 9px; cursor: pointer; transition: background .12s, color .12s, box-shadow .12s; }
.login-seg2 button.on { background: var(--surface); color: var(--accent-d); box-shadow: var(--shadow); }
.login-field2 { display: flex; flex-direction: column; gap: 9px; margin-bottom: 20px; }
.login-field2 > span { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); }
.login-field2 input {
  font-family: var(--sans); font-size: 16px; color: var(--text);
  border: 1.5px solid var(--border-strong); border-radius: 12px; padding: 15px 16px; background: var(--surface); outline: none; width: 100%;
}
.login-field2 input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.login-field2 .pwd-wrap input { padding-right: 48px; }
.login-btn2 { width: 100%; justify-content: center; padding: 15px; font-size: 16px; font-weight: 700; border-radius: 12px; margin-top: 6px; }
.login-foot2 { font-size: 13px; color: var(--text-3); text-align: center; margin-top: 22px; }
@media (max-width: 480px) { .login-card2 { padding: 34px 26px 26px; border-radius: 18px; } .login-h1 { font-size: 23px; } }

.login-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.login-field > span { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.login-field input, .login-field select, .login-field textarea {
  font-family: var(--sans); font-size: 14px; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 10px 12px; background: var(--surface); outline: none; width: 100%; resize: vertical;
}
.login-field input:focus, .login-field select:focus, .login-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-field input[readonly] { background: var(--surface-2); color: var(--text-2); }
.chk-field { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--text); }
.chk-field input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.chk-list { border: 1px solid var(--border-strong); border-radius: var(--radius); max-height: 200px; overflow-y: auto; padding: 4px; }
.chk-row { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; }
.chk-row:hover { background: var(--surface-2); }
.chk-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.login-foot { font-size: 11px; color: var(--text-3); text-align: center; margin-top: 16px; }
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 42px; }
.pwd-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 30px; height: 30px; border: none; background: none; color: var(--text-3); display: grid; place-items: center; cursor: pointer; border-radius: var(--radius-sm); }
.pwd-eye:hover { background: var(--surface-3); color: var(--text-2); }

/* logo brand chip */
.brand-logo { background: #fff; border-radius: 8px; padding: 9px 12px; display: flex; align-items: center; justify-content: center; }
.brand-logo img { width: 100%; height: auto; max-height: 38px; object-fit: contain; display: block; }
.brand-logo.lg { padding: 16px 22px; }
.brand-logo.lg img { max-height: 56px; }

/* ===== AREA CLIENTE ===== */
.cust-app { display: flex; flex-direction: column; height: 100vh; }
.cust-topbar { height: 62px; flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 24px; padding: 0 28px; }
.cust-tabs { display: flex; gap: 4px; margin-left: 8px; }
.cust-tabs button { border: none; background: none; font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--text-2); padding: 8px 14px; border-radius: var(--radius); cursor: pointer; display: inline-flex; align-items: center; gap: 7px; }
.cust-tabs button:hover { background: var(--surface-2); color: var(--text); }
.cust-tabs button.on { background: var(--accent-soft); color: var(--accent-d); }
.cust-topbar > .row-flex:last-child { margin-left: auto; }
.tab-badge { font-family: var(--mono); font-size: 11px; background: var(--accent); color: #fff; padding: 0 6px; border-radius: 20px; min-width: 18px; text-align: center; }
.cust-content { flex: 1; overflow-y: auto; padding: 28px; }
.cust-inner { max-width: 1080px; margin: 0 auto; }

.cust-hero { display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.cust-hero-ic { width: 56px; height: 56px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-d); display: grid; place-items: center; flex-shrink: 0; }
.cust-stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.cust-stat { background: var(--surface); padding: 15px 18px; }
.cust-stat .cs-k { font-family: var(--mono); font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); display: block; margin-bottom: 5px; }
.cust-stat .cs-v { font-size: 17px; font-weight: 600; }
.cust-cols { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: start; }

.cust-mac-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.cust-mac-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.cust-mac-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.cust-mac-foot { display: flex; justify-content: space-between; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.cust-mac-foot > div { display: flex; flex-direction: column; gap: 3px; }
.cust-mac-foot .cs-k { font-family: var(--mono); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }

.ticket-row { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.ticket-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--text-2); border-top: 1px solid var(--border); padding-top: 12px; }
.ticket-meta span { display: inline-flex; align-items: center; gap: 6px; }
.ticket-meta svg { color: var(--text-3); }
.ticket-meta .meta-ok { color: var(--ok); font-weight: 500; }
.ticket-meta .meta-ok svg { color: var(--ok); }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(20,32,46,.45); display: grid; place-items: center; z-index: 200; padding: 24px; backdrop-filter: blur(2px); }
.modal { width: 100%; max-width: 520px; background: var(--surface); border-radius: 12px; box-shadow: 0 20px 60px rgba(20,32,46,.3); overflow: hidden; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 16px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px 22px; max-height: 60vh; overflow-y: auto; }
.modal-body .login-field:last-child { margin-bottom: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ===== ALLEGATI (dropzone + chip) ===== */
.dropzone { display: flex; align-items: center; gap: 12px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); padding: 14px 16px; cursor: pointer; color: var(--text-2); font-size: 13px; transition: border-color .12s, background .12s; }
.dropzone:hover { border-color: var(--accent); background: var(--surface-2); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { font-weight: 600; color: var(--text); }
.allegati-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.allegato-chip { display: flex; align-items: center; gap: 11px; border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; background: var(--surface); }
.allegato-chip img { width: 38px; height: 38px; object-fit: cover; border-radius: var(--radius-sm); flex-shrink: 0; }
.allegato-ic { width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-d); display: grid; place-items: center; flex-shrink: 0; }
.allegato-info { flex: 1; min-width: 0; }
.allegato-nome { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.allegato-size { font-size: 11px; color: var(--text-3); }
.allegato-x { border: none; background: var(--surface-3); color: var(--text-2); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.allegato-x:hover { background: var(--danger-soft); color: var(--danger); }
/* allegati nella vista ticket */
.tk-allegati { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.tk-allegato { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 20px; padding: 4px 11px 4px 7px; font-size: 12px; color: var(--accent-d); text-decoration: none; background: var(--surface); }
.tk-allegato:hover { background: var(--accent-soft); border-color: var(--accent); }
.tk-allegato img { width: 22px; height: 22px; object-fit: cover; border-radius: 3px; }
/* fasi di lavorazione (vista cliente) */
.tk-fasi { border-left: 2px solid var(--accent); padding: 4px 0 4px 14px; margin: 0 0 12px; display: flex; flex-direction: column; gap: 10px; }
.tk-fasi-tit { font-family: var(--mono); font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); }
.tk-fase-meta { font-size: 11px; color: var(--text-3); margin-bottom: 2px; }
.tk-fase-testo { font-size: 13px; color: var(--text-2); line-height: 1.5; white-space: pre-wrap; }

/* ===== TOAST ===== */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 300; background: var(--text); color: #fff; padding: 13px 18px; border-radius: 8px; box-shadow: 0 10px 30px rgba(20,32,46,.35); display: flex; align-items: center; gap: 10px; font-size: 13.5px; max-width: 460px; animation: toastIn .25s ease; }
.toast svg { background: #fff; border-radius: 50%; padding: 1px; flex-shrink: 0; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
@media (max-width: 820px) { .login-wrap { grid-template-columns: 1fr; } .login-side { display: none; } }

/* ===== Hamburger (nascosto su desktop) ===== */
.hamburger { display: none; width: 40px; height: 40px; flex-shrink: 0; border: 1px solid var(--border); background: var(--surface); border-radius: var(--radius); color: var(--text-2); align-items: center; justify-content: center; cursor: pointer; margin-right: 2px; }
.hamburger:hover { background: var(--surface-2); }
.sidebar-scrim { display: none; }

/* ============================================================
   RESPONSIVE — TABLET (≤ 1024px): split a colonna singola
   ============================================================ */
@media (max-width: 1024px) {
  .split { grid-template-columns: 1fr; }
  .detail { position: static; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-row { grid-template-columns: 1fr !important; }
  .cust-cols { grid-template-columns: 1fr; }
}

/* ============================================================
   RESPONSIVE — CELLULARE (≤ 720px)
   ============================================================ */
@media (max-width: 720px) {
  /* --- Shell: la sidebar diventa un pannello a scomparsa --- */
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 80%; max-width: 290px;
    z-index: 120; transform: translateX(-100%); transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0,0,0,.4);
  }
  .app.menu-open .sidebar { transform: translateX(0); }
  .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(20,32,46,.5); z-index: 110; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .app.menu-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .hamburger { display: inline-flex; }

  /* --- Topbar --- */
  .topbar { height: auto; min-height: 56px; padding: 10px 14px; gap: 12px; }
  .topbar h1 { font-size: 16px; }
  .topbar .crumb { display: none; }
  .topbar .search { display: none !important; }

  .content { padding: 16px 14px 60px; }

  /* --- KPI: una colonna larga (2 se ci stanno) --- */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .kpi { padding: 13px 14px; }
  .kpi .val { font-size: 24px; }

  /* --- Toolbar di pagina: va a capo --- */
  .page-tools { gap: 8px; }
  .page-tools .seg { width: 100%; overflow-x: auto; }
  .page-tools .search { width: 100% !important; order: 5; }
  .tool-spacer { display: none; }
  .page-tools .btn { flex: 1; justify-content: center; }

  /* --- Tabelle: scroll orizzontale, niente troncamenti --- */
  .card > table.tbl { display: block; overflow-x: auto; white-space: nowrap; }
  table.tbl th, table.tbl td { padding: 10px 12px; }

  /* --- Dettaglio --- */
  .detail { position: static; }
  .field-grid { grid-template-columns: 1fr 1fr; }

  /* --- Finestre (modali) a tutto schermo --- */
  .modal-overlay { padding: 0; }
  .modal { max-width: 100% !important; width: 100%; height: 100%; border-radius: 0; display: flex; flex-direction: column; }
  .modal-body { flex: 1; max-height: none; }
  .form-row { grid-template-columns: 1fr; }

  /* --- AREA CLIENTE --- */
  .cust-topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; row-gap: 10px; }
  .cust-topbar > .cust-brand { flex: 1 1 auto; min-width: 0; }
  .cust-brand-text { min-width: 0; }
  .cust-brand-text > div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cust-actions { flex-shrink: 0; }
  .cust-tabs { order: 3; width: 100%; margin-left: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .cust-tabs button { white-space: nowrap; }
  .cust-content { padding: 16px 14px 60px; }
  .cust-hero { flex-wrap: wrap; }
  .cust-hero .btn { width: 100%; justify-content: center; }
  .cust-stat-grid { grid-template-columns: 1fr 1fr; }
  .cust-mac-grid { grid-template-columns: 1fr; }
  .ticket-meta { gap: 10px 16px; }

  /* --- Toast a tutta larghezza in basso --- */
  .toast { left: 14px; right: 14px; bottom: 14px; transform: none; max-width: none; }
  @keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
}

/* ===== Cellulari stretti (≤ 420px): KPI in colonna singola ===== */
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .cust-stat-grid { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
}
