@font-face { font-family: Editorial; src: url(/editorial.otf) format('opentype'); font-display: swap; }
:root {
  --paper: #f5efe5; --card: #fbf8f2; --white: #fff; --ink: #344f54; --ink-2: #4c6569; --rust: #a65330; --muted: #747771; --line: #e2dbcf; --line-2: #d3cbbd;
  --good: #3d7a55; --good-bg: #e3efe5; --bad: #b4442e; --bad-bg: #f6e1da; --warn: #9a6a12; --warn-bg: #f5ead0;
  --serif: Editorial, Georgia, serif; --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 10px; --side: 232px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 14px/1.45 var(--sans); }
a { color: var(--rust); }
h1, h2, h3, h4 { font-weight: 400; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button, .button { cursor: pointer; border: 1px solid var(--line-2); background: var(--white); border-radius: 8px; padding: 8px 14px; min-height: 38px; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; color: var(--ink); white-space: nowrap; }
button:hover, .button:hover { border-color: var(--ink); }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
button.primary:hover { background: #26393d; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: #0000000a; }
button.danger { color: var(--bad); }
button.small { min-height: 30px; padding: 4px 10px; font-size: 13px; }
button.icon { width: 36px; padding: 0; justify-content: center; font-size: 20px; line-height: 1; }
button.add { width: 100%; border-style: dashed; background: transparent; justify-content: center; margin: 8px 0 14px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }
input, select, textarea { border: 1px solid var(--line-2); background: var(--white); border-radius: 8px; padding: 8px 10px; min-height: 38px; width: 100%; }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--ink); }
input[type=file] { border: 0; padding: 4px 0; background: none; }
input.num { text-align: right; max-width: 110px; }
input.diff { border-color: var(--rust); background: #fff6f2; }
textarea { resize: vertical; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.spacer { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.print-only { display: none; }

/* layout */
.layout { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 30; }
.brand { padding: 22px 26px 14px; } .brand img { width: 130px; display: block; }
.sidebar nav { flex: 1; overflow-y: auto; padding: 6px 10px; display: grid; align-content: start; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.sidebar nav a:hover { background: #0000000a; }
.sidebar nav a.on { background: var(--ink); color: #fff; }
.sidebar .ic { width: 18px; text-align: center; opacity: .75; }
.me { border-top: 1px solid var(--line); padding: 12px 14px 12px 20px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.me small { color: var(--muted); }
.topbar { display: none; }
.scrim { display: none; }
.content { margin-left: var(--side); padding: 26px 32px 60px; max-width: 1500px; }

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px #0003; }
  .menu-open .sidebar { transform: none; }
  .menu-open .scrim { display: block; position: fixed; inset: 0; background: #20313566; z-index: 25; }
  .topbar { display: flex; position: sticky; top: 0; z-index: 20; align-items: center; gap: 8px; padding: 6px 12px; background: rgba(245,239,229,.96); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
  .topbar span { flex: 1; font: 20px var(--serif); }
  .topbar img { height: 30px; }
  .content { margin-left: 0; padding: 16px 16px 60px; }
}

/* pagina */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font: 400 40px/1.05 var(--serif); letter-spacing: -1px; }
.page-head p { margin: 6px 0 0; max-width: 720px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-title { font: 400 24px var(--serif); margin: 26px 0 10px; } .section-title small { font: 13px var(--sans); color: var(--muted); }
h3.sub { font: 400 21px var(--serif); margin: 18px 0 8px; }
h4 { font-weight: 600; margin: 14px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head h3 { font: 400 20px var(--serif); }
.grid { display: grid; gap: 16px; } .grid > .card { margin-bottom: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); margin-bottom: 16px; }
.grid.four { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); margin-bottom: 16px; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.empty.error { color: var(--bad); }
.note { background: var(--warn-bg); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.page > .note:first-child { margin-top: 0; }

/* indicatori */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis.small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin: 12px 0; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpi.click { cursor: pointer; } .kpi.click:hover { border-color: var(--ink); }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { font: 400 28px/1.15 var(--serif); margin-top: 4px; letter-spacing: -.5px; overflow-wrap: anywhere; }
.kpis.small .kpi-value { font-size: 22px; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.good .kpi-value { color: var(--good); } .kpi.bad .kpi-value { color: var(--bad); } .kpi.warn .kpi-value { color: var(--warn); }
.kpi.accent { background: var(--ink); color: #fff; border-color: var(--ink); } .kpi.accent .kpi-label, .kpi.accent .kpi-sub { color: #ffffffb0; }
.badge { display: inline-block; font-size: 11px; line-height: 1.5; padding: 1px 8px; border-radius: 20px; background: #0000000d; color: var(--ink-2); white-space: nowrap; vertical-align: 1px; }
.badge.good { background: var(--good-bg); color: var(--good); } .badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.be-card .be-row { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.bar { height: 10px; background: #0000000f; border-radius: 10px; overflow: hidden; margin-bottom: 6px; }
.bar > div { height: 100%; background: var(--rust); border-radius: 10px; } .bar > div.ok { background: var(--good); }
.chart { position: relative; width: 100%; }
.rank { margin: 0; padding-left: 20px; } .rank li { padding: 5px 0; border-bottom: 1px solid var(--line); } .rank li span { display: inline-block; max-width: 70%; }
.rank b { float: right; font-weight: 500; }
.legend-notes p { margin: 6px 0; font-size: 13px; }
.cause { display: inline-block; font-size: 11px; background: #0000000a; padding: 1px 6px; border-radius: 4px; margin: 1px 4px 1px 0; }

/* tab, filtri, chip */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); }
.tabs button.on { color: var(--rust); border-bottom-color: var(--rust); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select, .filters input[type=search] { width: auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.chips button { border-radius: 20px; min-height: 32px; padding: 4px 12px; font-size: 13px; background: transparent; }
.chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chips input { width: auto; flex: 1; min-width: 160px; }
.chip-btn { border-radius: 20px; min-height: 28px; padding: 2px 10px; font-size: 12px; margin: 2px; }
.period { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.period select, .period input { width: auto; min-height: 36px; padding: 6px 8px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; user-select: none; min-height: 36px; }

/* tabelle */
.table-wrap { min-width: 0; }
.table-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.table-tools input { max-width: 280px; }
.table-tools .muted { flex: 1; font-size: 12px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-2); cursor: pointer; white-space: nowrap; user-select: none; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th.r, td.r { text-align: right; white-space: nowrap; }
tbody tr.click { cursor: pointer; } tbody tr.click:hover { background: #ffffffaa; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line-2); border-bottom: 0; }
tr.void td { color: var(--muted); text-decoration: line-through; text-decoration-color: #0003; }
tr.warn td:first-child { box-shadow: inset 3px 0 var(--bad); }
tr.best td { background: var(--good-bg); }
td.empty { padding: 24px; }
.clip { display: inline-block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.lines-table td { padding: 6px 6px; } .lines-table .field { margin: 0; } .lines-table .field > span:first-child:empty { display: none; }
.inv-table input.num { max-width: 120px; margin-left: auto; display: block; }
.pl-table td small { display: block; font-size: 11px; color: var(--muted); }
.pl-table tr.strong td { font-weight: 600; } .pl-table tr.subtotal td { background: #ffffff90; border-top: 1px solid var(--line-2); }
.pl-table tr.detail td:first-child { padding-left: 26px; color: var(--ink-2); } .pl-table tr.detail td { font-size: 12.5px; }
.pl-table tr.info td { color: var(--muted); font-style: italic; } .pl-table tr.group td:first-child { font-weight: 500; }
.pl-table tr.sep td { border-top: 2px solid var(--line-2); }
.pl-table tr.result td { font-size: 15px; }

/* form */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 12px 14px; margin-bottom: 12px; }
.form-grid.compact { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.field { display: grid; gap: 4px; align-content: start; min-width: 0; }
.field > span:first-child { font-size: 12px; color: var(--muted); }
.field > small { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.field.wide { grid-column: 1 / -1; }
.suffix-wrap, .qty-input { display: flex; align-items: stretch; }
.suffix-wrap input, .qty-input input { border-top-right-radius: 0; border-bottom-right-radius: 0; min-width: 0; }
.suffix-wrap em, .qty-input em { font-style: normal; display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--line-2); border-left: 0; border-radius: 0 8px 8px 0; background: #f0ebe2; color: var(--muted); font-size: 12px; white-space: nowrap; }
.qty-input select { width: auto; border-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; background: #f0ebe2; }
.suffix-wrap:not(:has(em)) input { border-radius: 8px; }
.picker { position: relative; }
.picker ul { position: absolute; z-index: 50; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--white); border: 1px solid var(--line-2); border-radius: 8px; max-height: 280px; overflow-y: auto; box-shadow: 0 10px 30px #0002; min-width: 240px; }
.picker li { padding: 8px 10px; border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.picker li:hover { background: var(--paper); } .picker li small { color: var(--muted); }
dl.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0 0 12px; }
dl.facts dt { color: var(--muted); } dl.facts dd { margin: 0; }
.total-line { margin-right: auto; } .total-line strong { font: 400 22px var(--serif); margin-left: 6px; }

/* finestre */
dialog.modal { border: 0; padding: 0; background: transparent; width: calc(100% - 24px); max-width: 640px; max-height: calc(100dvh - 24px); }
dialog.modal.wide { max-width: 1040px; }
dialog.modal::backdrop { background: #20313577; backdrop-filter: blur(2px); }
.modal-box { background: var(--paper); border-radius: 14px; display: flex; flex-direction: column; max-height: calc(100dvh - 24px); box-shadow: 0 30px 80px #0004; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 10px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font: 400 26px var(--serif); letter-spacing: -.3px; }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; padding: 12px 20px; border-top: 1px solid var(--line); background: var(--card); border-radius: 0 0 14px 14px; }
@media (max-width: 600px) {
  dialog.modal, dialog.modal.wide { width: 100%; max-width: none; max-height: 100dvh; margin: 0; height: 100dvh; }
  .modal-box { border-radius: 0; max-height: 100dvh; height: 100%; }
  .modal-foot { border-radius: 0; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 32px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; } .kpi-value { font-size: 22px; }
}

/* vendite */
.sale-layout { display: grid; grid-template-columns: 1fr 330px; gap: 18px; }
@media (max-width: 800px) { .sale-layout { grid-template-columns: 1fr; } }
.dish-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.dish-btn { position: relative; flex-direction: column; align-items: flex-start; justify-content: space-between; white-space: normal; text-align: left; min-height: 72px; padding: 10px 12px; gap: 4px; }
.dish-btn small { color: var(--muted); }
.dish-btn.on { border-color: var(--ink); background: #e9efef; }
.dish-btn b { position: absolute; top: -7px; right: -7px; background: var(--rust); color: #fff; border-radius: 20px; min-width: 24px; height: 24px; display: grid; place-items: center; font-size: 12px; padding: 0 6px; }
.sale-lines { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; align-self: start; }
.sale-lines h3 { font: 400 20px var(--serif); margin-bottom: 6px; }
.sale-line { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: center; }
.sl-price { grid-column: 1 / -1; display: flex; gap: 6px; } .sl-price input { min-height: 32px; padding: 4px 8px; }
.stepper { display: flex; align-items: center; } .stepper button { width: 34px; min-height: 34px; padding: 0; justify-content: center; font-size: 18px; }
.stepper input { width: 52px; text-align: center; min-height: 34px; padding: 4px; border-radius: 0; border-left: 0; border-right: 0; }
.stepper button:first-child { border-radius: 8px 0 0 8px; } .stepper button:last-child { border-radius: 0 8px 8px 0; }

/* accesso */
.login { max-width: 340px; margin: 12vh auto 0; padding: 0 16px; text-align: center; }
.login img { width: 190px; } .login h1 { font: 400 30px var(--serif); margin: 10px 0 24px; }
.login form { display: grid; gap: 10px; } .login .error { color: var(--bad); min-height: 20px; }

/* avvisi */
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 1000; width: max-content; max-width: calc(100% - 32px); }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: 0 10px 30px #0003; }
.toast.error { background: var(--bad); }

/* stampa / PDF */
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .sidebar, .topbar, .actions, .tabs, .filters, .table-tools, .toasts, .chips, button, .modal-foot { display: none !important; }
  .content { margin: 0; padding: 0; max-width: none; }
  .card, .kpi { border-color: #ccc; background: #fff; break-inside: avoid; }
  .print-only { display: block; font: 400 22px var(--serif); margin-bottom: 10px; }
  dialog.modal[open] { position: static; width: 100%; max-width: none; max-height: none; height: auto; }
  dialog.modal[open] ~ * { display: none; }
  .modal-box { box-shadow: none; max-height: none; }
  .table-scroll { overflow: visible; }
}

/* righe di ricette/ordini/presenze impilate su schermi stretti */
@media (max-width: 700px) {
  .lines-table, .lines-table tbody, .lines-table tfoot { display: block; }
  .lines-table thead { display: none; }
  .lines-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px 8px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
  .lines-table td { border: 0; padding: 0; }
  .lines-table td:first-child { grid-column: 1 / -1; }
  .lines-table tfoot tr { grid-template-columns: 1fr auto; }
  .lines-table tfoot td:first-child { grid-column: auto; }
  .lines-table input.num { max-width: none; }
}
