:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --success: #22c55e;
  --error: #ef4444;
  --warning: #eab308;
  --info: #3b82f6;
  --radius: 10px;
  --font: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem;
  flex-shrink: 0;
}

.sidebar .brand {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.sidebar .brand-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.nav-group { margin-bottom: 1.25rem; }
.nav-group-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.nav-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  margin-bottom: 0.15rem;
}

.nav-link:hover, .nav-link.active {
  background: var(--surface2);
  color: var(--accent);
}

.main { flex: 1; display: flex; flex-direction: column; }

.topbar {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
}

.content { padding: 1.5rem; flex: 1; }

.page-title { font-size: 1.5rem; font-weight: 600; margin-bottom: 0.25rem; }
.page-subtitle { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.5rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

.stat-card {
  background: var(--surface2);
  border-radius: var(--radius);
  padding: 1rem;
}

.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.8rem; color: var(--muted); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { padding: 0.65rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; font-size: 0.75rem; text-transform: uppercase; }
tr:hover td { background: var(--surface2); }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-bar { background: #1e3a5f; color: #93c5fd; }
.badge-cocina { background: #3b2f1e; color: #fcd34d; }
.badge-parrilla { background: #3b1e1e; color: #fca5a5; }
.badge-alerta { background: #3b1e1e; color: var(--error); }
.badge-ok { background: #1e3b2f; color: var(--success); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover { background: var(--accent-hover); color: #000; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); color: var(--text); }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.35rem; }
.form-control {
  width: 100%;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
}
.form-control:focus { outline: none; border-color: var(--accent); }
select.form-control { cursor: pointer; }

.flash-messages { margin-bottom: 1rem; }
.flash {
  padding: 0.65rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}
.flash-success { background: #1e3b2f; color: var(--success); border: 1px solid #166534; }
.flash-error { background: #3b1e1e; color: var(--error); border: 1px solid #991b1b; }
.flash-info { background: #1e2a3b; color: var(--info); border: 1px solid #1d4ed8; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f1419 0%, #1a2332 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 1.5);
  padding: 2rem;
}

.login-card h1 { font-size: 1.4rem; margin-bottom: 0.25rem; }
.login-card p { color: var(--muted); font-size: 0.875rem; margin-bottom: 1.5rem; }

.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }

.margen-positivo { color: var(--success); }
.margen-negativo { color: var(--error); }

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

/* Mapa de mesas */
.mapa-container { overflow: hidden; }
.mapa-mesas {
  position: relative;
  width: 100%;
  min-height: 420px;
  background:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  background-color: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.mesa-item {
  position: absolute;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: grab;
  user-select: none;
  border: 3px solid transparent;
  transition: box-shadow 0.15s, transform 0.15s;
  font-size: 0.75rem;
}

.mesa-item:active { cursor: grabbing; }
.mesa-item.selected {
  box-shadow: 0 0 0 3px var(--accent);
  transform: scale(1.05);
  z-index: 10;
}

.mesa-libre { background: #1e3b2f; border-color: var(--success); color: var(--success); }
.mesa-ocupada { background: #3b1e1e; border-color: var(--error); color: #fca5a5; }
.mesa-reservada { background: #3b2f1e; border-color: var(--warning); color: #fcd34d; }

.mesa-num { font-size: 1.1rem; font-weight: 700; line-height: 1; }
.mesa-cap { font-size: 0.65rem; opacity: 0.8; }
.mesa-mesero { font-size: 0.6rem; margin-top: 2px; opacity: 0.9; }

.mapa-leyenda {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.mapa-leyenda span { display: flex; align-items: center; gap: 0.35rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-libre { background: var(--success); }
.dot-ocupada { background: var(--error); }
.dot-reservada { background: var(--warning); }

/* Pedidos POS */
.pedido-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.pedido-layout { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .pedido-layout { grid-template-columns: 1fr; } }

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 0.5rem;
  max-height: 320px;
  overflow-y: auto;
}

.menu-item-btn { margin: 0; }
.menu-tile {
  width: 100%;
  padding: 0.65rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.menu-tile:hover { border-color: var(--accent); background: var(--border); }
.menu-tile-name { font-size: 0.8rem; font-weight: 500; line-height: 1.2; }
.menu-tile-price { font-size: 0.85rem; color: var(--accent); font-weight: 600; }

.totales-box {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.totales-row {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.totales-total {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.badge-estado { text-transform: capitalize; }
.badge-pendiente { background: #1e2a3b; color: var(--info); }
.badge-preparacion { background: #3b2f1e; color: var(--warning); }
.badge-listo { background: #1e3b2f; color: var(--success); }
.badge-entregado { background: #1e3b2f; color: #86efac; }
.badge-pagado { background: #243044; color: var(--muted); }
.badge-cancelado { background: #3b1e1e; color: var(--error); }
.badge-confirmada { background: #1e3b2f; color: var(--success); }
.badge-completada { background: #243044; color: var(--muted); }
.badge-online { background: #1e3a5f; color: #93c5fd; margin-left: 0.25rem; font-size: 0.7rem; }
.badge-programado { background: #1e2a3b; color: var(--info); }
.badge-activo { background: #1e3b2f; color: var(--success); }
.badge-finalizado { background: #243044; color: var(--muted); }
.badge-ausente { background: #3b1e1e; color: var(--error); }
.badge-admin { background: #312e81; color: #c4b5fd; }
.badge-gerente { background: #1e3a5f; color: #93c5fd; }
.badge-cajero { background: #1e3b2f; color: #86efac; }
.badge-mesero { background: #3b2f1e; color: #fcd34d; }
.badge-cocina { background: #3b1e1e; color: #fca5a5; }
