:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1c2530;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #0f5c6e;
  --primary-2: #13788f;
  --primary-soft: #e3f1f4;
  --accent: #e07a2f;
  --accent-soft: #fdf0e6;
  --ok: #15803d;
  --ok-soft: #e7f6ec;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --info: #1d4ed8;
  --info-soft: #e5edff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 30, 50, .06), 0 4px 14px rgba(15, 30, 50, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary-2); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

/* ---------- Striscia demo ---------- */
.demo-bar {
  background: #1c2530; color: #cbd5e1; font-size: 12.5px;
  display: flex; align-items: center; gap: 10px; padding: 6px 16px; flex-wrap: wrap;
}
.demo-bar b { color: #fff; }
.demo-bar .sp { flex: 1; }
.demo-bar button {
  background: transparent; border: 1px solid #475569; color: #e2e8f0;
  border-radius: 999px; padding: 3px 10px; font-size: 12px;
}
.demo-bar button:hover { background: #334155; }

/* ---------- Layout ---------- */
.topbar {
  background: var(--primary); color: #fff;
  padding: 12px 16px; display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; background: #fff; color: var(--primary);
  display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none;
}
.brand-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; opacity: .8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .sp { flex: 1; }
.topnav { display: flex; gap: 4px; }
.topnav a {
  color: #fff; text-decoration: none; padding: 7px 12px; border-radius: 999px; font-size: 14px; opacity: .85; white-space: nowrap;
}
.topnav a.on { background: rgba(255,255,255,.18); opacity: 1; font-weight: 600; }

main { max-width: 1100px; margin: 0 auto; padding: 18px 16px 150px; }
.narrow { max-width: 720px; }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  text-decoration: none; color: var(--muted); font-size: 11.5px; text-align: center;
  padding: 8px 0 9px; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative;
}
.bottomnav a.on { color: var(--primary); font-weight: 600; }
.bottomnav svg { width: 22px; height: 22px; }
.bottomnav .badge-dot {
  position: absolute; top: 4px; left: 50%; margin-left: 6px;
  background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700;
  border-radius: 999px; padding: 0 6px; min-width: 18px; line-height: 17px;
}

/* ---------- Componenti ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card, .stack > * + * { margin-top: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.b { font-weight: 700; }
.right { text-align: right; }
.mt { margin-top: 14px; }
.mt-s { margin-top: 6px; }
.mb { margin-bottom: 14px; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 600;
  background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.accent { background: var(--accent); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.big { padding: 14px 18px; font-size: 16px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: default; }

.badge {
  display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  background: #eef2f6; color: #475569;
}
.badge.ricevuto { background: var(--info-soft); color: var(--info); }
.badge.preparazione { background: var(--warn-soft); color: var(--warn); }
.badge.caricato { background: var(--accent-soft); color: #9a4a10; }
.badge.consegnato { background: var(--ok-soft); color: var(--ok); }
.badge.new { background: var(--accent); color: #fff; }
.badge.sconto { background: var(--ok-soft); color: var(--ok); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 13px; font-size: 13.5px; white-space: nowrap;
}
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }

.input, select.input, textarea.input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff;
}
.input:focus { outline: 2px solid var(--primary-2); outline-offset: -1px; }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); }
.search .input { padding-left: 36px; }

.list > .item { padding: 12px 0; border-top: 1px solid var(--line); }
.list > .item:first-child { border-top: 0; padding-top: 2px; }
.list > .item:last-child { padding-bottom: 2px; }
a.item, .item.link { display: block; color: inherit; text-decoration: none; }
.item.link:hover, a.item:hover { background: #fafbfc; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; flex: none; }
.stepper button { border: 0; background: #fff; width: 36px; height: 36px; font-size: 19px; color: var(--primary); }
.stepper button:hover { background: var(--primary-soft); }
.stepper span { min-width: 30px; text-align: center; font-weight: 700; }
.add-btn { border: 0; background: var(--primary-soft); color: var(--primary); border-radius: 10px; height: 38px; padding: 0 14px; font-weight: 600; flex: none; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi .v { font-size: 22px; font-weight: 750; margin-top: 2px; }
.kpi .l { font-size: 12.5px; color: var(--muted); }

.hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.hero .muted { color: rgba(255,255,255,.8); }

.giro-head { display: flex; align-items: center; gap: 10px; }
.giro-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl-wrap { overflow-x: auto; }

.sticky-cart {
  position: fixed; left: 12px; right: 12px; bottom: 70px; z-index: 25;
  max-width: 696px; margin: 0 auto;
}
.sticky-cart a {
  display: flex; align-items: center; justify-content: space-between; text-decoration: none;
  background: var(--accent); color: #fff; padding: 13px 16px; border-radius: 12px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(224,122,47,.35);
}

.steps { display: flex; gap: 6px; margin: 10px 0 2px; }
.steps .s { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps .s.on { background: var(--primary-2); }
.steps-l { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); }

.lot { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; background: #f1f5f9; padding: 1px 6px; border-radius: 5px; white-space: nowrap; color: #334155; text-decoration: none; }
a.lot:hover { background: var(--primary-soft); color: var(--primary); }

.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: #1c2530; color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; z-index: 100;
  transition: all .25s ease; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: var(--muted); font-size: 14px; margin-bottom: 10px; }

/* ---------- Accesso ---------- */
.login-wrap { min-height: calc(100vh - 32px); display: grid; place-items: center; padding: 24px 16px; }
.login { width: 100%; max-width: 860px; }
.login-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.role-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 20px; }
.role-card h2 { margin-bottom: 4px; }
.client-pick { display: grid; gap: 8px; margin-top: 14px; max-height: 360px; overflow: auto; }
.client-pick button {
  text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
}
.client-pick button:hover { border-color: var(--primary-2); background: var(--primary-soft); }
.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; align-items: start; }
.giri-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; align-items: start; }

@media (max-width: 900px) {
  .giri-grid { grid-template-columns: 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .login-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; }
  .topbar .topnav { order: 3; width: 100%; overflow-x: auto; }
  h1 { font-size: 20px; }
  .hide-m { display: none !important; }
}
@media (min-width: 701px) {
  .hide-d { display: none !important; }
}

@media print {
  .demo-bar, .topbar, .bottomnav, .no-print, .toast { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; padding: 0; }
}

/* i figli delle griglie non devono allargare la pagina (tabelle larghe scorrono nel loro riquadro) */
.two-col > *, .giri-grid > *, .login-grid > * { min-width: 0; }
@media (max-width: 700px) {
  .client-pick { max-height: none; overflow: visible; }
}
