* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: #f4f6f9; color: #1e293b; min-height: 100vh; font-size: 14px; }
input, textarea, button, select { font-family: inherit; }
.screen { display: none; } .screen.on { display: block; }
.hidden-file { position: fixed; opacity: 0; pointer-events: none; top: -100px; }
#s-login { display: none; min-height: 100vh; align-items: center; justify-content: center; padding: 2rem; }
#s-login.on { display: flex; }
#s-loading { display: none; min-height: 100vh; align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 2rem; }
#s-loading.on { display: flex; }
.lbox { background: #fff; border: 1px solid #e2e8f0; border-radius: 16px; padding: 2.5rem 2rem; width: 100%; max-width: 340px; text-align: center; box-shadow: 0 4px 24px rgba(0,0,0,.07); }
.lbox h2 { font-size: 18px; font-weight: 600; color: #0f172a; margin-bottom: 4px; }
.lbox p { font-size: 13px; color: #94a3b8; margin-bottom: 1.8rem; }
.pin-wrap { position: relative; margin-bottom: 10px; }
.pin-wrap input { width: 100%; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 44px 12px 16px; font-size: 15px; color: #0f172a; outline: none; }
.pin-wrap input:focus { border-color: #f97316; background: #fff; }
.eye-btn { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 16px; }
.lbtn { width: 100%; padding: 12px; background: #f97316; color: #fff; border: none; border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.lbtn:hover { background: #ea6a00; } .lbtn:disabled { opacity: .5; }
.lerr { color: #ef4444; font-size: 12px; margin-top: 8px; min-height: 18px; }
.hdr { display: flex; align-items: center; gap: 10px; padding: 12px 20px; border-bottom: 1px solid #e2e8f0; background: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.hdr h1 { font-size: 14px; font-weight: 600; color: #0f172a; }
.hdr small { font-size: 11px; color: #94a3b8; display: block; }
.ai-badge { margin-left: auto; font-size: 10px; color: #16a34a; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 20px; padding: 3px 10px; display: flex; align-items: center; gap: 5px; }
.ai-badge::before { content: ''; width: 5px; height: 5px; background: #22c55e; border-radius: 50%; }
.logout-btn { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 11px; padding: 4px 8px; border-radius: 5px; margin-left: 8px; }
.logout-btn:hover { color: #64748b; background: #f1f5f9; }
.tabs { display: flex; gap: 3px; padding: 12px 20px 0; border-bottom: 1px solid #e2e8f0; background: #fff; }
.tab { padding: 7px 16px; border-radius: 7px 7px 0 0; font-size: 12px; font-weight: 500; border: none; cursor: pointer; background: transparent; color: #94a3b8; }
.tab.on { background: #f4f6f9; color: #0f172a; border: 1px solid #e2e8f0; border-bottom: 1px solid #f4f6f9; margin-bottom: -1px; font-weight: 600; }
.tcnt { background: #e2e8f0; border-radius: 9px; padding: 1px 6px; font-size: 10px; margin-left: 4px; color: #64748b; }
.body { padding: 20px; max-width: 960px; margin: 0 auto; }
.step { font-size: 13px; font-weight: 600; color: #0f172a; margin: 18px 0 8px; display: flex; align-items: center; gap: 8px; }
.step:first-child { margin-top: 0; }
.stepn { width: 22px; height: 22px; border-radius: 50%; background: #f97316; color: #fff; font-size: 12px; display: inline-flex; align-items: center; justify-content: center; }
.dz { border: 1.5px dashed #cbd5e1; border-radius: 12px; padding: 2rem; text-align: center; background: #fff; transition: all .2s; margin-bottom: 10px; cursor: pointer; }
.dz:hover, .dz.over { border-color: #f97316; background: #fff7ed; }
.dz-icon { width: 44px; height: 44px; background: #f1f5f9; border-radius: 10px; margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; }
.dz h3 { font-size: 14px; font-weight: 500; color: #334155; margin-bottom: 5px; }
.dz small { font-size: 12px; color: #94a3b8; display: block; }
.dz-small { padding: 12px 16px; margin: 0; text-align: left; flex: 1; min-width: 220px; }
.dz-small b { font-size: 13px; color: #334155; font-weight: 600; }
.prev-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.prev-or { font-size: 12px; color: #94a3b8; flex: 1; min-width: 200px; }
.prev-status { font-size: 12px; margin: 8px 0 4px; min-height: 4px; }
.fpill { display: inline-flex; align-items: center; gap: 8px; background: #f1f5f9; border: 1px solid #e2e8f0; border-radius: 8px; padding: 7px 12px; font-size: 12px; color: #64748b; margin-bottom: 4px; }
.fpill b { color: #334155; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fpill button { background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 18px; line-height: 1; }
.agrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; margin-top: 12px; }
.af label { display: block; font-size: 10px; color: #64748b; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.af input, .af select { width: 100%; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 7px; padding: 7px 9px; font-size: 13px; color: #0f172a; outline: none; }
.af input:focus, .af select:focus { border-color: #f97316; background: #fff; }
.af input.filled, .af select.filled { background: #fff7ed; border-color: #fed7aa; }
.btn { padding: 8px 16px; border-radius: 8px; font-size: 12px; font-weight: 500; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.big { padding: 12px 24px; font-size: 14px; font-weight: 600; }
.bpri { background: #f97316; color: #fff; } .bpri:not(:disabled):hover { background: #ea6a00; }
.bgho { background: #fff; color: #475569; border: 1px solid #e2e8f0; } .bgho:hover { background: #f8fafc; color: #1e293b; }
.bsm { padding: 5px 10px; font-size: 11px; }
.spin { width: 36px; height: 36px; border: 2px solid #e2e8f0; border-top-color: #f97316; border-radius: 50%; animation: sp .8s linear infinite; margin: 0 auto 14px; }
.spin.mini { width: 14px; height: 14px; margin: 0 6px 0 0; display: inline-block; vertical-align: middle; }
@keyframes sp { to { transform: rotate(360deg); } }
.spin-msg { font-size: 13px; color: #64748b; }
.spin-sub { font-size: 11px; color: #94a3b8; margin-top: 6px; }
.slbl { font-size: 10px; font-weight: 700; color: #94a3b8; text-transform: uppercase; letter-spacing: 1px; margin: 22px 0 8px; }
.cgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.ctitle { font-size: 10px; color: #94a3b8; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 10px; }
.fr { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; border-bottom: 1px solid #f1f5f9; gap: 10px; }
.fr:last-child { border: none; }
.fl { font-size: 12px; color: #64748b; }
.fv { font-size: 12px; color: #0f172a; font-weight: 600; text-align: right; max-width: 60%; }
.fv.miss { color: #cbd5e1; font-style: italic; font-weight: 400; }
.fv.hi { color: #f97316; }

/* Semaforo */
.sem { display: flex; align-items: center; gap: 16px; border-radius: 12px; padding: 16px 18px; border: 2px solid; }
.sem .luce { width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 -3px 6px rgba(0,0,0,.15); }
.sem h2 { font-size: 17px; font-weight: 700; }
.sem p { font-size: 12px; margin-top: 3px; }
.sem.verde { background: #f0fdf4; border-color: #22c55e; color: #14532d; } .sem.verde .luce { background: #22c55e; }
.sem.giallo { background: #fefce8; border-color: #eab308; color: #713f12; } .sem.giallo .luce { background: #eab308; }
.sem.rosso { background: #fef2f2; border-color: #ef4444; color: #7f1d1d; } .sem.rosso .luce { background: #ef4444; }
.ctab { width: 100%; border-collapse: collapse; font-size: 12px; }
.ctab th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; color: #94a3b8; padding: 9px 12px; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
.ctab td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.ctab tr:last-child td { border-bottom: none; }
.ctab td:first-child { font-weight: 600; color: #334155; white-space: nowrap; }
.ctab .sub { display: block; font-size: 11px; color: #94a3b8; font-weight: 400; margin-top: 2px; }
.ctab tr.rosso td { background: #fef2f2; }
.ctab tr.giallo td { background: #fefce8; }
.esito { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot.verde { background: #22c55e; } .dot.giallo { background: #eab308; } .dot.rosso { background: #ef4444; } .dot.grigio { background: #cbd5e1; }
.alert { display: flex; align-items: center; gap: 8px; border-radius: 8px; padding: 9px 12px; margin-bottom: 6px; font-size: 12px; font-weight: 500; }
.alert.verde { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.alert.giallo { background: #fefce8; border: 1px solid #fde68a; color: #854d0e; }
.alert.rosso { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }
.alert.info { background: #eff6ff; border: 1px solid #bfdbfe; color: #1d4ed8; }

.notes-box { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px; }
.notes-box textarea { width: 100%; background: transparent; border: none; outline: none; color: #334155; font-size: 12px; line-height: 1.6; resize: vertical; min-height: 70px; }
.refbar { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 9px; padding: 10px 14px; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.refbar .reflbl { font-size: 11px; color: #c2410c; font-weight: 600; }
.refbar input[type=text], .refbar input[type=email] { flex: 1; min-width: 160px; background: #fff; border: 1px solid #fed7aa; border-radius: 7px; padding: 6px 10px; font-size: 12px; outline: none; }
.refbar label { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #c2410c; cursor: pointer; white-space: nowrap; }
.ebox { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; overflow: hidden; }
.ehdr { padding: 10px 14px; border-bottom: 1px solid #f1f5f9; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; background: #f8fafc; }
.emeta { font-size: 11px; color: #64748b; line-height: 1.8; }
.emeta b { color: #334155; }
.ccrow { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ccrow input { background: #fff; border: 1px solid #e2e8f0; border-radius: 5px; padding: 2px 7px; font-size: 11px; outline: none; width: 170px; }
.ebody { padding: 14px; font-size: 12px; color: #334155; line-height: 1.7; white-space: pre-wrap; font-family: monospace; max-height: 240px; overflow-y: auto; }
.actbar { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 16px; padding-bottom: 2rem; }
.hi { background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px 14px; margin-bottom: 7px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.hi:hover { border-color: #f97316; }
.hi-nm { font-size: 12px; font-weight: 600; color: #0f172a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hi-sb { font-size: 10px; color: #94a3b8; margin-top: 2px; }
.hdel { background: none; border: none; color: #cbd5e1; cursor: pointer; font-size: 16px; padding: 3px 6px; border-radius: 4px; }
.hdel:hover { color: #ef4444; background: #fef2f2; }
.empty { text-align: center; padding: 3rem; font-size: 13px; color: #94a3b8; }
.toast { position: fixed; bottom: 16px; right: 16px; background: #1e293b; border-radius: 8px; padding: 10px 16px; font-size: 12px; color: #fff; opacity: 0; transition: opacity .25s; z-index: 99; max-width: 320px; pointer-events: none; }
.toast.on { opacity: 1; } .toast.err { background: #ef4444; } .toast.ok { background: #16a34a; }

@media (max-width: 700px) {
  .cgrid { grid-template-columns: 1fr; }
  .agrid { grid-template-columns: 1fr 1fr; }
  .body { padding: 14px; }
  .actbar .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }
}
@media print {
  body { background: #fff; font-size: 12px; }
  .no-print, .tabs { display: none !important; }
  .hdr { position: static; box-shadow: none; }
  .card, .ctab tr { break-inside: avoid; }
  .sem, .ctab tr.rosso td, .ctab tr.giallo td, .dot, .alert { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
