* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
}

.app {
  max-width: 1200px;
  margin: 24px auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  min-height: 88vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon {
  width: 32px; height: 32px;
  background: #f59e0b;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.brand h1 { font-size: 15px; margin: 0; line-height: 1.2; }
.brand p { font-size: 12px; margin: 0; color: #94a3b8; }

.tabs { display: flex; gap: 4px; background: #f1f5f9; padding: 4px; border-radius: 10px; }
.tab-btn {
  border: none; background: none; padding: 7px 14px; font-size: 13px; font-weight: 600;
  color: #64748b; border-radius: 8px; cursor: pointer;
}
.tab-btn.activo { background: #fff; color: #1e293b; box-shadow: 0 1px 2px rgba(0,0,0,0.08); }

.btn {
  border: none; border-radius: 8px; padding: 8px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: #f59e0b; color: #fff; }
.btn-primary:hover { background: #d97706; }
.btn-secondary { background: #fff; border: 1px solid #cbd5e1; color: #475569; }
.btn-secondary:hover { background: #f8fafc; }
.btn-full { width: 100%; }
.btn-icon {
  background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; width: 32px; height: 32px;
  font-size: 15px; cursor: pointer; color: #64748b;
}

.save-error { background: #fef2f2; color: #dc2626; font-size: 12px; padding: 8px 20px; }

.tab-panel { padding: 20px; flex: 1; }

/* ---- Catálogo ---- */
.panel-toolbar { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-toolbar input {
  flex: 1; max-width: 320px; padding: 9px 12px; font-size: 13px;
  border: 1px solid #e2e8f0; border-radius: 8px; outline: none;
}
.panel-toolbar input:focus { box-shadow: 0 0 0 2px #fcd34d; }

.tabla-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: #94a3b8; font-weight: 600; font-size: 11px; text-transform: uppercase; padding: 8px 10px; border-bottom: 1px solid #e2e8f0; }
td { padding: 10px; border-bottom: 1px solid #f1f5f9; }
tr.inactivo td { opacity: 0.45; }
.stock-bajo { color: #dc2626; font-weight: 700; }
.fila-link { cursor: pointer; }
.fila-link:hover { background: #f8fafc; }
.mini-btn {
  border: 1px solid #cbd5e1; background: #fff; border-radius: 6px;
  padding: 3px 8px; font-size: 11px; cursor: pointer; color: #475569;
}

/* ---- POS ---- */
.pos-layout { display: flex; gap: 20px; align-items: flex-start; }
.pos-productos { flex: 1; min-width: 0; }
.pos-productos input {
  width: 100%; padding: 9px 12px; font-size: 13px; margin-bottom: 12px;
  border: 1px solid #e2e8f0; border-radius: 8px; outline: none;
}
.grid-pos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pos-card {
  border: 1px solid #e2e8f0; border-radius: 10px; padding: 10px; text-align: left;
  background: #fff; cursor: pointer;
}
.pos-card:hover { border-color: #f59e0b; }
.pos-card:disabled { opacity: 0.4; cursor: not-allowed; }
.pos-card-nombre { font-size: 13px; font-weight: 600; margin: 0 0 4px; }
.pos-card-precio { font-size: 13px; color: #f59e0b; font-weight: 700; margin: 0; }
.pos-card-stock { font-size: 11px; color: #94a3b8; margin: 2px 0 0; }

.pos-carrito {
  width: 300px; flex-shrink: 0; border: 1px solid #e2e8f0; border-radius: 10px; padding: 14px;
}
.pos-carrito h3 { margin: 0 0 10px; font-size: 14px; }
.carrito-items { max-height: 220px; overflow-y: auto; margin-bottom: 10px; }
.carrito-item { display: flex; align-items: center; justify-content: space-between; font-size: 12px; padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
.carrito-item-nombre { flex: 1; margin-right: 6px; }
.qty-controls { display: flex; align-items: center; gap: 4px; }
.qty-controls button { width: 20px; height: 20px; border: 1px solid #cbd5e1; background: #fff; border-radius: 5px; cursor: pointer; font-size: 12px; line-height: 1; }
.carrito-vacio { font-size: 12px; color: #94a3b8; padding: 10px 0; }
.carrito-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 14px; margin: 8px 0 14px; }
.pos-carrito label { font-size: 11px; color: #64748b; display: block; margin: 8px 0 4px; }
.pos-carrito input, .pos-carrito select {
  width: 100%; padding: 7px 9px; font-size: 13px; border: 1px solid #e2e8f0; border-radius: 8px; outline: none;
}

/* ---- Historial ---- */
.venta-card { border: 1px solid #e2e8f0; border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.venta-card-top { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.venta-num { font-family: monospace; font-size: 12px; color: #94a3b8; }
.venta-cliente { font-size: 13px; font-weight: 600; margin: 2px 0 0; }
.venta-fecha { font-size: 11px; color: #94a3b8; }
.venta-total { font-weight: 700; color: #f59e0b; }
.venta-items { margin-top: 10px; padding-top: 10px; border-top: 1px solid #f1f5f9; font-size: 12px; }
.venta-items div { display: flex; justify-content: space-between; padding: 3px 0; }
.lista-vacia { padding: 24px; text-align: center; font-size: 13px; color: #94a3b8; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #e2e8f0; }
.modal-header h2 { font-size: 15px; margin: 0; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px; border-top: 1px solid #e2e8f0; }
.modal-body label { font-size: 11px; color: #64748b; display: block; }
.modal-body input, .modal-body select {
  width: 100%; margin-top: 4px; padding: 7px 9px; font-size: 13px;
  border: 1px solid #e2e8f0; border-radius: 8px; outline: none;
}
.grid-2c { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cat-row { display: flex; gap: 6px; align-items: center; }
.cat-row select { margin-top: 4px; }
.error-msg { color: #dc2626; font-size: 11px; }
