/* KliqFlow 0.9 — gestionale */
:root {
  --bg: #f4f6fb; --panel: #fff; --ink: #18223a; --muted: #6f7d93; --line: #e6eaf2;
  --brand: #2563eb; --brand-ink: #fff; --brand-soft: #e9f0fe; --side: #141d33; --side-ink: #aab6d3;
  --ok: #17865a; --ok-soft: #e6f6ee; --warn: #9a5b12; --warn-soft: #fff5e6; --bad: #b4313f; --bad-soft: #fdeef0;
  --r: 14px; --shadow: 0 4px 20px #16274a0d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink); background: var(--bg); font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
[hidden] { display: none !important; }
a { color: var(--brand); }
h1, h2, h3 { letter-spacing: -.02em; margin: 0; }
h2 { font-size: 18px; margin-bottom: 14px; }
h3 { font-size: 15px; margin: 18px 0 10px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.55; }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }

/* pulsanti e campi */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 10px; padding: 10px 14px;
  background: #e9eef6; color: #223150; transition: filter .12s, transform .12s; text-decoration: none; display: inline-flex;
  align-items: center; justify-content: center; gap: 6px; line-height: 1.2;
}
button:hover:not(:disabled), .btn:hover { filter: brightness(.96); }
button:active:not(:disabled) { transform: scale(.98); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 3px 10px #2563eb26; }
.danger { background: var(--bad-soft); color: var(--bad); }
.ghost { background: transparent; color: var(--brand); padding: 6px 8px; }
.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.lg { padding: 15px 18px; font-size: 17px; }
.block { width: 100%; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff; border: 1px solid #d7deea; border-radius: 10px;
  padding: 10px 12px; width: 100%; min-width: 0; outline: none;
}
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px #2563eb1f; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand); vertical-align: middle; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: #3a4762; }
label.check .help { font-weight: 400; color: var(--muted); font-size: 12px; }
label.field .help { font-weight: 400; color: var(--muted); font-size: 12px; }
label.check { display: flex; gap: 9px; align-items: center; font-size: 14px; cursor: pointer; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

/* struttura */
.side {
  position: fixed; inset: 0 auto 0 0; width: 232px; background: var(--side); color: #fff; padding: 22px 14px;
  display: flex; flex-direction: column; gap: 4px; z-index: 5;
}
.logo { font-size: 22px; font-weight: 800; letter-spacing: -.03em; padding: 0 8px; display: flex; align-items: center; gap: 10px; }
.logo img { border-radius: 7px; flex: none; }
.brandmark { margin: 0 0 4px; line-height: 0; }
.brandmark img { height: 52px; width: auto; }
.logo span { color: #8b98ff; }
.shopname { color: var(--side-ink); font-size: 12.5px; padding: 4px 8px 18px; line-height: 1.5; display: flex; gap: 10px; align-items: center; }
.shopname b { color: #fff; font-weight: 600; }
.shop-logo { width: 42px; height: 42px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; flex: none; }
.hero-logo { width: 64px; height: 64px; object-fit: contain; background: #fff; border-radius: 14px; padding: 5px; flex: none; }
img.logo-prev { object-fit: contain; background: #fff; border: 1px solid var(--line); }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  color: var(--side-ink); text-decoration: none; padding: 11px 12px; border-radius: 10px; font-size: 14px;
  display: flex; gap: 10px; align-items: center; font-weight: 500;
}
.nav a:hover { background: #222e4c; color: #fff; }
.nav a.active { background: #33439f; color: #fff; }
.nav a.child { padding: 7px 12px 7px 42px; font-size: 13px; }
.subnav { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .18s ease; }
.subnav.open { grid-template-rows: 1fr; }
.subnav > div { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.subnav.open { margin: 2px 0 4px; }
.nav .caret { margin-left: auto; font-size: 11px; opacity: .7; transition: transform .18s; }
.nav a.expanded .caret { transform: rotate(90deg); }
.nav a.child .ico { display: none; }
tr.group td { background: #f3f5fb; font-weight: 700; font-size: 13px; color: #34405a; padding: 8px 12px; }
.nav .ico { width: 20px; text-align: center; opacity: .9; }
.nav .count { margin-left: auto; background: #f2a33a; color: #2a1800; font-size: 11px; font-weight: 800; border-radius: 20px; padding: 2px 7px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.netpill { font-size: 12px; border-radius: 20px; padding: 8px 12px; background: #1f2b47; color: #a7f0d3; border: 1px solid #2f3e60; }
.netpill.off { color: #ffd08a; }
.side-foot button { background: #1f2b47; color: var(--side-ink); font-size: 13px; }
main { margin-left: 232px; padding: 26px 30px 40px; max-width: 1500px; }
.head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.head h1 { font-size: 26px; }
.head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel.flush { padding: 0; overflow: hidden; }
.panel > h2:first-child { margin-top: 0; }
.cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(330px, 1fr); gap: 16px; align-items: start; }
.cols.even { grid-template-columns: 1fr 1fr; }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow); }
.kpi .k { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.kpi .v { font-size: 25px; font-weight: 800; letter-spacing: -.03em; margin-top: 8px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 3px; }
.hero {
  background: linear-gradient(115deg, #0b1b3f, #2563eb); color: #fff; border-radius: 18px; padding: 22px 24px;
  display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap;
}
.hero h2 { font-size: 22px; margin: 0 0 4px; }
.hero p { margin: 0; color: #dfe4ff; font-size: 13.5px; }
.hero button { background: #fff; color: #3443c4; }

/* tabelle */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
th { color: #75839a; font-weight: 600; font-size: 12px; background: #f8f9fd; text-transform: uppercase; letter-spacing: .04em; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f7f8ff; }
tr.off td { color: #a0a9b8; }
tr.off td.strike { text-decoration: line-through; }
td .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty { padding: 28px; text-align: center; color: var(--muted); font-size: 14px; }

.badge { display: inline-block; border-radius: 20px; padding: 3px 9px; font-size: 11.5px; font-weight: 700; background: #edf0f6; color: #4a5872; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--brand-soft); color: #3442b8; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: #fff; border: 1px solid #d9e0ec; color: #35435e; border-radius: 30px; padding: 7px 13px; font-size: 13px; font-weight: 600; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.notice { border-radius: 12px; padding: 11px 14px; font-size: 13.5px; background: var(--brand-soft); color: #2d3a9a; margin-bottom: 14px; line-height: 1.5; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list-row:last-child { border-bottom: 0; }

/* cassa */
.scan { display: flex; gap: 10px; }
.scan input { font-size: 18px; padding: 14px 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; margin-top: 14px; }
.tile {
  background: #f6f8fd; border: 1px solid #e5e9f3; border-radius: 12px; padding: 12px; text-align: left; display: flex;
  flex-direction: column; gap: 5px; align-items: stretch; min-height: 82px; font-weight: 500;
}
.tile b { font-size: 14px; line-height: 1.3; }
.tile small { color: var(--muted); font-size: 12px; }
.tile .p { font-weight: 800; color: var(--ink); font-size: 14px; margin-top: auto; }
.tiles-head { grid-column: 1 / -1; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #6b7891; margin-top: 4px; }
.tiles-head span { text-transform: none; letter-spacing: 0; font-weight: 500; }
.tiles-more { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); text-align: center; padding: 6px; }
.tile.svc { background: #ecf8f1; border-color: #cdeadb; }
.tile.none { opacity: .45; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.cart-line .n { font-weight: 600; font-size: 14px; }
.qty { display: flex; align-items: center; gap: 4px; font-weight: 700; }
.qty button { padding: 5px 10px; background: var(--brand-soft); color: #3746c7; min-width: 32px; }
.qty span { min-width: 26px; text-align: center; }
.total-box { display: flex; justify-content: space-between; align-items: center; background: var(--brand-soft); border-radius: 14px; padding: 16px 18px; margin: 14px 0; }
.total-box .t { font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.sticky { position: sticky; top: 16px; }
.payments .chip { padding: 9px 14px; }

/* grafico */
.chart svg { width: 100%; height: auto; display: block; }
.bar { fill: var(--brand); }
.bar:hover { fill: #2f3fc4; }
.axis { fill: var(--muted); font-size: 10px; }
.hbar { height: 8px; background: #edf0f7; border-radius: 6px; overflow: hidden; margin-top: 5px; }
.hbar i { display: block; height: 100%; background: var(--brand); border-radius: 6px; }

/* prenotazioni */
.order { border: 1px solid var(--line); border-radius: 14px; padding: 15px; display: flex; flex-direction: column; gap: 8px; background: #fff; }
.orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.order .who { font-weight: 700; font-size: 15px; }
.order .lines { font-size: 13.5px; background: #f7f8fc; border-radius: 10px; padding: 9px 11px; line-height: 1.6; }
.thumb.big { width: 96px; height: 96px; border-radius: 12px; font-size: 30px; }
.photo-box { display: flex; gap: 14px; align-items: center; background: #f7f8fc; border-radius: 12px; padding: 12px; }
img.thumb { display: block; }
.thumb { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: #eef1f6; display: grid; place-items: center; color: #9aa5b8; font-size: 18px; }

/* finestre */
.overlay { position: fixed; inset: 0; background: #0d152a73; z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { background: #fff; border-radius: 18px; width: min(520px, 100%); box-shadow: 0 25px 70px #0b142a40; animation: pop .14s ease-out; }
.modal.wide { width: min(820px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px; }
.modal header h2 { margin: 0; font-size: 18px; }
.modal header button { background: transparent; font-size: 20px; padding: 4px 9px; color: var(--muted); }
.modal .body { padding: 10px 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fafbfe; border-radius: 0 0 18px 18px; }
.modal .err { color: var(--bad); font-size: 13.5px; min-height: 0; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.toast { background: #18223a; color: #fff; border-radius: 12px; padding: 12px 15px; font-size: 14px; box-shadow: 0 10px 30px #0b142a40; animation: pop .15s; line-height: 1.45; }
.toast.ok { background: #136b49; }
.toast.bad { background: #a72a38; }
.toast.warn { background: #8a520f; }

/* accesso */
.auth { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #e6e9ff, var(--bg) 60%); }
.auth .card { width: min(430px, 100%); background: #fff; border-radius: 22px; padding: 30px; box-shadow: 0 20px 60px #16274a1f; display: flex; flex-direction: column; gap: 12px; }
.auth h1 { font-size: 26px; }
.auth .err { color: var(--bad); font-size: 13.5px; }

.drawer { display: contents; }
.nav a.only-m { display: none; }
.acts .more-m { display: none; }
.menubtn { display: none; }
.cartbar { display: none; }

@media (max-width: 1100px) {
  .cols, .cols.even { grid-template-columns: 1fr; }
  .sticky { position: static; }
  /* cassa su tablet verticale e telefono: totale sempre a portata di dito */
  .cartbar:not([hidden]) { display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 8;
    background: var(--side); color: #fff; border-radius: 16px; padding: 10px 10px 10px 18px; align-items: center; justify-content: space-between;
    gap: 10px; box-shadow: 0 10px 30px #0b142a55; transition: transform .2s, opacity .2s; }
  .cartbar.away { transform: translateY(140%); opacity: 0; pointer-events: none; }
  .cartbar b { font-size: 19px; }
  #view:has(.cartbar:not([hidden])) { padding-bottom: 80px; }
}
@media (max-width: 1100px) and (min-width: 821px) { .cartbar:not([hidden]) { left: calc(232px + 16px); } }

@media (max-width: 820px) {
  /* barra superiore + menu a scomparsa */
  .side { position: sticky; top: 0; inset: auto; width: auto; height: auto; flex-direction: row; align-items: center; justify-content: space-between;
    padding: max(10px, env(safe-area-inset-top)) 14px 10px; }
  .logo { font-size: 20px; padding: 0; }
  .menubtn { display: inline-flex; position: relative; background: #24304f; color: #fff; font-size: 20px; padding: 7px 14px; border-radius: 10px; }
  .menubtn.alert::after, .menubtn[data-count]:not([data-count=""])::after { content: ''; position: absolute; top: 5px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: #f2a33a; }
  .drawer { display: none; position: fixed; inset: calc(56px + env(safe-area-inset-top)) 0 0 0; background: var(--side); overflow-y: auto; z-index: 30;
    flex-direction: column; gap: 4px; padding: 12px 14px calc(20px + env(safe-area-inset-bottom)); }
  body.navopen .drawer { display: flex; }
  body.navopen { overflow: hidden; }
  .nav a { padding: 13px 12px; font-size: 15.5px; }
  .nav a.child { padding: 11px 12px 11px 44px; font-size: 14.5px; }
  .nav a.only-m { display: flex; }
  .side-foot { margin-top: 18px; }
  main { margin: 0; padding: 16px 12px 30px; }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .head { margin-bottom: 14px; }
  .head h1 { font-size: 22px; }
  .panel { padding: 15px; border-radius: 15px; }
  .hero { padding: 18px; }
  .hero h2 { font-size: 19px; }
  .kpi .v { font-size: 21px; }
  /* Safari su iPhone/iPad ingrandisce la pagina se il testo dei campi è sotto i 16px */
  input, select, textarea { font-size: 16px; }
  .modal footer { flex-wrap: wrap; }
  .overlay { padding: 3vh 10px; }
  /* tabelle: su schermo stretto restano solo le colonne essenziali */
  .t-prod.own th:nth-child(2), .t-prod.own td:nth-child(2), .t-prod.own th:nth-child(5), .t-prod.own td:nth-child(5),
  .t-prod.own th:nth-child(6), .t-prod.own td:nth-child(6), .t-prod.own th:nth-child(8), .t-prod.own td:nth-child(8),
  .t-prod.staff th:nth-child(1), .t-prod.staff td:nth-child(1), .t-prod.staff th:nth-child(5), .t-prod.staff td:nth-child(5),
  .t-hist th:nth-child(3), .t-hist td:nth-child(3), .t-hist th:nth-child(4), .t-hist td:nth-child(4),
  .t-sup th:nth-child(2), .t-sup td:nth-child(2), .t-sup th:nth-child(3), .t-sup td:nth-child(3),
  .t-cat th:nth-child(3), .t-cat td:nth-child(3), .t-cat th:nth-child(7), .t-cat td:nth-child(7),
  .t-rec th:nth-child(4), .t-rec td:nth-child(4), .t-rec th:nth-child(5), .t-rec td:nth-child(5),
  .t-bolla th:nth-child(2), .t-bolla td:nth-child(2) { display: none; }
  tr.group td { display: table-cell !important; }
  td .acts { justify-content: flex-end; }
  .t-prod .acts button { display: none; }
  .t-prod .acts .more-m { display: inline-flex; font-size: 18px; padding: 4px 12px; }
  th, td { padding: 10px 8px; }
}
@media (max-width: 480px) { .t-prod.own th:nth-child(1), .t-prod.own td:nth-child(1):not([colspan]) { display: none; } .g2, .g3, .g4 { grid-template-columns: 1fr; } .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (pointer: coarse) { input, select, textarea { font-size: 16px; } .qty button { min-width: 40px; padding: 8px 12px; } }
