/* Impianto e componenti della console. Usa solo le variabili di tema.css.
   Tre larghezze: sopra 900px barra laterale fissa; sotto, cassetto con il bottone menu;
   sotto 720px le tabelle diventano schede. */

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh; background: var(--bg); color: var(--fg);
  font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
body::before { content: ""; position: fixed; inset: 0; background: var(--deco); pointer-events: none; z-index: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- guscio ---------- */
.app { position: relative; z-index: 1; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--side-line) transparent;
  display: flex; flex-direction: column; gap: 2px; padding: 18px 12px;
  background: var(--side-bg); color: var(--side-fg); border-right: 1px solid var(--side-line);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.logo { display: flex; align-items: center; gap: 8px; padding: 0 8px 16px; color: inherit; text-decoration: none; }
.logo svg { width: 26px; height: 26px; flex: none; }
.logo span { font-family: var(--font-brand); font-weight: 500; font-size: 20px; letter-spacing: -.045em; }
.nav-h { font-size: 11px; font-weight: 500; letter-spacing: .04em; color: var(--side-muted); padding: 14px 10px 4px; }
.nav a {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px;
  border-radius: var(--radius-sm); color: inherit; text-decoration: none; font-weight: 500; transition: background .15s;
}
.nav a:hover { background: var(--side-active); }
.nav a svg { width: 16px; height: 16px; opacity: .7; flex: none; }
.nav a[aria-current="page"] { background: var(--side-active); color: var(--side-active-fg); }
.nav a .count { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--side-line); display: grid; gap: 8px; }
.me { display: flex; align-items: center; gap: 10px; padding: 4px 6px; font-size: 13px; min-width: 0; }
.me i { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 600; color: #fff; background: linear-gradient(135deg, var(--brand-sand), var(--brand-terracotta)); }
.me > div { min-width: 0; }
.me small { display: block; color: var(--side-muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.mobile-bar { display: none; }
.scrim { display: none; }

.main { min-width: 0; padding: 26px 32px 56px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 20px; }
.page-head .grow { flex: 1 1 auto; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
h1 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: var(--track); line-height: 1.1; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side {
    position: fixed; z-index: 30; left: 0; top: 0; width: min(84vw, 300px);
    transform: translateX(-105%); transition: transform .25s ease;
    background: var(--panel-solid); box-shadow: var(--shadow);
  }
  .menu-open .side { transform: none; }
  .menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 25; background: var(--overlay); }
  .mobile-bar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 20;
    padding: 10px 14px; background: var(--side-bg); border-bottom: 1px solid var(--side-line);
    backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  }
  .mobile-bar .logo { padding: 0; margin-right: auto; }
  .main { padding: 18px 16px 48px; }
  h1 { font-size: 24px; }
}
@media (max-width: 560px) {
  .actions { width: 100%; }
  .actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------- comandi ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--panel); color: var(--fg);
  font-weight: 500; cursor: pointer; white-space: nowrap; transition: transform .1s, background .15s;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.btn:hover { background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-pri { background: var(--btn-pri); color: var(--accent-fg); border-color: transparent; box-shadow: var(--btn-pri-glow); }
.btn-pri:hover { background: var(--btn-pri); filter: brightness(1.06); }
.btn-icon { width: var(--tap); min-height: var(--tap); padding: 0; }
.btn-icon svg { width: 18px; height: 18px; }
@media (pointer: coarse) { .btn { min-height: var(--tap); } }

.input {
  min-height: 36px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel-2); color: var(--fg); min-width: 0;
}
.input::placeholder { color: var(--muted); }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-sm); background: var(--panel-2); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 4px 11px; border-radius: calc(var(--radius-sm) - 3px); color: var(--muted); font-size: 12.5px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--panel-solid); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }

.switch { position: relative; width: 34px; height: 20px; flex: none; border: 0; padding: 0; border-radius: 99px; background: var(--line); cursor: pointer; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: left .2s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { left: 16px; }

/* ---------- superfici ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); min-width: 0;
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.card-head .grow { flex: 1 1 auto; }
.card-head small { color: var(--muted); }
.card-body { padding: var(--pad) 18px; }
@media (max-width: 560px) { .card-head { padding: 12px 14px; } .card-body { padding: var(--pad) 14px; } .card-head .input { flex: 1 1 100%; } }

.notice {
  display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; margin-bottom: 20px; font-size: 13px; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
}
.notice b { color: var(--fg); font-weight: 500; }
.notice .live { margin-top: 5px; }

.live { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--ok); position: relative; }
.live::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ok); opacity: 0; animation: ping 2s infinite; }
.live.warn { background: var(--warn); } .live.warn::after { border-color: var(--warn); }
@keyframes ping { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(1.6); opacity: 0; } }

/* ---------- griglie ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 360px); gap: var(--gap); align-items: start; }
@media (max-width: 1180px) { .split { grid-template-columns: minmax(0, 1fr); } .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.kpi { position: relative; overflow: hidden; padding: 16px 18px 14px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { margin-top: 6px; font-size: 30px; font-weight: 600; letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi .sub { margin-top: 6px; font-size: 12px; color: var(--muted); }
.kpi .up { color: var(--ok); font-weight: 600; }
.kpi .spark { position: absolute; right: 12px; bottom: 12px; width: 90px; height: 30px; }
@media (max-width: 560px) {
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 22px; }
  .kpi .spark { display: none; }
}

/* ---------- etichette ---------- */
.tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 500; line-height: 18px; white-space: nowrap; }
.tag.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-pos { color: var(--info); background: var(--info-soft); }
.tag-delivery { color: var(--accent); background: var(--accent-soft); }
.tag-ok { color: var(--ok); background: var(--ok-soft); }
.tag-warn { color: var(--warn); background: var(--warn-soft); }
.tag-err { color: var(--err); background: var(--err-soft); }
.tag-mute { color: var(--muted); background: var(--panel-2); }
.tag-fake { color: var(--muted); background: transparent; border: 1px dashed var(--line); }

/* ---------- tabelle: sotto 720px diventano schede ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
.data th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.data td { padding: 0 14px; height: var(--row); border-bottom: 1px solid var(--line); white-space: nowrap; }
.data tr:last-child td { border-bottom: 0; }
.data tbody tr { transition: background .12s; }
.data tbody tr:hover td { background: var(--panel-2); }
.data .num { text-align: right; font-family: var(--font-mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.data .handle { width: 24px; color: var(--muted); opacity: .5; cursor: grab; }
.data tr.is-hidden .item { opacity: .45; }
.item { display: flex; align-items: center; gap: 10px; min-width: 0; }
.item .thumb { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); font-size: 11px; font-weight: 600; color: var(--muted); }
.item b { display: block; font-weight: 500; }
.item small { display: block; color: var(--muted); font-size: 12px; }
.item .missing { color: var(--warn); }
.chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11px; font-weight: 500; padding: 2px 7px; border-radius: var(--radius-xs); }
.chip.yes { color: var(--ok); background: var(--ok-soft); }
.chip.no { color: var(--muted); background: var(--panel-2); text-decoration: line-through; }

@media (max-width: 720px) {
  .data thead { display: none; }
  .data, .data tbody, .data tr, .data td { display: block; }
  .data tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  .data tr:last-child { border-bottom: 0; }
  .data td { height: auto; padding: 0; border: 0; white-space: normal; }
  .data td.handle { display: none; }
  .data td[data-label] { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; font-size: 12.5px; }
  .data td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 11.5px; }
  .data td.lead { grid-column: 1 / -1; }
  .data td.num { text-align: left; }
  .data tbody tr:hover td { background: none; }
}

/* ---------- flusso degli ordini ---------- */
.feed { list-style: none; margin: 0; padding: 4px 0; }
.feed li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; padding: 11px 18px; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed li.new { animation: arrive .6s ease-out; }
@keyframes arrive { from { opacity: 0; transform: translateY(-8px); background: var(--accent-soft); } to { opacity: 1; transform: none; } }
.feed .id { font-family: var(--font-mono); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.feed .amount { font-family: var(--font-mono); font-size: 13px; font-weight: 500; text-align: right; }
.feed .meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
@media (max-width: 560px) { .feed li { padding: 10px 14px; } }

.mix-bar { display: flex; gap: 2px; height: 8px; border-radius: 99px; overflow: hidden; }
.mix-bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; }

#marchioScelto { width: 100%; max-width: 100%; box-sizing: border-box; margin-bottom: 8px; }

/* TT.4.13: la console aperta dentro una bolla di prova: banda fissa in alto. */
.bolla-console-scenario { font-weight: 400; }
.bolla-console-banda { flex-wrap: wrap; position: sticky; top: 0; z-index: 50; display: flex; gap: 12px; align-items: center; justify-content: center; padding: 6px 12px; background: #b45309; color: #fff; font-weight: 600; font-size: 13px; }
.bolla-console-banda.chiusa { background: #7f1d1d; }
.bolla-console-esci { border: 1px solid #fff; background: transparent; color: inherit; border-radius: 6px; padding: 2px 10px; cursor: pointer; }
