:root {
  --bg: #f2f5f8; --card: #fff; --ink: #1f2933; --muted: #6b7683;
  --line: #e2e8f0; --brand: #17356b; --brand-d: #0f2547;
  --accent: #e8551f; --accent-d: #c74615; --slate: #6b7c8c;
  --warn: #b45309; --danger: #c0392b; --ok: #157347;
  --radius: 10px; --shadow: 0 1px 3px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; }
header { background: #fff; color: var(--ink); padding: 10px 18px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line); }
header .brand { display: flex; align-items: center; gap: 12px; }
header .logo { height: 30px; display: block; }
header .app-tag { font-size: 12px; color: var(--muted); font-weight: 600;
  border-left: 1px solid var(--line); padding-left: 12px; letter-spacing: .04em; }
header .badge { font-size: 12px; padding: 4px 10px; border-radius: 20px;
  background: #eef2f6; color: var(--muted); }
nav { display: flex; flex-wrap: wrap; gap: 4px; background: var(--brand);
  padding: 0 10px; }
nav button { background: transparent; border: none; color: #c3d0e6; padding: 11px 14px;
  cursor: pointer; font-size: 14px; border-bottom: 3px solid transparent; }
nav button:hover { color: #fff; }
nav button.active { color: #fff; border-bottom-color: var(--accent); font-weight: 600; }
main { max-width: 1000px; margin: 18px auto; padding: 0 14px; }
.view { display: none; }
.view.active { display: block; }
.card { background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 15px; font-family: inherit; background: #fff; }
input:focus, select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 140px; }
button.btn, a.btn { background: var(--accent); color: #fff; border: none; padding: 10px 18px;
  border-radius: 8px; font-size: 15px; cursor: pointer; font-weight: 600;
  text-decoration: none; display: inline-block; }
button.btn:hover, a.btn:hover { background: var(--accent-d); }
button.btn.ghost { background: #eef2f5; color: var(--ink); }
button.btn.ghost:hover { background: #e2e8f0; }
button.btn.danger { background: var(--danger); }
button.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; }
tr:hover td { background: #fafcfd; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px;
  font-weight: 600; }
.st-ARRIVATO { background:#e0e7ff; color:#3730a3; }
.st-ABBINATO { background:#dcfce7; color:#166534; }
.st-NON_ABBINATO { background:#fee2e2; color:#991b1b; }
.st-DDT_EMESSO { background:#fef3c7; color:#92400e; }
.st-CARICATO { background:#dbeafe; color:#1e40af; }
.st-IN_CONSEGNA { background:#cffafe; color:#155e75; }
.st-RITIRABILE { background:#bbf7d0; color:#14532d; }
.st-ANNULLATO { background:#e5e7eb; color:#6b7280; text-decoration:line-through; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: center; }
.tile .n { font-size: 28px; font-weight: 700; color: var(--brand); }
.tile .l { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.scan-input { font-size: 20px; padding: 14px; text-align: center; letter-spacing: 1px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1f2933; color: #fff; padding: 12px 20px; border-radius: 8px; z-index: 50;
  box-shadow: 0 4px 14px rgba(0,0,0,.25); font-size: 14px; opacity: 0; transition: opacity .2s;
  max-width: 90%; }
.toast.show { opacity: 1; }
.toast.ok { background: var(--ok); } .toast.err { background: var(--danger); }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 22px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content:''; position:absolute; left:-7px; top:12px; width:12px; height:12px;
  border-radius: 50%; background: var(--brand); }
.timeline .t { font-size: 12px; color: var(--muted); }
.result-box { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-top: 14px; }
.result-box.ok { border-color: #86efac; background: #f0fdf4; }
.result-box.warn { border-color: #fcd34d; background: #fffbeb; }
.result-box.err { border-color: #fca5a5; background: #fef2f2; }
.kv { display: flex; gap: 8px; font-size: 14px; padding: 2px 0; }
.kv b { min-width: 150px; color: var(--muted); font-weight: 500; }
#reader { margin-top: 12px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
#loginScreen { display: none; position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(135deg, var(--brand), var(--brand-d));
  align-items: center; justify-content: center; padding: 16px; }
#loginScreen.show { display: flex; }
.login-box { background: #fff; padding: 26px; border-radius: 14px; width: 340px;
  max-width: 100%; box-shadow: 0 12px 40px rgba(0,0,0,.3); }
.login-box h2 { font-size: 22px; }
