/* === Reset & base ========================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  color: #222;
  background: #f4f6f8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin-top: 0; }
h1 { font-size: 1.6em; }
h2 { font-size: 1.25em; }

/* === Layout =============================================================== */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
  background: #1f2937;
  color: #f9fafb;
  box-shadow: 0 2px 4px rgba(0,0,0,.1);
}
.topbar .brand a { color: #fff; font-weight: 700; font-size: 1.15em; }
.topbar .mainnav { display: flex; gap: 16px; flex: 1; }
.topbar .mainnav a { color: #d1d5db; padding: 6px 10px; border-radius: 6px; }
.topbar .mainnav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.topbar .userbox { display: flex; align-items: center; gap: 12px; font-size: 0.9em; }
.topbar .userbox .user { color: #d1d5db; }
.topbar .userbox .user em { color: #9ca3af; font-style: normal; }
.serata-badge { background: #065f46; color: #ecfdf5; padding: 4px 10px; border-radius: 999px; font-size: 0.85em; }
.serata-badge.warn { background: #7f1d1d; color: #fee2e2; }

.main { flex: 1; padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }
.footer { text-align: center; padding: 12px; color: #6b7280; font-size: 0.85em; }

/* === Componenti =========================================================== */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  margin-bottom: 20px;
}

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 1em;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  line-height: 1.2;
  transition: background .1s;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; text-decoration: none; }
.btn-success { background: #059669; color: #fff; }
.btn-success:hover { background: #047857; text-decoration: none; }
.btn-danger  { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; }
.btn-ghost { background: transparent; color: #f9fafb; border-color: rgba(255,255,255,.3); }
.btn-ghost:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.btn-secondary { background: #e5e7eb; color: #374151; }
.btn-secondary:hover { background: #d1d5db; text-decoration: none; }
.btn-lg { padding: 12px 24px; font-size: 1.1em; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* === Form ================================================================= */
.form-group { margin-bottom: 14px; }
label { display: block; margin-bottom: 4px; font-weight: 500; color: #374151; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=email], select, textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 1em;
  font-family: inherit;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* === Flash ================================================================ */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error   { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; }
.flash-info    { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.flash-warn    { background: #fef3c7; color: #78350f; border: 1px solid #fcd34d; }

/* === Login page =========================================================== */
body.login {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea, #764ba2);
}
body.login .main { max-width: 400px; }
body.login .card { padding: 32px; }
body.login h1 { text-align: center; }

/* === Tabelle ============================================================== */
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; }
table.data th { background: #f9fafb; font-weight: 600; color: #374151; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.05em; }
table.data tr:hover td { background: #f9fafb; }
table.data td.right, table.data th.right { text-align: right; }
table.data td.center, table.data th.center { text-align: center; }

/* === Cassa ================================================================ */
.cassa-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .cassa-layout { grid-template-columns: 1fr; }
}

.menu-cat { margin-bottom: 24px; }
.menu-cat-title {
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 600;
  margin-bottom: 10px;
  display: inline-block;
}
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.menu-item {
  background: #fff;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 1em;
  transition: transform .05s, box-shadow .1s;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 80px;
}
.menu-item:hover:not([disabled]) { border-color: #2563eb; transform: translateY(-1px); box-shadow: 0 3px 8px rgba(0,0,0,.1); }
.menu-item:active:not([disabled]) { transform: translateY(0); }
.menu-item[disabled] { opacity: .45; cursor: not-allowed; }
.menu-item .name { font-weight: 600; margin-bottom: 6px; color: #1f2937; }
.menu-item .price { font-size: 0.95em; color: #059669; font-weight: 700; }
.menu-item .esaurito { font-size: 0.8em; color: #b91c1c; font-weight: 600; text-transform: uppercase; }
.menu-item .stock { font-size: 0.75em; color: #6b7280; margin-top: 2px; }
.menu-item .stock.low { color: #d97706; font-weight: 600; }
.menu-item .stock.warn { color: #b91c1c; font-weight: 600; }
.menu-item.menu-item-warn { border-color: #fca5a5; background: #fef2f2; }

.cart {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
}
.cart-header { padding: 16px; border-bottom: 1px solid #e5e7eb; }
.cart-header h2 { margin: 0; }
.cart-body { flex: 1; overflow-y: auto; padding: 8px 16px; }
.cart-empty { color: #9ca3af; text-align: center; padding: 30px 0; }
.cart-row {
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}
.cart-row:last-child { border-bottom: none; }
.cart-row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.cart-row-name { font-weight: 600; flex: 1; }
.cart-row-remove { background: none; border: none; color: #dc2626; cursor: pointer; font-size: 1.2em; padding: 0 4px; }
.cart-row-remove:hover { color: #991b1b; }
.cart-row-controls { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.qty-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  border: 1px solid #d1d5db;
  background: #fff;
  cursor: pointer;
  font-size: 1.1em;
  font-weight: 600;
  color: #374151;
}
.qty-btn:hover { background: #f3f4f6; }
.qty-value { min-width: 32px; text-align: center; font-weight: 600; font-size: 1.05em; }
.qty-price { flex: 1; text-align: right; color: #374151; font-weight: 600; }
.cart-row-note {
  width: 100%;
  margin-top: 6px;
  padding: 5px 8px;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: inherit;
}
.cart-footer { border-top: 2px solid #e5e7eb; padding: 16px; }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.4em; font-weight: 700; margin-bottom: 12px; }
.cart-total-val { color: #059669; }

/* === Subnav admin ========================================================= */
.subnav {
  display: flex;
  gap: 4px;
  background: #fff;
  border-radius: 10px;
  padding: 6px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  overflow-x: auto;
}
.subnav a {
  padding: 8px 14px;
  border-radius: 6px;
  color: #4b5563;
  font-weight: 500;
  white-space: nowrap;
}
.subnav a:hover { background: #f3f4f6; text-decoration: none; }
.subnav a.active { background: #2563eb; color: #fff; }

/* === Toolbar ============================================================== */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar h1 { margin: 0; }

/* === Badges =============================================================== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-neutral { background: #e5e7eb; color: #4b5563; }
.badge-danger  { background: #fee2e2; color: #991b1b; }

/* === Home / dashboard ===================================================== */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.dashboard-tile {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  text-align: center;
  transition: transform .1s, box-shadow .1s;
  color: #1f2937;
}
.dashboard-tile:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.1); text-decoration: none; }
.dashboard-tile .icon { font-size: 2.5em; margin-bottom: 10px; }
.dashboard-tile .title { font-size: 1.1em; font-weight: 600; margin-bottom: 4px; }
.dashboard-tile .desc { font-size: 0.85em; color: #6b7280; }
