:root {
  --primary:      #f97316;
  --primary-dark: #ea580c;
  --bg:           #f3f4f6;
  --surface:      #ffffff;
  --border:       #e5e7eb;
  --text:         #111827;
  --text-muted:   #6b7280;
  --success:      #16a34a;
  --danger:       #dc2626;
  --radius:       12px;
  --shadow:       0 2px 8px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

/* ── Loading / empty ────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60vh;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 0.75rem; display: block; }

/* ── Header ─────────────────────────────────────────── */

.header {
  background: var(--primary);
  color: white;
  padding: 0.875rem 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1   { font-size: 1.2rem; font-weight: 700; }
.header .sub { font-size: 0.82rem; opacity: .9; margin-top: 0.1rem; }

/* ── Buttons ────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .75rem 1.4rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  line-height: 1;
}
.btn-primary  { background: var(--primary); color: white; }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-primary:active { transform: scale(.97); }
.btn-secondary { background: var(--surface); color: var(--primary); border: 2px solid var(--primary); }
.btn-outline   { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-success   { background: var(--success); color: white; }
.btn-danger    { background: var(--danger);  color: white; }
.btn-full      { width: 100%; }
.btn:disabled  { opacity: .5; cursor: not-allowed; }
.btn-sm        { padding: .45rem .9rem; font-size: .875rem; }

/* ── Cards ──────────────────────────────────────────── */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ── Produto ────────────────────────────────────────── */

.produto-card {
  display: flex;
  gap: .75rem;
  padding: .875rem;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}
.produto-card:last-child { border-bottom: none; }
.produto-card:active     { background: #f9fafb; }
.produto-card.indisponivel {
  opacity: .68;
  background: #f9fafb;
}

.produto-img-placeholder {
  width: 68px; height: 68px;
  border-radius: 8px;
  background: #f3f4f6;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.9rem;
  flex-shrink: 0;
}
.produto-info    { flex: 1; min-width: 0; }
.produto-nome    { font-weight: 600; font-size: .95rem; }
.produto-desc    { font-size: .8rem; color: var(--text-muted); margin: .15rem 0; }
.produto-preco   { font-weight: 700; color: var(--primary); }
.produto-tempo   { font-size: .75rem; color: var(--text-muted); }
.produto-estoque { font-size: .75rem; color: var(--text-muted); margin-top: .1rem; }
.produto-indisponivel-label {
  display: inline-flex;
  margin-top: .35rem;
  padding: .18rem .5rem;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 700;
}

.produto-add {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-shrink: 0;
}
.qty-btn {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  font-size: 1.2rem; font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
}
.qty-btn:active { transform: scale(.9); }
.qty-btn.minus  { background: #fee2e2; color: var(--danger); }
.qty-btn.plus   { background: var(--primary); color: white; }
.qty-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.qty-num        { font-weight: 700; min-width: 18px; text-align: center; }

/* ── Category label ─────────────────────────────────── */

.categoria-titulo {
  padding: 1rem 1rem .4rem;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}

/* ── Cart bar ───────────────────────────────────────── */

.cart-bar {
  position: fixed;
  bottom: 0;
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: var(--primary);
  color: white;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 200;
  cursor: pointer;
  font-weight: 600;
}
.cart-bar:hover { background: var(--primary-dark); }
.cart-bar-info  { display: flex; align-items: center; gap: .6rem; }
.cart-badge {
  background: white; color: var(--primary);
  border-radius: 50%;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .82rem;
}
.has-cart-bar { padding-bottom: 72px; }

/* ── Status badges ──────────────────────────────────── */

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: .22rem .6rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}
.status-novo        { background: #fef3c7; color: #92400e; }
.status-em_preparo  { background: #dbeafe; color: #1e40af; }
.status-pronto      { background: #dcfce7; color: #166534; }
.status-entregue    { background: #f3f4f6; color: #6b7280; }

/* ── Tabs ───────────────────────────────────────────── */

.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 56px;
  z-index: 90;
}
.tab {
  flex: 1;
  padding: .8rem;
  border: none;
  background: none;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
}
.tab.active  { color: var(--primary); border-bottom-color: var(--primary); }
.tab-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  border-radius: 999px;
  padding: 0 6px;
  font-size: .72rem;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Pedido items ───────────────────────────────────── */

.pedido-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem;
}
.pedido-item-info { flex: 1; min-width: 0; }
.pedido-item-nome { font-weight: 600; }
.pedido-item-qty  { font-size: .85rem; color: var(--text-muted); margin-top: .1rem; }
.cart-indisponivel { border: 1px solid #fecaca; }
.cart-alerta {
  margin-top: .35rem;
  color: var(--danger);
  font-size: .78rem;
  font-weight: 700;
}

/* ── Kitchen / Bar panels ───────────────────────────── */

.painel-header {
  background: #1f2937;
  color: white;
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.painel-header h1 { font-size: 1.2rem; font-weight: 700; }

.item-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 0 .75rem .75rem;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--border);
}
.item-card.novo       { border-left-color: #f59e0b; }
.item-card.em_preparo { border-left-color: #3b82f6; }
.item-card.pronto     { border-left-color: #22c55e; }

.item-mesa { font-size: .73rem; color: var(--text-muted); font-weight: 700; text-transform: uppercase; }
.item-nome { font-size: 1.05rem; font-weight: 700; margin: .2rem 0; }
.item-obs  { font-size: .83rem; color: var(--text-muted); font-style: italic; }
.item-actions { display: flex; gap: .5rem; margin-top: .65rem; }

/* ── Admin: mesas grid ──────────────────────────────── */

.stat-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .75rem;
  padding: 1rem;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.stat-card .value { font-size: 1.75rem; font-weight: 800; color: var(--primary); }
.stat-card .label { font-size: .78rem; color: var(--text-muted); margin-top: .2rem; }

.mesas-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .65rem;
  padding: 0 1rem 1rem;
}
.mesa-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: .875rem .5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 2px solid var(--border);
  transition: border-color .15s;
  user-select: none;
}
.mesa-card.ocupada         { border-color: #f59e0b; background: #fffbeb; }
.mesa-card.conta_solicitada{ border-color: #dc2626; background: #fef2f2; }
.mesa-card:active          { transform: scale(.96); }
.mesa-num    { font-size: 1.5rem; font-weight: 800; }
.mesa-status { font-size: .7rem; font-weight: 700; text-transform: uppercase; margin-top: .15rem; }

/* ── Modal ──────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
  z-index: 1000;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.25rem 1.25rem 0;
  -webkit-overflow-scrolling: touch;
}
.modal-title { font-size: 1.15rem; font-weight: 700; }

/* ── Name screen ────────────────────────────────────── */

.nome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
  text-align: center;
}
.nome-screen h1 { font-size: 1.75rem; font-weight: 800; color: var(--primary); margin-bottom: .4rem; }
.nome-screen p  { color: var(--text-muted); margin-bottom: 1.75rem; }

/* ── Login screen ───────────────────────────────────── */

.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}
.login-screen h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: 1.75rem; }

/* ── Inputs ─────────────────────────────────────────── */

.input-group { margin-bottom: .875rem; }
.input-group label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .88rem; }
.input-group input,
.input-group select,
.input-group textarea {
  width: 100%;
  padding: .825rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface);
  transition: border-color .15s;
}
.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Alerts ─────────────────────────────────────────── */

.alert {
  padding: .825rem 1rem;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 500;
}
.alert-success { background: #dcfce7; color: #166534; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info    { background: #dbeafe; color: #1e40af; }
.alert-danger  { background: #fee2e2; color: #991b1b; }

/* ── Section header ─────────────────────────────────── */

.section-header { padding: 1rem 1rem .4rem; font-size: 1rem; font-weight: 700; }

/* ── Divider ────────────────────────────────────────── */

.divider { height: 8px; background: var(--bg); }

/* ── Spinner ────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 3px solid rgba(255,255,255,.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Toast ──────────────────────────────────────────── */

.toast {
  position: fixed;
  top: 1rem;
  left: 50%; transform: translateX(-50%) translateY(-200%);
  background: #1f2937;
  color: white;
  padding: .875rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  z-index: 2000;
  transition: transform .3s ease;
  max-width: 340px;
  width: calc(100% - 2rem);
  text-align: center;
  font-size: .9rem;
  font-weight: 500;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ── Toggle switch ──────────────────────────────────── */

.toggle {
  position: relative;
  display: inline-block;
  width: 44px; height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 24px;
  cursor: pointer;
  transition: .2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: .2s;
}
.toggle input:checked + .toggle-slider              { background: var(--success); }
.toggle input:checked + .toggle-slider::before      { transform: translateX(20px); }

/* ── Produto admin card ──────────────────────────────── */

.produto-admin-card {
  display: flex;
  gap: .75rem;
  padding: .875rem;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.produto-admin-card:last-child { border-bottom: none; }

.produto-admin-img {
  width: 68px; height: 68px;
  border-radius: 8px;
  flex-shrink: 0;
  overflow: hidden;
  background: #f3f4f6;
}
.produto-admin-info  { flex: 1; min-width: 0; }
.produto-admin-nome  { font-weight: 700; font-size: .95rem; }
.produto-admin-meta  { font-size: .82rem; color: var(--text-muted); margin-top: .15rem; }
.produto-admin-desc  {
  font-size: .78rem; color: var(--text-muted); margin-top: .15rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Imagem produto (cliente) ───────────────────────── */

.produto-img {
  width: 68px; height: 68px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

/* ── Desktop border ─────────────────────────────────── */

@media (min-width: 480px) {
  #app { border: 1px solid var(--border); box-shadow: 0 0 40px rgba(0,0,0,.06); }
}
