:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #121212;
  --ink-2: #4b5260;
  --muted: #7a8290;
  --line: #e2e5ea;
  --accent: #E5011A;        /* rosso Dealer Pneumatici */
  --accent-dark: #b80015;
  --accent-ink: #ffffff;
  --accent-soft: #fde8ea;
  --link: #121212;
  --blue: #1d4ea8;   --blue-soft: #e8eefb;
  --green: #12805c;  --green-soft: #e3f4ec;
  --red: #c42b2b;    --red-soft: #fbe9e9;
  --amber: #a15c00;  --amber-soft: #fdf1dc;
  --grey-soft: #eceef1;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--link); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent); }
h1 { font-size: 24px; margin: 8px 0 16px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
code { background: var(--grey-soft); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
address { font-style: normal; line-height: 1.6; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-top: 20px; padding-bottom: 32px; }

/* Barra superiore */
.topbar { background: #fff; color: var(--ink); border-bottom: 3px solid var(--accent); box-shadow: 0 1px 0 var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: inherit; letter-spacing: -.01em; }
.brand, .brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark { width: 22px; height: 22px; border-radius: 50%; border: 5px solid var(--ink); box-shadow: inset 0 0 0 3px var(--accent); }
.brand-sub { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding-left: 12px; border-left: 1px solid var(--line); }
.brand.big { font-size: 22px; }
.brand-logo { display: inline-flex; align-items: center; height: 46px; }
.brand-logo img { display: block; height: 100%; width: auto; max-width: 200px; object-fit: contain; }
.brand.big .brand-logo { height: 72px; }
.brand.big .brand-sub { border: 0; padding: 0; }
.login-box .brand.big { flex-direction: column; align-items: flex-start; gap: 14px; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { color: var(--ink-2); padding: 8px 12px; border-radius: 8px; font-weight: 600; text-decoration: none; }
.topbar nav a:hover { color: var(--ink); background: var(--grey-soft); }
.topbar nav a.on { color: #fff; background: var(--ink); }
.pill { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 12px; text-align: center; line-height: 20px; }

/* Superfici */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.empty { text-align: center; padding: 40px 16px; color: var(--ink-2); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h1 { margin-right: auto; }
.summary { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }

/* Avvisi */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid transparent; }
.alert.ok { background: var(--green-soft); color: var(--green); border-color: #bfe5d3; }
.alert.error { background: var(--red-soft); color: var(--red); border-color: #f2c4c4; }
.alert.warn { background: var(--amber-soft); color: var(--amber); border-color: #f3d9a8; }
.alert.info { background: var(--blue-soft); color: var(--blue); border-color: #c9d6f7; }

/* Moduli */
input, select, textarea {
  font: inherit; color: inherit; background: #fff;
  border: 1px solid #cfd4dc; border-radius: 8px; padding: 8px 10px; min-height: 38px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--ink); outline-offset: -1px; border-color: var(--ink); }
label { display: block; font-size: 13px; color: var(--ink-2); font-weight: 500; }
label > input, label > select, label > textarea { margin-top: 4px; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--ink); white-space: nowrap; }
label.check input { width: auto; min-height: 0; }
.stack { display: grid; gap: 12px; }
.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.grid-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.grid-form .span2 { grid-column: span 2; }
.actions { display: flex; justify-content: flex-end; margin-top: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  padding: 8px 14px; min-height: 38px; border-radius: 8px;
  border: 1px solid #cfd4dc; background: #fff; color: var(--ink); white-space: nowrap;
}
.btn { text-decoration: none; }
.btn:hover { background: var(--grey-soft); color: var(--ink); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.sm { padding: 6px 10px; min-height: 34px; font-size: 13px; }
.btn.big { padding: 12px 22px; font-size: 16px; }
.btn.link { background: none; border-color: transparent; color: var(--ink); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px; padding-left: 4px; padding-right: 4px; font-weight: 500; }
.btn.link:hover { color: var(--accent); background: none; }
.btn.danger, .btn.link.danger { color: var(--muted); text-decoration-color: var(--muted); }
.btn.link.danger:hover { color: var(--red); }

/* Ricerca */
.search-main { display: flex; gap: 8px; }
.search-main input { font-size: 16px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.filters select { width: auto; max-width: 190px; }
.size { display: inline-flex; align-items: center; gap: 4px; }
.size select { width: 122px; }
.size span { color: var(--muted); font-weight: 600; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 10px; color: var(--ink-2); }
.results-head .sort label { display: inline-flex; align-items: center; gap: 8px; }
.results-head .sort select { width: auto; margin: 0; }

/* Tabelle */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
table.products, table.orders { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th { text-align: left; border-top: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafbfc; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.clickable { cursor: pointer; }
.clickable:hover td { background: #f8f9fb; }
.row-warn td { background: var(--amber-soft); }
.cart td { padding: 10px 8px; }
.cart th { padding: 8px; }
.cart input[type=number] { width: 76px; text-align: right; }

.prod-brand { font-weight: 700; letter-spacing: .01em; }
.prod-model { font-weight: 500; color: var(--ink-2); }
.prod-desc { color: var(--ink); }
.ref { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; }
.tags .ref { margin: 0 0 0 4px; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; background: var(--grey-soft); color: var(--ink-2); }
.tag.t-summer { background: #fff3d6; color: #8a5a00; }
.tag.t-winter { background: #e2efff; color: #1a4f9c; }
.tag.t-all { background: #e6f4ea; color: #1d6b3a; }
.price { font-weight: 700; font-size: 16px; }
.stock { display: inline-block; min-width: 34px; padding: 2px 6px; border-radius: 6px; background: var(--green-soft); color: var(--green); font-weight: 600; text-align: center; }
.stock.low { background: var(--amber-soft); color: var(--amber); }
.add-form { display: flex; gap: 6px; justify-content: flex-end; }
.add-form input { width: 64px; text-align: right; }
td.add { width: 1%; white-space: nowrap; text-align: right; }

.eu-row { display: inline-flex; gap: 4px; align-items: center; }
.eu { display: inline-block; width: 22px; height: 22px; line-height: 22px; text-align: center; border-radius: 4px; font-size: 12px; font-weight: 700; color: #fff; background: #9aa1ac; }
.eu-a { background: #1a9641; } .eu-b { background: #77c34a; } .eu-c { background: #d4c21f; color: #222; }
.eu-d { background: #f0a12a; } .eu-e { background: #e05a26; }
.eu-db { font-size: 12px; color: var(--ink-2); margin-left: 2px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.b-green { background: var(--green-soft); color: var(--green); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-grey { background: var(--grey-soft); color: var(--ink-2); }

.cart-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-top: 12px; flex-wrap: wrap; }
.totals { display: grid; grid-template-columns: auto auto; gap: 4px 24px; margin: 12px 0 0 auto; width: max-content; font-variant-numeric: tabular-nums; }
.totals dt { color: var(--ink-2); }
.totals dd { margin: 0; text-align: right; }
.totals .strong { font-size: 17px; color: var(--ink); }
.confirm { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.confirm p { margin: 0; max-width: 620px; }
.tracking-box { margin-top: 14px; display: grid; gap: 8px; justify-items: start; }

.pager { display: flex; justify-content: center; align-items: center; gap: 16px; margin: 16px 0; color: var(--ink-2); }

.muted, .muted-link { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.bad { color: var(--red); }
.ok-text { color: var(--green); margin-top: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }

.footer { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; color: var(--muted); font-size: 13px; padding-bottom: 24px; }

.login-box { max-width: 360px; margin: 10vh auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login-box .brand { color: var(--ink); margin-bottom: 20px; }
.login-box .btn { width: 100%; }

/* Telefono: le tabelle diventano schede */
@media (max-width: 820px) {
  .summary { grid-template-columns: 1fr; }
  .grid-form { grid-template-columns: 1fr 1fr; }
  table.products, table.orders, table.cart { border: 0; background: none; box-shadow: none; }
  table.products thead, table.orders thead, table.cart thead { display: none; }
  table.products tr, table.orders tr, table.cart tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 12px; margin-bottom: 10px;
  }
  table.cart tr { border-color: var(--line); }
  table.products td, table.orders td, table.cart td { border: 0; padding: 0; text-align: left; }
  table.products td:first-child, table.orders td:first-child, table.cart td:first-child { grid-column: 1 / -1; }
  td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  td.add { grid-column: 1 / -1; width: auto; }
  .add-form { justify-content: stretch; }
  .add-form .btn { flex: 1; }
  .filters select { max-width: none; flex: 1 1 140px; }
  .size { flex: 1 1 100%; }
  .size select { flex: 1; width: auto; }
}
@media (max-width: 520px) {
  .grid-form { grid-template-columns: 1fr; }
  .grid-form .span2 { grid-column: auto; }
  .topbar nav a { padding: 6px 8px; }
  .search-main .btn { padding: 8px 12px; }
}

/* Installazione */
.install { max-width: 860px; }
.install fieldset { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px; margin: 0; }
.install legend { font-weight: 700; padding: 0 6px; }
.checks { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 6px; }
.checks li.ok { color: var(--green); }
.checks li.ko { color: var(--red); font-weight: 600; }
.copybox { display: flex; align-items: center; gap: 8px; background: var(--ink); border-radius: 8px; padding: 10px 10px 10px 14px; margin-bottom: 16px; }
.copybox code { flex: 1; background: none; color: #fff; font-size: 13px; word-break: break-all; padding: 0; }
.step { margin-bottom: 6px; }

.mt { margin-top: 20px; }
.h-ref { font-size: 16px; font-weight: 600; color: var(--ink-2); }
.ref-form { display: flex; width: 100%; }
.ref-form input { flex: 1; }
