.mysagre-app {
  --bg: #111827;
  --panel: #1f2937;
  --line: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --green: #22c55e;
  --blue: #38bdf8;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  width: min(1100px, calc(100vw - 32px));
  max-width: none;
  position: relative;
  left: 0;
  transform: none;
  margin: 0 auto;
}

.mysagre-kitchen-board { max-width: 1180px; }
.mysagre-board-status { margin: 14px 2px; }
.mysagre-board-table-wrap { overflow-x: auto; }
.mysagre-board-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.mysagre-board-table th { padding: 10px 12px; text-align: center; color: #64748b; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.mysagre-board-table th:first-child { text-align: left; }
.mysagre-board-table td { padding: 12px; background: #f8fafc; text-align: center; font-size: 1.15rem; font-weight: 800; }
.mysagre-board-table td:first-child { width: 52%; text-align: left; border-radius: 12px 0 0 12px; }
.mysagre-board-table td:last-child { border-radius: 0 12px 12px 0; }
.mysagre-board-table select { width: 100%; min-height: 46px; padding: 8px 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: #0f172a; font: inherit; font-weight: 700; }
.mysagre-board-table td[data-field="riserva"] { color: #1d4ed8; }
.mysagre-board-table td[data-field="venduti"] { color: #111827; }
.mysagre-board-table td[data-field="daFare"] { color: #c2410c; }
.mysagre-board-table td[data-field="rimanenza"] { color: #166534; }

@media (max-width: 720px) {
  .mysagre-board-table { min-width: 760px; }
  .mysagre-kitchen-board .mysagre-header { align-items: center; }
}

.mysagre-app * {
  box-sizing: border-box;
}

.mysagre-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.mysagre-header strong {
  display: block;
  font-size: 18px;
  text-transform: uppercase;
}

.mysagre-muted,
.mysagre-header div {
  color: var(--muted);
}

.mysagre-warning {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(250, 204, 21, .45);
  border-left: 6px solid #facc15;
  border-radius: 6px;
  background: rgba(250, 204, 21, .12);
  color: #fde68a;
  font-weight: 700;
  line-height: 1.45;
}

.mysagre-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  margin-top: 16px;
}

.mysagre-app label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 12px;
}

.mysagre-app input,
.mysagre-app select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #e5e7eb;
  color: #111827;
  min-height: 42px;
  padding: 8px 10px;
}

.mysagre-two {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mysagre-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0 12px;
}

.mysagre-tabs button,
.mysagre-app button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.mysagre-tabs button {
  padding: 10px 14px;
  background: #334155;
  color: var(--text);
  white-space: nowrap;
}

.mysagre-tabs button.active {
  background: var(--blue);
  color: #082f49;
}

.mysagre-tabs button.mysagre-category-mangiare {
  background: #14532d;
  color: #dcfce7;
}

.mysagre-tabs button.mysagre-category-bere {
  background: #075985;
  color: #e0f2fe;
}

.mysagre-tabs button.mysagre-category-contorni {
  background: #581c87;
  color: #f3e8ff;
}

.mysagre-tabs button.mysagre-category-mangiare.active {
  background: #22c55e;
  color: #052e16;
}

.mysagre-tabs button.mysagre-category-bere.active {
  background: #38bdf8;
  color: #082f49;
}

.mysagre-tabs button.mysagre-category-contorni.active {
  background: #c084fc;
  color: #2e1065;
}

.mysagre-products {
  display: grid;
  gap: 8px;
}

.mysagre-product {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 64px;
  padding: 12px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  border: 1px solid var(--line);
}

.mysagre-product-info {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.mysagre-product-info:disabled {
  cursor: not-allowed;
}

.mysagre-product-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex: 0 0 auto;
}

.mysagre-product-price {
  min-width: 66px;
  text-align: right;
  white-space: nowrap;
}

.mysagre-quantity-control {
  display: grid;
  grid-template-columns: 36px 28px 36px;
  align-items: center;
  gap: 3px;
}

.mysagre-quantity-control button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #1f6fae;
  color: white;
  font-size: 24px;
  line-height: 1;
  font-weight: 800;
}

.mysagre-quantity-control button:disabled {
  opacity: .35;
  cursor: default;
}

.mysagre-product-quantity {
  min-width: 28px;
  text-align: center;
  font-size: 17px;
}

.mysagre-product:nth-child(even) {
  background: color-mix(in srgb, var(--panel) 86%, white 14%);
}

.mysagre-product.mysagre-category-mangiare {
  border-left: 7px solid #22c55e;
  background: linear-gradient(90deg, rgba(34, 197, 94, .22), var(--panel) 38%);
}

.mysagre-product.mysagre-category-bere {
  border-left: 7px solid #38bdf8;
  background: linear-gradient(90deg, rgba(56, 189, 248, .22), var(--panel) 38%);
}

.mysagre-product.mysagre-category-contorni {
  border-left: 7px solid #c084fc;
  background: linear-gradient(90deg, rgba(192, 132, 252, .24), var(--panel) 38%);
}

.mysagre-product.mysagre-category-mangiare:nth-child(even) {
  background: linear-gradient(90deg, rgba(34, 197, 94, .30), color-mix(in srgb, var(--panel) 86%, white 14%) 38%);
}

.mysagre-product.mysagre-category-bere:nth-child(even) {
  background: linear-gradient(90deg, rgba(56, 189, 248, .30), color-mix(in srgb, var(--panel) 86%, white 14%) 38%);
}

.mysagre-product.mysagre-category-contorni:nth-child(even) {
  background: linear-gradient(90deg, rgba(192, 132, 252, .32), color-mix(in srgb, var(--panel) 86%, white 14%) 38%);
}

.mysagre-product small {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.mysagre-product.low-stock {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, .22);
  border-left-color: #f59e0b;
}

.mysagre-product.low-stock small {
  color: #fbbf24;
}

.mysagre-product.unavailable {
  cursor: not-allowed;
  opacity: 1;
  background: rgba(239, 68, 68, .24);
  border-color: #ef4444;
  border-left-color: #ef4444;
  color: #fecaca;
}

.mysagre-product.unavailable small {
  color: #fca5a5;
}

.mysagre-cart {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  align-self: start;
}

.mysagre-cart h3 {
  display: flex;
  justify-content: space-between;
  margin: 0 0 12px;
  font-size: 18px;
}

.mysagre-app-preordini #mysagre-cart-rows {
  display: none;
}

.mysagre-cart-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.mysagre-cart-row button {
  height: 34px;
  background: #ef4444;
  color: white;
}

#mysagre-create,
#mysagre-close,
#mysagre-ospiti-create {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
  background: var(--green);
  color: #052e16;
}

#mysagre-create:disabled {
  opacity: .45;
  cursor: default;
}

#mysagre-ospiti-create:disabled {
  opacity: .45;
  cursor: default;
}

.mysagre-app-ospiti {
  --bg: #10201b;
  --panel: #183328;
  --line: #2f5f4c;
  --muted: #b7d8c8;
  --green: #38bdf8;
  --blue: #22c55e;
}

.mysagre-app-preordini {
  --bg: #111827;
  --panel: #1f2937;
  --line: #334155;
  --green: #22c55e;
  --blue: #38bdf8;
}

.mysagre-order-result {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 700;
}

.mysagre-order-result.waiting {
  color: #facc15;
}

.mysagre-order-result.success {
  color: #86efac;
}

.mysagre-order-result.error {
  color: #fca5a5;
}

.mysagre-guest-access {
  max-width: 460px;
}

.mysagre-guest-access button {
  width: 100%;
  min-height: 46px;
  background: var(--green);
  color: #052e16;
}

.mysagre-refresh {
  min-height: 40px;
  padding: 0 18px;
  background: var(--blue);
  color: #082f49;
}

.mysagre-stats {
  --bg: #171326;
  --panel: #241f3a;
  --line: #4c416e;
  --muted: #c4b5fd;
  --green: #a3e635;
  --blue: #c084fc;
}

.mysagre-stat-period {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
}

.mysagre-stat-period label {
  margin: 0;
}

.mysagre-stat-period button {
  min-height: 42px;
  padding: 0 18px;
  background: var(--green);
  color: #052e16;
}

.mysagre-stat-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.mysagre-stat-cards article,
.mysagre-stat-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.mysagre-stat-cards span {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.mysagre-stat-cards strong {
  display: block;
  margin-top: 4px;
  font-size: 26px;
}

.mysagre-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.mysagre-stat-panel h3 {
  margin: 0 0 10px;
  font-size: 17px;
}

.mysagre-stat-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.mysagre-stat-row:last-child {
  border-bottom: 0;
}

.mysagre-stat-row strong {
  text-align: right;
  white-space: nowrap;
}

.mysagre-stat-row small {
  display: block;
  color: var(--muted);
}

.mysagre-stat-orders {
  margin-top: 12px;
}

.mysagre-table-scroll {
  overflow-x: auto;
}

.mysagre-stat-orders table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
}

.mysagre-stat-orders th,
.mysagre-stat-orders td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.mysagre-stat-orders th {
  color: var(--muted);
}

.mysagre-dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: var(--text);
  max-width: 420px;
  width: calc(100% - 32px);
  text-align: center;
  padding: 24px;
}

.mysagre-dialog::backdrop {
  background: rgba(0, 0, 0, .65);
}

.mysagre-call-alert {
  display: grid;
  gap: 5px;
  margin: 12px 0;
  padding: 12px;
  border: 2px solid #fbbf24;
  border-radius: 8px;
  background: rgba(251, 191, 36, .18);
  color: #fef3c7;
}

.mysagre-call-alert[hidden] {
  display: none;
}

.mysagre-call-alert strong {
  font-size: 20px;
}

.mysagre-call-alert span {
  font-size: 17px;
  font-weight: 700;
}

.mysagre-final-message {
  display: grid;
  place-items: center;
  gap: 10px;
  min-height: 240px;
  border-radius: 8px;
  border: 2px solid var(--line);
  padding: 18px;
  font-weight: 800;
}

.mysagre-final-message strong {
  font-size: 28px;
}

.mysagre-final-message span {
  color: var(--muted);
  font-size: 18px;
}

.mysagre-final-message.success {
  border-color: #22c55e;
  background: rgba(34, 197, 94, .16);
  color: #bbf7d0;
}

.mysagre-final-message.expired {
  border-color: #ef4444;
  background: rgba(239, 68, 68, .16);
  color: #fecaca;
}

.mysagre-final-message.called {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, .20);
  color: #fef3c7;
}

#mysagre-qr {
  display: grid;
  place-items: center;
  background: white;
  width: 280px;
  height: 280px;
  margin: 16px auto;
}

#mysagre-code {
  display: block;
  margin: 10px 0;
}

@media (max-width: 800px) {
  .mysagre-app {
    width: 100%;
    left: auto;
    transform: none;
    padding: 12px;
  }

  .mysagre-grid,
  .mysagre-two,
  .mysagre-stat-period,
  .mysagre-stat-cards,
  .mysagre-stat-grid {
    grid-template-columns: 1fr;
  }

  .mysagre-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .mysagre-product {
    padding: 10px 8px;
    gap: 6px;
  }

  .mysagre-product-actions {
    gap: 6px;
  }

  .mysagre-product-price {
    min-width: 58px;
  }

  .mysagre-quantity-control {
    grid-template-columns: 34px 24px 34px;
  }

  .mysagre-quantity-control button {
    width: 34px;
    height: 34px;
  }
}
